From 1ac9ce8e4c71d89813a1d269055dcdb0effba05a Mon Sep 17 00:00:00 2001 From: Blockyyy <88585273+Blockyyy@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:56:18 +0200 Subject: [PATCH] sequence_player_set_tempo, sequence_player_set_transposition (#224) * Made Sequence function * snake case --- autogen/convert_functions.py | 6 +- autogen/lua_definitions/functions.lua | 36 +++++++ docs/lua/functions-4.md | 129 ++++++++++++++++++++++++++ docs/lua/functions.md | 10 ++ src/audio/seqplayer.c | 23 +++++ src/audio/seqplayer.h | 6 ++ src/pc/lua/smlua_functions_autogen.c | 121 ++++++++++++++++++++++++ 7 files changed, 329 insertions(+), 2 deletions(-) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 725e38bd..cc77a0e1 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -66,7 +66,8 @@ in_files = [ "src/engine/level_script.h", "src/game/ingame_menu.h", "src/game/first_person_cam.h", - "src/engine/behavior_script.h" + "src/engine/behavior_script.h", + "src/audio/seqplayer.h" ] override_allowed_functions = { @@ -81,7 +82,8 @@ override_allowed_functions = { "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "fade_into_special_warp" ], "src/game/area.h": [ "area_get_warp_node" ], "src/engine/level_script.h": [ "area_create_warp_node" ], - "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", "close_dialog_box", ] + "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", "close_dialog_box", ], + "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" ] } override_disallowed_functions = { diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index aa41ed12..f0973dcd 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7523,6 +7523,42 @@ function touch_coin_score_age(fileIndex, courseIndex) -- ... end +--- @param player integer +--- @return integer +function sequence_player_get_tempo(player) + -- ... +end + +--- @param player integer +--- @return integer +function sequence_player_get_tempo_acc(player) + -- ... +end + +--- @param player integer +--- @return integer +function sequence_player_get_transposition(player) + -- ... +end + +--- @param player integer +--- @param tempo integer +function sequence_player_set_tempo(player, tempo) + -- ... +end + +--- @param player integer +--- @param tempoAcc integer +function sequence_player_set_tempo_acc(player, tempoAcc) + -- ... +end + +--- @param player integer +--- @param transposition integer +function sequence_player_set_transposition(player, transposition) + -- ... +end + --- @param index integer --- @return Animation function get_mario_vanilla_animation(index) diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index a1132b09..a78d3cdd 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -8391,6 +8391,135 @@
+--- +# functions from seqplayer.h + +
+ + +## [sequence_player_get_tempo](#sequence_player_get_tempo) + +### Lua Example +`local integerValue = sequence_player_get_tempo(player)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | + +### Returns +- `integer` + +### C Prototype +`u16 sequence_player_get_tempo(u8 player);` + +[:arrow_up_small:](#) + +
+ +## [sequence_player_get_tempo_acc](#sequence_player_get_tempo_acc) + +### Lua Example +`local integerValue = sequence_player_get_tempo_acc(player)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | + +### Returns +- `integer` + +### C Prototype +`u16 sequence_player_get_tempo_acc(u8 player);` + +[:arrow_up_small:](#) + +
+ +## [sequence_player_get_transposition](#sequence_player_get_transposition) + +### Lua Example +`local integerValue = sequence_player_get_transposition(player)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | + +### Returns +- `integer` + +### C Prototype +`u16 sequence_player_get_transposition(u8 player);` + +[:arrow_up_small:](#) + +
+ +## [sequence_player_set_tempo](#sequence_player_set_tempo) + +### Lua Example +`sequence_player_set_tempo(player, tempo)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | +| tempo | `integer` | + +### Returns +- None + +### C Prototype +`void sequence_player_set_tempo(u8 player, u16 tempo);` + +[:arrow_up_small:](#) + +
+ +## [sequence_player_set_tempo_acc](#sequence_player_set_tempo_acc) + +### Lua Example +`sequence_player_set_tempo_acc(player, tempoAcc)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | +| tempoAcc | `integer` | + +### Returns +- None + +### C Prototype +`void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc);` + +[:arrow_up_small:](#) + +
+ +## [sequence_player_set_transposition](#sequence_player_set_transposition) + +### Lua Example +`sequence_player_set_transposition(player, transposition)` + +### Parameters +| Field | Type | +| ----- | ---- | +| player | `integer` | +| transposition | `integer` | + +### Returns +- None + +### C Prototype +`void sequence_player_set_transposition(u8 player, u16 transposition);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_anim_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 197bcb92..7b12d747 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1577,6 +1577,16 @@
+- seqplayer.h + - [sequence_player_get_tempo](functions-4.md#sequence_player_get_tempo) + - [sequence_player_get_tempo_acc](functions-4.md#sequence_player_get_tempo_acc) + - [sequence_player_get_transposition](functions-4.md#sequence_player_get_transposition) + - [sequence_player_set_tempo](functions-4.md#sequence_player_set_tempo) + - [sequence_player_set_tempo_acc](functions-4.md#sequence_player_set_tempo_acc) + - [sequence_player_set_transposition](functions-4.md#sequence_player_set_transposition) + +
+ - smlua_anim_utils.h - [get_mario_vanilla_animation](functions-4.md#get_mario_vanilla_animation) - [smlua_anim_util_get_current_animation_name](functions-4.md#smlua_anim_util_get_current_animation_name) diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index fe5416e9..64d161f6 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -3039,3 +3039,26 @@ void init_sequence_players(void) { } } +void sequence_player_set_tempo(u8 player, u16 tempo) { + gSequencePlayers[player].tempo = tempo; +} + +void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc) { + gSequencePlayers[player].tempoAcc = tempoAcc; +} + +void sequence_player_set_transposition(u8 player, u16 transposition) { + gSequencePlayers[player].transposition = transposition; +} + +u16 sequence_player_get_tempo(u8 player) { + return gSequencePlayers[player].tempo; +} + +u16 sequence_player_get_tempo_acc(u8 player) { + return gSequencePlayers[player].tempoAcc; +} + +u16 sequence_player_get_transposition(u8 player) { + return gSequencePlayers[player].transposition; +} \ No newline at end of file diff --git a/src/audio/seqplayer.h b/src/audio/seqplayer.h index 99ea13ac..f7a4b60c 100644 --- a/src/audio/seqplayer.h +++ b/src/audio/seqplayer.h @@ -15,5 +15,11 @@ void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume); void process_sequences(s32 iterationsRemaining); void init_sequence_player(u32 player); void init_sequence_players(void); +void sequence_player_set_tempo(u8 player, u16 tempo); +void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc); +void sequence_player_set_transposition(u8 player, u16 transposition); +u16 sequence_player_get_tempo(u8 player); +u16 sequence_player_get_tempo_acc(u8 player); +u16 sequence_player_get_transposition(u8 player); #endif // AUDIO_SEQPLAYER_H diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 9312bfa5..058e540e 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -46,6 +46,7 @@ #include "src/game/ingame_menu.h" #include "src/game/first_person_cam.h" #include "src/engine/behavior_script.h" +#include "src/audio/seqplayer.h" //////////// @@ -28107,6 +28108,118 @@ int smlua_func_touch_coin_score_age(lua_State* L) { return 1; } + ///////////////// + // seqplayer.h // +///////////////// + +int smlua_func_sequence_player_get_tempo(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", "sequence_player_get_tempo", 1, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_get_tempo"); return 0; } + + lua_pushinteger(L, sequence_player_get_tempo(player)); + + return 1; +} + +int smlua_func_sequence_player_get_tempo_acc(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", "sequence_player_get_tempo_acc", 1, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_get_tempo_acc"); return 0; } + + lua_pushinteger(L, sequence_player_get_tempo_acc(player)); + + return 1; +} + +int smlua_func_sequence_player_get_transposition(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", "sequence_player_get_transposition", 1, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_get_transposition"); return 0; } + + lua_pushinteger(L, sequence_player_get_transposition(player)); + + return 1; +} + +int smlua_func_sequence_player_set_tempo(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sequence_player_set_tempo", 2, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_set_tempo"); return 0; } + u16 tempo = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "sequence_player_set_tempo"); return 0; } + + sequence_player_set_tempo(player, tempo); + + return 1; +} + +int smlua_func_sequence_player_set_tempo_acc(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sequence_player_set_tempo_acc", 2, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_set_tempo_acc"); return 0; } + u16 tempoAcc = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "sequence_player_set_tempo_acc"); return 0; } + + sequence_player_set_tempo_acc(player, tempoAcc); + + return 1; +} + +int smlua_func_sequence_player_set_transposition(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sequence_player_set_transposition", 2, top); + return 0; + } + + u8 player = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sequence_player_set_transposition"); return 0; } + u16 transposition = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "sequence_player_set_transposition"); return 0; } + + sequence_player_set_transposition(player, transposition); + + return 1; +} + //////////////////////// // smlua_anim_utils.h // //////////////////////// @@ -34397,6 +34510,14 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "save_file_set_star_flags", smlua_func_save_file_set_star_flags); smlua_bind_function(L, "touch_coin_score_age", smlua_func_touch_coin_score_age); + // seqplayer.h + smlua_bind_function(L, "sequence_player_get_tempo", smlua_func_sequence_player_get_tempo); + smlua_bind_function(L, "sequence_player_get_tempo_acc", smlua_func_sequence_player_get_tempo_acc); + smlua_bind_function(L, "sequence_player_get_transposition", smlua_func_sequence_player_get_transposition); + smlua_bind_function(L, "sequence_player_set_tempo", smlua_func_sequence_player_set_tempo); + smlua_bind_function(L, "sequence_player_set_tempo_acc", smlua_func_sequence_player_set_tempo_acc); + smlua_bind_function(L, "sequence_player_set_transposition", smlua_func_sequence_player_set_transposition); + // smlua_anim_utils.h smlua_bind_function(L, "get_mario_vanilla_animation", smlua_func_get_mario_vanilla_animation); smlua_bind_function(L, "smlua_anim_util_get_current_animation_name", smlua_func_smlua_anim_util_get_current_animation_name);