From e9b7e416359e3cd736d0b75092babb9f3548ea9f Mon Sep 17 00:00:00 2001 From: Dom Light Date: Tue, 17 Nov 2015 23:05:24 +0000 Subject: [PATCH] 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;