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