moved (and renamed) global variables to game structure (ZX/ZY)
[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 GlobalInfo_MM
63 {
64 };
65
66 struct CycleList
67 {
68   int x, y;
69   int steps;
70 };
71
72 struct MovingList
73 {
74   int x, y;
75   int dir;
76 };
77
78 struct DamageList
79 {
80   int x, y;
81   int edge, angle;
82   boolean is_mirror;
83 };
84
85 struct BeamerInfo
86 {
87   int x, y;
88   int num;
89 };
90
91 struct PacMan
92 {
93   int XP, YP;
94   int Dr;
95 };
96
97 struct LaserInfo
98 {
99   struct XY start_edge;
100   int start_angle;
101
102   int current_angle;
103
104   struct DamageList damage[MAX_LASER_LEN + 10];
105   int num_damages;
106
107   struct XY edge[MAX_LASER_LEN + 10];
108   int num_edges;
109
110   struct BeamerInfo beamer[MAX_NUM_BEAMERS][2];
111   int beamer_edge[MAX_NUM_BEAMERS];
112   int beamer_nr[MAX_NUM_BEAMERS];
113   int num_beamers;
114
115   boolean overloaded;
116   int overload_value;
117
118   boolean fuse_off;
119   int fuse_x, fuse_y;
120
121   int dest_element;
122   boolean stops_inside_element;
123
124   boolean redraw;
125
126   int wall_mask;
127 };
128
129 struct GameInfo_MM
130 {
131   boolean LevelSolved;
132   boolean GameOver;
133
134   struct CycleList cycle[MM_MAX_PLAYFIELD_SIZE];
135   int num_cycle;
136
137   struct MovingList pacman[MM_MAX_PLAYFIELD_SIZE];
138   int num_pacman;
139
140   int score;
141   int energy_left;
142   int kettles_still_needed;
143   int lights_still_needed;
144   int num_keys;
145
146   boolean level_solved;
147   boolean game_over;
148   int game_over_cause;
149
150   boolean cheat_no_overload;
151   boolean cheat_no_explosion;
152
153   int laser_overload_value;
154   boolean laser_enabled;
155 };
156
157 struct LevelInfo_MM
158 {
159   int file_version;             // version of file the level was stored with
160   int game_version;             // version of game engine to play this level
161   boolean encoding_16bit_field;         // level contains 16-bit elements
162
163   int fieldx;
164   int fieldy;
165   int time;
166   int kettles_needed;
167   boolean auto_count_kettles;
168   boolean laser_red, laser_green, laser_blue;
169   char name[MM_MAX_LEVEL_NAME_LEN + 1];
170   char author[MM_MAX_LEVEL_AUTHOR_LEN + 1];
171   int score[MM_LEVEL_SCORE_ELEMENTS];
172   int amoeba_speed;
173   int time_fuse;
174   int time_bomb;
175   int time_ball;
176   int time_block;
177
178   short field[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
179 };
180
181 struct GraphicInfo_MM
182 {
183 };
184
185 struct EngineSnapshotInfo_MM
186 {
187   struct GameInfo_MM game_mm;
188
189   struct LaserInfo laser;
190
191   short Ur[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
192   short Hit[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
193   short Box[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
194   short Angle[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
195   short Frame[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT];
196
197   short LX,LY, XS,YS, ELX,ELY;
198   short CT,Ct;
199
200   int last_LX, last_LY, last_hit_mask;
201   int hold_x, hold_y;
202   int pacman_nr;
203
204   unsigned int rotate_delay;
205   unsigned int pacman_delay;
206   unsigned int energy_delay;
207   unsigned int overload_delay;
208 };
209
210
211 // ----------------------------------------------------------------------------
212 // exported functions
213 // ----------------------------------------------------------------------------
214
215 extern struct GlobalInfo_MM global_mm_info;
216 extern struct GameInfo_MM game_mm;
217 extern struct LevelInfo_MM native_mm_level;
218 extern struct EngineSnapshotInfo_MM engine_snapshot_mm;
219
220 extern short Ur[MM_MAX_PLAYFIELD_WIDTH][MM_MAX_PLAYFIELD_HEIGHT];
221
222 void mm_open_all(void);
223 void mm_close_all(void);
224
225 void InitElementProperties_MM(void);
226
227 void InitGfxBuffers_MM(void);
228
229 void InitGameEngine_MM(void);
230 void InitGameActions_MM(void);
231 void GameActions_MM(struct MouseActionInfo, boolean);
232
233 void DrawLaser_MM(void);
234
235 boolean ClickElement(int, int, int);
236
237 unsigned int InitEngineRandom_MM(int);
238
239 void setLevelInfoToDefaults_MM(void);
240 void copyInternalEngineVars_MM(void);
241 boolean LoadNativeLevel_MM(char *, boolean);
242 void SaveNativeLevel_MM(char *);
243
244 int getFieldbufferOffsetX_MM(void);
245 int getFieldbufferOffsetY_MM(void);
246
247 void BlitScreenToBitmap_MM(Bitmap *);
248 void RedrawPlayfield_MM(void);
249
250 void LoadEngineSnapshotValues_MM(void);
251 void SaveEngineSnapshotValues_MM(ListNode **);
252
253 int getButtonFromTouchPosition(int, int, int, int);
254
255 #endif  // GAME_MM_EXPORT_H