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