From ae6c88d1cec87ff171e5f29936fa18f735845aee Mon Sep 17 00:00:00 2001 From: zsilencer Date: Fri, 16 Oct 2015 02:25:56 -0600 Subject: [PATCH] remove unused/redundant RCT2_GLOBALS fix #2065 and cleanup --- src/audio/audio.c | 99 +++++++++------------ src/game.c | 6 +- src/peep/peep.c | 30 ++----- src/ride/ride.c | 213 ++++++++++++++++++++++----------------------- src/ride/vehicle.c | 34 +------- 5 files changed, 159 insertions(+), 223 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index dfc3b0e598..3934632f3e 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -94,35 +94,34 @@ void audio_get_devices() */ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) { - int result = 0; if (!gGameSoundsOff) { - RCT2_GLOBAL(0x00F438AD, uint8) = 0; + int volumedown = 0; int volume = 0; if (ebx == 0x8001) { rct_map_element* mapelement = map_get_surface_element_at(x / 32, y / 32); if (mapelement) { if ((mapelement->base_height * 8) - 5 > z) { - RCT2_GLOBAL(0x00F438AD, uint8) = 10; + volumedown = 10; } } - sint16 v11; - sint16 v12; + sint16 rx; + sint16 ry; switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { case 0: - v11 = y - x; - v12 = ((y + x) / 2) - z; + rx = y - x; + ry = ((y + x) / 2) - z; break; case 1: - v11 = -x - y; - v12 = ((y - x) / 2) - z; + rx = -x - y; + ry = ((y - x) / 2) - z; break; case 2: - v11 = x - y; - v12 = ((-y - x) / 2) - z; + rx = x - y; + ry = ((-y - x) / 2) - z; break; case 3: - v11 = y + x; - v12 = ((x - y) / 2) - z; + rx = y + x; + ry = ((x - y) / 2) - z; break; } rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); @@ -133,11 +132,11 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) } rct_viewport* viewport = window->viewport; if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { - sint16 v15 = v12 - viewport->view_y; - sint16 v16 = v11 - viewport->view_x; - ebx = viewport->x + (v16 >> viewport->zoom); - volume = RCT2_ADDRESS(0x0099282C, int)[sound_id] + ((-1024 * viewport->zoom - 1) << RCT2_GLOBAL(0x00F438AD, uint8)) + 1; - if (v15 < 0 || v15 >= viewport->view_height || v16 < 0 || v16 >= viewport->view_width || volume < -10000) { + sint16 vy = ry - viewport->view_y; + sint16 vx = rx - viewport->view_x; + ebx = viewport->x + (vx >> viewport->zoom); + volume = RCT2_ADDRESS(0x0099282C, int)[sound_id] + ((-1024 * viewport->zoom - 1) << volumedown) + 1; + if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || volume < -10000) { return sound_id; } } @@ -154,12 +153,9 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) } pan = ((x2 / screenwidth) - 0x8000) >> 4; } - if (!RCT2_GLOBAL(0x009AAC6D, uint8)) { - pan = 0; - } Mixer_Play_Effect(sound_id, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 1); } - return result; + return 0; } /** @@ -186,16 +182,12 @@ void start_title_music() break; } - if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && !gGameSoundsOff - && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { - if (!RCT2_GLOBAL(0x009AF600, uint8)) { + if (!gGameSoundsOff && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { + if (!gTitleMusicChannel) { gTitleMusicChannel = Mixer_Play_Music(musicPathId, MIXER_LOOP_INFINITE, true); - RCT2_GLOBAL(0x009AF600, uint8) = 1; } } else { - if (RCT2_GLOBAL(0x009AF600, uint8)) { - stop_title_music(); - } + stop_title_music(); } } @@ -205,13 +197,13 @@ void start_title_music() */ void stop_ride_music() { - if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) { - for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { - rct_ride_music* ride_music = &gRideMusicList[i]; - if (ride_music->rideid != (uint8)-1) { + for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { + rct_ride_music* ride_music = &gRideMusicList[i]; + if (ride_music->rideid != (uint8)-1) { + if (ride_music->sound_channel) { Mixer_Stop_Channel(ride_music->sound_channel); - ride_music->rideid = -1; } + ride_music->rideid = -1; } } } @@ -222,14 +214,9 @@ void stop_ride_music() */ void stop_crowd_sound() { - if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) { - if (RCT2_GLOBAL(0x009AF5FC, uint32) != 1) { - if (gCrowdSoundChannel) { - Mixer_Stop_Channel(gCrowdSoundChannel); - gCrowdSoundChannel = 0; - } - RCT2_GLOBAL(0x009AF5FC, uint32) = 1; - } + if (gCrowdSoundChannel) { + Mixer_Stop_Channel(gCrowdSoundChannel); + gCrowdSoundChannel = 0; } } @@ -239,15 +226,10 @@ void stop_crowd_sound() */ void stop_title_music() { - if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) { - if (RCT2_GLOBAL(0x009AF600, uint8) != 0) { - if (gTitleMusicChannel) { - Mixer_Stop_Channel(gTitleMusicChannel); - gTitleMusicChannel = 0; - } - } + if (gTitleMusicChannel) { + Mixer_Stop_Channel(gTitleMusicChannel); + gTitleMusicChannel = 0; } - RCT2_GLOBAL(0x009AF600, uint8) = 0; } /** @@ -264,10 +246,11 @@ void audio_init1() const utf8* path = get_file_path(ride_music_info->pathid); SDL_RWops *file = SDL_RWFromFile(path, "rb"); if (file != NULL) { - SDL_RWread(file, &RCT2_GLOBAL(0x009AF47E, uint32), 4, 1); + uint32 head; + SDL_RWread(file, &head, sizeof(head), 1); SDL_RWclose(file); RCT2_GLOBAL(0x014241BC, uint32) = 0; - if (RCT2_GLOBAL(0x009AF47E, uint32) == 0x78787878) { + if (head == 0x78787878) { ride_music_info->length = 0; } } @@ -283,12 +266,10 @@ void audio_init2(int device) audio_close(); for (int i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) { rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i]; - vehicle_sound->id = 0xFFFF; + vehicle_sound->id = -1; } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = device; - RCT2_GLOBAL(0x009AAC5C, uint8) = 1; config_save_default(); - RCT2_GLOBAL(0x009AF284, uint32) |= (1 << 0); for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { rct_ride_music* ride_music = &gRideMusicList[i]; ride_music->rideid = -1; @@ -303,9 +284,7 @@ void audio_close() { stop_crowd_sound(); stop_title_music(); - if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) { - stop_ride_music(); - } + stop_ride_music(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1; } @@ -326,7 +305,7 @@ void toggle_all_sounds(){ */ void pause_sounds() { - gGameSoundsOff = 1; + gGameSoundsOff = true; stop_vehicle_sounds(); stop_ride_music(); stop_crowd_sound(); @@ -338,7 +317,7 @@ void pause_sounds() */ void unpause_sounds() { - gGameSoundsOff = 0; + gGameSoundsOff = false; } /** diff --git a/src/game.c b/src/game.c index d1357b6175..ad6f2c4be4 100644 --- a/src/game.c +++ b/src/game.c @@ -539,10 +539,12 @@ void pause_toggle() { RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) ^= 1; window_invalidate_by_class(WC_TOP_TOOLBAR); - if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1) { pause_sounds(); - else unpause_sounds(); + } else { + unpause_sounds(); + } } /** diff --git a/src/peep/peep.c b/src/peep/peep.c index 9c2f09693d..4baff8613e 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -5156,9 +5156,6 @@ void peep_update_crowd_noise() rct_peep *peep; int visiblePeeps; - if (!(RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) - return; - if (gGameSoundsOff) return; @@ -5198,10 +5195,9 @@ void peep_update_crowd_noise() visiblePeeps = (visiblePeeps / 2) - 6; if (visiblePeeps < 0) { // Mute crowd noise - if (RCT2_GLOBAL(0x009AF5FC, uint32) != 1) { + if (gCrowdSoundChannel) { Mixer_Stop_Channel(gCrowdSoundChannel); gCrowdSoundChannel = 0; - RCT2_GLOBAL(0x009AF5FC, uint32) = 1; } } else { sint32 volume; @@ -5212,26 +5208,16 @@ void peep_update_crowd_noise() volume = volume * volume * volume * volume; volume = (((207360000 - volume) >> viewport->zoom) - 207360000) / 65536 - 150; - // Check if crowd noise is already playing - if (RCT2_GLOBAL(0x009AF5FC, uint32) == 1) { - // Load and play crowd noise - if (!gCrowdSoundChannel) { - gCrowdSoundChannel = Mixer_Play_Music(PATH_ID_CSS2, MIXER_LOOP_INFINITE, false); - if (gCrowdSoundChannel) { - Mixer_Channel_SetGroup(gCrowdSoundChannel, MIXER_GROUP_NONE); - } - } + // Load and play crowd noise if needed and set volume + if (!gCrowdSoundChannel) { + gCrowdSoundChannel = Mixer_Play_Music(PATH_ID_CSS2, MIXER_LOOP_INFINITE, false); if (gCrowdSoundChannel) { - Mixer_Channel_Volume(gCrowdSoundChannel, DStoMixerVolume(volume)); - RCT2_GLOBAL(0x009AF5FC, uint32) = volume; - } - } else { - // Alter crowd noise volume - if (RCT2_GLOBAL(0x009AF5FC, uint32) != volume) { - Mixer_Channel_Volume(gCrowdSoundChannel, DStoMixerVolume(volume)); - RCT2_GLOBAL(0x009AF5FC, uint32) = volume; + Mixer_Channel_SetGroup(gCrowdSoundChannel, MIXER_GROUP_NONE); } } + if (gCrowdSoundChannel) { + Mixer_Channel_Volume(gCrowdSoundChannel, DStoMixerVolume(volume)); + } } } diff --git a/src/ride/ride.c b/src/ride/ride.c index d1a2696aed..6647246b6f 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3328,10 +3328,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint if (panx < -10000) { panx = -10000; } - if (!RCT2_GLOBAL(0x009AAC6D, uint8)) { - panx = 0; - } - rct_ride_music* ride_music = &gRideMusicList[0];//&RCT2_GLOBAL(0x009AF46C, rct_ride_music); + rct_ride_music* ride_music = &gRideMusicList[0]; int channel = 0; uint32 a1; while (ride_music->rideid != rideIndex || ride_music->tuneid != *tuneId) { @@ -3352,15 +3349,15 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint label51: if (a1 < ride_music_info_list[*tuneId]->length) { position = a1; - rct_ride_music_params* ride_music_params = gRideMusicParamsListEnd;//RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*); - if (ride_music_params < &gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]/*(rct_ride_music_params*)0x009AF46C*/) { + rct_ride_music_params* ride_music_params = gRideMusicParamsListEnd; + if (ride_music_params < &gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]) { ride_music_params->rideid = rideIndex; ride_music_params->tuneid = *tuneId; ride_music_params->offset = a1; ride_music_params->volume = v32; ride_music_params->pan = panx; ride_music_params->freq = RCT2_GLOBAL(0x009AF47C, uint16); - gRideMusicParamsListEnd++;//RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)++; + gRideMusicParamsListEnd++; } } else { *tuneId = 0xFF; @@ -3443,124 +3440,122 @@ void ride_music_update_final() rct_ride_music_params* edi = NULL; int ebx; if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) { - if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) { - if (!gGameSoundsOff && gConfigSound.sound && gConfigSound.ride_music && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) { - // set to stop music if volume <= 1 ? - while (1) { - int v8 = 0; - int v9 = 1; - rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0];//&RCT2_GLOBAL(0x009AF430, rct_ride_music_params); - while (ride_music_params < gRideMusicParamsListEnd/*RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)*/) { - if (ride_music_params->rideid != (uint8)-1) { - rct_ride_music_info* ride_music_info = ride_music_info_list[ride_music_params->tuneid]; - if (RCT2_ADDRESS(0x009AA0B1, uint8*)[ride_music_info->pathid]) { // file_on_cdrom[] - v8++; - if (v9 >= ride_music_params->volume) { - v9 = ride_music_params->volume; - edi = ride_music_params; - } - } - } - ride_music_params++; - } - if (v8 <= 1) { - break; - } - edi->rideid = -1; - } - while (1) { - int v8 = 0; - int v9 = 1; - rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0];//&RCT2_GLOBAL(0x009AF430, rct_ride_music_params); - while (ride_music_params < gRideMusicParamsListEnd/*RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)*/) { - if (ride_music_params->rideid != (uint8)-1) { + if (!gGameSoundsOff && gConfigSound.sound && gConfigSound.ride_music && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) { + // set to stop music if volume <= 1 ? + while (1) { + int v8 = 0; + int v9 = 1; + rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]; + while (ride_music_params < gRideMusicParamsListEnd) { + if (ride_music_params->rideid != (uint8)-1) { + rct_ride_music_info* ride_music_info = ride_music_info_list[ride_music_params->tuneid]; + if (RCT2_ADDRESS(0x009AA0B1, uint8*)[ride_music_info->pathid]) { // file_on_cdrom[] v8++; if (v9 >= ride_music_params->volume) { v9 = ride_music_params->volume; edi = ride_music_params; } } + } + ride_music_params++; + } + if (v8 <= 1) { + break; + } + edi->rideid = -1; + } + while (1) { + int v8 = 0; + int v9 = 1; + rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]; + while (ride_music_params < gRideMusicParamsListEnd) { + if (ride_music_params->rideid != (uint8)-1) { + v8++; + if (v9 >= ride_music_params->volume) { + v9 = ride_music_params->volume; + edi = ride_music_params; + } + } + ride_music_params++; + } + if (v8 <= 2) { + break; + } + edi->rideid = -1; + } + + // stop currently playing music that is not in music params list or not playing? + rct_ride_music* ride_music = &gRideMusicList[0]; + int channel = 0; + do { + if (ride_music->rideid != (uint8)-1) { + rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]; + while (ride_music_params < gRideMusicParamsListEnd) { + if (ride_music_params->rideid == ride_music->rideid && ride_music_params->tuneid == ride_music->tuneid) { + int isplaying = Mixer_Channel_IsPlaying(gRideMusicList[channel].sound_channel); + if (isplaying) { + goto label32; + } + break; + } ride_music_params++; } - if (v8 <= 2) { - break; - } - edi->rideid = -1; + Mixer_Stop_Channel(gRideMusicList[channel].sound_channel); + ride_music->rideid = -1; } + label32: + ride_music++; + channel++; + } while(channel < AUDIO_MAX_RIDE_MUSIC); - // stop currently playing music that is not in music params list or not playing? - rct_ride_music* ride_music = &gRideMusicList[0];//&RCT2_GLOBAL(0x009AF46C, rct_ride_music); - int channel = 0; - do { - if (ride_music->rideid != (uint8)-1) { - rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0];//&RCT2_GLOBAL(0x009AF430, rct_ride_music_params); - while (ride_music_params < gRideMusicParamsListEnd/*RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)*/) { - if (ride_music_params->rideid == ride_music->rideid && ride_music_params->tuneid == ride_music->tuneid) { - int isplaying = Mixer_Channel_IsPlaying(gRideMusicList[channel].sound_channel); - if (isplaying) { - goto label32; + for (rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]; ride_music_params < gRideMusicParamsListEnd; ride_music_params++) { + if (ride_music_params->rideid != (uint8)-1) { + rct_ride_music* ride_music = &gRideMusicList[0]; + int channel = 0; + while (ride_music_params->rideid != ride_music->rideid || ride_music_params->tuneid != ride_music->tuneid) { + if (ride_music->rideid == (uint8)-1) { + ebx = channel; + } + ride_music++; + channel++; + if (channel >= AUDIO_MAX_RIDE_MUSIC) { + rct_ride_music_info* ride_music_info = ride_music_info_list[ride_music_params->tuneid]; + rct_ride_music* ride_music = &gRideMusicList[ebx]; + ride_music->sound_channel = Mixer_Play_Music(ride_music_info->pathid, MIXER_LOOP_NONE, true); + if (ride_music->sound_channel) { + ride_music->volume = ride_music_params->volume; + ride_music->pan = ride_music_params->pan; + ride_music->freq = ride_music_params->freq; + ride_music->rideid = ride_music_params->rideid; + ride_music->tuneid = ride_music_params->tuneid; + Mixer_Channel_Volume(ride_music->sound_channel, DStoMixerVolume(ride_music->volume)); + Mixer_Channel_Pan(ride_music->sound_channel, DStoMixerPan(ride_music->pan)); + Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->freq)); + int offset = ride_music_params->offset - 10000; + if (offset < 0) { + offset = 0; } - break; + Mixer_Channel_SetOffset(ride_music->sound_channel, offset); + } else { + //RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = 0; } - ride_music_params++; + return; } - Mixer_Stop_Channel(gRideMusicList[channel].sound_channel); - ride_music->rideid = -1; } - label32: - ride_music++; - channel++; - } while(channel < AUDIO_MAX_RIDE_MUSIC); - - for (rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]/*&RCT2_GLOBAL(0x009AF430, rct_ride_music_params)*/; ride_music_params < gRideMusicParamsListEnd/*RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)*/; ride_music_params++) { - if (ride_music_params->rideid != (uint8)-1) { - rct_ride_music* ride_music = &gRideMusicList[0];//&RCT2_GLOBAL(0x009AF46C, rct_ride_music); - int channel = 0; - while (ride_music_params->rideid != ride_music->rideid || ride_music_params->tuneid != ride_music->tuneid) { - if (ride_music->rideid == (uint8)-1) { - ebx = channel; - } - ride_music++; - channel++; - if (channel >= AUDIO_MAX_RIDE_MUSIC) { - rct_ride_music_info* ride_music_info = ride_music_info_list[ride_music_params->tuneid]; - rct_ride_music* ride_music = &gRideMusicList[ebx]; - ride_music->sound_channel = Mixer_Play_Music(ride_music_info->pathid, MIXER_LOOP_NONE, true); - if (ride_music->sound_channel) { - ride_music->volume = ride_music_params->volume; - ride_music->pan = ride_music_params->pan; - ride_music->freq = ride_music_params->freq; - ride_music->rideid = ride_music_params->rideid; - ride_music->tuneid = ride_music_params->tuneid; - Mixer_Channel_Volume(ride_music->sound_channel, DStoMixerVolume(ride_music->volume)); - Mixer_Channel_Pan(ride_music->sound_channel, DStoMixerPan(ride_music->pan)); - Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->freq)); - int offset = ride_music_params->offset - 10000; - if (offset < 0) { - offset = 0; - } - Mixer_Channel_SetOffset(ride_music->sound_channel, offset); - } else { - //RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = 0; - } - return; - } - } - - if (ride_music_params->volume != ride_music->volume) { - ride_music->volume = ride_music_params->volume; - Mixer_Channel_Volume(ride_music->sound_channel, DStoMixerVolume(ride_music->volume)); - } - if (ride_music_params->pan != ride_music->pan) { - ride_music->pan = ride_music_params->pan; - Mixer_Channel_Pan(ride_music->sound_channel, DStoMixerPan(ride_music->pan)); - } - if (ride_music_params->freq != ride_music->freq) { - ride_music->freq = ride_music_params->freq; - Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->freq)); - } + if (ride_music_params->volume != ride_music->volume) { + ride_music->volume = ride_music_params->volume; + Mixer_Channel_Volume(ride_music->sound_channel, DStoMixerVolume(ride_music->volume)); } + if (ride_music_params->pan != ride_music->pan) { + ride_music->pan = ride_music_params->pan; + Mixer_Channel_Pan(ride_music->sound_channel, DStoMixerPan(ride_music->pan)); + } + if (ride_music_params->freq != ride_music->freq) { + ride_music->freq = ride_music_params->freq; + Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->freq)); + } + } } } diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index a51b2aa365..4b03ba9c20 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -63,17 +63,11 @@ void vehicle_update_sound_params(rct_vehicle* vehicle) if (t8 >= RCT2_GLOBAL(0x009AF5A0, sint16) && t9 >= RCT2_GLOBAL(0x009AF5A2, sint16)) { uint16 v9 = sub_6BC2F3(vehicle); rct_vehicle_sound_params* i; - //for (i = RCT2_ADDRESS(0x00F438B4, rct_vehicle_sound_params); i < RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*) && v9 <= i->var_A; i++); for (i = &gVehicleSoundParamsList[0]; i < gVehicleSoundParamsListEnd && v9 <= i->var_A; i++); - //if (i < RCT2_ADDRESS(0x00F43908, rct_vehicle_sound_params)) { // 0x00F43908 is end of rct_vehicle_sound_params list, which has 7 elements, not to be confused with variable at 0x00F43908 if (i < &gVehicleSoundParamsList[countof(gVehicleSoundParamsList)]) { - //if (RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*) < RCT2_ADDRESS(0x00F43908, rct_vehicle_sound_params)) { - // RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*)++; - //} if (gVehicleSoundParamsListEnd < &gVehicleSoundParamsList[countof(gVehicleSoundParamsList)]) { gVehicleSoundParamsListEnd++; } - //rct_vehicle_sound_params* j = RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*) - 1; rct_vehicle_sound_params* j = gVehicleSoundParamsListEnd - 1; while (j >= i) { j--; @@ -195,17 +189,13 @@ void vehicle_sounds_update() } } } - //label12: - //RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params**) = &RCT2_GLOBAL(0x00F438B4, rct_vehicle_sound_params*); gVehicleSoundParamsListEnd = &gVehicleSoundParamsList[0]; for (uint16 i = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_VEHICLE, uint16); i != SPRITE_INDEX_NULL; i = g_sprite_list[i].vehicle.next) { vehicle_update_sound_params(&g_sprite_list[i].vehicle); } - //for (rct_vehicle_sound* vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound); vehicle_sound != &RCT2_GLOBAL(0x009AF42C, rct_vehicle_sound); vehicle_sound++) { for(int i = 0; i < countof(gVehicleSoundList); i++){ rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i]; if (vehicle_sound->id != (uint16)-1) { - //for (rct_vehicle_sound_params* vehicle_sound_params = &RCT2_GLOBAL(0x00F438B4, rct_vehicle_sound_params); vehicle_sound_params != RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*); vehicle_sound_params++) { for (rct_vehicle_sound_params* vehicle_sound_params = &gVehicleSoundParamsList[0]; vehicle_sound_params != gVehicleSoundParamsListEnd; vehicle_sound_params++) { if (vehicle_sound->id == vehicle_sound_params->id) { goto label26; @@ -223,10 +213,8 @@ void vehicle_sounds_update() ; } - //for (rct_vehicle_sound_params* vehicle_sound_params = &RCT2_GLOBAL(0x00F438B4, rct_vehicle_sound_params); ; vehicle_sound_params++) { for (rct_vehicle_sound_params* vehicle_sound_params = &gVehicleSoundParamsList[0]; ; vehicle_sound_params++) { label28: - //if (vehicle_sound_params >= RCT2_GLOBAL(0x00F438B0, rct_vehicle_sound_params*)) { if (vehicle_sound_params >= gVehicleSoundParamsListEnd) { return; } @@ -284,18 +272,15 @@ void vehicle_sounds_update() } rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[0]; - //rct_vehicle_sound* vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound); while (vehicle_sound_params->id != vehicle_sound->id) { - vehicle_sound++; // went here 2x - //if (vehicle_sound >= &RCT2_GLOBAL(0x009AF42C, rct_vehicle_sound)) { + vehicle_sound++; if (vehicle_sound >= &gVehicleSoundList[countof(gVehicleSoundList)]) { - //vehicle_sound = &RCT2_GLOBAL(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound); vehicle_sound = &gVehicleSoundList[0]; int i = 0; while (vehicle_sound->id != (uint16)-1) { vehicle_sound++; i++; - if (i >= countof(gVehicleSoundList)/*i >= RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MAX_VEHICLE_SOUNDS, uint8)*/) { + if (i >= countof(gVehicleSoundList)) { vehicle_sound_params = (rct_vehicle_sound_params*)((int)vehicle_sound_params + 10); goto label28; } @@ -354,9 +339,6 @@ void vehicle_sounds_update() } uint8 looping = RCT2_ADDRESS(0x009AF51E, uint8)[2 * sprite->vehicle.sound1_id]; int pan = vehicle_sound_params->panx; - if (!RCT2_GLOBAL(0x009AAC6D, uint8)) { - pan = 0; - } vehicle_sound->sound1_channel = Mixer_Play_Effect(sprite->vehicle.sound1_id, looping ? MIXER_LOOP_INFINITE : MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), DStoMixerRate(frequency), 0); goto label87; } @@ -366,9 +348,7 @@ void vehicle_sounds_update() } if (vehicle_sound_params->panx != vehicle_sound->sound1_pan) { vehicle_sound->sound1_pan = vehicle_sound_params->panx; - if (RCT2_GLOBAL(0x009AAC6D, uint8)) { - Mixer_Channel_Pan(vehicle_sound->sound1_channel, DStoMixerPan(vehicle_sound_params->panx)); - } + Mixer_Channel_Pan(vehicle_sound->sound1_channel, DStoMixerPan(vehicle_sound_params->panx)); } if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) && vehicle_sound_params->frequency != vehicle_sound->sound1_freq) { vehicle_sound->sound1_freq = vehicle_sound_params->frequency; @@ -414,9 +394,6 @@ void vehicle_sounds_update() } uint8 looping = RCT2_ADDRESS(0x009AF51E, uint8)[2 * sprite->vehicle.sound2_id]; int pan = vehicle_sound_params->panx; - if (!RCT2_GLOBAL(0x009AAC6D, uint8)) { - pan = 0; - } vehicle_sound->sound2_channel = Mixer_Play_Effect(sprite->vehicle.sound2_id, looping ? MIXER_LOOP_INFINITE : MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), DStoMixerRate(frequency), 0); goto label114; } @@ -426,9 +403,7 @@ void vehicle_sounds_update() } if (vehicle_sound_params->panx != vehicle_sound->sound2_pan) { vehicle_sound->sound2_pan = vehicle_sound_params->panx; - if (RCT2_GLOBAL(0x009AAC6D, uint8)) { - Mixer_Channel_Pan(vehicle_sound->sound2_channel, DStoMixerPan(vehicle_sound_params->panx)); - } + Mixer_Channel_Pan(vehicle_sound->sound2_channel, DStoMixerPan(vehicle_sound_params->panx)); } if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) && vehicle_sound_params->frequency != vehicle_sound->sound2_freq) { vehicle_sound->sound2_freq = vehicle_sound_params->frequency; @@ -438,7 +413,6 @@ void vehicle_sounds_update() frequency = 25700; } Mixer_Channel_Rate(vehicle_sound->sound2_channel, DStoMixerRate(frequency)); - } } }