mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-22 07:32:07 -05:00
Fix autogen for sound functions (#602)
This commit is contained in:
parent
be0e47a4c2
commit
c2ec761608
3 changed files with 27 additions and 7 deletions
|
@ -174,6 +174,22 @@ vec_type_after = """
|
|||
smlua_push_%s($[IDENTIFIER], $[INDEX]);
|
||||
"""
|
||||
|
||||
#
|
||||
# Special cases for sound functions
|
||||
#
|
||||
|
||||
SOUND_FUNCTIONS = [
|
||||
"play_sound",
|
||||
"play_sound_with_freq_scale",
|
||||
"stop_sound",
|
||||
"stop_sounds_from_source",
|
||||
]
|
||||
|
||||
vec3f_sound_before = """
|
||||
f32 *$[IDENTIFIER] = smlua_get_vec3f_from_buffer();
|
||||
smlua_get_vec3f($[IDENTIFIER], $[INDEX]);
|
||||
"""
|
||||
|
||||
###########################################################
|
||||
|
||||
manual_index_documentation = """
|
||||
|
@ -765,12 +781,15 @@ def build_vec_types():
|
|||
|
||||
############################################################################
|
||||
|
||||
def build_param(param, i):
|
||||
def build_param(fid, param, i):
|
||||
ptype = alter_type(param['type'])
|
||||
pid = param['identifier']
|
||||
|
||||
if ptype in VEC_TYPES:
|
||||
return (vec_type_before % (ptype, ptype.lower())).replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i))
|
||||
if ptype == "Vec3f" and fid in SOUND_FUNCTIONS:
|
||||
return vec3f_sound_before.replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i))
|
||||
else:
|
||||
return (vec_type_before % (ptype, ptype.lower())).replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i))
|
||||
elif ptype == 'bool':
|
||||
return ' %s %s = smlua_to_boolean(L, %d);\n' % (ptype, pid, i)
|
||||
elif ptype in integer_types:
|
||||
|
@ -870,7 +889,7 @@ def build_function(function, do_extern):
|
|||
if is_interact_func and param['identifier'] == 'interactType':
|
||||
s += " // interactType skipped so mods can't lie about what interaction it is\n"
|
||||
else:
|
||||
s += build_param(param, i)
|
||||
s += build_param(fid, param, i)
|
||||
s += ' if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %%u for function \'%%s\'", %d, "%s"); return 0; }\n' % (i, fid)
|
||||
i += 1
|
||||
s += '\n'
|
||||
|
|
|
@ -2331,6 +2331,7 @@ void stop_sound(u32 soundBits, f32 *pos) {
|
|||
void stop_sounds_from_source(f32 *pos) {
|
||||
MUTEX_LOCK(gAudioThread);
|
||||
|
||||
pos = smlua_get_vec3f_for_play_sound(pos);
|
||||
u8 bank;
|
||||
u8 soundIndex;
|
||||
|
||||
|
|
|
@ -12938,7 +12938,7 @@ int smlua_func_play_sound(lua_State* L) {
|
|||
s32 soundBits = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "play_sound"); return 0; }
|
||||
|
||||
Vec3f pos;
|
||||
f32 *pos = smlua_get_vec3f_from_buffer();
|
||||
smlua_get_vec3f(pos, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "play_sound"); return 0; }
|
||||
|
||||
|
@ -12961,7 +12961,7 @@ int smlua_func_play_sound_with_freq_scale(lua_State* L) {
|
|||
s32 soundBits = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "play_sound_with_freq_scale"); return 0; }
|
||||
|
||||
Vec3f pos;
|
||||
f32 *pos = smlua_get_vec3f_from_buffer();
|
||||
smlua_get_vec3f(pos, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "play_sound_with_freq_scale"); return 0; }
|
||||
f32 freqScale = smlua_to_number(L, 3);
|
||||
|
@ -13253,7 +13253,7 @@ int smlua_func_stop_sound(lua_State* L) {
|
|||
u32 soundBits = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stop_sound"); return 0; }
|
||||
|
||||
Vec3f pos;
|
||||
f32 *pos = smlua_get_vec3f_from_buffer();
|
||||
smlua_get_vec3f(pos, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "stop_sound"); return 0; }
|
||||
|
||||
|
@ -13274,7 +13274,7 @@ int smlua_func_stop_sounds_from_source(lua_State* L) {
|
|||
}
|
||||
|
||||
|
||||
Vec3f pos;
|
||||
f32 *pos = smlua_get_vec3f_from_buffer();
|
||||
smlua_get_vec3f(pos, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stop_sounds_from_source"); return 0; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue