updated various names of EM engine specific definitions
[rocksndiamonds.git] / src / game_em / emerald.h
1 /*
2
3 This program "Emerald Mine for X11"
4 is copyright © 2009 David Tritscher.  All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 1. Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12
13 2. The origin of this software must not be misrepresented; you must
14    not claim that you wrote the original software.  If you use this
15    software in a product, an acknowledgment in the product
16    documentation would be appreciated but is not required.
17
18 3. Altered source versions must be plainly marked as such, and must
19    not be misrepresented as being the original software.
20
21 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 */
34 /* 2007-03-31 06:22:47
35  *
36  * emerald mine game engine defines
37  */
38
39 // ----------------------------------------------------------------------------
40 // EM game engine source code was altered for integration in Rocks'n'Diamonds
41 // ----------------------------------------------------------------------------
42
43 #ifndef EMERALD_H
44 #define EMERALD_H
45
46
47 // ----------------------------------------------------------------------------
48 // constant definitions
49 // ----------------------------------------------------------------------------
50
51 /* define these for backwards compatibility */
52 #define EM_ENGINE_BAD_ROLL
53 #define EM_ENGINE_BAD_SPRING
54
55 /* define these to use additional elements */
56 #define EM_ENGINE_USE_ADDITIONAL_ELEMENTS
57
58 /* internal definitions for EM engine */
59 #ifdef EM_ENGINE_BAD_ROLL
60 #define BAD_ROLL
61 #endif
62
63 #ifdef EM_ENGINE_BAD_SPRING
64 #define BAD_SPRING
65 #endif
66
67 /* one border for Zborder elements, one border for steelwall, if needed */
68 #define EM_MAX_CAVE_WIDTH               (MAX_PLAYFIELD_WIDTH  + 2 + 2)
69 #define EM_MAX_CAVE_HEIGHT              (MAX_PLAYFIELD_HEIGHT + 2 + 2)
70
71 /*
72   -----------------------------------------------------------------------------
73   definition of elements used in the Emerald Mine Club engine;
74   the element names have the following properties:
75   - elements that start with 'X' can be stored in a level file
76   - elements that start with 'Y' indicate moving elements
77   - elements that end with 'B' are the "backside" of moving elements
78   -----------------------------------------------------------------------------
79 */
80
81 enum
82 {
83   Xblank = 0,
84   Xacid_splash_e,
85   Xacid_splash_w,
86
87 #ifdef EM_ENGINE_BAD_ROLL
88   Xpush_stone_e,
89   Xpush_stone_w,
90   Xpush_nut_e,
91   Xpush_nut_w,
92   Xpush_spring_e,
93   Xpush_spring_w,
94   Xpush_emerald_e,
95   Xpush_emerald_w,
96   Xpush_diamond_e,
97   Xpush_diamond_w,
98   Xpush_bomb_e,
99   Xpush_bomb_w,
100 #endif
101
102   Xstone,
103   Xstone_pause,
104   Xstone_fall,
105   Ystone_s,
106   Ystone_sB,
107   Ystone_e,
108   Ystone_eB,
109   Ystone_w,
110   Ystone_wB,
111   Xnut,
112   Xnut_pause,
113   Xnut_fall,
114   Ynut_s,
115   Ynut_sB,
116   Ynut_e,
117   Ynut_eB,
118   Ynut_w,
119   Ynut_wB,
120   Xbug_1_n,
121   Xbug_1_e,
122   Xbug_1_s,
123   Xbug_1_w,
124   Xbug_2_n,
125   Xbug_2_e,
126   Xbug_2_s,
127   Xbug_2_w,
128   Ybug_n,
129   Ybug_nB,
130   Ybug_e,
131   Ybug_eB,
132   Ybug_s,
133   Ybug_sB,
134   Ybug_w,
135   Ybug_wB,
136   Ybug_w_n,
137   Ybug_n_e,
138   Ybug_e_s,
139   Ybug_s_w,
140   Ybug_e_n,
141   Ybug_s_e,
142   Ybug_w_s,
143   Ybug_n_w,
144   Ybug_stone,
145   Ybug_spring,
146   Xtank_1_n,
147   Xtank_1_e,
148   Xtank_1_s,
149   Xtank_1_w,
150   Xtank_2_n,
151   Xtank_2_e,
152   Xtank_2_s,
153   Xtank_2_w,
154   Ytank_n,
155   Ytank_nB,
156   Ytank_e,
157   Ytank_eB,
158   Ytank_s,
159   Ytank_sB,
160   Ytank_w,
161   Ytank_wB,
162   Ytank_w_n,
163   Ytank_n_e,
164   Ytank_e_s,
165   Ytank_s_w,
166   Ytank_e_n,
167   Ytank_s_e,
168   Ytank_w_s,
169   Ytank_n_w,
170   Ytank_stone,
171   Ytank_spring,
172   Xandroid,
173   Xandroid_1_n,
174   Xandroid_2_n,
175   Xandroid_1_e,
176   Xandroid_2_e,
177   Xandroid_1_w,
178   Xandroid_2_w,
179   Xandroid_1_s,
180   Xandroid_2_s,
181   Yandroid_n,
182   Yandroid_nB,
183   Yandroid_ne,
184   Yandroid_neB,
185   Yandroid_e,
186   Yandroid_eB,
187   Yandroid_se,
188   Yandroid_seB,
189   Yandroid_s,
190   Yandroid_sB,
191   Yandroid_sw,
192   Yandroid_swB,
193   Yandroid_w,
194   Yandroid_wB,
195   Yandroid_nw,
196   Yandroid_nwB,
197   Xspring,
198   Xspring_pause,
199   Xspring_e,
200   Xspring_w,
201   Xspring_fall,
202   Yspring_s,
203   Yspring_sB,
204   Yspring_e,
205   Yspring_eB,
206   Yspring_w,
207   Yspring_wB,
208   Yspring_alien_e,
209   Yspring_alien_eB,
210   Yspring_alien_w,
211   Yspring_alien_wB,
212   Xeater_n,
213   Xeater_e,
214   Xeater_w,
215   Xeater_s,
216   Yeater_n,
217   Yeater_nB,
218   Yeater_e,
219   Yeater_eB,
220   Yeater_s,
221   Yeater_sB,
222   Yeater_w,
223   Yeater_wB,
224   Yeater_stone,
225   Yeater_spring,
226   Xalien,
227   Xalien_pause,
228   Yalien_n,
229   Yalien_nB,
230   Yalien_e,
231   Yalien_eB,
232   Yalien_s,
233   Yalien_sB,
234   Yalien_w,
235   Yalien_wB,
236   Yalien_stone,
237   Yalien_spring,
238   Xemerald,
239   Xemerald_pause,
240   Xemerald_fall,
241   Xemerald_shine,
242   Yemerald_s,
243   Yemerald_sB,
244   Yemerald_e,
245   Yemerald_eB,
246   Yemerald_w,
247   Yemerald_wB,
248   Yemerald_blank,
249   Ynut_stone,
250   Xdiamond,
251   Xdiamond_pause,
252   Xdiamond_fall,
253   Xdiamond_shine,
254   Ydiamond_s,
255   Ydiamond_sB,
256   Ydiamond_e,
257   Ydiamond_eB,
258   Ydiamond_w,
259   Ydiamond_wB,
260   Ydiamond_blank,
261   Ydiamond_stone,
262   Xdrip_fall,
263   Xdrip_stretch,
264   Xdrip_stretchB,
265   Xdrip,
266   Ydrip_1_s,
267   Ydrip_1_sB,
268   Ydrip_2_s,
269   Ydrip_2_sB,
270   Xbomb,
271   Xbomb_pause,
272   Xbomb_fall,
273   Ybomb_s,
274   Ybomb_sB,
275   Ybomb_e,
276   Ybomb_eB,
277   Ybomb_w,
278   Ybomb_wB,
279   Ybomb_blank,
280   Xballoon,
281   Yballoon_n,
282   Yballoon_nB,
283   Yballoon_e,
284   Yballoon_eB,
285   Yballoon_s,
286   Yballoon_sB,
287   Yballoon_w,
288   Yballoon_wB,
289   Xgrass,
290   Ygrass_nB,
291   Ygrass_eB,
292   Ygrass_sB,
293   Ygrass_wB,
294   Xdirt,
295   Ydirt_nB,
296   Ydirt_eB,
297   Ydirt_sB,
298   Ydirt_wB,
299   Xacid_ne,
300   Xacid_se,
301   Xacid_s,
302   Xacid_sw,
303   Xacid_nw,
304   Xacid_1,
305   Xacid_2,
306   Xacid_3,
307   Xacid_4,
308   Xacid_5,
309   Xacid_6,
310   Xacid_7,
311   Xacid_8,
312   Xball_1,
313   Yball_1,
314   Xball_2,
315   Yball_2,
316   Yball_blank,
317
318 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
319   Ykey_1_blank,
320   Ykey_2_blank,
321   Ykey_3_blank,
322   Ykey_4_blank,
323   Ykey_5_blank,
324   Ykey_6_blank,
325   Ykey_7_blank,
326   Ykey_8_blank,
327   Ylenses_blank,
328   Ymagnify_blank,
329   Ygrass_blank,
330   Ydirt_blank,
331 #endif
332
333   Xslidewall_ns,        /* growing wall */
334   Yslidewall_ns_blank,
335   Xslidewall_ew,
336   Yslidewall_ew_blank,
337   Xwonderwall,
338   XwonderwallB,
339   Xamoeba_1,
340   Xamoeba_2,
341   Xamoeba_3,
342   Xamoeba_4,
343   Xamoeba_5,
344   Xamoeba_6,
345   Xamoeba_7,
346   Xamoeba_8,
347   Xdoor_1,
348   Xdoor_2,
349   Xdoor_3,
350   Xdoor_4,
351   Xdoor_5,
352   Xdoor_6,
353   Xdoor_7,
354   Xdoor_8,
355   Xkey_1,
356   Xkey_2,
357   Xkey_3,
358   Xkey_4,
359   Xkey_5,
360   Xkey_6,
361   Xkey_7,
362   Xkey_8,
363   Xwind_n,
364   Xwind_e,
365   Xwind_s,
366   Xwind_w,
367   Xwind_any,
368   Xwind_stop,
369   Xexit,
370   Xexit_1,
371   Xexit_2,
372   Xexit_3,
373   Xdynamite,
374   Ydynamite_blank,
375   Xdynamite_1,
376   Xdynamite_2,
377   Xdynamite_3,
378   Xdynamite_4,
379   Xbumper,
380   XbumperB,
381   Xwheel,
382   XwheelB,
383   Xswitch,
384   XswitchB,
385   Xsand,
386   Xsand_stone,
387   Xsand_stonein_1,
388   Xsand_stonein_2,
389   Xsand_stonein_3,
390   Xsand_stonein_4,
391   Xsand_stonesand_1,
392   Xsand_stonesand_2,
393   Xsand_stonesand_3,
394   Xsand_stonesand_4,
395
396 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
397   Xsand_stonesand_quickout_1,
398   Xsand_stonesand_quickout_2,
399 #endif
400
401   Xsand_stoneout_1,
402   Xsand_stoneout_2,
403   Xsand_sandstone_1,
404   Xsand_sandstone_2,
405   Xsand_sandstone_3,
406   Xsand_sandstone_4,
407   Xplant,
408   Yplant,
409   Xlenses,
410   Xmagnify,
411   Xfake_amoeba,         /* dripper */
412   Xfake_amoebaB,
413   Xfake_blank,
414   Xfake_blankB,
415   Xfake_grass,
416   Xfake_grassB,
417   Xfake_door_1,
418   Xfake_door_2,
419   Xfake_door_3,
420   Xfake_door_4,
421   Xfake_door_5,
422   Xfake_door_6,
423   Xfake_door_7,
424   Xfake_door_8,
425
426 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
427   Xfake_acid_1,
428   Xfake_acid_2,
429   Xfake_acid_3,
430   Xfake_acid_4,
431   Xfake_acid_5,
432   Xfake_acid_6,
433   Xfake_acid_7,
434   Xfake_acid_8,
435 #endif
436
437   Xsteel_1,
438   Xsteel_2,
439   Xsteel_3,
440   Xsteel_4,
441   Xwall_1,
442   Xwall_2,
443   Xwall_3,
444   Xwall_4,
445   Xroundwall_1,
446   Xroundwall_2,
447   Xroundwall_3,
448   Xroundwall_4,
449   Xdecor_1,
450   Xdecor_2,
451   Xdecor_3,
452   Xdecor_4,
453   Xdecor_5,
454   Xdecor_6,
455   Xdecor_7,
456   Xdecor_8,
457   Xdecor_9,
458   Xdecor_10,
459   Xdecor_11,
460   Xdecor_12,
461   Xalpha_0,
462   Xalpha_1,
463   Xalpha_2,
464   Xalpha_3,
465   Xalpha_4,
466   Xalpha_5,
467   Xalpha_6,
468   Xalpha_7,
469   Xalpha_8,
470   Xalpha_9,
471   Xalpha_excla,
472   Xalpha_quote,
473   Xalpha_comma,
474   Xalpha_minus,
475   Xalpha_perio,
476   Xalpha_colon,
477   Xalpha_quest,
478   Xalpha_a,
479   Xalpha_b,
480   Xalpha_c,
481   Xalpha_d,
482   Xalpha_e,
483   Xalpha_f,
484   Xalpha_g,
485   Xalpha_h,
486   Xalpha_i,
487   Xalpha_j,
488   Xalpha_k,
489   Xalpha_l,
490   Xalpha_m,
491   Xalpha_n,
492   Xalpha_o,
493   Xalpha_p,
494   Xalpha_q,
495   Xalpha_r,
496   Xalpha_s,
497   Xalpha_t,
498   Xalpha_u,
499   Xalpha_v,
500   Xalpha_w,
501   Xalpha_x,
502   Xalpha_y,
503   Xalpha_z,
504   Xalpha_arrow_e,
505   Xalpha_arrow_w,
506   Xalpha_copyr,
507
508   Xboom_bug,            /* passed from explode to synchro (linked explosion);
509                            transition to explode_normal */
510   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
511                            transition to explode_normal */
512   Xboom_android,        /* passed from explode to synchro;
513                            transition to boom_2 */
514   Xboom_1,              /* passed from explode to synchro;
515                            transition to boom_2 */
516   Xboom_2,              /* transition to boom[] */
517
518   Znormal,              /* passed from synchro to explode, only in next[];
519                            no picture */
520   Zdynamite,            /* passed from synchro to explode, only in next[];
521                            no picture */
522   Zplayer,              /* special code to indicate player;
523                            no picture */
524   Zborder,              /* special code to indicate border;
525                            no picture */
526
527   TILE_MAX
528 };
529
530 /* other definitions */
531
532 enum
533 {
534   PLY_still = 0,
535   PLY_walk_n,
536   PLY_walk_e,
537   PLY_walk_s,
538   PLY_walk_w,
539   PLY_push_n,
540   PLY_push_e,
541   PLY_push_s,
542   PLY_push_w,
543   PLY_shoot_n,
544   PLY_shoot_e,
545   PLY_shoot_s,
546   PLY_shoot_w,
547
548   PLY_MAX
549 };
550
551 enum
552 {
553   SOUND_blank = 0,      /* player walks on blank */
554   SOUND_roll,           /* player pushes stone/bomb/nut/spring */
555   SOUND_stone,          /* stone hits ground */
556   SOUND_nut,            /* nut hits ground */
557   SOUND_crack,          /* stone hits nut */
558   SOUND_bug,            /* bug moves */
559   SOUND_tank,           /* tank moves */
560   SOUND_android_clone,  /* android places something */
561   SOUND_android_move,   /* android moves */
562   SOUND_spring,         /* spring hits ground/wall/bumper, stone hits spring */
563   SOUND_slurp,          /* spring kills alien */
564   SOUND_eater,          /* eater sits */
565   SOUND_eater_eat,      /* eater eats diamond */
566   SOUND_alien,          /* alien moves */
567   SOUND_collect,        /* player collects object */
568   SOUND_diamond,        /* diamond/emerald hits ground */
569   SOUND_squash,         /* stone squashes diamond */
570   SOUND_wonderfall,     /* object falls thru wonderwall */
571   SOUND_drip,           /* drip hits ground */
572   SOUND_push,           /* player pushes spring/balloon/android */
573   SOUND_dirt,           /* player digs into dirt */
574   SOUND_acid,           /* acid splashes */
575   SOUND_ball,           /* ball places something */
576   SOUND_slidewall,      /* slide wall grows */
577   SOUND_wonder,         /* wonderwall is active */
578   SOUND_door,           /* player goes thru door (gate) */
579   SOUND_exit_open,      /* exit opens */
580   SOUND_exit_leave,     /* player goes into exit */
581   SOUND_dynamite,       /* player places dynamite */
582   SOUND_tick,           /* dynamite ticks */
583   SOUND_press,          /* player presses wheel/wind/switch */
584   SOUND_wheel,          /* wheel moves */
585   SOUND_boom,           /* explosion */
586   SOUND_time,           /* time runs out */
587   SOUND_die,            /* player dies */
588
589   SOUND_MAX
590 };
591
592
593 // ----------------------------------------------------------------------------
594 // data structure definitions
595 // ----------------------------------------------------------------------------
596
597 struct LEVEL
598 {
599   int home_initial;             /* number of players (initial) */
600   int home;                     /* number of players not yet at home */
601                                 /* 0 == all players at home */
602
603   int width;                    /* playfield width */
604   int height;                   /* playfield height */
605
606   int time_seconds;             /* available time (seconds) */
607   int time_initial;             /* available time (initial) */
608   int time;                     /* time remaining (runtime) */
609
610   boolean killed_out_of_time;   /* kill player due to time out */
611
612   int required_initial;         /* emeralds needed (initial) */
613   int required;                 /* emeralds needed (runtime) */
614
615   int score;                    /* score */
616
617   /* all below entries must be filled every time a level is read */
618
619   int alien_score;              /* score for killing alien */
620   int amoeba_time;              /* amoeba speed */
621   int android_move_cnt_initial; /* android move counter (initial) */
622   int android_move_cnt;         /* android move counter */
623   int android_move_time;        /* android move reset time */
624   int android_clone_cnt_initial;/* android clone counter (initial) */
625   int android_clone_cnt;        /* android clone counter */
626   int android_clone_time;       /* android clone reset time */
627   int ball_cnt;                 /* ball counter */
628   int ball_pos;                 /* ball array pos counter */
629   int ball_random;              /* ball is random flag */
630   int ball_state_initial;       /* ball active flag (initial) */
631   int ball_state;               /* ball active flag */
632   int ball_time;                /* ball reset time */
633   int bug_score;                /* score for killing bug */
634   int diamond_score;            /* score for collecting diamond */
635   int dynamite_score;           /* score for collecting dynamite */
636   int eater_pos;                /* eater array pos */
637   int eater_score;              /* score for killing eater */
638   int emerald_score;            /* score for collecting emerald */
639   int exit_score;               /* score for entering exit */
640   int key_score;                /* score for colleting key */
641   int lenses_cnt_initial;       /* lenses counter (initial) */
642   int lenses_cnt;               /* lenses counter */
643   int lenses_score;             /* score for collecting lenses */
644   int lenses_time;              /* lenses reset time */
645   int magnify_cnt_initial;      /* magnify counter (initial) */
646   int magnify_cnt;              /* magnify counter */
647   int magnify_score;            /* score for collecting magnifier */
648   int magnify_time;             /* magnify reset time */
649   int nut_score;                /* score for cracking nut */
650   int shine_cnt;                /* shine counter for emerald/diamond */
651   int slurp_score;              /* score for slurping alien */
652   int tank_score;               /* score for killing tank */
653   int wheel_cnt_initial;        /* wheel counter (initial) */
654   int wheel_cnt;                /* wheel counter */
655   int wheel_x_initial;          /* wheel x pos (initial) */
656   int wheel_x;                  /* wheel x pos */
657   int wheel_y_initial;          /* wheel y pos (initial) */
658   int wheel_y;                  /* wheel y pos */
659   int wheel_time;               /* wheel reset time */
660   int wind_cnt_initial;         /* wind counter (initial) */
661   int wind_cnt;                 /* wind time counter */
662   int wind_direction_initial;   /* wind direction (initial) */
663   int wind_direction;           /* wind direction */
664   int wind_time;                /* wind reset time */
665   int wonderwall_state_initial; /* wonderwall active flag (initial) */
666   int wonderwall_state;         /* wonderwall active flag */
667   int wonderwall_time_initial;  /* wonderwall time (initial) */
668   int wonderwall_time;          /* wonderwall time */
669   short eater_array[8][9];      /* eater data */
670   short ball_array[8][8];       /* ball data */
671   short android_array[TILE_MAX];/* android clone table */
672   int num_ball_arrays;          /* number of ball data arrays used */
673
674   int exit_x, exit_y;           /* kludge for playing player exit sound */
675 };
676
677 struct PLAYER
678 {
679   int num;
680   int exists;
681   int alive_initial;
682   int alive;
683
684   int dynamite;
685   int dynamite_cnt;
686   int keys;
687   int anim;
688
689   int x_initial;
690   int y_initial;
691   int x;
692   int y;
693   int oldx;
694   int oldy;
695
696   int last_move_dir;
697
698   int joy_n:1;
699   int joy_e:1;
700   int joy_s:1;
701   int joy_w:1;
702   int joy_snap:1;
703   int joy_drop:1;
704   int joy_stick:1;
705   int joy_spin:1;
706 };
707
708 #endif  // EMERALD_H