Debian Codegraph @

build-projects/android/app/jni/src/game_em/emerald.h

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