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