Adjust for new autogen changes

This commit is contained in:
Cooliokid956 2025-11-25 04:38:09 -06:00
parent ca9fe155fd
commit caac53d93e
9 changed files with 48 additions and 51 deletions

View file

@ -130,7 +130,7 @@ override_disallowed_functions = {
"src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ],
"src/game/camera.h": [ "geo_", "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline", "romhack_camera_init_settings", "romhack_camera_reset_settings" ],
"src/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room", "geo_" ],
"src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown", "smlua_audio_custom_deinit", "audio_sample_destroy_pending_copies", "audio_custom_update_volume", "audio_custom_update_mute" ],
"src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown", "smlua_audio_custom_deinit", "audio_sample_destroy_pending_copies", "audio_custom_update_volume" ],
"src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ],
"src/pc/lua/utils/smlua_text_utils.h": [ "smlua_text_utils_init", "smlua_text_utils_shutdown", "smlua_text_utils_dialog_get_unmodified"],
"src/pc/lua/utils/smlua_anim_utils.h": [ "smlua_anim_util_reset", "smlua_anim_util_register_animation" ],

View file

@ -10276,7 +10276,8 @@ function audio_stream_set_looping(audio, looping)
end
--- @param audio ModAudio
--- @return table
--- @return integer loopStart
--- @return integer loopEnd
--- Gets an `audio` stream's loop points in samples
function audio_stream_get_loop_points(audio)
-- ...
@ -10284,7 +10285,7 @@ end
--- @param audio ModAudio
--- @param loopStart integer
--- @param loopEnd integer
--- @param loopEnd? integer
--- Sets an `audio` stream's loop points in samples
function audio_stream_set_loop_points(audio, loopStart, loopEnd)
-- ...

View file

