From 3a8b25a0eeab28349623ceeb9207e2f4c3f5ff3e Mon Sep 17 00:00:00 2001 From: Dom Light Date: Mon, 16 Nov 2015 22:39:40 +0000 Subject: [PATCH 01/10] Sanitize audio.h --- src/audio/audio.c | 50 +++++------ src/audio/audio.h | 117 +++++++++++++------------- src/audio/mixer.cpp | 20 ++--- src/audio/mixer.h | 2 +- src/editor.c | 4 +- src/game.c | 20 ++--- src/input.c | 4 +- src/interface/window.c | 2 +- src/management/news_item.c | 2 +- src/openrct2.c | 16 ++-- src/peep/peep.c | 14 +-- src/rct2.c | 4 +- src/ride/ride.c | 78 ++++++++--------- src/ride/track.c | 4 +- src/ride/vehicle.c | 88 +++++++++---------- src/title.c | 6 +- src/windows/editor_bottom_toolbar.c | 4 +- src/windows/editor_object_selection.c | 2 +- src/windows/error.c | 2 +- src/windows/footpath.c | 4 +- src/windows/install_track.c | 2 +- src/windows/map.c | 2 +- src/windows/maze_construction.c | 4 +- src/windows/new_ride.c | 2 +- src/windows/news.c | 4 +- src/windows/options.c | 8 +- src/windows/ride.c | 8 +- src/windows/ride_construction.c | 10 +-- src/windows/save_prompt.c | 4 +- src/windows/scenery.c | 2 +- src/windows/title_scenarioselect.c | 2 +- src/windows/top_toolbar.c | 16 ++-- src/windows/track_list.c | 2 +- src/windows/track_place.c | 4 +- src/world/balloon.c | 2 +- src/world/duck.c | 2 +- src/world/map.c | 12 +-- src/world/particle.c | 2 +- 38 files changed, 264 insertions(+), 267 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index 02f67c061e..d6721f347f 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -94,7 +94,7 @@ void audio_get_devices() * @param y (dx) * @param z (bp) */ -int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) +int audio_sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) { if (!gGameSoundsOff) { int volumedown = 0; @@ -164,7 +164,7 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) * * rct2: 0x006BD0F8 */ -void start_title_music() +void audio_start_title_music() { int musicPathId; switch (gConfigSound.title_music) { @@ -189,7 +189,7 @@ void start_title_music() gTitleMusicChannel = Mixer_Play_Music(musicPathId, MIXER_LOOP_INFINITE, true); } } else { - stop_title_music(); + audio_stop_title_music(); } } @@ -197,15 +197,15 @@ void start_title_music() * * rct2: 0x006BCA9F */ -void stop_ride_music() +void audio_stop_ride_music() { 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->ride_id != (uint8)-1) { if (ride_music->sound_channel) { Mixer_Stop_Channel(ride_music->sound_channel); } - ride_music->rideid = -1; + ride_music->ride_id = -1; } } } @@ -214,7 +214,7 @@ void stop_ride_music() * * rct2: 0x006BD07F */ -void stop_crowd_sound() +void audio_stop_crowd_sound() { if (gCrowdSoundChannel) { Mixer_Stop_Channel(gCrowdSoundChannel); @@ -226,7 +226,7 @@ void stop_crowd_sound() * * rct2: 0x006BD0BD */ -void stop_title_music() +void audio_stop_title_music() { if (gTitleMusicChannel) { Mixer_Stop_Channel(gTitleMusicChannel); @@ -251,9 +251,9 @@ void audio_init1() int devicenum = 0; audio_init2(devicenum); - for(int m = 0; m < countof(ride_music_info_list); m++) { - rct_ride_music_info* ride_music_info = ride_music_info_list[m]; - const utf8* path = get_file_path(ride_music_info->pathid); + for(int m = 0; m < countof(gRideMusicInfoList); m++) { + rct_ride_music_info* ride_music_info = gRideMusicInfoList[m]; + const utf8* path = get_file_path(ride_music_info->path_id); SDL_RWops *file = SDL_RWFromFile(path, "rb"); if (file != NULL) { uint32 head; @@ -282,7 +282,7 @@ void audio_init2(int device) config_save_default(); for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { rct_ride_music* ride_music = &gRideMusicList[i]; - ride_music->rideid = -1; + ride_music->ride_id = -1; } } @@ -292,21 +292,21 @@ void audio_init2(int device) */ void audio_close() { - stop_crowd_sound(); - stop_title_music(); - stop_ride_music(); + audio_stop_crowd_sound(); + audio_stop_title_music(); + audio_stop_ride_music(); stop_rain_sound(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1; } /* rct2: 0x006BAB8A */ -void toggle_all_sounds(){ +void audio_toggle_all_sounds(){ gConfigSound.sound = !gConfigSound.sound; if (!gConfigSound.sound) { - stop_title_music(); - pause_sounds(); + audio_stop_title_music(); + audio_pause_sounds(); } else { - unpause_sounds(); + audio_unpause_sounds(); } } @@ -314,12 +314,12 @@ void toggle_all_sounds(){ * * rct2: 0x006BABB4 */ -void pause_sounds() +void audio_pause_sounds() { gGameSoundsOff = true; - stop_vehicle_sounds(); - stop_ride_music(); - stop_crowd_sound(); + audio_stop_vehicle_sounds(); + audio_stop_ride_music(); + audio_stop_crowd_sound(); stop_rain_sound(); } @@ -327,7 +327,7 @@ void pause_sounds() * * rct2: 0x006BABD8 */ -void unpause_sounds() +void audio_unpause_sounds() { gGameSoundsOff = false; } @@ -336,7 +336,7 @@ void unpause_sounds() * * rct2: 0x006BABDF */ -void stop_vehicle_sounds() +void audio_stop_vehicle_sounds() { if (!gOpenRCT2Headless && RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) { for (int i = 0; i < countof(gVehicleSoundList); i++) { diff --git a/src/audio/audio.h b/src/audio/audio.h index 7c3030903a..6ec60fc572 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -25,20 +25,38 @@ #include "../world/sprite.h" #define AUDIO_DEVICE_NAME_SIZE 256 +#define AUDIO_MAX_RIDE_MUSIC 2 +#define AUDIO_MAX_VEHICLE_SOUNDS 14 +#define NUM_DEFAULT_MUSIC_TRACKS 46 typedef struct { char name[AUDIO_DEVICE_NAME_SIZE]; } audio_device; -extern int gAudioDeviceCount; -extern audio_device *gAudioDevices; +typedef struct { + uint8 ride_id; + uint8 tune_id; + sint16 volume; + sint16 pan; + uint16 frequency; + void* sound_channel; +} rct_ride_music; -#define AUDIO_MAX_VEHICLE_SOUNDS 14 -#define AUDIO_MAX_RIDE_MUSIC 2 +typedef struct { + uint32 length; + uint32 offset; + uint8 path_id; + uint8 var_9; +} rct_ride_music_info; -void audio_init(); -void audio_quit(); -void audio_get_devices(); +typedef struct { + uint8 ride_id; + uint8 tune_id; + sint32 offset; + sint16 volume; + sint16 pan; + uint16 frequency; +} rct_ride_music_params; typedef struct { uint16 id; @@ -57,64 +75,13 @@ typedef struct { typedef struct { uint16 id; - sint16 panx; - sint16 pany; + sint16 pan_x; + sint16 pan_y; uint16 frequency; sint16 volume; uint16 var_A; } rct_vehicle_sound_params; -typedef struct { - uint8 rideid; - uint8 tuneid; - sint32 offset; - sint16 volume; - sint16 pan; - uint16 freq; -} rct_ride_music_params; - -typedef struct { - uint8 rideid; - uint8 tuneid; - sint16 volume; - sint16 pan; - uint16 freq; - void* sound_channel; -} rct_ride_music; - -typedef struct { - uint32 length; - uint32 offset; - uint8 pathid; - uint8 var_9; -} rct_ride_music_info; - -#define NUM_DEFAULT_MUSIC_TRACKS 46 -extern rct_ride_music_info* ride_music_info_list[NUM_DEFAULT_MUSIC_TRACKS]; -extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; -extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; -extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; -extern rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; -extern rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; -extern rct_ride_music_params *gRideMusicParamsListEnd; -extern void *gCrowdSoundChannel; -extern void *gTitleMusicChannel; -extern void *gRainSoundChannel; -extern bool gGameSoundsOff; - -int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z); -void start_title_music(); -void stop_ride_music(); -void stop_crowd_sound(); -void stop_title_music(); -void audio_init1(); -void audio_init2(int device); -void audio_close(); -void pause_sounds(); -void toggle_all_sounds(); -void unpause_sounds(); -void stop_vehicle_sounds(); - typedef enum { SOUND_LIFT_1 = 0, SOUND_TRACK_FRICTION_1 = 1, @@ -182,4 +149,34 @@ typedef enum { SOUND_MAXID } RCT2_SOUND; +extern audio_device *gAudioDevices; +extern int gAudioDeviceCount; +extern void *gCrowdSoundChannel; +extern bool gGameSoundsOff; +extern void *gRainSoundChannel; +extern rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; +extern rct_ride_music_info* gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; +extern rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; +extern rct_ride_music_params *gRideMusicParamsListEnd; +extern void *gTitleMusicChannel; +extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; +extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; +extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; + +void audio_close(); +void audio_get_devices(); +void audio_init(); +void audio_init1(); +void audio_init2(int device); +void audio_pause_sounds(); +void audio_quit(); +int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z); +void audio_start_title_music(); +void audio_stop_crowd_sound(); +void audio_stop_ride_music(); +void audio_stop_title_music(); +void audio_stop_vehicle_sounds(); +void audio_toggle_all_sounds(); +void audio_unpause_sounds(); + #endif diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index d8c4bcfb19..1edda91bc7 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -530,20 +530,20 @@ void Mixer::Stop(Channel& channel) Unlock(); } -bool Mixer::LoadMusic(int pathid) +bool Mixer::LoadMusic(int pathId) { - if (pathid >= countof(musicsources)) { + if (pathId >= countof(musicsources)) { return false; } - if (!musicsources[pathid]) { - const char* filename = get_file_path(pathid); + if (!musicsources[pathId]) { + const char* filename = get_file_path(pathId); Source_Sample* source_sample = new Source_Sample; if (source_sample->LoadWAV(filename)) { - musicsources[pathid] = source_sample; + musicsources[pathId] = source_sample; return true; } else { delete source_sample; - musicsources[pathid] = &source_null; + musicsources[pathId] = &source_null; return false; } } else { @@ -880,7 +880,7 @@ void Mixer_Channel_SetGroup(void* channel, int group) ((Channel*)channel)->SetGroup(group); } -void* Mixer_Play_Music(int pathid, int loop, int streaming) +void* Mixer_Play_Music(int pathId, int loop, int streaming) { if (gOpenRCT2Headless) return 0; @@ -888,7 +888,7 @@ void* Mixer_Play_Music(int pathid, int loop, int streaming) return 0; } if (streaming) { - const utf8 *filename = get_file_path(pathid); + const utf8 *filename = get_file_path(pathId); SDL_RWops* rw = SDL_RWFromFile(filename, "rb"); if (rw == NULL) { @@ -908,8 +908,8 @@ void* Mixer_Play_Music(int pathid, int loop, int streaming) return 0; } } else { - if (gMixer.LoadMusic(pathid)) { - Channel* channel = gMixer.Play(*gMixer.musicsources[pathid], MIXER_LOOP_INFINITE, false, false); + if (gMixer.LoadMusic(pathId)) { + Channel* channel = gMixer.Play(*gMixer.musicsources[pathId], MIXER_LOOP_INFINITE, false, false); if (channel) { channel->SetGroup(MIXER_GROUP_MUSIC); } diff --git a/src/audio/mixer.h b/src/audio/mixer.h index 3fe66b4816..4b2aeccbac 100644 --- a/src/audio/mixer.h +++ b/src/audio/mixer.h @@ -210,7 +210,7 @@ int Mixer_Channel_IsPlaying(void* channel); unsigned long Mixer_Channel_GetOffset(void* channel); int Mixer_Channel_SetOffset(void* channel, unsigned long offset); void Mixer_Channel_SetGroup(void* channel, int group); -void* Mixer_Play_Music(int pathid, int loop, int streaming); +void* Mixer_Play_Music(int pathId, int loop, int streaming); void Mixer_SetVolume(float volume); static int DStoMixerVolume(int volume) { return (int)(SDL_MIX_MAXVOLUME * (SDL_pow(10, (float)volume / 2000))); }; diff --git a/src/editor.c b/src/editor.c index 7b4b98e3cd..7b566001ca 100644 --- a/src/editor.c +++ b/src/editor.c @@ -60,8 +60,8 @@ void editor_load() { rct_window *mainWindow; - pause_sounds(); - unpause_sounds(); + audio_pause_sounds(); + audio_unpause_sounds(); object_unload_all(); map_init(150); banner_init(); diff --git a/src/game.c b/src/game.c index 10c4c61466..26b21f0956 100644 --- a/src/game.c +++ b/src/game.c @@ -275,7 +275,7 @@ void game_update() // Update the game one or more times for (i = 0; i < numUpdates; i++) { game_logic_update(); - start_title_music(); + audio_start_title_music(); if (gGameSpeed > 1) continue; @@ -549,10 +549,10 @@ 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) { - pause_sounds(); - unpause_sounds(); + audio_pause_sounds(); + audio_unpause_sounds(); } else { - unpause_sounds(); + audio_unpause_sounds(); } } @@ -601,9 +601,9 @@ static int open_landscape_file_dialog() format_string((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); safe_strncpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH, MAX_PATH); format_string((char*)0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); - pause_sounds(); + audio_pause_sounds(); result = platform_open_common_file_dialog(1, (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68); - unpause_sounds(); + audio_unpause_sounds(); // window_proc return result; } @@ -618,9 +618,9 @@ static int open_load_game_dialog() format_string((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, STR_LOAD_GAME_DIALOG_TITLE, 0); safe_strncpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH, MAX_PATH); format_string((char*)0x0141EE68, STR_RCT2_SAVED_GAME, 0); - pause_sounds(); + audio_pause_sounds(); result = platform_open_common_file_dialog(1, (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68, "*.SV6", (char*)0x0141EE68); - unpause_sounds(); + audio_unpause_sounds(); // window_proc return result; } @@ -1020,9 +1020,9 @@ static int show_save_game_dialog(char *resultPath) safe_strncpy(filename, RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char), MAX_PATH); format_string(filterName, STR_RCT2_SAVED_GAME, NULL); - pause_sounds(); + audio_pause_sounds(); result = platform_open_common_file_dialog(0, title, filename, "*.SV6", filterName); - unpause_sounds(); + audio_unpause_sounds(); if (result) safe_strncpy(resultPath, filename, MAX_PATH); diff --git a/src/input.c b/src/input.c index 6a8706a3e2..c68a1562e4 100644 --- a/src/input.c +++ b/src/input.c @@ -1021,7 +1021,7 @@ static void input_widget_left(int x, int y, rct_window *w, int widgetIndex) break; default: if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) { - sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); // Set new cursor down widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; @@ -1267,7 +1267,7 @@ void input_state_widget_pressed(int x, int y, int state, int widgetIndex, rct_wi break; int mid_point_x = (widget->left + widget->right) / 2 + w->x; - sound_play_panned(5, mid_point_x, 0, 0, 0); + audio_sound_play_panned(5, mid_point_x, 0, 0, 0); if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; diff --git a/src/interface/window.c b/src/interface/window.c index 8a4ad7831a..8bf9e8efe1 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -397,7 +397,7 @@ rct_window *window_create(int x, int y, int width, int height, rct_window_event_ // Play sounds and flash the window if (!(flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))){ w->flags |= WF_WHITE_BORDER_MASK; - sound_play_panned(SOUND_WINDOW_OPEN, x + (width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_WINDOW_OPEN, x + (width / 2), 0, 0, 0); } w->number = 0; diff --git a/src/management/news_item.c b/src/management/news_item.c index c3e059c761..f83f5d2ca1 100644 --- a/src/management/news_item.c +++ b/src/management/news_item.c @@ -85,7 +85,7 @@ static void news_item_tick_current() // Only play news item sound when in normal playing mode if (ticks == 1 && (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) == SCREEN_FLAGS_PLAYING)) { // Play sound - sound_play_panned(SOUND_NEWS_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); + audio_sound_play_panned(SOUND_NEWS_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); } } diff --git a/src/openrct2.c b/src/openrct2.c index b3833ac573..8c920fcb0a 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -635,14 +635,14 @@ static bool openrct2_release_rct2_segment() */ static void openrct2_setup_rct2_hooks() { - addhook(0x006E732D, (int)gfx_set_dirty_blocks, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when all callers are decompiled - addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when 0x6E7FF3 is decompiled - addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0, 0); // remove when all callers are decompiled - addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0, 0); // remove when all callers are decompiled - addhook(0x006BB76E, (int)sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX, 0); // remove when all callers are decompiled - addhook(0x006C42D9, (int)scrolling_text_setup, 0, (int[]){EAX, ECX, EBP, END}, 0, EBX); // remove when all callers are decompiled - addhook(0x006C2321, (int)gfx_get_string_width, 0, (int[]){ESI, END}, 0, ECX); // remove when all callers are decompiled - addhook(0x006C2555, (int)format_string, 0, (int[]){EDI, EAX, ECX, END}, 0, 0); // remove when all callers are decompiled + addhook(0x006E732D, (int)gfx_set_dirty_blocks, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when all callers are decompiled + addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when 0x6E7FF3 is decompiled + addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0, 0); // remove when all callers are decompiled + addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0, 0); // remove when all callers are decompiled + addhook(0x006BB76E, (int)audio_sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX, 0); // remove when all callers are decompiled + addhook(0x006C42D9, (int)scrolling_text_setup, 0, (int[]){EAX, ECX, EBP, END}, 0, EBX); // remove when all callers are decompiled + addhook(0x006C2321, (int)gfx_get_string_width, 0, (int[]){ESI, END}, 0, ECX); // remove when all callers are decompiled + addhook(0x006C2555, (int)format_string, 0, (int[]){EDI, EAX, ECX, END}, 0, 0); // remove when all callers are decompiled } #if _MSC_VER >= 1900 diff --git a/src/peep/peep.c b/src/peep/peep.c index e714c8de93..2cc1bf15dc 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -392,7 +392,7 @@ static void sub_68F41A(rct_peep *peep, int index) } if (peep->flags & PEEP_FLAGS_EXPLODE && peep->x != (sint16)0x8000){ - sound_play_panned(SOUND_CRASH, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(SOUND_CRASH, 0x8001, peep->x, peep->y, peep->z); sprite_misc_3_create(peep->x, peep->y, peep->z + 16); sprite_misc_5_create(peep->x, peep->y, peep->z + 16); @@ -1029,7 +1029,7 @@ int peep_update_action(sint16* x, sint16* y, sint16* xy_distance, rct_peep* peep litter_create(peep->x, peep->y, peep->z, peep->sprite_direction, peep->sprite_index & 1); int sound_id = SOUND_COUGH_1 + (scenario_rand() & 3); - sound_play_panned(sound_id, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(sound_id, 0x8001, peep->x, peep->y, peep->z); invalidate_sprite_2((rct_sprite*)peep); *x = peep->x; @@ -1141,7 +1141,7 @@ void peep_update_sprite_type(rct_peep* peep) ) { bl = 1; - sound_play_panned(SOUND_BALLOON_POP, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(SOUND_BALLOON_POP, 0x8001, peep->x, peep->y, peep->z); } if (peep->x != SPRITE_LOCATION_NULL) { @@ -3161,7 +3161,7 @@ static void peep_update_ride_sub_state_20(rct_peep* peep){ return; } - sound_play_panned(SOUND_TOILET_FLUSH, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(SOUND_TOILET_FLUSH, 0x8001, peep->x, peep->y, peep->z); peep->sub_state++; @@ -5265,7 +5265,7 @@ void peep_applause() } // Play applause noise - sound_play_panned(SOUND_APPLAUSE, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); + audio_sound_play_panned(SOUND_APPLAUSE, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); } /** @@ -7523,7 +7523,7 @@ static void peep_spend_money(rct_peep *peep, money16 *peep_expend_type, money32 RCT2_GLOBAL(0x00141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8); finance_payment(-amount, RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) / 4); - sound_play_panned(SOUND_PURCHASE, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(SOUND_PURCHASE, 0x8001, peep->x, peep->y, peep->z); } static void peep_set_has_ridden(rct_peep *peep, int rideIndex) @@ -7851,7 +7851,7 @@ static void peep_on_exit_ride(rct_peep *peep, int rideIndex) int laugh = scenario_rand() & 7; if (laugh < 3) { - sound_play_panned(SOUND_LAUGH_1 + laugh, 0x8001, peep->x, peep->y, peep->z); + audio_sound_play_panned(SOUND_LAUGH_1 + laugh, 0x8001, peep->x, peep->y, peep->z); } } diff --git a/src/rct2.c b/src/rct2.c index 560db3ab9a..80ce5c8ba1 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -326,12 +326,12 @@ int check_file_path(int pathId) case PATH_ID_CUSTOM1: if (file != NULL) - ride_music_info_list[36]->length = (uint32)SDL_RWsize(file); // Store file size in music_custom1_size @ 0x009AF164 + gRideMusicInfoList[36]->length = (uint32)SDL_RWsize(file); // Store file size in music_custom1_size @ 0x009AF164 break; case PATH_ID_CUSTOM2: if (file != NULL) - ride_music_info_list[37]->length = (uint32)SDL_RWsize(file); // Store file size in music_custom2_size @ 0x009AF16E + gRideMusicInfoList[37]->length = (uint32)SDL_RWsize(file); // Store file size in music_custom2_size @ 0x009AF16E break; } diff --git a/src/ride/ride.c b/src/ride/ride.c index 573251d0d1..a0afb3d27f 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3278,7 +3278,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint if (screenwidth < 64) { screenwidth = 64; } - int panx = ((x2 / screenwidth) - 0x8000) >> 4; + int pan_x = ((x2 / screenwidth) - 0x8000) >> 4; int y2 = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->y + ((RCT2_GLOBAL(0x009AF5A2, sint16) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_y) >> RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom); y2 <<= 16; @@ -3286,12 +3286,12 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint if (screenheight < 64) { screenheight = 64; } - int pany = ((y2 / screenheight) - 0x8000) >> 4; + int pan_y = ((y2 / screenheight) - 0x8000) >> 4; uint8 vol1 = -1; uint8 vol2 = -1; - int panx2 = panx; - int pany2 = pany; + int panx2 = pan_x; + int pany2 = pan_y; if (pany2 < 0) { pany2 = -pany2; } @@ -3331,20 +3331,20 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint } int v32 = -(((uint8)(-vol1 - 1) * (uint8)(-vol1 - 1)) / 16) - 700; if (vol1 && v32 >= -4000) { - if (panx > 10000) { - panx = 10000; + if (pan_x > 10000) { + pan_x = 10000; } - if (panx < -10000) { - panx = -10000; + if (pan_x < -10000) { + pan_x = -10000; } rct_ride_music* ride_music = &gRideMusicList[0]; int channel = 0; uint32 a1; - while (ride_music->rideid != rideIndex || ride_music->tuneid != *tuneId) { + while (ride_music->ride_id != rideIndex || ride_music->tune_id != *tuneId) { ride_music++; channel++; if (channel >= AUDIO_MAX_RIDE_MUSIC) { - rct_ride_music_info* ride_music_info = ride_music_info_list[*tuneId]; + rct_ride_music_info* ride_music_info = gRideMusicInfoList[*tuneId]; a1 = position + ride_music_info->offset; goto label51; } @@ -3356,16 +3356,16 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint } a1 = Mixer_Channel_GetOffset(gRideMusicList[channel].sound_channel); label51: - if (a1 < ride_music_info_list[*tuneId]->length) { + if (a1 < gRideMusicInfoList[*tuneId]->length) { position = a1; 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->ride_id = rideIndex; + ride_music_params->tune_id = *tuneId; ride_music_params->offset = a1; ride_music_params->volume = v32; - ride_music_params->pan = panx; - ride_music_params->freq = RCT2_GLOBAL(0x009AF47C, uint16); + ride_music_params->pan = pan_x; + ride_music_params->frequency = RCT2_GLOBAL(0x009AF47C, uint16); gRideMusicParamsListEnd++; } } else { @@ -3375,7 +3375,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint } else { label58: ; - rct_ride_music_info* ride_music_info = ride_music_info_list[*tuneId]; + rct_ride_music_info* ride_music_info = gRideMusicInfoList[*tuneId]; position += ride_music_info->offset; if (position < ride_music_info->length) { return position; @@ -3388,10 +3388,10 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint return position; } -#define INIT_MUSIC_INFO(pathid, offset, length, unknown) (rct_ride_music_info[]){length, offset, pathid, unknown} +#define INIT_MUSIC_INFO(path_id, offset, length, unknown) (rct_ride_music_info[]){length, offset, path_id, unknown} //0x009AF1C8 -rct_ride_music_info* ride_music_info_list[NUM_DEFAULT_MUSIC_TRACKS] = { +rct_ride_music_info* gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS] = { INIT_MUSIC_INFO(PATH_ID_CSS4, 1378, 8139054, 0), INIT_MUSIC_INFO(PATH_ID_CSS5, 1378, 7796656, 0), INIT_MUSIC_INFO(PATH_ID_CSS6, 1378, 15787850, 0), @@ -3456,9 +3456,9 @@ void ride_music_update_final() 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[] + if (ride_music_params->ride_id != (uint8)-1) { + rct_ride_music_info* ride_music_info = gRideMusicInfoList[ride_music_params->tune_id]; + if (RCT2_ADDRESS(0x009AA0B1, uint8*)[ride_music_info->path_id]) { // file_on_cdrom[] v8++; if (v9 >= ride_music_params->volume) { v9 = ride_music_params->volume; @@ -3471,14 +3471,14 @@ void ride_music_update_final() if (v8 <= 1) { break; } - edi->rideid = -1; + edi->ride_id = -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) { + if (ride_music_params->ride_id != (uint8)-1) { v8++; if (v9 >= ride_music_params->volume) { v9 = ride_music_params->volume; @@ -3490,17 +3490,17 @@ void ride_music_update_final() if (v8 <= 2) { break; } - edi->rideid = -1; + edi->ride_id = -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) { + if (ride_music->ride_id != (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) { + if (ride_music_params->ride_id == ride_music->ride_id && ride_music_params->tune_id == ride_music->tune_id) { int isplaying = Mixer_Channel_IsPlaying(gRideMusicList[channel].sound_channel); if (isplaying) { goto label32; @@ -3510,7 +3510,7 @@ void ride_music_update_final() ride_music_params++; } Mixer_Stop_Channel(gRideMusicList[channel].sound_channel); - ride_music->rideid = -1; + ride_music->ride_id = -1; } label32: ride_music++; @@ -3518,28 +3518,28 @@ void ride_music_update_final() } while(channel < AUDIO_MAX_RIDE_MUSIC); for (rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0]; ride_music_params < gRideMusicParamsListEnd; ride_music_params++) { - if (ride_music_params->rideid != (uint8)-1) { + if (ride_music_params->ride_id != (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) { + while (ride_music_params->ride_id != ride_music->ride_id || ride_music_params->tune_id != ride_music->tune_id) { + if (ride_music->ride_id == (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_info* ride_music_info = gRideMusicInfoList[ride_music_params->tune_id]; rct_ride_music* ride_music = &gRideMusicList[ebx]; - ride_music->sound_channel = Mixer_Play_Music(ride_music_info->pathid, MIXER_LOOP_NONE, true); + ride_music->sound_channel = Mixer_Play_Music(ride_music_info->path_id, 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; + ride_music->frequency = ride_music_params->frequency; + ride_music->ride_id = ride_music_params->ride_id; + ride_music->tune_id = ride_music_params->tune_id; 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)); + Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->frequency)); int offset = ride_music_params->offset - 10000; if (offset < 0) { offset = 0; @@ -3558,9 +3558,9 @@ void ride_music_update_final() 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->frequency != ride_music->frequency) { + ride_music->frequency = ride_music_params->frequency; + Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->frequency)); } } diff --git a/src/ride/track.c b/src/ride/track.c index d6f5af362a..ff7bf11948 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -3047,7 +3047,7 @@ int save_track_design(uint8 rideIndex){ // Track design files format_string(RCT2_ADDRESS(0x141EE68, char), 2305, NULL); - pause_sounds(); + audio_pause_sounds(); int result = platform_open_common_file_dialog( 0, @@ -3056,7 +3056,7 @@ int save_track_design(uint8 rideIndex){ "*.TD?", RCT2_ADDRESS(0x141EE68, char)); - unpause_sounds(); + audio_unpause_sounds(); if (result == 0){ ride_list_item item = { .type = 0xFD, .entry_index = 0 }; diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 62edd5903f..4f66083e0b 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -75,25 +75,25 @@ void vehicle_update_sound_params(rct_vehicle* vehicle) *(j + 1) = *j; } i->var_A = v9; - int panx = (RCT2_GLOBAL(0x009AF5A0, sint16) / 2) + (RCT2_GLOBAL(0x009AF5A4, sint16) / 2) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x; - panx >>= RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom; - panx += RCT2_GLOBAL(0x00F438A4, rct_viewport*)->x; + int pan_x = (RCT2_GLOBAL(0x009AF5A0, sint16) / 2) + (RCT2_GLOBAL(0x009AF5A4, sint16) / 2) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x; + pan_x >>= RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom; + pan_x += RCT2_GLOBAL(0x00F438A4, rct_viewport*)->x; uint16 screenwidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16); if (screenwidth < 64) { screenwidth = 64; } - i->panx = ((((panx << 16) / screenwidth) - 0x8000) >> 4); + i->pan_x = ((((pan_x << 16) / screenwidth) - 0x8000) >> 4); - int pany = (RCT2_GLOBAL(0x009AF5A2, sint16) / 2) + (RCT2_GLOBAL(0x009AF5A6, sint16) / 2) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_y; - pany >>= RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom; - pany += RCT2_GLOBAL(0x00F438A4, rct_viewport*)->y; + int pan_y = (RCT2_GLOBAL(0x009AF5A2, sint16) / 2) + (RCT2_GLOBAL(0x009AF5A6, sint16) / 2) - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_y; + pan_y >>= RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom; + pan_y += RCT2_GLOBAL(0x00F438A4, rct_viewport*)->y; uint16 screenheight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16); if (screenheight < 64) { screenheight = 64; } - i->pany = ((((pany << 16) / screenheight) - 0x8000) >> 4); + i->pan_y = ((((pan_y << 16) / screenheight) - 0x8000) >> 4); sint32 v19 = vehicle->velocity; @@ -221,43 +221,43 @@ void vehicle_sounds_update() } uint8 vol1 = 0xFF; uint8 vol2 = 0xFF; - sint16 pany = vehicle_sound_params->pany; - if (pany < 0) { - pany = -pany; + sint16 pan_y = vehicle_sound_params->pan_y; + if (pan_y < 0) { + pan_y = -pan_y; } - if (pany > 0xFFF) { - pany = 0xFFF; + if (pan_y > 0xFFF) { + pan_y = 0xFFF; } - pany -= 0x800; - if (pany > 0) { - pany -= 0x400; - pany = -pany; - pany = pany / 4; - vol1 = LOBYTE(pany); - if ((sint8)HIBYTE(pany) != 0) { + pan_y -= 0x800; + if (pan_y > 0) { + pan_y -= 0x400; + pan_y = -pan_y; + pan_y = pan_y / 4; + vol1 = LOBYTE(pan_y); + if ((sint8)HIBYTE(pan_y) != 0) { vol1 = 0xFF; - if ((sint8)HIBYTE(pany) < 0) { + if ((sint8)HIBYTE(pan_y) < 0) { vol1 = 0; } } } - sint16 panx = vehicle_sound_params->panx; - if (panx < 0) { - panx = -panx; + sint16 pan_x = vehicle_sound_params->pan_x; + if (pan_x < 0) { + pan_x = -pan_x; } - if (panx > 0xFFF) { - panx = 0xFFF; + if (pan_x > 0xFFF) { + pan_x = 0xFFF; } - panx -= 0x800; - if (panx > 0) { - panx -= 0x400; - panx = -panx; - panx = panx / 4; - vol2 = LOBYTE(panx); - if ((sint8)HIBYTE(panx) != 0) { + pan_x -= 0x800; + if (pan_x > 0) { + pan_x -= 0x400; + pan_x = -pan_x; + pan_x = pan_x / 4; + vol2 = LOBYTE(pan_x); + if ((sint8)HIBYTE(pan_x) != 0) { vol2 = 0xFF; - if ((sint8)HIBYTE(panx) < 0) { + if ((sint8)HIBYTE(pan_x) < 0) { vol2 = 0; } } @@ -331,7 +331,7 @@ void vehicle_sounds_update() Mixer_Stop_Channel(vehicle_sound->sound1_channel); label69: vehicle_sound->sound1_id = sprite->vehicle.sound1_id; - vehicle_sound->sound1_pan = vehicle_sound_params->panx; + vehicle_sound->sound1_pan = vehicle_sound_params->pan_x; vehicle_sound->sound1_volume = volume; vehicle_sound->sound1_freq = vehicle_sound_params->frequency; uint16 frequency = vehicle_sound_params->frequency; @@ -339,7 +339,7 @@ void vehicle_sounds_update() frequency = (frequency / 2) + 4000; } uint8 looping = RCT2_ADDRESS(0x009AF51E, uint8)[2 * sprite->vehicle.sound1_id]; - int pan = vehicle_sound_params->panx; + int pan = vehicle_sound_params->pan_x; 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; } @@ -347,9 +347,9 @@ void vehicle_sounds_update() vehicle_sound->sound1_volume = volume; Mixer_Channel_Volume(vehicle_sound->sound1_channel, DStoMixerVolume(volume)); } - if (vehicle_sound_params->panx != vehicle_sound->sound1_pan) { - vehicle_sound->sound1_pan = vehicle_sound_params->panx; - Mixer_Channel_Pan(vehicle_sound->sound1_channel, DStoMixerPan(vehicle_sound_params->panx)); + if (vehicle_sound_params->pan_x != vehicle_sound->sound1_pan) { + vehicle_sound->sound1_pan = vehicle_sound_params->pan_x; + Mixer_Channel_Pan(vehicle_sound->sound1_channel, DStoMixerPan(vehicle_sound_params->pan_x)); } 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; @@ -382,7 +382,7 @@ void vehicle_sounds_update() Mixer_Stop_Channel(vehicle_sound->sound2_channel); label93: vehicle_sound->sound2_id = sprite->vehicle.sound2_id; - vehicle_sound->sound2_pan = vehicle_sound_params->panx; + vehicle_sound->sound2_pan = vehicle_sound_params->pan_x; vehicle_sound->sound2_volume = volume; vehicle_sound->sound2_freq = vehicle_sound_params->frequency; uint16 frequency = vehicle_sound_params->frequency; @@ -394,7 +394,7 @@ void vehicle_sounds_update() frequency = 25700; } uint8 looping = RCT2_ADDRESS(0x009AF51E, uint8)[2 * sprite->vehicle.sound2_id]; - int pan = vehicle_sound_params->panx; + int pan = vehicle_sound_params->pan_x; 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; } @@ -402,9 +402,9 @@ void vehicle_sounds_update() Mixer_Channel_Volume(vehicle_sound->sound2_channel, DStoMixerVolume(volume)); vehicle_sound->sound2_volume = volume; } - if (vehicle_sound_params->panx != vehicle_sound->sound2_pan) { - vehicle_sound->sound2_pan = vehicle_sound_params->panx; - Mixer_Channel_Pan(vehicle_sound->sound2_channel, DStoMixerPan(vehicle_sound_params->panx)); + if (vehicle_sound_params->pan_x != vehicle_sound->sound2_pan) { + vehicle_sound->sound2_pan = vehicle_sound_params->pan_x; + Mixer_Channel_Pan(vehicle_sound->sound2_channel, DStoMixerPan(vehicle_sound_params->pan_x)); } 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; diff --git a/src/title.c b/src/title.c index 1b8abc325a..bf2d8ff5a3 100644 --- a/src/title.c +++ b/src/title.c @@ -125,8 +125,8 @@ void title_load() window_staff_list_init_vars(); map_update_tile_pointers(); reset_0x69EBE4(); - stop_ride_music(); - stop_crowd_sound(); + audio_stop_ride_music(); + audio_stop_crowd_sound(); //stop_other_sounds(); viewport_init_all(); news_item_init_queue(); @@ -505,7 +505,7 @@ void title_update() for (i = 0; i < numUpdates; i++) { game_logic_update(); } - start_title_music(); + audio_start_title_music(); } RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~0x80; diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index 4416c40895..8e466117f9 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -336,9 +336,9 @@ static int show_save_scenario_dialog(char *resultPath) strcat(filename, ".SC6"); format_string(filterName, STR_RCT2_SCENARIO_FILE, NULL); - pause_sounds(); + audio_pause_sounds(); result = platform_open_common_file_dialog(0, title, filename, "*.SC6", filterName); - unpause_sounds(); + audio_unpause_sounds(); if (result) safe_strncpy(resultPath, filename, MAX_PATH); diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index f5eecca514..f9a00a06b9 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -973,7 +973,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, int s window_invalidate(w); - sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { diff --git a/src/windows/error.c b/src/windows/error.c index b93d15da65..c6489d3651 100644 --- a/src/windows/error.c +++ b/src/windows/error.c @@ -138,7 +138,7 @@ void window_error_open(rct_string_id title, rct_string_id message) w->widgets = window_error_widgets; w->error.var_480 = 0; if (!(RCT2_GLOBAL(0x009A8C29, uint8) & 1)) - sound_play_panned(SOUND_ERROR, 0, w->x + (w->width / 2), 0, 0); + audio_sound_play_panned(SOUND_ERROR, 0, w->x + (w->width / 2), 0, 0); } /** diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 3623eb99c2..0456bf11bf 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -768,7 +768,7 @@ static void window_footpath_place_path_at_point(int x, int y) // bp = RCT2_ADDRESS_COMMAND_MAP_Z // dx = RCT2_ADDRESS_COMMAND_MAP_Y // cx = RCT2_ADDRESS_COMMAND_MAP_X - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } } @@ -852,7 +852,7 @@ static void window_footpath_construct() cost = footpath_place(type, x, y, z, slope, GAME_COMMAND_FLAG_APPLY); if (cost != MONEY32_UNDEFINED) { - sound_play_panned( + audio_sound_play_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16), diff --git a/src/windows/install_track.c b/src/windows/install_track.c index a81bb58868..b549785c57 100644 --- a/src/windows/install_track.c +++ b/src/windows/install_track.c @@ -159,7 +159,7 @@ static void window_install_track_select(rct_window *w, int index) w->track_list.var_480 = index; - sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && index == 0) { window_close(w); ride_construct_new(_window_install_track_item); diff --git a/src/windows/map.c b/src/windows/map.c index 7c46d62645..29fbbb79a7 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1289,7 +1289,7 @@ static void window_map_place_park_entrance_tool_down(int x, int y) if (price == MONEY32_UNDEFINED) return; - sound_play_panned( + audio_sound_play_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16), diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index f815181b43..3fd6efc81d 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -371,7 +371,7 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* if (cost == MONEY32_UNDEFINED) return; - sound_play_panned( + audio_sound_play_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16), @@ -509,6 +509,6 @@ static void window_maze_construction_construct(int direction) _currentTrackBeginX = x; _currentTrackBeginY = y; if (_rideConstructionState != 7) { - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } } diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index 5fc5406d83..4fea00da60 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -688,7 +688,7 @@ static void window_new_ride_scrollmousedown(rct_window *w, int scrollIndex, int RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item; w->new_ride.selected_ride_id = *((sint16*)&item); - sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); w->new_ride.selected_ride_countdown = 8; window_invalidate(w); } diff --git a/src/windows/news.c b/src/windows/news.c index 25789b147d..623c6d579c 100644 --- a/src/windows/news.c +++ b/src/windows/news.c @@ -147,7 +147,7 @@ static void window_news_update(rct_window *w) return; window_invalidate(w); - sound_play_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); j = w->news.var_480; w->news.var_480 = -1; @@ -239,7 +239,7 @@ static void window_news_scrollmousedown(rct_window *w, int scrollIndex, int x, i w->news.var_482 = buttonIndex; w->news.var_484 = 4; window_invalidate(w); - sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); } } diff --git a/src/windows/options.c b/src/windows/options.c index 660d152380..ee607fbc48 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -552,14 +552,14 @@ static void window_options_mouseup(rct_window *w, int widgetIndex) case WINDOW_OPTIONS_PAGE_AUDIO: switch (widgetIndex) { case WIDX_SOUND_CHECKBOX: - toggle_all_sounds(); + audio_toggle_all_sounds(); config_save_default(); window_invalidate(w); break; case WIDX_MUSIC_CHECKBOX: gConfigSound.ride_music = !gConfigSound.ride_music; if (!gConfigSound.ride_music) { - stop_ride_music(); + audio_stop_ride_music(); } config_save_default(); window_invalidate(w); @@ -1095,9 +1095,9 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown window_invalidate(w); } - stop_title_music(); + audio_stop_title_music(); if (dropdownIndex != 0) - start_title_music(); + audio_start_title_music(); break; } break; diff --git a/src/windows/ride.c b/src/windows/ride.c index b6f44dde0b..88086e816a 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -4433,9 +4433,9 @@ static void window_ride_music_mousedown(int widgetIndex, rct_window *w, rct_widg for (i = 0; i < countof(MusicStyleOrder); i++) window_ride_current_music_style_order[numItems++] = MusicStyleOrder[i]; - if (ride_music_info_list[36]->length != 0) + if (gRideMusicInfoList[36]->length != 0) window_ride_current_music_style_order[numItems++] = MUSIC_STYLE_CUSTOM_MUSIC_1; - if (ride_music_info_list[37]->length != 0) + if (gRideMusicInfoList[37]->length != 0) window_ride_current_music_style_order[numItems++] = MUSIC_STYLE_CUSTOM_MUSIC_2; } @@ -4550,7 +4550,7 @@ static void window_ride_music_paint(rct_window *w, rct_drawpixelinfo *dpi) static void cancel_scenery_selection(){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) &= ~(1 << 2); RCT2_GLOBAL(0x9DEA6F, uint8) &= ~(1 << 0); - unpause_sounds(); + audio_unpause_sounds(); rct_window* main_w = window_get_main(); @@ -4579,7 +4579,7 @@ static void setup_scenery_selection(rct_window* w){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) |= (1 << 2); RCT2_GLOBAL(0x009DEA6F, uint8) |= 1; - pause_sounds(); + audio_pause_sounds(); rct_window* w_main = window_get_main(); diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index f6704d2175..b3e06f650b 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1594,7 +1594,7 @@ static void window_ride_construction_construct(rct_window *w) return; } - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); if (RCT2_GLOBAL(RCT2_ADDRESS_ABOVE_GROUND_FLAGS, uint8) & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) { viewport_set_visibility(1); @@ -3554,7 +3554,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) zAttempts == 0 || z < 0 ) { - sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); + audio_sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != NULL){ tool_set(w, 23, 12); @@ -3571,7 +3571,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) } else { window_close_by_class(WC_ERROR); - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); break; } } @@ -3626,7 +3626,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) _currentTrackCovered = saveCurrentTrackCovered; _currentTrackLiftHill = saveCurrentTrackLiftHill; - sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); + audio_sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); break; } else if (zAttempts >= 0) { z += 16; @@ -3680,7 +3680,7 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) return; } - sound_play_panned( + audio_sound_play_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 0321e20a66..1b05645b3f 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -192,7 +192,7 @@ void window_save_prompt_open() // Pause the game RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) |= 2; - pause_sounds(); + audio_pause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); stringId = prompt_mode + STR_LOAD_GAME_PROMPT_TITLE; @@ -212,7 +212,7 @@ static void window_save_prompt_close(rct_window *w) { // Unpause the game RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) &= ~2; - unpause_sounds(); + audio_unpause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); } diff --git a/src/windows/scenery.c b/src/windows/scenery.c index fd42a10f44..ecf4eaed73 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -795,7 +795,7 @@ void window_scenery_scrollmousedown(rct_window *w, int scrollIndex, int x, int y window_scenery_selected_scenery_by_tab[tabIndex] = sceneryId; window_scenery_is_repaint_scenery_tool_on &= 0xFE; - sound_play_panned(4, (w->width >> 1) + w->x, 0, 0, 0); + audio_sound_play_panned(4, (w->width >> 1) + w->x, 0, 0, 0); w->scenery.hover_counter = -16; RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_COST, uint32) = MONEY32_UNDEFINED; window_invalidate(w); diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 0a2f57f157..b4a4d1f6f3 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -215,7 +215,7 @@ static void window_scenarioselect_scrollmousedown(rct_window *w, int scrollIndex if (y >= 0) continue; - sound_play_panned(SOUND_CLICK_1, w->width / 2 + w->x, 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->width / 2 + w->x, 0, 0, 0); scenario_load_and_play(scenario); break; } diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 0d8f55b6da..c40c5ea852 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1479,7 +1479,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); success = true; break; } @@ -1507,7 +1507,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (successfulPlacements > 0) { window_close_by_class(WC_ERROR); } else { - sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1518,7 +1518,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_POSITION_THIS_HERE; int cost = game_do_command(gridX, flags, gridY, parameter_2, GAME_COMMAND_PLACE_PATH, parameter_3, 0); if (cost != MONEY32_UNDEFINED) { - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1542,7 +1542,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1556,7 +1556,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_LARGE: @@ -1579,7 +1579,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1593,7 +1593,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_BANNER: @@ -1613,7 +1613,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED) { int bannerId = regs.edi; - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); window_banner_open(bannerId); } break; diff --git a/src/windows/track_list.c b/src/windows/track_list.c index fc8b3187ca..76c837569b 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -158,7 +158,7 @@ static void window_track_list_select(rct_window *w, int index) w->track_list.var_480 = index; - sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && index == 0) { window_close(w); ride_construct_new(_window_track_list_item); diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 85365c9dc9..38102c2370 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -541,7 +541,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i if (cost != MONEY32_UNDEFINED) { window_close_by_class(WC_ERROR); - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, mapX, mapY, mapZ); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, mapX, mapY, mapZ); RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex; if (RCT2_GLOBAL(0x00F4414E, uint8) & 1) { @@ -563,7 +563,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i } // Unable to build track - sound_play_panned(SOUND_ERROR, 0x8001, mapX, mapY, mapZ); + audio_sound_play_panned(SOUND_ERROR, 0x8001, mapX, mapY, mapZ); } /** diff --git a/src/world/balloon.c b/src/world/balloon.c index 62de010dfe..b1e5cfbd1a 100644 --- a/src/world/balloon.c +++ b/src/world/balloon.c @@ -26,7 +26,7 @@ void balloon_pop(rct_balloon *balloon) { balloon->popped = 1; balloon->var_26 = 0; - sound_play_panned(SOUND_BALLOON_POP, 0x8001, balloon->x, balloon->y, balloon->z); + audio_sound_play_panned(SOUND_BALLOON_POP, 0x8001, balloon->x, balloon->y, balloon->z); } /** diff --git a/src/world/duck.c b/src/world/duck.c index 9f75a65ac5..a5f6d2d7f0 100644 --- a/src/world/duck.c +++ b/src/world/duck.c @@ -288,7 +288,7 @@ static void duck_update_fly_away(rct_duck *duck) */ void duck_press(rct_duck *duck) { - sound_play_panned(SOUND_QUACK, 0x8001, duck->x, duck->y, duck->z); + audio_sound_play_panned(SOUND_QUACK, 0x8001, duck->x, duck->y, duck->z); } /** diff --git a/src/world/map.c b/src/world/map.c index b75ea436d6..9e6519a358 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -1606,7 +1606,7 @@ money32 map_set_land_ownership(uint8 flags, sint16 x1, sint16 y1, sint16 x2, sin y += 16; sint16 z = map_element_height(x, y) & 0xFFFF; - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); return 0; } @@ -1629,7 +1629,7 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } uint8 min_height = 0xFF; @@ -1685,7 +1685,7 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } uint8 max_height = 0; @@ -1808,7 +1808,7 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); } // Force ride construction to recheck area @@ -1873,7 +1873,7 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); } // Force ride construction to recheck area @@ -2030,7 +2030,7 @@ money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop // Play sound (only once) if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - sound_play_panned(SOUND_PLACE_ITEM, 0x8001, centreX, centreY, centreZ); + audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, centreX, centreY, centreZ); } money32 totalCost = 0; diff --git a/src/world/particle.c b/src/world/particle.c index 1636b3ac42..27fe0221aa 100644 --- a/src/world/particle.c +++ b/src/world/particle.c @@ -71,7 +71,7 @@ void crashed_vehicle_particle_update(rct_crashed_vehicle_particle *particle) if (waterZ != 0 && particle->z >= waterZ && z <= waterZ) { // Splash - sound_play_panned(SOUND_WATER_2, 0x8001, particle->x, particle->y, waterZ); + audio_sound_play_panned(SOUND_WATER_2, 0x8001, particle->x, particle->y, waterZ); crash_splash_create(particle->x, particle->y, waterZ); sprite_remove((rct_sprite*)particle); return; From b736de003e2558be95cd4d5789714c5ea2b7a1d0 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Mon, 16 Nov 2015 22:39:47 +0000 Subject: [PATCH 02/10] Sanitize audio.c --- src/audio/audio.c | 310 +++++++++++++++++++++++------------------- src/audio/audio.h | 4 +- src/openrct2.c | 2 +- src/windows/options.c | 2 +- 4 files changed, 174 insertions(+), 144 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index d6721f347f..32d6f999e4 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -32,25 +32,28 @@ #include "../openrct2.h" #include "../util/util.h" -int gAudioDeviceCount; audio_device *gAudioDevices = NULL; +int gAudioDeviceCount; +void *gCrowdSoundChannel = 0; +bool gGameSoundsOff = false; +void *gRainSoundChannel = 0; +rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; +rct_ride_music_info *gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; +rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; +rct_ride_music_params *gRideMusicParamsListEnd; +void *gTitleMusicChannel = 0; rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params *gVehicleSoundParamsListEnd; -rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; -rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; -rct_ride_music_params *gRideMusicParamsListEnd; -void *gCrowdSoundChannel = 0; -void *gTitleMusicChannel = 0; -void *gRainSoundChannel = 0; -bool gGameSoundsOff = false; -void audio_init(int i) +void audio_init() { - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - log_fatal("SDL_Init %s", SDL_GetError()); - exit(-1); - } + int result = SDL_Init(SDL_INIT_AUDIO); + if (result >= 0) + return; + + log_fatal("SDL_Init %s", SDL_GetError()); + exit(-1); } void audio_quit() @@ -58,29 +61,29 @@ void audio_quit() SDL_QuitSubSystem(SDL_INIT_AUDIO); } -/** - * Populates audio devices. - */ -void audio_get_devices() +void audio_populate_devices() { - int i; - if (gAudioDevices != NULL) free(gAudioDevices); gAudioDeviceCount = SDL_GetNumAudioDevices(SDL_FALSE); - if (gAudioDeviceCount > 0) { - gAudioDeviceCount++; - gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device)); + if (gAudioDeviceCount <= 0) + return; - safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE); - for (i = 1; i < gAudioDeviceCount; i++) { - const char *utf8_name = SDL_GetAudioDeviceName(i - 1, SDL_FALSE); - if (utf8_name == NULL) - utf8_name = language_get_string(5511); + gAudioDeviceCount++; + gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device)); + safe_strncpy( + gAudioDevices[0].name, + language_get_string(5510), + AUDIO_DEVICE_NAME_SIZE + ); - safe_strncpy(gAudioDevices[i].name, utf8_name, AUDIO_DEVICE_NAME_SIZE); - } + for (int i = 1; i < gAudioDeviceCount; i++) { + const char *utf8Name = SDL_GetAudioDeviceName(i - 1, SDL_FALSE); + if (utf8Name == NULL) + utf8Name = language_get_string(5511); + + safe_strncpy(gAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE); } } @@ -94,69 +97,86 @@ void audio_get_devices() * @param y (dx) * @param z (bp) */ -int audio_sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) +int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) { - if (!gGameSoundsOff) { - 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) { - volumedown = 10; - } + if (gGameSoundsOff) + return 0; + + int volume = 0; + if (ebx == 0x8001) { + int volumeDown = 0; + rct_map_element *element = map_get_surface_element_at(x / 32, y / 32); + if (element && (element->base_height * 8) - 5 > z) + volumeDown = 10; + + sint16 rx; + sint16 ry; + switch (get_current_rotation()) { + case 0: + rx = y - x; + ry = ((y + x) / 2) - z; + break; + case 1: + rx = -x - y; + ry = ((y - x) / 2) - z; + break; + case 2: + rx = x - y; + ry = ((-y - x) / 2) - z; + break; + case 3: + rx = y + x; + ry = ((x - y) / 2) - z; + break; + } + + rct_window *window = RCT2_GLOBAL( + RCT2_ADDRESS_NEW_WINDOW_PTR, + rct_window* + ); + while (true) { + window--; + if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) { + break; } - sint16 rx; - sint16 ry; - switch (get_current_rotation()) { - case 0: - rx = y - x; - ry = ((y + x) / 2) - z; - break; - case 1: - rx = -x - y; - ry = ((y - x) / 2) - z; - break; - case 2: - rx = x - y; - ry = ((-y - x) / 2) - z; - break; - case 3: - rx = y + x; - ry = ((x - y) / 2) - z; - break; - } - rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); - while (1) { - window--; - if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) { - break; - } - rct_viewport* viewport = window->viewport; - if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { - 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; - } - } + rct_viewport *viewport = window->viewport; + if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { + sint16 vy = ry - viewport->view_y; + sint16 vx = rx - viewport->view_x; + ebx = viewport->x + (vx >> viewport->zoom); + volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; + + if (vy < 0 + || vy >= viewport->view_height + || vx < 0 + || vx >= viewport->view_width + || volume < -10000) + return soundId; } } - int pan; - if (ebx == (sint16)0x8000) { - pan = 0; - } else { - int x2 = ebx << 16; - uint16 screenwidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16); - if (screenwidth < 64) { - screenwidth = 64; - } - pan = ((x2 / screenwidth) - 0x8000) >> 4; - } - Mixer_Play_Effect(sound_id, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 1); } + + int pan = 0; + if (ebx != (sint16)0x8000) { + int x2 = ebx << 16; + uint16 screenWidth = max( + 64, + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) + ); + + pan = ((x2 / screenWidth) - 0x8000) >> 4; + } + + Mixer_Play_Effect( + soundId, + MIXER_LOOP_NONE, + DStoMixerVolume(volume), + DStoMixerPan(pan), + 1, + 1 + ); + return 0; } @@ -166,31 +186,33 @@ int audio_sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) */ void audio_start_title_music() { - int musicPathId; - switch (gConfigSound.title_music) { - default: + if (gGameSoundsOff || !RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { + audio_stop_title_music(); return; + } + + if (gTitleMusicChannel) + return; + + int pathId; + switch (gConfigSound.title_music) { case 1: - musicPathId = PATH_ID_CSS50; + pathId = PATH_ID_CSS50; break; case 2: - musicPathId = PATH_ID_CSS17; + pathId = PATH_ID_CSS17; break; case 3: if (rand() & 1) - musicPathId = PATH_ID_CSS50; + pathId = PATH_ID_CSS50; else - musicPathId = PATH_ID_CSS17; + pathId = PATH_ID_CSS17; break; + default: + return; } - if (!gGameSoundsOff && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { - if (!gTitleMusicChannel) { - gTitleMusicChannel = Mixer_Play_Music(musicPathId, MIXER_LOOP_INFINITE, true); - } - } else { - audio_stop_title_music(); - } + gTitleMusicChannel = Mixer_Play_Music(pathId, MIXER_LOOP_INFINITE, true); } /** @@ -200,13 +222,15 @@ void audio_start_title_music() void audio_stop_ride_music() { for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { - rct_ride_music* ride_music = &gRideMusicList[i]; - if (ride_music->ride_id != (uint8)-1) { - if (ride_music->sound_channel) { - Mixer_Stop_Channel(ride_music->sound_channel); - } - ride_music->ride_id = -1; + rct_ride_music *rideMusic = &gRideMusicList[i]; + if (rideMusic->ride_id == (uint8)-1) + continue; + + if (rideMusic->sound_channel) { + Mixer_Stop_Channel(rideMusic->sound_channel); } + + rideMusic->ride_id = -1; } } @@ -248,22 +272,22 @@ void stop_rain_sound() */ void audio_init1() { - int devicenum = 0; - audio_init2(devicenum); + int deviceNum = 0; + audio_init2(deviceNum); - for(int m = 0; m < countof(gRideMusicInfoList); m++) { - rct_ride_music_info* ride_music_info = gRideMusicInfoList[m]; - const utf8* path = get_file_path(ride_music_info->path_id); + for (int m = 0; m < countof(gRideMusicInfoList); m++) { + rct_ride_music_info *rideMusicInfo = gRideMusicInfoList[m]; + const utf8 *path = get_file_path(rideMusicInfo->path_id); SDL_RWops *file = SDL_RWFromFile(path, "rb"); - if (file != NULL) { - uint32 head; - SDL_RWread(file, &head, sizeof(head), 1); - SDL_RWclose(file); - RCT2_GLOBAL(0x014241BC, uint32) = 0; - if (head == 0x78787878) { - ride_music_info->length = 0; - } - } + if (file == NULL) + continue; + + uint32 head; + SDL_RWread(file, &head, sizeof(head), 1); + SDL_RWclose(file); + RCT2_GLOBAL(0x014241BC, uint32) = 0; + if (head == 0x78787878) + rideMusicInfo->length = 0; } } @@ -275,14 +299,15 @@ 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 = -1; + rct_vehicle_sound *vehicleSound = &gVehicleSoundList[i]; + vehicleSound->id = -1; } + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = device; config_save_default(); for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { - rct_ride_music* ride_music = &gRideMusicList[i]; - ride_music->ride_id = -1; + rct_ride_music *rideMusic = &gRideMusicList[i]; + rideMusic->ride_id = -1; } } @@ -302,11 +327,11 @@ void audio_close() /* rct2: 0x006BAB8A */ void audio_toggle_all_sounds(){ gConfigSound.sound = !gConfigSound.sound; - if (!gConfigSound.sound) { + if (gConfigSound.sound) + audio_unpause_sounds(); + else { audio_stop_title_music(); audio_pause_sounds(); - } else { - audio_unpause_sounds(); } } @@ -338,18 +363,23 @@ void audio_unpause_sounds() */ void audio_stop_vehicle_sounds() { - if (!gOpenRCT2Headless && RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) { - for (int i = 0; i < countof(gVehicleSoundList); i++) { - rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i]; - if (vehicle_sound->id != 0xFFFF) { - if (vehicle_sound->sound1_id != 0xFFFF) { - Mixer_Stop_Channel(vehicle_sound->sound1_channel); - } - if (vehicle_sound->sound2_id != 0xFFFF) { - Mixer_Stop_Channel(vehicle_sound->sound2_channel); - } - } - vehicle_sound->id = 0xFFFF; + if (gOpenRCT2Headless + || RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) == -1) + return; + + for (int i = 0; i < countof(gVehicleSoundList); i++) { + rct_vehicle_sound *vehicleSound = &gVehicleSoundList[i]; + if (vehicleSound->id == 0xFFFF) + continue; + + if (vehicleSound->sound1_id != 0xFFFF) { + Mixer_Stop_Channel(vehicleSound->sound1_channel); } + + if (vehicleSound->sound2_id != 0xFFFF) { + Mixer_Stop_Channel(vehicleSound->sound2_channel); + } + + vehicleSound->id = 0xFFFF; } } diff --git a/src/audio/audio.h b/src/audio/audio.h index 6ec60fc572..ceb42682ca 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -155,7 +155,7 @@ extern void *gCrowdSoundChannel; extern bool gGameSoundsOff; extern void *gRainSoundChannel; extern rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; -extern rct_ride_music_info* gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; +extern rct_ride_music_info *gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; extern rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; extern rct_ride_music_params *gRideMusicParamsListEnd; extern void *gTitleMusicChannel; @@ -164,11 +164,11 @@ extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; void audio_close(); -void audio_get_devices(); void audio_init(); void audio_init1(); void audio_init2(int device); void audio_pause_sounds(); +void audio_populate_devices(); void audio_quit(); int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z); void audio_start_title_music(); diff --git a/src/openrct2.c b/src/openrct2.c index 8c920fcb0a..4bebe17b65 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -249,7 +249,7 @@ bool openrct2_initialise() get_system_info(); if (!gOpenRCT2Headless) { audio_init(); - audio_get_devices(); + audio_populate_devices(); } if (!language_open(gConfigGeneral.language)) { diff --git a/src/windows/options.c b/src/windows/options.c index ee607fbc48..95778854e2 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -852,7 +852,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget* case WINDOW_OPTIONS_PAGE_AUDIO: switch (widgetIndex) { case WIDX_SOUND_DROPDOWN: - audio_get_devices(); + audio_populate_devices(); // populate the list with the sound devices for (i = 0; i < gAudioDeviceCount; i++) { From b9d48d2f9b74a99d4709383d5e9fad63d64dd730 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Tue, 17 Nov 2015 00:42:23 +0000 Subject: [PATCH 03/10] Document audio.h --- src/audio/audio.c | 42 +++++++++++++---------- src/audio/audio.h | 79 +++++++++++++++++++++++++++++++++++++------ src/rct2.c | 2 +- src/windows/options.c | 2 +- src/world/climate.c | 10 ++---- 5 files changed, 97 insertions(+), 38 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index 32d6f999e4..e3606baebf 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -46,6 +46,8 @@ rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params *gVehicleSoundParamsListEnd; +void audio_stop_channel(void **channel); + void audio_init() { int result = SDL_Init(SDL_INIT_AUDIO); @@ -240,10 +242,7 @@ void audio_stop_ride_music() */ void audio_stop_crowd_sound() { - if (gCrowdSoundChannel) { - Mixer_Stop_Channel(gCrowdSoundChannel); - gCrowdSoundChannel = 0; - } + audio_stop_channel(&gCrowdSoundChannel); } /** @@ -252,28 +251,35 @@ void audio_stop_crowd_sound() */ void audio_stop_title_music() { - if (gTitleMusicChannel) { - Mixer_Stop_Channel(gTitleMusicChannel); - gTitleMusicChannel = 0; - } + audio_stop_channel(&gTitleMusicChannel); } -void stop_rain_sound() +void audio_stop_rain_sound() { - if (gRainSoundChannel) { - Mixer_Stop_Channel(gRainSoundChannel); - gRainSoundChannel = 0; - } + audio_stop_channel(&gRainSoundChannel); +} + +/** +* Stops the specified audio channel from playing. +* @param channel The channel to stop. +*/ +void audio_stop_channel(void **channel) +{ + if (!*channel) + return; + + Mixer_Stop_Channel(*channel); + *channel = 0; } /** * * rct2: 0x006BA8E0 */ -void audio_init1() +void audio_init_ride_sounds_and_info() { int deviceNum = 0; - audio_init2(deviceNum); + audio_init_ride_sounds(deviceNum); for (int m = 0; m < countof(gRideMusicInfoList); m++) { rct_ride_music_info *rideMusicInfo = gRideMusicInfoList[m]; @@ -295,7 +301,7 @@ void audio_init1() * * rct2: 0x006BA9B5 */ -void audio_init2(int device) +void audio_init_ride_sounds(int device) { audio_close(); for (int i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) { @@ -320,7 +326,7 @@ void audio_close() audio_stop_crowd_sound(); audio_stop_title_music(); audio_stop_ride_music(); - stop_rain_sound(); + audio_stop_rain_sound(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1; } @@ -345,7 +351,7 @@ void audio_pause_sounds() audio_stop_vehicle_sounds(); audio_stop_ride_music(); audio_stop_crowd_sound(); - stop_rain_sound(); + audio_stop_rain_sound(); } /** diff --git a/src/audio/audio.h b/src/audio/audio.h index ceb42682ca..48a488a52e 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -29,11 +29,11 @@ #define AUDIO_MAX_VEHICLE_SOUNDS 14 #define NUM_DEFAULT_MUSIC_TRACKS 46 -typedef struct { +typedef struct audio_device { char name[AUDIO_DEVICE_NAME_SIZE]; } audio_device; -typedef struct { +typedef struct rct_ride_music { uint8 ride_id; uint8 tune_id; sint16 volume; @@ -42,14 +42,14 @@ typedef struct { void* sound_channel; } rct_ride_music; -typedef struct { +typedef struct rct_ride_music_info { uint32 length; uint32 offset; uint8 path_id; uint8 var_9; } rct_ride_music_info; -typedef struct { +typedef struct rct_ride_music_params { uint8 ride_id; uint8 tune_id; sint32 offset; @@ -58,7 +58,7 @@ typedef struct { uint16 frequency; } rct_ride_music_params; -typedef struct { +typedef struct rct_vehicle_sound { uint16 id; sint16 volume; uint16 sound1_id; @@ -73,7 +73,7 @@ typedef struct { void* sound2_channel; } rct_vehicle_sound; -typedef struct { +typedef struct rct_vehicle_sound_params { uint16 id; sint16 pan_x; sint16 pan_y; @@ -82,7 +82,7 @@ typedef struct { uint16 var_A; } rct_vehicle_sound_params; -typedef enum { +typedef enum RCT2_SOUND { SOUND_LIFT_1 = 0, SOUND_TRACK_FRICTION_1 = 1, SOUND_LIFT_2 = 2, @@ -163,20 +163,79 @@ extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; +/** +* Deregisters the audio device. +*/ void audio_close(); +/* +* Initialises the audio subsystem. +*/ void audio_init(); -void audio_init1(); -void audio_init2(int device); +/** +* Loads the ride sounds and info. +*/ +void audio_init_ride_sounds_and_info(); +/** +Loads the ride sounds. +*/ +void audio_init_ride_sounds(int device); +/** +* Temporarily stops playing sounds until audio_unpause_sounds() is called. +*/ void audio_pause_sounds(); +/** +* Populates the gAudioDevices array with the available audio devices. +*/ void audio_populate_devices(); +/** +* Terminates the audio subsystem. +* This appears to be unused. +*/ void audio_quit(); -int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z); +/** Plays the specified sound effect at the specified virtual location. +* @param soundId The sound effect to play. +* @param mode If set to 0x8001, play the sound at the specified location; if +* set to 0x8000, play the sound at the center of the viewport; if set to +* anything else, use the value of mode as a relative position to the center of +* the viewport. +* @param x The x coordinate of the location. +* @param y The y coordinate of the location. +* @param z The z coordinate of the location. +* @return 0 if the sound was played successfully, otherwise, soundId. +*/ +int audio_sound_play_panned(int soundId, int mode, sint16 x, sint16 y, sint16 z); +/** +* Starts playing the title music. +*/ void audio_start_title_music(); +/** +* Stops the crowd sound effect from playing. +*/ void audio_stop_crowd_sound(); +/** +* Stops the rain sound effect from playing. +*/ +void audio_stop_rain_sound(); +/** +* Stops ride music from playing. +*/ void audio_stop_ride_music(); +/** +* Stops the title music from playing. +*/ void audio_stop_title_music(); +/** +* Stops vehicle sounds from playing. +*/ void audio_stop_vehicle_sounds(); +/** +* Toggles whether all sounds should be played. +*/ void audio_toggle_all_sounds(); +/** +* Resumes playing sounds that had been paused by a call to +* audio_pause_sounds(). +*/ void audio_unpause_sounds(); #endif diff --git a/src/rct2.c b/src/rct2.c index 80ce5c8ba1..7781f5af7b 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -104,7 +104,7 @@ int rct2_init() font_sprite_initialise_characters(); if (!gOpenRCT2Headless) { platform_init(); - audio_init1(); + audio_init_ride_sounds_and_info(); } viewport_init_all(); news_item_init_queue(); diff --git a/src/windows/options.c b/src/windows/options.c index 95778854e2..6fcb3a819b 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -1069,7 +1069,7 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown case WINDOW_OPTIONS_PAGE_AUDIO: switch (widgetIndex) { case WIDX_SOUND_DROPDOWN: - audio_init2(dropdownIndex); + audio_init_ride_sounds(dropdownIndex); if (dropdownIndex < gAudioDeviceCount) { if (dropdownIndex == 0) { Mixer_Init(NULL); diff --git a/src/world/climate.c b/src/world/climate.c index 5692acb13b..ed1cac08d2 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -108,10 +108,7 @@ void climate_reset(int climate) _lightningTimer = 0; _thunderTimer = 0; if (_rainVolume != 1){ - if (gRainSoundChannel) { - Mixer_Stop_Channel(gRainSoundChannel); - gRainSoundChannel = 0; - } + audio_stop_rain_sound(); _rainVolume = 1; } @@ -272,10 +269,7 @@ static void climate_update_rain_sound() Mixer_Channel_Volume(gRainSoundChannel, DStoMixerVolume(_rainVolume)); } } else { - if (gRainSoundChannel) { - Mixer_Stop_Channel(gRainSoundChannel); - gRainSoundChannel = 0; - } + audio_stop_rain_sound(); _rainVolume = 1; } } From 72b6a1e74b1681cb62aa5aa4f363eecc24f3d4a0 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Tue, 17 Nov 2015 20:01:30 +0000 Subject: [PATCH 04/10] Add parens and use coordinate_3d_to_2d in audio.c --- src/audio/audio.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index e3606baebf..3082fceffa 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -111,26 +111,13 @@ int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) if (element && (element->base_height * 8) - 5 > z) volumeDown = 10; - sint16 rx; - sint16 ry; - switch (get_current_rotation()) { - case 0: - rx = y - x; - ry = ((y + x) / 2) - z; - break; - case 1: - rx = -x - y; - ry = ((y - x) / 2) - z; - break; - case 2: - rx = x - y; - ry = ((-y - x) / 2) - z; - break; - case 3: - rx = y + x; - ry = ((x - y) / 2) - z; - break; - } + uint8 rotation = get_current_rotation(); + rct_xyz16 pos3; + pos3.x = x; + pos3.y = y; + pos3.z = z; + + rct_xy16 pos2 = coordinate_3d_to_2d(&pos3, rotation); rct_window *window = RCT2_GLOBAL( RCT2_ADDRESS_NEW_WINDOW_PTR, @@ -143,8 +130,8 @@ int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) } rct_viewport *viewport = window->viewport; if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { - sint16 vy = ry - viewport->view_y; - sint16 vx = rx - viewport->view_x; + sint16 vy = pos2.y - viewport->view_y; + sint16 vx = pos2.x - viewport->view_x; ebx = viewport->x + (vx >> viewport->zoom); volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; @@ -188,7 +175,7 @@ int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) */ void audio_start_title_music() { - if (gGameSoundsOff || !RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { + if (gGameSoundsOff || !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) { audio_stop_title_music(); return; } From bbc58830f399585e689a70c3c217396b8ddb2e44 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Tue, 17 Nov 2015 20:07:39 +0000 Subject: [PATCH 05/10] Allow lines to be 128 characters --- src/audio/audio.c | 52 +++++++++++------------------------------------ 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index 3082fceffa..dd7daf0bb9 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -74,11 +74,7 @@ void audio_populate_devices() gAudioDeviceCount++; gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device)); - safe_strncpy( - gAudioDevices[0].name, - language_get_string(5510), - AUDIO_DEVICE_NAME_SIZE - ); + safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE); for (int i = 1; i < gAudioDeviceCount; i++) { const char *utf8Name = SDL_GetAudioDeviceName(i - 1, SDL_FALSE); @@ -119,28 +115,20 @@ int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) rct_xy16 pos2 = coordinate_3d_to_2d(&pos3, rotation); - rct_window *window = RCT2_GLOBAL( - RCT2_ADDRESS_NEW_WINDOW_PTR, - rct_window* - ); + rct_window *window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); while (true) { window--; - if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) { + if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) break; - } + rct_viewport *viewport = window->viewport; if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { sint16 vy = pos2.y - viewport->view_y; sint16 vx = pos2.x - viewport->view_x; ebx = viewport->x + (vx >> viewport->zoom); - volume = RCT2_ADDRESS(0x0099282C, int)[soundId] - + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; + volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; - if (vy < 0 - || vy >= viewport->view_height - || vx < 0 - || vx >= viewport->view_width - || volume < -10000) + if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || volume < -10000) return soundId; } } @@ -149,23 +137,11 @@ int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) int pan = 0; if (ebx != (sint16)0x8000) { int x2 = ebx << 16; - uint16 screenWidth = max( - 64, - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - ); - + uint16 screenWidth = max(64, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)); pan = ((x2 / screenWidth) - 0x8000) >> 4; } - Mixer_Play_Effect( - soundId, - MIXER_LOOP_NONE, - DStoMixerVolume(volume), - DStoMixerPan(pan), - 1, - 1 - ); - + Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 1); return 0; } @@ -215,9 +191,8 @@ void audio_stop_ride_music() if (rideMusic->ride_id == (uint8)-1) continue; - if (rideMusic->sound_channel) { + if (rideMusic->sound_channel) Mixer_Stop_Channel(rideMusic->sound_channel); - } rideMusic->ride_id = -1; } @@ -356,8 +331,7 @@ void audio_unpause_sounds() */ void audio_stop_vehicle_sounds() { - if (gOpenRCT2Headless - || RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) == -1) + if (gOpenRCT2Headless || RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) == -1) return; for (int i = 0; i < countof(gVehicleSoundList); i++) { @@ -365,13 +339,11 @@ void audio_stop_vehicle_sounds() if (vehicleSound->id == 0xFFFF) continue; - if (vehicleSound->sound1_id != 0xFFFF) { + if (vehicleSound->sound1_id != 0xFFFF) Mixer_Stop_Channel(vehicleSound->sound1_channel); - } - if (vehicleSound->sound2_id != 0xFFFF) { + if (vehicleSound->sound2_id != 0xFFFF) Mixer_Stop_Channel(vehicleSound->sound2_channel); - } vehicleSound->id = 0xFFFF; } From e9b7e416359e3cd736d0b75092babb9f3548ea9f Mon Sep 17 00:00:00 2001 From: Dom Light Date: Tue, 17 Nov 2015 23:05:24 +0000 Subject: [PATCH 06/10] Refactor audio_sound_play_planned --- src/audio/audio.c | 123 ++++++++++++++++---------- src/audio/audio.h | 47 +++++++--- src/input.c | 4 +- src/interface/window.c | 2 +- src/management/news_item.c | 2 +- src/openrct2.c | 2 +- src/peep/peep.c | 14 +-- src/windows/editor_object_selection.c | 2 +- src/windows/error.c | 2 +- src/windows/footpath.c | 4 +- src/windows/install_track.c | 2 +- src/windows/map.c | 2 +- src/windows/maze_construction.c | 4 +- src/windows/new_ride.c | 2 +- src/windows/news.c | 4 +- src/windows/ride_construction.c | 10 +-- src/windows/scenery.c | 2 +- src/windows/title_scenarioselect.c | 2 +- src/windows/top_toolbar.c | 16 ++-- src/windows/track_list.c | 2 +- src/windows/track_place.c | 4 +- src/world/balloon.c | 2 +- src/world/duck.c | 2 +- src/world/map.c | 12 +-- src/world/particle.c | 2 +- 25 files changed, 157 insertions(+), 113 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index dd7daf0bb9..68318df050 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -46,6 +46,7 @@ rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params *gVehicleSoundParamsListEnd; +bool audio_get_pan_from_location(int soundId, const rct_xyz16 *location, int *volume, int *pan); void audio_stop_channel(void **channel); void audio_init() @@ -85,63 +86,87 @@ void audio_populate_devices() } } -/** -* -* rct2: 0x006BB76E -* -* @param sound_id (eax) -* @param ebx (ebx) -* @param x (cx) -* @param y (dx) -* @param z (bp) -*/ -int audio_sound_play_panned(int soundId, int ebx, sint16 x, sint16 y, sint16 z) +int audio_play_sound_panned(int soundId, int pan, sint16 x, sint16 y, sint16 z) +{ + if (pan == AUDIO_PLAY_AT_LOCATION) + return audio_play_sound_at_location(soundId, x, y, z); + + return audio_play_sound(soundId, 0, pan); +} + +int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z) { if (gGameSoundsOff) return 0; int volume = 0; - if (ebx == 0x8001) { - int volumeDown = 0; - rct_map_element *element = map_get_surface_element_at(x / 32, y / 32); - if (element && (element->base_height * 8) - 5 > z) - volumeDown = 10; - - uint8 rotation = get_current_rotation(); - rct_xyz16 pos3; - pos3.x = x; - pos3.y = y; - pos3.z = z; - - rct_xy16 pos2 = coordinate_3d_to_2d(&pos3, rotation); - - rct_window *window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); - while (true) { - window--; - if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) - break; - - rct_viewport *viewport = window->viewport; - if (viewport && viewport->flags & VIEWPORT_FLAG_SOUND_ON) { - sint16 vy = pos2.y - viewport->view_y; - sint16 vx = pos2.x - viewport->view_x; - ebx = viewport->x + (vx >> viewport->zoom); - volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; - - if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || volume < -10000) - return soundId; - } - } - } - int pan = 0; - if (ebx != (sint16)0x8000) { - int x2 = ebx << 16; - uint16 screenWidth = max(64, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)); - pan = ((x2 / screenWidth) - 0x8000) >> 4; + rct_xyz16 location; + location.x = x; + location.y = y; + location.z = z; + + bool success = audio_get_pan_from_location(soundId, &location, &volume, &pan); + if (!success) + return soundId; + + return audio_play_sound(soundId, volume, pan); +} + +/** +* Returns the pan to use when playing the specified sound at a virtual location. +* @param soundId The sound effect to be played. +* @param location The location at which the sound effect is to be played. +* @param volume [out] The volume at which the sound effect should be played. +* @param pan [out] The pan at which the sound effection should be played. +* @return true if the sound is in range and should be played; otherwise, false. +*/ +bool audio_get_pan_from_location(int soundId, const rct_xyz16 *location, int *volume, int *pan) +{ + *volume = 0; + *pan = 0; + int volumeDown = 0; + rct_map_element *element = map_get_surface_element_at(location->x / 32, location->y / 32); + if (element && (element->base_height * 8) - 5 > location->z) + volumeDown = 10; + + uint8 rotation = get_current_rotation(); + rct_xy16 pos2 = coordinate_3d_to_2d(location, rotation); + rct_window *window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); + while (true) { + window--; + if (window < RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window)) + break; + + rct_viewport *viewport = window->viewport; + if (!viewport || !(viewport->flags & VIEWPORT_FLAG_SOUND_ON)) + continue; + + sint16 vy = pos2.y - viewport->view_y; + sint16 vx = pos2.x - viewport->view_x; + *pan = viewport->x + (vx >> viewport->zoom); + *volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; + + if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || *volume < -10000) + return false; } - Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 1); + return true; +} + +int audio_play_sound(int soundId, int volume, int pan) +{ + if (gGameSoundsOff) + return 0; + + int mixerPan = 0; + if (pan != AUDIO_PLAY_AT_CENTRE) { + int x2 = pan << 16; + uint16 screenWidth = max(64, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)); + mixerPan = ((x2 / screenWidth) - 0x8000) >> 4; + } + + Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(mixerPan), 1, 1); return 0; } diff --git a/src/audio/audio.h b/src/audio/audio.h index 48a488a52e..8c8c977d25 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -28,6 +28,8 @@ #define AUDIO_MAX_RIDE_MUSIC 2 #define AUDIO_MAX_VEHICLE_SOUNDS 14 #define NUM_DEFAULT_MUSIC_TRACKS 46 +#define AUDIO_PLAY_AT_CENTRE 0x8000 +#define AUDIO_PLAY_AT_LOCATION 0x8001 typedef struct audio_device { char name[AUDIO_DEVICE_NAME_SIZE]; @@ -184,6 +186,36 @@ void audio_init_ride_sounds(int device); */ void audio_pause_sounds(); /** +* Plays the specified sound. +* @param soundId The sound effect to play. +* @param volume The volume at which the sound effect should be played. +* @param pan The pan at which the sound effect should be played. If set to anything other than AUDIO_PLAY_AT_CENTRE, plays the +* sound at a position relative to the centre of the viewport. +*/ +int audio_play_sound(int soundId, int volume, int pan); +/** +* Plays the specified sound at a virtual location. +* @param soundId The sound effect to play. +* @param x The x coordinate of the location. +* @param y The y coordinate of the location. +* @param z The z coordinate of the location. +*/ +int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z); +/** +* rct2: 0x006BB76E +* @deprecated Use audio_play_sound_at_location or audio_play_sound instead. +* Plays the specified sound effect at a location specified by the pan parameter. +* @param soundId (eax) The sound effect to play. +* @param pan (ebx) If set to AUDIO_PLAY_AT_LOCATION, play the sound at the specified location; if set to AUDIO_PLAY_AT_CENTRE, play +* the sound at the centre of the viewport; if set to anything else, use the value of pan as a relative position to the centre +* of the viewport. +* @param x (cx) The x coordinate of the location. +* @param y (dx) The y coordinate of the location. +* @param z (bp) The z coordinate of the location. +* @return 0 if the sound was not out of range; otherwise, soundId. +*/ +int audio_play_sound_panned(int soundId, int pan, sint16 x, sint16 y, sint16 z); +/** * Populates the gAudioDevices array with the available audio devices. */ void audio_populate_devices(); @@ -192,18 +224,6 @@ void audio_populate_devices(); * This appears to be unused. */ void audio_quit(); -/** Plays the specified sound effect at the specified virtual location. -* @param soundId The sound effect to play. -* @param mode If set to 0x8001, play the sound at the specified location; if -* set to 0x8000, play the sound at the center of the viewport; if set to -* anything else, use the value of mode as a relative position to the center of -* the viewport. -* @param x The x coordinate of the location. -* @param y The y coordinate of the location. -* @param z The z coordinate of the location. -* @return 0 if the sound was played successfully, otherwise, soundId. -*/ -int audio_sound_play_panned(int soundId, int mode, sint16 x, sint16 y, sint16 z); /** * Starts playing the title music. */ @@ -233,8 +253,7 @@ void audio_stop_vehicle_sounds(); */ void audio_toggle_all_sounds(); /** -* Resumes playing sounds that had been paused by a call to -* audio_pause_sounds(). +* Resumes playing sounds that had been paused by a call to audio_pause_sounds(). */ void audio_unpause_sounds(); diff --git a/src/input.c b/src/input.c index c68a1562e4..68fe6541a9 100644 --- a/src/input.c +++ b/src/input.c @@ -1021,7 +1021,7 @@ static void input_widget_left(int x, int y, rct_window *w, int widgetIndex) break; default: if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) { - audio_sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); // Set new cursor down widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; @@ -1267,7 +1267,7 @@ void input_state_widget_pressed(int x, int y, int state, int widgetIndex, rct_wi break; int mid_point_x = (widget->left + widget->right) / 2 + w->x; - audio_sound_play_panned(5, mid_point_x, 0, 0, 0); + audio_play_sound_panned(5, mid_point_x, 0, 0, 0); if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; diff --git a/src/interface/window.c b/src/interface/window.c index 8bf9e8efe1..ebed32d5c2 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -397,7 +397,7 @@ rct_window *window_create(int x, int y, int width, int height, rct_window_event_ // Play sounds and flash the window if (!(flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))){ w->flags |= WF_WHITE_BORDER_MASK; - audio_sound_play_panned(SOUND_WINDOW_OPEN, x + (width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_WINDOW_OPEN, x + (width / 2), 0, 0, 0); } w->number = 0; diff --git a/src/management/news_item.c b/src/management/news_item.c index f83f5d2ca1..563703eeb7 100644 --- a/src/management/news_item.c +++ b/src/management/news_item.c @@ -85,7 +85,7 @@ static void news_item_tick_current() // Only play news item sound when in normal playing mode if (ticks == 1 && (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) == SCREEN_FLAGS_PLAYING)) { // Play sound - audio_sound_play_panned(SOUND_NEWS_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); + audio_play_sound_panned(SOUND_NEWS_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); } } diff --git a/src/openrct2.c b/src/openrct2.c index 4bebe17b65..54bfdac002 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -639,7 +639,7 @@ static void openrct2_setup_rct2_hooks() addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0, 0); // remove when 0x6E7FF3 is decompiled addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0, 0); // remove when all callers are decompiled addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0, 0); // remove when all callers are decompiled - addhook(0x006BB76E, (int)audio_sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX, 0); // remove when all callers are decompiled + addhook(0x006BB76E, (int)audio_play_sound_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX, 0); // remove when all callers are decompiled addhook(0x006C42D9, (int)scrolling_text_setup, 0, (int[]){EAX, ECX, EBP, END}, 0, EBX); // remove when all callers are decompiled addhook(0x006C2321, (int)gfx_get_string_width, 0, (int[]){ESI, END}, 0, ECX); // remove when all callers are decompiled addhook(0x006C2555, (int)format_string, 0, (int[]){EDI, EAX, ECX, END}, 0, 0); // remove when all callers are decompiled diff --git a/src/peep/peep.c b/src/peep/peep.c index 2cc1bf15dc..bc8dc47b31 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -392,7 +392,7 @@ static void sub_68F41A(rct_peep *peep, int index) } if (peep->flags & PEEP_FLAGS_EXPLODE && peep->x != (sint16)0x8000){ - audio_sound_play_panned(SOUND_CRASH, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(SOUND_CRASH, 0x8001, peep->x, peep->y, peep->z); sprite_misc_3_create(peep->x, peep->y, peep->z + 16); sprite_misc_5_create(peep->x, peep->y, peep->z + 16); @@ -1029,7 +1029,7 @@ int peep_update_action(sint16* x, sint16* y, sint16* xy_distance, rct_peep* peep litter_create(peep->x, peep->y, peep->z, peep->sprite_direction, peep->sprite_index & 1); int sound_id = SOUND_COUGH_1 + (scenario_rand() & 3); - audio_sound_play_panned(sound_id, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(sound_id, 0x8001, peep->x, peep->y, peep->z); invalidate_sprite_2((rct_sprite*)peep); *x = peep->x; @@ -1141,7 +1141,7 @@ void peep_update_sprite_type(rct_peep* peep) ) { bl = 1; - audio_sound_play_panned(SOUND_BALLOON_POP, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(SOUND_BALLOON_POP, 0x8001, peep->x, peep->y, peep->z); } if (peep->x != SPRITE_LOCATION_NULL) { @@ -3161,7 +3161,7 @@ static void peep_update_ride_sub_state_20(rct_peep* peep){ return; } - audio_sound_play_panned(SOUND_TOILET_FLUSH, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(SOUND_TOILET_FLUSH, 0x8001, peep->x, peep->y, peep->z); peep->sub_state++; @@ -5265,7 +5265,7 @@ void peep_applause() } // Play applause noise - audio_sound_play_panned(SOUND_APPLAUSE, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); + audio_play_sound_panned(SOUND_APPLAUSE, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2, 0, 0, 0); } /** @@ -7523,7 +7523,7 @@ static void peep_spend_money(rct_peep *peep, money16 *peep_expend_type, money32 RCT2_GLOBAL(0x00141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8); finance_payment(-amount, RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) / 4); - audio_sound_play_panned(SOUND_PURCHASE, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(SOUND_PURCHASE, 0x8001, peep->x, peep->y, peep->z); } static void peep_set_has_ridden(rct_peep *peep, int rideIndex) @@ -7851,7 +7851,7 @@ static void peep_on_exit_ride(rct_peep *peep, int rideIndex) int laugh = scenario_rand() & 7; if (laugh < 3) { - audio_sound_play_panned(SOUND_LAUGH_1 + laugh, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_panned(SOUND_LAUGH_1 + laugh, 0x8001, peep->x, peep->y, peep->z); } } diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index f9a00a06b9..b1e561c15a 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -973,7 +973,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, int s window_invalidate(w); - audio_sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { diff --git a/src/windows/error.c b/src/windows/error.c index c6489d3651..bba3cbece5 100644 --- a/src/windows/error.c +++ b/src/windows/error.c @@ -138,7 +138,7 @@ void window_error_open(rct_string_id title, rct_string_id message) w->widgets = window_error_widgets; w->error.var_480 = 0; if (!(RCT2_GLOBAL(0x009A8C29, uint8) & 1)) - audio_sound_play_panned(SOUND_ERROR, 0, w->x + (w->width / 2), 0, 0); + audio_play_sound_panned(SOUND_ERROR, 0, w->x + (w->width / 2), 0, 0); } /** diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 0456bf11bf..da68534d30 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -768,7 +768,7 @@ static void window_footpath_place_path_at_point(int x, int y) // bp = RCT2_ADDRESS_COMMAND_MAP_Z // dx = RCT2_ADDRESS_COMMAND_MAP_Y // cx = RCT2_ADDRESS_COMMAND_MAP_X - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } } @@ -852,7 +852,7 @@ static void window_footpath_construct() cost = footpath_place(type, x, y, z, slope, GAME_COMMAND_FLAG_APPLY); if (cost != MONEY32_UNDEFINED) { - audio_sound_play_panned( + audio_play_sound_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16), diff --git a/src/windows/install_track.c b/src/windows/install_track.c index b549785c57..1b631782ae 100644 --- a/src/windows/install_track.c +++ b/src/windows/install_track.c @@ -159,7 +159,7 @@ static void window_install_track_select(rct_window *w, int index) w->track_list.var_480 = index; - audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && index == 0) { window_close(w); ride_construct_new(_window_install_track_item); diff --git a/src/windows/map.c b/src/windows/map.c index 29fbbb79a7..daf93a9e71 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1289,7 +1289,7 @@ static void window_map_place_park_entrance_tool_down(int x, int y) if (price == MONEY32_UNDEFINED) return; - audio_sound_play_panned( + audio_play_sound_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16), diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index 3fd6efc81d..da13cd7a9a 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -371,7 +371,7 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* if (cost == MONEY32_UNDEFINED) return; - audio_sound_play_panned( + audio_play_sound_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16), @@ -509,6 +509,6 @@ static void window_maze_construction_construct(int direction) _currentTrackBeginX = x; _currentTrackBeginY = y; if (_rideConstructionState != 7) { - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } } diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index 4fea00da60..fc9d702cc6 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -688,7 +688,7 @@ static void window_new_ride_scrollmousedown(rct_window *w, int scrollIndex, int RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item; w->new_ride.selected_ride_id = *((sint16*)&item); - audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); w->new_ride.selected_ride_countdown = 8; window_invalidate(w); } diff --git a/src/windows/news.c b/src/windows/news.c index 623c6d579c..0df430e2de 100644 --- a/src/windows/news.c +++ b/src/windows/news.c @@ -147,7 +147,7 @@ static void window_news_update(rct_window *w) return; window_invalidate(w); - audio_sound_play_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); j = w->news.var_480; w->news.var_480 = -1; @@ -239,7 +239,7 @@ static void window_news_scrollmousedown(rct_window *w, int scrollIndex, int x, i w->news.var_482 = buttonIndex; w->news.var_484 = 4; window_invalidate(w); - audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); } } diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index b3e06f650b..f54adae7ec 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1594,7 +1594,7 @@ static void window_ride_construction_construct(rct_window *w) return; } - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); if (RCT2_GLOBAL(RCT2_ADDRESS_ABOVE_GROUND_FLAGS, uint8) & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) { viewport_set_visibility(1); @@ -3554,7 +3554,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) zAttempts == 0 || z < 0 ) { - audio_sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); + audio_play_sound_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != NULL){ tool_set(w, 23, 12); @@ -3571,7 +3571,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) } else { window_close_by_class(WC_ERROR); - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); break; } } @@ -3626,7 +3626,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) _currentTrackCovered = saveCurrentTrackCovered; _currentTrackLiftHill = saveCurrentTrackLiftHill; - audio_sound_play_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); + audio_play_sound_panned(SOUND_ERROR, RCT2_GLOBAL(0x0142406C, sint32), x, y, z); break; } else if (zAttempts >= 0) { z += 16; @@ -3680,7 +3680,7 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) return; } - audio_sound_play_panned( + audio_play_sound_panned( SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), diff --git a/src/windows/scenery.c b/src/windows/scenery.c index ecf4eaed73..8ca4deebd2 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -795,7 +795,7 @@ void window_scenery_scrollmousedown(rct_window *w, int scrollIndex, int x, int y window_scenery_selected_scenery_by_tab[tabIndex] = sceneryId; window_scenery_is_repaint_scenery_tool_on &= 0xFE; - audio_sound_play_panned(4, (w->width >> 1) + w->x, 0, 0, 0); + audio_play_sound_panned(4, (w->width >> 1) + w->x, 0, 0, 0); w->scenery.hover_counter = -16; RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_COST, uint32) = MONEY32_UNDEFINED; window_invalidate(w); diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index b4a4d1f6f3..cc20a5ca8c 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -215,7 +215,7 @@ static void window_scenarioselect_scrollmousedown(rct_window *w, int scrollIndex if (y >= 0) continue; - audio_sound_play_panned(SOUND_CLICK_1, w->width / 2 + w->x, 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->width / 2 + w->x, 0, 0, 0); scenario_load_and_play(scenario); break; } diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index c40c5ea852..cc90a70c0c 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1479,7 +1479,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); success = true; break; } @@ -1507,7 +1507,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (successfulPlacements > 0) { window_close_by_class(WC_ERROR); } else { - audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1518,7 +1518,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_POSITION_THIS_HERE; int cost = game_do_command(gridX, flags, gridY, parameter_2, GAME_COMMAND_PLACE_PATH, parameter_3, 0); if (cost != MONEY32_UNDEFINED) { - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1542,7 +1542,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1556,7 +1556,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_LARGE: @@ -1579,7 +1579,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1593,7 +1593,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - audio_sound_play_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_BANNER: @@ -1613,7 +1613,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED) { int bannerId = regs.edi; - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); window_banner_open(bannerId); } break; diff --git a/src/windows/track_list.c b/src/windows/track_list.c index 76c837569b..092fd3e6cc 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -158,7 +158,7 @@ static void window_track_list_select(rct_window *w, int index) w->track_list.var_480 = index; - audio_sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && index == 0) { window_close(w); ride_construct_new(_window_track_list_item); diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 38102c2370..799b649560 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -541,7 +541,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i if (cost != MONEY32_UNDEFINED) { window_close_by_class(WC_ERROR); - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, mapX, mapY, mapZ); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, mapX, mapY, mapZ); RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex; if (RCT2_GLOBAL(0x00F4414E, uint8) & 1) { @@ -563,7 +563,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i } // Unable to build track - audio_sound_play_panned(SOUND_ERROR, 0x8001, mapX, mapY, mapZ); + audio_play_sound_panned(SOUND_ERROR, 0x8001, mapX, mapY, mapZ); } /** diff --git a/src/world/balloon.c b/src/world/balloon.c index b1e5cfbd1a..a8470f0491 100644 --- a/src/world/balloon.c +++ b/src/world/balloon.c @@ -26,7 +26,7 @@ void balloon_pop(rct_balloon *balloon) { balloon->popped = 1; balloon->var_26 = 0; - audio_sound_play_panned(SOUND_BALLOON_POP, 0x8001, balloon->x, balloon->y, balloon->z); + audio_play_sound_panned(SOUND_BALLOON_POP, 0x8001, balloon->x, balloon->y, balloon->z); } /** diff --git a/src/world/duck.c b/src/world/duck.c index a5f6d2d7f0..bc50dd2fc0 100644 --- a/src/world/duck.c +++ b/src/world/duck.c @@ -288,7 +288,7 @@ static void duck_update_fly_away(rct_duck *duck) */ void duck_press(rct_duck *duck) { - audio_sound_play_panned(SOUND_QUACK, 0x8001, duck->x, duck->y, duck->z); + audio_play_sound_panned(SOUND_QUACK, 0x8001, duck->x, duck->y, duck->z); } /** diff --git a/src/world/map.c b/src/world/map.c index 9e6519a358..479325e033 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -1606,7 +1606,7 @@ money32 map_set_land_ownership(uint8 flags, sint16 x1, sint16 y1, sint16 x2, sin y += 16; sint16 z = map_element_height(x, y) & 0xFFFF; - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); return 0; } @@ -1629,7 +1629,7 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } uint8 min_height = 0xFF; @@ -1685,7 +1685,7 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); } uint8 max_height = 0; @@ -1808,7 +1808,7 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - audio_sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); } // Force ride construction to recheck area @@ -1873,7 +1873,7 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - audio_sound_play_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_play_sound_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); } // Force ride construction to recheck area @@ -2030,7 +2030,7 @@ money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop // Play sound (only once) if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_sound_play_panned(SOUND_PLACE_ITEM, 0x8001, centreX, centreY, centreZ); + audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, centreX, centreY, centreZ); } money32 totalCost = 0; diff --git a/src/world/particle.c b/src/world/particle.c index 27fe0221aa..fd421892e4 100644 --- a/src/world/particle.c +++ b/src/world/particle.c @@ -71,7 +71,7 @@ void crashed_vehicle_particle_update(rct_crashed_vehicle_particle *particle) if (waterZ != 0 && particle->z >= waterZ && z <= waterZ) { // Splash - audio_sound_play_panned(SOUND_WATER_2, 0x8001, particle->x, particle->y, waterZ); + audio_play_sound_panned(SOUND_WATER_2, 0x8001, particle->x, particle->y, waterZ); crash_splash_create(particle->x, particle->y, waterZ); sprite_remove((rct_sprite*)particle); return; From bb62b7561ad75815317362ad7cc611d1bfaea5c3 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Wed, 18 Nov 2015 00:03:15 +0000 Subject: [PATCH 07/10] Replace some uses of play_sound_panned with play_sound_at_location --- src/audio/audio.c | 41 ++++++++++++++++++--------------- src/peep/peep.c | 10 ++++---- src/windows/footpath.c | 5 ++-- src/windows/map.c | 3 +-- src/windows/maze_construction.c | 5 ++-- src/windows/ride_construction.c | 7 +++--- src/windows/top_toolbar.c | 16 ++++++------- src/windows/track_place.c | 4 ++-- src/world/balloon.c | 2 +- src/world/duck.c | 2 +- src/world/map.c | 12 +++++----- src/world/particle.c | 2 +- 12 files changed, 55 insertions(+), 54 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index 68318df050..f9e0f30ae8 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -32,6 +32,12 @@ #include "../openrct2.h" #include "../util/util.h" +typedef struct rct_audio_params { + bool in_range; + int volume; + int pan; +} rct_audio_params; + audio_device *gAudioDevices = NULL; int gAudioDeviceCount; void *gCrowdSoundChannel = 0; @@ -46,7 +52,7 @@ rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; rct_vehicle_sound_params *gVehicleSoundParamsListEnd; -bool audio_get_pan_from_location(int soundId, const rct_xyz16 *location, int *volume, int *pan); +rct_audio_params audio_get_params_from_location(int soundId, const rct_xyz16 *location); void audio_stop_channel(void **channel); void audio_init() @@ -99,33 +105,30 @@ int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z) if (gGameSoundsOff) return 0; - int volume = 0; - int pan = 0; rct_xyz16 location; location.x = x; location.y = y; location.z = z; - bool success = audio_get_pan_from_location(soundId, &location, &volume, &pan); - if (!success) + rct_audio_params params = audio_get_params_from_location(soundId, &location); + if (!params.in_range) return soundId; - return audio_play_sound(soundId, volume, pan); + return audio_play_sound(soundId, params.volume, params.pan); } /** -* Returns the pan to use when playing the specified sound at a virtual location. +* Returns the audio parameters to use when playing the specified sound at a virtual location. * @param soundId The sound effect to be played. * @param location The location at which the sound effect is to be played. -* @param volume [out] The volume at which the sound effect should be played. -* @param pan [out] The pan at which the sound effection should be played. -* @return true if the sound is in range and should be played; otherwise, false. +* @return The audio parameters to be used when playing this sound effect. */ -bool audio_get_pan_from_location(int soundId, const rct_xyz16 *location, int *volume, int *pan) +rct_audio_params audio_get_params_from_location(int soundId, const rct_xyz16 *location) { - *volume = 0; - *pan = 0; int volumeDown = 0; + rct_audio_params params; + params.in_range = true; + rct_map_element *element = map_get_surface_element_at(location->x / 32, location->y / 32); if (element && (element->base_height * 8) - 5 > location->z) volumeDown = 10; @@ -144,14 +147,16 @@ bool audio_get_pan_from_location(int soundId, const rct_xyz16 *location, int *vo sint16 vy = pos2.y - viewport->view_y; sint16 vx = pos2.x - viewport->view_x; - *pan = viewport->x + (vx >> viewport->zoom); - *volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; + params.pan = viewport->x + (vx >> viewport->zoom); + params.volume = RCT2_ADDRESS(0x0099282C, int)[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; - if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || *volume < -10000) - return false; + if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || params.volume < -10000) { + params.in_range = false; + return params; + } } - return true; + return params; } int audio_play_sound(int soundId, int volume, int pan) diff --git a/src/peep/peep.c b/src/peep/peep.c index bc8dc47b31..0821ef9c89 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -392,7 +392,7 @@ static void sub_68F41A(rct_peep *peep, int index) } if (peep->flags & PEEP_FLAGS_EXPLODE && peep->x != (sint16)0x8000){ - audio_play_sound_panned(SOUND_CRASH, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(SOUND_CRASH, peep->x, peep->y, peep->z); sprite_misc_3_create(peep->x, peep->y, peep->z + 16); sprite_misc_5_create(peep->x, peep->y, peep->z + 16); @@ -1029,7 +1029,7 @@ int peep_update_action(sint16* x, sint16* y, sint16* xy_distance, rct_peep* peep litter_create(peep->x, peep->y, peep->z, peep->sprite_direction, peep->sprite_index & 1); int sound_id = SOUND_COUGH_1 + (scenario_rand() & 3); - audio_play_sound_panned(sound_id, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(sound_id, peep->x, peep->y, peep->z); invalidate_sprite_2((rct_sprite*)peep); *x = peep->x; @@ -1141,7 +1141,7 @@ void peep_update_sprite_type(rct_peep* peep) ) { bl = 1; - audio_play_sound_panned(SOUND_BALLOON_POP, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(SOUND_BALLOON_POP, peep->x, peep->y, peep->z); } if (peep->x != SPRITE_LOCATION_NULL) { @@ -3161,7 +3161,7 @@ static void peep_update_ride_sub_state_20(rct_peep* peep){ return; } - audio_play_sound_panned(SOUND_TOILET_FLUSH, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(SOUND_TOILET_FLUSH, peep->x, peep->y, peep->z); peep->sub_state++; @@ -7523,7 +7523,7 @@ static void peep_spend_money(rct_peep *peep, money16 *peep_expend_type, money32 RCT2_GLOBAL(0x00141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8); finance_payment(-amount, RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) / 4); - audio_play_sound_panned(SOUND_PURCHASE, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(SOUND_PURCHASE, peep->x, peep->y, peep->z); } static void peep_set_has_ridden(rct_peep *peep, int rideIndex) diff --git a/src/windows/footpath.c b/src/windows/footpath.c index da68534d30..fb16189460 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -768,7 +768,7 @@ static void window_footpath_place_path_at_point(int x, int y) // bp = RCT2_ADDRESS_COMMAND_MAP_Z // dx = RCT2_ADDRESS_COMMAND_MAP_Y // cx = RCT2_ADDRESS_COMMAND_MAP_X - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } } @@ -852,9 +852,8 @@ static void window_footpath_construct() cost = footpath_place(type, x, y, z, slope, GAME_COMMAND_FLAG_APPLY); if (cost != MONEY32_UNDEFINED) { - audio_play_sound_panned( + audio_play_sound_at_location( SOUND_PLACE_ITEM, - 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_Z, uint16) diff --git a/src/windows/map.c b/src/windows/map.c index daf93a9e71..b932d36c1b 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1289,9 +1289,8 @@ static void window_map_place_park_entrance_tool_down(int x, int y) if (price == MONEY32_UNDEFINED) return; - audio_play_sound_panned( + audio_play_sound_at_location( SOUND_PLACE_ITEM, - 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16), RCT2_GLOBAL(0x009DEA64, uint16), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index da13cd7a9a..a3c992b76d 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -371,9 +371,8 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* if (cost == MONEY32_UNDEFINED) return; - audio_play_sound_panned( + audio_play_sound_at_location( SOUND_PLACE_ITEM, - 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, sint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, sint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); @@ -509,6 +508,6 @@ static void window_maze_construction_construct(int direction) _currentTrackBeginX = x; _currentTrackBeginY = y; if (_rideConstructionState != 7) { - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); } } diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index f54adae7ec..1ece93b7c2 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1594,7 +1594,7 @@ static void window_ride_construction_construct(rct_window *w) return; } - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); if (RCT2_GLOBAL(RCT2_ADDRESS_ABOVE_GROUND_FLAGS, uint8) & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) { viewport_set_visibility(1); @@ -3571,7 +3571,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) } else { window_close_by_class(WC_ERROR); - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); + audio_play_sound_at_location(SOUND_PLACE_ITEM, _currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ); break; } } @@ -3680,9 +3680,8 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) return; } - audio_play_sound_panned( + audio_play_sound_at_location( SOUND_PLACE_ITEM, - 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index cc90a70c0c..da8c8c4110 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1479,7 +1479,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); success = true; break; } @@ -1507,7 +1507,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (successfulPlacements > 0) { window_close_by_class(WC_ERROR); } else { - audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_ERROR, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1518,7 +1518,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_POSITION_THIS_HERE; int cost = game_do_command(gridX, flags, gridY, parameter_2, GAME_COMMAND_PLACE_PATH, parameter_3, 0); if (cost != MONEY32_UNDEFINED) { - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); } break; } @@ -1542,7 +1542,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1556,7 +1556,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_ERROR, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_LARGE: @@ -1579,7 +1579,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED){ window_close_by_class(WC_ERROR); - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); return; } @@ -1593,7 +1593,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; } - audio_play_sound_panned(SOUND_ERROR, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_ERROR, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); break; } case SCENERY_TYPE_BANNER: @@ -1613,7 +1613,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w if (cost != MONEY32_UNDEFINED) { int bannerId = regs.edi; - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); window_banner_open(bannerId); } break; diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 799b649560..e52fedbafb 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -541,7 +541,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i if (cost != MONEY32_UNDEFINED) { window_close_by_class(WC_ERROR); - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, mapX, mapY, mapZ); + audio_play_sound_at_location(SOUND_PLACE_ITEM, mapX, mapY, mapZ); RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex; if (RCT2_GLOBAL(0x00F4414E, uint8) & 1) { @@ -563,7 +563,7 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i } // Unable to build track - audio_play_sound_panned(SOUND_ERROR, 0x8001, mapX, mapY, mapZ); + audio_play_sound_at_location(SOUND_ERROR, mapX, mapY, mapZ); } /** diff --git a/src/world/balloon.c b/src/world/balloon.c index a8470f0491..88fdaf320a 100644 --- a/src/world/balloon.c +++ b/src/world/balloon.c @@ -26,7 +26,7 @@ void balloon_pop(rct_balloon *balloon) { balloon->popped = 1; balloon->var_26 = 0; - audio_play_sound_panned(SOUND_BALLOON_POP, 0x8001, balloon->x, balloon->y, balloon->z); + audio_play_sound_at_location(SOUND_BALLOON_POP, balloon->x, balloon->y, balloon->z); } /** diff --git a/src/world/duck.c b/src/world/duck.c index bc50dd2fc0..1e500247ca 100644 --- a/src/world/duck.c +++ b/src/world/duck.c @@ -288,7 +288,7 @@ static void duck_update_fly_away(rct_duck *duck) */ void duck_press(rct_duck *duck) { - audio_play_sound_panned(SOUND_QUACK, 0x8001, duck->x, duck->y, duck->z); + audio_play_sound_at_location(SOUND_QUACK, duck->x, duck->y, duck->z); } /** diff --git a/src/world/map.c b/src/world/map.c index 479325e033..e23eae101d 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -1606,7 +1606,7 @@ money32 map_set_land_ownership(uint8 flags, sint16 x1, sint16 y1, sint16 x2, sin y += 16; sint16 z = map_element_height(x, y) & 0xFFFF; - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); return 0; } @@ -1629,7 +1629,7 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); } uint8 min_height = 0xFF; @@ -1685,7 +1685,7 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b money32 cost = 0; if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); } uint8 max_height = 0; @@ -1808,7 +1808,7 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - audio_play_sound_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_LAYING_OUT_WATER, x, y, z); } // Force ride construction to recheck area @@ -1873,7 +1873,7 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint32) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint32) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint32) = z; - audio_play_sound_panned(SOUND_LAYING_OUT_WATER, 0x8001, x, y, z); + audio_play_sound_at_location(SOUND_LAYING_OUT_WATER, x, y, z); } // Force ride construction to recheck area @@ -2030,7 +2030,7 @@ money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop // Play sound (only once) if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { - audio_play_sound_panned(SOUND_PLACE_ITEM, 0x8001, centreX, centreY, centreZ); + audio_play_sound_at_location(SOUND_PLACE_ITEM, centreX, centreY, centreZ); } money32 totalCost = 0; diff --git a/src/world/particle.c b/src/world/particle.c index fd421892e4..4d2a9b7938 100644 --- a/src/world/particle.c +++ b/src/world/particle.c @@ -71,7 +71,7 @@ void crashed_vehicle_particle_update(rct_crashed_vehicle_particle *particle) if (waterZ != 0 && particle->z >= waterZ && z <= waterZ) { // Splash - audio_play_sound_panned(SOUND_WATER_2, 0x8001, particle->x, particle->y, waterZ); + audio_play_sound_at_location(SOUND_WATER_2, particle->x, particle->y, waterZ); crash_splash_create(particle->x, particle->y, waterZ); sprite_remove((rct_sprite*)particle); return; From a07333aeafaca0b504825c1f2e357339f76c890e Mon Sep 17 00:00:00 2001 From: Dom Light Date: Wed, 18 Nov 2015 00:11:31 +0000 Subject: [PATCH 08/10] Move memory address documentation to header file --- src/audio/audio.c | 41 ----------------------------------------- src/audio/audio.h | 13 ++++++++++++- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/audio/audio.c b/src/audio/audio.c index f9e0f30ae8..ad7706c221 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -175,10 +175,6 @@ int audio_play_sound(int soundId, int volume, int pan) return 0; } -/** -* -* rct2: 0x006BD0F8 -*/ void audio_start_title_music() { if (gGameSoundsOff || !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) { @@ -210,10 +206,6 @@ void audio_start_title_music() gTitleMusicChannel = Mixer_Play_Music(pathId, MIXER_LOOP_INFINITE, true); } -/** -* -* rct2: 0x006BCA9F -*/ void audio_stop_ride_music() { for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { @@ -228,19 +220,11 @@ void audio_stop_ride_music() } } -/** -* -* rct2: 0x006BD07F -*/ void audio_stop_crowd_sound() { audio_stop_channel(&gCrowdSoundChannel); } -/** -* -* rct2: 0x006BD0BD -*/ void audio_stop_title_music() { audio_stop_channel(&gTitleMusicChannel); @@ -264,10 +248,6 @@ void audio_stop_channel(void **channel) *channel = 0; } -/** -* -* rct2: 0x006BA8E0 -*/ void audio_init_ride_sounds_and_info() { int deviceNum = 0; @@ -289,10 +269,6 @@ void audio_init_ride_sounds_and_info() } } -/** -* -* rct2: 0x006BA9B5 -*/ void audio_init_ride_sounds(int device) { audio_close(); @@ -309,10 +285,6 @@ void audio_init_ride_sounds(int device) } } -/** -* -* rct2: 0x006BAB21 -*/ void audio_close() { audio_stop_crowd_sound(); @@ -322,7 +294,6 @@ void audio_close() RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1; } -/* rct2: 0x006BAB8A */ void audio_toggle_all_sounds(){ gConfigSound.sound = !gConfigSound.sound; if (gConfigSound.sound) @@ -333,10 +304,6 @@ void audio_toggle_all_sounds(){ } } -/** -* -* rct2: 0x006BABB4 -*/ void audio_pause_sounds() { gGameSoundsOff = true; @@ -346,19 +313,11 @@ void audio_pause_sounds() audio_stop_rain_sound(); } -/** -* -* rct2: 0x006BABD8 -*/ void audio_unpause_sounds() { gGameSoundsOff = false; } -/** -* -* rct2: 0x006BABDF -*/ void audio_stop_vehicle_sounds() { if (gOpenRCT2Headless || RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) == -1) diff --git a/src/audio/audio.h b/src/audio/audio.h index 8c8c977d25..77c6915522 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -167,6 +167,7 @@ extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; /** * Deregisters the audio device. +* rct2: 0x006BAB21 */ void audio_close(); /* @@ -175,14 +176,17 @@ void audio_close(); void audio_init(); /** * Loads the ride sounds and info. +* rct2: 0x006BA8E0 */ void audio_init_ride_sounds_and_info(); /** -Loads the ride sounds. +* Loads the ride sounds. +* rct2: 0x006BA9B5 */ void audio_init_ride_sounds(int device); /** * Temporarily stops playing sounds until audio_unpause_sounds() is called. +* rct2: 0x006BABB4 */ void audio_pause_sounds(); /** @@ -226,10 +230,12 @@ void audio_populate_devices(); void audio_quit(); /** * Starts playing the title music. +* rct2: 0x006BD0F8 */ void audio_start_title_music(); /** * Stops the crowd sound effect from playing. +* rct2: 0x006BD07F */ void audio_stop_crowd_sound(); /** @@ -238,22 +244,27 @@ void audio_stop_crowd_sound(); void audio_stop_rain_sound(); /** * Stops ride music from playing. +* rct2: 0x006BCA9F */ void audio_stop_ride_music(); /** * Stops the title music from playing. +* rct2: 0x006BD0BD */ void audio_stop_title_music(); /** * Stops vehicle sounds from playing. +* rct2: 0x006BABDF */ void audio_stop_vehicle_sounds(); /** * Toggles whether all sounds should be played. +* rct2: 0x006BAB8A */ void audio_toggle_all_sounds(); /** * Resumes playing sounds that had been paused by a call to audio_pause_sounds(). +* rct2: 0x006BABD8 */ void audio_unpause_sounds(); From 92a30e0a3220e4638f4b6754283c03c0b573e3f3 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Wed, 18 Nov 2015 00:20:22 +0000 Subject: [PATCH 09/10] Add missing return documentation [skip ci] --- src/audio/audio.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/audio/audio.h b/src/audio/audio.h index 77c6915522..3bfde4a2f5 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -195,6 +195,7 @@ void audio_pause_sounds(); * @param volume The volume at which the sound effect should be played. * @param pan The pan at which the sound effect should be played. If set to anything other than AUDIO_PLAY_AT_CENTRE, plays the * sound at a position relative to the centre of the viewport. +* @return 0 if the sound was not out of range; otherwise, soundId. */ int audio_play_sound(int soundId, int volume, int pan); /** @@ -203,6 +204,7 @@ int audio_play_sound(int soundId, int volume, int pan); * @param x The x coordinate of the location. * @param y The y coordinate of the location. * @param z The z coordinate of the location. +* @return 0 if the sound was not out of range; otherwise, soundId. */ int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z); /** @@ -210,9 +212,9 @@ int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z); * @deprecated Use audio_play_sound_at_location or audio_play_sound instead. * Plays the specified sound effect at a location specified by the pan parameter. * @param soundId (eax) The sound effect to play. -* @param pan (ebx) If set to AUDIO_PLAY_AT_LOCATION, play the sound at the specified location; if set to AUDIO_PLAY_AT_CENTRE, play -* the sound at the centre of the viewport; if set to anything else, use the value of pan as a relative position to the centre -* of the viewport. +* @param pan (ebx) If set to AUDIO_PLAY_AT_LOCATION, play the sound at the specified location; if set to AUDIO_PLAY_AT_CENTRE, +* play the sound at the centre of the viewport; if set to anything else, use the value of pan as a relative position to the +* centre of the viewport. * @param x (cx) The x coordinate of the location. * @param y (dx) The y coordinate of the location. * @param z (bp) The z coordinate of the location. From 55fb03fa7589363d71c1c58389830b53f9ec4529 Mon Sep 17 00:00:00 2001 From: Dom Light Date: Wed, 18 Nov 2015 14:01:29 +0000 Subject: [PATCH 10/10] Replace a call to audio_play_sound_panned --- src/peep/peep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index 0821ef9c89..57c2b46867 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -7851,7 +7851,7 @@ static void peep_on_exit_ride(rct_peep *peep, int rideIndex) int laugh = scenario_rand() & 7; if (laugh < 3) { - audio_play_sound_panned(SOUND_LAUGH_1 + laugh, 0x8001, peep->x, peep->y, peep->z); + audio_play_sound_at_location(SOUND_LAUGH_1 + laugh, peep->x, peep->y, peep->z); } }