changed using macros for checking sound and music loops
[rocksndiamonds.git] / src / game_mm / export.h
1 #ifndef GAME_MM_EXPORT_H
2 #define GAME_MM_EXPORT_H
3
4 // ============================================================================
5 // functions and definitions exported from game_mm to main program
6 // ============================================================================
7
8 // ----------------------------------------------------------------------------
9 // constant definitions
10 // ----------------------------------------------------------------------------
11
12 #define MM_MAX_PLAYFIELD_WIDTH          MAX_PLAYFIELD_WIDTH
13 #define MM_MAX_PLAYFIELD_HEIGHT         MAX_PLAYFIELD_HEIGHT
14
15 #define MM_STD_PLAYFIELD_WIDTH          16
16 #define MM_STD_PLAYFIELD_HEIGHT         12
17
18 #define MM_MAX_PLAYFIELD_SIZE           (MM_MAX_PLAYFIELD_WIDTH *       \
19                                          MM_MAX_PLAYFIELD_HEIGHT)
20
21 #define MAX_NUM_AMOEBA                  100
22 #define MAX_NUM_BEAMERS                 8
23
24 #define MAX_LASER_LEN                   256
25 #define MAX_LASER_ENERGY                100
26 #define MAX_LASER_OVERLOAD              100
27
28 #define MM_LEVEL_SCORE_ELEMENTS         16
29
30 #define MM_MAX_LEVEL_NAME_LEN           32
31 #define MM_MAX_LEVEL_AUTHOR_LEN         32
32
33
34 #define EL_MM_START_1_NATIVE            0
35 #define EL_MM_END_1_NATIVE              155
36
37 #define EL_MM_CHAR_START_NATIVE         160
38 #define EL_MM_CHAR_END_NATIVE           239
39
40 #define EL_MM_START_2_NATIVE            240
41 #define EL_MM_END_2_NATIVE              430
42
43 #define EL_MM_RUNTIME_START_NATIVE      500
44 #define EL_MM_RUNTIME_END_NATIVE        504
45
46 #define EL_MM_DUMMY_START_NATIVE        700
47 #define EL_MM_DUMMY_END_NATIVE          709
48
49 // elements to be specially mapped
50 #define EL_MM_EMPTY_NATIVE              0
51 #define EL_DF_EMPTY_NATIVE              304
52
53 // sounds
54 #define SND_MM_GAME_LEVELTIME_CHARGING  0
55 #define SND_MM_GAME_HEALTH_CHARGING     1
56
57
58 // ----------------------------------------------------------------------------
59 // data structure definitions
60 // ----------------------------------------------------------------------------
61
62 struct CycleList
63 {
64   int x, y;
65   int steps;
66 };
67
68 struct MovingList
69 {
70   int x, y;
71   int dir;
72 };
73
74 struct DamageList
75 {
76   int x, y;
77   int edge, angle;
78   boolean is_mirror;
79 };
80
81 struct BeamerInfo
82 {
83   int x, y;
84   int num;
85 };
86
87 struct PacMan
88 {
89   int XP, YP;
90   int Dr;
91 };
92
93 struct LaserInfo
94 {
95   struct XY start_edge;
96   int start_angle;
97
98   int current_angle;
99
100   struct DamageList damage[MAX_LASER_LEN + 10];
101   int num_damages;
102
103   struct XY edge[MAX_LASER_LEN + 10];
104   int num_edges;
105
106   struct BeamerInfo beamer[MAX_NUM_BEAMERS][2];
107   int beamer_edge[MAX_NUM_BEAMERS];
108   int beamer_nr[MAX_NUM_BEAMERS];
109   int num_beamers;
110
111   boolean overloaded;
112   int overload_value;
113
114   boolean fuse_off;
115   int fuse_x, fuse_y;
116
117   int dest_element;
118   boolean stops_inside_element;
119
120   boolean redraw;
121
122   int wall_mask;
123 };
124
125 struct GameInfo_MM
126 {
127   boolean LevelSolved;
128   boolean GameOver;
129
130   struct CycleList cycle[MM_MAX_PLAYFIELD_SIZE];
131   int num_cycle;
132
133   struct MovingList pacman[MM_MAX_PLAYFIELD_SIZE];
134   int num_pacman;
135
136   int score;
137   int energy_left;
138   int kettles_still_needed;
139   int lights_still_needed;
140   int num_keys;
141
142   boolean level_solved;
143   boolean game_over;
144   int game_over_cause;
145
146   boolean cheat_no_overload;
147   boolean cheat_no_explosion;
148
149   int laser_overload_value;
150   boolean laser_enabled;
151 };
152
153 struct LevelInfo_MM
154 {
155   int file_version;             // version of file the level was stored with
156   int game_version;             // version of game engine to play this level
157   boolean encoding_16bit_field;         // level contains 16-bit elements
158
159   int fieldx;
160   int fieldy;
161   int time;
162   int kettles_needed;
163   boolean auto_count_kettles;
164   boolean laser_red, laser_green, laser_blue;
165   char name[MM_MAX_LEVEL_NAME_LEN + 1];
166   char author[MM_MAX_LEVEL_AUTHOR_LEN + 1];
167   int score[MM_LEVEL_SCORE_ELEMENTS];
168   int amoeba_speed;
169   int time_fuse;
170   int time_bomb;
171   int time_ball;
172   int time_block;
173
174   short field[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
175 };
176
177 struct EngineSnapshotInfo_MM
178 {
179   struct GameInfo_MM game_mm;
180
181   struct LaserInfo laser;
182
183   short Ur[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
184   short Hit[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
185   short Box[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
186   short Angle[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
187   short Frame[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
188
189   short LX,LY, XS,YS, ELX,ELY;
190   short CT,Ct;
191
192   int last_LX, last_LY, last_hit_mask;
193   int hold_x, hold_y;
194   int pacman_nr;
195
196   unsigned int rotate_delay;
197   unsigned int pacman_delay;
198   unsigned int energy_delay;
199   unsigned int overload_delay;
200 };
201
202
203 // ----------------------------------------------------------------------------
204 // exported functions
205 // ----------------------------------------------------------------------------
206
207 extern struct GameInfo_MM game_mm;
208 extern struct LevelInfo_MM native_mm_level;
209 extern struct EngineSnapshotInfo_MM engine_snapshot_mm;
210
211 extern short Ur[MM_MAX_PLAYFIELD_WIDTH][MM_MAX_PLAYFIELD_HEIGHT];
212
213 void mm_open_all(void);
214 void mm_close_all(void);
215
216 void InitElementProperties_MM(void);
217
218 void InitGfxBuffers_MM(void);
219
220 void InitGameEngine_MM(void);
221 void InitGameActions_MM(void);
222 void GameActions_MM(struct MouseActionInfo, boolean);
223
224 void DrawLaser_MM(void);
225 void DrawTileCursor_MM(int, boolean);
226
227 boolean ClickElement(int, int, int);
228
229 unsigned int InitEngineRandom_MM(int);
230
231 void setLevelInfoToDefaults_MM(void);
232 void copyInternalEngineVars_MM(void);
233 boolean LoadNativeLevel_MM(char *, boolean);
234 void SaveNativeLevel_MM(char *);
235
236 int getFieldbufferOffsetX_MM(void);
237 int getFieldbufferOffsetY_MM(void);
238
239 void BlitScreenToBitmap_MM(Bitmap *);
240 void RedrawPlayfield_MM(void);
241
242 void LoadEngineSnapshotValues_MM(void);
243 void SaveEngineSnapshotValues_MM(ListNode **);
244
245 int getButtonFromTouchPosition(int, int, int, int);
246
247 #endif  // GAME_MM_EXPORT_H