set_sound_bank_override (#1046)
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled

This commit is contained in:
Blockyyy 2026-02-20 01:34:25 +01:00 committed by GitHub
parent 692c61f361
commit f6f5434dda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 87 additions and 0 deletions

View file

@ -80,6 +80,7 @@ in_files = [
"src/audio/seqplayer.h",
"src/engine/lighting_engine.h",
"src/pc/network/sync_object.h",
"src/audio/load.h",
]
override_allowed_functions = {
@ -99,6 +100,7 @@ override_allowed_functions = {
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", "handle_special_dialog_text" ],
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ],
"src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally", "sync_object_get_object" ],
"src/audio/load.h": [ "set_sound_bank_override" ],
}
override_disallowed_functions = {

View file

@ -5240,6 +5240,12 @@ function le_set_light_use_surface_normals(id, useSurfaceNormals)
-- ...
end
--- @param bank integer
--- Overrides the soundbank, set to -1 to reset
function set_sound_bank_override(bank)
-- ...
end
--- @param m MarioState
--- @return integer
--- Checks if Mario's current animation has reached its final frame (i.e., the last valid frame in the animation). Useful for deciding when to transition out of an animation-driven action

View file

@ -583,6 +583,35 @@ Sets whether a lighting engine point light will use a surface's normals to deter
<br />
---
# functions from load.h
<br />
## [set_sound_bank_override](#set_sound_bank_override)
### Description
Overrides the soundbank, set to -1 to reset
### Lua Example
`set_sound_bank_override(bank)`
### Parameters
| Field | Type |
| ----- | ---- |
| bank | `integer` |
### Returns
- None
### C Prototype
`void set_sound_bank_override(s32 bank);`
[:arrow_up_small:](#)
<br />
---
# functions from mario.h

View file

@ -997,6 +997,11 @@
<br />
- load.h
- [set_sound_bank_override](functions-4.md#set_sound_bank_override)
<br />
- mario.h
- [is_anim_at_end](functions-4.md#is_anim_at_end)
- [is_anim_past_end](functions-4.md#is_anim_past_end)

View file

@ -1481,6 +1481,13 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) {
#endif
#ifndef VERSION_SH
s32 gOverrideBank = -1;
void set_sound_bank_override(s32 bank) {
gOverrideBank = bank;
}
struct AudioBank *load_banks_immediate(s32 seqId, u8 *arg1) {
void *ret = NULL;
u32 bankId = 0;
@ -1498,6 +1505,10 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *arg1) {
bankId = gAlBankSets[offset - 1];
#endif
if (gOverrideBank > 0) {
bankId = gOverrideBank;
}
if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) {
#ifdef VERSION_EU
ret = get_bank_or_seq(&gBankLoadedPool, 2, bankId);

View file

@ -53,6 +53,7 @@ extern s32 gMinAiBufferLength;
extern s16 gTempoInternalToExternal;
extern s8 gAudioUpdatesPerFrame; // = 4
extern s8 gSoundMode;
extern s32 gOverrideBank;
#ifdef VERSION_SH
extern OSMesgQueue gUnkQueue1;
@ -95,6 +96,9 @@ void preload_sequence(u32 seqId, u8 preloadMask);
#endif
void load_sequence(u32 player, u32 seqId, s32 loadAsync);
/* |description|Overrides the soundbank, set to -1 to reset|descriptionEnd| */
void set_sound_bank_override(s32 bank);
#ifdef VERSION_SH
void func_sh_802f3158(s32 index, s32 arg1, s32 arg2, OSMesgQueue *retQueue);
u8 *func_sh_802f3220(u32 index, u32 *a1);

View file

@ -54,6 +54,7 @@
#include "src/audio/seqplayer.h"
#include "src/engine/lighting_engine.h"
#include "src/pc/network/sync_object.h"
#include "src/audio/load.h"
///////////////
@ -15889,6 +15890,27 @@ int smlua_func_le_set_light_use_surface_normals(lua_State* L) {
return 1;
}
////////////
// load.h //
////////////
int smlua_func_set_sound_bank_override(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_sound_bank_override", 1, top);
return 0;
}
s32 bank = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_sound_bank_override"); return 0; }
set_sound_bank_override(bank);
return 1;
}
/////////////
// mario.h //
/////////////
@ -37575,6 +37597,9 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "le_get_light_use_surface_normals", smlua_func_le_get_light_use_surface_normals);
smlua_bind_function(L, "le_set_light_use_surface_normals", smlua_func_le_set_light_use_surface_normals);
// load.h
smlua_bind_function(L, "set_sound_bank_override", smlua_func_set_sound_bank_override);
// mario.h
smlua_bind_function(L, "is_anim_at_end", smlua_func_is_anim_at_end);
smlua_bind_function(L, "is_anim_past_end", smlua_func_is_anim_past_end);

View file

@ -18,6 +18,7 @@
#include "pc/debuglog.h"
#include "pc/pc_main.h"
#include "pc/fs/fmem.h"
#include "audio/load.h"
struct AudioOverride {
bool enabled;
@ -73,6 +74,8 @@ bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) {
struct AudioOverride* override = &sAudioOverrides[sequenceId];
if (!override->enabled) { return false; }
if (gOverrideBank > -1) { override->bank = gOverrideBank; }
if (override->loaded) {
*seqData = override->buffer;
*bankId = override->bank;

View file

@ -36,6 +36,7 @@
#include "game/mario.h"
#include "engine/math_util.h"
#include "engine/lighting_engine.h"
#include "src/audio/load.h"
#ifdef DISCORD_SDK
#include "pc/discord/discord.h"
@ -711,6 +712,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
gOverrideFar = 0;
gOverrideFOV = 0;
gRoomOverride = -1;
gOverrideBank = -1;
gCurrActStarNum = 0;
gCurrActNum = 0;
gCurrCreditsEntry = NULL;