X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=f844675e4f6b562133f4a71efa1c4a13ca19fb77;hb=2d603d06ca862f3ca0721b66f62da188faf866c4;hp=fa1175c0d59b56e24d2dfcd5ecf0bad9f8232473;hpb=4e3bc17b6150a17a76cba2da2daa96af65bde5b9;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index fa1175c0..f844675e 100644 --- a/src/game.c +++ b/src/game.c @@ -76,12 +76,9 @@ #define DX_TIME (DX + XX_TIME) #define DY_TIME (DY + YY_TIME) -#define IS_LOOP_SOUND(s) ((s)==SND_KLAPPER || (s)==SND_ROEHR || \ - (s)==SND_NJAM || (s)==SND_MIEP) -#define IS_MUSIC_SOUND(s) ((s)==SND_ALCHEMY || (s)==SND_CHASE || \ - (s)==SND_NETWORK || (s)==SND_CZARDASZ || \ - (s)==SND_TYGER || (s)==SND_VOYAGER || \ - (s)==SND_TWILIGHT) +/* values for initial player move delay (initial delay counter value) */ +#define INITIAL_MOVE_DELAY_OFF -1 +#define INITIAL_MOVE_DELAY_ON 0 /* values for player movement speed (which is in fact a delay value) */ #define MOVE_DELAY_NORMAL_SPEED 8 @@ -107,11 +104,57 @@ static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); static void KillHeroUnlessProtected(int, int); +void PlaySoundLevel(int, int, int); +void PlaySoundLevelAction(int, int, int); +void PlaySoundLevelElementAction(int, int, int, int); + static void MapGameButtons(); static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; +#define SND_ACTION_UNKNOWN 0 +#define SND_ACTION_WAITING 1 +#define SND_ACTION_MOVING 2 +#define SND_ACTION_DIGGING 3 +#define SND_ACTION_COLLECTING 4 +#define SND_ACTION_PASSING 5 +#define SND_ACTION_IMPACT 6 +#define SND_ACTION_PUSHING 7 +#define SND_ACTION_ACTIVATING 8 +#define SND_ACTION_BURNING 9 + +#define NUM_SND_ACTIONS 10 + +static struct +{ + char *text; + int value; + boolean is_loop; +} sound_action_properties[] = +{ + /* insert _all_ loop sound actions here */ + { ".waiting", SND_ACTION_WAITING, TRUE }, + { ".moving", SND_ACTION_MOVING, TRUE }, /* continuos moving */ + { ".running", SND_ACTION_UNKNOWN, TRUE }, + { ".burning", SND_ACTION_BURNING, TRUE }, + { ".growing", SND_ACTION_UNKNOWN, TRUE }, + { ".attacking", SND_ACTION_UNKNOWN, TRUE }, + + /* other (non-loop) sound actions are optional */ + { ".stepping", SND_ACTION_MOVING, FALSE }, /* discrete moving */ + { ".digging", SND_ACTION_DIGGING, FALSE }, + { ".collecting", SND_ACTION_COLLECTING, FALSE }, + { ".passing", SND_ACTION_PASSING, FALSE }, + { ".impact", SND_ACTION_IMPACT, FALSE }, + { ".pushing", SND_ACTION_PUSHING, FALSE }, + { ".activating", SND_ACTION_ACTIVATING, FALSE }, + { NULL, 0, 0 }, +}; +static int element_action_sound[NUM_LEVEL_ELEMENTS][NUM_SND_ACTIONS]; +static boolean is_loop_sound[NUM_SOUND_EFFECTS]; + +#define IS_LOOP_SOUND(x) (is_loop_sound[x]) #ifdef DEBUG @@ -434,6 +477,14 @@ static void InitField(int x, int y, boolean init_game) void DrawGameDoorValues() { + int i, j; + + for (i=0; igems_still_needed, 3), FS_SMALL, FC_YELLOW); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, @@ -444,12 +495,195 @@ void DrawGameDoorValues() int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); } -void InitGame() + +/* + ============================================================================= + InitGameSound() + ----------------------------------------------------------------------------- + initialize sound effect lookup table for element actions + ============================================================================= +*/ + +void InitGameSound() +{ + int sound_effect_properties[NUM_SOUND_EFFECTS]; + int i, j; + +#if 0 + debug_print_timestamp(0, NULL); +#endif + + for (i=0; i game.engine_version == %06d\n", game.engine_version); +#endif + + /* dynamically adjust player properties according to game engine version */ + game.initial_move_delay = + (game.engine_version <= VERSION_IDENT(2,0,1) ? INITIAL_MOVE_DELAY_ON : + INITIAL_MOVE_DELAY_OFF); + + /* dynamically adjust player properties according to level information */ + game.initial_move_delay_value = + (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); + + /* dynamically adjust element properties according to game engine version */ + { + static int ep_em_slippery_wall[] = + { + EL_BETON, + EL_MAUERWERK, + EL_MAUER_LEBT, + EL_MAUER_X, + EL_MAUER_Y, + EL_MAUER_XY + }; + static int ep_em_slippery_wall_num = SIZEOF_ARRAY_INT(ep_em_slippery_wall); + + for (i=0; i VERSION_IDENT(2,0,1)) + Elementeigenschaften2[EL_MAUERND] |= EP_BIT_EM_SLIPPERY_WALL; + else + Elementeigenschaften2[EL_MAUERND] &= ~EP_BIT_EM_SLIPPERY_WALL; + } +} + + +/* + ============================================================================= + InitGame() + ----------------------------------------------------------------------------- + initialize and start new game + ============================================================================= +*/ + +void InitGame() +{ + int i, j, x, y; + + InitGameEngine(); #if DEBUG #if USE_NEW_AMOEBA_CODE @@ -505,9 +739,8 @@ void InitGame() player->last_move_dir = MV_NO_MOVING; player->is_moving = FALSE; - player->move_delay = -1; /* no initial move delay */ - player->move_delay_value = - (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); + player->move_delay = game.initial_move_delay; + player->move_delay_value = game.initial_move_delay_value; player->push_delay = 0; player->push_delay_value = 5; @@ -584,19 +817,8 @@ void InitGame() } for(y=0; y= GAME_VERSION_2_0) -#endif - Elementeigenschaften2[ep_em_slippery_wall[i]] |= - EP_BIT_EM_SLIPPERY_WALL; - else - Elementeigenschaften2[ep_em_slippery_wall[i]] &= - ~EP_BIT_EM_SLIPPERY_WALL; - } - } - if (BorderElement == EL_LEERRAUM) { SBX_Left = 0; @@ -804,18 +983,7 @@ void InitGame() DX + XX_LEVEL - 1, DY + YY_LEVEL + 1); } -#if 1 DrawGameDoorValues(); -#else - DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); - DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, - int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - DrawText(DX + XX_SCORE, DY + YY_SCORE, - int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); - DrawText(DX + XX_TIME, DY + YY_TIME, - int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); -#endif UnmapGameButtons(); UnmapTapeButtons(); @@ -831,8 +999,9 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - if (setup.sound_music && num_bg_loops) - PlayMusic(level_nr % num_bg_loops); + PlaySoundStereo(SND_GAME_STARTING, SOUND_MAX_RIGHT); + if (setup.sound_music) + PlayMusic(level_nr); KeyboardAutoRepeatOff(); @@ -983,15 +1152,18 @@ void GameWon() local_player->LevelSolved = FALSE; + PlaySoundStereo(SND_GAME_WINNING, SOUND_MAX_RIGHT); + if (TimeLeft) { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + SND_CTRL_PLAY_LOOP); - while(TimeLeft > 0) + while (TimeLeft > 0) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); if (TimeLeft > 0 && !(TimeLeft % 10)) RaiseScore(level.score[SC_ZEITBONUS]); if (TimeLeft > 100 && !(TimeLeft % 10)) @@ -1006,17 +1178,18 @@ void GameWon() } if (!tape.playing && setup.sound_loops) - StopSound(SND_SIRR); + StopSound(SND_GAME_LEVELTIME_BONUS); } else if (level.time == 0) /* level without time limit */ { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + SND_CTRL_PLAY_LOOP); - while(TimePlayed < 999) + while (TimePlayed < 999) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); if (TimePlayed < 999 && !(TimePlayed % 10)) RaiseScore(level.score[SC_ZEITBONUS]); if (TimePlayed < 900 && !(TimePlayed % 10)) @@ -1031,7 +1204,7 @@ void GameWon() } if (!tape.playing && setup.sound_loops) - StopSound(SND_SIRR); + StopSound(SND_GAME_LEVELTIME_BONUS); } #if 0 @@ -1310,8 +1483,8 @@ void CheckDynamite(int x, int y) MovDelay[x][y]--; if (MovDelay[x][y]) { - if (!(MovDelay[x][y] % 12)) - PlaySoundLevel(x, y, SND_ZISCH); + if (!(MovDelay[x][y] % 6)) + PlaySoundLevelAction(x, y, SND_ACTION_BURNING); if (IS_ACTIVE_BOMB(Feld[x][y])) { @@ -1325,7 +1498,11 @@ void CheckDynamite(int x, int y) } } - StopSound(SND_ZISCH); + if (Feld[x][y] == EL_DYNAMITE_ACTIVE) + StopSound(SND_DYNAMITE_BURNING); + else + StopSound(SND_DYNABOMB_BURNING); + Bang(x, y); } @@ -1602,9 +1779,9 @@ void Bang(int x, int y) int element = Feld[x][y]; if (game.emulation == EMU_SUPAPLEX) - PlaySoundLevel(x, y, SND_SP_BOOOM); + PlaySoundLevel(x, y, SND_SP_ELEMENT_EXPLODING); else - PlaySoundLevel(x, y, SND_ROAAAR); + PlaySoundLevel(x, y, SND_ELEMENT_EXPLODING); #if 0 if (IS_PLAYER(x, y)) /* remove objects that might cause smaller explosion */ @@ -1654,7 +1831,7 @@ void Blurb(int x, int y) if (element != EL_BLURB_LEFT && element != EL_BLURB_RIGHT) /* start */ { - PlaySoundLevel(x, y, SND_BLURB); + PlaySoundLevel(x, y, SND_ACID_SPLASHING); if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) && (!IN_LEV_FIELD(x-1, y-1) || !CAN_FALL(MovingOrBlocked2Element(x-1, y-1)))) @@ -1771,13 +1948,13 @@ static void ToggleSwitchgateSwitch(int x, int y) element == EL_SWITCHGATE_OPENING) { Feld[xx][yy] = EL_SWITCHGATE_CLOSING; - PlaySoundLevel(xx, yy, SND_OEFFNEN); + PlaySoundLevel(xx, yy, SND_SWITCHGATE_CLOSING); } else if (element == EL_SWITCHGATE_CLOSED || element == EL_SWITCHGATE_CLOSING) { Feld[xx][yy] = EL_SWITCHGATE_OPENING; - PlaySoundLevel(xx, yy, SND_OEFFNEN); + PlaySoundLevel(xx, yy, SND_SWITCHGATE_OPENING); } } } @@ -1841,7 +2018,7 @@ static void ActivateTimegateSwitch(int x, int y) element == EL_TIMEGATE_CLOSING) { Feld[xx][yy] = EL_TIMEGATE_OPENING; - PlaySoundLevel(xx, yy, SND_OEFFNEN); + PlaySoundLevel(xx, yy, SND_TIMEGATE_OPENING); } /* @@ -1894,7 +2071,7 @@ void Impact(int x, int y) else if (element == EL_PEARL) { Feld[x][y] = EL_PEARL_BREAKING; - PlaySoundLevel(x, y, SND_KNACK); + PlaySoundLevel(x, y, SND_PEARL_BREAKING); return; } @@ -1917,20 +2094,23 @@ void Impact(int x, int y) if (CAN_CHANGE(element) && (smashed == EL_MAGIC_WALL_OFF || smashed == EL_MAGIC_WALL_BD_OFF)) { - int x, y; + int xx, yy; int activated_magic_wall = (smashed == EL_MAGIC_WALL_OFF ? EL_MAGIC_WALL_EMPTY : EL_MAGIC_WALL_BD_EMPTY); /* activate magic wall / mill */ - - for (y=0; y= 0) - PlaySoundLevel(x, y, sound); - } + PlaySoundLevelElementAction(x, y, element, SND_ACTION_IMPACT); } void TurnRound(int x, int y) @@ -2537,6 +2675,7 @@ void StartMoving(int x, int y) InitMovingField(x, y, MV_DOWN); Feld[x][y] = EL_QUICKSAND_EMPTYING; Store[x][y] = EL_FELSBROCKEN; + PlaySoundLevel(x, y, SND_QUICKSAND_EMPTYING); } else if (Feld[x][y+1] == EL_MORAST_LEER) { @@ -2554,6 +2693,7 @@ void StartMoving(int x, int y) Feld[x][y+1] = EL_MORAST_VOLL; Store[x][y+1] = Store[x][y]; Store[x][y] = 0; + PlaySoundLevel(x, y, SND_QUICKSAND_SLIPPING_THROUGH); } } else if ((element == EL_FELSBROCKEN || element == EL_BD_ROCK) && @@ -2562,6 +2702,7 @@ void StartMoving(int x, int y) InitMovingField(x, y, MV_DOWN); Feld[x][y] = EL_QUICKSAND_FILLING; Store[x][y] = element; + PlaySoundLevel(x, y, SND_QUICKSAND_FILLING); } else if (element == EL_MAGIC_WALL_FULL) { @@ -2707,6 +2848,7 @@ void StartMoving(int x, int y) if (element!=EL_MAMPFER && element!=EL_MAMPFER2 && element!=EL_PACMAN) { TurnRound(x, y); + if (MovDelay[x][y] && (element == EL_KAEFER || element == EL_FLIEGER || element == EL_SP_SNIKSNAK || @@ -2725,15 +2867,19 @@ void StartMoving(int x, int y) { int phase = MovDelay[x][y] % 8; - if (phase>3) - phase = 7-phase; + if (phase > 3) + phase = 7 - phase; if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(element)+phase); + DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(element) + phase); - if ((element == EL_MAMPFER || element == EL_MAMPFER2) - && MovDelay[x][y]%4 == 3) - PlaySoundLevel(x, y, SND_NJAM); + if (MovDelay[x][y] % 4 == 3) + { + if (element == EL_MAMPFER) + PlaySoundLevel(x, y, SND_YAMYAM_WAITING); + else if (element == EL_MAMPFER2) + PlaySoundLevel(x, y, SND_DARK_YAMYAM_WAITING); + } } else if (element == EL_SP_ELECTRON) DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL); @@ -2780,17 +2926,12 @@ void StartMoving(int x, int y) } } - if (MovDelay[x][y]) - return; - } + if (MovDelay[x][y]) /* element still has to wait some time */ + { + PlaySoundLevelAction(x, y, SND_ACTION_WAITING); - if (element == EL_KAEFER || element == EL_BUTTERFLY) - { - PlaySoundLevel(x, y, SND_KLAPPER); - } - else if (element == EL_FLIEGER || element == EL_FIREFLY) - { - PlaySoundLevel(x, y, SND_ROEHR); + return; + } } /* now make next step */ @@ -2827,7 +2968,7 @@ void StartMoving(int x, int y) Feld[x][y] = EL_LEERRAUM; DrawLevelField(x, y); - PlaySoundLevel(newx, newy, SND_BUING); + PlaySoundLevel(newx, newy, SND_PENGUIN_ENTERING_EXIT); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) DrawGraphicThruMask(SCREENX(newx), SCREENY(newy), el2gfx(element)); @@ -2865,6 +3006,8 @@ void StartMoving(int x, int y) Feld[newx][newy] = EL_LEERRAUM; DrawLevelField(newx, newy); } + + PlaySoundLevel(x, y, SND_PIG_EATING_GEM); } else if (!IS_FREE(newx, newy)) { @@ -2905,6 +3048,8 @@ void StartMoving(int x, int y) else DrawLevelField(x, y); + PlaySoundLevel(x, y, SND_DRAGON_ATTACKING); + MovDelay[x][y] = 50; Feld[newx][newy] = EL_BURNING; if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_LEERRAUM) @@ -2925,6 +3070,8 @@ void StartMoving(int x, int y) Feld[newx][newy] = EL_LEERRAUM; DrawLevelField(newx, newy); } + + PlaySoundLevel(x, y, SND_YAMYAM_EATING_DIAMOND); } else if (element == EL_MAMPFER2 && IN_LEV_FIELD(newx, newy) && IS_MAMPF2(Feld[newx][newy])) @@ -2944,6 +3091,8 @@ void StartMoving(int x, int y) Feld[newx][newy] = EL_LEERRAUM; DrawLevelField(newx, newy); } + + PlaySoundLevel(x, y, SND_DARK_YAMYAM_EATING_ANY); } else if ((element == EL_PACMAN || element == EL_MOLE) && IN_LEV_FIELD(newx, newy) && IS_AMOEBOID(Feld[newx][newy])) @@ -2959,6 +3108,7 @@ void StartMoving(int x, int y) if (element == EL_MOLE) { Feld[newx][newy] = EL_DEAMOEBING; + PlaySoundLevel(x, y, SND_MOLE_EATING_AMOEBA); MovDelay[newx][newy] = 0; /* start amoeba shrinking delay */ return; /* wait for shrinking amoeba */ } @@ -2966,6 +3116,7 @@ void StartMoving(int x, int y) { Feld[newx][newy] = EL_LEERRAUM; DrawLevelField(newx, newy); + PlaySoundLevel(x, y, SND_PACMAN_EATING_AMOEBA); } } else if (element == EL_MOLE && IN_LEV_FIELD(newx, newy) && @@ -2994,13 +3145,14 @@ void StartMoving(int x, int y) if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); + PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + return; } - if (element == EL_ROBOT && IN_SCR_FIELD(x, y)) - PlaySoundLevel(x, y, SND_SCHLURF); - InitMovingField(x, y, MovDir[x][y]); + + PlaySoundLevelAction(x, y, SND_ACTION_MOVING); } if (MovDir[x][y]) @@ -3040,7 +3192,7 @@ void ContinueMoving(int x, int y) MovPos[x][y] += step; - if (ABS(MovPos[x][y])>=TILEX) /* object reached its destination */ + if (ABS(MovPos[x][y]) >= TILEX) /* object reached its destination */ { Feld[x][y] = EL_LEERRAUM; Feld[newx][newy] = element; @@ -3255,6 +3407,9 @@ void AmoebeUmwandeln(int ax, int ay) } } } + PlaySoundLevel(ax, ay, (IS_GEM(level.amoeba_content) ? + SND_AMOEBA_TURNING_TO_GEM : + SND_AMOEBA_TURNING_TO_ROCK)); Bang(ax, ay); } else @@ -3276,7 +3431,12 @@ void AmoebeUmwandeln(int ax, int ay) continue; if (Feld[x][y] == EL_AMOEBA2DIAM) + { + PlaySoundLevel(x, y, (IS_GEM(level.amoeba_content) ? + SND_AMOEBA_TURNING_TO_GEM : + SND_AMOEBA_TURNING_TO_ROCK)); Bang(x, y); + } } } } @@ -3315,8 +3475,9 @@ void AmoebeUmwandelnBD(int ax, int ay, int new_element) } if (done) - PlaySoundLevel(ax, ay, - (new_element == EL_BD_ROCK ? SND_KLOPF : SND_PLING)); + PlaySoundLevel(ax, ay, (new_element == EL_BD_ROCK ? + SND_BD_AMOEBA_TURNING_TO_ROCK : + SND_BD_AMOEBA_TURNING_TO_GEM)); } void AmoebeWaechst(int x, int y) @@ -3330,7 +3491,10 @@ void AmoebeWaechst(int x, int y) if (DelayReached(&sound_delay, sound_delay_value)) { - PlaySoundLevel(x, y, SND_AMOEBE); + if (Store[x][y] == EL_AMOEBE_BD) + PlaySoundLevel(x, y, SND_BD_AMOEBA_CREATING); + else + PlaySoundLevel(x, y, SND_AMOEBA_CREATING); sound_delay_value = 30; } } @@ -3350,7 +3514,7 @@ void AmoebeWaechst(int x, int y) } } -void AmoebeSchrumpft(int x, int y) +void AmoebaDisappearing(int x, int y) { static unsigned long sound_delay = 0; static unsigned long sound_delay_value = 0; @@ -3360,10 +3524,7 @@ void AmoebeSchrumpft(int x, int y) MovDelay[x][y] = 7; if (DelayReached(&sound_delay, sound_delay_value)) - { - PlaySoundLevel(x, y, SND_BLURB); sound_delay_value = 30; - } } if (MovDelay[x][y]) /* wait some time before shrinking */ @@ -3513,7 +3674,10 @@ void AmoebeAbleger(int ax, int ay) Store[newax][neway] = element; } else if (neway == ay) + { Feld[newax][neway] = EL_TROPFEN; /* drop left or right from amoeba */ + PlaySoundLevel(newax, neway, SND_AMOEBA_DROPPING); + } else { InitMovingField(ax, ay, MV_DOWN); /* drop dripping out of amoeba */ @@ -3532,6 +3696,7 @@ void Life(int ax, int ay) static int life[4] = { 2, 3, 3, 3 }; /* parameters for "game of life" */ int life_time = 40; int element = Feld[ax][ay]; + boolean changed = FALSE; if (Stop[ax][ay]) return; @@ -3570,29 +3735,35 @@ void Life(int ax, int ay) if (xx == ax && yy == ay) /* field in the middle */ { - if (nachbarnlife[1]) + if (nachbarn < life[0] || nachbarn > life[1]) { Feld[xx][yy] = EL_LEERRAUM; if (!Stop[xx][yy]) DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; + changed = TRUE; } } else if (IS_FREE(xx, yy) || Feld[xx][yy] == EL_ERDREICH) { /* free border field */ - if (nachbarn>=life[2] && nachbarn<=life[3]) + if (nachbarn >= life[2] && nachbarn <= life[3]) { Feld[xx][yy] = element; MovDelay[xx][yy] = (element == EL_LIFE ? 0 : life_time-1); if (!Stop[xx][yy]) DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; + changed = TRUE; } } } + + if (changed) + PlaySoundLevel(ax, ay, element == EL_LIFE ? SND_GAMEOFLIFE_CREATING : + SND_BIOMAZE_CREATING); } -void Ablenk(int x, int y) +void RobotWheel(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; @@ -3605,7 +3776,7 @@ void Ablenk(int x, int y) if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) DrawGraphic(SCREENX(x), SCREENY(y), GFX_ABLENK+MovDelay[x][y]%4); if (!(MovDelay[x][y]%4)) - PlaySoundLevel(x, y, SND_MIEP); + PlaySoundLevel(x, y, SND_ROBOT_WHEEL_RUNNING); return; } } @@ -3630,7 +3801,7 @@ void TimegateWheel(int x, int y) DrawGraphic(SCREENX(x), SCREENY(y), GFX_TIMEGATE_SWITCH + MovDelay[x][y]%4); if (!(MovDelay[x][y]%4)) - PlaySoundLevel(x, y, SND_MIEP); + PlaySoundLevel(x, y, SND_TIMEGATE_WHEEL_RUNNING); return; } } @@ -3737,7 +3908,7 @@ void AusgangstuerPruefen(int x, int y) (x > LEVELX(BX2) ? LEVELX(BX2) : x), y < LEVELY(BY1) ? LEVELY(BY1) : (y > LEVELY(BY2) ? LEVELY(BY2) : y), - SND_OEFFNEN); + SND_EXIT_OPENING); } } @@ -3879,7 +4050,7 @@ static void CloseAllOpenTimegates() if (element == EL_TIMEGATE_OPEN || element == EL_TIMEGATE_OPENING) { Feld[x][y] = EL_TIMEGATE_CLOSING; - PlaySoundLevel(x, y, SND_OEFFNEN); + PlaySoundLevel(x, y, SND_TIMEGATE_CLOSING); } } } @@ -3989,6 +4160,7 @@ void MauerAbleger(int ax, int ay) boolean links_frei = FALSE, rechts_frei = FALSE; boolean oben_massiv = FALSE, unten_massiv = FALSE; boolean links_massiv = FALSE, rechts_massiv = FALSE; + boolean new_wall = FALSE; if (!MovDelay[ax][ay]) /* start building new wall */ MovDelay[ax][ay] = 6; @@ -4018,6 +4190,7 @@ void MauerAbleger(int ax, int ay) MovDir[ax][ay-1] = MV_UP; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay-1))) DrawGraphic(SCREENX(ax), SCREENY(ay-1), GFX_MAUER_UP); + new_wall = TRUE; } if (unten_frei) { @@ -4026,6 +4199,7 @@ void MauerAbleger(int ax, int ay) MovDir[ax][ay+1] = MV_DOWN; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay+1))) DrawGraphic(SCREENX(ax), SCREENY(ay+1), GFX_MAUER_DOWN); + new_wall = TRUE; } } @@ -4039,7 +4213,9 @@ void MauerAbleger(int ax, int ay) MovDir[ax-1][ay] = MV_LEFT; if (IN_SCR_FIELD(SCREENX(ax-1), SCREENY(ay))) DrawGraphic(SCREENX(ax-1), SCREENY(ay), GFX_MAUER_LEFT); + new_wall = TRUE; } + if (rechts_frei) { Feld[ax+1][ay] = EL_MAUERND; @@ -4047,6 +4223,7 @@ void MauerAbleger(int ax, int ay) MovDir[ax+1][ay] = MV_RIGHT; if (IN_SCR_FIELD(SCREENX(ax+1), SCREENY(ay))) DrawGraphic(SCREENX(ax+1), SCREENY(ay), GFX_MAUER_RIGHT); + new_wall = TRUE; } } @@ -4067,6 +4244,9 @@ void MauerAbleger(int ax, int ay) ((links_massiv && rechts_massiv) || element == EL_MAUER_Y)) Feld[ax][ay] = EL_MAUERWERK; + + if (new_wall) + PlaySoundLevel(ax, ay, SND_WALL_GROWING); } void CheckForDragon(int x, int y) @@ -4166,7 +4346,7 @@ static void CheckBuggyBase(int x, int y) if (IS_PLAYER(xx, yy)) { - PlaySoundLevel(x, y, SND_SP_BUG); + PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVATING); break; } } @@ -4196,6 +4376,7 @@ static void CheckTrap(int x, int y) return; Feld[x][y] = EL_TRAP_ACTIVE; + PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); } } else if (element == EL_TRAP_ACTIVE) @@ -4247,6 +4428,9 @@ static void DrawBeltAnimation(int x, int y, int element) int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7); DrawGraphicAnimation(x, y, graphic, 8, delay, mode); + + if (!(FrameCounter % 2)) + PlaySoundLevel(x, y, SND_CONVEYOR_BELT_RUNNING); } } @@ -4552,7 +4736,7 @@ void GameActions() else if (element == EL_AMOEBING) AmoebeWaechst(x, y); else if (element == EL_DEAMOEBING) - AmoebeSchrumpft(x, y); + AmoebaDisappearing(x, y); #if !USE_NEW_AMOEBA_CODE else if (IS_AMOEBALIVE(element)) @@ -4562,7 +4746,7 @@ void GameActions() else if (element == EL_LIFE || element == EL_LIFE_ASYNC) Life(x, y); else if (element == EL_ABLENK_EIN) - Ablenk(x, y); + RobotWheel(x, y); else if (element == EL_TIMEGATE_SWITCH_ON) TimegateWheel(x, y); else if (element == EL_SALZSAEURE) @@ -4609,9 +4793,17 @@ void GameActions() else if (element == EL_EXTRA_TIME) DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_NORMAL); else if (element == EL_SHIELD_PASSIVE) + { DrawGraphicAnimation(x, y, GFX_SHIELD_PASSIVE, 6, 4, ANIM_NORMAL); + if (!(FrameCounter % 4)) + PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_ACTIVATED); + } else if (element == EL_SHIELD_ACTIVE) + { DrawGraphicAnimation(x, y, GFX_SHIELD_ACTIVE, 6, 4, ANIM_NORMAL); + if (!(FrameCounter % 4)) + PlaySoundLevel(x, y, SND_SHIELD_ACTIVE_ACTIVATED); + } if (game.magic_wall_active) { @@ -4704,7 +4896,16 @@ void GameActions() if (game.magic_wall_active) { if (!(game.magic_wall_time_left % 4)) - PlaySoundLevel(sieb_x, sieb_y, SND_MIEP); + { + int element = Feld[sieb_x][sieb_y]; + + if (element == EL_MAGIC_WALL_BD_FULL || + element == EL_MAGIC_WALL_BD_EMPTY || + element == EL_MAGIC_WALL_BD_EMPTYING) + PlaySoundLevel(sieb_x, sieb_y, SND_BD_MAGIC_WALL_RUNNING); + else + PlaySoundLevel(sieb_x, sieb_y, SND_MAGIC_WALL_RUNNING); + } if (game.magic_wall_time_left > 0) { @@ -4789,7 +4990,7 @@ void GameActions() TimeLeft--; if (TimeLeft <= 10 && setup.time_limit) - PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MAX_RIGHT); DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); @@ -4797,7 +4998,7 @@ void GameActions() for (i=0; iprogrammed_action = MV_DOWN; } } @@ -5494,8 +5697,8 @@ void BuryHero(struct PlayerInfo *player) if (!player->active) return; - PlaySoundLevel(jx, jy, SND_AUTSCH); - PlaySoundLevel(jx, jy, SND_LACHEN); + PlaySoundLevel(jx, jy, SND_PLAYER_DYING); + PlaySoundLevel(jx, jy, SND_GAME_LOSING); player->GameOver = TRUE; RemoveHero(player); @@ -5534,7 +5737,7 @@ int DigField(struct PlayerInfo *player, dy == +1 ? MV_DOWN : MV_NO_MOVING); int element; - if (!player->MovPos) + if (player->MovPos == 0) player->Pushing = FALSE; if (mode == DF_NO_PUSH) @@ -5582,20 +5785,13 @@ int DigField(struct PlayerInfo *player, switch (element) { case EL_LEERRAUM: - PlaySoundLevel(x, y, SND_EMPTY); - break; - case EL_ERDREICH: case EL_SAND_INVISIBLE: case EL_TRAP_INACTIVE: - Feld[x][y] = EL_LEERRAUM; - PlaySoundLevel(x, y, SND_SCHLURF); - break; - case EL_SP_BASE: case EL_SP_BUG: - Feld[x][y] = EL_LEERRAUM; - PlaySoundLevel(x, y, SND_SP_BASE); + RemoveField(x, y); + PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING); break; case EL_EDELSTEIN: @@ -5617,21 +5813,18 @@ int DigField(struct PlayerInfo *player, DrawText(DX_EMERALDS, DY_EMERALDS, int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); - if (element == EL_SP_INFOTRON) - PlaySoundLevel(x, y, SND_SP_INFOTRON); - else - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); break; case EL_SPEED_PILL: RemoveField(x, y); player->move_delay_value = MOVE_DELAY_HIGH_SPEED; - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_SPEED_PILL_COLLECTING); break; case EL_ENVELOPE: Feld[x][y] = EL_LEERRAUM; - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_ENVELOPE_COLLECTING); break; case EL_EXTRA_TIME: @@ -5641,20 +5834,20 @@ int DigField(struct PlayerInfo *player, TimeLeft += 10; DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); } - PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); + PlaySoundStereo(SND_EXTRA_TIME_COLLECTING, SOUND_MAX_RIGHT); break; case EL_SHIELD_PASSIVE: RemoveField(x, y); player->shield_passive_time_left += 10; - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_COLLECTING); break; case EL_SHIELD_ACTIVE: RemoveField(x, y); player->shield_passive_time_left += 10; player->shield_active_time_left += 10; - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_SHIELD_ACTIVE_COLLECTING); break; case EL_DYNAMITE_INACTIVE: @@ -5665,10 +5858,7 @@ int DigField(struct PlayerInfo *player, DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - if (element == EL_SP_DISK_RED) - PlaySoundLevel(x, y, SND_SP_INFOTRON); - else - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); break; case EL_DYNABOMB_NR: @@ -5676,21 +5866,21 @@ int DigField(struct PlayerInfo *player, player->dynabomb_count++; player->dynabombs_left++; RaiseScoreElement(EL_DYNAMITE_INACTIVE); - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_DYNABOMB_NR_COLLECTING); break; case EL_DYNABOMB_SZ: RemoveField(x, y); player->dynabomb_size++; RaiseScoreElement(EL_DYNAMITE_INACTIVE); - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_DYNABOMB_SZ_COLLECTING); break; case EL_DYNABOMB_XL: RemoveField(x, y); player->dynabomb_xl = TRUE; RaiseScoreElement(EL_DYNAMITE_INACTIVE); - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_DYNABOMB_XL_COLLECTING); break; case EL_SCHLUESSEL1: @@ -5707,7 +5897,7 @@ int DigField(struct PlayerInfo *player, GFX_SCHLUESSEL1 + key_nr); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, GFX_SCHLUESSEL1 + key_nr); - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_KEY_COLLECTING); break; } @@ -5725,7 +5915,7 @@ int DigField(struct PlayerInfo *player, GFX_SCHLUESSEL1 + key_nr); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, GFX_SCHLUESSEL1 + key_nr); - PlaySoundLevel(x, y, SND_PONG); + PlaySoundLevel(x, y, SND_KEY_COLLECTING); break; } @@ -5734,6 +5924,7 @@ int DigField(struct PlayerInfo *player, ZX = x; ZY = y; DrawLevelField(x, y); + PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVATING); return MF_ACTION; break; @@ -5741,6 +5932,8 @@ int DigField(struct PlayerInfo *player, { int xx, yy; + PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVATING); + for (yy=0; yySwitching = TRUE; ToggleBeltSwitch(x, y); + PlaySoundLevel(x, y, SND_CONVEYOR_BELT_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -5782,6 +5976,7 @@ int DigField(struct PlayerInfo *player, { player->Switching = TRUE; ToggleSwitchgateSwitch(x, y); + PlaySoundLevel(x, y, SND_SWITCHGATE_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -5792,12 +5987,16 @@ int DigField(struct PlayerInfo *player, { player->Switching = TRUE; ToggleLightSwitch(x, y); + PlaySoundLevel(x, y, element == EL_LIGHT_SWITCH_OFF ? + SND_LIGHT_SWITCH_ACTIVATING : + SND_LIGHT_SWITCH_DEACTIVATING); } return MF_ACTION; break; case EL_TIMEGATE_SWITCH_OFF: ActivateTimegateSwitch(x, y); + PlaySoundLevel(x, y, SND_TIMEGATE_WHEEL_ACTIVATING); return MF_ACTION; break; @@ -5815,6 +6014,7 @@ int DigField(struct PlayerInfo *player, element == EL_BALLOON_SEND_UP ? MV_UP : element == EL_BALLOON_SEND_DOWN ? MV_DOWN : MV_NO_MOVING); + PlaySoundLevel(x, y, SND_BALLOON_SWITCH_ACTIVATING); return MF_ACTION; break; @@ -5824,11 +6024,11 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; player->LevelSolved = player->GameOver = TRUE; - PlaySoundStereo(SND_SP_EXIT, PSND_MAX_RIGHT); + PlaySoundStereo(SND_SP_EXIT_ENTERING, SOUND_MAX_RIGHT); break; + /* the following elements cannot be pushed by "snapping" */ case EL_FELSBROCKEN: - case EL_BD_ROCK: case EL_BOMBE: case EL_DX_SUPABOMB: case EL_KOKOSNUSS: @@ -5836,7 +6036,12 @@ int DigField(struct PlayerInfo *player, case EL_SP_ZONK: case EL_SP_DISK_ORANGE: case EL_SPRING: - if (dy || mode == DF_SNAP) + if (mode == DF_SNAP) + return MF_NO_ACTION; + /* no "break" -- fall through to next case */ + /* the following elements can be pushed by "snapping" */ + case EL_BD_ROCK: + if (dy) return MF_NO_ACTION; player->Pushing = TRUE; @@ -5863,8 +6068,16 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; #endif - RemoveField(x, y); - Feld[x+dx][y+dy] = element; + if (mode == DF_SNAP) + { + InitMovingField(x, y, move_direction); + ContinueMoving(x, y); + } + else + { + RemoveField(x, y); + Feld[x+dx][y+dy] = element; + } if (element == EL_SPRING) { @@ -5875,14 +6088,7 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8)); DrawLevelField(x+dx, y+dy); - if (element == EL_FELSBROCKEN || element == EL_BD_ROCK) - PlaySoundLevel(x+dx, y+dy, SND_PUSCH); - else if (element == EL_KOKOSNUSS) - PlaySoundLevel(x+dx, y+dy, SND_KNURK); - else if (IS_SP_ELEMENT(element)) - PlaySoundLevel(x+dx, y+dy, SND_SP_ZONKPUSH); - else - PlaySoundLevel(x+dx, y+dy, SND_PUSCH); /* better than "SND_KLOPF" */ + PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); break; case EL_PFORTE1: @@ -5914,8 +6120,7 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE); - + PlaySoundLevel(x, y, SND_GATE_PASSING); break; case EL_EM_GATE_1X: @@ -5931,8 +6136,7 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE); - + PlaySoundLevel(x, y, SND_GATE_PASSING); break; case EL_SWITCHGATE_OPEN: @@ -5944,8 +6148,7 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE); - + PlaySoundLevelElementAction(x, y, element, SND_ACTION_PASSING); break; case EL_SP_PORT1_LEFT: @@ -5987,7 +6190,7 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE); + PlaySoundLevel(x, y, SND_SP_PORT_PASSING); break; case EL_TUBE_CROSS: @@ -6028,6 +6231,8 @@ int DigField(struct PlayerInfo *player, if (!(tube_enter_directions[i][1] & move_direction)) return MF_NO_ACTION; /* tube has no opening in this direction */ + + PlaySoundLevel(x, y, SND_TUBE_PASSING); } break; @@ -6041,7 +6246,7 @@ int DigField(struct PlayerInfo *player, if (mode == DF_SNAP) return MF_NO_ACTION; - PlaySoundLevel(x, y, SND_BUING); + PlaySoundLevel(x, y, SND_EXIT_ENTERING); break; @@ -6049,7 +6254,7 @@ int DigField(struct PlayerInfo *player, Feld[x][y] = EL_BIRNE_EIN; local_player->lights_still_needed--; DrawLevelField(x, y); - PlaySoundLevel(x, y, SND_DENG); + PlaySoundLevel(x, y, SND_LAMP_ACTIVATING); return MF_ACTION; break; @@ -6058,15 +6263,15 @@ int DigField(struct PlayerInfo *player, TimeLeft += 10; DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); DrawLevelField(x, y); - PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); + PlaySoundStereo(SND_TIME_ORB_FULL_COLLECTING, SOUND_MAX_RIGHT); return MF_ACTION; break; case EL_SOKOBAN_FELD_LEER: break; - case EL_SOKOBAN_FELD_VOLL: case EL_SOKOBAN_OBJEKT: + case EL_SOKOBAN_FELD_VOLL: case EL_SONDE: case EL_SP_DISK_YELLOW: case EL_BALLOON: @@ -6120,32 +6325,37 @@ int DigField(struct PlayerInfo *player, Feld[x+dx][y+dy] = EL_SOKOBAN_FELD_VOLL; local_player->sokobanfields_still_needed--; if (element == EL_SOKOBAN_OBJEKT) - PlaySoundLevel(x, y, SND_DENG); + PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_FILLING); + else + PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); } else + { Feld[x+dx][y+dy] = EL_SOKOBAN_OBJEKT; + if (element == EL_SOKOBAN_FELD_VOLL) + PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_CLEARING); + else + PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); + } } else { RemoveField(x, y); Feld[x+dx][y+dy] = element; + PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); } player->push_delay_value = (element == EL_BALLOON ? 0 : 2); DrawLevelField(x, y); DrawLevelField(x+dx, y+dy); - if (element == EL_BALLOON) - PlaySoundLevel(x+dx, y+dy, SND_SCHLURF); - else - PlaySoundLevel(x+dx, y+dy, SND_PUSCH); if (IS_SB_ELEMENT(element) && local_player->sokobanfields_still_needed == 0 && game.emulation == EMU_SOKOBAN) { player->LevelSolved = player->GameOver = TRUE; - PlaySoundLevel(x, y, SND_BUING); + PlaySoundLevel(x, y, SND_SOKOBAN_GAME_SOLVING); } break; @@ -6177,6 +6387,9 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) if (!dx && !dy) { + if (player->MovPos == 0) + player->Pushing = FALSE; + player->snapped = FALSE; return FALSE; } @@ -6230,6 +6443,8 @@ boolean PlaceBomb(struct PlayerInfo *player) else DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT); } + + PlaySoundLevel(jx, jy, SND_DYNAMITE_PLACING); } else { @@ -6238,47 +6453,71 @@ boolean PlaceBomb(struct PlayerInfo *player) player->dynabombs_left--; if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNABOMB); + + PlaySoundLevel(jx, jy, SND_DYNABOMB_PLACING); } return TRUE; } -void PlaySoundLevel(int x, int y, int sound_nr) +void PlaySoundLevel(int x, int y, int nr) { + static int loop_sound_frame[NUM_SOUND_EFFECTS]; + static int loop_sound_volume[NUM_SOUND_EFFECTS]; int sx = SCREENX(x), sy = SCREENY(y); - int volume, stereo; - int silence_distance = 8; + int volume, stereo_position; + int max_distance = 8; + int type = (IS_LOOP_SOUND(nr) ? SND_CTRL_PLAY_LOOP : SND_CTRL_PLAY_SOUND); - if ((!setup.sound_simple && !IS_LOOP_SOUND(sound_nr)) || - (!setup.sound_loops && IS_LOOP_SOUND(sound_nr))) + if ((!setup.sound_simple && !IS_LOOP_SOUND(nr)) || + (!setup.sound_loops && IS_LOOP_SOUND(nr))) return; if (!IN_LEV_FIELD(x, y) || - sx < -silence_distance || sx >= SCR_FIELDX+silence_distance || - sy < -silence_distance || sy >= SCR_FIELDY+silence_distance) + sx < -max_distance || sx >= SCR_FIELDX + max_distance || + sy < -max_distance || sy >= SCR_FIELDY + max_distance) return; - volume = PSND_MAX_VOLUME; - -#if !defined(PLATFORM_MSDOS) - stereo = (sx - SCR_FIELDX/2) * 12; -#else - stereo = PSND_MIDDLE + (2 * sx - (SCR_FIELDX - 1)) * 5; - if (stereo > PSND_MAX_RIGHT) - stereo = PSND_MAX_RIGHT; - if (stereo < PSND_MAX_LEFT) - stereo = PSND_MAX_LEFT; -#endif + volume = SOUND_MAX_VOLUME; if (!IN_SCR_FIELD(sx, sy)) { - int dx = ABS(sx - SCR_FIELDX/2) - SCR_FIELDX/2; - int dy = ABS(sy - SCR_FIELDY/2) - SCR_FIELDY/2; + int dx = ABS(sx - SCR_FIELDX / 2) - SCR_FIELDX / 2; + int dy = ABS(sy - SCR_FIELDY / 2) - SCR_FIELDY / 2; + + volume -= volume * (dx > dy ? dx : dy) / max_distance; + } + + stereo_position = (SOUND_MAX_LEFT + + (sx + max_distance) * SOUND_MAX_LEFT2RIGHT / + (SCR_FIELDX + 2 * max_distance)); + + if (IS_LOOP_SOUND(nr)) + { + /* This assures that quieter loop sounds do not overwrite louder ones, + while restarting sound volume comparison with each new game frame. */ - volume -= volume * (dx > dy ? dx : dy) / silence_distance; + if (loop_sound_volume[nr] > volume && loop_sound_frame[nr] == FrameCounter) + return; + + loop_sound_volume[nr] = volume; + loop_sound_frame[nr] = FrameCounter; } - PlaySoundExt(sound_nr, volume, stereo, PSND_NO_LOOP); + PlaySoundExt(nr, volume, stereo_position, type); +} + +void PlaySoundLevelAction(int x, int y, int sound_action) +{ + PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action); +} + +void PlaySoundLevelElementAction(int x, int y, int element, int sound_action) +{ + int sound_effect = element_action_sound[element][sound_action]; + + if (sound_effect != -1) + PlaySoundLevel(x, y, sound_effect); } void RaiseScore(int value) @@ -6548,8 +6787,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) else if (audio.music_available) { setup.sound = setup.sound_music = TRUE; - if (num_bg_loops) - PlayMusic(level_nr % num_bg_loops); + PlayMusic(level_nr); } break;