X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_em%2Fsynchro_2.c;h=70f6797c88e38030fabacdcfec58249e5f8ae8a0;hp=4fbf2d9f182a56ac443bb2bc9310455fd3a0c416;hb=99261bc36a147246e39cdc6d5ce9b098257c4d1b;hpb=08cbfb7b24ed1170a91e5e9d6d683d6162f120f9 diff --git a/src/game_em/synchro_2.c b/src/game_em/synchro_2.c index 4fbf2d9f..70f6797c 100644 --- a/src/game_em/synchro_2.c +++ b/src/game_em/synchro_2.c @@ -8,37 +8,55 @@ * compilers suck. */ -#include "display.h" -#include "tile.h" -#include "level.h" -#include "sample.h" +#include "main_em.h" -#if defined(TARGET_X11) - #define RANDOM (random = random << 31 | random >> 1) -#define PLAY(sample) { if ((unsigned int)(y - top) <= 12 && (unsigned int)(x - left) <= 20) play[sample] = 1; } -extern unsigned int screen_x; -extern unsigned int screen_y; +static void set_nearest_player_xy(int x, int y, int *dx, int *dy) +{ + int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT; + int i; + + /* default values if no players are alive anymore */ + *dx = 0; + *dy = 0; + + for (i = 0; i < MAX_PLAYERS; i++) + { + if (!ply[i].alive) + continue; + + distance = ABS(ply[i].x - x) + ABS(ply[i].y - y); + + if (distance < distance_shortest) + { + *dx = ply[i].x; + *dy = ply[i].y; + + distance_shortest = distance; + } + } +} void synchro_2(void) { - register unsigned int x = 0; - register unsigned int y = 1; - register unsigned long random = Random; - register unsigned short *cave_cache = Cave[y]; /* might be a win */ - unsigned long score = 0; - - unsigned int temp = 0; /* initialized to make compilers happy */ - unsigned int left = screen_x / TILEX; /* only needed for sounds */ - unsigned int top = screen_y / TILEY; - unsigned int dx; /* only needed to find closest player */ - unsigned int dy; + int x = 0; + int y = 1; + unsigned int random = RandomEM; + short *cave_cache = Cave[y]; /* might be a win */ + int score = 0; + + int temp = 0; /* initialized to make compilers happy */ + int dx; /* only needed to find closest player */ + int dy; + int element; loop: - switch (cave_cache[++x]) + element = cave_cache[++x]; + + switch (element) { default: goto loop; @@ -353,7 +371,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -361,6 +379,16 @@ void synchro_2(void) case Yacid_splash_wB: case Xplant: case Yplant: +#if 1 + case Xfake_acid_1: + case Xfake_acid_2: + case Xfake_acid_3: + case Xfake_acid_4: + case Xfake_acid_5: + case Xfake_acid_6: + case Xfake_acid_7: + case Xfake_acid_8: +#endif Cave[y][x] = Ystone_sB; Cave[y+1][x] = Ystone_s; Next[y][x] = Xblank; @@ -484,12 +512,22 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: case Yacid_splash_eB: case Yacid_splash_wB: +#if 1 + case Xfake_acid_1: + case Xfake_acid_2: + case Xfake_acid_3: + case Xfake_acid_4: + case Xfake_acid_5: + case Xfake_acid_6: + case Xfake_acid_7: + case Xfake_acid_8: +#endif Cave[y][x] = Ystone_sB; Cave[y+1][x] = Ystone_s; Next[y][x] = Xblank; @@ -521,13 +559,23 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: case Yacid_splash_eB: case Yacid_splash_wB: case Zplayer: +#if 1 + case Xfake_acid_1: + case Xfake_acid_2: + case Xfake_acid_3: + case Xfake_acid_4: + case Xfake_acid_5: + case Xfake_acid_6: + case Xfake_acid_7: + case Xfake_acid_8: +#endif Cave[y][x] = Ystone_sB; Cave[y+1][x] = Ystone_s; Next[y][x] = Xblank; @@ -539,7 +587,7 @@ void synchro_2(void) Cave[y+1][x] = Yemerald_stone; Next[y][x] = Xstone; Next[y+1][x] = Xemerald; - play[SAMPLE_crack] = 1; + play_element_sound(x, y, SAMPLE_crack, Xnut); score += lev.nut_score; goto loop; @@ -563,6 +611,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xemerald; Boom[y+2][x] = Xemerald; Boom[y+2][x+1] = Xemerald; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.bug_score; goto loop; @@ -586,6 +637,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.tank_score; goto loop; @@ -643,6 +697,9 @@ void synchro_2(void) Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6]; Boom[y+2][x] = lev.eater_array[lev.eater_pos][7]; Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8]; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif lev.eater_pos = (lev.eater_pos + 1) & 7; score += lev.eater_score; goto loop; @@ -661,6 +718,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.alien_score; goto loop; @@ -715,7 +775,7 @@ void synchro_2(void) case Xplant: case Yplant: Next[y][x] = Xstone; - PLAY(SAMPLE_stone); + play_element_sound(x, y, SAMPLE_stone, Xstone); goto loop; } @@ -723,7 +783,7 @@ void synchro_2(void) Cave[y+1][x] = Ydiamond_stone; Next[y][x] = Xblank; Next[y+1][x] = Xstone_pause; - play[SAMPLE_squash] = 1; + play_element_sound(x, y, SAMPLE_squash, Xdiamond); goto loop; case Xbomb: @@ -739,6 +799,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif goto loop; case Xwonderwall: @@ -754,14 +817,14 @@ void synchro_2(void) } Next[y][x] = Xblank; - play[SAMPLE_squash] = 1; + play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall); goto loop; } default: Cave[y][x] = Xstone; Next[y][x] = Xstone; - PLAY(SAMPLE_stone); + play_element_sound(x, y, SAMPLE_stone, Xstone); goto loop; } @@ -784,7 +847,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -905,7 +968,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -942,7 +1005,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -958,17 +1021,17 @@ void synchro_2(void) default: Cave[y][x] = Xnut; Next[y][x] = Xnut; - PLAY(SAMPLE_nut); + play_element_sound(x, y, SAMPLE_nut, Xnut); goto loop; } /* --------------------------------------------------------------------- */ case Xbug_n: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; switch (Cave[y][x+1]) @@ -989,7 +1052,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ybug_n_e; Next[y][x] = Xbug_goe; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: @@ -997,10 +1060,10 @@ void synchro_2(void) } case Xbug_gon: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; bug_gon: @@ -1021,7 +1084,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1034,23 +1097,23 @@ void synchro_2(void) Cave[y-1][x] = Ybug_n; Next[y][x] = Xblank; Next[y-1][x] = Xbug_n; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: Cave[y][x] = Ybug_n_w; Next[y][x] = Xbug_gow; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; } /* --------------------------------------------------------------------- */ case Xbug_e: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; switch (Cave[y+1][x]) @@ -1071,7 +1134,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ybug_e_s; Next[y][x] = Xbug_gos; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: @@ -1079,10 +1142,10 @@ void synchro_2(void) } case Xbug_goe: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; bug_goe: @@ -1103,7 +1166,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1116,23 +1179,23 @@ void synchro_2(void) Cave[y][x+1] = Ybug_e; Next[y][x] = Xblank; Next[y][x+1] = Xbug_e; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: Cave[y][x] = Ybug_e_n; Next[y][x] = Xbug_gon; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; } /* --------------------------------------------------------------------- */ case Xbug_s: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; switch (Cave[y][x-1]) @@ -1153,7 +1216,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ybug_s_w; Next[y][x] = Xbug_gow; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: @@ -1161,10 +1224,10 @@ void synchro_2(void) } case Xbug_gos: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; bug_gos: @@ -1185,7 +1248,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1198,23 +1261,23 @@ void synchro_2(void) Cave[y+1][x] = Ybug_s; Next[y][x] = Xblank; Next[y+1][x] = Xbug_s; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: Cave[y][x] = Ybug_s_e; Next[y][x] = Xbug_goe; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; } /* --------------------------------------------------------------------- */ case Xbug_w: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; switch (Cave[y-1][x]) @@ -1235,7 +1298,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ybug_w_n; Next[y][x] = Xbug_gon; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: @@ -1243,10 +1306,10 @@ void synchro_2(void) } case Xbug_gow: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto bug_boom; bug_gow: @@ -1267,7 +1330,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1280,23 +1343,23 @@ void synchro_2(void) Cave[y][x-1] = Ybug_w; Next[y][x] = Xblank; Next[y][x-1] = Xbug_w; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; default: Cave[y][x] = Ybug_w_s; Next[y][x] = Xbug_gos; - PLAY(SAMPLE_bug); + play_element_sound(x, y, SAMPLE_bug, element); goto loop; } /* --------------------------------------------------------------------- */ case Xtank_n: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; switch (Cave[y][x-1]) @@ -1317,7 +1380,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ytank_n_w; Next[y][x] = Xtank_gow; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: @@ -1325,10 +1388,10 @@ void synchro_2(void) } case Xtank_gon: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; tank_gon: @@ -1349,7 +1412,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1362,23 +1425,23 @@ void synchro_2(void) Cave[y-1][x] = Ytank_n; Next[y][x] = Xblank; Next[y-1][x] = Xtank_n; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: Cave[y][x] = Ytank_n_e; Next[y][x] = Xtank_goe; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; } /* --------------------------------------------------------------------- */ case Xtank_e: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; switch (Cave[y-1][x]) @@ -1399,7 +1462,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ytank_e_n; Next[y][x] = Xtank_gon; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: @@ -1407,10 +1470,10 @@ void synchro_2(void) } case Xtank_goe: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; tank_goe: @@ -1431,7 +1494,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1444,23 +1507,23 @@ void synchro_2(void) Cave[y][x+1] = Ytank_e; Next[y][x] = Xblank; Next[y][x+1] = Xtank_e; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: Cave[y][x] = Ytank_e_s; Next[y][x] = Xtank_gos; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; } /* --------------------------------------------------------------------- */ case Xtank_s: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; switch (Cave[y][x+1]) @@ -1481,7 +1544,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ytank_s_e; Next[y][x] = Xtank_goe; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: @@ -1489,10 +1552,10 @@ void synchro_2(void) } case Xtank_gos: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; tank_gos: @@ -1513,7 +1576,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1526,23 +1589,23 @@ void synchro_2(void) Cave[y+1][x] = Ytank_s; Next[y][x] = Xblank; Next[y+1][x] = Xtank_s; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: Cave[y][x] = Ytank_s_w; Next[y][x] = Xtank_gow; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; } /* --------------------------------------------------------------------- */ case Xtank_w: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; switch (Cave[y+1][x]) @@ -1563,7 +1626,7 @@ void synchro_2(void) case Zplayer: Cave[y][x] = Ytank_w_s; Next[y][x] = Xtank_gos; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: @@ -1571,10 +1634,10 @@ void synchro_2(void) } case Xtank_gow: - if (tab_ameuba[Cave[y-1][x]] || - tab_ameuba[Cave[y][x+1]] || - tab_ameuba[Cave[y+1][x]] || - tab_ameuba[Cave[y][x-1]]) + if (tab_amoeba[Cave[y-1][x]] || + tab_amoeba[Cave[y][x+1]] || + tab_amoeba[Cave[y+1][x]] || + tab_amoeba[Cave[y][x-1]]) goto tank_boom; tank_gow: @@ -1595,7 +1658,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -1608,13 +1671,13 @@ void synchro_2(void) Cave[y][x-1] = Ytank_w; Next[y][x] = Xblank; Next[y][x-1] = Xtank_w; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; default: Cave[y][x] = Ytank_w_n; Next[y][x] = Xtank_gon; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_tank, element); goto loop; } @@ -1729,8 +1792,8 @@ void synchro_2(void) goto android_move; } - Next[y][x] = temp; /* the item we chose to clone */ - play[SAMPLE_android] = 1; + Next[y][x] = temp; /* the item we chose to clone */ + play_element_sound(x, y, SAMPLE_android_clone, temp); switch (RANDOM & 7) { @@ -1839,39 +1902,9 @@ void synchro_2(void) Cave[y+1][x+1] == Zplayer) goto android_still; - if (ply1.alive && ply2.alive) - { - if ((ply1.x > x ? ply1.x - x : x - ply1.x) + - (ply1.y > y ? ply1.y - y : y - ply1.y) < - (ply2.x > x ? ply2.x - x : x - ply2.x) + - (ply2.y > y ? ply2.y - y : y - ply2.y)) - { - dx = ply1.x; - dy = ply1.y; - } - else - { - dx = ply2.x; - dy = ply2.y; - } - } - else if (ply1.alive) - { - dx = ply1.x; - dy = ply1.y; - } - else if (ply2.alive) - { - dx = ply2.x; - dy = ply2.y; - } - else - { - dx = 0; - dy = 0; - } + set_nearest_player_xy(x, y, &dx, &dy); - Next[y][x] = Xblank; /* assume we will move */ + Next[y][x] = Xblank; /* assume we will move */ temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3; if (RANDOM & 1) @@ -2002,7 +2035,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_nB; Cave[y-1][x] = Yandroid_n; Next[y-1][x] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_ne: @@ -2010,7 +2043,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_neB; Cave[y-1][x+1] = Yandroid_ne; Next[y-1][x+1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_e: @@ -2018,7 +2051,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_eB; Cave[y][x+1] = Yandroid_e; Next[y][x+1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_se: @@ -2026,7 +2059,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_seB; Cave[y+1][x+1] = Yandroid_se; Next[y+1][x+1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_s: @@ -2034,7 +2067,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_sB; Cave[y+1][x] = Yandroid_s; Next[y+1][x] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_sw: @@ -2042,7 +2075,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_swB; Cave[y+1][x-1] = Yandroid_sw; Next[y+1][x-1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_w: @@ -2050,7 +2083,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_wB; Cave[y][x-1] = Yandroid_w; Next[y][x-1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; android_nw: @@ -2058,7 +2091,7 @@ void synchro_2(void) Cave[y][x] = Yandroid_nwB; Cave[y-1][x-1] = Yandroid_nw; Next[y-1][x-1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; /* --------------------------------------------------------------------- */ @@ -2080,7 +2113,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2090,7 +2123,7 @@ void synchro_2(void) Cave[y-1][x] = Yandroid_n; Next[y][x] = Xblank; Next[y-1][x] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2114,7 +2147,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2124,7 +2157,7 @@ void synchro_2(void) Cave[y-1][x] = Yandroid_n; Next[y][x] = Xblank; Next[y-1][x] = Xandroid_1_n; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2150,7 +2183,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2160,7 +2193,7 @@ void synchro_2(void) Cave[y][x+1] = Yandroid_e; Next[y][x] = Xblank; Next[y][x+1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2184,7 +2217,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2194,7 +2227,7 @@ void synchro_2(void) Cave[y][x+1] = Yandroid_e; Next[y][x] = Xblank; Next[y][x+1] = Xandroid_1_e; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2220,7 +2253,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2230,7 +2263,7 @@ void synchro_2(void) Cave[y+1][x] = Yandroid_s; Next[y][x] = Xblank; Next[y+1][x] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2254,7 +2287,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2264,7 +2297,7 @@ void synchro_2(void) Cave[y+1][x] = Yandroid_s; Next[y][x] = Xblank; Next[y+1][x] = Xandroid_1_s; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2290,7 +2323,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2300,7 +2333,7 @@ void synchro_2(void) Cave[y][x-1] = Yandroid_w; Next[y][x] = Xblank; Next[y][x-1] = Xandroid; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2324,7 +2357,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2334,7 +2367,7 @@ void synchro_2(void) Cave[y][x-1] = Yandroid_w; Next[y][x] = Xblank; Next[y][x-1] = Xandroid_1_w; - PLAY(SAMPLE_tank); + play_element_sound(x, y, SAMPLE_android_move, element); goto loop; default: @@ -2360,7 +2393,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2514,7 +2547,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2551,7 +2584,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2583,7 +2616,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2609,7 +2642,7 @@ void synchro_2(void) Cave[y][x+1] = Yspring_kill_e; Next[y][x] = Xblank; Next[y][x+1] = Xspring_e; - play[SAMPLE_slurp] = 1; + play_element_sound(x, y, SAMPLE_slurp, Xalien); score += lev.slurp_score; goto loop; @@ -2617,13 +2650,13 @@ void synchro_2(void) case XbumperB: Cave[y][x+1] = XbumperB; Next[y][x] = Xspring_w; - PLAY(SAMPLE_spring); + play_element_sound(x, y, SAMPLE_spring, Xspring); goto loop; default: Cave[y][x] = Xspring; Next[y][x] = Xspring; - PLAY(SAMPLE_spring); + play_element_sound(x, y, SAMPLE_spring, Xspring); goto loop; } @@ -2646,7 +2679,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2678,7 +2711,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2704,7 +2737,7 @@ void synchro_2(void) Cave[y][x-1] = Yspring_kill_w; Next[y][x] = Xblank; Next[y][x-1] = Xspring_w; - play[SAMPLE_slurp] = 1; + play_element_sound(x, y, SAMPLE_slurp, Xalien); score += lev.slurp_score; goto loop; @@ -2712,13 +2745,13 @@ void synchro_2(void) case XbumperB: Cave[y][x-1] = XbumperB; Next[y][x] = Xspring_e; - PLAY(SAMPLE_spring); + play_element_sound(x, y, SAMPLE_spring, Xspring); goto loop; default: Cave[y][x] = Xspring; Next[y][x] = Xspring; - PLAY(SAMPLE_spring); + play_element_sound(x, y, SAMPLE_spring, Xspring); goto loop; } @@ -2741,7 +2774,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2767,6 +2800,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif goto loop; case Xbug_n: @@ -2789,6 +2825,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xemerald; Boom[y+2][x] = Xemerald; Boom[y+2][x+1] = Xemerald; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.bug_score; goto loop; @@ -2812,6 +2851,9 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.tank_score; goto loop; @@ -2831,6 +2873,9 @@ void synchro_2(void) Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6]; Boom[y+2][x] = lev.eater_array[lev.eater_pos][7]; Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8]; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif lev.eater_pos = (lev.eater_pos + 1) & 7; score += lev.eater_score; goto loop; @@ -2849,13 +2894,16 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif score += lev.alien_score; goto loop; default: Cave[y][x] = Xspring; Next[y][x] = Xspring; - PLAY(SAMPLE_spring); + play_element_sound(x, y, SAMPLE_spring, Xspring); goto loop; } @@ -2866,7 +2914,7 @@ void synchro_2(void) { Cave[y][x+1] = Ydiamond_eat; Next[y][x+1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2874,7 +2922,7 @@ void synchro_2(void) { Cave[y+1][x] = Ydiamond_eat; Next[y+1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2882,7 +2930,7 @@ void synchro_2(void) { Cave[y][x-1] = Ydiamond_eat; Next[y][x-1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2890,7 +2938,7 @@ void synchro_2(void) { Cave[y-1][x] = Ydiamond_eat; Next[y-1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2910,7 +2958,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2927,7 +2975,7 @@ void synchro_2(void) default: Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w; - PLAY(SAMPLE_eater); + play_element_sound(x, y, SAMPLE_eater, element); goto loop; } @@ -2938,7 +2986,7 @@ void synchro_2(void) { Cave[y+1][x] = Ydiamond_eat; Next[y+1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2946,7 +2994,7 @@ void synchro_2(void) { Cave[y][x-1] = Ydiamond_eat; Next[y][x-1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2954,7 +3002,7 @@ void synchro_2(void) { Cave[y-1][x] = Ydiamond_eat; Next[y-1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2962,7 +3010,7 @@ void synchro_2(void) { Cave[y][x+1] = Ydiamond_eat; Next[y][x+1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -2982,7 +3030,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -2999,7 +3047,7 @@ void synchro_2(void) default: Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s; - PLAY(SAMPLE_eater); + play_element_sound(x, y, SAMPLE_eater, element); goto loop; } @@ -3010,7 +3058,7 @@ void synchro_2(void) { Cave[y][x-1] = Ydiamond_eat; Next[y][x-1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3018,7 +3066,7 @@ void synchro_2(void) { Cave[y-1][x] = Ydiamond_eat; Next[y-1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3026,7 +3074,7 @@ void synchro_2(void) { Cave[y][x+1] = Ydiamond_eat; Next[y][x+1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3034,7 +3082,7 @@ void synchro_2(void) { Cave[y+1][x] = Ydiamond_eat; Next[y+1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3054,7 +3102,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3071,7 +3119,7 @@ void synchro_2(void) default: Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w; - PLAY(SAMPLE_eater); + play_element_sound(x, y, SAMPLE_eater, element); goto loop; } @@ -3082,7 +3130,7 @@ void synchro_2(void) { Cave[y-1][x] = Ydiamond_eat; Next[y-1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3090,7 +3138,7 @@ void synchro_2(void) { Cave[y][x+1] = Ydiamond_eat; Next[y][x+1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3098,7 +3146,7 @@ void synchro_2(void) { Cave[y+1][x] = Ydiamond_eat; Next[y+1][x] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3106,7 +3154,7 @@ void synchro_2(void) { Cave[y][x-1] = Ydiamond_eat; Next[y][x-1] = Xblank; - play[SAMPLE_eater] = 1; + play_element_sound(x, y, SAMPLE_eater_eat, element); goto loop; } @@ -3126,7 +3174,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3143,48 +3191,22 @@ void synchro_2(void) default: Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s; - PLAY(SAMPLE_eater); + play_element_sound(x, y, SAMPLE_eater, element); goto loop; } /* --------------------------------------------------------------------- */ case Xalien: + if (lev.wheel_cnt) { dx = lev.wheel_x; dy = lev.wheel_y; } - else if (ply1.alive && ply2.alive) - { - if ((ply1.x > x ? ply1.x - x : x - ply1.x) + - (ply1.y > y ? ply1.y - y : y - ply1.y) < - (ply2.x > x ? ply2.x - x : x - ply2.x) + - (ply2.y > y ? ply2.y - y : y - ply2.y)) - { - dx = ply1.x; - dy = ply1.y; - } - else - { - dx = ply2.x; - dy = ply2.y; - } - } - else if (ply1.alive) - { - dx = ply1.x; - dy = ply1.y; - } - else if (ply2.alive) - { - dx = ply2.x; - dy = ply2.y; - } else { - dx = 0; - dy = 0; + set_nearest_player_xy(x, y, &dx, &dy); } if (RANDOM & 1) @@ -3207,7 +3229,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3220,7 +3242,7 @@ void synchro_2(void) Cave[y-1][x] = Yalien_n; Next[y][x] = Xblank; Next[y-1][x] = Xalien_pause; - PLAY(SAMPLE_alien); + play_element_sound(x, y, SAMPLE_alien, Xalien); goto loop; } } @@ -3242,7 +3264,7 @@ void synchro_2(void) Cave[y][x+1] = Yacid_splash_eB; if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3255,7 +3277,7 @@ void synchro_2(void) Cave[y+1][x] = Yalien_s; Next[y][x] = Xblank; Next[y+1][x] = Xalien_pause; - PLAY(SAMPLE_alien); + play_element_sound(x, y, SAMPLE_alien, Xalien); goto loop; } } @@ -3280,7 +3302,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3293,7 +3315,7 @@ void synchro_2(void) Cave[y][x+1] = Yalien_e; Next[y][x] = Xblank; Next[y][x+1] = Xalien_pause; - PLAY(SAMPLE_alien); + play_element_sound(x, y, SAMPLE_alien, Xalien); goto loop; } } @@ -3315,7 +3337,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3328,7 +3350,7 @@ void synchro_2(void) Cave[y][x-1] = Yalien_w; Next[y][x] = Xblank; Next[y][x-1] = Xalien_pause; - PLAY(SAMPLE_alien); + play_element_sound(x, y, SAMPLE_alien, Xalien); goto loop; } } @@ -3359,7 +3381,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3494,7 +3516,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3531,7 +3553,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3556,14 +3578,14 @@ void synchro_2(void) } Next[y][x] = Xblank; - play[SAMPLE_squash] = 1; + play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall); goto loop; } default: Cave[y][x] = Xemerald; Next[y][x] = Xemerald; - PLAY(SAMPLE_diamond); + play_element_sound(x, y, SAMPLE_diamond, Xemerald); goto loop; } @@ -3586,7 +3608,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3721,7 +3743,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3758,7 +3780,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3783,14 +3805,14 @@ void synchro_2(void) } Next[y][x] = Xblank; - play[SAMPLE_squash] = 1; + play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall); goto loop; } default: Cave[y][x] = Xdiamond; Next[y][x] = Xdiamond; - PLAY(SAMPLE_diamond); + play_element_sound(x, y, SAMPLE_diamond, Xdiamond); goto loop; } @@ -3813,7 +3835,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xdrip_stretchB; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -3832,41 +3854,41 @@ void synchro_2(void) switch (RANDOM & 7) { case 0: - temp = Xameuba_1; + temp = Xamoeba_1; break; case 1: - temp = Xameuba_2; + temp = Xamoeba_2; break; case 2: - temp = Xameuba_3; + temp = Xamoeba_3; break; case 3: - temp = Xameuba_4; + temp = Xamoeba_4; break; case 4: - temp = Xameuba_5; + temp = Xamoeba_5; break; case 5: - temp = Xameuba_6; + temp = Xamoeba_6; break; case 6: - temp = Xameuba_7; + temp = Xamoeba_7; break; case 7: - temp = Xameuba_8; + temp = Xamoeba_8; break; } Cave[y][x] = temp; Next[y][x] = temp; - play[SAMPLE_drip] = 1; + play_element_sound(x, y, SAMPLE_drip, Xdrip_fall); goto loop; } @@ -3905,7 +3927,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4025,7 +4047,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4062,7 +4084,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4086,6 +4108,9 @@ void synchro_2(void) Boom[y+1][x-1] = Xblank; Boom[y+1][x] = Xblank; Boom[y+1][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif goto loop; } @@ -4114,7 +4139,7 @@ void synchro_2(void) if (Cave[y-2][x-1] == Xblank) Cave[y-2][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4147,7 +4172,7 @@ void synchro_2(void) if (Cave[y-1][x] == Xblank) Cave[y-1][x] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4180,7 +4205,7 @@ void synchro_2(void) if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4213,7 +4238,7 @@ void synchro_2(void) if (Cave[y-1][x-2] == Xblank) Cave[y-1][x-2] = Yacid_splash_wB; Next[y][x] = Xblank; - PLAY(SAMPLE_acid); + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: @@ -4264,6 +4289,38 @@ void synchro_2(void) Next[y][x] = Xacid_1; goto loop; + case Xfake_acid_1: + Next[y][x] = Xfake_acid_2; + goto loop; + + case Xfake_acid_2: + Next[y][x] = Xfake_acid_3; + goto loop; + + case Xfake_acid_3: + Next[y][x] = Xfake_acid_4; + goto loop; + + case Xfake_acid_4: + Next[y][x] = Xfake_acid_5; + goto loop; + + case Xfake_acid_5: + Next[y][x] = Xfake_acid_6; + goto loop; + + case Xfake_acid_6: + Next[y][x] = Xfake_acid_7; + goto loop; + + case Xfake_acid_7: + Next[y][x] = Xfake_acid_8; + goto loop; + + case Xfake_acid_8: + Next[y][x] = Xfake_acid_1; + goto loop; + /* --------------------------------------------------------------------- */ case Xball_1: @@ -4290,7 +4347,7 @@ void synchro_2(void) ball_common: - play[SAMPLE_ball] = 1; + play_element_sound(x, y, SAMPLE_ball, element); if (lev.ball_random) { switch (RANDOM & 7) @@ -4427,7 +4484,8 @@ void synchro_2(void) } } - lev.ball_pos = (lev.ball_pos + 1) & 7; + lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays; + goto loop; /* --------------------------------------------------------------------- */ @@ -4437,14 +4495,14 @@ void synchro_2(void) { Cave[y-1][x] = Ygrow_ns_eat; Next[y-1][x] = Xgrow_ns; - play[SAMPLE_grow] = 1; + play_element_sound(x, y, SAMPLE_grow, Xgrow_ns); } if (tab_blank[Cave[y+1][x]]) { Cave[y+1][x] = Ygrow_ns_eat; Next[y+1][x] = Xgrow_ns; - play[SAMPLE_grow] = 1; + play_element_sound(x, y, SAMPLE_grow, Xgrow_ns); } goto loop; @@ -4454,14 +4512,14 @@ void synchro_2(void) { Cave[y][x+1] = Ygrow_ew_eat; Next[y][x+1] = Xgrow_ew; - play[SAMPLE_grow] = 1; + play_element_sound(x, y, SAMPLE_grow, Xgrow_ew); } if (tab_blank[Cave[y][x-1]]) { Cave[y][x-1] = Ygrow_ew_eat; Next[y][x-1] = Xgrow_ew; - play[SAMPLE_grow] = 1; + play_element_sound(x, y, SAMPLE_grow, Xgrow_ew); } goto loop; @@ -4472,7 +4530,7 @@ void synchro_2(void) if (lev.wonderwall_time && lev.wonderwall_state) { Cave[y][x] = XwonderwallB; - play[SAMPLE_wonder] = 1; + play_element_sound(x, y, SAMPLE_wonder, Xwonderwall); } goto loop; @@ -4500,6 +4558,8 @@ void synchro_2(void) Next[y][x] = Xexit_1; } + play_element_sound(x, y, SAMPLE_exit_open, Xexit); + goto loop; case Xexit_1: @@ -4517,22 +4577,22 @@ void synchro_2(void) /* --------------------------------------------------------------------- */ case Xdynamite_1: - play[SAMPLE_tick] = 1; + play_element_sound(x, y, SAMPLE_tick, Xdynamite_1); Next[y][x] = Xdynamite_2; goto loop; case Xdynamite_2: - play[SAMPLE_tick] = 1; + play_element_sound(x, y, SAMPLE_tick, Xdynamite_2); Next[y][x] = Xdynamite_3; goto loop; case Xdynamite_3: - play[SAMPLE_tick] = 1; + play_element_sound(x, y, SAMPLE_tick, Xdynamite_3); Next[y][x] = Xdynamite_4; goto loop; case Xdynamite_4: - play[SAMPLE_tick] = 1; + play_element_sound(x, y, SAMPLE_tick, Xdynamite_4); Next[y][x] = Zdynamite; Boom[y-1][x-1] = Xblank; Boom[y-1][x] = Xblank; @@ -4572,21 +4632,21 @@ void synchro_2(void) case Xacid_6: case Xacid_7: case Xacid_8: - Cave[y][x] = Xsand_stonesand_3; + Cave[y][x] = Xsand_stonesand_quickout_1; if (Cave[y][x+1] == Xblank) Cave[y][x+1] = Yacid_splash_eB; if (Cave[y][x-1] == Xblank) Cave[y][x-1] = Yacid_splash_wB; - Next[y][x] = Xsand_stonesand_4; - PLAY(SAMPLE_acid); + Next[y][x] = Xsand_stonesand_quickout_2; + play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; case Xblank: case Yacid_splash_eB: case Yacid_splash_wB: - Cave[y][x] = Xsand_stonesand_3; + Cave[y][x] = Xsand_stonesand_quickout_1; Cave[y+1][x] = Xsand_stoneout_1; - Next[y][x] = Xsand_stonesand_4; + Next[y][x] = Xsand_stonesand_quickout_2; Next[y+1][x] = Xsand_stoneout_2; goto loop; @@ -4633,6 +4693,16 @@ void synchro_2(void) Next[y][x] = Xsand; goto loop; +#if 1 + case Xsand_stonesand_quickout_1: + Next[y][x] = Xsand_stonesand_quickout_2; + goto loop; + + case Xsand_stonesand_quickout_2: + Next[y][x] = Xsand; + goto loop; +#endif + case Xsand_stoneout_1: Next[y][x] = Xsand_stoneout_2; goto loop; @@ -4734,6 +4804,9 @@ void synchro_2(void) Boom[y+1][x-1] = Xemerald; Boom[y+1][x] = Xemerald; Boom[y+1][x+1] = Xemerald; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif goto loop; case Xboom_bomb: @@ -4750,12 +4823,23 @@ void synchro_2(void) Boom[y+1][x-1] = Xblank; Boom[y+1][x] = Xblank; Boom[y+1][x+1] = Xblank; +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, element); +#endif goto loop; case Xboom_android: +#if PLAY_ELEMENT_SOUND + play_element_sound(x, y, SAMPLE_boom, Xandroid); +#endif case Xboom_1: Next[y][x] = Xboom_2; - play[SAMPLE_boom] = 1; +#if !PLAY_ELEMENT_SOUND + if (x != lev.exit_x && y != lev.exit_y) + play_sound(x, y, SAMPLE_boom); + else + lev.exit_x = lev.exit_y = -1; +#endif goto loop; case Xboom_2: @@ -4781,10 +4865,12 @@ void synchro_2(void) done: - if (ply1.alive || ply2.alive) - lev.score += score; /* only get a score if someone is alive */ + if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive) + lev.score += score; /* only add a score if someone is alive */ + else + game_em.game_over = TRUE; - Random = random; + RandomEM = random; { void *temp = Cave; @@ -4795,5 +4881,3 @@ void synchro_2(void) Draw = temp; } } - -#endif