@ -5854,7 +5854,7 @@ Sets if an `audio` stream is looping or not
Gets an `audio` stream's loop points in samples
### Lua Example
`local tableValue = audio_stream_get_loop_points(audio)`
`local loopStart, loopEnd = audio_stream_get_loop_points(audio)`
### Parameters
| Field | Type |
@ -5862,10 +5862,10 @@ Gets an `audio` stream's loop points in samples
| audio | [ModAudio](structs.md#ModAudio) |
### Returns
- `table`
- None
### C Prototype
`LuaTable audio_stream_get_loop_points(struct ModAudio* audio);`
`void audio_stream_get_loop_points(struct ModAudio* audio, RET u64 *loopStart, RET u64 *loopEnd);`
[:arrow_up_small:](#)
@ -5890,7 +5890,7 @@ Sets an `audio` stream's loop points in samples
- None
### C Prototype
`void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, s64 loopEnd);`
`void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, OPTIONAL s64 loopEnd);`
[:arrow_up_small:](#)

View file

@ -30612,17 +30612,23 @@ int smlua_func_audio_stream_get_loop_points(lua_State* L) {
struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_loop_points"); return 0; }
smlua_push_lua_table(L, audio_stream_get_loop_points(audio));
u64 loopStart;
u64 loopEnd;
return 1;
audio_stream_get_loop_points(audio, &loopStart, &loopEnd);
lua_pushinteger(L, loopStart);
lua_pushinteger(L, loopEnd);
return 2;
}
int smlua_func_audio_stream_set_loop_points(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 3) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_loop_points", 3, top);
if (top < 2 || top > 3) {
LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "audio_stream_set_loop_points", 2, 3, top);
return 0;
}
@ -30630,8 +30636,11 @@ int smlua_func_audio_stream_set_loop_points(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_loop_points"); return 0; }
s64 loopStart = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_loop_points"); return 0; }
s64 loopEnd = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_loop_points"); return 0; }
s64 loopEnd = (s64) NULL;
if (top >= 3) {
loopEnd = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_loop_points"); return 0; }
}
audio_stream_set_loop_points(audio, loopStart, loopEnd);

View file

@ -440,28 +440,16 @@ void audio_stream_set_looping(struct ModAudio* audio, bool looping) {
ma_sound_set_looping(&audio->sound, looping);
}
LuaTable audio_stream_get_loop_points(struct ModAudio* audio) {
struct lua_State *L = gLuaState;
if (!L || !audio_sanity_check(audio, true, "get stream loop points for")) { return 0; }
u64 loopStart, loopEnd;
ma_data_source_get_loop_point_in_pcm_frames(&audio->decoder, &loopStart, &loopEnd);
lua_newtable(L);
lua_pushinteger(L, loopStart);
lua_rawseti(L, -2, 1);
lua_pushinteger(L, loopEnd);
lua_rawseti(L, -2, 2);
return smlua_to_lua_table(L, -1);
void audio_stream_get_loop_points(struct ModAudio* audio, RET u64 *loopStart, RET u64 *loopEnd) {
ma_data_source_get_loop_point_in_pcm_frames(&audio->decoder, loopStart, loopEnd);
}
void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, OPTIONAL s64 loopEnd) {
if (!audio_sanity_check(audio, true, "set stream loop points for")) { return; }
u64 length; ma_data_source_get_length_in_pcm_frames(&audio->decoder, &length);
if (loopStart < 0) loopStart += length;
if (loopEnd <= 0) loopEnd += length;
if (loopStart < 0) loopStart = length + loopStart % length;
if (loopEnd <= 0) loopEnd = length + loopEnd % length;
ma_sound_set_looping(&audio->sound, true);
ma_data_source_set_loop_point_in_pcm_frames(&audio->decoder, loopStart, loopEnd);
@ -642,24 +630,27 @@ void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) {
ma_sound_start(sound);
}
static bool sModAudioMute = false;
void audio_custom_update_volume(void) {
gMasterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
if (!sModAudioPool) { return; }
ma_engine_set_volume(&sModAudioEngine, sModAudioMute ? 0 : gMasterVolume);
bool shouldMute = (configMuteFocusLoss && !WAPI.has_focus());
// Update master volume
f32 masterVolume = shouldMute ? 0 : ((f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f);
gMasterVolume = masterVolume;
if (!sModAudioPool) { return; }
if (ma_engine_get_volume(&sModAudioEngine) != masterVolume) {
ma_engine_set_volume(&sModAudioEngine, masterVolume);
}
// Update music volume
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
if (ma_sound_group_get_volume(&sModAudioStreamGroup) != musicVolume) {
ma_sound_group_set_volume(&sModAudioStreamGroup, musicVolume);
}
// Update sound volume
f32 sfxVolume = (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f;
ma_sound_group_set_volume(&sModAudioStreamGroup, musicVolume);
ma_sound_group_set_volume(&sModAudioSampleGroup, sfxVolume);
}
void audio_custom_update_mute(bool mute) {
if (!sModAudioPool) { return; }
if (sModAudioMute != mute) {
sModAudioMute = mute;
ma_engine_set_volume(&sModAudioEngine, mute ? 0 : gMasterVolume);
if (ma_sound_group_get_volume(&sModAudioSampleGroup) != sfxVolume) {
ma_sound_group_set_volume(&sModAudioSampleGroup, sfxVolume);
}
}

View file

@ -59,9 +59,9 @@ bool audio_stream_get_looping(struct ModAudio* audio);
/* |description|Sets if an `audio` stream is looping or not|descriptionEnd| */
void audio_stream_set_looping(struct ModAudio* audio, bool looping);
/* |description|Gets an `audio` stream's loop points in samples|descriptionEnd| */
LuaTable audio_stream_get_loop_points(struct ModAudio* audio);
void audio_stream_get_loop_points(struct ModAudio* audio, RET u64 *loopStart, RET u64 *loopEnd);
/* |description|Sets an `audio` stream's loop points in samples|descriptionEnd| */
void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, s64 loopEnd);
void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, OPTIONAL s64 loopEnd);
/* |description|Gets the frequency of an `audio` stream|descriptionEnd| */
f32 audio_stream_get_frequency(struct ModAudio* audio);
/* |description|Sets the frequency of an `audio` stream|descriptionEnd| */
@ -82,7 +82,6 @@ void audio_sample_stop(struct ModAudio* audio);
void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume);
void audio_custom_update_volume(void);
void audio_custom_update_mute(bool mute);
void audio_custom_shutdown(void);
void smlua_audio_custom_deinit(void);

View file

@ -211,6 +211,7 @@ Collision *smlua_collision_util_get_level_collision(u32 level, u16 area) {
LuaTable smlua_collision_util_find_surface_types(Collision* data) {
lua_State* L = gLuaState;
if (!L) { return 0; }
if (data && *data++ == COL_INIT()) {
lua_newtable(L);

View file

@ -542,22 +542,18 @@ u8 get_volume_env(void) {
void set_volume_master(u8 volume) {
gLuaVolumeMaster = MIN(volume, 127);
audio_custom_update_volume();
}
void set_volume_level(u8 volume) {
gLuaVolumeLevel = MIN(volume, 127);
audio_custom_update_volume();
}
void set_volume_sfx(u8 volume) {
gLuaVolumeSfx = MIN(volume, 127);
audio_custom_update_volume();
}
void set_volume_env(u8 volume) {
gLuaVolumeEnv = MIN(volume, 127);
audio_custom_update_volume();
}
///

View file

@ -301,7 +301,7 @@ static s16 sAudioBuffer[SAMPLES_HIGH * 2 * 2] = { 0 };
inline static void buffer_audio(void) {
bool shouldMute = (configMuteFocusLoss && !WAPI.has_focus()) || (gMasterVolume == 0);
audio_custom_update_mute(shouldMute);
audio_custom_update_volume();
if (!shouldMute) {
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f);