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