rnd-20060112-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
366 #if 1
367   Xfake_acid_1,
368   Xfake_acid_2,
369   Xfake_acid_3,
370   Xfake_acid_4,
371   Xfake_acid_5,
372   Xfake_acid_6,
373   Xfake_acid_7,
374   Xfake_acid_8,
375 #endif
376
377   Xsteel_1,
378   Xsteel_2,
379   Xsteel_3,
380   Xsteel_4,
381   Xwall_1,
382   Xwall_2,
383   Xwall_3,
384   Xwall_4,
385   Xround_wall_1,
386   Xround_wall_2,
387   Xround_wall_3,
388   Xround_wall_4,
389   Xdecor_1,
390   Xdecor_2,
391   Xdecor_3,
392   Xdecor_4,
393   Xdecor_5,
394   Xdecor_6,
395   Xdecor_7,
396   Xdecor_8,
397   Xdecor_9,
398   Xdecor_10,
399   Xdecor_11,
400   Xdecor_12,
401   Xalpha_0,
402   Xalpha_1,
403   Xalpha_2,
404   Xalpha_3,
405   Xalpha_4,
406   Xalpha_5,
407   Xalpha_6,
408   Xalpha_7,
409   Xalpha_8,
410   Xalpha_9,
411   Xalpha_excla,
412   Xalpha_quote,
413   Xalpha_comma,
414   Xalpha_minus,
415   Xalpha_perio,
416   Xalpha_colon,
417   Xalpha_quest,
418   Xalpha_a,
419   Xalpha_b,
420   Xalpha_c,
421   Xalpha_d,
422   Xalpha_e,
423   Xalpha_f,
424   Xalpha_g,
425   Xalpha_h,
426   Xalpha_i,
427   Xalpha_j,
428   Xalpha_k,
429   Xalpha_l,
430   Xalpha_m,
431   Xalpha_n,
432   Xalpha_o,
433   Xalpha_p,
434   Xalpha_q,
435   Xalpha_r,
436   Xalpha_s,
437   Xalpha_t,
438   Xalpha_u,
439   Xalpha_v,
440   Xalpha_w,
441   Xalpha_x,
442   Xalpha_y,
443   Xalpha_z,
444   Xalpha_arrow_e,
445   Xalpha_arrow_w,
446   Xalpha_copyr,
447
448   Xboom_bug,            /* passed from explode to synchro (linked explosion);
449                            transition to explode_normal */
450   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
451                            transition to explode_normal */
452   Xboom_android,        /* passed from explode to synchro;
453                            transition to boom_2 */
454   Xboom_1,              /* passed from explode to synchro;
455                            transition to boom_2 */
456   Xboom_2,              /* transition to boom[] */
457
458   Znormal,              /* passed from synchro to explode, only in next[];
459                            no picture */
460   Zdynamite,            /* passed from synchro to explode, only in next[];
461                            no picture */
462   Zplayer,              /* special code to indicate player;
463                            no picture */
464   ZBORDER,              /* special code to indicate border;
465                            no picture */
466
467   TILE_MAX
468 };
469
470 enum
471 {
472   SPR_still = 0,
473   SPR_walk  = 1,
474   SPR_push  = 5,
475   SPR_spray = 9,
476
477   SPR_MAX   = 13
478 };
479
480 enum
481 {
482   SAMPLE_blank = 0,     /* player walks on blank */
483   SAMPLE_roll,          /* player pushes stone/bomb/nut/spring */
484   SAMPLE_stone,         /* stone hits ground */
485   SAMPLE_nut,           /* nut hits ground */
486   SAMPLE_crack,         /* stone hits nut */
487   SAMPLE_bug,           /* bug moves */
488   SAMPLE_tank,          /* tank moves */
489   SAMPLE_android_clone, /* android places something */
490   SAMPLE_android_move,  /* android moves */
491   SAMPLE_spring,        /* spring hits ground/wall/bumper, stone hits spring */
492   SAMPLE_slurp,         /* spring kills alien */
493   SAMPLE_eater,         /* eater sits */
494   SAMPLE_eater_eat,     /* eater eats diamond */
495   SAMPLE_alien,         /* alien moves */
496   SAMPLE_collect,       /* player collects object */
497   SAMPLE_diamond,       /* diamond/emerald hits ground */
498   SAMPLE_squash,        /* stone squashes diamond */
499   SAMPLE_wonderfall,    /* object falls thru wonderwall */
500   SAMPLE_drip,          /* drip hits ground */
501   SAMPLE_push,          /* player pushes balloon/android */
502   SAMPLE_dirt,          /* player walks on dirt */
503   SAMPLE_acid,          /* acid splashes */
504   SAMPLE_ball,          /* ball places something */
505   SAMPLE_grow,          /* growing wall grows */
506   SAMPLE_wonder,        /* wonderwall is active */
507   SAMPLE_door,          /* player goes thru door (gate) */
508   SAMPLE_exit_open,     /* exit opens */
509   SAMPLE_exit_leave,    /* player goes into exit */
510   SAMPLE_dynamite,      /* player places dynamite */
511   SAMPLE_tick,          /* dynamite ticks */
512   SAMPLE_press,         /* player presses wheel/wind/switch */
513   SAMPLE_wheel,         /* wheel moves */
514   SAMPLE_boom,          /* explosion */
515   SAMPLE_time,          /* time runs out */
516   SAMPLE_die,           /* player dies */
517
518   SAMPLE_MAX
519 };
520
521 struct LEVEL
522 {
523   unsigned int home_initial;            /* number of players (initial) */
524   unsigned int home;                    /* number of players not yet at home */
525                                         /* 0 == all players at home */
526
527   unsigned int width;                   /* playfield width */
528   unsigned int height;                  /* playfield height */
529
530   unsigned int time_seconds;            /* available time (seconds) */
531   unsigned int time_initial;            /* available time (initial) */
532   unsigned int time;                    /* time remaining (runtime) */
533
534   boolean killed_out_of_time;           /* kill player due to time out */
535
536   unsigned int required_initial;        /* emeralds needed (initial) */
537   unsigned int required;                /* emeralds needed (runtime) */
538
539   unsigned int score;                   /* score */
540
541   /* all below entries must be filled every time a level is read */
542
543   unsigned int alien_score;             /* score for killing alien */
544   unsigned int amoeba_time;             /* amoeba speed */
545   unsigned int android_move_cnt_initial;/* android move counter (initial) */
546   unsigned int android_move_cnt;        /* android move counter */
547   unsigned int android_move_time;       /* android move reset time */
548   unsigned int android_clone_cnt_initial;/* android clone counter (initial) */
549   unsigned int android_clone_cnt;       /* android clone counter */
550   unsigned int android_clone_time;      /* android clone reset time */
551   unsigned int ball_cnt;                /* ball counter */
552   unsigned int ball_pos;                /* ball array pos counter */
553   unsigned int ball_random;             /* ball is random flag */
554   unsigned int ball_state_initial;      /* ball active flag (initial) */
555   unsigned int ball_state;              /* ball active flag */
556   unsigned int ball_time;               /* ball reset time */
557   unsigned int bug_score;               /* score for killing bug */
558   unsigned int diamond_score;           /* score for collecting diamond */
559   unsigned int dynamite_score;          /* score for collecting dynamite */
560   unsigned int eater_pos;               /* eater array pos */
561   unsigned int eater_score;             /* score for killing eater */
562   unsigned int emerald_score;           /* score for collecting emerald */
563   unsigned int exit_score;              /* score for entering exit */
564   unsigned int key_score;               /* score for colleting key */
565   unsigned int lenses_cnt_initial;      /* lenses counter (initial) */
566   unsigned int lenses_cnt;              /* lenses counter */
567   unsigned int lenses_score;            /* score for collecting lenses */
568   unsigned int lenses_time;             /* lenses reset time */
569   unsigned int magnify_cnt_initial;     /* magnify counter (initial) */
570   unsigned int magnify_cnt;             /* magnify counter */
571   unsigned int magnify_score;           /* score for collecting magnifier */
572   unsigned int magnify_time;            /* magnify reset time */
573   unsigned int nut_score;               /* score for cracking nut */
574   unsigned int shine_cnt;               /* shine counter for emerald/diamond */
575   unsigned int slurp_score;             /* score for slurping alien */
576   unsigned int tank_score;              /* score for killing tank */
577   unsigned int wheel_cnt_initial;       /* wheel counter (initial) */
578   unsigned int wheel_cnt;               /* wheel counter */
579   unsigned int wheel_x_initial;         /* wheel x pos (initial) */
580   unsigned int wheel_x;                 /* wheel x pos */
581   unsigned int wheel_y_initial;         /* wheel y pos (initial) */
582   unsigned int wheel_y;                 /* wheel y pos */
583   unsigned int wheel_time;              /* wheel reset time */
584   unsigned int wind_cnt_initial;        /* wind counter (initial) */
585   unsigned int wind_cnt;                /* wind time counter */
586   unsigned int wind_direction_initial;  /* wind direction (initial) */
587   unsigned int wind_direction;          /* wind direction */
588   unsigned int wind_time;               /* wind reset time */
589   unsigned int wonderwall_state_initial;/* wonderwall active flag (initial) */
590   unsigned int wonderwall_state;        /* wonderwall active flag */
591   unsigned int wonderwall_time_initial; /* wonderwall time (initial) */
592   unsigned int wonderwall_time;         /* wonderwall time */
593   unsigned short eater_array[8][9];     /* eater data */
594   unsigned short ball_array[8][8];      /* ball data */
595   unsigned short android_array[TILE_MAX];/* android clone table */
596   unsigned int num_ball_arrays;         /* number of ball data arrays used */
597 };
598
599 struct PLAYER
600 {
601   unsigned int num;
602   unsigned int alive_initial;
603   unsigned int alive;
604
605   unsigned int dynamite;
606   unsigned int dynamite_cnt;
607   unsigned int keys;
608   unsigned int anim;
609
610   unsigned int x_initial;
611   unsigned int y_initial;
612   unsigned int x;
613   unsigned int y;
614   unsigned int oldx;
615   unsigned int oldy;
616
617   unsigned int last_move_dir;
618
619   unsigned joy_n:1;
620   unsigned joy_e:1;
621   unsigned joy_s:1;
622   unsigned joy_w:1;
623   unsigned joy_snap:1;
624   unsigned joy_drop:1;
625   unsigned joy_stick:1;
626   unsigned joy_spin:1;
627 };
628
629
630 /* ------------------------------------------------------------------------- */
631 /* definitions and structures for use by the main game functions             */
632 /* ------------------------------------------------------------------------- */
633
634 /* values for native Emerald Mine game version */
635 #define FILE_VERSION_EM_V3      3
636 #define FILE_VERSION_EM_V4      4
637 #define FILE_VERSION_EM_V5      5
638 #define FILE_VERSION_EM_V6      6
639
640 #define FILE_VERSION_EM_ACTUAL  FILE_VERSION_EM_V6
641
642 struct GlobalInfo_EM
643 {
644   Bitmap *screenbuffer;
645 };
646
647 struct LevelInfo_EM
648 {
649   int file_version;
650
651   unsigned short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT];
652
653   struct LEVEL *lev;
654   struct PLAYER *ply1, *ply2;
655 };
656
657 struct GraphicInfo_EM
658 {
659   Bitmap *bitmap;
660   int src_x, src_y;
661   int src_offset_x, src_offset_y;
662   int dst_offset_x, dst_offset_y;
663   int width, height;
664
665   Bitmap *crumbled_bitmap;
666   int crumbled_src_x, crumbled_src_y;
667   int crumbled_border_size;
668
669   boolean has_crumbled_graphics;
670   boolean preserve_background;
671
672   int unique_identifier;        /* used to identify needed screen updates */
673 };
674
675 #endif  /* MAIN_EM_H */