rnd-20050115-1-src
[rocksndiamonds.git] / src / game_em / main_em.h
1 #ifndef MAIN_EM_H
2 #define MAIN_EM_H
3
4 #include "../engines.h"
5
6
7 /* 2000-07-30T11:06:03Z ---------------------------------------------------- */
8
9 #define EM_MAX_CAVE_WIDTH               102
10 #define EM_MAX_CAVE_HEIGHT              102
11
12 /* define these for backwards compatibility */
13 #define EM_ENGINE_BAD_ROLL
14 #define EM_ENGINE_BAD_SPRING
15
16
17 /*
18   -----------------------------------------------------------------------------
19   definition of elements used in the Emerald Mine Club engine;
20   the element names have the following properties:
21   - elements that start with an 'X' can be stored in a level file;
22   - elements that start with an 'Y' indicate moving elements;
23   - elements that end with a 'B' are the "backside" of a moving element.
24   -----------------------------------------------------------------------------
25 */
26
27 enum
28 {
29   Xblank = 0,           /* still */
30   Yacid_splash_eB,      /* hmm */
31   Yacid_splash_wB,      /* hmm */
32
33 #ifdef EM_ENGINE_BAD_ROLL
34   Xstone_force_e,       /* only use these in eater */
35   Xstone_force_w,
36   Xnut_force_e,
37   Xnut_force_w,
38   Xspring_force_e,
39   Xspring_force_w,
40   Xemerald_force_e,
41   Xemerald_force_w,
42   Xdiamond_force_e,
43   Xdiamond_force_w,
44   Xbomb_force_e,
45   Xbomb_force_w,
46 #endif
47
48   Xstone,
49   Xstone_pause,
50   Xstone_fall,
51   Ystone_s,
52   Ystone_sB,
53   Ystone_e,
54   Ystone_eB,
55   Ystone_w,
56   Ystone_wB,
57   Xnut,
58   Xnut_pause,
59   Xnut_fall,
60   Ynut_s,
61   Ynut_sB,
62   Ynut_e,
63   Ynut_eB,
64   Ynut_w,
65   Ynut_wB,
66   Xbug_n,
67   Xbug_e,
68   Xbug_s,
69   Xbug_w,
70   Xbug_gon,
71   Xbug_goe,
72   Xbug_gos,
73   Xbug_gow,
74   Ybug_n,
75   Ybug_nB,
76   Ybug_e,
77   Ybug_eB,
78   Ybug_s,
79   Ybug_sB,
80   Ybug_w,
81   Ybug_wB,
82   Ybug_w_n,
83   Ybug_n_e,
84   Ybug_e_s,
85   Ybug_s_w,
86   Ybug_e_n,
87   Ybug_s_e,
88   Ybug_w_s,
89   Ybug_n_w,
90   Ybug_stone,
91   Ybug_spring,
92   Xtank_n,
93   Xtank_e,
94   Xtank_s,
95   Xtank_w,
96   Xtank_gon,
97   Xtank_goe,
98   Xtank_gos,
99   Xtank_gow,
100   Ytank_n,
101   Ytank_nB,
102   Ytank_e,
103   Ytank_eB,
104   Ytank_s,
105   Ytank_sB,
106   Ytank_w,
107   Ytank_wB,
108   Ytank_w_n,
109   Ytank_n_e,
110   Ytank_e_s,
111   Ytank_s_w,
112   Ytank_e_n,
113   Ytank_s_e,
114   Ytank_w_s,
115   Ytank_n_w,
116   Ytank_stone,
117   Ytank_spring,
118   Xandroid,
119   Xandroid_1_n,
120   Xandroid_2_n,
121   Xandroid_1_e,
122   Xandroid_2_e,
123   Xandroid_1_w,
124   Xandroid_2_w,
125   Xandroid_1_s,
126   Xandroid_2_s,
127   Yandroid_n,
128   Yandroid_nB,
129   Yandroid_ne,
130   Yandroid_neB,
131   Yandroid_e,
132   Yandroid_eB,
133   Yandroid_se,
134   Yandroid_seB,
135   Yandroid_s,
136   Yandroid_sB,
137   Yandroid_sw,
138   Yandroid_swB,
139   Yandroid_w,
140   Yandroid_wB,
141   Yandroid_nw,
142   Yandroid_nwB,
143   Xspring,
144   Xspring_pause,
145   Xspring_e,
146   Xspring_w,
147   Xspring_fall,
148   Yspring_s,
149   Yspring_sB,
150   Yspring_e,
151   Yspring_eB,
152   Yspring_w,
153   Yspring_wB,
154   Yspring_kill_e,
155   Yspring_kill_eB,
156   Yspring_kill_w,
157   Yspring_kill_wB,
158   Xeater_n,
159   Xeater_e,
160   Xeater_w,
161   Xeater_s,
162   Yeater_n,
163   Yeater_nB,
164   Yeater_e,
165   Yeater_eB,
166   Yeater_s,
167   Yeater_sB,
168   Yeater_w,
169   Yeater_wB,
170   Yeater_stone,
171   Yeater_spring,
172   Xalien,
173   Xalien_pause,
174   Yalien_n,
175   Yalien_nB,
176   Yalien_e,
177   Yalien_eB,
178   Yalien_s,
179   Yalien_sB,
180   Yalien_w,
181   Yalien_wB,
182   Yalien_stone,
183   Yalien_spring,
184   Xemerald,
185   Xemerald_pause,
186   Xemerald_fall,
187   Xemerald_shine,
188   Yemerald_s,
189   Yemerald_sB,
190   Yemerald_e,
191   Yemerald_eB,
192   Yemerald_w,
193   Yemerald_wB,
194   Yemerald_eat,
195   Yemerald_stone,
196   Xdiamond,
197   Xdiamond_pause,
198   Xdiamond_fall,
199   Xdiamond_shine,
200   Ydiamond_s,
201   Ydiamond_sB,
202   Ydiamond_e,
203   Ydiamond_eB,
204   Ydiamond_w,
205   Ydiamond_wB,
206   Ydiamond_eat,
207   Ydiamond_stone,
208   Xdrip_fall,
209   Xdrip_stretch,
210   Xdrip_stretchB,
211   Xdrip_eat,
212   Ydrip_s1,
213   Ydrip_s1B,
214   Ydrip_s2,
215   Ydrip_s2B,
216   Xbomb,
217   Xbomb_pause,
218   Xbomb_fall,
219   Ybomb_s,
220   Ybomb_sB,
221   Ybomb_e,
222   Ybomb_eB,
223   Ybomb_w,
224   Ybomb_wB,
225   Ybomb_eat,
226   Xballoon,
227   Yballoon_n,
228   Yballoon_nB,
229   Yballoon_e,
230   Yballoon_eB,
231   Yballoon_s,
232   Yballoon_sB,
233   Yballoon_w,
234   Yballoon_wB,
235   Xgrass,
236   Ygrass_nB,
237   Ygrass_eB,
238   Ygrass_sB,
239   Ygrass_wB,
240   Xdirt,
241   Ydirt_nB,
242   Ydirt_eB,
243   Ydirt_sB,
244   Ydirt_wB,
245   Xacid_ne,
246   Xacid_se,
247   Xacid_s,
248   Xacid_sw,
249   Xacid_nw,
250   Xacid_1,
251   Xacid_2,
252   Xacid_3,
253   Xacid_4,
254   Xacid_5,
255   Xacid_6,
256   Xacid_7,
257   Xacid_8,
258   Xball_1,
259   Xball_1B,
260   Xball_2,
261   Xball_2B,
262   Yball_eat,
263
264 #if 1
265   Ykey_1_eat,
266   Ykey_2_eat,
267   Ykey_3_eat,
268   Ykey_4_eat,
269   Ykey_5_eat,
270   Ykey_6_eat,
271   Ykey_7_eat,
272   Ykey_8_eat,
273   Ylenses_eat,
274   Ymagnify_eat,
275   Ygrass_eat,
276   Ydirt_eat,
277 #endif
278
279   Xgrow_ns,
280   Ygrow_ns_eat,
281   Xgrow_ew,
282   Ygrow_ew_eat,
283   Xwonderwall,
284   XwonderwallB,
285   Xamoeba_1,
286   Xamoeba_2,
287   Xamoeba_3,
288   Xamoeba_4,
289   Xamoeba_5,
290   Xamoeba_6,
291   Xamoeba_7,
292   Xamoeba_8,
293   Xdoor_1,
294   Xdoor_2,
295   Xdoor_3,
296   Xdoor_4,
297   Xdoor_5,
298   Xdoor_6,
299   Xdoor_7,
300   Xdoor_8,
301   Xkey_1,
302   Xkey_2,
303   Xkey_3,
304   Xkey_4,
305   Xkey_5,
306   Xkey_6,
307   Xkey_7,
308   Xkey_8,
309   Xwind_n,
310   Xwind_e,
311   Xwind_s,
312   Xwind_w,
313   Xwind_nesw,
314   Xwind_stop,
315   Xexit,
316   Xexit_1,
317   Xexit_2,
318   Xexit_3,
319   Xdynamite,
320   Ydynamite_eat,
321   Xdynamite_1,
322   Xdynamite_2,
323   Xdynamite_3,
324   Xdynamite_4,
325   Xbumper,
326   XbumperB,
327   Xwheel,
328   XwheelB,
329   Xswitch,
330   XswitchB,
331   Xsand,
332   Xsand_stone,
333   Xsand_stonein_1,
334   Xsand_stonein_2,
335   Xsand_stonein_3,
336   Xsand_stonein_4,
337   Xsand_stonesand_1,
338   Xsand_stonesand_2,
339   Xsand_stonesand_3,
340   Xsand_stonesand_4,
341   Xsand_stoneout_1,
342   Xsand_stoneout_2,
343   Xsand_sandstone_1,
344   Xsand_sandstone_2,
345   Xsand_sandstone_3,
346   Xsand_sandstone_4,
347   Xplant,
348   Yplant,
349   Xlenses,
350   Xmagnify,
351   Xdripper,
352   XdripperB,
353   Xfake_blank,
354   Xfake_blankB,
355   Xfake_grass,
356   Xfake_grassB,
357   Xfake_door_1,
358   Xfake_door_2,
359   Xfake_door_3,
360   Xfake_door_4,
361   Xfake_door_5,
362   Xfake_door_6,
363   Xfake_door_7,
364   Xfake_door_8,
365   Xsteel_1,
366   Xsteel_2,
367   Xsteel_3,
368   Xsteel_4,
369   Xwall_1,
370   Xwall_2,
371   Xwall_3,
372   Xwall_4,
373   Xround_wall_1,
374   Xround_wall_2,
375   Xround_wall_3,
376   Xround_wall_4,
377   Xdecor_1,
378   Xdecor_2,
379   Xdecor_3,
380   Xdecor_4,
381   Xdecor_5,
382   Xdecor_6,
383   Xdecor_7,
384   Xdecor_8,
385   Xdecor_9,
386   Xdecor_10,
387   Xdecor_11,
388   Xdecor_12,
389   Xalpha_0,
390   Xalpha_1,
391   Xalpha_2,
392   Xalpha_3,
393   Xalpha_4,
394   Xalpha_5,
395   Xalpha_6,
396   Xalpha_7,
397   Xalpha_8,
398   Xalpha_9,
399   Xalpha_excla,
400   Xalpha_quote,
401   Xalpha_comma,
402   Xalpha_minus,
403   Xalpha_perio,
404   Xalpha_colon,
405   Xalpha_quest,
406   Xalpha_a,
407   Xalpha_b,
408   Xalpha_c,
409   Xalpha_d,
410   Xalpha_e,
411   Xalpha_f,
412   Xalpha_g,
413   Xalpha_h,
414   Xalpha_i,
415   Xalpha_j,
416   Xalpha_k,
417   Xalpha_l,
418   Xalpha_m,
419   Xalpha_n,
420   Xalpha_o,
421   Xalpha_p,
422   Xalpha_q,
423   Xalpha_r,
424   Xalpha_s,
425   Xalpha_t,
426   Xalpha_u,
427   Xalpha_v,
428   Xalpha_w,
429   Xalpha_x,
430   Xalpha_y,
431   Xalpha_z,
432   Xalpha_arrow_e,
433   Xalpha_arrow_w,
434   Xalpha_copyr,
435
436   Xboom_bug,            /* passed from explode to synchro (linked explosion);
437                            transition to explode_normal */
438   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
439                            transition to explode_normal */
440   Xboom_android,        /* passed from explode to synchro;
441                            transition to boom_2 */
442   Xboom_1,              /* passed from explode to synchro;
443                            transition to boom_2 */
444   Xboom_2,              /* transition to boom[] */
445
446   Znormal,              /* passed from synchro to explode, only in next[];
447                            no picture */
448   Zdynamite,            /* passed from synchro to explode, only in next[];
449                            no picture */
450   Zplayer,              /* special code to indicate player;
451                            no picture */
452   ZBORDER,              /* special code to indicate border;
453                            no picture */
454
455   TILE_MAX
456 };
457
458 enum
459 {
460   SPR_still = 0,
461   SPR_walk  = 1,
462   SPR_push  = 5,
463   SPR_spray = 9,
464
465   SPR_MAX   = 13
466 };
467
468 enum
469 {
470   SAMPLE_blank = 0,     /* player walks on blank */
471   SAMPLE_roll,          /* player pushes stone/bomb/nut/spring */
472   SAMPLE_stone,         /* stone hits ground */
473   SAMPLE_nut,           /* nut hits ground */
474   SAMPLE_crack,         /* stone hits nut */
475   SAMPLE_bug,           /* bug moves */
476   SAMPLE_tank,          /* tank moves */
477   SAMPLE_android,       /* android places something */
478   SAMPLE_spring,        /* spring hits ground/wall/bumper, stone hits spring */
479   SAMPLE_slurp,         /* spring kills alien */
480   SAMPLE_eater,         /* eater sits/eats diamond */
481   SAMPLE_alien,         /* alien moves */
482   SAMPLE_collect,       /* player collects object */
483   SAMPLE_diamond,       /* diamond/emerald hits ground */
484   SAMPLE_squash,        /* stone squashes diamond */
485   SAMPLE_wonderfall,    /* object falls thru wonderwall */
486   SAMPLE_drip,          /* drip hits ground */
487   SAMPLE_push,          /* player pushes balloon/android */
488   SAMPLE_dirt,          /* player walks on dirt */
489   SAMPLE_acid,          /* acid splashes */
490   SAMPLE_ball,          /* ball places something */
491   SAMPLE_grow,          /* growing wall grows */
492   SAMPLE_wonder,        /* wonderwall is active */
493   SAMPLE_door,          /* player goes thru door (gate) */
494   SAMPLE_exit,          /* player goes into exit */
495   SAMPLE_dynamite,      /* player places dynamite */
496   SAMPLE_tick,          /* dynamite ticks */
497   SAMPLE_press,         /* player presses wheel/wind/switch */
498   SAMPLE_wheel,         /* wheel moves */
499   SAMPLE_boom,          /* explosion */
500   SAMPLE_time,          /* time runs out */
501   SAMPLE_die,           /* player dies */
502
503   SAMPLE_MAX
504 };
505
506 struct LEVEL
507 {
508   unsigned int home_initial;          /* number of players (initial) */
509   unsigned int home;                  /* number of players not yet at home */
510                                       /* 0 == all players at home */
511
512   unsigned int width;                 /* playfield width */
513   unsigned int height;                /* playfield height */
514
515   unsigned int time_seconds;          /* available time (seconds) */
516   unsigned int time_initial;          /* available time (initial) */
517   unsigned int time;                  /* time remaining (runtime) */
518
519   unsigned int required_initial;      /* emeralds needed (initial) */
520   unsigned int required;              /* emeralds needed (runtime) */
521
522   unsigned int score;                 /* score */
523
524   /* fill in all below /every/ time you read a level */
525   unsigned int alien_score;           /* alien popped by stone/spring score */
526   unsigned int amoeba_time;           /* amoeba speed */
527   unsigned int android_move_cnt_initial; /* android move time counter (initial) */
528   unsigned int android_move_cnt;      /* android move time counter */
529   unsigned int android_move_time;     /* android move reset time */
530   unsigned int android_clone_cnt_initial; /* android clone time counter (initial) */
531   unsigned int android_clone_cnt;     /* android clone time counter */
532   unsigned int android_clone_time;    /* android clone reset time */
533   unsigned int ball_cnt;              /* ball time counter */
534   unsigned int ball_pos;              /* ball array pos counter */
535   unsigned int ball_random;           /* ball is random flag */
536   unsigned int ball_state_initial;    /* ball currently on flag (initial) */
537   unsigned int ball_state;            /* ball currently on flag */
538   unsigned int ball_time;             /* ball reset time */
539   unsigned int bug_score;             /* bug popped by stone/spring score */
540   unsigned int diamond_score;         /* diamond collect score */
541   unsigned int dynamite_score;        /* dynamite collect scoer*/
542   unsigned int eater_pos;             /* eater array pos */
543   unsigned int eater_score;           /* eater popped by stone/spring score */
544   unsigned int emerald_score;         /* emerald collect score */
545   unsigned int exit_score;            /* exit score */
546   unsigned int key_score;             /* key collect score */
547   unsigned int lenses_cnt_initial;    /* lenses time counter (initial) */
548   unsigned int lenses_cnt;            /* lenses time counter */
549   unsigned int lenses_score;          /* lenses collect score */
550   unsigned int lenses_time;           /* lenses reset time */
551   unsigned int magnify_cnt_initial;   /* magnify time counter (initial) */
552   unsigned int magnify_cnt;           /* magnify time counter */
553   unsigned int magnify_score;         /* magnify collect score */
554   unsigned int magnify_time;          /* magnify reset time */
555   unsigned int nut_score;             /* nut crack score */
556   unsigned int shine_cnt;             /* shine counter for emerald/diamond */
557   unsigned int slurp_score;           /* slurp alien score */
558   unsigned int tank_score;            /* tank popped by stone/spring */
559   unsigned int wheel_cnt_initial;     /* wheel time counter (initial) */
560   unsigned int wheel_cnt;             /* wheel time counter */
561   unsigned int wheel_x_initial;       /* wheel x pos (initial) */
562   unsigned int wheel_x;               /* wheel x pos */
563   unsigned int wheel_y_initial;       /* wheel y pos (initial) */
564   unsigned int wheel_y;               /* wheel y pos */
565   unsigned int wheel_time;            /* wheel reset time */
566   unsigned int wind_cnt_initial;      /* wind time counter (initial) */
567   unsigned int wind_cnt;              /* wind time counter */
568   unsigned int wind_direction_initial;/* wind direction (initial) */
569   unsigned int wind_direction;        /* wind direction */
570   unsigned int wind_time;             /* wind reset time */
571   unsigned int wonderwall_state_initial; /* wonderwall currently on flag (initial) */
572   unsigned int wonderwall_state;      /* wonderwall currently on flag */
573   unsigned int wonderwall_time_initial;/* wonderwall time (initial) */
574   unsigned int wonderwall_time;       /* wonderwall time */
575   unsigned short eater_array[8][9];   /* eater data */
576   unsigned short ball_array[8][8];    /* ball data */
577   unsigned short android_array[TILE_MAX]; /* android clone table */
578 };
579
580 struct PLAYER
581 {
582   unsigned int num;
583   unsigned int alive_initial;
584   unsigned int alive;
585
586   unsigned int dynamite;
587   unsigned int dynamite_cnt;
588   unsigned int keys;
589   unsigned int anim;
590
591   unsigned int x_initial;
592   unsigned int y_initial;
593   unsigned int x;
594   unsigned int y;
595   unsigned int oldx;
596   unsigned int oldy;
597
598   unsigned int last_move_dir;
599
600   unsigned joy_n:1;
601   unsigned joy_e:1;
602   unsigned joy_s:1;
603   unsigned joy_w:1;
604   unsigned joy_snap:1;
605   unsigned joy_drop:1;
606   unsigned joy_stick:1;
607   unsigned joy_spin:1;
608 };
609
610
611 /* ------------------------------------------------------------------------- */
612 /* definitions and structures for use by the main game functions             */
613 /* ------------------------------------------------------------------------- */
614
615 /* values for native Emerald Mine game version */
616 #define FILE_VERSION_EM_V3      3
617 #define FILE_VERSION_EM_V4      4
618 #define FILE_VERSION_EM_V5      5
619 #define FILE_VERSION_EM_V6      6
620
621 #define FILE_VERSION_EM_ACTUAL  FILE_VERSION_EM_V6
622
623 struct GlobalInfo_EM
624 {
625   Bitmap *screenbuffer;
626 };
627
628 struct LevelInfo_EM
629 {
630   int file_version;
631
632   struct LEVEL *lev;
633   struct PLAYER *ply1, *ply2;
634
635   unsigned short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT];
636 };
637
638 struct GraphicInfo_EM
639 {
640   Bitmap *bitmap;
641   int src_x, src_y;
642   int src_offset_x, src_offset_y;
643   int dst_offset_x, dst_offset_y;
644   int width, height;
645
646   boolean has_crumbled_graphics;
647   Bitmap *crumbled_bitmap;
648   int crumbled_src_x, crumbled_src_y;
649   int crumbled_border_size;
650
651   int unique_identifier;        /* used to identify needed screen updates */
652 };
653
654 #endif  /* MAIN_EM_H */