rnd-20060402-1-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   Xsand_stoneout_1,
357   Xsand_stoneout_2,
358   Xsand_sandstone_1,
359   Xsand_sandstone_2,
360   Xsand_sandstone_3,
361   Xsand_sandstone_4,
362   Xplant,
363   Yplant,
364   Xlenses,
365   Xmagnify,
366   Xdripper,
367   XdripperB,
368   Xfake_blank,
369   Xfake_blankB,
370   Xfake_grass,
371   Xfake_grassB,
372   Xfake_door_1,
373   Xfake_door_2,
374   Xfake_door_3,
375   Xfake_door_4,
376   Xfake_door_5,
377   Xfake_door_6,
378   Xfake_door_7,
379   Xfake_door_8,
380
381 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
382   Xfake_acid_1,
383   Xfake_acid_2,
384   Xfake_acid_3,
385   Xfake_acid_4,
386   Xfake_acid_5,
387   Xfake_acid_6,
388   Xfake_acid_7,
389   Xfake_acid_8,
390 #endif
391
392   Xsteel_1,
393   Xsteel_2,
394   Xsteel_3,
395   Xsteel_4,
396   Xwall_1,
397   Xwall_2,
398   Xwall_3,
399   Xwall_4,
400   Xround_wall_1,
401   Xround_wall_2,
402   Xround_wall_3,
403   Xround_wall_4,
404   Xdecor_1,
405   Xdecor_2,
406   Xdecor_3,
407   Xdecor_4,
408   Xdecor_5,
409   Xdecor_6,
410   Xdecor_7,
411   Xdecor_8,
412   Xdecor_9,
413   Xdecor_10,
414   Xdecor_11,
415   Xdecor_12,
416   Xalpha_0,
417   Xalpha_1,
418   Xalpha_2,
419   Xalpha_3,
420   Xalpha_4,
421   Xalpha_5,
422   Xalpha_6,
423   Xalpha_7,
424   Xalpha_8,
425   Xalpha_9,
426   Xalpha_excla,
427   Xalpha_quote,
428   Xalpha_comma,
429   Xalpha_minus,
430   Xalpha_perio,
431   Xalpha_colon,
432   Xalpha_quest,
433   Xalpha_a,
434   Xalpha_b,
435   Xalpha_c,
436   Xalpha_d,
437   Xalpha_e,
438   Xalpha_f,
439   Xalpha_g,
440   Xalpha_h,
441   Xalpha_i,
442   Xalpha_j,
443   Xalpha_k,
444   Xalpha_l,
445   Xalpha_m,
446   Xalpha_n,
447   Xalpha_o,
448   Xalpha_p,
449   Xalpha_q,
450   Xalpha_r,
451   Xalpha_s,
452   Xalpha_t,
453   Xalpha_u,
454   Xalpha_v,
455   Xalpha_w,
456   Xalpha_x,
457   Xalpha_y,
458   Xalpha_z,
459   Xalpha_arrow_e,
460   Xalpha_arrow_w,
461   Xalpha_copyr,
462
463   Xboom_bug,            /* passed from explode to synchro (linked explosion);
464                            transition to explode_normal */
465   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
466                            transition to explode_normal */
467   Xboom_android,        /* passed from explode to synchro;
468                            transition to boom_2 */
469   Xboom_1,              /* passed from explode to synchro;
470                            transition to boom_2 */
471   Xboom_2,              /* transition to boom[] */
472
473   Znormal,              /* passed from synchro to explode, only in next[];
474                            no picture */
475   Zdynamite,            /* passed from synchro to explode, only in next[];
476                            no picture */
477   Zplayer,              /* special code to indicate player;
478                            no picture */
479   ZBORDER,              /* special code to indicate border;
480                            no picture */
481
482   TILE_MAX
483 };
484
485 /* other definitions */
486
487 enum
488 {
489   SPR_still = 0,
490   SPR_walk  = 1,
491   SPR_push  = 5,
492   SPR_spray = 9,
493
494   SPR_MAX   = 13
495 };
496
497 enum
498 {
499   SAMPLE_blank = 0,     /* player walks on blank */
500   SAMPLE_roll,          /* player pushes stone/bomb/nut/spring */
501   SAMPLE_stone,         /* stone hits ground */
502   SAMPLE_nut,           /* nut hits ground */
503   SAMPLE_crack,         /* stone hits nut */
504   SAMPLE_bug,           /* bug moves */
505   SAMPLE_tank,          /* tank moves */
506   SAMPLE_android_clone, /* android places something */
507   SAMPLE_android_move,  /* android moves */
508   SAMPLE_spring,        /* spring hits ground/wall/bumper, stone hits spring */
509   SAMPLE_slurp,         /* spring kills alien */
510   SAMPLE_eater,         /* eater sits */
511   SAMPLE_eater_eat,     /* eater eats diamond */
512   SAMPLE_alien,         /* alien moves */
513   SAMPLE_collect,       /* player collects object */
514   SAMPLE_diamond,       /* diamond/emerald hits ground */
515   SAMPLE_squash,        /* stone squashes diamond */
516   SAMPLE_wonderfall,    /* object falls thru wonderwall */
517   SAMPLE_drip,          /* drip hits ground */
518   SAMPLE_push,          /* player pushes balloon/android */
519   SAMPLE_dirt,          /* player walks on dirt */
520   SAMPLE_acid,          /* acid splashes */
521   SAMPLE_ball,          /* ball places something */
522   SAMPLE_grow,          /* growing wall grows */
523   SAMPLE_wonder,        /* wonderwall is active */
524   SAMPLE_door,          /* player goes thru door (gate) */
525   SAMPLE_exit_open,     /* exit opens */
526   SAMPLE_exit_leave,    /* player goes into exit */
527   SAMPLE_dynamite,      /* player places dynamite */
528   SAMPLE_tick,          /* dynamite ticks */
529   SAMPLE_press,         /* player presses wheel/wind/switch */
530   SAMPLE_wheel,         /* wheel moves */
531   SAMPLE_boom,          /* explosion */
532   SAMPLE_time,          /* time runs out */
533   SAMPLE_die,           /* player dies */
534
535   SAMPLE_MAX
536 };
537
538
539 /* ------------------------------------------------------------------------- */
540 /* data structure definitions                                                */
541 /* ------------------------------------------------------------------------- */
542
543 struct LEVEL
544 {
545   int home_initial;             /* number of players (initial) */
546   int home;                     /* number of players not yet at home */
547                                 /* 0 == all players at home */
548
549   int width;                    /* playfield width */
550   int height;                   /* playfield height */
551
552   int time_seconds;             /* available time (seconds) */
553   int time_initial;             /* available time (initial) */
554   int time;                     /* time remaining (runtime) */
555
556   boolean killed_out_of_time;   /* kill player due to time out */
557
558   int required_initial;         /* emeralds needed (initial) */
559   int required;                 /* emeralds needed (runtime) */
560
561   int score;                    /* score */
562
563   /* all below entries must be filled every time a level is read */
564
565   int alien_score;              /* score for killing alien */
566   int amoeba_time;              /* amoeba speed */
567   int android_move_cnt_initial; /* android move counter (initial) */
568   int android_move_cnt;         /* android move counter */
569   int android_move_time;        /* android move reset time */
570   int android_clone_cnt_initial;/* android clone counter (initial) */
571   int android_clone_cnt;        /* android clone counter */
572   int android_clone_time;       /* android clone reset time */
573   int ball_cnt;                 /* ball counter */
574   int ball_pos;                 /* ball array pos counter */
575   int ball_random;              /* ball is random flag */
576   int ball_state_initial;       /* ball active flag (initial) */
577   int ball_state;               /* ball active flag */
578   int ball_time;                /* ball reset time */
579   int bug_score;                /* score for killing bug */
580   int diamond_score;            /* score for collecting diamond */
581   int dynamite_score;           /* score for collecting dynamite */
582   int eater_pos;                /* eater array pos */
583   int eater_score;              /* score for killing eater */
584   int emerald_score;            /* score for collecting emerald */
585   int exit_score;               /* score for entering exit */
586   int key_score;                /* score for colleting key */
587   int lenses_cnt_initial;       /* lenses counter (initial) */
588   int lenses_cnt;               /* lenses counter */
589   int lenses_score;             /* score for collecting lenses */
590   int lenses_time;              /* lenses reset time */
591   int magnify_cnt_initial;      /* magnify counter (initial) */
592   int magnify_cnt;              /* magnify counter */
593   int magnify_score;            /* score for collecting magnifier */
594   int magnify_time;             /* magnify reset time */
595   int nut_score;                /* score for cracking nut */
596   int shine_cnt;                /* shine counter for emerald/diamond */
597   int slurp_score;              /* score for slurping alien */
598   int tank_score;               /* score for killing tank */
599   int wheel_cnt_initial;        /* wheel counter (initial) */
600   int wheel_cnt;                /* wheel counter */
601   int wheel_x_initial;          /* wheel x pos (initial) */
602   int wheel_x;                  /* wheel x pos */
603   int wheel_y_initial;          /* wheel y pos (initial) */
604   int wheel_y;                  /* wheel y pos */
605   int wheel_time;               /* wheel reset time */
606   int wind_cnt_initial;         /* wind counter (initial) */
607   int wind_cnt;                 /* wind time counter */
608   int wind_direction_initial;   /* wind direction (initial) */
609   int wind_direction;           /* wind direction */
610   int wind_time;                /* wind reset time */
611   int wonderwall_state_initial; /* wonderwall active flag (initial) */
612   int wonderwall_state;         /* wonderwall active flag */
613   int wonderwall_time_initial;  /* wonderwall time (initial) */
614   int wonderwall_time;          /* wonderwall time */
615   short eater_array[8][9];      /* eater data */
616   short ball_array[8][8];       /* ball data */
617   short android_array[TILE_MAX];/* android clone table */
618   int num_ball_arrays;          /* number of ball data arrays used */
619 };
620
621 struct PLAYER
622 {
623   int num;
624   int exists;
625   int alive_initial;
626   int alive;
627
628   int dynamite;
629   int dynamite_cnt;
630   int keys;
631   int anim;
632
633   int x_initial;
634   int y_initial;
635   int x;
636   int y;
637   int oldx;
638   int oldy;
639
640   int last_move_dir;
641
642   int joy_n:1;
643   int joy_e:1;
644   int joy_s:1;
645   int joy_w:1;
646   int joy_snap:1;
647   int joy_drop:1;
648   int joy_stick:1;
649   int joy_spin:1;
650 };
651
652 struct GlobalInfo_EM
653 {
654   Bitmap *screenbuffer;
655 };
656
657 struct GameInfo_EM
658 {
659   boolean any_player_moving;
660   int last_moving_player;
661   int last_player_direction[MAX_PLAYERS];
662 };
663
664 struct LevelInfo_EM
665 {
666   int file_version;
667
668   short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT];
669
670   struct LEVEL *lev;
671   struct PLAYER *ply[MAX_PLAYERS];
672 };
673
674 struct GraphicInfo_EM
675 {
676   Bitmap *bitmap;
677   int src_x, src_y;
678   int src_offset_x, src_offset_y;
679   int dst_offset_x, dst_offset_y;
680   int width, height;
681
682   Bitmap *crumbled_bitmap;
683   int crumbled_src_x, crumbled_src_y;
684   int crumbled_border_size;
685
686   boolean has_crumbled_graphics;
687   boolean preserve_background;
688
689   int unique_identifier;        /* used to identify needed screen updates */
690 };
691
692
693 /* ------------------------------------------------------------------------- */
694 /* exported functions                                                        */
695 /* ------------------------------------------------------------------------- */
696
697 extern struct GlobalInfo_EM global_em_info;
698 extern struct LevelInfo_EM native_em_level;
699 extern struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8];
700 extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][SPR_MAX][8];
701
702 extern void em_open_all();
703 extern void em_close_all();
704
705 extern void InitGameEngine_EM();
706 extern void GameActions_EM(byte *, boolean);
707
708 extern unsigned int InitEngineRND_EM(long);
709
710 extern void setLevelInfoToDefaults_EM();
711 extern boolean LoadNativeLevel_EM(char *);
712
713 extern void BlitScreenToBitmap_EM(Bitmap *);
714 extern void RedrawPlayfield_EM(boolean);
715 extern void DrawGameDoorValues_EM();
716
717 #endif  /* EXPORT_H */