rnd-20140104-3-src
[rocksndiamonds.git] / src / game_em / export.h
1 #ifndef EXPORT_H
2 #define EXPORT_H
3
4 /* ========================================================================= */
5 /* functions and definitions exported from game_em to main program           */
6 /* ========================================================================= */
7
8 /* ------------------------------------------------------------------------- */
9 /* constant definitions                                                      */
10 /* ------------------------------------------------------------------------- */
11
12 /* define these for backwards compatibility */
13 #define EM_ENGINE_BAD_ROLL
14 #define EM_ENGINE_BAD_SPRING
15
16 /* define these to use additional elements */
17 #define EM_ENGINE_USE_ADDITIONAL_ELEMENTS
18
19 /* internal definitions for EM engine */
20 #ifdef EM_ENGINE_BAD_ROLL
21 #define BAD_ROLL
22 #endif
23
24 #ifdef EM_ENGINE_BAD_SPRING
25 #define BAD_SPRING
26 #endif
27
28 /* one border for ZBORDER elements, one border for steelwall, if needed */
29 #define EM_MAX_CAVE_WIDTH               (MAX_PLAYFIELD_WIDTH  + 2 + 2)
30 #define EM_MAX_CAVE_HEIGHT              (MAX_PLAYFIELD_HEIGHT + 2 + 2)
31
32 /*
33   -----------------------------------------------------------------------------
34   definition of elements used in the Emerald Mine Club engine;
35   the element names have the following properties:
36   - elements that start with 'X' can be stored in a level file
37   - elements that start with 'Y' indicate moving elements
38   - elements that end with 'B' are the "backside" of moving elements
39   -----------------------------------------------------------------------------
40 */
41
42 enum
43 {
44   Xblank = 0,           /* still */
45   Yacid_splash_eB,      /* hmm */
46   Yacid_splash_wB,      /* hmm */
47
48 #ifdef EM_ENGINE_BAD_ROLL
49   Xstone_force_e,       /* only use these in eater */
50   Xstone_force_w,
51   Xnut_force_e,
52   Xnut_force_w,
53   Xspring_force_e,
54   Xspring_force_w,
55   Xemerald_force_e,
56   Xemerald_force_w,
57   Xdiamond_force_e,
58   Xdiamond_force_w,
59   Xbomb_force_e,
60   Xbomb_force_w,
61 #endif
62
63   Xstone,
64   Xstone_pause,
65   Xstone_fall,
66   Ystone_s,
67   Ystone_sB,
68   Ystone_e,
69   Ystone_eB,
70   Ystone_w,
71   Ystone_wB,
72   Xnut,
73   Xnut_pause,
74   Xnut_fall,
75   Ynut_s,
76   Ynut_sB,
77   Ynut_e,
78   Ynut_eB,
79   Ynut_w,
80   Ynut_wB,
81   Xbug_n,
82   Xbug_e,
83   Xbug_s,
84   Xbug_w,
85   Xbug_gon,
86   Xbug_goe,
87   Xbug_gos,
88   Xbug_gow,
89   Ybug_n,
90   Ybug_nB,
91   Ybug_e,
92   Ybug_eB,
93   Ybug_s,
94   Ybug_sB,
95   Ybug_w,
96   Ybug_wB,
97   Ybug_w_n,
98   Ybug_n_e,
99   Ybug_e_s,
100   Ybug_s_w,
101   Ybug_e_n,
102   Ybug_s_e,
103   Ybug_w_s,
104   Ybug_n_w,
105   Ybug_stone,
106   Ybug_spring,
107   Xtank_n,
108   Xtank_e,
109   Xtank_s,
110   Xtank_w,
111   Xtank_gon,
112   Xtank_goe,
113   Xtank_gos,
114   Xtank_gow,
115   Ytank_n,
116   Ytank_nB,
117   Ytank_e,
118   Ytank_eB,
119   Ytank_s,
120   Ytank_sB,
121   Ytank_w,
122   Ytank_wB,
123   Ytank_w_n,
124   Ytank_n_e,
125   Ytank_e_s,
126   Ytank_s_w,
127   Ytank_e_n,
128   Ytank_s_e,
129   Ytank_w_s,
130   Ytank_n_w,
131   Ytank_stone,
132   Ytank_spring,
133   Xandroid,
134   Xandroid_1_n,
135   Xandroid_2_n,
136   Xandroid_1_e,
137   Xandroid_2_e,
138   Xandroid_1_w,
139   Xandroid_2_w,
140   Xandroid_1_s,
141   Xandroid_2_s,
142   Yandroid_n,
143   Yandroid_nB,
144   Yandroid_ne,
145   Yandroid_neB,
146   Yandroid_e,
147   Yandroid_eB,
148   Yandroid_se,
149   Yandroid_seB,
150   Yandroid_s,
151   Yandroid_sB,
152   Yandroid_sw,
153   Yandroid_swB,
154   Yandroid_w,
155   Yandroid_wB,
156   Yandroid_nw,
157   Yandroid_nwB,
158   Xspring,
159   Xspring_pause,
160   Xspring_e,
161   Xspring_w,
162   Xspring_fall,
163   Yspring_s,
164   Yspring_sB,
165   Yspring_e,
166   Yspring_eB,
167   Yspring_w,
168   Yspring_wB,
169   Yspring_kill_e,
170   Yspring_kill_eB,
171   Yspring_kill_w,
172   Yspring_kill_wB,
173   Xeater_n,
174   Xeater_e,
175   Xeater_w,
176   Xeater_s,
177   Yeater_n,
178   Yeater_nB,
179   Yeater_e,
180   Yeater_eB,
181   Yeater_s,
182   Yeater_sB,
183   Yeater_w,
184   Yeater_wB,
185   Yeater_stone,
186   Yeater_spring,
187   Xalien,
188   Xalien_pause,
189   Yalien_n,
190   Yalien_nB,
191   Yalien_e,
192   Yalien_eB,
193   Yalien_s,
194   Yalien_sB,
195   Yalien_w,
196   Yalien_wB,
197   Yalien_stone,
198   Yalien_spring,
199   Xemerald,
200   Xemerald_pause,
201   Xemerald_fall,
202   Xemerald_shine,
203   Yemerald_s,
204   Yemerald_sB,
205   Yemerald_e,
206   Yemerald_eB,
207   Yemerald_w,
208   Yemerald_wB,
209   Yemerald_eat,
210   Yemerald_stone,
211   Xdiamond,
212   Xdiamond_pause,
213   Xdiamond_fall,
214   Xdiamond_shine,
215   Ydiamond_s,
216   Ydiamond_sB,
217   Ydiamond_e,
218   Ydiamond_eB,
219   Ydiamond_w,
220   Ydiamond_wB,
221   Ydiamond_eat,
222   Ydiamond_stone,
223   Xdrip_fall,
224   Xdrip_stretch,
225   Xdrip_stretchB,
226   Xdrip_eat,
227   Ydrip_s1,
228   Ydrip_s1B,
229   Ydrip_s2,
230   Ydrip_s2B,
231   Xbomb,
232   Xbomb_pause,
233   Xbomb_fall,
234   Ybomb_s,
235   Ybomb_sB,
236   Ybomb_e,
237   Ybomb_eB,
238   Ybomb_w,
239   Ybomb_wB,
240   Ybomb_eat,
241   Xballoon,
242   Yballoon_n,
243   Yballoon_nB,
244   Yballoon_e,
245   Yballoon_eB,
246   Yballoon_s,
247   Yballoon_sB,
248   Yballoon_w,
249   Yballoon_wB,
250   Xgrass,
251   Ygrass_nB,
252   Ygrass_eB,
253   Ygrass_sB,
254   Ygrass_wB,
255   Xdirt,
256   Ydirt_nB,
257   Ydirt_eB,
258   Ydirt_sB,
259   Ydirt_wB,
260   Xacid_ne,
261   Xacid_se,
262   Xacid_s,
263   Xacid_sw,
264   Xacid_nw,
265   Xacid_1,
266   Xacid_2,
267   Xacid_3,
268   Xacid_4,
269   Xacid_5,
270   Xacid_6,
271   Xacid_7,
272   Xacid_8,
273   Xball_1,
274   Xball_1B,
275   Xball_2,
276   Xball_2B,
277   Yball_eat,
278
279 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
280   Ykey_1_eat,
281   Ykey_2_eat,
282   Ykey_3_eat,
283   Ykey_4_eat,
284   Ykey_5_eat,
285   Ykey_6_eat,
286   Ykey_7_eat,
287   Ykey_8_eat,
288   Ylenses_eat,
289   Ymagnify_eat,
290   Ygrass_eat,
291   Ydirt_eat,
292 #endif
293
294   Xgrow_ns,
295   Ygrow_ns_eat,
296   Xgrow_ew,
297   Ygrow_ew_eat,
298   Xwonderwall,
299   XwonderwallB,
300   Xamoeba_1,
301   Xamoeba_2,
302   Xamoeba_3,
303   Xamoeba_4,
304   Xamoeba_5,
305   Xamoeba_6,
306   Xamoeba_7,
307   Xamoeba_8,
308   Xdoor_1,
309   Xdoor_2,
310   Xdoor_3,
311   Xdoor_4,
312   Xdoor_5,
313   Xdoor_6,
314   Xdoor_7,
315   Xdoor_8,
316   Xkey_1,
317   Xkey_2,
318   Xkey_3,
319   Xkey_4,
320   Xkey_5,
321   Xkey_6,
322   Xkey_7,
323   Xkey_8,
324   Xwind_n,
325   Xwind_e,
326   Xwind_s,
327   Xwind_w,
328   Xwind_nesw,
329   Xwind_stop,
330   Xexit,
331   Xexit_1,
332   Xexit_2,
333   Xexit_3,
334   Xdynamite,
335   Ydynamite_eat,
336   Xdynamite_1,
337   Xdynamite_2,
338   Xdynamite_3,
339   Xdynamite_4,
340   Xbumper,
341   XbumperB,
342   Xwheel,
343   XwheelB,
344   Xswitch,
345   XswitchB,
346   Xsand,
347   Xsand_stone,
348   Xsand_stonein_1,
349   Xsand_stonein_2,
350   Xsand_stonein_3,
351   Xsand_stonein_4,
352   Xsand_stonesand_1,
353   Xsand_stonesand_2,
354   Xsand_stonesand_3,
355   Xsand_stonesand_4,
356
357 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
358   Xsand_stonesand_quickout_1,
359   Xsand_stonesand_quickout_2,
360 #endif
361
362   Xsand_stoneout_1,
363   Xsand_stoneout_2,
364   Xsand_sandstone_1,
365   Xsand_sandstone_2,
366   Xsand_sandstone_3,
367   Xsand_sandstone_4,
368   Xplant,
369   Yplant,
370   Xlenses,
371   Xmagnify,
372   Xdripper,
373   XdripperB,
374   Xfake_blank,
375   Xfake_blankB,
376   Xfake_grass,
377   Xfake_grassB,
378   Xfake_door_1,
379   Xfake_door_2,
380   Xfake_door_3,
381   Xfake_door_4,
382   Xfake_door_5,
383   Xfake_door_6,
384   Xfake_door_7,
385   Xfake_door_8,
386
387 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
388   Xfake_acid_1,
389   Xfake_acid_2,
390   Xfake_acid_3,
391   Xfake_acid_4,
392   Xfake_acid_5,
393   Xfake_acid_6,
394   Xfake_acid_7,
395   Xfake_acid_8,
396 #endif
397
398   Xsteel_1,
399   Xsteel_2,
400   Xsteel_3,
401   Xsteel_4,
402   Xwall_1,
403   Xwall_2,
404   Xwall_3,
405   Xwall_4,
406   Xround_wall_1,
407   Xround_wall_2,
408   Xround_wall_3,
409   Xround_wall_4,
410   Xdecor_1,
411   Xdecor_2,
412   Xdecor_3,
413   Xdecor_4,
414   Xdecor_5,
415   Xdecor_6,
416   Xdecor_7,
417   Xdecor_8,
418   Xdecor_9,
419   Xdecor_10,
420   Xdecor_11,
421   Xdecor_12,
422   Xalpha_0,
423   Xalpha_1,
424   Xalpha_2,
425   Xalpha_3,
426   Xalpha_4,
427   Xalpha_5,
428   Xalpha_6,
429   Xalpha_7,
430   Xalpha_8,
431   Xalpha_9,
432   Xalpha_excla,
433   Xalpha_quote,
434   Xalpha_comma,
435   Xalpha_minus,
436   Xalpha_perio,
437   Xalpha_colon,
438   Xalpha_quest,
439   Xalpha_a,
440   Xalpha_b,
441   Xalpha_c,
442   Xalpha_d,
443   Xalpha_e,
444   Xalpha_f,
445   Xalpha_g,
446   Xalpha_h,
447   Xalpha_i,
448   Xalpha_j,
449   Xalpha_k,
450   Xalpha_l,
451   Xalpha_m,
452   Xalpha_n,
453   Xalpha_o,
454   Xalpha_p,
455   Xalpha_q,
456   Xalpha_r,
457   Xalpha_s,
458   Xalpha_t,
459   Xalpha_u,
460   Xalpha_v,
461   Xalpha_w,
462   Xalpha_x,
463   Xalpha_y,
464   Xalpha_z,
465   Xalpha_arrow_e,
466   Xalpha_arrow_w,
467   Xalpha_copyr,
468
469   Xboom_bug,            /* passed from explode to synchro (linked explosion);
470                            transition to explode_normal */
471   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
472                            transition to explode_normal */
473   Xboom_android,        /* passed from explode to synchro;
474                            transition to boom_2 */
475   Xboom_1,              /* passed from explode to synchro;
476                            transition to boom_2 */
477   Xboom_2,              /* transition to boom[] */
478
479   Znormal,              /* passed from synchro to explode, only in next[];
480                            no picture */
481   Zdynamite,            /* passed from synchro to explode, only in next[];
482                            no picture */
483   Zplayer,              /* special code to indicate player;
484                            no picture */
485   ZBORDER,              /* special code to indicate border;
486                            no picture */
487
488   TILE_MAX
489 };
490
491 /* other definitions */
492
493 enum
494 {
495   SPR_still = 0,
496   SPR_walk  = 1,
497   SPR_push  = 5,
498   SPR_spray = 9,
499
500   SPR_MAX   = 13
501 };
502
503 enum
504 {
505   SAMPLE_blank = 0,     /* player walks on blank */
506   SAMPLE_roll,          /* player pushes stone/bomb/nut/spring */
507   SAMPLE_stone,         /* stone hits ground */
508   SAMPLE_nut,           /* nut hits ground */
509   SAMPLE_crack,         /* stone hits nut */
510   SAMPLE_bug,           /* bug moves */
511   SAMPLE_tank,          /* tank moves */
512   SAMPLE_android_clone, /* android places something */
513   SAMPLE_android_move,  /* android moves */
514   SAMPLE_spring,        /* spring hits ground/wall/bumper, stone hits spring */
515   SAMPLE_slurp,         /* spring kills alien */
516   SAMPLE_eater,         /* eater sits */
517   SAMPLE_eater_eat,     /* eater eats diamond */
518   SAMPLE_alien,         /* alien moves */
519   SAMPLE_collect,       /* player collects object */
520   SAMPLE_diamond,       /* diamond/emerald hits ground */
521   SAMPLE_squash,        /* stone squashes diamond */
522   SAMPLE_wonderfall,    /* object falls thru wonderwall */
523   SAMPLE_drip,          /* drip hits ground */
524   SAMPLE_push,          /* player pushes balloon/android */
525   SAMPLE_dirt,          /* player walks on dirt */
526   SAMPLE_acid,          /* acid splashes */
527   SAMPLE_ball,          /* ball places something */
528   SAMPLE_grow,          /* growing wall grows */
529   SAMPLE_wonder,        /* wonderwall is active */
530   SAMPLE_door,          /* player goes thru door (gate) */
531   SAMPLE_exit_open,     /* exit opens */
532   SAMPLE_exit_leave,    /* player goes into exit */
533   SAMPLE_dynamite,      /* player places dynamite */
534   SAMPLE_tick,          /* dynamite ticks */
535   SAMPLE_press,         /* player presses wheel/wind/switch */
536   SAMPLE_wheel,         /* wheel moves */
537   SAMPLE_boom,          /* explosion */
538   SAMPLE_time,          /* time runs out */
539   SAMPLE_die,           /* player dies */
540
541   SAMPLE_MAX
542 };
543
544
545 /* ------------------------------------------------------------------------- */
546 /* data structure definitions                                                */
547 /* ------------------------------------------------------------------------- */
548
549 struct LEVEL
550 {
551   int home_initial;             /* number of players (initial) */
552   int home;                     /* number of players not yet at home */
553                                 /* 0 == all players at home */
554
555   int width;                    /* playfield width */
556   int height;                   /* playfield height */
557
558   int time_seconds;             /* available time (seconds) */
559   int time_initial;             /* available time (initial) */
560   int time;                     /* time remaining (runtime) */
561
562   boolean killed_out_of_time;   /* kill player due to time out */
563
564   int required_initial;         /* emeralds needed (initial) */
565   int required;                 /* emeralds needed (runtime) */
566
567   int score;                    /* score */
568
569   /* all below entries must be filled every time a level is read */
570
571   int alien_score;              /* score for killing alien */
572   int amoeba_time;              /* amoeba speed */
573   int android_move_cnt_initial; /* android move counter (initial) */
574   int android_move_cnt;         /* android move counter */
575   int android_move_time;        /* android move reset time */
576   int android_clone_cnt_initial;/* android clone counter (initial) */
577   int android_clone_cnt;        /* android clone counter */
578   int android_clone_time;       /* android clone reset time */
579   int ball_cnt;                 /* ball counter */
580   int ball_pos;                 /* ball array pos counter */
581   int ball_random;              /* ball is random flag */
582   int ball_state_initial;       /* ball active flag (initial) */
583   int ball_state;               /* ball active flag */
584   int ball_time;                /* ball reset time */
585   int bug_score;                /* score for killing bug */
586   int diamond_score;            /* score for collecting diamond */
587   int dynamite_score;           /* score for collecting dynamite */
588   int eater_pos;                /* eater array pos */
589   int eater_score;              /* score for killing eater */
590   int emerald_score;            /* score for collecting emerald */
591   int exit_score;               /* score for entering exit */
592   int key_score;                /* score for colleting key */
593   int lenses_cnt_initial;       /* lenses counter (initial) */
594   int lenses_cnt;               /* lenses counter */
595   int lenses_score;             /* score for collecting lenses */
596   int lenses_time;              /* lenses reset time */
597   int magnify_cnt_initial;      /* magnify counter (initial) */
598   int magnify_cnt;              /* magnify counter */
599   int magnify_score;            /* score for collecting magnifier */
600   int magnify_time;             /* magnify reset time */
601   int nut_score;                /* score for cracking nut */
602   int shine_cnt;                /* shine counter for emerald/diamond */
603   int slurp_score;              /* score for slurping alien */
604   int tank_score;               /* score for killing tank */
605   int wheel_cnt_initial;        /* wheel counter (initial) */
606   int wheel_cnt;                /* wheel counter */
607   int wheel_x_initial;          /* wheel x pos (initial) */
608   int wheel_x;                  /* wheel x pos */
609   int wheel_y_initial;          /* wheel y pos (initial) */
610   int wheel_y;                  /* wheel y pos */
611   int wheel_time;               /* wheel reset time */
612   int wind_cnt_initial;         /* wind counter (initial) */
613   int wind_cnt;                 /* wind time counter */
614   int wind_direction_initial;   /* wind direction (initial) */
615   int wind_direction;           /* wind direction */
616   int wind_time;                /* wind reset time */
617   int wonderwall_state_initial; /* wonderwall active flag (initial) */
618   int wonderwall_state;         /* wonderwall active flag */
619   int wonderwall_time_initial;  /* wonderwall time (initial) */
620   int wonderwall_time;          /* wonderwall time */
621   short eater_array[8][9];      /* eater data */
622   short ball_array[8][8];       /* ball data */
623   short android_array[TILE_MAX];/* android clone table */
624   int num_ball_arrays;          /* number of ball data arrays used */
625
626   int exit_x, exit_y;           /* kludge for playing player exit sound */
627 };
628
629 struct PLAYER
630 {
631   int num;
632   int exists;
633   int alive_initial;
634   int alive;
635
636   int dynamite;
637   int dynamite_cnt;
638   int keys;
639   int anim;
640
641   int x_initial;
642   int y_initial;
643   int x;
644   int y;
645   int oldx;
646   int oldy;
647
648   int last_move_dir;
649
650   int joy_n:1;
651   int joy_e:1;
652   int joy_s:1;
653   int joy_w:1;
654   int joy_snap:1;
655   int joy_drop:1;
656   int joy_stick:1;
657   int joy_spin:1;
658 };
659
660 struct GlobalInfo_EM
661 {
662   Bitmap *screenbuffer;
663 };
664
665 struct GameInfo_EM
666 {
667   boolean any_player_moving;
668   int last_moving_player;
669   int last_player_direction[MAX_PLAYERS];
670 };
671
672 struct LevelInfo_EM
673 {
674   int file_version;
675
676   short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT];
677
678   struct LEVEL *lev;
679   struct PLAYER *ply[MAX_PLAYERS];
680 };
681
682 struct GraphicInfo_EM
683 {
684   Bitmap *bitmap;
685   int src_x, src_y;
686   int src_offset_x, src_offset_y;
687   int dst_offset_x, dst_offset_y;
688   int width, height;
689
690   Bitmap *crumbled_bitmap;
691   int crumbled_src_x, crumbled_src_y;
692   int crumbled_border_size;
693
694   boolean has_crumbled_graphics;
695   boolean preserve_background;
696
697   int unique_identifier;        /* used to identify needed screen updates */
698 };
699
700 struct EngineSnapshotInfo_EM
701 {
702   struct GameInfo_EM game_em;
703   unsigned int RandomEM;
704   struct LEVEL lev;
705   struct PLAYER ply[MAX_PLAYERS];
706   short Array[4][EM_MAX_CAVE_HEIGHT][EM_MAX_CAVE_WIDTH];
707   int screen_x;
708   int screen_y;
709   int frame;
710   short **Boom;
711   short **Cave;
712   short **Next;
713   short **Draw;
714 };
715
716
717 /* ------------------------------------------------------------------------- */
718 /* exported functions                                                        */
719 /* ------------------------------------------------------------------------- */
720
721 extern struct GlobalInfo_EM global_em_info;
722 extern struct LevelInfo_EM native_em_level;
723 extern struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8];
724 extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][SPR_MAX][8];
725 extern struct EngineSnapshotInfo_EM engine_snapshot_em;
726
727 extern void em_open_all();
728 extern void em_close_all();
729
730 extern void InitGfxBuffers_EM();
731
732 extern void InitGameEngine_EM();
733 extern void GameActions_EM(byte *, boolean);
734
735 extern unsigned int InitEngineRandom_EM(int);
736
737 extern void setLevelInfoToDefaults_EM();
738 extern boolean LoadNativeLevel_EM(char *, boolean);
739
740 extern void BackToFront_EM(void);
741 extern void BlitScreenToBitmap_EM(Bitmap *);
742 extern void RedrawPlayfield_EM(boolean);
743 extern void DrawGameDoorValues_EM();
744
745 extern void LoadEngineSnapshotValues_EM();
746 extern void SaveEngineSnapshotValues_EM();
747
748 #endif  /* EXPORT_H */