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