diff --git a/autogen/common.py b/autogen/common.py
index 09b806de9..bed5781af 100644
--- a/autogen/common.py
+++ b/autogen/common.py
@@ -1,6 +1,7 @@
import os
import re
from vec_types import *
+from exposed_lists import structs_excluded
usf_types = ['u8', 'u16', 'u32', 'u64', 's8', 's16', 's32', 's64', 'f32', 'f64']
vec_types = list(VEC_TYPES.keys())
@@ -21,37 +22,6 @@ type_mappings = {
'size_t': 'u64', # this is assumed
}
-exclude_structs = [
- 'AnimationTable',
- 'BullyCollisionData',
- 'CameraFOVStatus',
- 'CameraStoredInfo',
- 'CameraTrigger',
- 'Cutscene',
- 'CutsceneSplinePoint',
- 'CutsceneVariable',
- 'FloorGeometry',
- 'GraphNode_802A45E4',
- 'HandheldShakePoint',
- 'LinearTransitionPoint',
- 'MarioAnimDmaRelatedThing',
- 'ModAudioSampleCopies',
- 'ModFile',
- 'ModeTransitionInfo',
- 'OffsetSizePair',
- 'PaintingMeshVertex',
- 'ParallelTrackingPoint',
- 'PlayerGeometry',
- 'SPTask',
- 'SoundState',
- 'TransitionInfo',
- 'UnusedArea28',
- 'VblankHandler',
- 'Vtx_Interp',
- 'WarpTransition',
- 'WarpTransitionData',
-]
-
override_types = { "Gfx", "Vtx" }
def extract_integer_datatype(c_type):
@@ -212,7 +182,7 @@ def translate_type_to_lot(ptype, allowArrays=True):
struct_id = ptype.split(' ')[1]
- if struct_id in exclude_structs:
+ if struct_id in structs_excluded:
return 'LOT_???'
return 'LOT_' + struct_id.upper()
@@ -327,4 +297,32 @@ def translate_to_def(ptype):
return 'function'
if ptype.startswith('`Array` <'):
ptype = ptype.replace('`Array` <', '') + "[]"
- return ptype.replace('enum ', '').replace('const ', '').replace(' ', '').replace('`', '').replace('<', '_').replace('>', '')
\ No newline at end of file
+ return ptype.replace('enum ', '').replace('const ', '').replace(' ', '').replace('`', '').replace('<', '_').replace('>', '')
+
+allowed_identifier_cache = {}
+def allowed_identifier(whitelists, blacklists, key, ident):
+ global allowed_identifier_cache
+
+ if whitelists is None: whitelists = {}
+ if blacklists is None: blacklists = {}
+
+ cache_key = "_".join([whitelists.get("__name__", ""), blacklists.get("__name__", ""), key])
+ if cache_key in allowed_identifier_cache:
+ whitelist_regex, blacklist_regex = allowed_identifier_cache[cache_key]
+ else:
+ blacklist = blacklists.get("*", []) + blacklists.get(key, [])
+ blacklist_regex = blacklist and re.compile("|".join(blacklist)) or None
+ whitelist = whitelists.get(key, [])
+ whitelist_regex = whitelist and re.compile("|".join(whitelist)) or None
+ allowed_identifier_cache[cache_key] = (whitelist_regex, blacklist_regex)
+
+ if blacklist_regex is not None:
+ if blacklist_regex.search(ident) is not None:
+ return False
+
+ if whitelist_regex is not None:
+ if whitelist_regex.search(ident) is not None:
+ return True
+ return False
+
+ return True
diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py
index b8ca00e71..a57a44bc2 100644
--- a/autogen/convert_constants.py
+++ b/autogen/convert_constants.py
@@ -1,144 +1,25 @@
+import sys
from common import *
from extract_constants import *
from vec_types import *
-import sys
+from exposed_lists import \
+ constants_files, \
+ constants_whitelist, \
+ constants_blacklist, \
+ constants_hidden
-in_filename = 'autogen/lua_constants/built-in.lua'
+verbose = len(sys.argv) > 1 and (sys.argv[1] == "-v" or sys.argv[1] == "--verbose")
+
+in_filenames = ['autogen/lua_constants/built-in.lua', 'autogen/lua_constants/math.lua']
deprecated_filename = 'autogen/lua_constants/deprecated.lua'
out_filename = 'src/pc/lua/smlua_constants_autogen.c'
out_filename_docs = 'docs/lua/constants.md'
out_filename_defs = 'autogen/lua_definitions/constants.lua'
-in_files = [
- "include/types.h",
- "include/sm64.h",
- "src/pc/lua/smlua_hooks.h",
- "src/game/area.h",
- "src/game/camera.h",
- "include/mario_animation_ids.h",
- "include/sounds.h",
- "src/game/characters.h",
- "src/pc/network/network.h",
- "src/pc/network/network_player.h",
- "include/PR/os_cont.h",
- "src/game/interaction.c",
- "src/game/interaction.h",
- "src/pc/djui/djui_hud_utils.h",
- "src/pc/controller/controller_mouse.h",
- "include/behavior_table.h",
- "src/pc/lua/utils/smlua_model_utils.h",
- "src/pc/lua/utils/smlua_misc_utils.h",
- "include/object_constants.h",
- "include/mario_geo_switch_case_ids.h",
- "src/game/object_list_processor.h",
- "src/engine/graph_node.h",
- "levels/level_defines.h",
- "src/game/obj_behaviors.c",
- "src/game/save_file.h",
- "src/game/obj_behaviors_2.h",
- "include/dialog_ids.h",
- "include/seq_ids.h",
- "include/surface_terrains.h",
- "src/game/level_update.h",
- "src/pc/network/version.h",
- "include/geo_commands.h",
- "include/level_commands.h",
- "src/audio/external.h",
- "src/game/envfx_snow.h",
- "src/pc/mods/mod_storage.h",
- "src/pc/mods/mod_fs.h",
- "src/game/first_person_cam.h",
- "src/pc/djui/djui_console.h",
- "src/game/player_palette.h",
- "src/pc/network/lag_compensation.h",
- "src/pc/djui/djui_panel_menu.h",
- "src/engine/lighting_engine.h",
- "include/PR/gbi.h",
- "include/PR/gbi_extension.h",
- "src/pc/gfx/gfx_pc.h",
- "src/engine/surface_load.h",
- "src/pc/lua/utils/smlua_audio_utils.h",
- "src/pc/voice_chat.h",
-]
-
-exclude_constants = {
- "*": [ "^MAXCONTROLLERS$", "^AREA_[^T].*", "^AREA_T[HTO]", "^CONT_ERR.*", "^READ_MASK$", "^SIGN_RANGE$", ],
- "include/sm64.h": [ "END_DEMO" ],
- "include/types.h": [ "GRAPH_NODE_GUARD" ],
- "src/audio/external.h": [ "DS_DIFF" ],
- "src/game/save_file.h": [ "EEPROM_SIZE" ],
- "src/game/obj_behaviors.c": [ "^o$" ],
- "src/pc/djui/djui_console.h": [ "CONSOLE_MAX_TMP_BUFFER" ],
- "src/pc/lua/smlua_hooks.h": [ "^LUA_BEHAVIOR_.*", "MAX_HOOKED_.*", "^HOOK_RETURN_.*", "^ACTION_HOOK_.*", "^MOD_MENU_ELEMENT_.*" ],
- "src/pc/djui/djui_panel_menu.h": [ "RAINBOW_TEXT_LEN" ],
- "src/pc/mods/mod_fs.h": [ "INT_TYPE_MAX", "FLOAT_TYPE_MAX", "FILE_SEEK_MAX" ],
- "src/engine/surface_load.h": [ "NUM_CELLS" ],
- "src/pc/network/version.h": [ "VERSION_OFFSET" ],
-}
-
-include_constants = {
- "include/geo_commands.h": [ "BACKGROUND" ],
- "include/level_commands.h": [ "WARP_CHECKPOINT", "WARP_NO_CHECKPOINT" ],
- "src/audio/external.h": [ "SEQ_PLAYER", "DS_" ],
- "src/pc/lua/utils/smlua_audio_utils.h": ["MOD_AUDIO_CHANNEL"],
- "src/pc/mods/mod_storage.h": [ "MAX_KEYS", "MAX_KEY_VALUE_LENGTH" ],
- "include/PR/gbi.h": [
- "^G_NOOP$",
- "^G_SETOTHERMODE_H$",
- "^G_SETOTHERMODE_L$",
- "^G_ENDDL$",
- "^G_DL$",
- "^G_MOVEMEM$",
- "^G_MOVEWORD$",
- "^G_MTX$",
- "^G_GEOMETRYMODE$",
- "^G_POPMTX$",
- "^G_TEXTURE$",
- "^G_COPYMEM$",
- "^G_VTX$",
- "^G_TRI1$",
- "^G_TRI2$",
- "^G_SETCIMG$",
- "^G_SETZIMG$",
- "^G_SETTIMG$",
- "^G_SETCOMBINE$",
- "^G_SETENVCOLOR$",
- "^G_SETPRIMCOLOR$",
- "^G_SETBLENDCOLOR$",
- "^G_SETFOGCOLOR$",
- "^G_SETFILLCOLOR$",
- "^G_FILLRECT$",
- "^G_SETTILE$",
- "^G_LOADTILE$",
- "^G_LOADBLOCK$",
- "^G_SETTILESIZE$",
- "^G_LOADTLUT$",
- "^G_SETSCISSOR$",
- "^G_TEXRECTFLIP$",
- "^G_TEXRECT$",
- ],
- "include/PR/gbi_extension.h": [
- "^G_VTX_EXT$",
- "^G_PPARTTOCOLOR$",
- "^G_SETENVRGB$",
- "^G_STATE_EXT$",
- ],
-}
-
-# Constants that exist in the source code but should not appear
-# in the documentation or VSCode autocomplete
-hide_constants = {
- "interaction.h": [ "INTERACT_UNKNOWN_08" ],
-}
-
-pretend_find = [
- "SOUND_ARG_LOAD",
-]
############################################################################
seen_constants = []
totalConstants = 0
-verbose = len(sys.argv) > 1 and (sys.argv[1] == "-v" or sys.argv[1] == "--verbose")
overrideConstant = {
'VERSION_REGION': '"US"',
}
@@ -150,6 +31,9 @@ defined_values = {
'F3DEX_GBI_2': True,
'DEVELOPMENT': False,
}
+pretend_find = [
+ "SOUND_ARG_LOAD",
+]
############################################################################
@@ -179,26 +63,19 @@ def saw_constant(identifier, inIfBlock):
seen_constants.append(identifier)
return False
-def allowed_identifier(filename, ident):
- exclude_list = exclude_constants['*']
+def get_constant(filename, line, inIfBlock, field, index, set_to, set_to_val):
+ if set_to is not None:
+ if allowed_identifier(constants_whitelist, constants_blacklist, filename, field):
+ if set_to_val is not None:
+ return [field, str(set_to_val + index)]
+ return [field, '((%s) + %d)' % (set_to, index)]
- if filename in exclude_constants:
- exclude_list.extend(exclude_constants[filename])
+ elif allowed_identifier(constants_whitelist, constants_blacklist, filename, field):
+ if saw_constant(field, inIfBlock):
+ print('>>> ' + line)
+ return [field, str(index)]
- for exclude in exclude_list:
- if re.search(exclude, ident) != None:
- return False
-
- if filename in include_constants:
- for include in include_constants[filename]:
- if re.search(include, ident) != None:
- return True
- return False
-
- if ident in overrideConstant:
- return False
-
- return True
+ return None
def process_enum(filename, line, inIfBlock):
_, ident, val = line.split(' ', 2)
@@ -233,24 +110,15 @@ def process_enum(filename, line, inIfBlock):
except Exception:
set_to_val = None
- constants.append([ident, val])
+ if allowed_identifier(constants_whitelist, constants_blacklist, filename, field):
+ constants.append([ident, val])
set_to = ident
index = 1
continue
- if set_to is not None:
- if set_to_val is not None:
- constants.append([field, str(set_to_val + index)])
- else:
- constants.append([field, '((%s) + %d)' % (set_to, index)])
- index += 1
- continue
-
- if allowed_identifier(filename, field):
- constants.append([field, str(index)])
-
- if saw_constant(field, inIfBlock):
- print('>>> ' + line)
+ constant = get_constant(filename, line, inIfBlock, field, index, set_to, set_to_val)
+ if constant is not None:
+ constants.append(constant)
index += 1
@@ -277,7 +145,7 @@ def process_define(filename, line, inIfBlock):
print('UNRECOGNIZED DEFINE: ' + line)
return None
- if not allowed_identifier(filename, ident):
+ if not allowed_identifier(constants_whitelist, constants_blacklist, filename, ident):
return None
if saw_constant(ident, inIfBlock):
@@ -348,7 +216,7 @@ def process_file(filename):
def process_files():
seen_constants = []
processed_files = []
- files = sorted(in_files, key=lambda d: d.split('/')[-1])
+ files = sorted(constants_files, key=lambda d: d.split('/')[-1])
for f in files:
processed_files.append(process_file(f))
for key, item in overrideConstant.items():
@@ -411,7 +279,7 @@ def build_to_c(built_files):
txt = ''
# Built-in and deprecated
- for filename in [in_filename, deprecated_filename]:
+ for filename in [*in_filenames, deprecated_filename]:
with open(get_path(filename), 'r') as f:
for line in f.readlines():
txt += line.strip() + '\n'
@@ -439,13 +307,6 @@ def build_to_c(built_files):
############################################################################
-def doc_should_document(fname, identifier):
- if fname in hide_constants:
- for pattern in hide_constants[fname]:
- if re.search(pattern, identifier) != None:
- return False
- return True
-
def doc_constant_index(processed_files):
s = '# Supported Constants\n'
for processed_file in processed_files:
@@ -478,7 +339,7 @@ def doc_constant(fname, processed_constant):
for c in [processed_constant]:
if c[0].startswith('#'):
continue
- if not doc_should_document(fname, c[0]):
+ if not allowed_identifier(None, constants_hidden, fname, c[0]):
continue
s += '- %s\n' % (c[0])
@@ -540,7 +401,7 @@ def def_constant(fname, processed_constant, skip_constant):
continue
if skip_constant:
continue
- if not doc_should_document(fname, c[0]):
+ if not allowed_identifier(None, constants_hidden, fname, c[0]):
continue
if '"' in c[1]:
s += '\n--- @type string\n'
@@ -555,9 +416,10 @@ def def_constant(fname, processed_constant, skip_constant):
def build_to_def(processed_files):
s = '-- AUTOGENERATED FOR CODE EDITORS --\n\n'
- with open(get_path(in_filename), 'r') as f:
- s += f.read()
- s += '\n'
+ for filename in in_filenames:
+ with open(get_path(filename), 'r') as f:
+ s += f.read()
+ s += '\n'
s += '\n\n-------------------------\n'
s += '-- vec types constants --\n'
diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py
index 6f6a7c9e7..8d520c0b0 100644
--- a/autogen/convert_functions.py
+++ b/autogen/convert_functions.py
@@ -3,175 +3,24 @@ import sys
from extract_functions import *
from common import *
from vec_types import *
+from exposed_lists import \
+ functions_files, \
+ functions_whitelist, \
+ functions_blacklist, \
+ functions_hidden, \
+ functions_version_excludes, \
+ functions_params_types
verbose = len(sys.argv) > 1 and (sys.argv[1] == "-v" or sys.argv[1] == "--verbose")
rejects = ""
integer_types = ["u8", "u16", "u32", "u64", "s8", "s16", "s32", "s64", "int", "lua_Integer"]
number_types = ["f32", "float", "f64", "double", "lua_Number"]
+parameter_keywords = ["VEC_OUT", "RET", "INOUT", "OPTIONAL"]
out_filename = 'src/pc/lua/smlua_functions_autogen.c'
out_filename_docs = 'docs/lua/functions%s.md'
out_filename_defs = 'autogen/lua_definitions/functions.lua'
-in_files = [
- "src/audio/external.h",
- "src/engine/math_util.h",
- "src/engine/math_util.inl",
- "src/engine/math_util_vec3f.inl",
- "src/engine/math_util_vec3i.inl",
- "src/engine/math_util_vec3s.inl",
- "src/engine/math_util_mat4.inl",
- "src/engine/surface_collision.h",
- "src/engine/surface_load.h",
- "src/game/camera.h",
- "src/game/characters.h",
- "src/game/mario_actions_airborne.c",
- "src/game/mario_actions_automatic.c",
- "src/game/mario_actions_cutscene.c",
- "src/game/mario_actions_moving.c",
- "src/game/mario_actions_object.c",
- "src/game/mario_actions_stationary.c",
- "src/game/mario_actions_submerged.c",
- "src/game/mario_step.h",
- "src/game/mario.h",
- "src/game/rumble_init.h",
- "src/pc/djui/djui_popup.h",
- "src/pc/network/network_utils.h",
- "src/pc/djui/djui_console.h",
- "src/pc/djui/djui_chat_message.h",
- "src/pc/djui/djui_language.h",
- "src/game/interaction.h",
- "src/game/level_info.h",
- "src/game/save_file.h",
- "src/game/sound_init.h",
- "src/pc/djui/djui_hud_utils.h",
- "src/pc/djui/djui_panel_menu.h",
- "src/pc/network/network_player.h",
- "src/pc/network/lag_compensation.h",
- "include/behavior_table.h",
- "src/pc/lua/utils/smlua_obj_utils.h",
- "src/pc/lua/utils/smlua_misc_utils.h",
- "src/pc/lua/utils/smlua_camera_utils.h",
- "src/pc/lua/utils/smlua_gfx_utils.h",
- "src/pc/lua/utils/smlua_collision_utils.h",
- "src/pc/lua/utils/smlua_model_utils.h",
- "src/pc/lua/utils/smlua_text_utils.h",
- "src/pc/lua/utils/smlua_audio_utils.h",
- "src/pc/lua/utils/smlua_level_utils.h",
- "src/pc/lua/utils/smlua_anim_utils.h",
- "src/pc/lua/utils/smlua_deprecated.h",
- "src/game/object_helpers.c",
- "src/game/obj_behaviors.c",
- "src/game/obj_behaviors_2.c",
- "src/game/platform_displacement.h",
- "src/game/spawn_sound.h",
- "src/game/object_list_processor.h",
- "src/game/behavior_actions.h",
- "src/game/mario_misc.h",
- "src/pc/mods/mod_storage.h",
- "src/pc/mods/mod_fs.h",
- "src/pc/utils/misc.h",
- "src/game/level_update.h",
- "src/game/area.h",
- "src/engine/level_script.h",
- "src/game/ingame_menu.h",
- "src/game/first_person_cam.h",
- "src/engine/behavior_script.h",
- "src/audio/seqplayer.h",
- "src/engine/lighting_engine.h",
- "src/pc/network/sync_object.h",
- "src/audio/load.h",
- "src/pc/djui/djui_gfx.h",
- "src/pc/voice_chat.h"
-]
-
-override_allowed_functions = {
- "src/audio/external.h": [ " play_", "fade", "current_background", "stop_", "sound_banks", "drop_queued_background_music", "set_sound_moving_speed", "background_music_default_volume", "get_sound_pan", "sound_get_level_intensity", "set_audio_muted" ],
- "src/game/rumble_init.h": [ "queue_rumble_", "reset_rumble_timers" ],
- "src/pc/djui/djui_popup.h": [ "create" ],
- "src/pc/djui/djui_language.h": [ "djui_language_get" ],
- "src/pc/djui/djui_panel_menu.h": [ "djui_menu_get_rainbow_string_color" ],
- "src/game/save_file.h": [ "get_level_", "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_reload", "save_file_erase_current_backup_save", "save_file_set_star_flags", "save_file_is_cannon_unlocked", "save_file_set_cannon_unlocked", "touch_coin_score_age", "save_file_set_course_coin_score", "save_file_do_save", "save_file_remove_star_flags", "save_file_erase" ],
- "src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ],
- "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
- "src/game/platform_displacement.h": [ "apply_platform_displacement" ],
- "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*" ],
- "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_warp", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "pressed_pause", "fade_into_special_warp", "get_instant_warp" ],
- "src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ],
- "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", "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" ],
- "src/pc/djui/djui_gfx.h": [ "djui_gfx_get_scale" ],
-}
-
-override_disallowed_functions = {
- "src/audio/external.h": [ " func_" ],
- "src/engine/surface_load.h": [ "load_area_terrain", "alloc_surface_pools", "clear_dynamic_surfaces", "get_area_terrain_size", "alloc_surface", "add_surface", "remove_surface_from_partition", "delete_surface", "swap_and_pop_surface_pool", "add_surface_without_hook" ],
- "src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
- "src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
- "src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ],
- "src/game/mario_actions_cutscene.c": [ "^[us]32 act_.*", " geo_", "spawn_obj", "print_displaying_credits_entry" ],
- "src/game/mario_actions_moving.c": [ "^[us]32 act_.*" ],
- "src/game/mario_actions_object.c": [ "^[us]32 act_.*" ],
- "src/game/mario_actions_stationary.c": [ "^[us]32 act_.*", "mario_exit_palette_editor" ],
- "src/game/mario_actions_submerged.c": [ "^[us]32 act_.*" ],
- "src/game/mario_step.h": [ " stub_mario_step", "transfer_bully_speed" ],
- "src/game/mario.h": [ " init_mario" ],
- "src/pc/djui/djui_console.h": [ " djui_console_create", "djui_console_message_create", "djui_console_message_dequeue" ],
- "src/pc/djui/djui_chat_message.h": [ "create_from" ],
- "src/pc/djui/djui_hud_utils.h": [ "djui_hud_clear_interp_data", "djui_hud_print_text", "djui_hud_print_text_interpolated" ],
- "src/game/interaction.h": [ "process_interaction", "_handle_" ],
- "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ],
- "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ],
- "src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup", "network_player_name_valid" ],
- "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "geo_", "abs[fi]", "^bit_shift", "_debug$", "^stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table" ],
- "src/game/obj_behaviors.c": [ "debug_", "geo_", "turn_obj_away_from_surface"],
- "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ],
- "src/game/spawn_sound.h": [ "exec_anim_sound_state" ],
- "src/game/level_info.h": [ "_name_table", "convert_string_" ],
- "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" ],
- "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" ],
- "src/pc/lua/utils/smlua_gfx_utils.h": [ "gfx_allocate_internal", "vtx_allocate_internal", "gfx_get_length_no_sentinel" ],
- "src/pc/network/lag_compensation.h": [ "lag_compensation_clear" ],
- "src/game/first_person_cam.h": [ "first_person_update" ],
- "src/pc/lua/utils/smlua_collision_utils.h": [ "collision_find_surface_on_ray" ],
- "src/engine/behavior_script.h": [ "stub_behavior_script_2", "cur_obj_update" ],
- "src/pc/mods/mod_storage.h": [ "mod_storage_shutdown" ],
- "src/pc/mods/mod_fs.h": [ "mod_fs_read_file_from_uri", "mod_fs_shutdown" ],
- "src/pc/utils/misc.h": [ "str_.*", "file_get_line", "delta_interpolate_(normal|rgba|mtx)", "detect_and_skip_mtx_interpolation", "precise_delay_f64", "can_update_game", "update_game", "open_url", "open_folder" ],
- "src/engine/lighting_engine.h": [ "le_calculate_vertex_lighting", "le_clear", "le_shutdown" ],
- "src/pc/voice_chat.h": [ "voicechat_init", "voicechat_shutdown", "voicechat_init_player", "voicechat_encode_audio", "voicechat_decode_audio", "voicechat_mix", "voicechat_push_pending_global_mute", "voicechat_resolve_pending_global_mutes" ],
-}
-
-override_hide_functions = {
- "smlua_deprecated.h": [ ".*" ],
- "network_player.h": [ "network_player_get_palette_color_channel", "network_player_get_override_palette_color_channel" ],
-}
-
-override_function_version_excludes = {
- "bhv_play_music_track_when_touched_loop": "VERSION_JP",
- "play_knockback_sound": "VERSION_JP",
- "cur_obj_spawn_star_at_y_offset": "VERSION_JP",
-}
-
-lua_function_params = {
- "src/pc/lua/utils/smlua_obj_utils.h::spawn_object_sync::objSetupFunction": [ "struct Object*" ],
-}
-
-parameter_keywords = [
- "VEC_OUT",
- "RET",
- "INOUT",
- "OPTIONAL"
-]
-
###########################################################
template = """/* THIS FILE IS AUTOGENERATED */
@@ -979,8 +828,8 @@ def build_function(function, do_extern):
s = ''
fid = function['identifier']
- if fid in override_function_version_excludes:
- s += '#ifndef ' + override_function_version_excludes[fid] + '\n'
+ if fid in functions_version_excludes:
+ s += '#ifndef ' + functions_version_excludes[fid] + '\n'
fparams, freturns = split_function_parameters_and_returns(function)
@@ -1075,7 +924,7 @@ def build_function(function, do_extern):
num_returns = max(1, push_value + len(freturns))
s += ' return %d;\n}\n' % num_returns
- if fid in override_function_version_excludes:
+ if fid in functions_version_excludes:
s += '#endif\n'
function['implemented'] = 'UNIMPLEMENTED' not in s
@@ -1109,8 +958,8 @@ def build_bind(function):
s = ' ' + s
# There is no point in adding the ifndef statement if the function is commented out here anyways.
# So we only do it on implemented functions.
- if fid in override_function_version_excludes:
- s = '#ifndef ' + override_function_version_excludes[fid] + '\n' + s
+ if fid in functions_version_excludes:
+ s = '#ifndef ' + functions_version_excludes[fid] + '\n' + s
s += '\n#endif'
else:
s = ' //' + s + ' <--- UNIMPLEMENTED'
@@ -1127,7 +976,7 @@ def build_binds(processed_files):
def build_includes():
s = ''
- for f in in_files:
+ for f in functions_files:
if not f.endswith('.h'):
continue
s += '#include "%s"\n' % f
@@ -1136,19 +985,8 @@ def build_includes():
############################################################################
def process_function(fname, line, description):
- if fname in override_allowed_functions:
- found_match = False
- for pattern in override_allowed_functions[fname]:
- if re.search(pattern, line) != None:
- found_match = True
- break
- if not found_match:
- return None
-
- if fname in override_disallowed_functions:
- for pattern in override_disallowed_functions[fname]:
- if re.search(pattern, line) != None:
- return None
+ if not allowed_identifier(functions_whitelist, functions_blacklist, fname, line):
+ return None
function = {}
@@ -1204,8 +1042,8 @@ def process_function(fname, line, description):
# remember lua function params
lf_key = fname + '::' + function['identifier'] + '::' + param['identifier']
- if param['type'] == 'LuaFunction' and lf_key in lua_function_params:
- param['lua_function_params'] = lua_function_params[lf_key]
+ if param['type'] == 'LuaFunction' and lf_key in functions_params_types:
+ param['lua_function_params'] = functions_params_types[lf_key]
function['params'].append(param)
param_index += 1
@@ -1239,7 +1077,7 @@ def process_file(fname):
def process_files():
processed_files = []
- files = sorted(in_files, key=lambda d: d.split('/')[-1])
+ files = sorted(functions_files, key=lambda d: d.split('/')[-1])
for f in files:
processed_files.append(process_file(f))
return processed_files
@@ -1293,16 +1131,6 @@ def output_fuzz_file():
############################################################################
-def doc_should_document(fname, identifier):
- if fname in override_hide_functions:
- found_match = False
- for pattern in override_hide_functions[fname]:
- if re.search(pattern, identifier) != None:
- found_match = True
- break
- return not found_match
- return True
-
def doc_page_link(page_num):
if page_num == 1:
return 'functions.md'
@@ -1319,7 +1147,7 @@ def doc_function_index(processed_files):
for function in processed_file['functions']:
if not function['implemented']:
continue
- if not doc_should_document(processed_file['filename'], function['identifier']):
+ if not allowed_identifier(None, functions_hidden, processed_file['filename'], function['identifier']):
continue
s += ' - [%s](%s#%s)\n' % (function['identifier'], doc_page_link(page_num), function['identifier'])
@@ -1356,7 +1184,7 @@ def doc_function(fname, function):
if len(sys.argv) >= 2 and sys.argv[1] == 'fuzz':
output_fuzz_function(fname, function)
- if not doc_should_document(fname, function['identifier']):
+ if not allowed_identifier(None, functions_hidden, fname, function['identifier']):
return ''
fid = function['identifier']
@@ -1503,7 +1331,7 @@ def def_function(fname, function):
return ''
fid = function['identifier']
- if not doc_should_document(fname, fid):
+ if not allowed_identifier(None, functions_hidden, fname, fid):
return ''
rtype, _ = translate_type_to_lua(function['type'])
diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py
index 66e0a684c..b8e0b38dd 100644
--- a/autogen/convert_structs.py
+++ b/autogen/convert_structs.py
@@ -1,43 +1,21 @@
-import os
import re
import sys
from extract_structs import *
from extract_object_fields import *
from common import *
from vec_types import *
-
-in_files = [
- "include/types.h",
- "src/game/area.h",
- "src/game/camera.h",
- "src/game/characters.h",
- "src/engine/surface_collision.h",
- "src/pc/network/network_player.h",
- "src/pc/djui/djui_hud_utils.h",
- "src/pc/djui/djui_theme.h",
- "src/game/object_helpers.h",
- "src/game/mario_step.h",
- "src/game/ingame_menu.h",
- "src/pc/lua/utils/smlua_anim_utils.h",
- "src/pc/lua/utils/smlua_misc_utils.h",
- "src/pc/lua/utils/smlua_camera_utils.h",
- "src/pc/lua/utils/smlua_collision_utils.h",
- "src/pc/lua/utils/smlua_level_utils.h",
- "src/game/spawn_sound.h",
- "src/pc/network/network.h",
- "src/game/hardcoded.h",
- "src/pc/mods/mod.h",
- "src/pc/mods/mod_fs.h",
- "src/pc/lua/utils/smlua_audio_utils.h",
- "src/game/paintings.h",
- "src/pc/djui/djui_types.h",
- "src/game/level_update.h",
- "src/game/first_person_cam.h",
- "src/game/player_palette.h",
- "src/engine/graph_node.h",
- "include/PR/gbi.h",
- "src/pc/voice_chat.h",
-]
+from exposed_lists import \
+ structs_files, \
+ structs_whitelist, \
+ structs_blacklist, \
+ structs_excluded, \
+ structs_fields_whitelist, \
+ structs_fields_blacklist, \
+ structs_fields_hidden, \
+ structs_fields_version_excludes, \
+ structs_fields_types, \
+ structs_fields_mutable, \
+ structs_fields_immutable
out_filename_c = 'src/pc/lua/smlua_cobject_autogen.c'
out_filename_h = 'src/pc/lua/smlua_cobject_autogen.h'
@@ -74,108 +52,7 @@ struct LuaObjectField* smlua_get_object_field_autogen(u16 lot, const char* key);
#endif
"""
-override_field_types = {
- "Surface": { "normal": "Vec3f" },
- "Object": { "oAnimations": "ObjectAnimPointer*" },
-}
-
-override_field_mutable = {
- "NetworkPlayer": [
- "overrideModelIndex",
- "overridePalette",
- "overridePaletteIndex",
- ],
-}
-
-override_field_invisible = {
- "Mod": [ "files", "showedScriptWarning", "customBehaviorIndex", "customObjectFields" ],
- "Camera": [ "paletteEditorCapState", "filler31", "filler3C", "unusedVec1" ],
- "LakituState": [ "filler30", "filler3E", "filler72", "unusedVec1", "unusedVec2" ],
- "NetworkPlayer": [ "gag", "moderator", "discordId", "rxPacketHash", "rxSeqIds" ],
- "GraphNode": [ "_guard1", "_guard2", "padding" ],
- "GraphNodeRoot": ["unk15", "views"],
- "GraphNodeMasterList": [ "listHeads", "listTails" ],
- "GraphNodeCullingRadius": [ "pad1E" ],
- "GraphNodeTranslation": [ "pad1E" ],
- "GraphNodeBackground": [ "unused" ],
- "GraphNodePerspective": [ "unused" ],
- "GraphNodeSwitchCase": [ "unused" ],
- "GraphNodeObject": [ "unk4C" ],
- "FnGraphNode": [ "luaTokenIndex" ],
- "Object": [ "firstSurface", "customFields", "bhvStack", "bhvStackIndex" ],
- "SpawnInfo": [ "unk18" ],
- "Animation": [ "unusedBoneCount" ],
- "ModAudio": [ "alive", "sound", "decoder", "buffer", "bufferSize", "sampleCopiesTail", "volChannel" ],
- "Painting": [ "normalDisplayList", "textureMaps", "rippleDisplayList", "ripples" ],
- "DialogEntry": [ "str" ],
- "ModFsFile": [ "data", "capacity" ],
- "ModFs": [ "files" ],
- "VoicePlayer": [ "internal" ],
-}
-
-override_field_deprecated = {
- "NetworkPlayer": [ "paletteIndex", "overridePaletteIndex", "overridePaletteIndexLp" ],
- "ModAudio": [ "file", "relativePath" ], # compatibility band-aid
-}
-
-override_field_immutable = {
- "MarioState": [ "playerIndex", "controller", "marioObj", "marioBodyState", "statusForCamera", "area", "dialogId" ],
- "MarioAnimation": [ "animDmaTable" ],
- "ObjectNode": [ "next", "prev" ],
- "Character": [ "*" ],
- "NetworkPlayer": [ "*" ],
- "TextureInfo": [ "*" ],
- "Object": ["oSyncID", "coopFlags", "oChainChompSegments", "oWigglerSegments", "oHauntedChairUnk100", "oTTCTreadmillBigSurface", "oTTCTreadmillSmallSurface", "bhvStackIndex", "respawnInfoType", "numSurfaces", "bhvStack" ],
- "Surface": [ "poolType", "socId" ],
- "GlobalObjectAnimations": [ "*"],
- "SpawnParticlesInfo": [ "model" ],
- "WaterDropletParams": [ "model" ],
- "MarioBodyState": [ "updateTorsoTime", "updateHeadPosTime", "animPartsPos", "animPartsRot", "currAnimPart" ],
- "Area": [ "localAreaTimer", "nextSyncID", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ],
- "Mod": [ "*" ],
- "ModFile": [ "*" ],
- "Painting": [ "id", "imageCount", "textureType", "textureWidth", "textureHeight" ],
- "SpawnInfo": [ "syncID", "next", "unk18" ],
- "CustomLevelInfo": [ "next" ],
- "GraphNode": [ "children", "next", "parent", "prev", "type" ],
- "GraphNodeBackground": [ "prevCameraTimestamp", "unused" ],
- "GraphNodeCamera": [ "matrixPtrPrev", "prevTimestamp" ],
- "GraphNodeHeldObject": [ "prevShadowPosTimestamp" ],
- "GraphNodeObject": [ "angle", "animInfo", "cameraToObject", "node", "pos", "prevAngle", "prevPos", "prevScale", "prevScaleTimestamp", "prevShadowPos", "prevShadowPosTimestamp", "prevThrowMatrix", "prevThrowMatrixTimestamp", "prevTimestamp", "scale", "shadowPos", "sharedChild", "skipInterpolationTimestamp", "throwMatrixPrev", "unk4C", ],
- "GraphNodeObjectParent": [ "sharedChild" ],
- "GraphNodePerspective": [ "unused" ],
- "GraphNodeSwitchCase": [ "fnNode", "unused" ],
- "GraphNodeRoot": ["node", "areaIndex", "numViews"],
- "ObjectWarpNode": [ "next" ],
- "Animation": [ "*" ],
- "AnimationTable": [ "*" ],
- "Controller": [ "controllerData", "statusData" ],
- "FirstPersonCamera": [ "enabled" ],
- "ModAudio": [ "isStream", "loaded" ],
- "Gfx": [ "w0", "w1" ], # to protect from invalid type conversions
- "DialogEntry": [ "unused", "linesPerBox", "leftOffset", "width", "str", "text", "replaced"],
- "ModFsFile": [ "*" ],
- "ModFs": [ "*" ],
- "StaticObjectCollision": [ "*" ],
- "VoicePlayer": [ "talking", "error", "clientMutedState", "playerMutedState" ],
-}
-
-override_field_version_excludes = {
- "oCameraLakituMusicPlayed": "VERSION_JP",
- "oCoinUnk1B0": "VERSION_JP",
-}
-
-override_allowed_structs = {
- "src/pc/network/network.h": [ "ServerSettings", "NametagsSettings" ],
- "src/pc/djui/djui_types.h": [ "DjuiColor" ],
- "src/game/level_update.h": [ "HudDisplay" ],
- "src/game/player_palette.h": [ "PlayerPalette" ],
- "src/game/ingame_menu.h" : [ "DialogEntry" ],
- "include/PR/gbi.h": [ "Gfx", "Vtx" ],
- "src/pc/voice_chat.h": [ "VoicePlayer" ],
-}
-
-sLuaManuallyDefinedStructs = [{
+lua_manually_defined_structs = [{
'path': 'n/a',
'structs': [
*['struct %s { %s }' % (
@@ -379,10 +256,8 @@ def parse_structs(extracted, sortFields = False):
for e in extracted:
for struct in e['structs']:
parsed = parse_struct(struct, sortFields)
- if e['path'] in override_allowed_structs:
- if parsed['identifier'] not in override_allowed_structs[e['path']]:
- continue
- structs.append(parsed)
+ if allowed_identifier(structs_whitelist, structs_blacklist, e['path'], parsed['identifier']):
+ structs.append(parsed)
return structs
############################################################################
@@ -419,9 +294,9 @@ def output_fuzz_struct(struct):
fid, ftype, fimmutable, lvt, lot, size = get_struct_field_info(struct, field)
if fimmutable == 'true':
continue
- if sid in override_field_invisible:
- if fid in override_field_invisible[sid]:
- continue
+
+ if not allowed_identifier(structs_fields_whitelist, structs_fields_blacklist, sid, fid):
+ continue
if '(' in fid or '[' in fid or ']' in fid:
continue
@@ -510,8 +385,8 @@ def get_struct_field_info(struct, field):
ftype = field['type']
size = 1
- if sid in override_field_types and fid in override_field_types[sid]:
- ftype = override_field_types[sid][fid]
+ if sid in structs_fields_types and fid in structs_fields_types[sid]:
+ ftype = structs_fields_types[sid][fid]
lvt = translate_type_to_lvt(ftype, allowArrays=True)
lot = translate_type_to_lot(ftype, allowArrays=True)
@@ -522,12 +397,12 @@ def get_struct_field_info(struct, field):
if field.get('get') and field['set'] == 'NULL':
fimmutable = 'true'
- if sid in override_field_immutable:
- if fid in override_field_immutable[sid] or '*' in override_field_immutable[sid]:
+ if sid in structs_fields_immutable:
+ if fid in structs_fields_immutable[sid] or '*' in structs_fields_immutable[sid]:
fimmutable = 'true'
- if sid in override_field_mutable:
- if fid in override_field_mutable[sid] or '*' in override_field_mutable[sid]:
+ if sid in structs_fields_mutable:
+ if fid in structs_fields_mutable[sid] or '*' in structs_fields_mutable[sid]:
fimmutable = 'false'
if not ('char' in ftype and '[' in ftype and 'unsigned' not in ftype):
@@ -558,13 +433,12 @@ def build_struct(struct):
for field in struct['fields']:
fid, ftype, fimmutable, lvt, lot, size = get_struct_field_info(struct, field)
+ if not allowed_identifier(structs_fields_whitelist, structs_fields_blacklist, sid, fid):
+ continue
+
if re.search(r'\[([^\]]+)\]', ftype):
ftype = re.sub(r'\[[^\]]*\]', '', ftype).strip()
- if sid in override_field_invisible:
- if fid in override_field_invisible[sid]:
- continue
-
name = sid
if sid in reversed_override_types:
name = reversed_override_types[sid]
@@ -576,8 +450,8 @@ def build_struct(struct):
struct_str = "struct " if not struct['typedef'] else ""
startStr = ''
endStr = ' },'
- if fid in override_field_version_excludes:
- startStr += '#ifndef ' + override_field_version_excludes[fid] + '\n'
+ if fid in structs_fields_version_excludes:
+ startStr += '#ifndef ' + structs_fields_version_excludes[fid] + '\n'
endStr += '\n#endif'
startStr += ' { '
row.append(startStr)
@@ -640,7 +514,7 @@ def build_structs(structs):
s = ''
for struct in structs:
- if struct['identifier'] in exclude_structs:
+ if struct['identifier'] in structs_excluded:
continue
oldFields = struct['fields']
struct['fields'] = sorted(struct['fields'], key=lambda d: d['identifier'])
@@ -669,7 +543,7 @@ def build_body(parsed):
for struct in parsed:
sid = struct['identifier']
- if sid in exclude_structs:
+ if sid in structs_excluded:
continue
lot_names += f'\t[LOT_{sid.upper()}] = "{sid}",\n'
lot_names += '};\n'
@@ -703,7 +577,7 @@ def build_lot_enum():
def build_includes():
s = '#include "smlua.h"\n'
- for in_file in in_files:
+ for in_file in structs_files:
s += '#include "%s"\n' % in_file
return s
@@ -729,7 +603,7 @@ def doc_struct_index(structs):
s = '# Supported Structs\n'
for struct in structs:
sid = struct['identifier']
- if sid in exclude_structs:
+ if sid in structs_excluded:
continue
s += '- [%s](#%s)\n' % (sid, sid)
global total_structs
@@ -739,15 +613,13 @@ def doc_struct_index(structs):
def doc_struct_field(struct, field):
fid, ftype, fimmutable, lvt, lot, size = get_struct_field_info(struct, field)
-
sid = struct['identifier']
- if sid in override_field_invisible:
- if fid in override_field_invisible[sid]:
- return '', False
- if sid in override_field_deprecated:
- if fid in override_field_deprecated[sid]:
- return '', False
+ if not allowed_identifier(structs_fields_whitelist, structs_fields_blacklist, sid, fid):
+ return '', False
+
+ if not allowed_identifier(None, structs_fields_hidden, sid, fid):
+ return '', False
if '???' in lvt or '???' in lot:
return '', False
@@ -823,13 +695,13 @@ def doc_struct(struct):
return s
def doc_structs(structs):
- structs.extend(parse_structs(sLuaManuallyDefinedStructs, False)) # Don't sort fields for vec types in the documentation
+ structs.extend(parse_structs(lua_manually_defined_structs, False)) # Don't sort fields for vec types in the documentation
structs = sorted(structs, key=lambda d: d['identifier'])
s = '## [:rewind: Lua Reference](lua.md)\n\n'
s += doc_struct_index(structs)
for struct in structs:
- if struct['identifier'] in exclude_structs:
+ if struct['identifier'] in structs_excluded:
continue
s += doc_struct(struct) + '\n'
@@ -878,13 +750,11 @@ def def_struct(struct):
for field in struct['fields']:
fid, ftype, fimmutable, lvt, lot, size = get_struct_field_info(struct, field)
- if sid in override_field_invisible:
- if fid in override_field_invisible[sid]:
- continue
+ if not allowed_identifier(structs_fields_whitelist, structs_fields_blacklist, sid, fid):
+ continue
- if sid in override_field_deprecated:
- if fid in override_field_deprecated[sid]:
- continue
+ if not allowed_identifier(None, structs_fields_hidden, sid, fid):
+ continue
if '???' in lvt or '???' in lot:
continue
@@ -911,7 +781,7 @@ def def_structs(structs):
s = '-- AUTOGENERATED FOR CODE EDITORS --\n'
for struct in structs:
- if struct['identifier'] in exclude_structs:
+ if struct['identifier'] in structs_excluded:
continue
s += def_struct(struct)
@@ -926,7 +796,7 @@ def def_structs(structs):
def build_files():
extracted = []
- for in_file in in_files:
+ for in_file in structs_files:
path = get_path(in_file)
extracted.append({
'path': in_file,
diff --git a/autogen/exposed_lists.py b/autogen/exposed_lists.py
new file mode 100644
index 000000000..57e05279c
--- /dev/null
+++ b/autogen/exposed_lists.py
@@ -0,0 +1,477 @@
+#############
+# CONSTANTS #
+#############
+
+# Autogen will look in these files for constants
+constants_files = [
+ "include/types.h",
+ "include/sm64.h",
+ "src/pc/lua/smlua_hooks.h",
+ "src/game/area.h",
+ "src/game/camera.h",
+ "include/mario_animation_ids.h",
+ "include/sounds.h",
+ "src/game/characters.h",
+ "src/pc/network/network.h",
+ "src/pc/network/network_player.h",
+ "include/PR/os_cont.h",
+ "src/game/interaction.c",
+ "src/game/interaction.h",
+ "src/pc/djui/djui_hud_utils.h",
+ "src/pc/controller/controller_mouse.h",
+ "include/behavior_table.h",
+ "src/pc/lua/utils/smlua_model_utils.h",
+ "src/pc/lua/utils/smlua_misc_utils.h",
+ "include/object_constants.h",
+ "include/mario_geo_switch_case_ids.h",
+ "src/game/object_list_processor.h",
+ "src/engine/graph_node.h",
+ "levels/level_defines.h",
+ "levels/course_defines.h",
+ "src/game/obj_behaviors.c",
+ "src/game/save_file.h",
+ "src/game/obj_behaviors_2.h",
+ "include/dialog_ids.h",
+ "include/seq_ids.h",
+ "include/surface_terrains.h",
+ "src/game/level_update.h",
+ "src/pc/network/version.h",
+ "include/geo_commands.h",
+ "include/level_commands.h",
+ "src/audio/external.h",
+ "src/game/envfx_snow.h",
+ "src/pc/mods/mod_storage.h",
+ "src/pc/mods/mod_fs.h",
+ "src/game/first_person_cam.h",
+ "src/pc/djui/djui_console.h",
+ "src/game/player_palette.h",
+ "src/pc/network/lag_compensation.h",
+ "src/pc/djui/djui_panel_menu.h",
+ "src/engine/lighting_engine.h",
+ "include/PR/gbi.h",
+ "include/PR/gbi_extension.h",
+ "src/pc/gfx/gfx_pc.h",
+ "src/engine/surface_load.h",
+ "src/pc/lua/utils/smlua_audio_utils.h",
+ "src/pc/voice_chat.h",
+]
+
+# For each file, expose only these constants
+constants_whitelist = { "__name__": "constants_whitelist",
+ "include/geo_commands.h": [ "BACKGROUND" ],
+ "include/level_commands.h": [ "WARP_CHECKPOINT", "WARP_NO_CHECKPOINT" ],
+ "src/audio/external.h": [ "SEQ_PLAYER", "DS_" ],
+ "src/pc/lua/utils/smlua_audio_utils.h": ["MOD_AUDIO_CHANNEL"],
+ "src/pc/mods/mod_storage.h": [ "MAX_KEYS", "MAX_KEY_VALUE_LENGTH" ],
+ "include/PR/gbi.h": [
+ "^G_NOOP$",
+ "^G_SETOTHERMODE_H$",
+ "^G_SETOTHERMODE_L$",
+ "^G_ENDDL$",
+ "^G_DL$",
+ "^G_MOVEMEM$",
+ "^G_MOVEWORD$",
+ "^G_MTX$",
+ "^G_GEOMETRYMODE$",
+ "^G_POPMTX$",
+ "^G_TEXTURE$",
+ "^G_COPYMEM$",
+ "^G_VTX$",
+ "^G_TRI1$",
+ "^G_TRI2$",
+ "^G_SETCIMG$",
+ "^G_SETZIMG$",
+ "^G_SETTIMG$",
+ "^G_SETCOMBINE$",
+ "^G_SETENVCOLOR$",
+ "^G_SETPRIMCOLOR$",
+ "^G_SETBLENDCOLOR$",
+ "^G_SETFOGCOLOR$",
+ "^G_SETFILLCOLOR$",
+ "^G_FILLRECT$",
+ "^G_SETTILE$",
+ "^G_LOADTILE$",
+ "^G_LOADBLOCK$",
+ "^G_SETTILESIZE$",
+ "^G_LOADTLUT$",
+ "^G_SETSCISSOR$",
+ "^G_TEXRECTFLIP$",
+ "^G_TEXRECT$",
+ ],
+ "include/PR/gbi_extension.h": [
+ "^G_VTX_EXT$",
+ "^G_PPARTTOCOLOR$",
+ "^G_SETENVRGB$",
+ "^G_STATE_EXT$",
+ ],
+}
+
+# For each file, do not expose these constants
+constants_blacklist = { "__name__": "constants_blacklist",
+ "*": [ "^MAXCONTROLLERS$", "^AREA_[^T].*", "^AREA_T[HTO]", "^CONT_ERR.*", "^READ_MASK$", "^SIGN_RANGE$" ],
+ "include/sm64.h": [ "END_DEMO" ],
+ "include/types.h": [ "GRAPH_NODE_GUARD" ],
+ "src/audio/external.h": [ "DS_DIFF" ],
+ "src/game/save_file.h": [ "EEPROM_SIZE" ],
+ "src/game/obj_behaviors.c": [ "^o$" ],
+ "src/pc/djui/djui_console.h": [ "CONSOLE_MAX_TMP_BUFFER" ],
+ "src/pc/lua/smlua_hooks.h": [ "^LUA_BEHAVIOR_.*", "MAX_HOOKED_.*", "^HOOK_RETURN_.*", "^ACTION_HOOK_.*", "^MOD_MENU_ELEMENT_.*" ],
+ "src/pc/djui/djui_panel_menu.h": [ "RAINBOW_TEXT_LEN" ],
+ "src/pc/mods/mod_fs.h": [ "INT_TYPE_MAX", "FLOAT_TYPE_MAX", "FILE_SEEK_MAX" ],
+ "src/engine/surface_load.h": [ "NUM_CELLS" ],
+ "src/pc/network/version.h": [ "VERSION_OFFSET" ],
+}
+
+# For each file, expose these constants, but hide them from the documentation or VSCode autocomplete
+constants_hidden = { "__name__": "constants_hidden",
+ "interaction.h": [ "INTERACT_UNKNOWN_08" ],
+}
+
+#############
+# FUNCTIONS #
+#############
+
+# Autogen will look in these files for functions
+functions_files = [
+ "src/audio/external.h",
+ "src/engine/math_util.h",
+ "src/engine/math_util.inl",
+ "src/engine/math_util_vec3f.inl",
+ "src/engine/math_util_vec3i.inl",
+ "src/engine/math_util_vec3s.inl",
+ "src/engine/math_util_mat4.inl",
+ "src/engine/surface_collision.h",
+ "src/engine/surface_load.h",
+ "src/game/camera.h",
+ "src/game/characters.h",
+ "src/game/mario_actions_airborne.c",
+ "src/game/mario_actions_automatic.c",
+ "src/game/mario_actions_cutscene.c",
+ "src/game/mario_actions_moving.c",
+ "src/game/mario_actions_object.c",
+ "src/game/mario_actions_stationary.c",
+ "src/game/mario_actions_submerged.c",
+ "src/game/mario_step.h",
+ "src/game/mario.h",
+ "src/game/rumble_init.h",
+ "src/pc/djui/djui_popup.h",
+ "src/pc/network/network_utils.h",
+ "src/pc/djui/djui_console.h",
+ "src/pc/djui/djui_chat_message.h",
+ "src/pc/djui/djui_language.h",
+ "src/game/interaction.h",
+ "src/game/level_info.h",
+ "src/game/save_file.h",
+ "src/game/sound_init.h",
+ "src/pc/djui/djui_hud_utils.h",
+ "src/pc/djui/djui_panel_menu.h",
+ "src/pc/network/network_player.h",
+ "src/pc/network/lag_compensation.h",
+ "include/behavior_table.h",
+ "src/pc/lua/utils/smlua_obj_utils.h",
+ "src/pc/lua/utils/smlua_misc_utils.h",
+ "src/pc/lua/utils/smlua_camera_utils.h",
+ "src/pc/lua/utils/smlua_gfx_utils.h",
+ "src/pc/lua/utils/smlua_collision_utils.h",
+ "src/pc/lua/utils/smlua_model_utils.h",
+ "src/pc/lua/utils/smlua_text_utils.h",
+ "src/pc/lua/utils/smlua_audio_utils.h",
+ "src/pc/lua/utils/smlua_level_utils.h",
+ "src/pc/lua/utils/smlua_anim_utils.h",
+ "src/pc/lua/utils/smlua_deprecated.h",
+ "src/game/object_helpers.c",
+ "src/game/obj_behaviors.c",
+ "src/game/obj_behaviors_2.c",
+ "src/game/platform_displacement.h",
+ "src/game/spawn_sound.h",
+ "src/game/object_list_processor.h",
+ "src/game/behavior_actions.h",
+ "src/game/mario_misc.h",
+ "src/pc/mods/mod_storage.h",
+ "src/pc/mods/mod_fs.h",
+ "src/pc/utils/misc.h",
+ "src/game/level_update.h",
+ "src/game/area.h",
+ "src/engine/level_script.h",
+ "src/game/ingame_menu.h",
+ "src/game/first_person_cam.h",
+ "src/engine/behavior_script.h",
+ "src/audio/seqplayer.h",
+ "src/engine/lighting_engine.h",
+ "src/pc/network/sync_object.h",
+ "src/audio/load.h",
+ "src/pc/djui/djui_gfx.h",
+ "src/pc/voice_chat.h"
+]
+
+# For each file, expose only these functions
+functions_whitelist = { "__name__": "functions_whitelist",
+ "src/audio/external.h": [ " play_", "fade", "current_background", "stop_", "sound_banks", "drop_queued_background_music", "set_sound_moving_speed", "background_music_default_volume", "get_sound_pan", "sound_get_level_intensity", "set_audio_muted" ],
+ "src/game/rumble_init.h": [ "queue_rumble_", "reset_rumble_", "cancel_rumble", "is_rumble_finished_and_queue_empty" ],
+ "src/pc/djui/djui_popup.h": [ "create" ],
+ "src/pc/djui/djui_language.h": [ "djui_language_get" ],
+ "src/pc/djui/djui_panel_menu.h": [ "djui_menu_get_rainbow_string_color" ],
+ "src/game/save_file.h": [ "get_level_", "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_reload", "save_file_erase_current_backup_save", "save_file_set_star_flags", "save_file_is_cannon_unlocked", "save_file_set_cannon_unlocked", "touch_coin_score_age", "save_file_set_course_coin_score", "save_file_do_save", "save_file_remove_star_flags", "save_file_erase" ],
+ "src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ],
+ "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
+ "src/game/platform_displacement.h": [ "apply_platform_displacement" ],
+ "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*" ],
+ "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_warp", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "pressed_pause", "fade_into_special_warp", "get_instant_warp" ],
+ "src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ],
+ "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", "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" ],
+ "src/pc/djui/djui_gfx.h": [ "djui_gfx_get_scale" ],
+}
+
+# For each file, do not expose these functions
+functions_blacklist = { "__name__": "functions_blacklist",
+ "src/audio/external.h": [ " func_" ],
+ "src/engine/surface_load.h": [ "load_area_terrain", "alloc_surface_pools", "clear_dynamic_surfaces", "get_area_terrain_size", "alloc_surface", "add_surface", "remove_surface_from_partition", "delete_surface", "swap_and_pop_surface_pool", "add_surface_without_hook" ],
+ "src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
+ "src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
+ "src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ],
+ "src/game/mario_actions_cutscene.c": [ "^[us]32 act_.*", " geo_", "spawn_obj", "print_displaying_credits_entry" ],
+ "src/game/mario_actions_moving.c": [ "^[us]32 act_.*" ],
+ "src/game/mario_actions_object.c": [ "^[us]32 act_.*" ],
+ "src/game/mario_actions_stationary.c": [ "^[us]32 act_.*", "mario_exit_palette_editor" ],
+ "src/game/mario_actions_submerged.c": [ "^[us]32 act_.*" ],
+ "src/game/mario_step.h": [ " stub_mario_step", "transfer_bully_speed" ],
+ "src/game/mario.h": [ " init_mario" ],
+ "src/pc/djui/djui_console.h": [ " djui_console_create", "djui_console_message_create", "djui_console_message_dequeue" ],
+ "src/pc/djui/djui_chat_message.h": [ "create_from" ],
+ "src/pc/djui/djui_hud_utils.h": [ "djui_hud_clear_interp_data", "djui_hud_print_text", "djui_hud_print_text_interpolated" ],
+ "src/game/interaction.h": [ "process_interaction", "_handle_" ],
+ "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ],
+ "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ],
+ "src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup", "network_player_name_valid" ],
+ "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "geo_", "abs[fi]", "^bit_shift", "_debug$", "stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table", "bit_shift_left" ],
+ "src/game/obj_behaviors.c": [ "debug_", "geo_", "turn_obj_away_from_surface"],
+ "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ],
+ "src/game/spawn_sound.h": [ "exec_anim_sound_state", "calc_dist_to_volume_range" ],
+ "src/game/level_info.h": [ "_name_table", "convert_string_" ],
+ "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" ],
+ "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" ],
+ "src/pc/lua/utils/smlua_gfx_utils.h": [ "gfx_allocate_internal", "vtx_allocate_internal", "gfx_get_length_no_sentinel" ],
+ "src/pc/network/lag_compensation.h": [ "lag_compensation_clear" ],
+ "src/game/first_person_cam.h": [ "first_person_update" ],
+ "src/pc/lua/utils/smlua_collision_utils.h": [ "collision_find_surface_on_ray" ],
+ "src/engine/behavior_script.h": [ "stub_behavior_script_2", "cur_obj_update" ],
+ "src/pc/mods/mod_storage.h": [ "mod_storage_shutdown" ],
+ "src/pc/mods/mod_fs.h": [ "mod_fs_read_file_from_uri", "mod_fs_shutdown" ],
+ "src/pc/utils/misc.h": [ "str_.*", "file_get_line", "delta_interpolate_(normal|rgba|mtx)", "detect_and_skip_mtx_interpolation", "precise_delay_f64", "can_update_game", "update_game", "open_url", "open_folder" ],
+ "src/engine/lighting_engine.h": [ "le_calculate_vertex_lighting", "le_clear", "le_shutdown" ],
+ "src/pc/voice_chat.h": [ "voicechat_init", "voicechat_shutdown", "voicechat_init_player", "voicechat_encode_audio", "voicechat_decode_audio", "voicechat_mix", "voicechat_push_pending_global_mute", "voicechat_resolve_pending_global_mutes" ],
+}
+
+# For each file, expose these functions, but hide them from the documentation or VSCode autocomplete
+functions_hidden = { "__name__": "functions_hidden",
+ "smlua_deprecated.h": [ ".*" ],
+ "network_player.h": [ "network_player_get_palette_color_channel", "network_player_get_override_palette_color_channel" ],
+}
+
+# For each function, expose it except for the specified version
+functions_version_excludes = {
+ "bhv_play_music_track_when_touched_loop": "VERSION_JP",
+ "play_knockback_sound": "VERSION_JP",
+ "cur_obj_spawn_star_at_y_offset": "VERSION_JP",
+}
+
+# For each function parameter, specify its type
+functions_params_types = {
+ "src/pc/lua/utils/smlua_obj_utils.h::spawn_object_sync::objSetupFunction": [ "struct Object*" ],
+}
+
+###########
+# STRUCTS #
+###########
+
+# Autogen will look in these files for structs
+structs_files = [
+ "include/types.h",
+ "src/game/area.h",
+ "src/game/camera.h",
+ "src/game/characters.h",
+ "src/engine/surface_collision.h",
+ "src/pc/network/network_player.h",
+ "src/pc/djui/djui_hud_utils.h",
+ "src/pc/djui/djui_theme.h",
+ "src/game/object_helpers.h",
+ "src/game/mario_step.h",
+ "src/game/ingame_menu.h",
+ "src/pc/lua/utils/smlua_anim_utils.h",
+ "src/pc/lua/utils/smlua_misc_utils.h",
+ "src/pc/lua/utils/smlua_camera_utils.h",
+ "src/pc/lua/utils/smlua_collision_utils.h",
+ "src/pc/lua/utils/smlua_level_utils.h",
+ "src/game/spawn_sound.h",
+ "src/pc/network/network.h",
+ "src/game/hardcoded.h",
+ "src/pc/mods/mod.h",
+ "src/pc/mods/mod_fs.h",
+ "src/pc/lua/utils/smlua_audio_utils.h",
+ "src/game/paintings.h",
+ "src/pc/djui/djui_types.h",
+ "src/game/level_update.h",
+ "src/game/first_person_cam.h",
+ "src/game/player_palette.h",
+ "src/engine/graph_node.h",
+ "include/PR/gbi.h",
+ "src/pc/voice_chat.h",
+]
+
+# For each file, expose only these structs
+structs_whitelist = { "__name__": "structs_whitelist",
+ "src/pc/network/network.h": [ "ServerSettings", "NametagsSettings" ],
+ "src/pc/djui/djui_types.h": [ "DjuiColor" ],
+ "src/game/level_update.h": [ "HudDisplay" ],
+ "src/game/player_palette.h": [ "PlayerPalette" ],
+ "src/game/ingame_menu.h" : [ "DialogEntry" ],
+ "include/PR/gbi.h": [ "Gfx", "^Vtx$" ],
+ "src/pc/voice_chat.h": [ "VoicePlayer" ],
+}
+
+# For each file, do not expose these structs
+structs_blacklist = { "__name__": "structs_blacklist",
+}
+
+# Ignore these structs entirely across all files
+structs_excluded = [
+ 'AnimationTable',
+ 'BullyCollisionData',
+ 'CameraFOVStatus',
+ 'CameraStoredInfo',
+ 'CameraTrigger',
+ 'Cutscene',
+ 'CutsceneSplinePoint',
+ 'CutsceneVariable',
+ 'FloorGeometry',
+ 'GraphNode_802A45E4',
+ 'HandheldShakePoint',
+ 'LinearTransitionPoint',
+ 'MarioAnimDmaRelatedThing',
+ 'ModAudioSampleCopies',
+ 'ModFile',
+ 'ModeTransitionInfo',
+ 'OffsetSizePair',
+ 'PaintingMeshVertex',
+ 'ParallelTrackingPoint',
+ 'PlayerGeometry',
+ 'SPTask',
+ 'SoundState',
+ 'TransitionInfo',
+ 'UnusedArea28',
+ 'VblankHandler',
+ 'Vtx_Interp',
+ 'WarpTransition',
+ 'WarpTransitionData',
+]
+
+# For each struct, expose only these fields
+structs_fields_whitelist = { "__name__": "structs_fields_whitelist",
+}
+
+# For each struct, do not expose these fields
+structs_fields_blacklist = { "__name__": "structs_fields_blacklist",
+ "Mod": [ "files", "showedScriptWarning", "customBehaviorIndex", "customObjectFields" ],
+ "Camera": [ "paletteEditorCapState" ],
+ "NetworkPlayer": [ "gag", "moderator", "discordId", "rxPacketHash", "rxSeqIds" ],
+ "GraphNode": [ "_guard1", "_guard2", "padding" ],
+ "GraphNodeRoot": ["unk15", "views"],
+ "GraphNodeMasterList": [ "listHeads", "listTails" ],
+ "GraphNodeCullingRadius": [ "pad1E" ],
+ "GraphNodeTranslation": [ "pad1E" ],
+ "GraphNodeBackground": [ "unused" ],
+ "GraphNodePerspective": [ "unused" ],
+ "GraphNodeSwitchCase": [ "unused" ],
+ "GraphNodeObject": [ "unk4C" ],
+ "FnGraphNode": [ "luaTokenIndex" ],
+ "Object": [ "firstSurface", "customFields", "bhvStack", "bhvStackIndex" ],
+ "Animation": [ "unusedBoneCount" ],
+ "ModAudio": [ "alive", "sound", "decoder", "buffer", "bufferSize", "sampleCopiesTail", "volChannel" ],
+ "Painting": [ "normalDisplayList", "textureMaps", "rippleDisplayList", "ripples" ],
+ "DialogEntry": [ "str" ],
+ "ModFsFile": [ "data", "capacity" ],
+ "ModFs": [ "files" ],
+ "VoicePlayer": [ "internal" ],
+}
+
+# For each struct, expose these fields, but hide them from the documentation or VSCode autocomplete
+structs_fields_hidden = { "__name__": "structs_fields_hidden",
+ "NetworkPlayer": [ "paletteIndex", "overridePaletteIndex", "overridePaletteIndexLp" ],
+ "ModAudio": [ "^file$", "relativePath" ], # compatibility band-aid
+ "Camera": [ "filler31", "filler3C", "unusedVec1" ],
+ "LakituState": [ "filler30", "filler3E", "filler72", "unusedVec1", "unusedVec2" ],
+ "SpawnInfo": [ "unk18" ],
+}
+
+# For each struct field, expose it except for the specified version
+structs_fields_version_excludes = {
+ "oCameraLakituMusicPlayed": "VERSION_JP",
+ "oCoinUnk1B0": "VERSION_JP",
+}
+
+# For each struct and field, specify its type
+structs_fields_types = {
+ "Surface": {
+ "normal": "Vec3f"
+ },
+ "Object": {
+ "oAnimations": "ObjectAnimPointer*"
+ },
+}
+
+# For each struct, specify which fields are mutable (read and write)
+structs_fields_mutable = {
+ "NetworkPlayer": [ "overrideModelIndex", "overridePalette", "overridePaletteIndex" ],
+}
+
+# For each struct, specify which fields are immutable (read-only)
+structs_fields_immutable = {
+ "MarioState": [ "playerIndex", "controller", "marioObj", "marioBodyState", "statusForCamera", "area", "dialogId" ],
+ "MarioAnimation": [ "animDmaTable" ],
+ "ObjectNode": [ "next", "prev" ],
+ "Character": [ "*" ],
+ "NetworkPlayer": [ "*" ],
+ "TextureInfo": [ "*" ],
+ "Object": ["oSyncID", "coopFlags", "oChainChompSegments", "oWigglerSegments", "oHauntedChairUnk100", "oTTCTreadmillBigSurface", "oTTCTreadmillSmallSurface", "bhvStackIndex", "respawnInfoType", "numSurfaces", "bhvStack" ],
+ "Surface": [ "poolType", "socId" ],
+ "GlobalObjectAnimations": [ "*"],
+ "SpawnParticlesInfo": [ "model" ],
+ "WaterDropletParams": [ "model" ],
+ "MarioBodyState": [ "updateTorsoTime", "updateHeadPosTime", "animPartsPos", "animPartsRot", "currAnimPart" ],
+ "Area": [ "localAreaTimer", "nextSyncID", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ],
+ "Mod": [ "*" ],
+ "ModFile": [ "*" ],
+ "Painting": [ "id", "imageCount", "textureType", "textureWidth", "textureHeight" ],
+ "SpawnInfo": [ "syncID", "next", "unk18" ],
+ "CustomLevelInfo": [ "next" ],
+ "GraphNode": [ "children", "next", "parent", "prev", "type" ],
+ "GraphNodeBackground": [ "prevCameraTimestamp", "unused" ],
+ "GraphNodeCamera": [ "matrixPtrPrev", "prevTimestamp" ],
+ "GraphNodeHeldObject": [ "prevShadowPosTimestamp" ],
+ "GraphNodeObject": [ "angle", "animInfo", "cameraToObject", "node", "pos", "prevAngle", "prevPos", "prevScale", "prevScaleTimestamp", "prevShadowPos", "prevShadowPosTimestamp", "prevThrowMatrix", "prevThrowMatrixTimestamp", "prevTimestamp", "scale", "shadowPos", "sharedChild", "skipInterpolationTimestamp", "throwMatrixPrev", "unk4C", ],
+ "GraphNodeObjectParent": [ "sharedChild" ],
+ "GraphNodePerspective": [ "unused" ],
+ "GraphNodeSwitchCase": [ "fnNode", "unused" ],
+ "GraphNodeRoot": ["node", "areaIndex", "numViews"],
+ "ObjectWarpNode": [ "next" ],
+ "Animation": [ "*" ],
+ "AnimationTable": [ "*" ],
+ "Controller": [ "controllerData", "statusData" ],
+ "FirstPersonCamera": [ "enabled" ],
+ "ModAudio": [ "isStream", "loaded" ],
+ "Gfx": [ "w0", "w1" ], # to protect from invalid type conversions
+ "DialogEntry": [ "unused", "linesPerBox", "leftOffset", "width", "str", "text", "replaced"],
+ "ModFsFile": [ "*" ],
+ "ModFs": [ "*" ],
+ "StaticObjectCollision": [ "*" ],
+ "VoicePlayer": [ "talking", "error", "clientMutedState", "playerMutedState" ],
+}
diff --git a/autogen/extract_constants.py b/autogen/extract_constants.py
index 3290a042b..c8e8faafc 100644
--- a/autogen/extract_constants.py
+++ b/autogen/extract_constants.py
@@ -11,8 +11,21 @@ def extract_level_defines(txt):
txt += ' LEVEL_COUNT,\n };'
return txt
+def extract_course_defines(txt):
+ tmp = txt
+ txt = 'enum CourseNum {\n'
+ for line in tmp.splitlines():
+ if line.startswith('DEFINE_COURSE(') or line.startswith('DEFINE_BONUS_COURSE('):
+ txt += ' ' + line.replace('(', ',').split(',')[1].strip() + ',\n'
+ txt += ' COURSE_END,\n'
+ txt += ' COURSE_COUNT = COURSE_END - 1,\n'
+ txt += ' COURSE_MAX = COURSE_COUNT,\n'
+ txt += ' COURSE_MIN = 1,\n };'
+ return txt
+
extra_steps = {
"levels/level_defines.h": extract_level_defines,
+ "levels/course_defines.h": extract_course_defines,
}
def extract_constants(filename):
diff --git a/autogen/lua_constants/built-in.lua b/autogen/lua_constants/built-in.lua
index 58b436d3a..20cefae0a 100644
--- a/autogen/lua_constants/built-in.lua
+++ b/autogen/lua_constants/built-in.lua
@@ -79,72 +79,6 @@ function SOUND_ARG_LOAD(bank, soundID, priority, flags)
)
end
--------------
--- courses --
--------------
-
---- @type integer
-COURSE_NONE = 0
---- @type integer
-COURSE_BOB = 1
---- @type integer
-COURSE_WF = 2
---- @type integer
-COURSE_JRB = 3
---- @type integer
-COURSE_CCM = 4
---- @type integer
-COURSE_BBH = 5
---- @type integer
-COURSE_HMC = 6
---- @type integer
-COURSE_LLL = 7
---- @type integer
-COURSE_SSL = 8
---- @type integer
-COURSE_DDD = 9
---- @type integer
-COURSE_SL = 10
---- @type integer
-COURSE_WDW = 11
---- @type integer
-COURSE_TTM = 12
---- @type integer
-COURSE_THI = 13
---- @type integer
-COURSE_TTC = 14
---- @type integer
-COURSE_RR = 15
---- @type integer
-COURSE_BITDW = 16
---- @type integer
-COURSE_BITFS = 17
---- @type integer
-COURSE_BITS = 18
---- @type integer
-COURSE_PSS = 19
---- @type integer
-COURSE_COTMC = 20
---- @type integer
-COURSE_TOTWC = 21
---- @type integer
-COURSE_VCUTM = 22
---- @type integer
-COURSE_WMOTR = 23
---- @type integer
-COURSE_SA = 24
---- @type integer
-COURSE_CAKE_END = 25
---- @type integer
-COURSE_END = 26
---- @type integer
-COURSE_MAX = 25
---- @type integer
-COURSE_COUNT = 25
---- @type integer
-COURSE_MIN = 1
-
-
------------------------------
-- player palette functions --
------------------------------
@@ -174,326 +108,3 @@ function network_player_get_override_palette_color(np, part)
}
return color
end
-
---------------------------
--- local math functions --
---------------------------
-local __math_min, __math_max, __math_sqrt, __math_floor, __math_ceil, __math_cos, __math_sin, __math_pi = math.min, math.max, math.sqrt, math.floor, math.ceil, math.cos, math.sin, math.pi
-
-------------
--- tweens --
-------------
--- Unrelated to SM64, but these are for `math.tween`
-
----@param x number
----@return number
-IN_SINE = function (x) return 1 - __math_cos((x * __math_pi) / 2) end
----@param x number
----@return number
-OUT_SINE = function (x) return __math_sin((x * __math_pi) / 2) end
----@param x number
----@return number
-IN_OUT_SINE = function (x) return -(__math_cos(__math_pi * x) - 1) / 2 end
----@param x number
----@return number
-OUT_IN_SINE = function (x) return x < 0.5 and 0.5 * __math_sin(x * __math_pi) or 1 - 0.5 * __math_cos(((x * 2 - 1) * (__math_pi / 2))) end
----@param x number
----@return number
-IN_QUAD = function (x) return x ^ 2 end
----@param x number
----@return number
-OUT_QUAD = function (x) return 1 - ((1 - x) ^ 2) end
----@param x number
----@return number
-IN_OUT_QUAD = function (x) return x < 0.5 and 2 * (x ^ 2) or 1 - ((-2 * x + 2) ^ 2) / 2 end
----@param x number
----@return number
-OUT_IN_QUAD = function (x) return x < 0.5 and 0.5 * (-(2 * x) * ((2 * x) - 2)) or 0.5 + 0.5 * (2 * x - 1) ^ 2 end
----@param x number
----@return number
-IN_CUBIC = function (x) return x ^ 3 end
----@param x number
----@return number
-OUT_CUBIC = function (x) return 1 - ((1 - x) ^ 3) end
----@param x number
----@return number
-IN_OUT_CUBIC = function (x) return x < 0.5 and 4 * (x ^ 3) or 1 - ((-2 * x + 2) ^ 3) / 2 end
----@param x number
----@return number
-OUT_IN_CUBIC = function (x) return x < 0.5 and 0.5 * (((2 * x - 1) ^ 3) + 1) or 0.5 + 0.5 * (2 * x - 1) ^ 3 end
----@param x number
----@return number
-IN_QUART = function (x) return x ^ 4 end
----@param x number
----@return number
-OUT_QUART = function (x) return 1 - ((1 - x) ^ 4) end
----@param x number
----@return number
-IN_OUT_QUART = function (x) return x < 0.5 and 8 * (x ^ 4) or 1 - ((-2 * x + 2) ^ 4) / 2 end
----@param x number
----@return number
-OUT_IN_QUART = function (x) return x < 0.5 and 0.5 * (1 - ((2 * x - 1) ^ 4)) or 0.5 + 0.5 * (2 * x - 1) ^ 4 end
----@param x number
----@return number
-IN_QUINT = function (x) return x ^ 5 end
----@param x number
----@return number
-OUT_QUINT = function (x) return 1 - ((1 - x) ^ 5) end
----@param x number
----@return number
-IN_OUT_QUINT = function (x) return x < 0.5 and 16 * (x ^ 5) or 1 - ((-2 * x + 2) ^ 5) / 2 end
----@param x number
----@return number
-OUT_IN_QUINT = function (x) return x < 0.5 and 0.5 * (((2 * x - 1) ^ 5) + 1) or 0.5 + 0.5 * (2 * x - 1) ^ 5 end
----@param x number
----@return number
-IN_EXPO = function (x) return x == 0 and x or 2 ^ (10 * x - 10) end
----@param x number
----@return number
-OUT_EXPO = function (x) return x == 1 and x or 1 - (2 ^ (-10 * x)) end
----@param x number
----@return number
-IN_OUT_EXPO = function (x) return (x == 0 or x == 1) and x or x < 0.5 and (2 ^ (20 * x - 10)) / 2 or (2 - (2 ^ (-20 * x + 10))) / 2 end
----@param x number
----@return number
-OUT_IN_EXPO = function (x) return (x == 0 or x == 1) and x or x < 0.5 and 0.5 * (1 - 2 ^ (-20 * x)) or 0.5 + 0.5 * (2 ^ (20 * x - 20)) end
----@param x number
----@return number
-IN_CIRC = function (x) return 1 - __math_sqrt(1 - (x ^ 2)) end
----@param x number
----@return number
-OUT_CIRC = function (x) return __math_sqrt(1 - ((x - 1) ^ 2)) end
----@param x number
----@return number
-IN_OUT_CIRC = function (x) return x < 0.5 and (1 - __math_sqrt(1 - ((2 * x) ^ 2))) / 2 or (__math_sqrt(1 - ((-2 * x + 2) ^ 2)) + 1) / 2 end
----@param x number
----@return number
-OUT_IN_CIRC = function (x) return x < 0.5 and 0.5 * __math_sqrt(1 - (2 * x - 1) ^ 2) or 0.5 + 0.5 * (1 - __math_sqrt(1 - (2 * x - 1) ^ 2)) end
----@param x number
----@return number
-IN_BACK = function (x) return (1.70158 + 1) * (x ^ 3) - 1.70158 * (x ^ 2) end
----@param x number
----@return number
-OUT_BACK = function (x) return 1 + (1.70158 + 1) * ((x - 1) ^ 3) + 1.70158 * ((x - 1) ^ 2) end
----@param x number
----@return number
-IN_OUT_BACK = function (x) return x < 0.5 and (((2 * x) ^ 2) * (((1.70158 * 1.525) + 1) * 2 * x - (1.70158 * 1.525))) / 2 or (((2 * x - 2) ^ 2) * (((1.70158 * 1.525) + 1) * (x * 2 - 2) + (1.70158 * 1.525)) + 2) / 2 end
----@param x number
----@return number
-OUT_IN_BACK = function (x) return x < 0.5 and 0.5 * (1 + (1.70158 + 1) * ((2 * x) - 1) ^ 3 + 1.70158 * ((2 * x) - 1) ^ 2) or 0.5 + 0.5 * ((1.70158 + 1) * (2 * x - 1) ^ 3 - 1.70158 * (2 * x - 1) ^ 2) end
----@param x number
----@return number
-IN_ELASTIC = function (x) return (x == 0 or x == 1) and x or -(2 ^ (10 * x - 10)) * __math_sin((x * 10 - 10.75) * ((2 * __math_pi) / 3)) end
----@param x number
----@return number
-OUT_ELASTIC = function (x) return (x == 0 or x == 1) and x or (2 ^ (-10 * x)) * __math_sin((x * 10 - 0.75) * ((2 * __math_pi) / 3)) + 1 end
----@param x number
----@return number
-IN_OUT_ELASTIC = function (x) return (x == 0 or x == 1) and x or (x < 0.5 and (-0.5 * (2 ^ (20 * x - 10)) * __math_sin((20 * x - 11.125) * ((2 * __math_pi) / 4.5)))) or (0.5 * (2 ^ (-20 * x + 10)) * __math_sin((20 * x - 11.125) * ((2 * __math_pi) / 4.5)) + 1) end
----@param x number
----@return number
-OUT_IN_ELASTIC = function (x) return (x == 0 or x == 1) and x or (x < 0.5 and 0.5 * ((2 ^ (-10 * (x * 2))) * __math_sin(((x * 2) * 10 - 0.75) * ((2 * __math_pi) / 3)) + 1)) or 0.5 + 0.5 * (-(2 ^ (10 * ((x - 0.5) * 2) - 10)) * __math_sin((((x - 0.5) * 2) * 10 - 10.75) * ((2 * __math_pi) / 3))) end
----@param x number
----@return number
-IN_BOUNCE = function (x) return 1 - OUT_BOUNCE(1 - x) end
----@param x number
----@return number
-OUT_BOUNCE = function (x) if x < 1 / 2.75 then return 7.5625 * (x ^ 2) elseif x < 2 / 2.75 then x = x - 1.5 / 2.75 return 7.5625 * (x ^ 2) + 0.75 elseif x < 2.5 / 2.75 then x = x - 2.25 / 2.75 return 7.5625 * (x ^ 2) + 0.9375 else x = x - 2.625 / 2.75 return 7.5625 * (x ^ 2) + 0.984375 end end
----@param x number
----@return number
-IN_OUT_BOUNCE = function (x) return x < 0.5 and (1 - OUT_BOUNCE(1 - 2 * x)) / 2 or (1 + OUT_BOUNCE(2 * x - 1)) / 2 end
----@param x number
----@return number
-OUT_IN_BOUNCE = function (x) return x < 0.5 and 0.5 * OUT_BOUNCE(x * 2) or 0.5 + 0.5 * IN_BOUNCE(2 * x - 1) end
-
---- @alias EasingFunction
---- | `IN_SINE`
---- | `OUT_SINE`
---- | `IN_OUT_SINE`
---- | `OUT_IN_SINE`
---- | `IN_QUAD`
---- | `OUT_QUAD`
---- | `IN_OUT_QUAD`
---- | `OUT_IN_QUAD`
---- | `IN_CUBIC`
---- | `OUT_CUBIC`
---- | `IN_OUT_CUBIC`
---- | `OUT_IN_CUBIC`
---- | `IN_QUART`
---- | `OUT_QUART`
---- | `IN_OUT_QUART`
---- | `OUT_IN_QUART`
---- | `IN_QUINT`
---- | `OUT_QUINT`
---- | `IN_OUT_QUINT`
---- | `OUT_IN_QUINT`
---- | `IN_EXPO`
---- | `OUT_EXPO`
---- | `IN_OUT_EXPO`
---- | `OUT_IN_EXPO`
---- | `IN_CIRC`
---- | `OUT_CIRC`
---- | `IN_OUT_CIRC`
---- | `OUT_IN_CIRC`
---- | `IN_BACK`
---- | `OUT_BACK`
---- | `IN_OUT_BACK`
---- | `OUT_IN_BACK`
---- | `IN_ELASTIC`
---- | `OUT_ELASTIC`
---- | `IN_OUT_ELASTIC`
---- | `OUT_IN_ELASTIC`
---- | `IN_BOUNCE`
---- | `OUT_BOUNCE`
---- | `IN_OUT_BOUNCE`
---- | `OUT_IN_BOUNCE`
---- | fun(x: number): number
-
---------------------
--- math functions --
---------------------
---- Note: These functions don't exist in the Lua math library,
---- and are useful enough to not have to redefine them in every mod
-
---- @param x number
---- @return number
---- Computes the square of the number `x`
-function math.sqr(x)
- return x * x
-end
-
---- @param x number
---- @param a number
---- @param b number
---- @return number
---- Clamps the number `x` between bounds `a` (minimum) and `b` (maximum)
-function math.clamp(x, a, b)
- return __math_min(__math_max(x, a), b)
-end
-
---- @param a number
---- @param b number
---- @return number
---- Computes the hypotenuse of a right-angled triangle given sides `a` and `b` using the Pythagorean theorem
-function math.hypot(a, b)
- return __math_sqrt(a * a + b * b)
-end
-
---- @param x number
---- @return number
---- Returns 1 if `x` is positive or zero, -1 otherwise
-function math.sign(x)
- return x >= 0 and 1 or -1
-end
-
---- @param x number
---- @return number
---- Returns 1 if `x` is positive, 0 if it is zero, -1 otherwise
-function math.sign0(x)
- return x ~= 0 and (x > 0 and 1 or -1) or 0
-end
-
---- @param a number
---- @param b number
---- @param t number
---- @return number
---- Linearly interpolates between `a` and `b` using delta `t`
-function math.lerp(a, b, t)
- return a + (b - a) * t
-end
-
---- @param a number
---- @param b number
---- @param x number
---- @return number
---- Determines where `x` linearly lies between `a` and `b`. It's the inverse of `math.lerp`
-function math.invlerp(a, b, x)
- return (x - a) / (b - a)
-end
-
---- @param a number
---- @param b number
---- @param c number
---- @param d number
---- @param x number
---- @return number
---- Linearly remaps `x` from the source range `[a, b]` to the destination range `[c, d]`
-function math.remap(a, b, c, d, x)
- return c + (d - c) * ((x - a) / (b - a))
-end
-
---- @param x number
---- Rounds `x` to the nearest integer value
-function math.round(x)
- return x > 0 and __math_floor(x + 0.5) or __math_ceil(x - 0.5)
-end
-
---- @param t EasingFunction | number
---- @param a number
---- @param b number
---- @param x number
---- @return number
---- Interpolates between `a` and `b` using delta `x` and a tweening or easing math function `t`
-function math.tween(t, a, b, x)
- local y
-
- if type(t) == 'function' then
- y = a + t(x) * (b - a)
- else
- y = a + t * (b - a)
- end
-
- return y
-end
-
-local __common_signed_conversion = function (x, size)
- x = __math_floor(x) & (1 << size) - 1
- return x - ((x & (1 << (size - 1))) << 1)
-end
-
-local __common_unsigned_conversion = function (x, size)
- return __math_floor(x) & (1 << size) - 1
-end
-
---- @param x number
---- @return integer
---- Converts `x` into a valid `s8` range
---- - `[-128, 127]`
-function math.s8(x)
- return __common_signed_conversion(x, 8)
-end
---- @param x number
---- @return integer
---- Converts `x` into a valid `s16` range
---- - `[-32768, 32767]`
-function math.s16(x)
- return __common_signed_conversion(x, 16)
-end
---- @param x number
---- @return integer
---- Converts `x` into a valid `s32` range
---- - `[-2147483648, 2147483647]`
-function math.s32(x)
- return __common_signed_conversion(x, 32)
-end
---- @param x number
---- @return integer
---- Converts `x` into a valid `u8` range
---- - `[0, 255]`
-function math.u8(x)
- return __common_unsigned_conversion(x, 8)
-end
---- @param x number
---- @return integer
---- Converts `x` into a valid `u16` range
---- - `[0, 65535]`
-function math.u16(x)
- return __common_unsigned_conversion(x, 16)
-end
---- @param x number
---- @return integer
---- Converts `x` into a valid `u32` range
---- - `[0, 4294967295]`
-function math.u32(x)
- return __common_unsigned_conversion(x, 32)
-end
diff --git a/autogen/lua_constants/deprecated.lua b/autogen/lua_constants/deprecated.lua
index 437ca2108..4e610ff0c 100644
--- a/autogen/lua_constants/deprecated.lua
+++ b/autogen/lua_constants/deprecated.lua
@@ -4,7 +4,6 @@ FONT_TINY = -1
--- @type integer
ANIM_FLAG_FORWARD = (1 << 1)
-
-----------------------
-- Renamed functions --
-----------------------
@@ -12,6 +11,14 @@ ANIM_FLAG_FORWARD = (1 << 1)
rom_hack_cam_set_collisions = camera_romhack_set_collisions
camera_romhack_allow_centering = camera_romhack_allow_switchable
camera_romhack_get_allow_centering = camera_romhack_get_allow_switchable
+bhv_star_door_loop_2 = bhv_star_door_loop_update_render_state
+absf_2 = math.abs
+cur_obj_enable_rendering_2 = cur_obj_enable_rendering
+cur_obj_can_mario_activate_textbox_2 = cur_obj_can_mario_activate_textbox
+reset_rumble_timers_2 = reset_rumble_timers_vibrate
+cur_obj_play_sound_1 = cur_obj_play_sound_if_visible
+cur_obj_play_sound_2 = cur_obj_play_sound_and_rumble_if_visible
+bit_shift_left = function (shift) return math.u8(1 << shift) end
--------------------
-- Math functions --
diff --git a/autogen/lua_constants/math.lua b/autogen/lua_constants/math.lua
new file mode 100644
index 000000000..03e30f6e1
--- /dev/null
+++ b/autogen/lua_constants/math.lua
@@ -0,0 +1,318 @@
+local __math_min, __math_max, __math_sqrt, __math_floor, __math_ceil, __math_cos, __math_sin, __math_pi = math.min, math.max, math.sqrt, math.floor, math.ceil, math.cos, math.sin, math.pi
+
+------------
+-- tweens --
+------------
+
+---@param x number
+---@return number
+IN_SINE = function (x) return 1 - __math_cos((x * __math_pi) / 2) end
+---@param x number
+---@return number
+OUT_SINE = function (x) return __math_sin((x * __math_pi) / 2) end
+---@param x number
+---@return number
+IN_OUT_SINE = function (x) return -(__math_cos(__math_pi * x) - 1) / 2 end
+---@param x number
+---@return number
+OUT_IN_SINE = function (x) return x < 0.5 and 0.5 * __math_sin(x * __math_pi) or 1 - 0.5 * __math_cos(((x * 2 - 1) * (__math_pi / 2))) end
+---@param x number
+---@return number
+IN_QUAD = function (x) return x ^ 2 end
+---@param x number
+---@return number
+OUT_QUAD = function (x) return 1 - ((1 - x) ^ 2) end
+---@param x number
+---@return number
+IN_OUT_QUAD = function (x) return x < 0.5 and 2 * (x ^ 2) or 1 - ((-2 * x + 2) ^ 2) / 2 end
+---@param x number
+---@return number
+OUT_IN_QUAD = function (x) return x < 0.5 and 0.5 * (-(2 * x) * ((2 * x) - 2)) or 0.5 + 0.5 * (2 * x - 1) ^ 2 end
+---@param x number
+---@return number
+IN_CUBIC = function (x) return x ^ 3 end
+---@param x number
+---@return number
+OUT_CUBIC = function (x) return 1 - ((1 - x) ^ 3) end
+---@param x number
+---@return number
+IN_OUT_CUBIC = function (x) return x < 0.5 and 4 * (x ^ 3) or 1 - ((-2 * x + 2) ^ 3) / 2 end
+---@param x number
+---@return number
+OUT_IN_CUBIC = function (x) return x < 0.5 and 0.5 * (((2 * x - 1) ^ 3) + 1) or 0.5 + 0.5 * (2 * x - 1) ^ 3 end
+---@param x number
+---@return number
+IN_QUART = function (x) return x ^ 4 end
+---@param x number
+---@return number
+OUT_QUART = function (x) return 1 - ((1 - x) ^ 4) end
+---@param x number
+---@return number
+IN_OUT_QUART = function (x) return x < 0.5 and 8 * (x ^ 4) or 1 - ((-2 * x + 2) ^ 4) / 2 end
+---@param x number
+---@return number
+OUT_IN_QUART = function (x) return x < 0.5 and 0.5 * (1 - ((2 * x - 1) ^ 4)) or 0.5 + 0.5 * (2 * x - 1) ^ 4 end
+---@param x number
+---@return number
+IN_QUINT = function (x) return x ^ 5 end
+---@param x number
+---@return number
+OUT_QUINT = function (x) return 1 - ((1 - x) ^ 5) end
+---@param x number
+---@return number
+IN_OUT_QUINT = function (x) return x < 0.5 and 16 * (x ^ 5) or 1 - ((-2 * x + 2) ^ 5) / 2 end
+---@param x number
+---@return number
+OUT_IN_QUINT = function (x) return x < 0.5 and 0.5 * (((2 * x - 1) ^ 5) + 1) or 0.5 + 0.5 * (2 * x - 1) ^ 5 end
+---@param x number
+---@return number
+IN_EXPO = function (x) return x == 0 and x or 2 ^ (10 * x - 10) end
+---@param x number
+---@return number
+OUT_EXPO = function (x) return x == 1 and x or 1 - (2 ^ (-10 * x)) end
+---@param x number
+---@return number
+IN_OUT_EXPO = function (x) return (x == 0 or x == 1) and x or x < 0.5 and (2 ^ (20 * x - 10)) / 2 or (2 - (2 ^ (-20 * x + 10))) / 2 end
+---@param x number
+---@return number
+OUT_IN_EXPO = function (x) return (x == 0 or x == 1) and x or x < 0.5 and 0.5 * (1 - 2 ^ (-20 * x)) or 0.5 + 0.5 * (2 ^ (20 * x - 20)) end
+---@param x number
+---@return number
+IN_CIRC = function (x) return 1 - __math_sqrt(1 - (x ^ 2)) end
+---@param x number
+---@return number
+OUT_CIRC = function (x) return __math_sqrt(1 - ((x - 1) ^ 2)) end
+---@param x number
+---@return number
+IN_OUT_CIRC = function (x) return x < 0.5 and (1 - __math_sqrt(1 - ((2 * x) ^ 2))) / 2 or (__math_sqrt(1 - ((-2 * x + 2) ^ 2)) + 1) / 2 end
+---@param x number
+---@return number
+OUT_IN_CIRC = function (x) return x < 0.5 and 0.5 * __math_sqrt(1 - (2 * x - 1) ^ 2) or 0.5 + 0.5 * (1 - __math_sqrt(1 - (2 * x - 1) ^ 2)) end
+---@param x number
+---@return number
+IN_BACK = function (x) return (1.70158 + 1) * (x ^ 3) - 1.70158 * (x ^ 2) end
+---@param x number
+---@return number
+OUT_BACK = function (x) return 1 + (1.70158 + 1) * ((x - 1) ^ 3) + 1.70158 * ((x - 1) ^ 2) end
+---@param x number
+---@return number
+IN_OUT_BACK = function (x) return x < 0.5 and (((2 * x) ^ 2) * (((1.70158 * 1.525) + 1) * 2 * x - (1.70158 * 1.525))) / 2 or (((2 * x - 2) ^ 2) * (((1.70158 * 1.525) + 1) * (x * 2 - 2) + (1.70158 * 1.525)) + 2) / 2 end
+---@param x number
+---@return number
+OUT_IN_BACK = function (x) return x < 0.5 and 0.5 * (1 + (1.70158 + 1) * ((2 * x) - 1) ^ 3 + 1.70158 * ((2 * x) - 1) ^ 2) or 0.5 + 0.5 * ((1.70158 + 1) * (2 * x - 1) ^ 3 - 1.70158 * (2 * x - 1) ^ 2) end
+---@param x number
+---@return number
+IN_ELASTIC = function (x) return (x == 0 or x == 1) and x or -(2 ^ (10 * x - 10)) * __math_sin((x * 10 - 10.75) * ((2 * __math_pi) / 3)) end
+---@param x number
+---@return number
+OUT_ELASTIC = function (x) return (x == 0 or x == 1) and x or (2 ^ (-10 * x)) * __math_sin((x * 10 - 0.75) * ((2 * __math_pi) / 3)) + 1 end
+---@param x number
+---@return number
+IN_OUT_ELASTIC = function (x) return (x == 0 or x == 1) and x or (x < 0.5 and (-0.5 * (2 ^ (20 * x - 10)) * __math_sin((20 * x - 11.125) * ((2 * __math_pi) / 4.5)))) or (0.5 * (2 ^ (-20 * x + 10)) * __math_sin((20 * x - 11.125) * ((2 * __math_pi) / 4.5)) + 1) end
+---@param x number
+---@return number
+OUT_IN_ELASTIC = function (x) return (x == 0 or x == 1) and x or (x < 0.5 and 0.5 * ((2 ^ (-10 * (x * 2))) * __math_sin(((x * 2) * 10 - 0.75) * ((2 * __math_pi) / 3)) + 1)) or 0.5 + 0.5 * (-(2 ^ (10 * ((x - 0.5) * 2) - 10)) * __math_sin((((x - 0.5) * 2) * 10 - 10.75) * ((2 * __math_pi) / 3))) end
+---@param x number
+---@return number
+IN_BOUNCE = function (x) return 1 - OUT_BOUNCE(1 - x) end
+---@param x number
+---@return number
+OUT_BOUNCE = function (x) if x < 1 / 2.75 then return 7.5625 * (x ^ 2) elseif x < 2 / 2.75 then x = x - 1.5 / 2.75 return 7.5625 * (x ^ 2) + 0.75 elseif x < 2.5 / 2.75 then x = x - 2.25 / 2.75 return 7.5625 * (x ^ 2) + 0.9375 else x = x - 2.625 / 2.75 return 7.5625 * (x ^ 2) + 0.984375 end end
+---@param x number
+---@return number
+IN_OUT_BOUNCE = function (x) return x < 0.5 and (1 - OUT_BOUNCE(1 - 2 * x)) / 2 or (1 + OUT_BOUNCE(2 * x - 1)) / 2 end
+---@param x number
+---@return number
+OUT_IN_BOUNCE = function (x) return x < 0.5 and 0.5 * OUT_BOUNCE(x * 2) or 0.5 + 0.5 * IN_BOUNCE(2 * x - 1) end
+
+--- @alias EasingFunction
+--- | `IN_SINE`
+--- | `OUT_SINE`
+--- | `IN_OUT_SINE`
+--- | `OUT_IN_SINE`
+--- | `IN_QUAD`
+--- | `OUT_QUAD`
+--- | `IN_OUT_QUAD`
+--- | `OUT_IN_QUAD`
+--- | `IN_CUBIC`
+--- | `OUT_CUBIC`
+--- | `IN_OUT_CUBIC`
+--- | `OUT_IN_CUBIC`
+--- | `IN_QUART`
+--- | `OUT_QUART`
+--- | `IN_OUT_QUART`
+--- | `OUT_IN_QUART`
+--- | `IN_QUINT`
+--- | `OUT_QUINT`
+--- | `IN_OUT_QUINT`
+--- | `OUT_IN_QUINT`
+--- | `IN_EXPO`
+--- | `OUT_EXPO`
+--- | `IN_OUT_EXPO`
+--- | `OUT_IN_EXPO`
+--- | `IN_CIRC`
+--- | `OUT_CIRC`
+--- | `IN_OUT_CIRC`
+--- | `OUT_IN_CIRC`
+--- | `IN_BACK`
+--- | `OUT_BACK`
+--- | `IN_OUT_BACK`
+--- | `OUT_IN_BACK`
+--- | `IN_ELASTIC`
+--- | `OUT_ELASTIC`
+--- | `IN_OUT_ELASTIC`
+--- | `OUT_IN_ELASTIC`
+--- | `IN_BOUNCE`
+--- | `OUT_BOUNCE`
+--- | `IN_OUT_BOUNCE`
+--- | `OUT_IN_BOUNCE`
+--- | fun(x: number): number
+
+--------------------
+-- math functions --
+--------------------
+--- Note: These functions don't exist in the Lua math library,
+--- and are useful enough to not have to redefine them in every mod
+
+--- @param x number
+--- @return number
+--- Computes the square of the number `x`
+function math.sqr(x)
+ return x * x
+end
+
+--- @param x number
+--- @param a number
+--- @param b number
+--- @return number
+--- Clamps the number `x` between bounds `a` (minimum) and `b` (maximum)
+function math.clamp(x, a, b)
+ return __math_min(__math_max(x, a), b)
+end
+
+--- @param a number
+--- @param b number
+--- @return number
+--- Computes the hypotenuse of a right-angled triangle given sides `a` and `b` using the Pythagorean theorem
+function math.hypot(a, b)
+ return __math_sqrt(a * a + b * b)
+end
+
+--- @param x number
+--- @return number
+--- Returns 1 if `x` is positive or zero, -1 otherwise
+function math.sign(x)
+ return x >= 0 and 1 or -1
+end
+
+--- @param x number
+--- @return number
+--- Returns 1 if `x` is positive, 0 if it is zero, -1 otherwise
+function math.sign0(x)
+ return x ~= 0 and (x > 0 and 1 or -1) or 0
+end
+
+--- @param a number
+--- @param b number
+--- @param t number
+--- @return number
+--- Linearly interpolates between `a` and `b` using delta `t`
+function math.lerp(a, b, t)
+ return a + (b - a) * t
+end
+
+--- @param a number
+--- @param b number
+--- @param x number
+--- @return number
+--- Determines where `x` linearly lies between `a` and `b`. It's the inverse of `math.lerp`
+function math.invlerp(a, b, x)
+ return (x - a) / (b - a)
+end
+
+--- @param a number
+--- @param b number
+--- @param c number
+--- @param d number
+--- @param x number
+--- @return number
+--- Linearly remaps `x` from the source range `[a, b]` to the destination range `[c, d]`
+function math.remap(a, b, c, d, x)
+ return c + (d - c) * ((x - a) / (b - a))
+end
+
+--- @param x number
+--- Rounds `x` to the nearest integer value
+function math.round(x)
+ return x > 0 and __math_floor(x + 0.5) or __math_ceil(x - 0.5)
+end
+
+--- @param t EasingFunction | number
+--- @param a number
+--- @param b number
+--- @param x number
+--- @return number
+--- Interpolates between `a` and `b` using delta `x` and a tweening or easing math function `t`
+function math.tween(t, a, b, x)
+ local y
+
+ if type(t) == 'function' then
+ y = a + t(x) * (b - a)
+ else
+ y = a + t * (b - a)
+ end
+
+ return y
+end
+
+local __common_signed_conversion = function (x, size)
+ x = __math_floor(x) & (1 << size) - 1
+ return x - ((x & (1 << (size - 1))) << 1)
+end
+
+local __common_unsigned_conversion = function (x, size)
+ return __math_floor(x) & (1 << size) - 1
+end
+
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `s8` range
+--- - `[-128, 127]`
+function math.s8(x)
+ return __common_signed_conversion(x, 8)
+end
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `s16` range
+--- - `[-32768, 32767]`
+function math.s16(x)
+ return __common_signed_conversion(x, 16)
+end
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `s32` range
+--- - `[-2147483648, 2147483647]`
+function math.s32(x)
+ return __common_signed_conversion(x, 32)
+end
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `u8` range
+--- - `[0, 255]`
+function math.u8(x)
+ return __common_unsigned_conversion(x, 8)
+end
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `u16` range
+--- - `[0, 65535]`
+function math.u16(x)
+ return __common_unsigned_conversion(x, 16)
+end
+--- @param x number
+--- @return integer
+--- Converts `x` into a valid `u32` range
+--- - `[0, 4294967295]`
+function math.u32(x)
+ return __common_unsigned_conversion(x, 32)
+end
diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua
index 03f35d4dd..bddc8c247 100644
--- a/autogen/lua_definitions/constants.lua
+++ b/autogen/lua_definitions/constants.lua
@@ -81,72 +81,6 @@ function SOUND_ARG_LOAD(bank, soundID, priority, flags)
)
end
--------------
--- courses --
--------------
-
---- @type integer
-COURSE_NONE = 0
---- @type integer
-COURSE_BOB = 1
---- @type integer
-COURSE_WF = 2
---- @type integer
-COURSE_JRB = 3
---- @type integer
-COURSE_CCM = 4
---- @type integer
-COURSE_BBH = 5
---- @type integer
-COURSE_HMC = 6
---- @type integer
-COURSE_LLL = 7
---- @type integer
-COURSE_SSL = 8
---- @type integer
-COURSE_DDD = 9
---- @type integer
-COURSE_SL = 10
---- @type integer
-COURSE_WDW = 11
---- @type integer
-COURSE_TTM = 12
---- @type integer
-COURSE_THI = 13
---- @type integer
-COURSE_TTC = 14
---- @type integer
-COURSE_RR = 15
---- @type integer
-COURSE_BITDW = 16
---- @type integer
-COURSE_BITFS = 17
---- @type integer
-COURSE_BITS = 18
---- @type integer
-COURSE_PSS = 19
---- @type integer
-COURSE_COTMC = 20
---- @type integer
-COURSE_TOTWC = 21
---- @type integer
-COURSE_VCUTM = 22
---- @type integer
-COURSE_WMOTR = 23
---- @type integer
-COURSE_SA = 24
---- @type integer
-COURSE_CAKE_END = 25
---- @type integer
-COURSE_END = 26
---- @type integer
-COURSE_MAX = 25
---- @type integer
-COURSE_COUNT = 25
---- @type integer
-COURSE_MIN = 1
-
-
------------------------------
-- player palette functions --
------------------------------
@@ -177,15 +111,11 @@ function network_player_get_override_palette_color(np, part)
return color
end
---------------------------
--- local math functions --
---------------------------
local __math_min, __math_max, __math_sqrt, __math_floor, __math_ceil, __math_cos, __math_sin, __math_pi = math.min, math.max, math.sqrt, math.floor, math.ceil, math.cos, math.sin, math.pi
------------
-- tweens --
------------
--- Unrelated to SM64, but these are for `math.tween`
---@param x number
---@return number
@@ -2404,6 +2334,69 @@ M_MOUSE_BUTTON = MOUSE_BUTTON_2
--- @type integer
R_MOUSE_BUTTON = MOUSE_BUTTON_3
+COURSE_NONE = 0 --- @type CourseNum
+COURSE_BOB = 1 --- @type CourseNum
+COURSE_WF = 2 --- @type CourseNum
+COURSE_JRB = 3 --- @type CourseNum
+COURSE_CCM = 4 --- @type CourseNum
+COURSE_BBH = 5 --- @type CourseNum
+COURSE_HMC = 6 --- @type CourseNum
+COURSE_LLL = 7 --- @type CourseNum
+COURSE_SSL = 8 --- @type CourseNum
+COURSE_DDD = 9 --- @type CourseNum
+COURSE_SL = 10 --- @type CourseNum
+COURSE_WDW = 11 --- @type CourseNum
+COURSE_TTM = 12 --- @type CourseNum
+COURSE_THI = 13 --- @type CourseNum
+COURSE_TTC = 14 --- @type CourseNum
+COURSE_RR = 15 --- @type CourseNum
+COURSE_BITDW = 16 --- @type CourseNum
+COURSE_BITFS = 17 --- @type CourseNum
+COURSE_BITS = 18 --- @type CourseNum
+COURSE_PSS = 19 --- @type CourseNum
+COURSE_COTMC = 20 --- @type CourseNum
+COURSE_TOTWC = 21 --- @type CourseNum
+COURSE_VCUTM = 22 --- @type CourseNum
+COURSE_WMOTR = 23 --- @type CourseNum
+COURSE_SA = 24 --- @type CourseNum
+COURSE_CAKE_END = 25 --- @type CourseNum
+COURSE_END = 26 --- @type CourseNum
+COURSE_COUNT = COURSE_END - 1 --- @type CourseNum
+COURSE_MAX = COURSE_COUNT --- @type CourseNum
+COURSE_MIN = 1 --- @type CourseNum
+
+--- @alias CourseNum
+--- | `COURSE_NONE`
+--- | `COURSE_BOB`
+--- | `COURSE_WF`
+--- | `COURSE_JRB`
+--- | `COURSE_CCM`
+--- | `COURSE_BBH`
+--- | `COURSE_HMC`
+--- | `COURSE_LLL`
+--- | `COURSE_SSL`
+--- | `COURSE_DDD`
+--- | `COURSE_SL`
+--- | `COURSE_WDW`
+--- | `COURSE_TTM`
+--- | `COURSE_THI`
+--- | `COURSE_TTC`
+--- | `COURSE_RR`
+--- | `COURSE_BITDW`
+--- | `COURSE_BITFS`
+--- | `COURSE_BITS`
+--- | `COURSE_PSS`
+--- | `COURSE_COTMC`
+--- | `COURSE_TOTWC`
+--- | `COURSE_VCUTM`
+--- | `COURSE_WMOTR`
+--- | `COURSE_SA`
+--- | `COURSE_CAKE_END`
+--- | `COURSE_END`
+--- | `COURSE_COUNT`
+--- | `COURSE_MAX`
+--- | `COURSE_MIN`
+
DIALOG_NONE = -1 --- @type DialogId
DIALOG_000 = 0 --- @type DialogId
DIALOG_001 = 1 --- @type DialogId
@@ -5181,6 +5174,15 @@ BOBOMB_ACT_LAVA_DEATH = 100
--- @type integer
BOBOMB_ACT_DEATH_PLANE_DEATH = 101
+COIN_TYPE_NONE = 0 --- @type CoinType
+COIN_TYPE_YELLOW = 1 --- @type CoinType
+COIN_TYPE_BLUE = 2 --- @type CoinType
+
+--- @alias CoinType
+--- | `COIN_TYPE_NONE`
+--- | `COIN_TYPE_YELLOW`
+--- | `COIN_TYPE_BLUE`
+
--- @type integer
HIDDEN_BLUE_COIN_ACT_INACTIVE = 0
diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua
index 988bb1224..240dade35 100644
--- a/autogen/lua_definitions/functions.lua
+++ b/autogen/lua_definitions/functions.lua
@@ -93,11 +93,11 @@ function spawn_wind_particles(pitch, yaw)
-- ...
end
---- @param a0 number
---- @param a1 number
+--- @param maxDistToFloor number
+--- @param distance number
--- @return integer
---- Checks if the current object is moving `a1` units over a floor and within a threshold of `a0`
-function check_if_moving_over_floor(a0, a1)
+--- Checks if the current object is moving `distance` units over a floor and within a max distance to floor of `maxDistToFloor`
+function check_if_moving_over_floor(maxDistToFloor, distance)
-- ...
end
@@ -144,8 +144,8 @@ function cur_obj_spawn_strong_wind_particles(windSpread, scale, relPosX, relPosY
-- ...
end
---- Behavior loop function for Star Door
-function bhv_star_door_loop_2()
+--- Behavior loop function for Star Door, which updates its render state
+function bhv_star_door_loop_update_render_state()
-- ...
end
@@ -319,11 +319,11 @@ function bhv_cannon_base_unused_loop()
-- ...
end
---- @param sp28 number
---- @param sp2C number
---- @param sp30 integer
---- Common behavior for when Mario's anchoring when grabbed
-function common_anchor_mario_behavior(sp28, sp2C, sp30)
+--- @param forwardVel number
+--- @param upwardsVel number
+--- @param interactStatusFlags integer
+--- Common behavior for an object when grabbing Mario. Used by King Bob-omb and Chuckya anchor objects. When Mario is thrown, sets `forwardVel`, `upwardsVel` and `interactStatusFlags` to him
+function common_anchor_mario_behavior(forwardVel, upwardsVel, interactStatusFlags)
-- ...
end
@@ -8275,13 +8275,6 @@ function set_yoshi_as_not_dead()
-- ...
end
---- @param f number
---- @return number
---- Absolute value (always positive) function
-function absf_2(f)
- -- ...
-end
-
--- @param objNewX number
--- @param objY number
--- @param objNewZ number
@@ -8947,10 +8940,10 @@ function set_room_override(room)
-- ...
end
---- @param a0 Mat4
---- @param a1 Object
+--- @param mtx Mat4
+--- @param obj Object
--- Updates an object's position based on a parent transformation matrix
-function obj_update_pos_from_parent_transformation(a0, a1)
+function obj_update_pos_from_parent_transformation(mtx, obj)
-- ...
end
@@ -8962,11 +8955,11 @@ function obj_apply_scale_to_matrix(obj, dst, src)
-- ...
end
---- @param a0 Mat4
---- @param a1 Mat4
---- @param a2 Mat4
+--- @param dest Mat4
+--- @param src1 Mat4
+--- @param src2 Mat4
--- Combines two transformation matrices into a single result matrix
-function create_transformation_from_matrices(a0, a1, a2)
+function create_transformation_from_matrices(dest, src1, src2)
-- ...
end
@@ -9350,11 +9343,6 @@ function cur_obj_set_pos_relative_to_parent(dleft, dy, dforward)
-- ...
end
---- Alternative function that enables rendering for the current object
-function cur_obj_enable_rendering_2()
- -- ...
-end
-
--- Unused function that initializes the current object on the floor
function cur_obj_unused_init_on_floor()
-- ...
@@ -9513,17 +9501,17 @@ function mario_is_dive_sliding(m)
-- ...
end
---- @param sp18 number
---- @param sp1C integer
+--- @param velY number
+--- @param animIndex integer
--- Sets the current object's vertical velocity and initializes an animation
-function cur_obj_set_y_vel_and_animation(sp18, sp1C)
+function cur_obj_set_y_vel_and_animation(velY, animIndex)
-- ...
end
---- @param sp18 integer
---- @param sp1C integer
---- Disables rendering, makes intangible, and resets action and animation
-function cur_obj_unrender_and_reset_state(sp18, sp1C)
+--- @param animIndex integer
+--- @param action integer
+--- Disables rendering, makes intangible, and resets animation and action
+function cur_obj_unrender_and_reset_state(animIndex, action)
-- ...
end
@@ -9783,11 +9771,11 @@ function cur_obj_start_cam_event(obj, cameraEvent)
-- ...
end
---- @param sp0 integer
---- @param sp4 integer
---- @param sp8 number
---- Sets Mario's interact status to hoot-grabbed if Mario is within range
-function set_mario_interact_hoot_if_in_range(sp0, sp4, sp8)
+--- @param unused1 integer
+--- @param unused2 integer
+--- @param maxDistanceToMario number
+--- Sets Mario's interact status to hoot-grabbed if Mario is within range `maxDistanceToMario`
+function set_mario_interact_hoot_if_in_range(unused1, unused2, maxDistanceToMario)
-- ...
end
@@ -9840,29 +9828,29 @@ end
--- @param obj Object
--- @param numCoins integer
---- @param sp30 number
+--- @param baseYVel number
--- @param coinBehavior Pointer_BehaviorScript
--- @param posJitter integer
--- @param model integer
--- Spawns loot coins from an object using the specified behavior, jitter, and model
-function obj_spawn_loot_coins(obj, numCoins, sp30, coinBehavior, posJitter, model)
+function obj_spawn_loot_coins(obj, numCoins, baseYVel, coinBehavior, posJitter, model)
-- ...
end
--- @param obj Object
--- @param numCoins integer
---- @param sp28 number
+--- @param baseYVel number
--- @param posJitter integer
--- Spawns blue loot coins from an object
-function obj_spawn_loot_blue_coins(obj, numCoins, sp28, posJitter)
+function obj_spawn_loot_blue_coins(obj, numCoins, baseYVel, posJitter)
-- ...
end
--- @param obj Object
--- @param numCoins integer
---- @param sp28 number
+--- @param baseYVel number
--- Spawns yellow loot coins from an object
-function obj_spawn_loot_yellow_coins(obj, numCoins, sp28)
+function obj_spawn_loot_yellow_coins(obj, numCoins, baseYVel)
-- ...
end
@@ -10049,9 +10037,9 @@ function obj_translate_xz_random(obj, rangeLength)
-- ...
end
---- @param a0 Object
+--- @param obj Object
--- Builds the object's world velocity from its transform basis vectors
-function obj_build_vel_from_transform(a0)
+function obj_build_vel_from_transform(obj)
-- ...
end
@@ -10137,19 +10125,12 @@ function bhv_dust_smoke_loop()
-- ...
end
---- @param sp0 integer
---- @param sp4 integer
---- Placeholder function with no behavior
-function stub_obj_helpers_3(sp0, sp4)
- -- ...
-end
-
---- @param a0 integer
---- @param a1 integer
---- @param sp10 number
---- @param sp14 number
---- Smoothly scales the current object over time using enabled axes
-function cur_obj_scale_over_time(a0, a1, sp10, sp14)
+--- @param axes integer
+--- @param duration integer
+--- @param minScale number
+--- @param maxScale number
+--- Smoothly scales between `minScale` and `maxScale` the current object over a `duration` using enabled `axes` (1 = x, 2 = y, 4 = z, can be combined)
+function cur_obj_scale_over_time(axes, duration, minScale, maxScale)
-- ...
end
@@ -10158,11 +10139,6 @@ function cur_obj_set_pos_to_home_with_debug()
-- ...
end
---- Placeholder function with no behavior
-function stub_obj_helpers_4()
- -- ...
-end
-
--- @return integer
--- Returns `TRUE` if Mario is currently standing on the current platform object
function cur_obj_is_mario_on_platform()
@@ -10183,18 +10159,18 @@ function cur_obj_shake_y_until(cycles, amount)
-- ...
end
---- @param a0 integer
+--- @param index integer
--- @return integer
--- Moves the current object up and down along a preset displacement table
-function cur_obj_move_up_and_down(a0)
+function cur_obj_move_up_and_down(index)
-- ...
end
---- @param sp20 integer
---- @param sp24 integer
+--- @param setHomeToMario integer
+--- @param unused integer
--- @return Object
--- Spawns a star object without triggering level exit behavior
-function spawn_star_with_no_lvl_exit(sp20, sp24)
+function spawn_star_with_no_lvl_exit(setHomeToMario, unused)
-- ...
end
@@ -10203,13 +10179,6 @@ function spawn_base_star_with_no_lvl_exit()
-- ...
end
---- @param a0 integer
---- @return integer
---- Returns the value at index a0 from a behavior-specific left-shift table
-function bit_shift_left(a0)
- -- ...
-end
-
--- @return integer
--- Returns `TRUE` if the current object is farther than 2000 units from every active Mario
function cur_obj_mario_far_away()
@@ -10250,10 +10219,10 @@ function cur_obj_set_hitbox_and_die_if_attacked(hitbox, deathSound, noLootCoins)
-- ...
end
---- @param sp18 number
---- @param sp1C integer
+--- @param mistSize number
+--- @param coinType CoinType
--- Explodes the current object, spawns particles, and optionally spawns coins
-function obj_explode_and_spawn_coins(sp18, sp1C)
+function obj_explode_and_spawn_coins(mistSize, coinType)
-- ...
end
@@ -10312,22 +10281,13 @@ end
--- @param m MarioState
--- @param radius number
--- @param height number
---- @param unused integer
+--- @param unused? integer
--- @return integer
--- Checks whether Mario can activate the current object's textbox within a vertical and horizontal range
function cur_obj_can_mario_activate_textbox(m, radius, height, unused)
-- ...
end
---- @param m MarioState
---- @param radius number
---- @param height number
---- @return integer
---- Wrapper that checks Mario textbox activation using a fixed unused parameter value
-function cur_obj_can_mario_activate_textbox_2(m, radius, height)
- -- ...
-end
-
--- @param m MarioState
--- @param dialogFlags integer
--- @param dialogResult integer
@@ -10480,39 +10440,61 @@ function apply_platform_displacement(o, platform)
-- ...
end
---- @param a0 integer
---- @param a1 integer
---- Queues rumble data
-function queue_rumble_data(a0, a1)
+--- @param time integer
+--- @param level integer
+--- Queues rumble data with `time` and `level`
+function queue_rumble_data(time, level)
-- ...
end
--- @param object Object
---- @param a0 integer
---- @param a1 integer
---- Queues rumble data for object, factoring in its distance from Mario
-function queue_rumble_data_object(object, a0, a1)
+--- @param time integer
+--- @param level integer
+--- Queues rumble data for object with `time` and `level`, factoring in its distance from Mario
+function queue_rumble_data_object(object, time, level)
-- ...
end
--- @param m MarioState
---- @param a0 integer
---- @param a1 integer
---- Queues rumble data for Mario
-function queue_rumble_data_mario(m, a0, a1)
+--- @param time integer
+--- @param level integer
+--- Queues rumble data with `time` and `level` only if `m` is the local Mario
+function queue_rumble_data_mario(m, time, level)
+ -- ...
+end
+
+--- @param decay integer
+--- Queues rumble `decay`
+function queue_rumble_decay(decay)
+ -- ...
+end
+
+--- @return integer
+--- Checks if rumble is finished and there is no rumble queued
+function is_rumble_finished_and_queue_empty()
-- ...
end
--- @param m MarioState
---- Resets rumble timers
+--- Resets rumble timers only if `m` is the local Mario
function reset_rumble_timers(m)
-- ...
end
--- @param m MarioState
---- @param a0 integer
---- Resets rumble timers and sets a field based on `a0`
-function reset_rumble_timers_2(m, a0)
+--- @param level integer
+--- Resets rumble timers and sets vibrate based on `level`
+function reset_rumble_timers_vibrate(m, level)
+ -- ...
+end
+
+--- Queues rumble data for submerged actions
+function queue_rumble_submerged()
+ -- ...
+end
+
+--- Cancels all currently queued rumble data
+function cancel_rumble()
-- ...
end
@@ -12448,7 +12430,7 @@ end
--- @param x number
--- @param y number
--- @param z number
---- @param objSetupFunction function
+--- @param objSetupFunction? function
--- @return Object
--- Spawns a synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
--- You can change the fields of the object in `objSetupFunction`
@@ -12461,7 +12443,7 @@ end
--- @param x number
--- @param y number
--- @param z number
---- @param objSetupFunction function
+--- @param objSetupFunction? function
--- @return Object
--- Spawns a non-synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
--- You can change the fields of the object in `objSetupFunction`
@@ -13137,13 +13119,13 @@ end
--- @param soundMagic integer
--- Plays a sound if the current object is visible
-function cur_obj_play_sound_1(soundMagic)
+function cur_obj_play_sound_if_visible(soundMagic)
-- ...
end
--- @param soundMagic integer
---- Plays a sound if the current object is visible and queues rumble for specific sounds
-function cur_obj_play_sound_2(soundMagic)
+--- Plays a sound if the current object is visible and queues rumble for the following sounds: `SOUND_OBJ_BOWSER_WALK`, `SOUND_OBJ_POUNDING_LOUD`, `SOUND_OBJ_WHOMP_LOWPRIO`
+function cur_obj_play_sound_and_rumble_if_visible(soundMagic)
-- ...
end
@@ -13154,24 +13136,6 @@ function create_sound_spawner(soundMagic)
-- ...
end
---- @param distance number
---- @return integer
---- Unused vanilla function, calculates a volume based on `distance`.
---- If `distance` is less than 500 then 127, if `distance` is greater than 1500 then 0, if `distance` is between 500 and 1500 then it ranges linearly from 60 to 124.
---- What an even more strange and confusing function
-function calc_dist_to_volume_range_1(distance)
- -- ...
-end
-
---- @param distance number
---- @return integer
---- Unused vanilla function, calculates a volume based on `distance`.
---- If `distance` is less than 1300 then 127, if `distance` is greater than 2300 then 0, if `distance` is between 1300 and 2300 then it ranges linearly from 60 to 127.
---- What a strange and confusing function
-function calc_dist_to_volume_range_2(distance)
- -- ...
-end
-
--- @param colData WallCollisionData
--- @return integer
--- Detects wall collisions at a given position and adjusts the position based on the walls found.
diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua
index 6fe50ec70..181a4b736 100644
--- a/autogen/lua_definitions/structs.lua
+++ b/autogen/lua_definitions/structs.lua
@@ -1563,6 +1563,7 @@
--- @field public oCoinUnkF4 integer
--- @field public oCoinUnkF8 integer
--- @field public oCoinUnk110 number
+--- @field public oCoinBaseYVel number
--- @field public oCoinUnk1B0 integer
--- @field public oCollisionParticleUnkF4 number
--- @field public oControllablePlatformUnkF8 integer
@@ -2266,6 +2267,9 @@
--- @field public clientMutedState VoiceChatMuteState
--- @field public playerMutedState VoiceChatMuteState
+--- @class VoicePlayerInternal
+--- @field public buffer VoiceBuffer
+
--- @class Vtx
--- @field public x number
--- @field public y number
diff --git a/data/behavior_data.c b/data/behavior_data.c
index d3b28073a..86a0a84f2 100644
--- a/data/behavior_data.c
+++ b/data/behavior_data.c
@@ -76,7 +76,7 @@ const BehaviorScript bhvStarDoor[] = {
SET_INT(oIntangibleTimer, 0),
BEGIN_LOOP(),
CALL_NATIVE(bhv_star_door_loop),
- CALL_NATIVE(bhv_star_door_loop_2),
+ CALL_NATIVE(bhv_star_door_loop_update_render_state),
CALL_NATIVE(load_object_collision_model),
END_LOOP(),
};
diff --git a/data/dynos.c.h b/data/dynos.c.h
index 82d7a2494..f178956de 100644
--- a/data/dynos.c.h
+++ b/data/dynos.c.h
@@ -68,6 +68,7 @@ u64 dynos_level_cmd_get(void *cmd, u64 offset);
void dynos_level_cmd_next(void *cmd);
void dynos_level_parse_script(const void *script, s32 (*aPreprocessFunction)(u8, void *));
void* dynos_level_get_script(s32 level);
+const void *dynos_level_get_vanilla_script(s32 level);
s32 dynos_level_get_mod_index(s32 level);
bool dynos_level_is_vanilla_level(s32 level);
Collision *dynos_level_get_collision(u32 level, u16 area);
diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h
index 0acd63350..d1f09dc8c 100644
--- a/data/dynos.cpp.h
+++ b/data/dynos.cpp.h
@@ -798,6 +798,7 @@ void DynOS_UpdateGfx();
bool DynOS_IsTransitionActive();
void DynOS_Mod_Update();
void DynOS_Mod_Shutdown();
+bool DynOS_Mod_IsShuttingDown();
//
// Gfx
@@ -829,6 +830,7 @@ s8 DynOS_Level_GetCourse(s32 aLevel);
void DynOS_Level_Override(void* originalScript, void* newScript, s32 modIndex);
void DynOS_Level_Unoverride();
const void *DynOS_Level_GetScript(s32 aLevel);
+const void *DynOS_Level_GetVanillaScript(s32 aLevel);
s32 DynOS_Level_GetModIndex(s32 aLevel);
bool DynOS_Level_IsVanillaLevel(s32 aLevel);
Collision *DynOS_Level_GetCollision(u32 aLevel, u16 aArea);
diff --git a/data/dynos_bin_behavior.cpp b/data/dynos_bin_behavior.cpp
index f6673b413..28303f5ea 100644
--- a/data/dynos_bin_behavior.cpp
+++ b/data/dynos_bin_behavior.cpp
@@ -1133,6 +1133,7 @@ s64 DynOS_Bhv_ParseBehaviorScriptConstants(const String &_Arg, bool *found) {
bhv_constant(oCoinUnkF4);
bhv_constant(oCoinUnkF8);
bhv_constant(oCoinUnk110);
+ bhv_constant(oCoinBaseYVel);
#ifndef VERSION_JP
bhv_constant(oCoinUnk1B0);
#endif
diff --git a/data/dynos_c.cpp b/data/dynos_c.cpp
index 28d6fc4ed..afd0439eb 100644
--- a/data/dynos_c.cpp
+++ b/data/dynos_c.cpp
@@ -228,6 +228,10 @@ void* dynos_level_get_script(s32 level) {
return (void *) DynOS_Level_GetScript(level);
}
+const void *dynos_level_get_vanilla_script(s32 level) {
+ return DynOS_Level_GetVanillaScript(level);
+}
+
s32 dynos_level_get_mod_index(s32 level) {
return DynOS_Level_GetModIndex(level);
}
diff --git a/data/dynos_level.cpp b/data/dynos_level.cpp
index a630fd1d7..070c24df9 100644
--- a/data/dynos_level.cpp
+++ b/data/dynos_level.cpp
@@ -21,7 +21,7 @@ extern const BehaviorScript *sWarpBhvSpawnTable[];
#define DYNOS_LEVEL_MARIO_POS_WARP_ID (-1)
-extern void *gDynosLevelScriptsOriginal[LEVEL_COUNT];
+extern const void *gDynosLevelScriptsOriginal[LEVEL_COUNT];
void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFunction)(u8, void *));
@@ -158,7 +158,7 @@ void DynOS_Level_Init() {
// Level warps
for (sDynosCurrentLevelNum = 0; sDynosCurrentLevelNum < LEVEL_COUNT; ++sDynosCurrentLevelNum) {
- sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript = gDynosLevelScriptsOriginal[sDynosCurrentLevelNum];
+ sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript = (void *) gDynosLevelScriptsOriginal[sDynosCurrentLevelNum];
sDynosLevelScripts[sDynosCurrentLevelNum].mModIndex = DYNOS_LEVEL_MOD_INDEX_VANILLA;
if (sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript) {
DynOS_Level_ParseScript(sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript, DynOS_Level_PreprocessScript);
@@ -199,7 +199,7 @@ void DynOS_Level_Unoverride() {
for (s32 i = 0; i < LEVEL_COUNT; i++) {
sDynosCurrentLevelNum = i;
sDynosLevelWarps[i].Clear();
- sDynosLevelScripts[i].mLevelScript = gDynosLevelScriptsOriginal[i];
+ sDynosLevelScripts[i].mLevelScript = (void *) gDynosLevelScriptsOriginal[i];
sDynosLevelScripts[i].mModIndex = DYNOS_LEVEL_MOD_INDEX_VANILLA;
DynOS_Level_ParseScript(sDynosLevelScripts[i].mLevelScript, DynOS_Level_PreprocessScript);
}
@@ -216,6 +216,13 @@ const void *DynOS_Level_GetScript(s32 aLevel) {
return sDynosLevelScripts[aLevel].mLevelScript;
}
+const void *DynOS_Level_GetVanillaScript(s32 aLevel) {
+ if (aLevel < LEVEL_MIN || aLevel >= LEVEL_COUNT) {
+ return NULL;
+ }
+ return (const void *) gDynosLevelScriptsOriginal[aLevel];
+}
+
s32 DynOS_Level_GetModIndex(s32 aLevel) {
if (aLevel >= CUSTOM_LEVEL_NUM_START) {
struct CustomLevelInfo* info = smlua_level_util_get_info(aLevel);
@@ -231,7 +238,7 @@ bool DynOS_Level_IsVanillaLevel(s32 aLevel) {
DynOS_Level_Init();
if (aLevel >= LEVEL_MIN && aLevel < LEVEL_COUNT) {
- return sDynosLevelScripts[aLevel].mLevelScript == gDynosLevelScriptsOriginal[aLevel];
+ return sDynosLevelScripts[aLevel].mLevelScript == (void *) gDynosLevelScriptsOriginal[aLevel];
}
return false;
}
diff --git a/data/dynos_main.cpp b/data/dynos_main.cpp
index 6d11ccb1b..0f96b9138 100644
--- a/data/dynos_main.cpp
+++ b/data/dynos_main.cpp
@@ -52,3 +52,7 @@ void DynOS_Mod_Update() {
void DynOS_Mod_Shutdown() {
sDynosModShutdown = true;
}
+
+bool DynOS_Mod_IsShuttingDown() {
+ return sDynosModShutdown;
+}
diff --git a/data/dynos_mgr_bhv.cpp b/data/dynos_mgr_bhv.cpp
index bb6aa7b86..41a7b4ee7 100644
--- a/data/dynos_mgr_bhv.cpp
+++ b/data/dynos_mgr_bhv.cpp
@@ -36,7 +36,7 @@ void DynOS_Bhv_Activate(s32 modIndex, const SysPath &aFilename, const char *aBeh
void DynOS_Bhv_ModShutdown() {
auto &_CustomBehaviorScripts = DynOS_Bhv_GetArray();
for (auto &pair : _CustomBehaviorScripts) {
- Delete(pair.second);
+ DynOS_Gfx_Free(pair.second);
}
_CustomBehaviorScripts.clear();
}
diff --git a/data/dynos_mgr_builtin.cpp b/data/dynos_mgr_builtin.cpp
index c2f8823f8..d3df37830 100644
--- a/data/dynos_mgr_builtin.cpp
+++ b/data/dynos_mgr_builtin.cpp
@@ -184,46 +184,14 @@ static const void* sDynosBuiltinScriptPtrs[] = {
define_builtin(level_main_menu_entry_1),
};
-#define define_level_original(lvl, script) (void*) script
-
-void* gDynosLevelScriptsOriginal[LEVEL_COUNT] = {
- define_level_original(0, NULL),
- define_level_original(LEVEL_UNKNOWN_1, NULL),
- define_level_original(LEVEL_UNKNOWN_2, NULL),
- define_level_original(LEVEL_UNKNOWN_3, NULL),
- define_level_original(LEVEL_BBH, level_bbh_entry),
- define_level_original(LEVEL_CCM, level_ccm_entry),
- define_level_original(LEVEL_CASTLE, level_castle_inside_entry),
- define_level_original(LEVEL_HMC, level_hmc_entry),
- define_level_original(LEVEL_SSL, level_ssl_entry),
- define_level_original(LEVEL_BOB, level_bob_entry),
- define_level_original(LEVEL_SL, level_sl_entry),
- define_level_original(LEVEL_WDW, level_wdw_entry),
- define_level_original(LEVEL_JRB, level_jrb_entry),
- define_level_original(LEVEL_THI, level_thi_entry),
- define_level_original(LEVEL_TTC, level_ttc_entry),
- define_level_original(LEVEL_RR, level_rr_entry),
- define_level_original(LEVEL_CASTLE_GROUNDS, level_castle_grounds_entry),
- define_level_original(LEVEL_BITDW, level_bitdw_entry),
- define_level_original(LEVEL_VCUTM, level_vcutm_entry),
- define_level_original(LEVEL_BITFS, level_bitfs_entry),
- define_level_original(LEVEL_SA, level_sa_entry),
- define_level_original(LEVEL_BITS, level_bits_entry),
- define_level_original(LEVEL_LLL, level_lll_entry),
- define_level_original(LEVEL_DDD, level_ddd_entry),
- define_level_original(LEVEL_WF, level_wf_entry),
- define_level_original(LEVEL_ENDING, level_ending_entry),
- define_level_original(LEVEL_CASTLE_COURTYARD, level_castle_courtyard_entry),
- define_level_original(LEVEL_PSS, level_pss_entry),
- define_level_original(LEVEL_COTMC, level_cotmc_entry),
- define_level_original(LEVEL_TOTWC, level_totwc_entry),
- define_level_original(LEVEL_BOWSER_1, level_bowser_1_entry),
- define_level_original(LEVEL_WMOTR, level_wmotr_entry),
- define_level_original(LEVEL_UNKNOWN_32, NULL),
- define_level_original(LEVEL_BOWSER_2, level_bowser_2_entry),
- define_level_original(LEVEL_BOWSER_3, level_bowser_3_entry),
- define_level_original(LEVEL_UNKNOWN_35, NULL),
- define_level_original(LEVEL_TTM, level_ttm_entry),
+const void *gDynosLevelScriptsOriginal[] = {
+ [LEVEL_NONE] = NULL,
+#define STUB_LEVEL(_0, levelNum, _2, _3, _4, _5, _6, _7, _8) [levelNum] = NULL,
+#define DEFINE_LEVEL(_0, levelNum, _2, folder, _4, _5, _6, _7, _8, _9, _10) \
+ [levelNum] = level_ ## folder ## _entry,
+#include "levels/level_defines.h"
+#undef STUB_LEVEL
+#undef DEFINE_LEVEL
};
const void* DynOS_Builtin_ScriptPtr_GetFromName(const char* aDataName) {
@@ -1398,12 +1366,13 @@ static void *geo_rotate_3d_coin(s32 callContext, void *node, UNUSED void *c) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct {
- const char *name;
+ const char *names[2];
const void *func;
u8 type;
} DynosBuiltinFunction;
-#define define_builtin_function(_func, _type) { .name = #_func, .func = (const void *) _func, .type = _type }
+#define define_builtin_function(_func, _type) { .names = {#_func, NULL}, .func = (const void *) _func, .type = _type }
+#define define_builtin_function_renamed(_func, _oldName, _type) { .names = {#_func, #_oldName}, .func = (const void *) _func, .type = _type }
static const DynosBuiltinFunction sDynosBuiltinFuncs[] = {
define_builtin_function(geo_mirror_mario_set_alpha, FUNCTION_GEO),
@@ -1452,7 +1421,7 @@ static const DynosBuiltinFunction sDynosBuiltinFuncs[] = {
define_builtin_function(geo_snufit_move_mask, FUNCTION_GEO),
define_builtin_function(geo_snufit_scale_body, FUNCTION_GEO),
define_builtin_function(geo_scale_bowser_key, FUNCTION_GEO),
- { .name = "geo_rotate_coin", .func = (const void *) geo_rotate_3d_coin, .type = FUNCTION_GEO },
+ define_builtin_function_renamed(geo_rotate_3d_coin, geo_rotate_coin, FUNCTION_GEO),
define_builtin_function(geo_offset_klepto_held_object, FUNCTION_GEO),
define_builtin_function(geo_switch_peach_eyes, FUNCTION_GEO),
@@ -1470,7 +1439,7 @@ static const DynosBuiltinFunction sDynosBuiltinFuncs[] = {
define_builtin_function(bhv_door_init, FUNCTION_BHV),
define_builtin_function(bhv_door_loop, FUNCTION_BHV),
define_builtin_function(bhv_star_door_loop, FUNCTION_BHV),
- define_builtin_function(bhv_star_door_loop_2, FUNCTION_BHV),
+ define_builtin_function_renamed(bhv_star_door_loop_update_render_state, bhv_star_door_loop_2, FUNCTION_BHV),
define_builtin_function(bhv_mr_i_loop, FUNCTION_BHV),
define_builtin_function(bhv_mr_i_body_loop, FUNCTION_BHV),
define_builtin_function(bhv_mr_i_particle_loop, FUNCTION_BHV),
@@ -2047,9 +2016,16 @@ static const char *sDynosBuiltinFuncTypeNames[] = {
[FUNCTION_LVL] = "level script",
};
+static inline bool DynOS_Builtin_Func_HasName(const DynosBuiltinFunction &aBuiltinFunc, const char *aDataName) {
+ return aDataName != NULL && (
+ (aBuiltinFunc.names[0] != NULL && strcmp(aBuiltinFunc.names[0], aDataName) == 0) ||
+ (aBuiltinFunc.names[1] != NULL && strcmp(aBuiltinFunc.names[1], aDataName) == 0)
+ );
+}
+
const void* DynOS_Builtin_Func_GetFromName(const char* aDataName, u8 aFuncType) {
for (const auto &builtinFunc : sDynosBuiltinFuncs) {
- if (builtinFunc.type == aFuncType && strcmp(builtinFunc.name, aDataName) == 0) {
+ if (builtinFunc.type == aFuncType && DynOS_Builtin_Func_HasName(builtinFunc, aDataName)) {
return builtinFunc.func;
}
}
@@ -2067,7 +2043,7 @@ const char *DynOS_Builtin_Func_GetNameFromIndex(s32 aIndex, u8 aFuncType) {
s32 count = (s32) (sizeof(sDynosBuiltinFuncs) / sizeof(sDynosBuiltinFuncs[0]));
if (aIndex < 0 || aIndex >= count) { return NULL; }
if (sDynosBuiltinFuncs[aIndex].type != aFuncType) { return NULL; }
- return sDynosBuiltinFuncs[aIndex].name;
+ return sDynosBuiltinFuncs[aIndex].names[0];
}
s32 DynOS_Builtin_Func_GetIndexFromData(const void* aData, u8 aFuncType) {
@@ -2086,10 +2062,11 @@ static String DynOS_Builtin_Func_CheckMisuse_Internal(s32 aIndex, const char* aD
for (s32 i = 0; i < count; ++i) {
const auto &builtinFunc = sDynosBuiltinFuncs[i];
if (aFuncType != builtinFunc.type && (
- aIndex == i || (aDataName && strcmp(aDataName, builtinFunc.name) == 0) || aData == builtinFunc.func)) {
+ aIndex == i || DynOS_Builtin_Func_HasName(builtinFunc, aDataName) || aData == builtinFunc.func)
+ ) {
return String(
"Invalid use of %s function in %s: %s",
- builtinFunc.name,
+ builtinFunc.names[0],
sDynosBuiltinFuncTypeNames[builtinFunc.type],
sDynosBuiltinFuncTypeNames[aFuncType]
);
diff --git a/data/dynos_mgr_gfx.cpp b/data/dynos_mgr_gfx.cpp
index af87e7e29..42ce7df3a 100644
--- a/data/dynos_mgr_gfx.cpp
+++ b/data/dynos_mgr_gfx.cpp
@@ -350,7 +350,7 @@ void DynOS_Gfx_ModShutdown() {
sModsDisplayLists.Clear();
sModsVertexBuffers.Clear();
- // Restore vanilla display lists
+ // Restore vanilla display lists and vertices
for (auto &it : sRomToRamGfxVtxMap) {
const void *original = it.second.gfxCopy ? it.second.gfxCopy : it.first;
void *duplicate = it.second.duplicate;
diff --git a/data/dynos_mgr_lvl.cpp b/data/dynos_mgr_lvl.cpp
index fbcc6eb82..858828f27 100644
--- a/data/dynos_mgr_lvl.cpp
+++ b/data/dynos_mgr_lvl.cpp
@@ -1,7 +1,9 @@
#include "dynos.cpp.h"
extern "C" {
+#include "include/level_table.h"
#include "engine/level_script.h"
+#include "game/level_update.h"
#include "game/skybox.h"
}
@@ -41,7 +43,7 @@ void DynOS_Lvl_ModShutdown() {
if (!_CustomLevelScripts.empty()) {
for (auto& pair : _CustomLevelScripts) {
DynOS_Tex_Invalid(pair.second);
- Delete(pair.second);
+ DynOS_Gfx_Free(pair.second);
}
_CustomLevelScripts.clear();
}
@@ -173,12 +175,17 @@ double_break:
}
void *DynOS_Lvl_Override(void *aCmd) {
+ static bool sLevelIsVanilla = true;
+
auto& _OverrideLevelScripts = DynosOverrideLevelScripts();
for (auto& overrideStruct : _OverrideLevelScripts) {
if (aCmd == overrideStruct.originalScript || aCmd == overrideStruct.newScript) {
- aCmd = (void*)overrideStruct.newScript;
+ if (!DynOS_Mod_IsShuttingDown()) {
+ aCmd = (void*)overrideStruct.newScript;
+ }
gLevelScriptModIndex = overrideStruct.gfxData->mModIndex;
gLevelScriptActive = (LevelScript*)aCmd;
+ sLevelIsVanilla = false;
}
}
@@ -189,9 +196,29 @@ void *DynOS_Lvl_Override(void *aCmd) {
if (aCmd == s->mData) {
gLevelScriptModIndex = script.second->mModIndex;
gLevelScriptActive = (LevelScript*)aCmd;
+ sLevelIsVanilla = false;
}
}
}
+ for (u16 i = 0; i < LEVEL_COUNT; ++i) {
+ const void *vanillaScript = DynOS_Level_GetVanillaScript(i);
+ if (vanillaScript == aCmd) {
+ gLevelScriptModIndex = -1;
+ gLevelScriptActive = (LevelScript*)aCmd;
+ sLevelIsVanilla = true;
+ break;
+ }
+ }
+
+ // Evict the VM from any custom level scripts because we're about to delete them
+ if (DynOS_Mod_IsShuttingDown() && !sLevelIsVanilla) {
+ LevelScript *vanillaScript = (LevelScript *) DynOS_Level_GetVanillaScript(get_menu_level());
+ gLevelScriptModIndex = -1;
+ gLevelScriptActive = vanillaScript;
+ sLevelIsVanilla = true;
+ return vanillaScript;
+ }
+
return aCmd;
}
diff --git a/data/dynos_mgr_movtexqc.cpp b/data/dynos_mgr_movtexqc.cpp
index ede5daee3..b880ff3b8 100644
--- a/data/dynos_mgr_movtexqc.cpp
+++ b/data/dynos_mgr_movtexqc.cpp
@@ -70,8 +70,5 @@ DataNode* DynOS_MovtexQC_GetFromIndex(s32 index) {
void DynOS_MovtexQC_ModShutdown() {
auto& _DynosRegisteredMovtexQCs = DynosRegisteredMovtexQCs();
- for (auto ®istered : _DynosRegisteredMovtexQCs) {
- Delete(registered.dataNode);
- }
_DynosRegisteredMovtexQCs.clear();
}
diff --git a/docs/c/sections/smlua.md b/docs/c/sections/smlua.md
index 39632006a..e1661068f 100644
--- a/docs/c/sections/smlua.md
+++ b/docs/c/sections/smlua.md
@@ -2,22 +2,20 @@
# SMLua
-SMLua is what allows Lua to communicate with SM64. It's the backbone of the modding api, and it contains multiple features that makes development in C convenient.
+SMLua is what allows Lua to communicate with SM64. It's the backbone of the modding API, and it contains multiple features that makes development in C convenient.
## Autogen
-Autogen is the system in place to allow C functions to be generated into Lua functions automatically.
+Autogen is the system in place to allow C constants, functions and structs to be exposed to the Lua API automatically.
Autogen can be ran by running `autogen/autogen.sh` in the root directory of your project.
-Autogen needs to be ran for a variety of reasons:
-
-- Anytime a function's name, parameter, or description is changed
-- Anytime a struct's name, or variable is changed
-- Anytime a enum's name, or contents is changed
-- Anytime a new function or struct is added
-- Anytime a hook event is added or modified
-- And much more
+Autogen may need a rerun when changes are made to:
+- Functions
+- Structs
+- Enums
+- Hooks
+- etc.
## Adding functions, structs, and constants to autogen
@@ -27,23 +25,37 @@ Constants, functions, and structs are each handled in their own files.
- `convert_functions.py`
- `convert_structs.py`
-Each file is laid out differently to account for their own needs, the only thing that's the same in each is `in_files`, which tells autogen to look for functions, constants, or structs in a specific file
+But thankfully, one does not need to know how it works but rather focus on a single file: `exposed_lists.py`.
+In this file, you will find numerous options sorted in three categories: `constants`, `functions` and `structs`.
+Note that all `whitelist`, `blacklist` and `hidden` dicts support regular expressions.
### Constants
-Constants is the least used one, so it has the least to go over.
+Let's start with the constants options:
-- `exclude_constants` tells autogen to ignore specific constants. For instance, in `djui_console.h`, we don't want to include `CONSOLE_MAX_TMP_BUFFER`, Lua has no need for that constant, so we exclude it.
-- `include_constants` tells autogen to add specific constants, and ignore every other constant in that file. For instance, in `mod_storage.h`, there's a bunch of constants we don't want exposed to Lua, so instead of excluding them, we include the few we actually need.
+- `constants_files` defines in which files autogen should look into to expose constants.
+ All filepaths are relative to the root of the repository.
+- `constants_whitelist` defines for each file which constants should be exposed and ignore every other constant in that file.
+ For example, in `mod_storage.h`, there's a bunch of constants we don't want exposed to Lua, so instead of excluding them, we include the few we actually need.
+- `constants_blacklist` defines for each file which constants should not be exposed.
+ For example, in `djui_console.h`, we don't want to include `CONSOLE_MAX_TMP_BUFFER`, Lua has no need for that constant, so we exclude it.
+- `constants_hidden` defines for each file which constants should be exposed, but not appear in the documentation.
+ It is usually done for deprecated constants or ones that have a temporary or placeholder name but some mods already use them, so they can't be removed completely.
+ For example, in `interaction.h`, `INTERACT_UNKNOWN_08` is not a very explicit name, but since mods use it, it must exist in the API.
### Functions
Functions have quite a bit of options, so let's go over it:
-- `override_allowed_functions` is similar to `include_constants`, it tells autogen to add specific functions and ignore all other functions in the file. It proves especially useful for functions since frequently files contains tons of functions that shouldn't be exposed to Lua.
-- `override_disallowed_functions` is similar to `exclude_constants`, it tells autogen to ignore specific functions.
-- `override_hide_functions` tells autogen to not document the function. It still exists in SMLua, and Lua can call it, but it can't see it. This is typically used for deprecated functions.
-- `override_function_version_excludes` excludes functions from a specific version of the game. It doesn't have too much of a use anymore, so you can ignore it.
+- `functions_files` defines in which files autogen should look into to expose functions.
+ All filepaths are relative to the root of the repository.
+- `functions_whitelist` defines for each file which functions should be exposed and ignore every other function in that file.
+ It proves especially useful for functions since frequently files contains tons of functions that shouldn't be exposed to Lua.
+- `functions_blacklist` defines for each file which functions should not be exposed.
+- `functions_hidden` defines for each file which functions should be exposed, but not appear in the documentation.
+ This is typically used for deprecated or renamed functions.
+- `functions_version_excludes` excludes functions from a specific version of the game.
+ It doesn't have too much of a use anymore, so you can ignore it.
Functions have a unique feature of being able to be documented. In a header file where autogen reads the function and generates documentation and generates an SMLua implementation, you can define a description for the function above it. An example of it and the syntax is as the following:
@@ -66,13 +78,22 @@ s32 is_anim_at_end(struct MarioState *m);
Structs have the most options, so let's go through it:
-- `override_field_types` changes the type of a field in a struct to something else. It pretty much lies to lua about what it actually is. This usually isn't useful, but in specific scenarios it can be.
-- `override_field_mutable` tells autogen to make a specific field mutable and also make every other field immutable.
-- `override_field_invisible` tells autogen to hide a field from Lua. Unlike `override_hide_functions`, it makes the value not accessible at all.
-- `override_field_deprecated` tells autogen to mark certain fields as deprecated.
-- `override_field_immutable` tells autogen to make certain fields immutable.
-- `override_field_version_excludes` tells autogen to exclude specific fields depending on your version. Similarly to `override_function_version_excludes`, it doesn't have too much of a use anymore, so you can ignore it.
-- `override_allowed_structs` tells autogen to make specific structs visible and tangible to Lua, but remove all other structs from Lua.
+- `structs_files` defines in which files autogen should look into to expose structs.
+ All filepaths are relative to the root of the repository.
+- `structs_whitelist` defines for each file which structs should be exposed and ignore every other struct in that file.
+- `structs_blacklist` defines for each file which structs should not be exposed at all.
+- `structs_excluded` is a list of struct names that should never be exposed from any file, including as another struct fields.
+- `structs_fields_whitelist` defines for each struct which fields should be exposed and ignore every other field in that struct.
+- `structs_fields_blacklist` defines for each struct which fields should not be exposed to Lua.
+- `structs_fields_hidden` defines for each struct which fields should be exposed, but not appear in the documentation.
+ Like constants and functions, this is usually done for deprecated or renamed fields.
+- `structs_fields_version_excludes` tells autogen to exclude specific fields depending on your version.
+ Similarly to `functions_version_excludes`, it doesn't have too much of a use anymore, so you can ignore it.
+- `structs_fields_types` changes the type of a field in a struct to something else.
+ It pretty much lies to Lua about what it actually is. This usually isn't useful, but in specific scenarios it can be.
+- `structs_fields_mutable` defines which fields should be mutable (read and write), but turn every other field of the struct immutable (read-only).
+- `structs_fields_immutable` defines which fields should be immutable (read-only).
+ By default, all fields are mutable, except pointers.
## Hook Events
@@ -105,7 +126,7 @@ enum LuaHookedEventReturn {
- `HOOK_RETURN_ON_SUCCESSFUL_CALL` should be used if you don't want any other mods to use a hook call if the call succeeds for the first mod handling it. It's only used a few times, but it can come in handy.
- `HOOK_RETURN_ON_OUTPUT_SET` should be used if you don't want any mod to access a hook that had it's output set by Lua.
- If these 3 hook return types don't cover what you are looking for, you need to make a custom implementation, mark this parameter with an `_` if you want to do a custom implementation.
-- Every argument after is the parameters and return values for Lua, and they are optional. Parameters come first, insert the parameters you want Lua to receive, for instance, `struct MarioState* m` to allow Lua to receive a mario state in the hook event call.
+- Every argument after is the parameters and return values for Lua, and they are optional. Parameters come first, insert the parameters you want Lua to receive, for instance, `struct MarioState *m` to allow Lua to receive a mario state in the hook event call.
- After parameters comes output, or return values. This is optional. To define an output parameter, use the `OUTPUT` macro.
- Here is an example hook showcasing this:
@@ -128,4 +149,4 @@ smlua_call_event_hooks(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_LAVA_WALL, &all
- The output should be a reference so the function can properly set the variable.
- If Lua doesn't return anything, the output passed into the function stays as what it was originally, so it serves as a default value. That's why `allowHazard` is set to true.
-After all these changes, remember to rerun autogen. Once that's done, you should have your hook into the game, test it and make sure everything works!
\ No newline at end of file
+After all these changes, remember to rerun autogen. Once that's done, you should have your hook into the game, test it and make sure everything works!
diff --git a/docs/lua/constants.md b/docs/lua/constants.md
index 01af148c1..08ed81095 100644
--- a/docs/lua/constants.md
+++ b/docs/lua/constants.md
@@ -11,6 +11,8 @@
- [enum CharacterType](#enum-CharacterType)
- [enum CharacterSound](#enum-CharacterSound)
- [controller_mouse.h](#controller_mouseh)
+- [course_defines.h](#course_definesh)
+ - [enum CourseNum](#enum-CourseNum)
- [dialog_ids.h](#dialog_idsh)
- [enum DialogId](#enum-DialogId)
- [djui_console.h](#djui_consoleh)
@@ -70,6 +72,7 @@
- [obj_behaviors.c](#obj_behaviorsc)
- [obj_behaviors_2.h](#obj_behaviors_2h)
- [object_constants.h](#object_constantsh)
+ - [enum CoinType](#enum-CoinType)
- [object_list_processor.h](#object_list_processorh)
- [enum ObjectList](#enum-ObjectList)
- [os_cont.h](#os_conth)
@@ -960,6 +963,46 @@
+## [course_defines.h](#course_defines.h)
+
+### [enum CourseNum](#CourseNum)
+| Identifier | Value |
+| :--------- | :---- |
+| COURSE_NONE | 0 |
+| COURSE_BOB | 1 |
+| COURSE_WF | 2 |
+| COURSE_JRB | 3 |
+| COURSE_CCM | 4 |
+| COURSE_BBH | 5 |
+| COURSE_HMC | 6 |
+| COURSE_LLL | 7 |
+| COURSE_SSL | 8 |
+| COURSE_DDD | 9 |
+| COURSE_SL | 10 |
+| COURSE_WDW | 11 |
+| COURSE_TTM | 12 |
+| COURSE_THI | 13 |
+| COURSE_TTC | 14 |
+| COURSE_RR | 15 |
+| COURSE_BITDW | 16 |
+| COURSE_BITFS | 17 |
+| COURSE_BITS | 18 |
+| COURSE_PSS | 19 |
+| COURSE_COTMC | 20 |
+| COURSE_TOTWC | 21 |
+| COURSE_VCUTM | 22 |
+| COURSE_WMOTR | 23 |
+| COURSE_SA | 24 |
+| COURSE_CAKE_END | 25 |
+| COURSE_END | 26 |
+| COURSE_COUNT | COURSE_END - 1 |
+| COURSE_MAX | COURSE_COUNT |
+| COURSE_MIN | 1 |
+
+[:arrow_up_small:](#)
+
+
+
## [dialog_ids.h](#dialog_ids.h)
### [enum DialogId](#DialogId)
@@ -2428,6 +2471,13 @@
- BOBOMB_ACT_EXPLODE
- BOBOMB_ACT_LAVA_DEATH
- BOBOMB_ACT_DEATH_PLANE_DEATH
+
+### [enum CoinType](#CoinType)
+| Identifier | Value |
+| :--------- | :---- |
+| COIN_TYPE_NONE | 0 |
+| COIN_TYPE_YELLOW | 1 |
+| COIN_TYPE_BLUE | 2 |
- HIDDEN_BLUE_COIN_ACT_INACTIVE
- HIDDEN_BLUE_COIN_ACT_WAITING
- HIDDEN_BLUE_COIN_ACT_ACTIVE
diff --git a/docs/lua/examples/behavior-ball.lua b/docs/lua/examples/behavior-ball.lua
index ed6d76765..5ca1adb12 100644
--- a/docs/lua/examples/behavior-ball.lua
+++ b/docs/lua/examples/behavior-ball.lua
@@ -58,10 +58,10 @@ function bhv_ball_loop(obj)
-- play sounds
if stepRc == 1 then
- cur_obj_play_sound_2(SOUND_GENERAL_BOX_LANDING_2)
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOX_LANDING_2)
elseif (stepRc & 1) ~= 0 then
if obj.oForwardVel > 20.0 then
- cur_obj_play_sound_2(SOUND_ENV_SLIDING)
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ENV_SLIDING)
end
end
diff --git a/docs/lua/functions-2.md b/docs/lua/functions-2.md
index 9cad9f1e8..d1391d3f6 100644
--- a/docs/lua/functions-2.md
+++ b/docs/lua/functions-2.md
@@ -158,22 +158,22 @@ Spawns wind particles around the current object
## [check_if_moving_over_floor](#check_if_moving_over_floor)
### Description
-Checks if the current object is moving `a1` units over a floor and within a threshold of `a0`
+Checks if the current object is moving `distance` units over a floor and within a max distance to floor of `maxDistToFloor`
### Lua Example
-`local integerValue = check_if_moving_over_floor(a0, a1)`
+`local integerValue = check_if_moving_over_floor(maxDistToFloor, distance)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | `number` |
-| a1 | `number` |
+| maxDistToFloor | `number` |
+| distance | `number` |
### Returns
- `integer`
### C Prototype
-`s32 check_if_moving_over_floor(f32 a0, f32 a1);`
+`s32 check_if_moving_over_floor(f32 maxDistToFloor, f32 distance);`
[:arrow_up_small:](#)
@@ -305,13 +305,13 @@ Spawns strong wind particles relative to the current object
-## [bhv_star_door_loop_2](#bhv_star_door_loop_2)
+## [bhv_star_door_loop_update_render_state](#bhv_star_door_loop_update_render_state)
### Description
-Behavior loop function for Star Door
+Behavior loop function for Star Door, which updates its render state
### Lua Example
-`bhv_star_door_loop_2()`
+`bhv_star_door_loop_update_render_state()`
### Parameters
- None
@@ -320,7 +320,7 @@ Behavior loop function for Star Door
- None
### C Prototype
-`void bhv_star_door_loop_2(void);`
+`void bhv_star_door_loop_update_render_state(void);`
[:arrow_up_small:](#)
@@ -1043,23 +1043,23 @@ Behavior loop function for cannon base unused
## [common_anchor_mario_behavior](#common_anchor_mario_behavior)
### Description
-Common behavior for when Mario's anchoring when grabbed
+Common behavior for an object when grabbing Mario. Used by King Bob-omb and Chuckya anchor objects. When Mario is thrown, sets `forwardVel`, `upwardsVel` and `interactStatusFlags` to him
### Lua Example
-`common_anchor_mario_behavior(sp28, sp2C, sp30)`
+`common_anchor_mario_behavior(forwardVel, upwardsVel, interactStatusFlags)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp28 | `number` |
-| sp2C | `number` |
-| sp30 | `integer` |
+| forwardVel | `number` |
+| upwardsVel | `number` |
+| interactStatusFlags | `integer` |
### Returns
- None
### C Prototype
-`void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30);`
+`void common_anchor_mario_behavior(f32 forwardVel, f32 upwardsVel, s32 interactStatusFlags);`
[:arrow_up_small:](#)
diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md
index f8b9ab5ef..dd8e633d2 100644
--- a/docs/lua/functions-5.md
+++ b/docs/lua/functions-5.md
@@ -2909,29 +2909,6 @@ Marks Yoshi as alive
-## [absf_2](#absf_2)
-
-### Description
-Absolute value (always positive) function
-
-### Lua Example
-`local numberValue = absf_2(f)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| f | `number` |
-
-### Returns
-- `number`
-
-### C Prototype
-`f32 absf_2(f32 f);`
-
-[:arrow_up_small:](#)
-
-
-
## [obj_find_wall](#obj_find_wall)
### Description
diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md
index af00fbdfc..e827c2f9d 100644
--- a/docs/lua/functions-6.md
+++ b/docs/lua/functions-6.md
@@ -65,19 +65,19 @@ Overrides the current room Mario is in. Set to -1 to reset override
Updates an object's position based on a parent transformation matrix
### Lua Example
-`obj_update_pos_from_parent_transformation(a0, a1)`
+`obj_update_pos_from_parent_transformation(mtx, obj)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | [Mat4](structs.md#Mat4) |
-| a1 | [Object](structs.md#Object) |
+| mtx | [Mat4](structs.md#Mat4) |
+| obj | [Object](structs.md#Object) |
### Returns
- None
### C Prototype
-`void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1);`
+`void obj_update_pos_from_parent_transformation(Mat4 mtx, struct Object *obj);`
[:arrow_up_small:](#)
@@ -114,20 +114,20 @@ Applies an object's scale to a transformation matrix
Combines two transformation matrices into a single result matrix
### Lua Example
-`create_transformation_from_matrices(a0, a1, a2)`
+`create_transformation_from_matrices(dest, src1, src2)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | [Mat4](structs.md#Mat4) |
-| a1 | [Mat4](structs.md#Mat4) |
-| a2 | [Mat4](structs.md#Mat4) |
+| dest | [Mat4](structs.md#Mat4) |
+| src1 | [Mat4](structs.md#Mat4) |
+| src2 | [Mat4](structs.md#Mat4) |
### Returns
- None
### C Prototype
-`void create_transformation_from_matrices(VEC_OUT Mat4 a0, Mat4 a1, Mat4 a2);`
+`void create_transformation_from_matrices(VEC_OUT Mat4 dest, Mat4 src1, Mat4 src2);`
[:arrow_up_small:](#)
@@ -1329,27 +1329,6 @@ Sets the current object's position relative to its parent's facing direction
-## [cur_obj_enable_rendering_2](#cur_obj_enable_rendering_2)
-
-### Description
-Alternative function that enables rendering for the current object
-
-### Lua Example
-`cur_obj_enable_rendering_2()`
-
-### Parameters
-- None
-
-### Returns
-- None
-
-### C Prototype
-`void cur_obj_enable_rendering_2(void);`
-
-[:arrow_up_small:](#)
-
-
-
## [cur_obj_unused_init_on_floor](#cur_obj_unused_init_on_floor)
### Description
@@ -1896,19 +1875,19 @@ Checks if Mario is performing a dive slide action
Sets the current object's vertical velocity and initializes an animation
### Lua Example
-`cur_obj_set_y_vel_and_animation(sp18, sp1C)`
+`cur_obj_set_y_vel_and_animation(velY, animIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp18 | `number` |
-| sp1C | `integer` |
+| velY | `number` |
+| animIndex | `integer` |
### Returns
- None
### C Prototype
-`void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);`
+`void cur_obj_set_y_vel_and_animation(f32 velY, s32 animIndex);`
[:arrow_up_small:](#)
@@ -1917,22 +1896,22 @@ Sets the current object's vertical velocity and initializes an animation
## [cur_obj_unrender_and_reset_state](#cur_obj_unrender_and_reset_state)
### Description
-Disables rendering, makes intangible, and resets action and animation
+Disables rendering, makes intangible, and resets animation and action
### Lua Example
-`cur_obj_unrender_and_reset_state(sp18, sp1C)`
+`cur_obj_unrender_and_reset_state(animIndex, action)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp18 | `integer` |
-| sp1C | `integer` |
+| animIndex | `integer` |
+| action | `integer` |
### Returns
- None
### C Prototype
-`void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C);`
+`void cur_obj_unrender_and_reset_state(s32 animIndex, s32 action);`
[:arrow_up_small:](#)
@@ -2831,23 +2810,23 @@ Starts a camera event and makes the current object the secondary camera focus
## [set_mario_interact_hoot_if_in_range](#set_mario_interact_hoot_if_in_range)
### Description
-Sets Mario's interact status to hoot-grabbed if Mario is within range
+Sets Mario's interact status to hoot-grabbed if Mario is within range `maxDistanceToMario`
### Lua Example
-`set_mario_interact_hoot_if_in_range(sp0, sp4, sp8)`
+`set_mario_interact_hoot_if_in_range(unused1, unused2, maxDistanceToMario)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp0 | `integer` |
-| sp4 | `integer` |
-| sp8 | `number` |
+| unused1 | `integer` |
+| unused2 | `integer` |
+| maxDistanceToMario | `number` |
### Returns
- None
### C Prototype
-`void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8);`
+`void set_mario_interact_hoot_if_in_range(UNUSED s32 unused1, UNUSED s32 unused2, f32 maxDistanceToMario);`
[:arrow_up_small:](#)
@@ -3024,14 +3003,14 @@ Sets the current object's hurtbox radius and height
Spawns loot coins from an object using the specified behavior, jitter, and model
### Lua Example
-`obj_spawn_loot_coins(obj, numCoins, sp30, coinBehavior, posJitter, model)`
+`obj_spawn_loot_coins(obj, numCoins, baseYVel, coinBehavior, posJitter, model)`
### Parameters
| Field | Type |
| ----- | ---- |
| obj | [Object](structs.md#Object) |
| numCoins | `integer` |
-| sp30 | `number` |
+| baseYVel | `number` |
| coinBehavior | `Pointer` <`BehaviorScript`> |
| posJitter | `integer` |
| model | `integer` |
@@ -3040,7 +3019,7 @@ Spawns loot coins from an object using the specified behavior, jitter, and model
- None
### C Prototype
-`void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model);`
+`void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 baseYVel, const BehaviorScript *coinBehavior, s16 posJitter, s16 model);`
[:arrow_up_small:](#)
@@ -3052,21 +3031,21 @@ Spawns loot coins from an object using the specified behavior, jitter, and model
Spawns blue loot coins from an object
### Lua Example
-`obj_spawn_loot_blue_coins(obj, numCoins, sp28, posJitter)`
+`obj_spawn_loot_blue_coins(obj, numCoins, baseYVel, posJitter)`
### Parameters
| Field | Type |
| ----- | ---- |
| obj | [Object](structs.md#Object) |
| numCoins | `integer` |
-| sp28 | `number` |
+| baseYVel | `number` |
| posJitter | `integer` |
### Returns
- None
### C Prototype
-`void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter);`
+`void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 baseYVel, s16 posJitter);`
[:arrow_up_small:](#)
@@ -3078,20 +3057,20 @@ Spawns blue loot coins from an object
Spawns yellow loot coins from an object
### Lua Example
-`obj_spawn_loot_yellow_coins(obj, numCoins, sp28)`
+`obj_spawn_loot_yellow_coins(obj, numCoins, baseYVel)`
### Parameters
| Field | Type |
| ----- | ---- |
| obj | [Object](structs.md#Object) |
| numCoins | `integer` |
-| sp28 | `number` |
+| baseYVel | `number` |
### Returns
- None
### C Prototype
-`void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28);`
+`void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 baseYVel);`
[:arrow_up_small:](#)
@@ -3759,18 +3738,18 @@ Applies a random translation to an object on the X and Z axes
Builds the object's world velocity from its transform basis vectors
### Lua Example
-`obj_build_vel_from_transform(a0)`
+`obj_build_vel_from_transform(obj)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | [Object](structs.md#Object) |
+| obj | [Object](structs.md#Object) |
### Returns
- None
### C Prototype
-`void obj_build_vel_from_transform(struct Object *a0);`
+`void obj_build_vel_from_transform(struct Object *obj);`
[:arrow_up_small:](#)
@@ -4069,51 +4048,27 @@ Behavior loop function for dust smoke
-## [stub_obj_helpers_3](#stub_obj_helpers_3)
-
-### Description
-Placeholder function with no behavior
-
-### Lua Example
-`stub_obj_helpers_3(sp0, sp4)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| sp0 | `integer` |
-| sp4 | `integer` |
-
-### Returns
-- None
-
-### C Prototype
-`void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4);`
-
-[:arrow_up_small:](#)
-
-
-
## [cur_obj_scale_over_time](#cur_obj_scale_over_time)
### Description
-Smoothly scales the current object over time using enabled axes
+Smoothly scales between `minScale` and `maxScale` the current object over a `duration` using enabled `axes` (1 = x, 2 = y, 4 = z, can be combined)
### Lua Example
-`cur_obj_scale_over_time(a0, a1, sp10, sp14)`
+`cur_obj_scale_over_time(axes, duration, minScale, maxScale)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | `integer` |
-| a1 | `integer` |
-| sp10 | `number` |
-| sp14 | `number` |
+| axes | `integer` |
+| duration | `integer` |
+| minScale | `number` |
+| maxScale | `number` |
### Returns
- None
### C Prototype
-`void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14);`
+`void cur_obj_scale_over_time(s32 axes, s32 duration, f32 minScale, f32 maxScale);`
[:arrow_up_small:](#)
@@ -4140,27 +4095,6 @@ Moves an object to its home position while applying debug position offsets
-## [stub_obj_helpers_4](#stub_obj_helpers_4)
-
-### Description
-Placeholder function with no behavior
-
-### Lua Example
-`stub_obj_helpers_4()`
-
-### Parameters
-- None
-
-### Returns
-- None
-
-### C Prototype
-`void stub_obj_helpers_4(void);`
-
-[:arrow_up_small:](#)
-
-
-
## [cur_obj_is_mario_on_platform](#cur_obj_is_mario_on_platform)
### Description
@@ -4233,18 +4167,18 @@ Oscillates the current object vertically until a specified number of cycles pass
Moves the current object up and down along a preset displacement table
### Lua Example
-`local integerValue = cur_obj_move_up_and_down(a0)`
+`local integerValue = cur_obj_move_up_and_down(index)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | `integer` |
+| index | `integer` |
### Returns
- `integer`
### C Prototype
-`s32 cur_obj_move_up_and_down(s32 a0);`
+`s32 cur_obj_move_up_and_down(s32 index);`
[:arrow_up_small:](#)
@@ -4256,19 +4190,19 @@ Moves the current object up and down along a preset displacement table
Spawns a star object without triggering level exit behavior
### Lua Example
-`local objectValue = spawn_star_with_no_lvl_exit(sp20, sp24)`
+`local objectValue = spawn_star_with_no_lvl_exit(setHomeToMario, unused)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp20 | `integer` |
-| sp24 | `integer` |
+| setHomeToMario | `integer` |
+| unused | `integer` |
### Returns
- [Object](structs.md#Object)
### C Prototype
-`struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24);`
+`struct Object *spawn_star_with_no_lvl_exit(s32 setHomeToMario, s32 unused);`
[:arrow_up_small:](#)
@@ -4295,29 +4229,6 @@ Spawns a base star with default parameters and no level exit behavior
-## [bit_shift_left](#bit_shift_left)
-
-### Description
-Returns the value at index a0 from a behavior-specific left-shift table
-
-### Lua Example
-`local integerValue = bit_shift_left(a0)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| a0 | `integer` |
-
-### Returns
-- `integer`
-
-### C Prototype
-`s32 bit_shift_left(s32 a0);`
-
-[:arrow_up_small:](#)
-
-
-
## [cur_obj_mario_far_away](#cur_obj_mario_far_away)
### Description
@@ -4459,19 +4370,19 @@ Gives the current object a hitbox and kills it if attacked, with optional loot s
Explodes the current object, spawns particles, and optionally spawns coins
### Lua Example
-`obj_explode_and_spawn_coins(sp18, sp1C)`
+`obj_explode_and_spawn_coins(mistSize, coinType)`
### Parameters
| Field | Type |
| ----- | ---- |
-| sp18 | `number` |
-| sp1C | `integer` |
+| mistSize | `number` |
+| coinType | [enum CoinType](constants.md#enum-CoinType) |
### Returns
- None
### C Prototype
-`void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C);`
+`void obj_explode_and_spawn_coins(f32 mistSize, enum CoinType coinType);`
[:arrow_up_small:](#)
@@ -4696,32 +4607,7 @@ Checks whether Mario can activate the current object's textbox within a vertical
- `integer`
### C Prototype
-`s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused);`
-
-[:arrow_up_small:](#)
-
-
-
-## [cur_obj_can_mario_activate_textbox_2](#cur_obj_can_mario_activate_textbox_2)
-
-### Description
-Wrapper that checks Mario textbox activation using a fixed unused parameter value
-
-### Lua Example
-`local integerValue = cur_obj_can_mario_activate_textbox_2(m, radius, height)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| m | [MarioState](structs.md#MarioState) |
-| radius | `number` |
-| height | `number` |
-
-### Returns
-- `integer`
-
-### C Prototype
-`s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height);`
+`s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, OPTIONAL UNUSED s32 unused);`
[:arrow_up_small:](#)
@@ -5273,22 +5159,22 @@ Apply one frame of platform rotation to the object using the given platform
## [queue_rumble_data](#queue_rumble_data)
### Description
-Queues rumble data
+Queues rumble data with `time` and `level`
### Lua Example
-`queue_rumble_data(a0, a1)`
+`queue_rumble_data(time, level)`
### Parameters
| Field | Type |
| ----- | ---- |
-| a0 | `integer` |
-| a1 | `integer` |
+| time | `integer` |
+| level | `integer` |
### Returns
- None
### C Prototype
-`void queue_rumble_data(s16 a0, s16 a1);`
+`void queue_rumble_data(s16 time, s16 level);`
[:arrow_up_small:](#)
@@ -5297,23 +5183,23 @@ Queues rumble data
## [queue_rumble_data_object](#queue_rumble_data_object)
### Description
-Queues rumble data for object, factoring in its distance from Mario
+Queues rumble data for object with `time` and `level`, factoring in its distance from Mario
### Lua Example
-`queue_rumble_data_object(object, a0, a1)`
+`queue_rumble_data_object(object, time, level)`
### Parameters
| Field | Type |
| ----- | ---- |
| object | [Object](structs.md#Object) |
-| a0 | `integer` |
-| a1 | `integer` |
+| time | `integer` |
+| level | `integer` |
### Returns
- None
### C Prototype
-`void queue_rumble_data_object(struct Object* object, s16 a0, s16 a1);`
+`void queue_rumble_data_object(struct Object* object, s16 time, s16 level);`
[:arrow_up_small:](#)
@@ -5322,23 +5208,67 @@ Queues rumble data for object, factoring in its distance from Mario
## [queue_rumble_data_mario](#queue_rumble_data_mario)
### Description
-Queues rumble data for Mario
+Queues rumble data with `time` and `level` only if `m` is the local Mario
### Lua Example
-`queue_rumble_data_mario(m, a0, a1)`
+`queue_rumble_data_mario(m, time, level)`
### Parameters
| Field | Type |
| ----- | ---- |
| m | [MarioState](structs.md#MarioState) |
-| a0 | `integer` |
-| a1 | `integer` |
+| time | `integer` |
+| level | `integer` |
### Returns
- None
### C Prototype
-`void queue_rumble_data_mario(struct MarioState* m, s16 a0, s16 a1);`
+`void queue_rumble_data_mario(struct MarioState* m, s16 time, s16 level);`
+
+[:arrow_up_small:](#)
+
+
+
+## [queue_rumble_decay](#queue_rumble_decay)
+
+### Description
+Queues rumble `decay`
+
+### Lua Example
+`queue_rumble_decay(decay)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| decay | `integer` |
+
+### Returns
+- None
+
+### C Prototype
+`void queue_rumble_decay(s16 decay);`
+
+[:arrow_up_small:](#)
+
+
+
+## [is_rumble_finished_and_queue_empty](#is_rumble_finished_and_queue_empty)
+
+### Description
+Checks if rumble is finished and there is no rumble queued
+
+### Lua Example
+`local integerValue = is_rumble_finished_and_queue_empty()`
+
+### Parameters
+- None
+
+### Returns
+- `integer`
+
+### C Prototype
+`u8 is_rumble_finished_and_queue_empty(void);`
[:arrow_up_small:](#)
@@ -5347,7 +5277,7 @@ Queues rumble data for Mario
## [reset_rumble_timers](#reset_rumble_timers)
### Description
-Resets rumble timers
+Resets rumble timers only if `m` is the local Mario
### Lua Example
`reset_rumble_timers(m)`
@@ -5367,25 +5297,67 @@ Resets rumble timers
-## [reset_rumble_timers_2](#reset_rumble_timers_2)
+## [reset_rumble_timers_vibrate](#reset_rumble_timers_vibrate)
### Description
-Resets rumble timers and sets a field based on `a0`
+Resets rumble timers and sets vibrate based on `level`
### Lua Example
-`reset_rumble_timers_2(m, a0)`
+`reset_rumble_timers_vibrate(m, level)`
### Parameters
| Field | Type |
| ----- | ---- |
| m | [MarioState](structs.md#MarioState) |
-| a0 | `integer` |
+| level | `integer` |
### Returns
- None
### C Prototype
-`void reset_rumble_timers_2(struct MarioState* m, s32 a0);`
+`void reset_rumble_timers_vibrate(struct MarioState* m, s32 level);`
+
+[:arrow_up_small:](#)
+
+
+
+## [queue_rumble_submerged](#queue_rumble_submerged)
+
+### Description
+Queues rumble data for submerged actions
+
+### Lua Example
+`queue_rumble_submerged()`
+
+### Parameters
+- None
+
+### Returns
+- None
+
+### C Prototype
+`void queue_rumble_submerged(void);`
+
+[:arrow_up_small:](#)
+
+
+
+## [cancel_rumble](#cancel_rumble)
+
+### Description
+Cancels all currently queued rumble data
+
+### Lua Example
+`cancel_rumble()`
+
+### Parameters
+- None
+
+### Returns
+- None
+
+### C Prototype
+`void cancel_rumble(void);`
[:arrow_up_small:](#)
diff --git a/docs/lua/functions-7.md b/docs/lua/functions-7.md
index 1db23e1d9..e532a94da 100644
--- a/docs/lua/functions-7.md
+++ b/docs/lua/functions-7.md
@@ -4104,7 +4104,7 @@ You can change the fields of the object in `objSetupFunction`
- [Object](structs.md#Object)
### C Prototype
-`struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
+`struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);`
[:arrow_up_small:](#)
@@ -4133,7 +4133,7 @@ You can change the fields of the object in `objSetupFunction`
- [Object](structs.md#Object)
### C Prototype
-`struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
+`struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);`
[:arrow_up_small:](#)
@@ -6332,13 +6332,13 @@ Stops cap music completely
-## [cur_obj_play_sound_1](#cur_obj_play_sound_1)
+## [cur_obj_play_sound_if_visible](#cur_obj_play_sound_if_visible)
### Description
Plays a sound if the current object is visible
### Lua Example
-`cur_obj_play_sound_1(soundMagic)`
+`cur_obj_play_sound_if_visible(soundMagic)`
### Parameters
| Field | Type |
@@ -6349,19 +6349,19 @@ Plays a sound if the current object is visible
- None
### C Prototype
-`void cur_obj_play_sound_1(s32 soundMagic);`
+`void cur_obj_play_sound_if_visible(s32 soundMagic);`
[:arrow_up_small:](#)
-## [cur_obj_play_sound_2](#cur_obj_play_sound_2)
+## [cur_obj_play_sound_and_rumble_if_visible](#cur_obj_play_sound_and_rumble_if_visible)
### Description
-Plays a sound if the current object is visible and queues rumble for specific sounds
+Plays a sound if the current object is visible and queues rumble for the following sounds: `SOUND_OBJ_BOWSER_WALK`, `SOUND_OBJ_POUNDING_LOUD`, `SOUND_OBJ_WHOMP_LOWPRIO`
### Lua Example
-`cur_obj_play_sound_2(soundMagic)`
+`cur_obj_play_sound_and_rumble_if_visible(soundMagic)`
### Parameters
| Field | Type |
@@ -6372,7 +6372,7 @@ Plays a sound if the current object is visible and queues rumble for specific so
- None
### C Prototype
-`void cur_obj_play_sound_2(s32 soundMagic);`
+`void cur_obj_play_sound_and_rumble_if_visible(s32 soundMagic);`
[:arrow_up_small:](#)
@@ -6402,56 +6402,6 @@ Create a sound spawner for objects that need a sound play once.
-## [calc_dist_to_volume_range_1](#calc_dist_to_volume_range_1)
-
-### Description
-Unused vanilla function, calculates a volume based on `distance`.
-If `distance` is less than 500 then 127, if `distance` is greater than 1500 then 0, if `distance` is between 500 and 1500 then it ranges linearly from 60 to 124.
-What an even more strange and confusing function
-
-### Lua Example
-`local integerValue = calc_dist_to_volume_range_1(distance)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| distance | `number` |
-
-### Returns
-- `integer`
-
-### C Prototype
-`s32 calc_dist_to_volume_range_1(f32 distance);`
-
-[:arrow_up_small:](#)
-
-
-
-## [calc_dist_to_volume_range_2](#calc_dist_to_volume_range_2)
-
-### Description
-Unused vanilla function, calculates a volume based on `distance`.
-If `distance` is less than 1300 then 127, if `distance` is greater than 2300 then 0, if `distance` is between 1300 and 2300 then it ranges linearly from 60 to 127.
-What a strange and confusing function
-
-### Lua Example
-`local integerValue = calc_dist_to_volume_range_2(distance)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| distance | `number` |
-
-### Returns
-- `integer`
-
-### C Prototype
-`s32 calc_dist_to_volume_range_2(f32 distance);`
-
-[:arrow_up_small:](#)
-
-
-
---
# functions from surface_collision.h
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index 95d8edf36..b69ff0796 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -53,7 +53,7 @@
- [play_penguin_walking_sound](functions-2.md#play_penguin_walking_sound)
- [update_angle_from_move_flags](functions-2.md#update_angle_from_move_flags)
- [cur_obj_spawn_strong_wind_particles](functions-2.md#cur_obj_spawn_strong_wind_particles)
- - [bhv_star_door_loop_2](functions-2.md#bhv_star_door_loop_2)
+ - [bhv_star_door_loop_update_render_state](functions-2.md#bhv_star_door_loop_update_render_state)
- [bhv_cap_switch_loop](functions-2.md#bhv_cap_switch_loop)
- [bhv_tiny_star_particles_init](functions-2.md#bhv_tiny_star_particles_init)
- [bhv_grindel_thwomp_loop](functions-2.md#bhv_grindel_thwomp_loop)
@@ -1457,7 +1457,6 @@
- obj_behaviors.c
- [set_yoshi_as_not_dead](functions-5.md#set_yoshi_as_not_dead)
- - [absf_2](functions-5.md#absf_2)
- [obj_find_wall](functions-5.md#obj_find_wall)
- [turn_obj_away_from_steep_floor](functions-5.md#turn_obj_away_from_steep_floor)
- [obj_orient_graph](functions-5.md#obj_orient_graph)
@@ -1601,7 +1600,6 @@
- [cur_obj_hide](functions-6.md#cur_obj_hide)
- [cur_obj_set_pos_relative](functions-6.md#cur_obj_set_pos_relative)
- [cur_obj_set_pos_relative_to_parent](functions-6.md#cur_obj_set_pos_relative_to_parent)
- - [cur_obj_enable_rendering_2](functions-6.md#cur_obj_enable_rendering_2)
- [cur_obj_unused_init_on_floor](functions-6.md#cur_obj_unused_init_on_floor)
- [obj_set_face_angle_to_move_angle](functions-6.md#obj_set_face_angle_to_move_angle)
- [get_object_list_from_behavior](functions-6.md#get_object_list_from_behavior)
@@ -1721,17 +1719,14 @@
- [cur_obj_push_mario_away](functions-6.md#cur_obj_push_mario_away)
- [cur_obj_push_mario_away_from_cylinder](functions-6.md#cur_obj_push_mario_away_from_cylinder)
- [bhv_dust_smoke_loop](functions-6.md#bhv_dust_smoke_loop)
- - [stub_obj_helpers_3](functions-6.md#stub_obj_helpers_3)
- [cur_obj_scale_over_time](functions-6.md#cur_obj_scale_over_time)
- [cur_obj_set_pos_to_home_with_debug](functions-6.md#cur_obj_set_pos_to_home_with_debug)
- - [stub_obj_helpers_4](functions-6.md#stub_obj_helpers_4)
- [cur_obj_is_mario_on_platform](functions-6.md#cur_obj_is_mario_on_platform)
- [cur_obj_is_any_player_on_platform](functions-6.md#cur_obj_is_any_player_on_platform)
- [cur_obj_shake_y_until](functions-6.md#cur_obj_shake_y_until)
- [cur_obj_move_up_and_down](functions-6.md#cur_obj_move_up_and_down)
- [spawn_star_with_no_lvl_exit](functions-6.md#spawn_star_with_no_lvl_exit)
- [spawn_base_star_with_no_lvl_exit](functions-6.md#spawn_base_star_with_no_lvl_exit)
- - [bit_shift_left](functions-6.md#bit_shift_left)
- [cur_obj_mario_far_away](functions-6.md#cur_obj_mario_far_away)
- [is_mario_moving_fast_or_in_air](functions-6.md#is_mario_moving_fast_or_in_air)
- [is_item_in_array](functions-6.md#is_item_in_array)
@@ -1749,7 +1744,6 @@
- [set_time_stop_flags_if_alone](functions-6.md#set_time_stop_flags_if_alone)
- [clear_time_stop_flags](functions-6.md#clear_time_stop_flags)
- [cur_obj_can_mario_activate_textbox](functions-6.md#cur_obj_can_mario_activate_textbox)
- - [cur_obj_can_mario_activate_textbox_2](functions-6.md#cur_obj_can_mario_activate_textbox_2)
- [cur_obj_end_dialog](functions-6.md#cur_obj_end_dialog)
- [cur_obj_has_model](functions-6.md#cur_obj_has_model)
- [cur_obj_align_gfx_with_floor](functions-6.md#cur_obj_align_gfx_with_floor)
@@ -1788,8 +1782,12 @@
- [queue_rumble_data](functions-6.md#queue_rumble_data)
- [queue_rumble_data_object](functions-6.md#queue_rumble_data_object)
- [queue_rumble_data_mario](functions-6.md#queue_rumble_data_mario)
+ - [queue_rumble_decay](functions-6.md#queue_rumble_decay)
+ - [is_rumble_finished_and_queue_empty](functions-6.md#is_rumble_finished_and_queue_empty)
- [reset_rumble_timers](functions-6.md#reset_rumble_timers)
- - [reset_rumble_timers_2](functions-6.md#reset_rumble_timers_2)
+ - [reset_rumble_timers_vibrate](functions-6.md#reset_rumble_timers_vibrate)
+ - [queue_rumble_submerged](functions-6.md#queue_rumble_submerged)
+ - [cancel_rumble](functions-6.md#cancel_rumble)
@@ -2231,11 +2229,9 @@
- spawn_sound.h
- - [cur_obj_play_sound_1](functions-7.md#cur_obj_play_sound_1)
- - [cur_obj_play_sound_2](functions-7.md#cur_obj_play_sound_2)
+ - [cur_obj_play_sound_if_visible](functions-7.md#cur_obj_play_sound_if_visible)
+ - [cur_obj_play_sound_and_rumble_if_visible](functions-7.md#cur_obj_play_sound_and_rumble_if_visible)
- [create_sound_spawner](functions-7.md#create_sound_spawner)
- - [calc_dist_to_volume_range_1](functions-7.md#calc_dist_to_volume_range_1)
- - [calc_dist_to_volume_range_2](functions-7.md#calc_dist_to_volume_range_2)
diff --git a/docs/lua/guides/object-lists.md b/docs/lua/guides/object-lists.md
index 1d8a77ed8..e90ad29ed 100644
--- a/docs/lua/guides/object-lists.md
+++ b/docs/lua/guides/object-lists.md
@@ -90,7 +90,6 @@
|`bhvUnused0DFC`|`OBJ_LIST_DEFAULT`|
|`bhvMistCircParticleSpawner`|`OBJ_LIST_DEFAULT`|
|`bhvDirtParticleSpawner`|`OBJ_LIST_DEFAULT`|
-|``|`OBJ_LIST_DEFAULT`|
|`bhvSnowParticleSpawner`|`OBJ_LIST_DEFAULT`|
|`bhvWind`|`OBJ_LIST_UNIMPORTANT`|
|`bhvEndToad`|`OBJ_LIST_DEFAULT`|
@@ -106,6 +105,7 @@
|`bhvBitfsTiltingInvertedPyramid`|`OBJ_LIST_SURFACE`|
|`bhvSquishablePlatform`|`OBJ_LIST_SURFACE`|
|`bhvCutOutObject`|`OBJ_LIST_GENACTOR`|
+|`bhvBetaMovingFlamesSpawn`|`OBJ_LIST_DEFAULT`|
|`bhvBetaMovingFlames`|`OBJ_LIST_LEVEL`|
|`bhvRrRotatingBridgePlatform`|`OBJ_LIST_SURFACE`|
|`bhvFlamethrower`|`OBJ_LIST_DEFAULT`|
@@ -186,6 +186,7 @@
|`bhvLllSinkingRockBlock`|`OBJ_LIST_SURFACE`|
|`bhvStub1D70`|`OBJ_LIST_DEFAULT`|
|`bhvLllMovingOctagonalMeshPlatform`|`OBJ_LIST_SURFACE`|
+|`bhvSnowBall`|`OBJ_LIST_DEFAULT`|
|`bhvLllRotatingBlockWithFireBars`|`OBJ_LIST_SURFACE`|
|`bhvLllRotatingHexFlame`|`OBJ_LIST_LEVEL`|
|`bhvLllWoodPiece`|`OBJ_LIST_SURFACE`|
@@ -214,6 +215,7 @@
|`bhvWdwExpressElevator`|`OBJ_LIST_SURFACE`|
|`bhvWdwExpressElevatorPlatform`|`OBJ_LIST_SURFACE`|
|`bhvChirpChirp`|`OBJ_LIST_DEFAULT`|
+|`bhvChirpChirpUnused`|`OBJ_LIST_DEFAULT`|
|`bhvBub`|`OBJ_LIST_GENACTOR`|
|`bhvExclamationBox`|`OBJ_LIST_SURFACE`|
|`bhvRotatingExclamationMark`|`OBJ_LIST_DEFAULT`|
@@ -235,6 +237,7 @@
|`bhvWhitePuff2`|`OBJ_LIST_UNIMPORTANT`|
|`bhvWhitePuffSmoke2`|`OBJ_LIST_UNIMPORTANT`|
|`bhvPurpleSwitchHiddenBoxes`|`OBJ_LIST_SURFACE`|
+|`bhvBlueCoinNumber`|`OBJ_LIST_DEFAULT`|
|`bhvBlueCoinSwitch`|`OBJ_LIST_SURFACE`|
|`bhvHiddenBlueCoin`|`OBJ_LIST_LEVEL`|
|`bhvOpenableCageDoor`|`OBJ_LIST_SURFACE`|
@@ -261,6 +264,7 @@
|`bhvMeshElevator`|`OBJ_LIST_SURFACE`|
|`bhvMerryGoRound`|`OBJ_LIST_SURFACE`|
|`bhvPlaysMusicTrackWhenTouched`|`OBJ_LIST_DEFAULT`|
+|`bhvInsideCannon`|`OBJ_LIST_DEFAULT`|
|`bhvBetaBowserAnchor`|`OBJ_LIST_DESTRUCTIVE`|
|`bhvStaticCheckeredPlatform`|`OBJ_LIST_SURFACE`|
|`bhvUnused2A10`|`OBJ_LIST_DEFAULT`|
@@ -273,7 +277,6 @@
|`bhvSparkle`|`OBJ_LIST_UNIMPORTANT`|
|`bhvSparkleSpawn`|`OBJ_LIST_UNIMPORTANT`|
|`bhvSparkleParticleSpawner`|`OBJ_LIST_DEFAULT`|
-|``|`OBJ_LIST_UNIMPORTANT`|
|`bhvScuttlebug`|`OBJ_LIST_GENACTOR`|
|`bhvScuttlebugSpawn`|`OBJ_LIST_SPAWNER`|
|`bhvWhompKingBoss`|`OBJ_LIST_SURFACE`|
@@ -296,6 +299,20 @@
|`bhvMario`|`OBJ_LIST_PLAYER`|
|`bhvToadMessage`|`OBJ_LIST_GENACTOR`|
|`bhvUnlockDoorStar`|`OBJ_LIST_LEVEL`|
+|`bhvInstantActiveWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvAirborneWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvHardAirKnockBackWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvSpinAirborneCircleWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvDeathWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvSpinAirborneWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvFlyingWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvPaintingStarCollectWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvPaintingDeathWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvAirborneDeathWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvAirborneStarCollectWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvLaunchStarCollectWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvLaunchDeathWarp`|`OBJ_LIST_DEFAULT`|
+|`bhvSwimmingWarp`|`OBJ_LIST_DEFAULT`|
|`bhvRandomAnimatedTexture`|`OBJ_LIST_LEVEL`|
|`bhvYellowBackgroundInMenu`|`OBJ_LIST_LEVEL`|
|`bhvMenuButton`|`OBJ_LIST_LEVEL`|
@@ -388,6 +405,7 @@
|`bhvMetalCap`|`OBJ_LIST_LEVEL`|
|`bhvNormalCap`|`OBJ_LIST_LEVEL`|
|`bhvVanishCap`|`OBJ_LIST_LEVEL`|
+|`bhvStarNumber`|`OBJ_LIST_DEFAULT`|
|`bhvStar`|`OBJ_LIST_LEVEL`|
|`bhvStarSpawnCoordinates`|`OBJ_LIST_LEVEL`|
|`bhvHiddenRedCoinStar`|`OBJ_LIST_LEVEL`|
diff --git a/docs/lua/structs.md b/docs/lua/structs.md
index d7b08991a..394d71734 100644
--- a/docs/lua/structs.md
+++ b/docs/lua/structs.md
@@ -95,6 +95,7 @@
- [Vec4i](#Vec4i)
- [Vec4s](#Vec4s)
- [VoicePlayer](#VoicePlayer)
+- [VoicePlayerInternal](#VoicePlayerInternal)
- [Vtx](#Vtx)
- [WallCollisionData](#WallCollisionData)
- [WarpNode](#WarpNode)
@@ -2173,6 +2174,7 @@
| oCoinUnkF4 | `integer` | |
| oCoinUnkF8 | `integer` | |
| oCoinUnk110 | `number` | |
+| oCoinBaseYVel | `number` | |
| oCoinUnk1B0 | `integer` | |
| oCollisionParticleUnkF4 | `number` | |
| oControllablePlatformUnkF8 | `integer` | |
@@ -3114,6 +3116,16 @@
+## [VoicePlayerInternal](#VoicePlayerInternal)
+
+| Field | Type | Access |
+| ----- | ---- | ------ |
+| buffer | [VoiceBuffer](structs.md#VoiceBuffer) | read-only |
+
+[:arrow_up_small:](#)
+
+
+
## [Vtx](#Vtx)
| Field | Type | Access |
diff --git a/include/object_constants.h b/include/object_constants.h
index 720955e83..a44c37c9f 100644
--- a/include/object_constants.h
+++ b/include/object_constants.h
@@ -146,6 +146,13 @@
#define BOBOMB_ACT_LAVA_DEATH 100
#define BOBOMB_ACT_DEATH_PLANE_DEATH 101
+/* Coin Type */
+enum CoinType { // coinType
+ COIN_TYPE_NONE,
+ COIN_TYPE_YELLOW,
+ COIN_TYPE_BLUE
+};
+
/* Hidden Blue Coin */
/* oAction */
#define HIDDEN_BLUE_COIN_ACT_INACTIVE 0
diff --git a/include/object_fields.h b/include/object_fields.h
index fedbe1e91..f1e0e75a4 100644
--- a/include/object_fields.h
+++ b/include/object_fields.h
@@ -398,11 +398,12 @@
#define /*0x1AC*/ oCloudFwooshMovementRadius OBJECT_FIELD_S16(0x49, 0)
/* Coin */
-#define /*0x0F4*/ oCoinUnkF4 OBJECT_FIELD_S32(0x1B)
-#define /*0x0F8*/ oCoinUnkF8 OBJECT_FIELD_S32(0x1C)
-#define /*0x110*/ oCoinUnk110 OBJECT_FIELD_F32(0x22)
+#define /*0x0F4*/ oCoinUnkF4 OBJECT_FIELD_S32(0x1B)
+#define /*0x0F8*/ oCoinUnkF8 OBJECT_FIELD_S32(0x1C)
+#define /*0x110*/ oCoinUnk110 OBJECT_FIELD_F32(0x22)
+#define /*0x110*/ oCoinBaseYVel OBJECT_FIELD_F32(0x22)
#ifndef VERSION_JP
-#define /*0x1B0*/ oCoinUnk1B0 OBJECT_FIELD_S32(0x4A)
+#define /*0x1B0*/ oCoinUnk1B0 OBJECT_FIELD_S32(0x4A)
#endif
/* Collision Particle */
diff --git a/lang/Italian.ini b/lang/Italian.ini
index d60760db6..401f1a44a 100644
--- a/lang/Italian.ini
+++ b/lang/Italian.ini
@@ -198,6 +198,7 @@ FILE_SELECT_THEME = "Selezione file"
[DYNOS]
DYNOS = "DYNOS"
LOCAL_PLAYER_MODEL_ONLY = "Solo modello del giocatore locale"
+OPEN_DYNOS_FOLDER = "Apri la cartella dei DynOS"
[HOST_MESSAGE]
INFO_TITLE = "INFO"
@@ -212,6 +213,8 @@ MODS = "MOD"
CATEGORIES = "Categorie"
WARNING = "\\#ffffa0\\Attenzione:\\#dcdcdc\\ Sono state attivate 10 o più mod, disabilitane alcune per evitare instabilità o lag."
NO_MODS_FOUND = "Non è stata trovata alcuna mod."
+BROWSE_MODS = "Cerca tra le Mod"
+OPEN_MOD_FOLDER = "Apri la cartella delle Mod"
[HOST_MOD_CATEGORIES]
ALL = "Tutte"
diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c
index a41a3c5a2..127101fc5 100644
--- a/levels/castle_inside/painting.inc.c
+++ b/levels/castle_inside/painting.inc.c
@@ -1308,7 +1308,7 @@ static const Gfx inside_castle_seg7_painting_dl_070235B8[] = {
}
// 0x07023620 - 0x07023698
-struct Painting bob_painting = {
+DEFINE_PAINTING(bob_painting, {
/* id */ 0x0000,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1333,10 +1333,10 @@ struct Painting bob_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023698 - 0x07023710
-struct Painting ccm_painting = {
+DEFINE_PAINTING(ccm_painting, {
/* id */ 0x0001,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1361,10 +1361,10 @@ struct Painting ccm_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023710 - 0x07023788
-struct Painting wf_painting = {
+DEFINE_PAINTING(wf_painting, {
/* id */ 0x0002,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1389,10 +1389,10 @@ struct Painting wf_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023788 - 0x07023800
-struct Painting jrb_painting = {
+DEFINE_PAINTING(jrb_painting, {
/* id */ 0x0003,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1417,10 +1417,10 @@ struct Painting jrb_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023800 - 0x07023878
-struct Painting lll_painting = {
+DEFINE_PAINTING(lll_painting, {
/* id */ 0x0004,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1445,10 +1445,10 @@ struct Painting lll_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023878 - 0x070238F0
-struct Painting ssl_painting = {
+DEFINE_PAINTING(ssl_painting, {
/* id */ 0x0005,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1473,10 +1473,10 @@ struct Painting ssl_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x070238F0 - 0x07023968
-struct Painting hmc_painting = {
+DEFINE_PAINTING(hmc_painting, {
/* id */ 0x000E,
/* Image Count */ 0x01,
/* Texture Type */ PAINTING_ENV_MAP,
@@ -1501,10 +1501,10 @@ struct Painting hmc_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 768.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023968 - 0x070239E0
-struct Painting ddd_painting = {
+DEFINE_PAINTING(ddd_painting, {
/* id */ 0x0007,
/* Image Count */ 0x01,
/* Texture Type */ PAINTING_ENV_MAP,
@@ -1529,10 +1529,10 @@ struct Painting ddd_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 819.2f,
/* Ripples */ { 0 },
-};
+});
// 0x070239E0 - 0x07023A58
-struct Painting wdw_painting = {
+DEFINE_PAINTING(wdw_painting, {
/* id */ 0x0008,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1557,10 +1557,10 @@ struct Painting wdw_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 614.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023A58 - 0x07023AD0
-struct Painting thi_tiny_painting = {
+DEFINE_PAINTING(thi_tiny_painting, {
/* id */ 0x0009,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1585,10 +1585,10 @@ struct Painting thi_tiny_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 393.216f,
/* Ripples */ { 0 },
-};
+});
// 0x07023AD0 - 0x07023B48
-struct Painting ttm_painting = {
+DEFINE_PAINTING(ttm_painting, {
/* id */ 0x000A,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1613,10 +1613,10 @@ struct Painting ttm_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 256.0f,
/* Ripples */ { 0 },
-};
+});
// 0x07023B48 - 0x07023BC0
-struct Painting ttc_painting = {
+DEFINE_PAINTING(ttc_painting, {
/* id */ 0x000B,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1641,10 +1641,10 @@ struct Painting ttc_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 409.6f,
/* Ripples */ { 0 },
-};
+});
// 0x07023BC0 - 0x07023C38
-struct Painting sl_painting = {
+DEFINE_PAINTING(sl_painting, {
/* id */ 0x000C,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1669,10 +1669,10 @@ struct Painting sl_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 716.8f,
/* Ripples */ { 0 },
-};
+});
// 0x07023C38 - 0x07023CB0
-struct Painting thi_huge_painting = {
+DEFINE_PAINTING(thi_huge_painting, {
/* id */ 0x000D,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -1697,382 +1697,4 @@ struct Painting thi_huge_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 1638.4f,
/* Ripples */ { 0 },
-};
-
-struct Painting default_bob_painting = {
- /* id */ 0x0000,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 90.0f,
- /* Position */ -5222.4f, 409.6f, -153.6f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023050,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235C0,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_ccm_painting = {
- /* id */ 0x0001,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ -2611.2f, -307.2f, -4352.0f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070230B0,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235C8,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_wf_painting = {
- /* id */ 0x0002,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ -51.2f, -204.8f, -4505.6f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023110,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235D0,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_jrb_painting = {
- /* id */ 0x0003,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 270.0f,
- /* Position */ 4300.8f, 409.6f, -537.6f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023170,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235D8,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_lll_painting = {
- /* id */ 0x0004,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ -1689.6f, -1126.4f, -3942.4f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070231D0,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235E0,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_ssl_painting = {
- /* id */ 0x0005,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 180.0f,
- /* Position */ -2611.2f, -1177.6f, -1075.2f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023230,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235E8,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_hmc_painting = {
- /* id */ 0x000E,
- /* Image Count */ 0x01,
- /* Texture Type */ PAINTING_ENV_MAP,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 270.0f, 0.0f,
- /* Position */ 2099.2f, -1484.8f, -2278.4f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f,
- /* Ripple Decay */ 1.0f, 1.0f, 0.98f,
- /* Ripple Rate */ 0.0f, 0.05f, 0.05f,
- /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023580,
- /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044,
- /* Textures */ inside_castle_seg7_painting_textures_070235F0,
- /* Texture w, h */ 32, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07022640,
- /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 768.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_ddd_painting = {
- /* id */ 0x0007,
- /* Image Count */ 0x01,
- /* Texture Type */ PAINTING_ENV_MAP,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 270.0f,
- /* Position */ 3456.0f, -1075.2f, 1587.2f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f,
- /* Ripple Decay */ 1.0f, 1.0f, 0.98f,
- /* Ripple Rate */ 0.0f, 0.05f, 0.05f,
- /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070235B8,
- /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044,
- /* Textures */ inside_castle_seg7_painting_textures_070235F4,
- /* Texture w, h */ 32, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07022640,
- /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS,
- /* Alpha */ 0xB4,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 819.2f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_wdw_painting = {
- /* id */ 0x0008,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ -966.656f, 1305.6f, -143.36f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023290,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_070235F8,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 614.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_thi_tiny_painting = {
- /* id */ 0x0009,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 180.0f,
- /* Position */ -4598.7842f, 1354.752f, 3005.44f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070232F0,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_07023600,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 393.216f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_ttm_painting = {
- /* id */ 0x000A,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 180.0f,
- /* Position */ -546.816f, 1356.8f, 3813.376f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023350,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_07023608,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 256.0f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_ttc_painting = {
- /* id */ 0x000B,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 180.0f,
- /* Position */ 0.0f, 2713.6f, 7232.5122f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070233B0,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_07023610,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 409.6f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_sl_painting = {
- /* id */ 0x000C,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ 3179.52f, 1408.0f, -271.36f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_07023410,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_07023618,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 716.8f,
- /* Ripples */ { 0 },
-};
-
-struct Painting default_thi_huge_painting = {
- /* id */ 0x000D,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 0.0f,
- /* Position */ -5614.5918f, 1510.4f, -3292.16f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 40.0f, 160.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.12f, 0.07f,
- /* Ripple Dispersion */ 0.0f, 80.0f, 60.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ inside_castle_seg7_painting_dl_070232F0,
- /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518,
- /* Textures */ inside_castle_seg7_painting_textures_07023600,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 1638.4f,
- /* Ripples */ { 0 },
-};
+});
diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c
index e1b1ce697..4af357cef 100644
--- a/levels/hmc/areas/1/painting.inc.c
+++ b/levels/hmc/areas/1/painting.inc.c
@@ -510,7 +510,7 @@ static const Gfx hmc_seg7_painting_dl_070254E0[] = {
}
// 0x0702551C (PaintingData)
-struct Painting cotmc_painting = {
+DEFINE_PAINTING(cotmc_painting, {
/* id */ 0x000E,
/* Image Count */ 0x01,
/* Texture Type */ PAINTING_ENV_MAP,
@@ -535,31 +535,4 @@ struct Painting cotmc_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 723.968018f,
/* Ripples */ { 0 },
-};
-
-struct Painting default_cotmc_painting = {
- /* id */ 0x000E,
- /* Image Count */ 0x01,
- /* Texture Type */ PAINTING_ENV_MAP,
- /* Floor Status */ 0x00, 0x00 , 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 270.0f, 0.0f,
- /* Position */ 2989.055908f, -4485.120117f, 5135.359863f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f,
- /* Ripple Decay */ 1.0f, 1.0f, 0.98f,
- /* Ripple Rate */ 0.0f, 0.05f, 0.05f,
- /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ hmc_seg7_painting_dl_070254E0,
- /* Texture Maps */ hmc_seg7_painting_texture_maps_07024CD4,
- /* Textures */ hmc_seg7_painting_textures_07025518,
- /* Texture w, h */ 32, 32,
- /* Ripple DList */ hmc_seg7_painting_dl_070242D0,
- /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 723.968018f,
- /* Ripples */ { 0 },
-};
+});
diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c
index 2ae5d05db..1f0dd0d10 100644
--- a/levels/ttm/areas/1/painting.inc.c
+++ b/levels/ttm/areas/1/painting.inc.c
@@ -542,7 +542,7 @@ static const Gfx ttm_seg7_painting_dl_07012E98[] = {
}
// 0x07012F00 (PaintingData)
-struct Painting ttm_slide_painting = {
+DEFINE_PAINTING(ttm_slide_painting, {
/* id */ 0x0000,
/* Image Count */ 0x02,
/* Texture Type */ PAINTING_IMAGE,
@@ -567,31 +567,4 @@ struct Painting ttm_slide_painting = {
/* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
/* Size */ 460.8f,
/* Ripples */ { 0 },
-};
-
-struct Painting default_ttm_slide_painting = {
- /* id */ 0x0000,
- /* Image Count */ 0x02,
- /* Texture Type */ PAINTING_IMAGE,
- /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */,
- /* Ripple Status */ 0x00,
- /* Rotation */ 0.0f, 90.0f,
- /* Position */ 3072.0f, 921.6f, -819.2f,
- /* curr passive entry */
- /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f,
- /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f,
- /* Ripple Rate */ 0.0f, 0.24f, 0.14f,
- /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f,
- /* Curr Ripple Timer */ 0.0f,
- /* Curr Ripple x, y */ 0.0f, 0.0f,
- /* Normal DList */ ttm_seg7_painting_dl_07012E98,
- /* Texture Maps */ ttm_seg7_painting_texture_maps_07012E88,
- /* Textures */ ttm_seg7_painting_textures_07012EF8,
- /* Texture w, h */ 64, 32,
- /* Ripple DList */ ttm_seg7_painting_dl_07012430,
- /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY,
- /* Alpha */ 0xFF,
- /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */
- /* Size */ 460.8f,
- /* Ripples */ { 0 },
-};
+});
diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c
index 1c8303a52..110c652b0 100644
--- a/src/game/behavior_actions.c
+++ b/src/game/behavior_actions.c
@@ -113,21 +113,21 @@ s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046,
#include "behaviors/white_puff_explode.inc.c"
// not in behavior file
-struct SpawnParticlesInfo D_8032F270 = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
+struct SpawnParticlesInfo sMistParticles = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
// generate_wind_puffs/dust (something like that)
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) {
- D_8032F270.sizeBase = size;
- D_8032F270.sizeRange = size / 20.0;
- D_8032F270.offsetY = offsetY;
+ sMistParticles.sizeBase = size;
+ sMistParticles.sizeRange = size / 20.0;
+ sMistParticles.offsetY = offsetY;
if (count == 0) {
- D_8032F270.count = 20;
+ sMistParticles.count = 20;
} else if (count > 20) {
- D_8032F270.count = count;
+ sMistParticles.count = count;
} else {
- D_8032F270.count = 4;
+ sMistParticles.count = 4;
}
- cur_obj_spawn_particles(&D_8032F270);
+ cur_obj_spawn_particles(&sMistParticles);
}
#include "behaviors/sparkle_spawn_star.inc.c"
@@ -230,7 +230,7 @@ s32 set_obj_anim_with_accel_and_sound(s16 a0, s16 a1, s32 a2) {
if ((sp1C = o->header.gfx.animInfo.animAccel / (f32) 0x10000) == 0)
sp1C = 1.0f;
if (cur_obj_check_anim_frame_in_range(a0, sp1C) || cur_obj_check_anim_frame_in_range(a1, sp1C)) {
- cur_obj_play_sound_2(a2);
+ cur_obj_play_sound_and_rumble_if_visible(a2);
return 1;
}
return 0;
diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h
index bfff0f99d..e2b0dc6cd 100644
--- a/src/game/behavior_actions.h
+++ b/src/game/behavior_actions.h
@@ -17,8 +17,8 @@ void spawn_mist_from_global(void);
void clear_particle_flags(u32 flags);
/* |description|Spawns wind particles around the current object|descriptionEnd| */
void spawn_wind_particles(s16 pitch, s16 yaw);
-/* |description|Checks if the current object is moving `a1` units over a floor and within a threshold of `a0`|descriptionEnd| */
-s32 check_if_moving_over_floor(f32 a0, f32 a1);
+/* |description|Checks if the current object is moving `distance` units over a floor and within a max distance to floor of `maxDistToFloor`|descriptionEnd| */
+s32 check_if_moving_over_floor(f32 maxDistToFloor, f32 distance);
/* |description|Calculates the time it takes for the current object to follow an arc from `pos` to `goal`|descriptionEnd| */
s32 arc_to_goal_pos(Vec3f goal, Vec3f pos, f32 yVel, f32 gravity);
/* |description|Moves Tox Box|descriptionEnd| */
@@ -30,8 +30,8 @@ s32 update_angle_from_move_flags(INOUT s32 *angle);
/* |description|Spawns strong wind particles relative to the current object|descriptionEnd| */
void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ);
-/* |description|Behavior loop function for Star Door|descriptionEnd| */
-void bhv_star_door_loop_2(void);
+/* |description|Behavior loop function for Star Door, which updates its render state|descriptionEnd| */
+void bhv_star_door_loop_update_render_state(void);
/* |description|Behavior loop function for Cap Switch|descriptionEnd| */
void bhv_cap_switch_loop(void);
/* |description|Behavior init function for tiny Star particles|descriptionEnd| */
@@ -100,8 +100,8 @@ void bhv_cannon_base_loop(void);
void bhv_cannon_barrel_loop(void);
/* |description|Behavior loop function for cannon base unused|descriptionEnd| */
void bhv_cannon_base_unused_loop(void);
-/* |description|Common behavior for when Mario's anchoring when grabbed|descriptionEnd| */
-void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30);
+/* |description|Common behavior for an object when grabbing Mario. Used by King Bob-omb and Chuckya anchor objects. When Mario is thrown, sets `forwardVel`, `upwardsVel` and `interactStatusFlags` to him|descriptionEnd| */
+void common_anchor_mario_behavior(f32 forwardVel, f32 upwardsVel, s32 interactStatusFlags);
/* |description|Behavior loop function for Chuckya|descriptionEnd| */
void bhv_chuckya_loop(void);
/* |description|Behavior loop function for Chuckya mario anchor|descriptionEnd| */
diff --git a/src/game/behaviors/amp.inc.c b/src/game/behaviors/amp.inc.c
index e797f6a69..ceea1faa7 100644
--- a/src/game/behaviors/amp.inc.c
+++ b/src/game/behaviors/amp.inc.c
@@ -233,7 +233,7 @@ void bhv_homing_amp_loop(void) {
case HOMING_AMP_ACT_CHASE:
homing_amp_chase_loop();
- cur_obj_play_sound_1(SOUND_AIR_AMP_BUZZ);
+ cur_obj_play_sound_if_visible(SOUND_AIR_AMP_BUZZ);
break;
case HOMING_AMP_ACT_GIVE_UP:
@@ -316,7 +316,7 @@ static void fixed_circling_amp_idle_loop(void) {
// Oscillate
o->oAmpYPhase++;
- // Where there is a cur_obj_play_sound_1 call in the main circling amp update function,
+ // Where there is a cur_obj_play_sound_if_visible call in the main circling amp update function,
// there is nothing here. Fixed amps are the only amps that never play
// the "amp buzzing" sound.
}
@@ -342,7 +342,7 @@ static void circling_amp_idle_loop(void) {
// Oscillate
o->oAmpYPhase++;
- cur_obj_play_sound_1(SOUND_AIR_AMP_BUZZ);
+ cur_obj_play_sound_if_visible(SOUND_AIR_AMP_BUZZ);
}
/**
diff --git a/src/game/behaviors/animated_floor_switch.inc.c b/src/game/behaviors/animated_floor_switch.inc.c
index ca1c64cb4..0d64b62d0 100644
--- a/src/game/behaviors/animated_floor_switch.inc.c
+++ b/src/game/behaviors/animated_floor_switch.inc.c
@@ -55,9 +55,9 @@ void bhv_animates_on_floor_switch_press_loop(void) {
if (o->oFloorSwitchPressAnimationUnkF4 != 0) {
if (o->oFloorSwitchPressAnimationUnkF4 < 60) {
- cur_obj_play_sound_1(SOUND_GENERAL2_SWITCH_TICK_SLOW);
+ cur_obj_play_sound_if_visible(SOUND_GENERAL2_SWITCH_TICK_SLOW);
} else {
- cur_obj_play_sound_1(SOUND_GENERAL2_SWITCH_TICK_FAST);
+ cur_obj_play_sound_if_visible(SOUND_GENERAL2_SWITCH_TICK_FAST);
}
if (--o->oFloorSwitchPressAnimationUnkF4 == 0) {
diff --git a/src/game/behaviors/bbh_haunted_bookshelf.inc.c b/src/game/behaviors/bbh_haunted_bookshelf.inc.c
index 9ab34072a..5f38a010f 100644
--- a/src/game/behaviors/bbh_haunted_bookshelf.inc.c
+++ b/src/game/behaviors/bbh_haunted_bookshelf.inc.c
@@ -40,7 +40,7 @@ void bhv_haunted_bookshelf_loop(void) {
case HAUNTED_BOOKSHELF_ACT_RECEDE:
// Move the bookshelf and play the sound
o->oPosX += 5.0f;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4_2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR4_2);
// Delete the object after 102 frames
if (o->oTimer > 101) {
diff --git a/src/game/behaviors/bbh_merry_go_round.inc.c b/src/game/behaviors/bbh_merry_go_round.inc.c
index be096afd6..9154b07bb 100644
--- a/src/game/behaviors/bbh_merry_go_round.inc.c
+++ b/src/game/behaviors/bbh_merry_go_round.inc.c
@@ -62,7 +62,7 @@ static void handle_merry_go_round_music(void) {
stop_secondary_music(300); // Switch to BBH music? FIXME: Audio needs labelling
o->oMerryGoRoundMusicShouldPlay = FALSE;
} else {
- cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING);
+ cur_obj_play_sound_if_visible(SOUND_ENV_MERRY_GO_ROUND_CREAKING);
}
}
diff --git a/src/game/behaviors/beta_holdable_object.inc.c b/src/game/behaviors/beta_holdable_object.inc.c
index b4ec61f9a..5f21dc23a 100644
--- a/src/game/behaviors/beta_holdable_object.inc.c
+++ b/src/game/behaviors/beta_holdable_object.inc.c
@@ -35,9 +35,6 @@ static void beta_holdable_object_drop(void) {
* Throw the object.
*/
static void beta_holdable_object_throw(void) {
- // cur_obj_enable_rendering_2 just calls cur_obj_enable_rendering and does
- // nothing else; it's useless here. Maybe it originally did more?
- cur_obj_enable_rendering_2();
cur_obj_enable_rendering();
o->oHeldState = HELD_FREE;
diff --git a/src/game/behaviors/bird.inc.c b/src/game/behaviors/bird.inc.c
index 700657a69..b97ab6f14 100644
--- a/src/game/behaviors/bird.inc.c
+++ b/src/game/behaviors/bird.inc.c
@@ -22,7 +22,7 @@ static void bird_act_inactive(void) {
if (o->oBehParams2ndByte != BIRD_BP_SPAWNED) {
s32 i;
- cur_obj_play_sound_2(SOUND_GENERAL_BIRDS_FLY_AWAY);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BIRDS_FLY_AWAY);
for (i = 0; i < 6; i++) {
spawn_object(o, MODEL_BIRDS, bhvBird);
diff --git a/src/game/behaviors/blue_coin.inc.c b/src/game/behaviors/blue_coin.inc.c
index 156806de2..a5feecd18 100644
--- a/src/game/behaviors/blue_coin.inc.c
+++ b/src/game/behaviors/blue_coin.inc.c
@@ -144,7 +144,7 @@ void bhv_blue_coin_switch_loop(void) {
// Set gravity to 0 so it doesn't accelerate when receding.
o->oGravity = 0.0f;
- cur_obj_play_sound_2(SOUND_GENERAL_SWITCH_DOOR_OPEN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWITCH_DOOR_OPEN);
network_send_object(o);
}
@@ -194,7 +194,7 @@ void bhv_blue_coin_switch_loop(void) {
o->oPosY = o->oHomeY - 120.0f;
o->oVelY = 20.0f;
o->oGravity = 0.0f;
- cur_obj_play_sound_2(SOUND_GENERAL_SWITCH_DOOR_OPEN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWITCH_DOOR_OPEN);
network_send_object(o);
} else {
obj_mark_for_deletion(o);
diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c
index 9abd1b832..f2646abe4 100644
--- a/src/game/behaviors/bobomb.inc.c
+++ b/src/game/behaviors/bobomb.inc.c
@@ -101,7 +101,7 @@ void bobomb_act_chase_mario(void) {
collisionFlags = object_step();
if (sp1a == 5 || sp1a == 16)
- cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOBOMB_WALK);
struct Object* player = nearest_player_to_object(o);
if (player) {
@@ -214,7 +214,7 @@ void bobomb_dropped_loop(void) {
}
void bobomb_thrown_loop(void) {
- cur_obj_enable_rendering_2();
+ cur_obj_enable_rendering();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
o->oHeldState = 0;
@@ -278,7 +278,7 @@ void bhv_bobomb_loop(void) {
== 0) /* oBobombFuseTimer % 2 or oBobombFuseTimer % 8 */
spawn_object(o, MODEL_SMOKE, bhvBobombFuseSmoke);
- cur_obj_play_sound_1(SOUND_AIR_BOBOMB_LIT_FUSE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BOBOMB_LIT_FUSE);
o->oBobombFuseTimer++;
}
@@ -316,7 +316,7 @@ void bobomb_buddy_act_idle(void) {
object_step();
if ((animFrame == 5) || (animFrame == 16)) {
- cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOBOMB_WALK);
}
struct Object* player = nearest_player_to_object(o);
@@ -423,7 +423,7 @@ void bobomb_buddy_act_talk(void) {
void bobomb_buddy_act_turn_to_talk(void) {
s16 animFrame = o->header.gfx.animInfo.animFrame;
if ((animFrame == 5) || (animFrame == 16)) {
- cur_obj_play_sound_2(SOUND_OBJ_BOBOMB_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOBOMB_WALK);
}
struct Object *player = nearest_interacting_player_to_object(o);
@@ -433,7 +433,7 @@ void bobomb_buddy_act_turn_to_talk(void) {
o->oAction = BOBOMB_BUDDY_ACT_TALK;
}
- cur_obj_play_sound_2(SOUND_ACTION_READ_SIGN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_READ_SIGN);
}
void bobomb_buddy_actions(void) {
diff --git a/src/game/behaviors/bomp.inc.c b/src/game/behaviors/bomp.inc.c
index e5783bced..aadbdd68b 100644
--- a/src/game/behaviors/bomp.inc.c
+++ b/src/game/behaviors/bomp.inc.c
@@ -28,7 +28,7 @@ void bhv_small_bomp_loop(void) {
if (o->oTimer == 15.0) {
o->oAction = BOMP_ACT_EXTEND;
o->oForwardVel = 40.0f;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN2);
}
break;
@@ -42,7 +42,7 @@ void bhv_small_bomp_loop(void) {
o->oAction = BOMP_ACT_RETRACT;
o->oForwardVel = 10.0f;
o->oMoveAngleYaw -= 0x8000;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN2);
}
break;
@@ -88,7 +88,7 @@ void bhv_large_bomp_loop(void) {
if (o->oTimer == 15.0) {
o->oAction = BOMP_ACT_EXTEND;
o->oForwardVel = 10.0f;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN2);
}
break;
@@ -102,7 +102,7 @@ void bhv_large_bomp_loop(void) {
o->oAction = BOMP_ACT_RETRACT;
o->oForwardVel = 10.0f;
o->oMoveAngleYaw -= 0x8000;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN2);
}
break;
diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c
index abc848b76..a9c7854a6 100644
--- a/src/game/behaviors/boo.inc.c
+++ b/src/game/behaviors/boo.inc.c
@@ -184,7 +184,7 @@ static s32 boo_vanish_or_appear(void) {
if (relativeAngleToMario > relativeAngleToMarioThreshhold || relativeMarioFaceAngle < relativeMarioFaceAngleThreshhold) {
if (o->oOpacity == 40) {
o->oBooTargetOpacity = 255;
- cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_LONG);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOO_LAUGH_LONG);
}
if (o->oOpacity > 180) {
@@ -351,11 +351,11 @@ static s32 boo_get_attack_status(void) {
o->oInteractStatus = 0;
- cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_SHORT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOO_LAUGH_SHORT);
attackStatus = BOO_ATTACKED;
} else {
- cur_obj_play_sound_2(SOUND_OBJ_BOO_BOUNCE_TOP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOO_BOUNCE_TOP);
o->oInteractStatus = 0;
@@ -969,7 +969,7 @@ void bhv_boo_in_castle_loop(void) {
if (distanceToPlayer < 1000.0f) {
o->oAction++;
- cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_LONG);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOO_LAUGH_LONG);
}
o->oForwardVel = 0.0f;
@@ -1026,7 +1026,7 @@ void bhv_boo_boss_spawned_bridge_loop(void) {
// fallthrough
case 1:
o->oPosY += 8.0f;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR2);
if (o->oPosY > targetY) {
o->oPosY = targetY;
@@ -1036,7 +1036,7 @@ void bhv_boo_boss_spawned_bridge_loop(void) {
break;
case 2:
if (o->oTimer == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
}
if (cur_obj_move_up_and_down(o->oTimer)) {
diff --git a/src/game/behaviors/boo_cage.inc.c b/src/game/behaviors/boo_cage.inc.c
index 11c2f6745..9c1a68bc5 100644
--- a/src/game/behaviors/boo_cage.inc.c
+++ b/src/game/behaviors/boo_cage.inc.c
@@ -92,7 +92,7 @@ void bhv_boo_cage_loop(void) {
// When the cage lands/bounces, play a landing/bouncing sound.
if (o->oMoveFlags & OBJ_MOVE_LANDED) {
- cur_obj_play_sound_2(SOUND_GENERAL_SOFT_LANDING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SOFT_LANDING);
}
// Once the cage stops bouncing and settles on the ground,
diff --git a/src/game/behaviors/boulder.inc.c b/src/game/behaviors/boulder.inc.c
index b278b22a4..62306aa92 100644
--- a/src/game/behaviors/boulder.inc.c
+++ b/src/game/behaviors/boulder.inc.c
@@ -15,7 +15,7 @@ void boulder_act_1(void) {
sp1E = object_step_without_floor_orient();
if ((sp1E & 0x09) == 0x01 && o->oVelY > 10.0f) {
- cur_obj_play_sound_2(SOUND_GENERAL_GRINDEL_ROLL);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_GRINDEL_ROLL);
spawn_mist_particles();
}
@@ -43,7 +43,7 @@ void bhv_big_boulder_loop(void) {
case 1:
boulder_act_1();
adjust_rolling_face_pitch(1.5f);
- cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_UNKNOWN2);
break;
}
diff --git a/src/game/behaviors/bowling_ball.inc.c b/src/game/behaviors/bowling_ball.inc.c
index 6e0f6bd4f..9d671d97d 100644
--- a/src/game/behaviors/bowling_ball.inc.c
+++ b/src/game/behaviors/bowling_ball.inc.c
@@ -103,7 +103,7 @@ void bhv_bowling_ball_roll_loop(void) {
}
if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && (o->oVelY > 5.0f))
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_POUND1_LOWPRIO);
}
void bhv_bowling_ball_initializeLoop(void) {
@@ -271,7 +271,7 @@ void bhv_bob_pit_bowling_ball_loop(void) {
bowling_ball_set_hitbox();
set_camera_shake_from_point(SHAKE_POS_BOWLING_BALL, o->oPosX, o->oPosY, o->oPosZ);
- cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_UNKNOWN2);
set_object_visibility(o, 3000);
}
@@ -291,12 +291,12 @@ void bhv_free_bowling_ball_roll_loop(void) {
if (o->oForwardVel > 10.0f) {
set_camera_shake_from_point(SHAKE_POS_BOWLING_BALL, o->oPosX, o->oPosY, o->oPosZ);
- cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_UNKNOWN2);
}
// warning: 'and' of mutually exclusive equal-tests is always 0
/*if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && !(collisionFlags & OBJ_COL_FLAGS_LANDED))
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1_LOWPRIO);*/
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_POUND1_LOWPRIO);*/
if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 6000)) {
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c
index 1181e97c1..4a02dbec2 100644
--- a/src/game/behaviors/bowser.inc.c
+++ b/src/game/behaviors/bowser.inc.c
@@ -49,7 +49,7 @@ s16 D_8032F520[][3] = { { 1, 10, 40 }, { 0, 0, 74 }, { -1, -10, 114 }, { 1
{ -1, 80, 184 }, { 1, 160, 186 }, { -1, -160, 186 }, { 1, 0, 0 }, };
void bhv_bowser_tail_anchor_init(void) {
- if (!o->parentObj) { mark_obj_for_deletion(o); return; }
+ if (!o->parentObj) { obj_mark_for_deletion(o); return; }
sync_object_init_field(o->parentObj, o->oAction);
sync_object_init_field(o->parentObj, o->oPrevAction);
sync_object_init_field(o->parentObj, o->oTimer);
@@ -87,7 +87,7 @@ void bhv_bowser_flame_spawn_loop(void) {
sp30 = 0;
}
if (sp30 > 45 && sp30 < 85) {
- cur_obj_play_sound_1(SOUND_AIR_BOWSER_SPIT_FIRE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BOWSER_SPIT_FIRE);
sp2C = sp1C[5 * sp30];
sp28 = sp1C[5 * sp30 + 2];
o->oPosX = bowser->oPosX + (sp28 * sp20 + sp2C * sp24);
@@ -111,7 +111,7 @@ void bhv_bowser_flame_spawn_loop(void) {
}
void bhv_bowser_body_anchor_init(void) {
- if (!o->parentObj) { mark_obj_for_deletion(o); return; }
+ if (!o->parentObj) { obj_mark_for_deletion(o); return; }
sync_object_init_field(o->parentObj, o->oInteractType);
sync_object_init_field(o->parentObj, o->oInteractStatus);
sync_object_init_field(o->parentObj, o->oIntangibleTimer);
@@ -169,7 +169,7 @@ void bowser_bounce(s32 *a) {
if (a[0] < 4) {
cur_obj_start_cam_event(o, CAM_EVENT_BOWSER_THROW_BOUNCE);
spawn_mist_particles_variable(0, 0, 60.0f);
- cur_obj_play_sound_2(SOUND_OBJ_BOWSER_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOWSER_WALK);
}
}
}
@@ -411,7 +411,7 @@ void bowser_act_default(void) // only lasts one frame
void bowser_act_breath_fire(void) {
o->oForwardVel = 0.0f;
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_BOWSER_INHALING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOWSER_INHALING);
if (cur_obj_init_animation_and_check_if_near_end(6))
o->oAction = 0;
}
@@ -463,7 +463,7 @@ void bowser_act_teleport(void) {
o->oBowserUnk1AC = 0;
o->oBowserUnkF8 = 30;
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ2_BOWSER_TELEPORT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_BOWSER_TELEPORT);
if (o->oOpacity == 0) {
o->oSubAction++;
o->oMoveAngleYaw = angleToPlayer;
@@ -480,7 +480,7 @@ void bowser_act_teleport(void) {
if (distanceToPlayer > 500.0f) {
o->oSubAction = 2;
o->oMoveAngleYaw = angleToPlayer; // large change in angle?
- cur_obj_play_sound_2(SOUND_OBJ2_BOWSER_TELEPORT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_BOWSER_TELEPORT);
}
break;
case 2:
@@ -499,7 +499,7 @@ void bowser_act_spit_fire_into_sky(void) // only in sky
cur_obj_init_animation_with_sound(11);
frame = o->header.gfx.animInfo.animFrame;
if (frame > 24 && frame < 36) {
- cur_obj_play_sound_1(SOUND_AIR_BOWSER_SPIT_FIRE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BOWSER_SPIT_FIRE);
struct MarioState* marioState = nearest_mario_state_to_object(o);
if (marioState && marioState->playerIndex == 0) {
struct Object* flame = NULL;
@@ -870,7 +870,7 @@ void bowser_act_jump_onto_stage(void) {
void bowser_act_dance(void) {
if (is_item_in_array(o->oTimer, D_8032F514))
- cur_obj_play_sound_2(SOUND_OBJ_BOWSER_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOWSER_WALK);
if (cur_obj_init_animation_and_check_if_near_end(10))
o->oAction = 0;
}
@@ -898,7 +898,7 @@ void bowser_spawn_grand_star_key(void) {
struct Object* prevReward = cur_obj_nearest_object_with_behavior(bhvBowserKey);
reward = (prevReward != NULL) ? prevReward : spawn_object(o, MODEL_BOWSER_KEY, bhvBowserKey);
gSecondCameraFocus = reward;
- cur_obj_play_sound_2(SOUND_GENERAL2_BOWSER_KEY);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_BOWSER_KEY);
if (prevReward == NULL && reward != NULL) {
// set the home position
@@ -931,7 +931,7 @@ void bowser_dead_bounce(void) {
o->oBowserEyesShut = 1;
bowser_bounce(&o->oBowserUnkF8);
if (o->oMoveFlags & OBJ_MOVE_LANDED)
- cur_obj_play_sound_2(SOUND_OBJ_BOWSER_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOWSER_WALK);
if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) {
o->oForwardVel = 0.0f;
o->oSubAction++;
@@ -993,7 +993,7 @@ s32 bowser_dead_not_bits_end(void) {
}
if (marioState && should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog(marioState, 2, 18, *sBowserDefeatedDialogText[o->oBehParams2ndByte], 0, bowser_dead_not_bits_end_continue_dialog)) {
o->oBowserUnkF8++;
- cur_obj_play_sound_2(SOUND_GENERAL2_BOWSER_EXPLODE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_BOWSER_EXPLODE);
seq_player_unlower_volume(SEQ_PLAYER_LEVEL, 60);
seq_player_fade_out(SEQ_PLAYER_LEVEL, 1);
network_send_object(o);
@@ -1252,7 +1252,7 @@ void bowser_held_update(void) {
switch (o->oBowserUnk10E) {
case 0:
- cur_obj_play_sound_2(SOUND_OBJ_BOWSER_TAIL_PICKUP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BOWSER_TAIL_PICKUP);
cur_obj_unrender_and_reset_state(3, 1);
o->oBowserUnk10E++;
break;
@@ -1628,7 +1628,7 @@ void falling_bowser_plat_act_2(void) {
f32 sp1C;
UNUSED struct Object *sp18 = o->oPlatformUnkF8;
if (o->oTimer == 0 || o->oTimer == 22)
- cur_obj_play_sound_2(SOUND_GENERAL_BOWSER_PLATFORM_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOWSER_PLATFORM_2);
if (o->oTimer < 22) {
set_environmental_camera_shake(SHAKE_ENV_FALLING_BITS_PLAT);
o->oVelY = 8.0f;
diff --git a/src/game/behaviors/bowser_key.inc.c b/src/game/behaviors/bowser_key.inc.c
index f2a0fbe03..4279c3b74 100644
--- a/src/game/behaviors/bowser_key.inc.c
+++ b/src/game/behaviors/bowser_key.inc.c
@@ -38,14 +38,14 @@ void bhv_bowser_key_loop(void) {
o->oAction++;
else if (o->oMoveFlags & OBJ_MOVE_LANDED)
#ifndef VERSION_JP
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN3_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN3_2);
#else
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN3_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN3_LOWPRIO);
#endif
} else {
obj_set_hitbox(o, &sBowserKeyHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
- mark_obj_for_deletion(o);
+ obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
}
diff --git a/src/game/behaviors/bowser_puzzle_piece.inc.c b/src/game/behaviors/bowser_puzzle_piece.inc.c
index 85474573b..1937491e3 100644
--- a/src/game/behaviors/bowser_puzzle_piece.inc.c
+++ b/src/game/behaviors/bowser_puzzle_piece.inc.c
@@ -223,7 +223,7 @@ void bhv_lll_bowser_puzzle_piece_move(f32 xOffset, f32 zOffset, s32 duration, UN
} else {
// On frame 20, play the shifting sound.
if (o->oTimer == 20)
- cur_obj_play_sound_2(SOUND_OBJ2_BOWSER_PUZZLE_PIECE_MOVE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_BOWSER_PUZZLE_PIECE_MOVE);
// For the number of frames specified by duration, move the piece.
if (o->oTimer < duration + 20) {
diff --git a/src/game/behaviors/breakable_box_small.inc.c b/src/game/behaviors/breakable_box_small.inc.c
index 26066e57f..6c93fb86b 100644
--- a/src/game/behaviors/breakable_box_small.inc.c
+++ b/src/game/behaviors/breakable_box_small.inc.c
@@ -39,10 +39,10 @@ void small_breakable_box_act_move(void) {
obj_attack_collided_from_other_object(o);
if (sp1E == 1)
- cur_obj_play_sound_2(SOUND_GENERAL_BOX_LANDING_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOX_LANDING_2);
if (sp1E & 1) {
if (o->oForwardVel > 20.0f) {
- cur_obj_play_sound_2(SOUND_ENV_SLIDING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ENV_SLIDING);
small_breakable_box_spawn_dust();
}
}
@@ -110,7 +110,6 @@ void breakable_box_small_get_dropped(void) {
void breakable_box_small_get_thrown(void) {
cur_obj_become_tangible();
- cur_obj_enable_rendering_2();
cur_obj_enable_rendering();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
o->oHeldState = 0;
diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c
index d4875e040..f3576ac18 100644
--- a/src/game/behaviors/bub.inc.c
+++ b/src/game/behaviors/bub.inc.c
@@ -92,7 +92,7 @@ void bub_act_2(void) {
} else
o->oInteractStatus = 0;
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_MOVING_WATER);
if (o->oForwardVel == 0.0f)
o->oForwardVel = 6.0f;
dy = o->oPosY - player->oPosY;
diff --git a/src/game/behaviors/bubba.inc.c b/src/game/behaviors/bubba.inc.c
index 2b2e2f5c2..8eadecbae 100644
--- a/src/game/behaviors/bubba.inc.c
+++ b/src/game/behaviors/bubba.inc.c
@@ -64,7 +64,7 @@ void bubba_act_1(void) {
o->oAction = 0;
} else if (o->oBubbaUnk100 != 0) {
if (--o->oBubbaUnk100 == 0) {
- cur_obj_play_sound_2(SOUND_OBJ_BUBBA_CHOMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BUBBA_CHOMP);
o->oAction = 0;
} else if (o->oBubbaUnk100 < 15) {
o->oAnimState = 1;
diff --git a/src/game/behaviors/bullet_bill.inc.c b/src/game/behaviors/bullet_bill.inc.c
index 767a3e032..b278f27ff 100644
--- a/src/game/behaviors/bullet_bill.inc.c
+++ b/src/game/behaviors/bullet_bill.inc.c
@@ -56,7 +56,7 @@ void bullet_bill_act_2(void) {
if (distanceToPlayer > 300.0f)
cur_obj_rotate_yaw_toward(angleToPlayer, 0x100);
if (o->oTimer == 50) {
- cur_obj_play_sound_2(SOUND_OBJ_POUNDING_CANNON);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_POUNDING_CANNON);
cur_obj_shake_screen(SHAKE_POS_SMALL);
}
if (o->oTimer > 150 || o->oMoveFlags & OBJ_MOVE_HIT_WALL) {
diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c
index 4a9294433..1809d4c71 100644
--- a/src/game/behaviors/bully.inc.c
+++ b/src/game/behaviors/bully.inc.c
@@ -109,9 +109,9 @@ void bully_check_mario_collision(void) {
#endif
o->oInteractStatus & INT_STATUS_INTERACTED) {
if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL) {
- cur_obj_play_sound_2(SOUND_OBJ2_BULLY_ATTACKED);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_BULLY_ATTACKED);
} else {
- cur_obj_play_sound_2(SOUND_OBJ2_LARGE_BULLY_ATTACKED);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_LARGE_BULLY_ATTACKED);
}
o->oInteractStatus &= ~INT_STATUS_INTERACTED;
@@ -216,9 +216,9 @@ void bully_play_stomping_sound(void) {
case BULLY_ACT_PATROL:
if (sp26 == 0 || sp26 == 12) {
if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL)
- cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BULLY_WALK);
else
- cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALKING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BULLY_WALKING);
}
break;
@@ -226,9 +226,9 @@ void bully_play_stomping_sound(void) {
case BULLY_ACT_BACK_UP:
if (sp26 == 0 || sp26 == 5) {
if (o->oBehParams2ndByte == BULLY_BP_SIZE_SMALL)
- cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BULLY_WALK);
else
- cur_obj_play_sound_2(SOUND_OBJ_BULLY_WALKING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BULLY_WALKING);
}
break;
}
@@ -251,11 +251,11 @@ void bully_step(void) {
void bully_spawn_coin(void) {
struct Object *coin = spawn_object(o, MODEL_YELLOW_COIN, bhvMovingYellowCoin);
#ifdef VERSION_JP // TODO: maybe move this ifdef logic to the header?
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT);
#elif defined(VERSION_EU) || defined(VERSION_SH)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_EU);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT_EU);
#else
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT_2);
#endif
if (coin == NULL) { return; }
coin->oForwardVel = 10.0f;
@@ -429,7 +429,7 @@ void bhv_big_bully_with_minions_loop(void) {
o->oAction = BULLY_ACT_PATROL;
if (collisionFlags == 1) {
- cur_obj_play_sound_2(SOUND_OBJ_THWOMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_THWOMP);
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
spawn_mist_particles();
}
diff --git a/src/game/behaviors/camera_lakitu.inc.c b/src/game/behaviors/camera_lakitu.inc.c
index a4ad352fb..fdc0a3375 100644
--- a/src/game/behaviors/camera_lakitu.inc.c
+++ b/src/game/behaviors/camera_lakitu.inc.c
@@ -116,7 +116,7 @@ static void camera_lakitu_intro_act_show_dialog(void) {
s16 targetMovePitch = 0;
s16 targetMoveYaw = 0;
- cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY);
+ cur_obj_play_sound_if_visible(SOUND_AIR_LAKITU_FLY);
// Face toward mario
if (marioState) {
diff --git a/src/game/behaviors/cannon.inc.c b/src/game/behaviors/cannon.inc.c
index 9450aac0c..f1591add6 100644
--- a/src/game/behaviors/cannon.inc.c
+++ b/src/game/behaviors/cannon.inc.c
@@ -44,7 +44,7 @@ void opened_cannon_act_0(void) {
void opened_cannon_act_4(void) {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_CANNON1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_CANNON1);
o->oPosY += 5.0f;
o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 2;
o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 2;
@@ -64,7 +64,7 @@ void opened_cannon_act_4(void) {
void opened_cannon_act_6(void) {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_CANNON2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_CANNON2);
if (o->oTimer < 4) {
o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f;
o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f;
@@ -92,7 +92,7 @@ void opened_cannon_act_6(void) {
void opened_cannon_act_5(void) {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_CANNON3);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_CANNON3);
if (o->oTimer < 4) {
} else {
if (o->oTimer < 20) {
diff --git a/src/game/behaviors/cannon_door.inc.c b/src/game/behaviors/cannon_door.inc.c
index b5a9d32fd..0197aa3d2 100644
--- a/src/game/behaviors/cannon_door.inc.c
+++ b/src/game/behaviors/cannon_door.inc.c
@@ -20,7 +20,7 @@ void bhv_cannon_closed_init(void) {
void cannon_door_act_opening(void) {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_CANNON_UP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CANNON_UP);
if (o->oTimer < 30) {
o->oVelY = -0.5f;
diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c
index 9fada0a72..91bfa48cf 100644
--- a/src/game/behaviors/capswitch.inc.c
+++ b/src/game/behaviors/capswitch.inc.c
@@ -21,7 +21,7 @@ void cap_switch_act_1(void) {
if (capSwitchForcePress || cur_obj_is_mario_on_platform()) {
save_file_set_flags(BHV_ARR(D_8032F0C0, o->oBehParams2ndByte, s32));
o->oAction = 2;
- cur_obj_play_sound_2(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
if (!capSwitchForcePress) {
capSwitchForcePress = TRUE;
network_send_object(o);
diff --git a/src/game/behaviors/castle_floor_trap.inc.c b/src/game/behaviors/castle_floor_trap.inc.c
index bda06b09a..1824f3ddb 100644
--- a/src/game/behaviors/castle_floor_trap.inc.c
+++ b/src/game/behaviors/castle_floor_trap.inc.c
@@ -35,7 +35,7 @@ void bhv_castle_floor_trap_open_detect(void) {
void bhv_castle_floor_trap_open(void) {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_CASTLE_TRAP_OPEN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CASTLE_TRAP_OPEN);
o->oAngleVelRoll -= 0x100;
o->oFaceAngleRoll += o->oAngleVelRoll;
if (o->oFaceAngleRoll < -0x4000) {
diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c
index d89b324cf..c47e5f19a 100644
--- a/src/game/behaviors/chain_chomp.inc.c
+++ b/src/game/behaviors/chain_chomp.inc.c
@@ -183,7 +183,7 @@ static void chain_chomp_sub_act_turn(void) {
if (o->oTimer > 40) {
// Increase the maximum distance from the pivot and enter
// the lunging sub-action.
- cur_obj_play_sound_2(SOUND_GENERAL_CHAIN_CHOMP2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CHAIN_CHOMP2);
o->oSubAction = CHAIN_CHOMP_SUB_ACT_LUNGE;
o->oChainChompMaxDistFromPivotPerChainPart = 900.0f / 5;
@@ -200,7 +200,7 @@ static void chain_chomp_sub_act_turn(void) {
o->oForwardVel = 0.0f;
}
} else {
- cur_obj_play_sound_2(SOUND_GENERAL_CHAIN_CHOMP1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CHAIN_CHOMP1);
o->oForwardVel = 10.0f;
o->oVelY = 20.0f;
}
@@ -296,7 +296,7 @@ static void chain_chomp_released_lunge_around(void) {
o->oWallHitboxRadius = 200.0f;
} else {
if (++o->oChainChompNumLunges <= 5) {
- cur_obj_play_sound_2(SOUND_GENERAL_CHAIN_CHOMP1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CHAIN_CHOMP1);
o->oMoveAngleYaw = cur_obj_angle_to_home() + random_sign() * 0x2000;
o->oForwardVel = 30.0f;
o->oVelY = 50.0f;
@@ -517,7 +517,7 @@ void bhv_wooden_post_update(void) {
// When ground pounded by mario, drop by -45 + -20
if (!o->oWoodenPostMarioPounding) {
if ((o->oWoodenPostMarioPounding = cur_obj_is_mario_ground_pounding_platform())) {
- cur_obj_play_sound_2(SOUND_GENERAL_POUND_WOOD_POST);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_POUND_WOOD_POST);
o->oWoodenPostSpeedY = -70.0f;
network_send_object(o);
}
diff --git a/src/game/behaviors/checkerboard_platform.inc.c b/src/game/behaviors/checkerboard_platform.inc.c
index 355b7bbd9..20b38f24a 100644
--- a/src/game/behaviors/checkerboard_platform.inc.c
+++ b/src/game/behaviors/checkerboard_platform.inc.c
@@ -51,7 +51,7 @@ void checkerboard_plat_act_rotate(s32 a0, s16 a1) {
static void bhv_checkerboard_platform_run_once(void) {
if (o->oDistanceToMario < 1000.0f) {
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR4);
}
load_object_collision_model();
}
diff --git a/src/game/behaviors/chuckya.inc.c b/src/game/behaviors/chuckya.inc.c
index 9b1a25ae8..af368416a 100644
--- a/src/game/behaviors/chuckya.inc.c
+++ b/src/game/behaviors/chuckya.inc.c
@@ -1,6 +1,6 @@
// chuckya.c.inc
-void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
+void common_anchor_mario_behavior(f32 forwardVel, f32 upwardsVel, s32 interactStatusFlags) {
if (!o) { return; }
for (s32 i = 0; i < MAX_PLAYERS; i++) {
if (!is_player_active(&gMarioStates[i])) { continue; }
@@ -15,9 +15,9 @@ void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
obj_set_gfx_pos_at_obj_pos(player, o);
break;
case 2:
- player->oInteractStatus |= (sp30 + INT_STATUS_MARIO_UNK2);
- marioState->forwardVel = sp28;
- marioState->vel[1] = sp2C;
+ player->oInteractStatus |= (interactStatusFlags + INT_STATUS_MARIO_UNK2);
+ marioState->forwardVel = forwardVel;
+ marioState->vel[1] = upwardsVel;
o->parentObj->oChuckyaUnk88 = 0;
break;
case 3:
@@ -35,7 +35,7 @@ void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
}
void bhv_chuckya_anchor_mario_loop(void) {
- common_anchor_mario_behavior(40.0f, 40.0f, 64);
+ common_anchor_mario_behavior(40.0f, 40.0f, INT_STATUS_MARIO_UNK6);
}
s32 unknown_chuckya_function(s32 sp20, f32 sp24, f32 sp28, s32 sp2C) {
@@ -134,7 +134,7 @@ void chuckya_act_0(void) {
o->oChuckyaUnkFC++;
cur_obj_init_animation_with_sound(4);
if (o->oForwardVel > 1.0f)
- cur_obj_play_sound_1(SOUND_AIR_CHUCKYA_MOVE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_CHUCKYA_MOVE);
print_debug_bottom_up("fg %d", sp3C);
print_debug_bottom_up("sp %d", o->oForwardVel);
}
@@ -167,7 +167,7 @@ void chuckya_act_1(void) {
} else {
cur_obj_init_animation_with_sound(3);
if (cur_obj_check_anim_frame(18)) {
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN4);
o->oChuckyaUnk88 = 2;
o->oAction = 3;
o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO);
@@ -205,7 +205,7 @@ void chuckya_move(void) {
if (o->oInteractStatus & INT_STATUS_GRABBED_MARIO) {
o->oAction = 1;
o->oChuckyaUnk88 = 1;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN3);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN3);
o->usingObj = nearest_player_to_object(o);
}
}
diff --git a/src/game/behaviors/clam.inc.c b/src/game/behaviors/clam.inc.c
index 32f571a28..df37e4cbd 100644
--- a/src/game/behaviors/clam.inc.c
+++ b/src/game/behaviors/clam.inc.c
@@ -17,7 +17,7 @@ void clam_act_0(void) {
s32 distanceToPlayer = dist_between_objects(o, player);
if (cur_obj_init_anim_check_frame(0, 25)) {
- cur_obj_play_sound_2(SOUND_GENERAL_CLAM_SHELL3);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CLAM_SHELL3);
spawn_mist_from_global();
cur_obj_become_tangible();
@@ -25,7 +25,7 @@ void clam_act_0(void) {
o->oTimer = 0;
if (sync_object_is_owned_locally(o->oSyncID)) { network_send_object(o); }
} else if (o->oTimer > 150 && player == gMarioStates[0].marioObj && distanceToPlayer < 500.0f) {
- cur_obj_play_sound_2(SOUND_GENERAL_CLAM_SHELL2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CLAM_SHELL2);
o->oAction = 1;
if (sync_object_is_owned_locally(o->oSyncID)) { network_send_object(o); }
} else if (o->oClamUnkF4 != 0) {
diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c
index f34c63dd0..d1fdbae2d 100644
--- a/src/game/behaviors/cloud.inc.c
+++ b/src/game/behaviors/cloud.inc.c
@@ -77,10 +77,10 @@ static void cloud_fwoosh_update(void) {
o->oCloudBlowing = o->oTimer = 0;
} else if (o->oCloudGrowSpeed < -0.1f) {
// Start blowing once we start shrinking faster than -0.1
- cur_obj_play_sound_1(SOUND_AIR_BLOW_WIND);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BLOW_WIND);
cur_obj_spawn_strong_wind_particles(12, 3.0f, 0.0f, -50.0f, 120.0f);
} else {
- cur_obj_play_sound_1(SOUND_ENV_WIND1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WIND1);
}
} else {
// Return to normal size
diff --git a/src/game/behaviors/coffin.inc.c b/src/game/behaviors/coffin.inc.c
index 6691e1d0b..23eeaa90d 100644
--- a/src/game/behaviors/coffin.inc.c
+++ b/src/game/behaviors/coffin.inc.c
@@ -76,7 +76,7 @@ void coffin_act_idle(void) {
// If the coffin landed...
if (obj_face_pitch_approach(0, -o->oAngleVelPitch)) {
- cur_obj_play_sound_2(SOUND_GENERAL_ELEVATOR_MOVE_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ELEVATOR_MOVE_2);
// This bit changes the coffin's position,
// spawns dust there, then resets the position.
@@ -114,7 +114,7 @@ void coffin_act_idle(void) {
&& (distanceToPlayer > 100.0f || (marioState && marioState->action == ACT_SQUISHED))) {
if ((player && player->oPosY - o->oPosY < 200.0f) && absf(distForwards) < 140.0f) {
if (distSideways < 150.0f && distSideways > -450.0f) {
- cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BUTTON_PRESS_2_LOWPRIO);
o->oAction = COFFIN_ACT_STAND_UP;
}
}
@@ -140,7 +140,7 @@ void coffin_act_stand_up(void) {
o->oFaceAngleRoll = 0;
} else if (o->oTimer > 30) {
if (gGlobalTimer % 4 == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_ELEVATOR_MOVE_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ELEVATOR_MOVE_2);
}
// Shake the coffin while its standing
o->oFaceAngleRoll = 400 * (gGlobalTimer % 2) - 200;
diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c
index cd78b7d19..a6516aff1 100644
--- a/src/game/behaviors/coin.inc.c
+++ b/src/game/behaviors/coin.inc.c
@@ -50,7 +50,7 @@ void bhv_temp_coin_loop(void) {
void bhv_coin_init(void) {
rng_position_init(o->oPosX, o->oPosY, o->oPosZ);
- o->oVelY = random_float() * 10.0f + 30 + o->oCoinUnk110;
+ o->oVelY = random_float() * 10.0f + 30 + o->oCoinBaseYVel;
o->oForwardVel = random_float() * 10.0f;
o->oMoveAngleYaw = random_u16();
rng_position_finish();
@@ -78,11 +78,11 @@ void bhv_coin_loop(void) {
}
if (o->oTimer == 0)
#if defined(VERSION_US)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT_2);
#elif defined(VERSION_EU) || defined(VERSION_SH)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT_EU);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT_EU);
#else
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_SPURT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_SPURT);
#endif
if (o->oVelY < 0)
cur_obj_become_tangible();
@@ -97,12 +97,12 @@ void bhv_coin_loop(void) {
#ifndef VERSION_JP
if (o->oMoveFlags & OBJ_MOVE_BOUNCE) {
if (o->oCoinUnk1B0 < 5)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_DROP);
o->oCoinUnk1B0++;
}
#else
if (o->oMoveFlags & OBJ_MOVE_BOUNCE)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_DROP);
#endif
if (cur_obj_wait_then_blink(400, 20))
obj_mark_for_deletion(o);
@@ -212,7 +212,7 @@ void coin_inside_boo_act_1(void) {
cur_obj_update_floor_and_walls();
cur_obj_if_hit_wall_bounce_away();
if (o->oMoveFlags & OBJ_MOVE_BOUNCE)
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_DROP);
if (o->oTimer > 90 || (o->oMoveFlags & OBJ_MOVE_LANDED)) {
obj_set_hitbox(o, &sYellowCoinHitbox);
cur_obj_become_tangible();
diff --git a/src/game/behaviors/controllable_platform.inc.c b/src/game/behaviors/controllable_platform.inc.c
index b93bbb6f0..4a7180ed9 100644
--- a/src/game/behaviors/controllable_platform.inc.c
+++ b/src/game/behaviors/controllable_platform.inc.c
@@ -34,7 +34,7 @@ void bhv_controllable_platform_sub_loop(void) {
if (o->parentObj) { o->parentObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; }
#endif
o->oAction = 1;
- cur_obj_play_sound_2(SOUND_GENERAL_MOVING_PLATFORM_SWITCH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_MOVING_PLATFORM_SWITCH);
if (o->parentObj) { network_send_object(o->parentObj); }
}
break;
@@ -118,7 +118,7 @@ void controllable_platform_hit_wall(s8 sp1B) {
o->oTimer = 0;
D_80331694 = 5;
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_POUND1);
#ifdef VERSION_SH
queue_rumble_data(50, 80);
#endif
@@ -297,7 +297,7 @@ void bhv_controllable_platform_loop(void) {
o->oPosX += o->oVelX;
o->oPosZ += o->oVelZ;
if (D_80331694 != 0 && D_80331694 != 6)
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR2);
if (sync_object_is_owned_locally(o->oSyncID) && oldD_80331694 != D_80331694) {
network_send_object(o);
diff --git a/src/game/behaviors/cruiser.inc.c b/src/game/behaviors/cruiser.inc.c
index a705bb2c3..72597920e 100644
--- a/src/game/behaviors/cruiser.inc.c
+++ b/src/game/behaviors/cruiser.inc.c
@@ -15,7 +15,7 @@ void bhv_rr_cruiser_wing_loop(void) {
}
#ifndef VERSION_JP
if (o->oTimer == 64) {
- cur_obj_play_sound_2(SOUND_GENERAL_BOAT_ROCK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOAT_ROCK);
o->oTimer = 0;
}
#endif
diff --git a/src/game/behaviors/decorative_pendulum.inc.c b/src/game/behaviors/decorative_pendulum.inc.c
index 2aa9539ff..30bec4f2f 100644
--- a/src/game/behaviors/decorative_pendulum.inc.c
+++ b/src/game/behaviors/decorative_pendulum.inc.c
@@ -27,5 +27,5 @@ void bhv_decorative_pendulum_loop(void) {
* actually one sound played twice in rapid succession.
*/
if (o->oAngleVelRoll == 0x10 || o->oAngleVelRoll == -0x10)
- cur_obj_play_sound_2(SOUND_GENERAL_BIG_CLOCK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BIG_CLOCK);
}
diff --git a/src/game/behaviors/door.inc.c b/src/game/behaviors/door.inc.c
index 0e29f9b47..3158b1e73 100644
--- a/src/game/behaviors/door.inc.c
+++ b/src/game/behaviors/door.inc.c
@@ -56,18 +56,18 @@ void set_door_camera_event(void) {
void play_door_open_noise(void) {
s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR);
if (o->oTimer == 0) {
- cur_obj_play_sound_2(D_8032F328[sp1C]);
+ cur_obj_play_sound_and_rumble_if_visible(D_8032F328[sp1C]);
//gTimeStopState |= TIME_STOP_MARIO_OPENED_DOOR;
}
if (o->oTimer == 70) {
- cur_obj_play_sound_2(D_8032F330[sp1C]);
+ cur_obj_play_sound_and_rumble_if_visible(D_8032F330[sp1C]);
}
}
void play_warp_door_open_noise(void) {
s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR);
if (o->oTimer == 30)
- cur_obj_play_sound_2(D_8032F330[sp1C]);
+ cur_obj_play_sound_and_rumble_if_visible(D_8032F330[sp1C]);
}
void bhv_door_loop(void) {
@@ -120,7 +120,7 @@ void bhv_door_loop(void) {
load_object_collision_model();
o->oIntangibleTimer = 0;
}
- bhv_star_door_loop_2();
+ bhv_star_door_loop_update_render_state();
}
void bhv_door_init(void) {
@@ -155,31 +155,31 @@ void bhv_door_init(void) {
sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS);
}
-void bhv_star_door_loop_2(void) {
- s32 sp4 = 0;
+void bhv_star_door_loop_update_render_state(void) {
+ s32 inSameOrAdjacentRoomToMario = 0;
if (gMarioCurrentRoom != 0) {
if (o->oDoorUnkF8 == gMarioCurrentRoom)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gMarioCurrentRoom == o->oDoorUnkFC)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gMarioCurrentRoom == o->oDoorUnk100)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnkFC)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oDoorUnk100)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnkFC)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
else if (gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oDoorUnk100)
- sp4 = 1;
+ inSameOrAdjacentRoomToMario = 1;
} else
- sp4 = 1;
- if (sp4 == 1) {
+ inSameOrAdjacentRoomToMario = 1;
+ if (inSameOrAdjacentRoomToMario == 1) {
o->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE;
D_8035FEE4++;
}
- if (sp4 == 0) {
+ if (inSameOrAdjacentRoomToMario == 0) {
o->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
}
- o->oDoorUnk88 = sp4;
+ o->oDoorUnk88 = inSameOrAdjacentRoomToMario;
}
diff --git a/src/game/behaviors/dorrie.inc.c b/src/game/behaviors/dorrie.inc.c
index 74001e4e7..2b6d9562c 100644
--- a/src/game/behaviors/dorrie.inc.c
+++ b/src/game/behaviors/dorrie.inc.c
@@ -38,7 +38,7 @@ void dorrie_act_move(void) {
cur_obj_init_animation_with_sound(1);
if (o->oDorrieForwardDistToMario < 320.0f && o->oDorrieGroundPounded) {
- cur_obj_play_sound_2(SOUND_OBJ_DORRIE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DORRIE);
o->collisionData = segmented_to_virtual(dorrie_seg6_collision_0600FBB8);
o->oAction = DORRIE_ACT_LOWER_HEAD;
o->oForwardVel = 0.0f;
diff --git a/src/game/behaviors/drawbridge.inc.c b/src/game/behaviors/drawbridge.inc.c
index 61c6019e2..e11111066 100644
--- a/src/game/behaviors/drawbridge.inc.c
+++ b/src/game/behaviors/drawbridge.inc.c
@@ -54,7 +54,7 @@ void bhv_lll_drawbridge_loop(void) {
// the game at regular intervals can leave the drawbridge raised indefinitely.
if (o->oTimer >= 51 && (globalTimer % 8) == 0) {
o->oAction = LLL_DRAWBRIDGE_ACT_LOWER;
- cur_obj_play_sound_2(SOUND_GENERAL_BOAT_TILT1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOAT_TILT1);
}
}
@@ -65,7 +65,7 @@ void bhv_lll_drawbridge_loop(void) {
// the game at regular intervals can leave the drawbridge lowered indefinitely.
if (o->oTimer >= 51 && (globalTimer % 8) == 0) {
o->oAction = LLL_DRAWBRIDGE_ACT_RAISE;
- cur_obj_play_sound_2(SOUND_GENERAL_BOAT_TILT2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOAT_TILT2);
}
}
}
diff --git a/src/game/behaviors/elevator.inc.c b/src/game/behaviors/elevator.inc.c
index 47190e840..85a5bf94b 100644
--- a/src/game/behaviors/elevator.inc.c
+++ b/src/game/behaviors/elevator.inc.c
@@ -1,7 +1,7 @@
// elevator.c.inc
void elevator_starting_shake(void) {
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_POUND1);
cur_obj_shake_screen(SHAKE_POS_SMALL);
}
@@ -43,7 +43,7 @@ void elevator_act_1(void) {
struct MarioState* marioState = nearest_mario_state_to_object(o);
struct Object* player = marioState ? marioState->marioObj : NULL;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR1);
if (o->oTimer == 0 && cur_obj_is_any_player_on_platform()) {
elevator_starting_shake();
}
@@ -67,7 +67,7 @@ void elevator_act_2(void) { // Pretty similar code to action 1
struct MarioState* marioState = nearest_mario_state_to_object(o);
struct Object* player = marioState ? marioState->marioObj : NULL;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR1);
if (o->oTimer == 0 && cur_obj_is_any_player_on_platform()) {
elevator_starting_shake();
}
@@ -96,7 +96,7 @@ void elevator_act_4(void) {
o->oVelY = 0;
if (o->oTimer == 0) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
- cur_obj_play_sound_2(SOUND_GENERAL_METAL_POUND);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_METAL_POUND);
}
if (marioState && !mario_is_in_air_action(marioState) && !cur_obj_is_any_player_on_platform()) {
o->oAction = 1;
@@ -112,7 +112,7 @@ void elevator_act_3(void) // nearly identical to action 2
o->oVelY = 0;
if (o->oTimer == 0) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
- cur_obj_play_sound_2(SOUND_GENERAL_METAL_POUND);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_METAL_POUND);
}
if (marioState && !mario_is_in_air_action(marioState) && !cur_obj_is_any_player_on_platform()) {
o->oAction = 0;
diff --git a/src/game/behaviors/end_birds_1.inc.c b/src/game/behaviors/end_birds_1.inc.c
index 532c27280..e1b7d7ff7 100644
--- a/src/game/behaviors/end_birds_1.inc.c
+++ b/src/game/behaviors/end_birds_1.inc.c
@@ -19,7 +19,7 @@ void bhv_end_birds_1_loop(void) {
if (gCurrentObject->oTimer < 100)
obj_rotate_towards_point(gCurrentObject, sp34, 0, 0, 0x20, 0x20);
if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0))
- cur_obj_play_sound_2(SOUND_GENERAL_BIRDS_FLY_AWAY);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BIRDS_FLY_AWAY);
if (gCutsceneTimer == 0)
obj_mark_for_deletion(gCurrentObject);
break;
diff --git a/src/game/behaviors/end_birds_2.inc.c b/src/game/behaviors/end_birds_2.inc.c
index 9526448ea..b4dfb82ca 100644
--- a/src/game/behaviors/end_birds_2.inc.c
+++ b/src/game/behaviors/end_birds_2.inc.c
@@ -23,7 +23,7 @@ void bhv_end_birds_2_loop(void) {
obj_rotate_towards_point(gCurrentObject, sp3C, 0, 0, 8, 8);
if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0))
- cur_obj_play_sound_2(SOUND_GENERAL_BIRDS_FLY_AWAY);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BIRDS_FLY_AWAY);
break;
}
diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c
index dad710028..f23966ae2 100644
--- a/src/game/behaviors/enemy_lakitu.inc.c
+++ b/src/game/behaviors/enemy_lakitu.inc.c
@@ -181,7 +181,7 @@ static void enemy_lakitu_sub_act_hold_spiny(void) {
*/
static void enemy_lakitu_sub_act_throw_spiny(void) {
if (cur_obj_init_anim_check_frame(2, 2)) {
- cur_obj_play_sound_2(SOUND_OBJ_EVIL_LAKITU_THROW);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_EVIL_LAKITU_THROW);
o->prevObj = NULL;
}
@@ -196,7 +196,7 @@ static void enemy_lakitu_sub_act_throw_spiny(void) {
*/
static void enemy_lakitu_act_main(void) {
cur_obj_unhide();
- cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY);
+ cur_obj_play_sound_if_visible(SOUND_AIR_LAKITU_FLY);
cur_obj_update_floor_and_walls();
diff --git a/src/game/behaviors/express_elevator.inc.c b/src/game/behaviors/express_elevator.inc.c
index 34268bf68..4aa9ed5f2 100644
--- a/src/game/behaviors/express_elevator.inc.c
+++ b/src/game/behaviors/express_elevator.inc.c
@@ -19,7 +19,7 @@ void bhv_wdw_express_elevator_loop(void) {
} else if (o->oAction == 1) {
o->oVelY = -20.0f;
o->oPosY += o->oVelY;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR4);
if (o->oTimer > 132)
o->oAction++;
} else if (o->oAction == 2) {
@@ -28,7 +28,7 @@ void bhv_wdw_express_elevator_loop(void) {
} else if (o->oAction == 3) {
o->oVelY = 10.0f;
o->oPosY += o->oVelY;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR4);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR4);
if (o->oPosY >= o->oHomeY) {
o->oPosY = o->oHomeY;
o->oAction++;
diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c
index a7157dba5..a344dcc16 100644
--- a/src/game/behaviors/eyerok.inc.c
+++ b/src/game/behaviors/eyerok.inc.c
@@ -115,7 +115,7 @@ static void eyerok_boss_act_sleep(void) {
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000;
if (o->oTimer == 0) {
} else if (distanceToPlayer < 500.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_EYEROK_EXPLODE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_EYEROK_EXPLODE);
o->oAction = EYEROK_BOSS_ACT_WAKE_UP;
}
}
@@ -278,7 +278,7 @@ static s32 eyerok_hand_check_attacked(void) {
struct Object* player = nearest_player_to_object(o);
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
if (o->oEyerokReceivedAttack != 0 && abs_angle_diff(angleToPlayer, o->oFaceAngleYaw) < 0x3000) {
- cur_obj_play_sound_2(SOUND_OBJ2_EYEROK_SOUND_SHORT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_EYEROK_SOUND_SHORT);
if (--o->oHealth >= 2 || !sync_object_is_owned_locally(o->parentObj->oSyncID)) {
o->oAction = EYEROK_HAND_ACT_ATTACKED;
@@ -302,7 +302,7 @@ static s32 eyerok_hand_check_attacked(void) {
}
static void eyerok_hand_pound_ground(void) {
- cur_obj_play_sound_2(SOUND_OBJ_POUNDING_LOUD);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_POUNDING_LOUD);
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
spawn_mist_from_global();
}
@@ -497,7 +497,7 @@ static void eyerok_hand_act_die(void) {
}
if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) {
- cur_obj_play_sound_2(SOUND_OBJ_POUNDING_LOUD);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_POUNDING_LOUD);
o->oForwardVel = 0.0f;
}
}
diff --git a/src/game/behaviors/falling_pillar.inc.c b/src/game/behaviors/falling_pillar.inc.c
index b4c138b6b..793a0fe7c 100644
--- a/src/game/behaviors/falling_pillar.inc.c
+++ b/src/game/behaviors/falling_pillar.inc.c
@@ -79,7 +79,7 @@ void bhv_falling_pillar_loop(void) {
o->oAction = FALLING_PILLAR_ACT_TURNING;
// Play the detaching sound.
- cur_obj_play_sound_2(SOUND_GENERAL_POUND_ROCK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_POUND_ROCK);
}
break;
diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c
index 049667f3e..bd27e1ce3 100644
--- a/src/game/behaviors/fire_piranha_plant.inc.c
+++ b/src/game/behaviors/fire_piranha_plant.inc.c
@@ -61,7 +61,7 @@ static void fire_piranha_plant_act_hide(void) {
if (cur_obj_check_if_near_animation_end()) {
if (--o->oFirePiranhaPlantDeathSpinTimer == 0) {
- cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
}
}
} else if (approach_f32_ptr(&o->oFirePiranhaPlantScale, 0.0f,
@@ -83,7 +83,7 @@ static void fire_piranha_plant_act_hide(void) {
}
} else if (sNumActiveFirePiranhaPlants < 2 && o->oTimer > 100 && distanceToPlayer > 100.0f
&& distanceToPlayer < 800.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_PIRANHA_PLANT_APPEAR);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_PIRANHA_PLANT_APPEAR);
o->oFirePiranhaPlantActive = TRUE;
sNumActiveFirePiranhaPlants += 1;
@@ -108,7 +108,7 @@ static void fire_piranha_plant_act_grow(void) {
if (approach_f32_ptr(&o->oFirePiranhaPlantScale, o->oFirePiranhaPlantNeutralScale,
0.04f * o->oFirePiranhaPlantNeutralScale)) {
if (o->oTimer > 80) {
- cur_obj_play_sound_2(SOUND_OBJ_PIRANHA_PLANT_SHRINK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_PIRANHA_PLANT_SHRINK);
o->oAction = FIRE_PIRANHA_PLANT_ACT_HIDE;
cur_obj_init_animation_with_sound(0);
} else if (o->oTimer < 50) {
@@ -116,7 +116,7 @@ static void fire_piranha_plant_act_grow(void) {
} else { // TODO: Check if we can put these conditionals on same line
if (obj_is_rendering_enabled()) {
if (cur_obj_check_anim_frame(56)) {
- cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_FLAME_BLOWN);
obj_spit_fire(0, (s32)(30.0f * o->oFirePiranhaPlantNeutralScale),
(s32)(140.0f * o->oFirePiranhaPlantNeutralScale),
2.5f * o->oFirePiranhaPlantNeutralScale, MODEL_RED_FLAME_SHADOW,
diff --git a/src/game/behaviors/fire_spitter.inc.c b/src/game/behaviors/fire_spitter.inc.c
index 1afb63580..d736fc76d 100644
--- a/src/game/behaviors/fire_spitter.inc.c
+++ b/src/game/behaviors/fire_spitter.inc.c
@@ -27,7 +27,7 @@ static void fire_spitter_act_spit_fire(void) {
o->oAction = FIRE_SPITTER_ACT_IDLE;
} else {
if (sync_object_is_owned_locally(o->oSyncID)) {
- cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_FLAME_BLOWN);
struct Object* fire = obj_spit_fire(0, 0, 0, 5.0f, MODEL_RED_FLAME_SHADOW, 20.0f, 15.0f, 0x1000);
struct Object* spawn_objects[] = { fire };
@@ -41,7 +41,7 @@ static void fire_spitter_act_spit_fire(void) {
}
static void bhv_fire_spitter_on_received_post(UNUSED u8 localIndex) {
- cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_FLAME_BLOWN);
}
void bhv_fire_spitter_update(void) {
diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c
index 604e55f50..93fe96871 100644
--- a/src/game/behaviors/fish.inc.c
+++ b/src/game/behaviors/fish.inc.c
@@ -182,7 +182,7 @@ static void fish_act_flee(void) {
distance = (s32)(1.0 / (distanceToPlayer / 600.0));
}
distance *= 127;
- cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_MOVING_WATER);
}
// Speed the animation up over time.
diff --git a/src/game/behaviors/flamethrower.inc.c b/src/game/behaviors/flamethrower.inc.c
index b69ecb236..61dbf9aa2 100644
--- a/src/game/behaviors/flamethrower.inc.c
+++ b/src/game/behaviors/flamethrower.inc.c
@@ -73,7 +73,7 @@ void bhv_flamethrower_loop(void) {
o->oFlameThowerUnk110 = sp34;
flame = spawn_object_relative(o->oBehParams2ndByte, 0, 0, 0, o, model, bhvFlamethrowerFlame);
if (flame != NULL) { flame->oForwardVel = flameVel; }
- cur_obj_play_sound_1(SOUND_AIR_BLOW_FIRE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BLOW_FIRE);
} else if (o->oTimer > 60)
o->oAction = 0;
}
diff --git a/src/game/behaviors/fly_guy.inc.c b/src/game/behaviors/fly_guy.inc.c
index 537b4c549..d6a71d027 100644
--- a/src/game/behaviors/fly_guy.inc.c
+++ b/src/game/behaviors/fly_guy.inc.c
@@ -172,7 +172,7 @@ static void fly_guy_act_shoot_fire(void) {
} else {
// We have reached below scale 1.2 in the shrinking portion
s16 fireMovePitch = marioState ? obj_turn_pitch_toward_mario(marioState, 0.0f, 0) : 0;
- cur_obj_play_sound_2(SOUND_OBJ_FLAME_BLOWN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_FLAME_BLOWN);
clamp_s16(&fireMovePitch, 0x800, 0x3000);
if (sync_object_is_owned_locally(o->oSyncID)) {
diff --git a/src/game/behaviors/flying_bookend_switch.inc.c b/src/game/behaviors/flying_bookend_switch.inc.c
index e48acf338..7d06752e8 100644
--- a/src/game/behaviors/flying_bookend_switch.inc.c
+++ b/src/game/behaviors/flying_bookend_switch.inc.c
@@ -38,7 +38,7 @@ struct ObjectHitbox sBookSwitchHitbox = {
void flying_bookend_act_0(void) {
struct MarioState* marioState = nearest_mario_state_to_object(o);
if (marioState && obj_is_near_to_and_facing_mario(marioState, 400.0f, 0x3000)) {
- cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DEFAULT_DEATH);
o->oAction = 1;
o->oBookendUnkF4 = o->oFaceAnglePitch + 0x7FFF;
o->oBookendUnkF8 = o->oFaceAngleRoll - 0x7FFF;
@@ -152,7 +152,7 @@ void bhv_bookend_spawn_loop(void) {
u32 models[] = { MODEL_BOOKEND };
network_send_spawn_objects(spawn_objects, models, 1);
- cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DEFAULT_DEATH);
}
o->oTimer = 0;
}
@@ -355,7 +355,7 @@ void bhv_book_switch_loop(void) {
}
if (o->oBookSwitchUnkF4 == 0.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_DEFAULT_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DEFAULT_DEATH);
}
if (approach_f32_ptr(&o->oBookSwitchUnkF4, 50.0f, 20.0f)) {
diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c
index 209e1def7..103afce2a 100644
--- a/src/game/behaviors/goomba.inc.c
+++ b/src/game/behaviors/goomba.inc.c
@@ -125,7 +125,7 @@ void bhv_goomba_init(void) {
* Enter the jump action and set initial y velocity.
*/
static void goomba_begin_jump(void) {
- cur_obj_play_sound_2(SOUND_OBJ_GOOMBA_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_GOOMBA_ALERT);
o->oAction = GOOMBA_ACT_JUMP;
o->oForwardVel = 0.0f;
o->oVelY = 50.0f / 3.0f * o->oGoombaScale;
diff --git a/src/game/behaviors/grand_star.inc.c b/src/game/behaviors/grand_star.inc.c
index e74edff5e..0e608eb22 100644
--- a/src/game/behaviors/grand_star.inc.c
+++ b/src/game/behaviors/grand_star.inc.c
@@ -63,7 +63,7 @@ void bhv_grand_star_loop(void) {
if (o->oTimer == 0) {
obj_set_angle(o, 0, 0, 0);
o->oAngleVelYaw = 0x400;
- cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_STAR_APPEARS);
}
if (o->oTimer > 70) {
o->oAction++;
@@ -74,7 +74,7 @@ void bhv_grand_star_loop(void) {
Vec3f empty;
empty[0] = empty[1] = empty[2] = 0.0f;
- cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_GRAND_STAR);
cutscene_object(CUTSCENE_STAR_SPAWN, o);
o->oGrandStarUnk108 = arc_to_goal_pos(empty, &o->oPosX, 80.0f, -2.0f);
}
@@ -85,7 +85,7 @@ void bhv_grand_star_loop(void) {
o->oVelY = 60.0f;
o->oForwardVel = 0.0f;
o->oSubAction++;
- cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_GRAND_STAR_JUMP);
}
} else if (o->oVelY < 0.0f && o->oPosY < o->oHomeY + 200.0f) {
o->oPosY = o->oHomeY + 200.0f;
@@ -94,7 +94,7 @@ void bhv_grand_star_loop(void) {
set_mario_npc_dialog(&gMarioStates[0], 0, NULL);
o->oAction++;
o->oInteractStatus = 0;
- cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_GRAND_STAR_JUMP);
}
spawn_sparkle_particles(3, 200, 80, -60);
} else if (o->oAction == 2) {
diff --git a/src/game/behaviors/grill_door.inc.c b/src/game/behaviors/grill_door.inc.c
index 76c1596e1..d1ba17bc0 100644
--- a/src/game/behaviors/grill_door.inc.c
+++ b/src/game/behaviors/grill_door.inc.c
@@ -45,7 +45,7 @@ void bhv_openable_grill_loop(void) {
grillObj = o->oOpenableGrillUnkF4;
if (grillObj && grillObj->oAction == 2) {
o->oOpenableGrillUnk88 = 2;
- cur_obj_play_sound_2(SOUND_GENERAL_CAGE_OPEN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_CAGE_OPEN);
o->oAction++;
if (o->oBehParams2ndByte != 0)
play_puzzle_jingle();
diff --git a/src/game/behaviors/haunted_chair.inc.c b/src/game/behaviors/haunted_chair.inc.c
index 57cc82dcc..788bd550f 100644
--- a/src/game/behaviors/haunted_chair.inc.c
+++ b/src/game/behaviors/haunted_chair.inc.c
@@ -81,7 +81,7 @@ void haunted_chair_act_0(void) {
f32 val08;
if (o->oFaceAnglePitch < 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_HAUNTED_CHAIR_MOVE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_HAUNTED_CHAIR_MOVE);
val08 = 4.0f;
} else {
val08 = -4.0f;
@@ -126,7 +126,7 @@ void haunted_chair_act_1(void) {
} else {
if (o->oHauntedChairUnkF4 != 0) {
if (--o->oHauntedChairUnkF4 == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_HAUNTED_CHAIR);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_HAUNTED_CHAIR);
if (marioState) {
o->oMoveAnglePitch = obj_turn_pitch_toward_mario(marioState, 120.0f, 0);
}
@@ -134,7 +134,7 @@ void haunted_chair_act_1(void) {
obj_compute_vel_from_move_pitch(50.0f);
} else if (o->oHauntedChairUnkF4 > 20) {
if (gGlobalTimer % 4 == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_AIR_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_AIR_2);
}
o->oFaceAngleYaw += 0x2710;
}
diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c
index 159676e8f..37e966b35 100644
--- a/src/game/behaviors/heave_ho.inc.c
+++ b/src/game/behaviors/heave_ho.inc.c
@@ -19,7 +19,7 @@ void bhv_heave_ho_throw_mario_loop(void) {
case 1:
break;
case 2:
- cur_obj_play_sound_2(SOUND_OBJ_HEAVEHO_TOSSED);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_HEAVEHO_TOSSED);
if (player) {
player->oInteractStatus |= INT_STATUS_MARIO_UNK2;
}
@@ -108,7 +108,7 @@ void heave_ho_move(void) {
else
o->oGraphYOffset = 0.0f;
if (o->oForwardVel > 3.0f)
- cur_obj_play_sound_1(SOUND_AIR_HEAVEHO_MOVE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_HEAVEHO_MOVE);
if (o->oAction != 0 && o->oMoveFlags & OBJ_MOVE_MASK_IN_WATER)
o->oAction = 0;
if (o->oInteractStatus & INT_STATUS_GRABBED_MARIO) {
diff --git a/src/game/behaviors/hoot.inc.c b/src/game/behaviors/hoot.inc.c
index 8285f86b6..bcea39520 100644
--- a/src/game/behaviors/hoot.inc.c
+++ b/src/game/behaviors/hoot.inc.c
@@ -88,7 +88,7 @@ void hoot_free_step(s16 fastOscY, s32 speed) {
}
if (sp26 == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
}
void hoot_player_set_yaw(void) {
@@ -125,7 +125,7 @@ void hoot_carry_step(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev) {
o->oPosZ += o->oVelZ;
if (sp22 == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
}
// sp48 = xPrev
@@ -160,9 +160,9 @@ void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev) {
return;
}
- if (absf_2(o->oPosX) > 8000.0f)
+ if (absf(o->oPosX) > 8000.0f)
o->oPosX = xPrev;
- if (absf_2(o->oPosZ) > 8000.0f)
+ if (absf(o->oPosZ) > 8000.0f)
o->oPosZ = zPrev;
if (floorY + 125.0f > o->oPosY)
o->oPosY = floorY + 125.0f;
@@ -180,7 +180,7 @@ void hoot_act_ascent(f32 xPrev, f32 zPrev) {
o->oMoveAnglePitch = 0xCE38;
if (o->oTimer >= 29) {
- cur_obj_play_sound_1(SOUND_ENV_WIND2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WIND2);
o->header.gfx.animInfo.animFrame = 1;
}
diff --git a/src/game/behaviors/horizontal_grindel.inc.c b/src/game/behaviors/horizontal_grindel.inc.c
index e2f001de2..ddecba5b8 100644
--- a/src/game/behaviors/horizontal_grindel.inc.c
+++ b/src/game/behaviors/horizontal_grindel.inc.c
@@ -14,7 +14,7 @@ void bhv_horizontal_grindel_init(void) {
void bhv_horizontal_grindel_update(void) {
if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) {
if (!o->oHorizontalGrindelOnGround) {
- cur_obj_play_sound_2(SOUND_OBJ_THWOMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_THWOMP);
o->oHorizontalGrindelOnGround = TRUE;
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
@@ -29,7 +29,7 @@ void bhv_horizontal_grindel_update(void) {
o->oHorizontalGrindelTargetYaw += 0x8000;
o->oHorizontalGrindelDistToHome = 0.0f;
} else {
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB_JUMP);
o->oForwardVel = 11.0f;
o->oVelY = 70.0f;
o->oGravity = -4.0f;
diff --git a/src/game/behaviors/intro_lakitu.inc.c b/src/game/behaviors/intro_lakitu.inc.c
index ea1095f02..1d7dcbc03 100644
--- a/src/game/behaviors/intro_lakitu.inc.c
+++ b/src/game/behaviors/intro_lakitu.inc.c
@@ -82,7 +82,7 @@ void bhv_intro_lakitu_loop(void) {
gCurrentObject->oPosZ = gCamera->pos[2];
}
if (gCutsceneTimer > 52)
- cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
+ cur_obj_play_sound_if_visible(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
if (intro_lakitu_set_pos_and_focus(gCurrentObject, gIntroLakituStartToPipeOffsetFromCamera,
gIntroLakituStartToPipeFocus) == 1)
@@ -91,10 +91,10 @@ void bhv_intro_lakitu_loop(void) {
switch (gCurrentObject->oTimer) {
#if defined(VERSION_US) || defined(VERSION_SH)
case 534:
- cur_obj_play_sound_2(SOUND_ACTION_FLYING_FAST);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_FLYING_FAST);
break;
case 581:
- cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45E);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_INTRO_UNK45E);
break;
#endif
case 73:
@@ -112,9 +112,9 @@ void bhv_intro_lakitu_loop(void) {
}
#ifdef VERSION_EU
if (gCurrentObject->oTimer == 446)
- cur_obj_play_sound_2(SOUND_ACTION_FLYING_FAST);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_FLYING_FAST);
if (gCurrentObject->oTimer == 485)
- cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45E);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_INTRO_UNK45E);
#endif
break;
case 2:
@@ -132,11 +132,11 @@ void bhv_intro_lakitu_loop(void) {
gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw + 0x4000;
gCurrentObject->oMoveAnglePitch = 0x800;
}
- cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
+ cur_obj_play_sound_if_visible(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
break;
case 3:
- cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
+ cur_obj_play_sound_if_visible(SOUND_AIR_LAKITU_FLY_HIGHPRIO);
vec3f_set(sp58, -1128.f, 560.f, 4664.f);
sp58[0] -= gNetworkPlayers[0].globalIndex * 350.f;
gCurrentObject->oMoveAngleYaw += 0x200;
@@ -174,7 +174,7 @@ void bhv_intro_lakitu_loop(void) {
}
#ifndef VERSION_JP
if (gCurrentObject->oTimer == 14)
- cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45F);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_ACTION_INTRO_UNK45F);
#endif
break;
case 100:
diff --git a/src/game/behaviors/jrb_ship.inc.c b/src/game/behaviors/jrb_ship.inc.c
index 9500272dc..20d1aa374 100644
--- a/src/game/behaviors/jrb_ship.inc.c
+++ b/src/game/behaviors/jrb_ship.inc.c
@@ -40,7 +40,7 @@ void bhv_ship_part_3_loop(void) {
o->oAngleVelPitch = o->oFaceAnglePitch - sp1E;
o->oAngleVelRoll = o->oFaceAngleRoll - sp1C;
if (gMarioObject && gMarioObject->oPosY > 1000.0f) {
- cur_obj_play_sound_1(SOUND_ENV_BOAT_ROCKING1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_BOAT_ROCKING1);
}
}
@@ -106,7 +106,7 @@ void bhv_jrb_sliding_box_loop(void) {
o->oParentRelativePosZ += o->oJrbSlidingBoxUnkFC;
if (gMarioObject && gMarioObject->oPosY > 1000.0f) {
if (absf(o->oJrbSlidingBoxUnkFC) > 3.0f) {
- cur_obj_play_sound_1(SOUND_AIR_ROUGH_SLIDE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_ROUGH_SLIDE);
}
}
diff --git a/src/game/behaviors/kickable_board.inc.c b/src/game/behaviors/kickable_board.inc.c
index c9a1812e0..506b5c25f 100644
--- a/src/game/behaviors/kickable_board.inc.c
+++ b/src/game/behaviors/kickable_board.inc.c
@@ -57,7 +57,7 @@ void bhv_kickable_board_loop(void) {
if (o->oTimer > 30 && (sp24 = check_mario_attacking(marioState))) {
if (marioState->marioObj->oPosY > o->oPosY + 160.0f && sp24 == 2) {
o->oAction++;
- cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BUTTON_PRESS_2);
if (sync_object_is_owned_locally(o->oSyncID)) { network_send_object(o); }
} else
o->oTimer = 0;
@@ -72,7 +72,7 @@ void bhv_kickable_board_loop(void) {
} else
init_kickable_board_rock();
if (!(o->oKickableBoardF4 & 0x7FFF))
- cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BUTTON_PRESS_2);
o->oKickableBoardF4 += 0x400;
break;
case 2:
@@ -85,7 +85,7 @@ void bhv_kickable_board_loop(void) {
o->oAngleVelPitch = 0;
o->oAction++;
cur_obj_shake_screen(SHAKE_POS_SMALL);
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN4);
if (sync_object_is_owned_locally(o->oSyncID)) { network_send_object(o); }
}
load_object_collision_model();
diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c
index 3047a3bbb..71e267bb3 100644
--- a/src/game/behaviors/king_bobomb.inc.c
+++ b/src/game/behaviors/king_bobomb.inc.c
@@ -41,7 +41,7 @@ Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx)
}
void bhv_bobomb_anchor_mario_loop(void) {
- common_anchor_mario_behavior(50.0f, 50.0f, 64);
+ common_anchor_mario_behavior(50.0f, 50.0f, INT_STATUS_MARIO_UNK6);
}
u8 king_bobomb_act_0_continue_dialog(void) { return o->oAction == 0 && o->oSubAction != 0; }
@@ -58,7 +58,7 @@ void king_bobomb_act_0(void) {
cur_obj_init_animation_with_sound(5);
cur_obj_set_pos_to_home();
o->oHealth = gBehaviorValues.KingBobombHealth;
- if (marioState && should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f)) {
+ if (marioState && should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox(&gMarioStates[0], 500.0f, 100.0f, 0x1000)) {
o->oSubAction++;
seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40);
}
@@ -119,7 +119,7 @@ void king_bobomb_act_3(void) {
o->oKingBobombUnk104 = 0;
o->oKingBobombUnkFC = 0;
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN3);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN3);
if (cur_obj_init_animation_and_check_if_near_end(0)) {
o->oSubAction++;
cur_obj_init_animation_and_anim_frame(1, 0);
@@ -147,7 +147,7 @@ void king_bobomb_act_3(void) {
cur_obj_init_animation_with_sound(9);
if (cur_obj_check_anim_frame(31)) {
o->oKingBobombUnk88 = 2;
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN4);
} else if (cur_obj_check_if_near_animation_end()) {
o->oAction = 1;
o->oInteractStatus &= ~(INT_STATUS_GRABBED_MARIO);
@@ -182,8 +182,8 @@ void king_bobomb_act_6(void) {
if (o->oSubAction == 0) {
if (o->oTimer == 0) {
o->oKingBobombUnk104 = 0;
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
- cur_obj_play_sound_2(SOUND_OBJ2_KING_BOBOMB_DAMAGE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_KING_BOBOMB_DAMAGE);
cur_obj_shake_screen(SHAKE_POS_SMALL);
spawn_mist_particles_variable(0, 0, 100.0f);
o->oInteractType = 8;
@@ -267,7 +267,7 @@ void king_bobomb_act_4(void) { // bobomb been thrown
o->oHealth--;
o->oForwardVel = 0;
o->oVelY = 0;
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB);
if (o->oHealth)
o->oAction = 6;
else
@@ -280,7 +280,7 @@ void king_bobomb_act_4(void) { // bobomb been thrown
o->oVelY = 0;
o->oSubAction++;
} else if (o->oMoveFlags & OBJ_MOVE_LANDED)
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB);
} else {
if (cur_obj_init_animation_and_check_if_near_end(10))
o->oAction = 5; // Go back to top of hill
@@ -296,7 +296,7 @@ void king_bobomb_act_5(void) { // bobomb returns home
switch (o->oSubAction) {
case 0:
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB_JUMP);
o->oKingBobombUnkF8 = 1;
cur_obj_init_animation_and_extend_if_at_end(8);
o->oMoveAngleYaw = cur_obj_angle_to_home();
@@ -316,7 +316,7 @@ void king_bobomb_act_5(void) { // bobomb returns home
o->oGravity = -4.0f;
o->oKingBobombUnkF8 = 0;
cur_obj_init_animation_with_sound(7);
- cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_BOBOMB);
cur_obj_shake_screen(SHAKE_POS_SMALL);
o->oSubAction++;
}
@@ -330,7 +330,7 @@ void king_bobomb_act_5(void) { // bobomb returns home
o->oAction = 0;
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
}
- if (marioState && should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f))
+ if (marioState && should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox(&gMarioStates[0], 500.0f, 100.0f, 0x1000))
o->oSubAction++;
break;
case 4:
diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c
index 27161e5ba..fe870f51d 100644
--- a/src/game/behaviors/klepto.inc.c
+++ b/src/game/behaviors/klepto.inc.c
@@ -34,12 +34,12 @@ static s32 klepto_set_and_check_if_anim_at_end(void) {
cur_obj_set_anim_if_at_end(5);
} else if (o->oSoundStateID == 5) {
if (cur_obj_set_anim_if_at_end(0)) {
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
o->header.gfx.animInfo.animFrame = 9;
}
} else {
if (cur_obj_check_anim_frame(9)) {
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
}
return TRUE;
}
@@ -54,7 +54,7 @@ static void klepto_anim_dive(void) {
} else {
if (o->oSoundStateID == 0) {
if (cur_obj_check_anim_frame(9)) {
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
cur_obj_init_animation_with_sound(6);
}
} else if (--o->oKleptoUnk1AE == 0) {
@@ -231,7 +231,7 @@ static void klepto_act_turn_toward_mario(void) {
if (klepto_set_and_check_if_anim_at_end() && cur_obj_check_if_at_animation_end() && o->oKleptoDistanceToTarget > 800.0f
&& abs_angle_diff(angleToPlayer, o->oFaceAngleYaw) < 0x800 && o->oKleptoUnk1B0 < 0x400) {
- cur_obj_play_sound_2(SOUND_OBJ_KLEPTO1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KLEPTO1);
o->oAction = KLEPTO_ACT_DIVE_AT_MARIO;
o->oMoveAngleYaw = o->oFaceAngleYaw;
o->oFlags |= 0x00000008;
@@ -252,7 +252,7 @@ static void klepto_act_dive_at_mario(void) {
approach_f32_ptr(&o->oKleptoSpeed, 60.0f, 10.0f);
if (o->oSoundStateID == 2) {
if (cur_obj_check_anim_frame(11)) {
- cur_obj_play_sound_2(SOUND_GENERAL_SWISH_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_SWISH_WATER);
}
if (cur_obj_set_anim_if_at_end(0)) {
@@ -408,7 +408,7 @@ void bhv_klepto_update(void) {
}
if (obj_handle_attacks(&sKleptoHitbox, o->oAction, sKleptoAttackHandlers)) {
- cur_obj_play_sound_2(SOUND_OBJ_KLEPTO2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KLEPTO2);
u8 kleptoHoldingCap = (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_CAP);
diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c
index 5b67aeece..78a2a00d3 100644
--- a/src/game/behaviors/koopa.inc.c
+++ b/src/game/behaviors/koopa.inc.c
@@ -340,7 +340,7 @@ static void koopa_shelled_act_lying(void) {
*/
void shelled_koopa_attack_handler(s32 attackType) {
if (o->header.gfx.scale[0] > 0.8f) {
- cur_obj_play_sound_2(SOUND_OBJ_KOOPA_DAMAGE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KOOPA_DAMAGE);
o->oKoopaMovementType = KOOPA_BP_UNSHELLED;
o->oAction = KOOPA_UNSHELLED_ACT_LYING;
@@ -583,7 +583,7 @@ static void koopa_unshelled_update(void) {
*/
s32 obj_begin_race(s32 noTimer) {
if (o->oTimer == 50) {
- cur_obj_play_sound_2(SOUND_GENERAL_RACE_GUN_SHOT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_RACE_GUN_SHOT);
if (!noTimer) {
play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE), 0);
@@ -614,7 +614,7 @@ static void koopa_the_quick_act_wait_before_race(void) {
if (o->oKoopaTheQuickInitTextboxCooldown != 0) {
o->oKoopaTheQuickInitTextboxCooldown -= 1;
- } else if (marioState == &gMarioStates[0] && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 400.0f, 400.0f)) {
+ } else if (marioState == &gMarioStates[0] && cur_obj_can_mario_activate_textbox(&gMarioStates[0], 400.0f, 400.0f, 0x1000)) {
//! The next action doesn't execute until next frame, giving mario one
// frame where he can jump, and thus no longer be ready to speak.
// (On J, he has two frames and doing this enables time stop - see
@@ -847,7 +847,7 @@ static void koopa_the_quick_act_after_race(void) {
if (!o->parentObj) { return; }
if (o->parentObj->oKoopaRaceEndpointUnk100 == 0) {
- if (marioState == &gMarioStates[0] && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 400.0f, 400.0f)) {
+ if (marioState == &gMarioStates[0] && cur_obj_can_mario_activate_textbox(&gMarioStates[0], 400.0f, 400.0f, 0x1000)) {
stop_background_music(SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE));
// Determine which text to display
diff --git a/src/game/behaviors/lll_hexagonal_ring.inc.c b/src/game/behaviors/lll_hexagonal_ring.inc.c
index 4e2d3b968..c9bc3773e 100644
--- a/src/game/behaviors/lll_hexagonal_ring.inc.c
+++ b/src/game/behaviors/lll_hexagonal_ring.inc.c
@@ -13,7 +13,7 @@ void hexagonal_ring_spawn_flames(void) {
obj_scale_xyz(sp1C, size, size, size);
}
if (random_float() < 0.1)
- cur_obj_play_sound_2(SOUND_GENERAL_VOLCANO_EXPLOSION);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_VOLCANO_EXPLOSION);
}
void bhv_lll_rotating_hexagonal_ring_loop(void) {
diff --git a/src/game/behaviors/manta_ray.inc.c b/src/game/behaviors/manta_ray.inc.c
index 627b0a03c..ea0b7c60a 100644
--- a/src/game/behaviors/manta_ray.inc.c
+++ b/src/game/behaviors/manta_ray.inc.c
@@ -81,7 +81,7 @@ static void manta_ray_move(void) {
cur_obj_set_pos_via_transform();
if (animFrame == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_MOVING_WATER);
}
}
diff --git a/src/game/behaviors/metal_box.inc.c b/src/game/behaviors/metal_box.inc.c
index ddc24ce85..498107aa4 100644
--- a/src/game/behaviors/metal_box.inc.c
+++ b/src/game/behaviors/metal_box.inc.c
@@ -12,14 +12,14 @@ struct ObjectHitbox sMetalBoxHitbox = {
.hurtboxHeight = 300,
};
-s32 check_if_moving_over_floor(f32 a0, f32 a1) {
+s32 check_if_moving_over_floor(f32 maxDistToFloor, f32 distance) {
if (!o) { return 0; }
- struct Surface *sp24;
- f32 sp20 = o->oPosX + sins(o->oMoveAngleYaw) * a1;
+ struct Surface *floor;
+ f32 destX = o->oPosX + sins(o->oMoveAngleYaw) * distance;
f32 floorHeight;
- f32 sp18 = o->oPosZ + coss(o->oMoveAngleYaw) * a1;
- floorHeight = find_floor(sp20, o->oPosY, sp18, &sp24);
- if (absf(floorHeight - o->oPosY) < a0) // abs
+ f32 destZ = o->oPosZ + coss(o->oMoveAngleYaw) * distance;
+ floorHeight = find_floor(destX, o->oPosY, destZ, &floor);
+ if (absf(floorHeight - o->oPosY) < maxDistToFloor) // abs
return 1;
else
return 0;
@@ -45,7 +45,7 @@ void bhv_pushable_loop(void) {
o->oMoveAngleYaw = (s16)((player->oMoveAngleYaw + 0x2000) & 0xc000);
if (check_if_moving_over_floor(8.0f, 150.0f)) {
o->oForwardVel = 4.0f;
- cur_obj_play_sound_1(SOUND_ENV_METAL_BOX_PUSH);
+ cur_obj_play_sound_if_visible(SOUND_ENV_METAL_BOX_PUSH);
}
}
}
diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c
index 24fcb578c..0f3dc8b0e 100644
--- a/src/game/behaviors/mips.inc.c
+++ b/src/game/behaviors/mips.inc.c
@@ -176,10 +176,10 @@ void bhv_mips_act_follow_path(void) {
// Play sounds during walk animation.
if (cur_obj_check_if_near_animation_end() == 1 && (collisionFlags & OBJ_COL_FLAG_UNDERWATER)) {
- cur_obj_play_sound_2(SOUND_OBJ_MIPS_RABBIT_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MIPS_RABBIT_WATER);
spawn_object(o, MODEL_NONE, bhvShallowWaterSplash);
} else if (cur_obj_check_if_near_animation_end() == 1) {
- cur_obj_play_sound_2(SOUND_OBJ_MIPS_RABBIT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MIPS_RABBIT);
}
}
@@ -315,7 +315,7 @@ void bhv_mips_dropped(void) {
* Handles MIPS being thrown by Mario.
*/
void bhv_mips_thrown(void) {
- cur_obj_enable_rendering_2();
+ cur_obj_enable_rendering();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
o->oHeldState = HELD_FREE;
o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW;
diff --git a/src/game/behaviors/moneybag.inc.c b/src/game/behaviors/moneybag.inc.c
index 3082c1550..7617323a6 100644
--- a/src/game/behaviors/moneybag.inc.c
+++ b/src/game/behaviors/moneybag.inc.c
@@ -77,7 +77,7 @@ void moneybag_jump(s8 collisionFlags) {
if (cur_obj_check_if_near_animation_end() == 1) {
o->oMoneybagJumpState = MONEYBAG_JUMP_JUMP;
- cur_obj_play_sound_2(SOUND_GENERAL_BOING2_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BOING2_LOWPRIO);
}
break;
@@ -159,7 +159,7 @@ void moneybag_act_return_home(void) {
if (is_point_close_to_object(o, o->oHomeX, o->oHomeY, o->oHomeZ, 100)) {
spawn_object(o, MODEL_YELLOW_COIN, bhvMoneybagHidden);
#ifndef VERSION_JP
- cur_obj_play_sound_2(SOUND_GENERAL_VANISH_SFX);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_VANISH_SFX);
#endif
cur_obj_init_animation(0);
o->oAction = MONEYBAG_ACT_DISAPPEAR;
@@ -239,7 +239,7 @@ void bhv_moneybag_hidden_loop(void) {
if (sync_object_is_owned_locally(o->oSyncID)) {
struct Object* moneyBag = spawn_object(o, MODEL_MONEYBAG, bhvMoneybag);
#ifndef VERSION_JP
- cur_obj_play_sound_2(SOUND_GENERAL_VANISH_SFX);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_VANISH_SFX);
#endif
o->oAction = FAKE_MONEYBAG_COIN_ACT_TRANSFORM;
diff --git a/src/game/behaviors/monty_mole.inc.c b/src/game/behaviors/monty_mole.inc.c
index f7821d558..3bdf642f7 100644
--- a/src/game/behaviors/monty_mole.inc.c
+++ b/src/game/behaviors/monty_mole.inc.c
@@ -211,7 +211,7 @@ static void monty_mole_act_select_hole(void) {
o->oMontyMoleHoleY = o->oMontyMoleCurrentHole->oPosY;
o->oMontyMoleHoleZ = o->oMontyMoleCurrentHole->oPosZ;
- cur_obj_play_sound_2(SOUND_OBJ2_MONTY_MOLE_APPEAR);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_MONTY_MOLE_APPEAR);
// Mark hole as unavailable
o->oMontyMoleCurrentHole->oMontyMoleHoleCooldown = -1;
@@ -311,7 +311,7 @@ static void monty_mole_act_begin_jump_into_hole(void) {
*/
static void monty_mole_act_throw_rock(void) {
if (cur_obj_init_anim_check_frame(8, 10)) {
- cur_obj_play_sound_2(SOUND_OBJ_MONTY_MOLE_ATTACK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MONTY_MOLE_ATTACK);
o->prevObj = NULL;
}
diff --git a/src/game/behaviors/moving_coin.inc.c b/src/game/behaviors/moving_coin.inc.c
index d3eb8257a..fc8310af7 100644
--- a/src/game/behaviors/moving_coin.inc.c
+++ b/src/game/behaviors/moving_coin.inc.c
@@ -33,7 +33,7 @@ s32 coin_step(s16 *collisionFlagsPtr) {
if ((*collisionFlagsPtr & 0x1) != 0 && (*collisionFlagsPtr & 0x8) == 0) /* bit 0, bit 3 */
{
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_DROP);
return 1;
}
@@ -118,7 +118,7 @@ void bhv_moving_blue_coin_loop(void) {
{
o->oForwardVel += 25.0f;
if (!(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL))
- cur_obj_play_sound_2(SOUND_GENERAL_COIN_DROP); /* bit 3 */
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_COIN_DROP); /* bit 3 */
} else
o->oForwardVel *= 0.98;
diff --git a/src/game/behaviors/mr_blizzard.inc.c b/src/game/behaviors/mr_blizzard.inc.c
index a38c3c2e7..9107945ed 100644
--- a/src/game/behaviors/mr_blizzard.inc.c
+++ b/src/game/behaviors/mr_blizzard.inc.c
@@ -114,7 +114,7 @@ static void mr_blizzard_act_hide_unhide(void) {
if (distanceToPlayer < 1000.0f) {
// If Mario is in range, move to rising action, make Mr. Blizzard visible,
// make Mr. Blizzard tangible, and initialize GraphYVel.
- cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNOW_SAND2);
o->oAction = MR_BLIZZARD_ACT_RISE_FROM_GROUND;
o->oMoveAngleYaw = angleToPlayer;
o->oMrBlizzardGraphYVel = 42.0f;
@@ -240,7 +240,7 @@ static void mr_blizzard_act_death(void) {
if (clamp_f32(&o->oMrBlizzardDizziness, -0x4000, 0x4000)) {
if (o->oMrBlizzardChangeInDizziness != 0.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNOW_SAND1);
// If Mr. Blizzard is wearing Mario's cap, clear
// the save flag and spawn Mario's cap.
if (o->oAnimState) {
@@ -273,7 +273,7 @@ static void mr_blizzard_act_death(void) {
// at .03 units per frame. Spawn coins and set the coins to not respawn.
if (o->oTimer >= 30) {
if (o->oTimer == 30) {
- cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
}
if (o->oMrBlizzardScale != 0.0f) {
@@ -305,7 +305,7 @@ static void mr_blizzard_act_throw_snowball(void) {
// Play a sound and set HeldObj to NULL. Then set action to 0.
if (cur_obj_init_anim_check_frame(1, 7)) {
- cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_SCUTTLEBUG_ALERT);
o->prevObj = o->oMrBlizzardHeldObj = NULL;
} else if (cur_obj_check_if_near_animation_end()) {
o->oAction = MR_BLIZZARD_ACT_SPAWN_SNOWBALL;
@@ -347,7 +347,7 @@ static void mr_blizzard_act_jump(void) {
cur_obj_rotate_yaw_toward(o->oMrBlizzardTargetMoveYaw, 3400);
if (--o->oMrBlizzardTimer == 0) {
- cur_obj_play_sound_2(SOUND_OBJ_MR_BLIZZARD_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MR_BLIZZARD_ALERT);
// If Mr. Blizzard is more than 700 units from its home, change its target yaw
// by 180 degrees, jump in the air, set distance from home to 0.
@@ -370,7 +370,7 @@ static void mr_blizzard_act_jump(void) {
// set its timer to 15. If Mr. Blizzard's DistFromHome is not 0,
// set DistFromHome to its current distance from its home.
// Otherwise, set DistFromHome to 700.
- cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNOW_SAND1);
if (o->oMrBlizzardDistFromHome != 0) {
o->oMrBlizzardDistFromHome = (s32) cur_obj_lateral_dist_to_home();
} else {
diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c
index 49c60ed02..7ae80d7c1 100644
--- a/src/game/behaviors/mr_i.inc.c
+++ b/src/game/behaviors/mr_i.inc.c
@@ -50,7 +50,7 @@ void spawn_mr_i_particle(void) {
network_send_spawn_objects(spawn_objects, models, 1);
}
- cur_obj_play_sound_2(SOUND_OBJ_MRI_SHOOT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MRI_SHOOT);
}
void bhv_mr_i_body_loop(void) {
@@ -99,12 +99,12 @@ void mr_i_act_3(void) {
sp36 = o->oMoveAngleYaw;
o->oMoveAngleYaw += sp34 * coss(0x4000 * sp2C);
if (sp36 < 0 && o->oMoveAngleYaw >= 0)
- cur_obj_play_sound_2(SOUND_OBJ2_MRI_SPINNING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_MRI_SPINNING);
o->oMoveAnglePitch = (1.0 - coss(0x4000 * sp2C)) * -0x4000;
cur_obj_shake_y(4.0f);
} else if (o->oTimer < 96) {
if (o->oTimer == 64)
- cur_obj_play_sound_2(SOUND_OBJ_MRI_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_MRI_DEATH);
sp30 = (f32)(o->oTimer - 63) / 32;
o->oMoveAngleYaw += sp34 * coss(0x4000 * sp2C);
o->oMoveAnglePitch = (1.0 - coss(0x4000 * sp2C)) * -0x4000;
diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c
index f986c4eb4..b09ee332b 100644
--- a/src/game/behaviors/piranha_plant.inc.c
+++ b/src/game/behaviors/piranha_plant.inc.c
@@ -44,7 +44,7 @@ s32 piranha_plant_check_interactions(void) {
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
stop_secondary_music(50);
if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) {
- cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_DYING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_PIRANHA_PLANT_DYING);
// Spawn 20 intangible purple particles that quickly dissipate.
for (i = 0; i < 20; i++) {
@@ -180,7 +180,7 @@ void piranha_plant_attacked(void) {
*/
void piranha_plant_act_shrink_and_die(void) {
if (o->oTimer == 0) {
- cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
o->oPiranhaPlantScale = 1.0f;
}
@@ -276,7 +276,7 @@ void piranha_plant_act_biting(void) {
// Play a bite sound effect on certain frames.
if (is_item_in_array(frame, sPiranhaPlantBiteSoundFrames)) {
- cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_BITE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_PIRANHA_PLANT_BITE);
}
// Move to face the player.
diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c
index c27653b64..4d07730ce 100644
--- a/src/game/behaviors/platform_on_track.inc.c
+++ b/src/game/behaviors/platform_on_track.inc.c
@@ -170,9 +170,9 @@ static void platform_on_track_act_move_along_track(void) {
s16 initialAngle;
if (!o->oPlatformOnTrackIsNotSkiLift) {
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR3);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR3);
} else if (!o->oPlatformOnTrackIsNotHMC) {
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR1);
}
// Fall after reaching the last waypoint if desired
@@ -184,7 +184,7 @@ static void platform_on_track_act_move_along_track(void) {
if (o->oPlatformOnTrackPrevWaypointFlags != 0 && !o->oPlatformOnTrackIsNotSkiLift) {
if (o->oPlatformOnTrackPrevWaypointFlags == WAYPOINT_FLAGS_END
|| o->oPlatformOnTrackPrevWaypointFlags == WAYPOINT_FLAGS_PLATFORM_ON_TRACK_PAUSE) {
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
o->oForwardVel = 0.0f;
if (o->oPlatformOnTrackPrevWaypointFlags == WAYPOINT_FLAGS_END) {
diff --git a/src/game/behaviors/purple_switch.inc.c b/src/game/behaviors/purple_switch.inc.c
index b15150ca9..8f2f1909e 100644
--- a/src/game/behaviors/purple_switch.inc.c
+++ b/src/game/behaviors/purple_switch.inc.c
@@ -45,7 +45,7 @@ void bhv_purple_switch_loop(void) {
case PURPLE_SWITCH_PRESSED:
cur_obj_scale_over_time(2, 3, 1.5f, 0.2f);
if (o->oTimer >= 3) {
- cur_obj_play_sound_2(SOUND_GENERAL2_PURPLE_SWITCH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_PURPLE_SWITCH);
o->oAction = PURPLE_SWITCH_TICKING;
cur_obj_shake_screen(SHAKE_POS_SMALL);
queue_rumble_data_object(o, 5, 80);
diff --git a/src/game/behaviors/pyramid_top.inc.c b/src/game/behaviors/pyramid_top.inc.c
index 43cd81ff9..826a72605 100644
--- a/src/game/behaviors/pyramid_top.inc.c
+++ b/src/game/behaviors/pyramid_top.inc.c
@@ -32,7 +32,7 @@ void bhv_pyramid_top_spinning(void) {
// At first, move upward smoothly without rotating.
if (o->oTimer < 60) {
- o->oPosY = o->oHomeY + absf_2(sins(o->oTimer * 0x2000) * 10.0f);
+ o->oPosY = o->oHomeY + absf(sins(o->oTimer * 0x2000) * 10.0f);
} else {
// Then, rotate at an accelerating rate, and move upward at a constant rate.
o->oAngleVelYaw += 0x100;
@@ -109,7 +109,7 @@ void bhv_pyramid_top_loop(void) {
case PYRAMID_TOP_ACT_SPINNING:
if (o->oTimer == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL2_PYRAMID_TOP_SPIN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_PYRAMID_TOP_SPIN);
}
bhv_pyramid_top_spinning();
diff --git a/src/game/behaviors/racing_penguin.inc.c b/src/game/behaviors/racing_penguin.inc.c
index 6e205f6ed..4eb5cfb26 100644
--- a/src/game/behaviors/racing_penguin.inc.c
+++ b/src/game/behaviors/racing_penguin.inc.c
@@ -88,7 +88,7 @@ static void racing_penguin_act_wait_for_mario(void) {
struct Object* player = nearest_player_to_object(o);
if (!player) { return; }
if (o->oTimer > o->oRacingPenguinInitTextCooldown && o->oPosY - player->oPosY <= 0.0f
- && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 400.0f, 400.0f)) {
+ && cur_obj_can_mario_activate_textbox(&gMarioStates[0], 400.0f, 400.0f, 0x1000)) {
o->oAction = RACING_PENGUIN_ACT_SHOW_INIT_TEXT;
}
}
@@ -160,7 +160,7 @@ static void racing_penguin_act_race(void) {
targetSpeed = player ? (o->oPosY - player->oPosY) : o->oPosY;
minSpeed = 70.0f;
- cur_obj_play_sound_1(SOUND_AIR_ROUGH_SLIDE);
+ cur_obj_play_sound_if_visible(SOUND_AIR_ROUGH_SLIDE);
if (targetSpeed < 100.0f || (o->oPathedPrevWaypointFlags & WAYPOINT_MASK_00FF) >= 35) {
if ((o->oPathedPrevWaypointFlags & WAYPOINT_MASK_00FF) >= 35) {
@@ -210,7 +210,7 @@ static void racing_penguin_act_race(void) {
static void racing_penguin_act_finish_race(void) {
if (o->oForwardVel != 0.0f) {
if (o->oTimer > 5 && (o->oMoveFlags & OBJ_MOVE_HIT_WALL)) {
- cur_obj_play_sound_2(SOUND_OBJ_POUNDING_LOUD);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_POUNDING_LOUD);
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
o->oForwardVel = 0.0f;
}
@@ -229,7 +229,7 @@ static void racing_penguin_act_show_final_text(void) {
cur_obj_init_animation_with_sound(3);
o->oForwardVel = 0.0f;
- if (cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 400.0f, 400.0f)) {
+ if (cur_obj_can_mario_activate_textbox(&gMarioStates[0], 400.0f, 400.0f, 0x1000)) {
if (o->oRacingPenguinMarioWon) {
if (o->oRacingPenguinMarioCheated) {
o->oRacingPenguinFinalTextbox = gBehaviorValues.dialogs.RacingPenguinCheatDialog;
diff --git a/src/game/behaviors/recovery_heart.inc.c b/src/game/behaviors/recovery_heart.inc.c
index 085cd4373..4293bf3b2 100644
--- a/src/game/behaviors/recovery_heart.inc.c
+++ b/src/game/behaviors/recovery_heart.inc.c
@@ -23,7 +23,7 @@ void bhv_recovery_heart_loop(void) {
if (collided) {
if (o->oSpinningHeartPlayedSound == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_HEART_SPIN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_HEART_SPIN);
o->oSpinningHeartPlayedSound += 1;
}
diff --git a/src/game/behaviors/rolling_log.inc.c b/src/game/behaviors/rolling_log.inc.c
index 3cc6c9dfa..1184ed881 100644
--- a/src/game/behaviors/rolling_log.inc.c
+++ b/src/game/behaviors/rolling_log.inc.c
@@ -115,8 +115,8 @@ void bhv_rolling_log_loop(void) {
}
o->oFaceAnglePitch += o->oAngleVelPitch;
- if (absf_2(o->oFaceAnglePitch & 0x1FFF) < 528.0f && o->oAngleVelPitch != 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN1_2);
+ if (absf(o->oFaceAnglePitch & 0x1FFF) < 528.0f && o->oAngleVelPitch != 0) {
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNKNOWN1_2);
}
}
@@ -130,7 +130,7 @@ void volcano_act_1(void) {
o->oAngleVelPitch = 0;
o->oRollingLogUnkF4 = 0;
o->oAction = 2;
- cur_obj_play_sound_2(SOUND_GENERAL_BIG_POUND);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BIG_POUND);
set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ);
}
}
@@ -159,7 +159,7 @@ void bhv_volcano_trap_loop(void) {
case 0:
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 1000)) {
o->oAction = 1;
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_POUND2);
}
break;
@@ -172,7 +172,7 @@ void bhv_volcano_trap_loop(void) {
o->oPosY = o->oHomeY + sins(o->oTimer * 0x1000) * 10.0f;
}
if (o->oTimer == 50) {
- cur_obj_play_sound_2(SOUND_GENERAL_UNK45);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNK45);
o->oAction = 3;
}
break;
diff --git a/src/game/behaviors/rotating_platform.inc.c b/src/game/behaviors/rotating_platform.inc.c
index 9fe04591d..50e3f01ac 100644
--- a/src/game/behaviors/rotating_platform.inc.c
+++ b/src/game/behaviors/rotating_platform.inc.c
@@ -10,7 +10,7 @@ struct WFRotatingPlatformData sWFRotatingPlatformData[] = {
static void bhv_wf_rotating_wooden_platform_run_once(void) {
if (o->oAction != 0) {
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR2);
}
load_object_collision_model();
}
diff --git a/src/game/behaviors/scuttlebug.inc.c b/src/game/behaviors/scuttlebug.inc.c
index 4082f05dd..6dc97cd21 100644
--- a/src/game/behaviors/scuttlebug.inc.c
+++ b/src/game/behaviors/scuttlebug.inc.c
@@ -50,7 +50,7 @@ void bhv_scuttlebug_loop(void) {
switch (o->oSubAction) {
case 0:
if (o->oMoveFlags & OBJ_MOVE_LANDED)
- cur_obj_play_sound_2(SOUND_OBJ_GOOMBA_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_GOOMBA_ALERT);
if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) {
o->oHomeX = o->oPosX;
o->oHomeY = o->oPosY;
@@ -71,7 +71,7 @@ void bhv_scuttlebug_loop(void) {
if (abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) {
o->oScuttlebugUnkF8 = 1;
o->oVelY = 20.0f;
- cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_SCUTTLEBUG_ALERT);
}
} else if (o->oScuttlebugUnkF8 == 1) {
o->oForwardVel = 15.0f;
@@ -96,7 +96,7 @@ void bhv_scuttlebug_loop(void) {
o->oFlags &= ~8;
o->oForwardVel = -10.0f;
o->oVelY = 30.0f;
- cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_SCUTTLEBUG_ALERT);
o->oSubAction++;
break;
case 4:
@@ -156,7 +156,7 @@ void bhv_scuttlebug_spawn_loop(void) {
if (o->oAction == 0) {
if (o->oTimer > 30 && 500.0f < distanceToPlayer && distanceToPlayer < 1500.0f) {
- cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_SCUTTLEBUG_ALERT);
struct Object *scuttlebug = spawn_object(o, MODEL_SCUTTLEBUG, bhvScuttlebug);
if (scuttlebug != NULL) {
scuttlebug->oScuttlebugUnkF4 = o->oScuttlebugSpawnerUnkF4;
diff --git a/src/game/behaviors/seesaw_platform.inc.c b/src/game/behaviors/seesaw_platform.inc.c
index 9c120ab0c..5b0417ae5 100644
--- a/src/game/behaviors/seesaw_platform.inc.c
+++ b/src/game/behaviors/seesaw_platform.inc.c
@@ -42,7 +42,7 @@ void bhv_seesaw_platform_update(void) {
o->oFaceAnglePitch += (s32) o->oSeesawPlatformPitchVel;
if (absf(o->oSeesawPlatformPitchVel) > 10.0f) {
- cur_obj_play_sound_1(SOUND_ENV_BOAT_ROCKING1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_BOAT_ROCKING1);
}
f32 x = 0;
diff --git a/src/game/behaviors/skeeter.inc.c b/src/game/behaviors/skeeter.inc.c
index 9a5ecfe0b..e9344e763 100644
--- a/src/game/behaviors/skeeter.inc.c
+++ b/src/game/behaviors/skeeter.inc.c
@@ -50,7 +50,7 @@ static void skeeter_act_idle(void) {
if (o->oSkeeterWaitTime != 0) {
o->oSkeeterWaitTime -= 1;
} else if (cur_obj_check_if_near_animation_end()) {
- cur_obj_play_sound_2(SOUND_OBJ_WALKING_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_WALKING_WATER);
o->oAction = SKEETER_ACT_LUNGE;
o->oForwardVel = 80.0f;
o->oSkeeterUnk1AC = 0;
diff --git a/src/game/behaviors/sl_snowman_wind.inc.c b/src/game/behaviors/sl_snowman_wind.inc.c
index b5f3025ef..ccc3aabb2 100644
--- a/src/game/behaviors/sl_snowman_wind.inc.c
+++ b/src/game/behaviors/sl_snowman_wind.inc.c
@@ -57,6 +57,6 @@ void bhv_sl_snowman_wind_loop(void) {
}
// Spawn wind and play wind sound
cur_obj_spawn_strong_wind_particles(12, 3.0f, 0, 0, 0);
- cur_obj_play_sound_1(SOUND_AIR_BLOW_WIND);
+ cur_obj_play_sound_if_visible(SOUND_AIR_BLOW_WIND);
}
}
diff --git a/src/game/behaviors/snow_mound.inc.c b/src/game/behaviors/snow_mound.inc.c
index 849e37adc..9e24f0979 100644
--- a/src/game/behaviors/snow_mound.inc.c
+++ b/src/game/behaviors/snow_mound.inc.c
@@ -8,7 +8,7 @@ void bhv_sliding_snow_mound_loop(void) {
if (o->oTimer >= 118)
o->oAction = 1;
- cur_obj_play_sound_1(SOUND_ENV_SINK_QUICKSAND);
+ cur_obj_play_sound_if_visible(SOUND_ENV_SINK_QUICKSAND);
break;
case 1:
diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c
index 00eeef110..429ab3008 100644
--- a/src/game/behaviors/snowman.inc.c
+++ b/src/game/behaviors/snowman.inc.c
@@ -100,7 +100,7 @@ void snowmans_bottom_act_2(void) {
o->parentObj->oAction = 2;
o->parentObj->oVelY = 100.0f;
- cur_obj_play_sound_2(SOUND_OBJ_SNOWMAN_BOUNCE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNOWMAN_BOUNCE);
}
if (o->oTimer == 200) {
@@ -151,13 +151,13 @@ void bhv_snowmans_bottom_loop(void) {
case 1:
snowmans_bottom_act_1();
adjust_rolling_face_pitch(o->oSnowmansBottomUnkF4);
- cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_UNKNOWN2);
break;
case 2:
snowmans_bottom_act_2();
adjust_rolling_face_pitch(o->oSnowmansBottomUnkF4);
- cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_UNKNOWN2);
break;
case 3:
@@ -233,7 +233,7 @@ void bhv_snowmans_head_loop(void) {
if (o->oPosY < -994.0f) {
o->oPosY = -994.0f;
o->oAction = 4;
- cur_obj_play_sound_2(SOUND_OBJ_SNOWMAN_EXPLODE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNOWMAN_EXPLODE);
play_puzzle_jingle();
}
break;
diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c
index e1576e7a4..323040cd3 100644
--- a/src/game/behaviors/snufit.inc.c
+++ b/src/game/behaviors/snufit.inc.c
@@ -109,7 +109,7 @@ void snufit_act_shoot(void) {
} else if (o->oSnufitBullets < 3 && o->oTimer >= 3) {
if (sync_object_is_owned_locally(o->oSyncID)) {
o->oSnufitBullets += 1;
- cur_obj_play_sound_2(SOUND_OBJ_SNUFIT_SHOOT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNUFIT_SHOOT);
struct Object* bullet = spawn_object_relative(0, 0, -20, 40, o, MODEL_BOWLING_BALL, bhvSnufitBalls);
o->oSnufitRecoil = -30;
o->oTimer = 0;
@@ -120,7 +120,7 @@ void snufit_act_shoot(void) {
network_send_spawn_objects(spawn_objects, models, 1);
}
} else {
- cur_obj_play_sound_2(SOUND_OBJ_SNUFIT_SHOOT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SNUFIT_SHOOT);
o->oSnufitRecoil = -30;
o->oTimer = 0;
}
diff --git a/src/game/behaviors/sound_birds.inc.c b/src/game/behaviors/sound_birds.inc.c
index d1bdc3864..bfa6db067 100644
--- a/src/game/behaviors/sound_birds.inc.c
+++ b/src/game/behaviors/sound_birds.inc.c
@@ -6,15 +6,15 @@ void bhv_birds_sound_loop(void) {
switch (o->oBehParams2ndByte) {
case 0:
- cur_obj_play_sound_1(SOUND_OBJ2_BIRD_CHIRP1);
+ cur_obj_play_sound_if_visible(SOUND_OBJ2_BIRD_CHIRP1);
break;
case 1:
- cur_obj_play_sound_1(SOUND_GENERAL2_BIRD_CHIRP2);
+ cur_obj_play_sound_if_visible(SOUND_GENERAL2_BIRD_CHIRP2);
break;
case 2:
- cur_obj_play_sound_1(SOUND_OBJ_BIRD_CHIRP3);
+ cur_obj_play_sound_if_visible(SOUND_OBJ_BIRD_CHIRP3);
break;
}
}
diff --git a/src/game/behaviors/sound_sand.inc.c b/src/game/behaviors/sound_sand.inc.c
index 95535b686..7117a57d3 100644
--- a/src/game/behaviors/sound_sand.inc.c
+++ b/src/game/behaviors/sound_sand.inc.c
@@ -4,5 +4,5 @@ void bhv_sand_sound_loop(void) {
if (gCamera->mode == CAMERA_MODE_BEHIND_MARIO)
return;
- cur_obj_play_sound_1(SOUND_ENV_MOVINGSAND);
+ cur_obj_play_sound_if_visible(SOUND_ENV_MOVINGSAND);
}
diff --git a/src/game/behaviors/sound_volcano.inc.c b/src/game/behaviors/sound_volcano.inc.c
index a96964dac..b9101bb7b 100644
--- a/src/game/behaviors/sound_volcano.inc.c
+++ b/src/game/behaviors/sound_volcano.inc.c
@@ -1,5 +1,5 @@
// sound_volcano.inc.c
void bhv_volcano_sound_loop(void) {
- cur_obj_play_sound_1(SOUND_ENV_DRONING1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_DRONING1);
}
diff --git a/src/game/behaviors/sound_waterfall.inc.c b/src/game/behaviors/sound_waterfall.inc.c
index 5763ac8b5..fcc21fd9b 100644
--- a/src/game/behaviors/sound_waterfall.inc.c
+++ b/src/game/behaviors/sound_waterfall.inc.c
@@ -1,5 +1,5 @@
// sound_waterfall.inc.c
void bhv_waterfall_sound_loop(void) {
- cur_obj_play_sound_1(SOUND_ENV_WATERFALL2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATERFALL2);
}
diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c
index 381967265..659730a7b 100644
--- a/src/game/behaviors/sparkle_spawn_star.inc.c
+++ b/src/game/behaviors/sparkle_spawn_star.inc.c
@@ -20,7 +20,7 @@ void bhv_spawned_star_init(void) {
if (bit_shift_left(gLevelValues.useGlobalStarIds ? starId % 7 : starId) & save_file_get_star_flags(gCurrSaveFileNum - 1, (gLevelValues.useGlobalStarIds ? (starId / 7) - 1 : gCurrCourseNum - 1))) {
cur_obj_set_model(smlua_model_util_load(E_MODEL_TRANSPARENT_STAR));
}
- cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_STAR_APPEARS);
// exclamation box stars are not sent through the normal exclamation box
// path due to jankiness in oBehParams. Send the spawn event here instead.
@@ -39,7 +39,7 @@ void bhv_spawned_star_init(void) {
void set_sparkle_spawn_star_hitbox(void) {
obj_set_hitbox(o, &sSparkleSpawnStarHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
- mark_obj_for_deletion(o);
+ obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
}
@@ -113,7 +113,7 @@ void bhv_spawned_star_loop(void) {
o->oGravity = -4.0f;
spawn_mist_particles();
}
- cur_obj_play_sound_1(SOUND_ENV_STAR);
+ cur_obj_play_sound_if_visible(SOUND_ENV_STAR);
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
if (o->oVelY < 0 && o->oPosY < o->oHomeY) {
o->oAction++;
diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c
index 71783e743..5628fc5d3 100644
--- a/src/game/behaviors/spawn_star.inc.c
+++ b/src/game/behaviors/spawn_star.inc.c
@@ -78,7 +78,7 @@ void bhv_collect_star_loop(void) {
o->oFaceAngleYaw += 0x800;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
- mark_obj_for_deletion(o);
+ obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
spawn_star_number();
@@ -126,7 +126,7 @@ void bhv_star_spawn_loop(void) {
o->oPosY = o->oStarSpawnUnkFC + sins((o->oTimer * 0x8000) / 30) * 400.0f;
o->oFaceAngleYaw += 0x1000;
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
- cur_obj_play_sound_1(SOUND_ENV_STAR);
+ cur_obj_play_sound_if_visible(SOUND_ENV_STAR);
if (o->oTimer == 30) {
o->oAction = 2;
o->oForwardVel = 0;
@@ -143,10 +143,10 @@ void bhv_star_spawn_loop(void) {
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
obj_move_xyz_using_fvel_and_yaw(o);
o->oFaceAngleYaw = o->oFaceAngleYaw - o->oTimer * 0x10 + 0x1000;
- cur_obj_play_sound_1(SOUND_ENV_STAR);
+ cur_obj_play_sound_if_visible(SOUND_ENV_STAR);
if (o->oPosY < o->oHomeY) {
- cur_obj_play_sound_2(SOUND_GENERAL_STAR_APPEARS);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_STAR_APPEARS);
cur_obj_become_tangible();
o->oPosY = o->oHomeY;
o->oAction = 3;
@@ -165,7 +165,7 @@ void bhv_star_spawn_loop(void) {
}
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
- mark_obj_for_deletion(o);
+ obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
diff --git a/src/game/behaviors/spindel.inc.c b/src/game/behaviors/spindel.inc.c
index 7ee1cd609..db84772da 100644
--- a/src/game/behaviors/spindel.inc.c
+++ b/src/game/behaviors/spindel.inc.c
@@ -69,8 +69,8 @@ void bhv_spindel_loop(void) {
o->oPosZ += o->oVelZ;
o->oMoveAnglePitch += o->oAngleVelPitch;
- if (absf_2(o->oMoveAnglePitch & 0x1fff) < 800.0f && o->oAngleVelPitch != 0) {
- cur_obj_play_sound_2(SOUND_GENERAL2_SPINDEL_ROLL);
+ if (absf(o->oMoveAnglePitch & 0x1fff) < 800.0f && o->oAngleVelPitch != 0) {
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_SPINDEL_ROLL);
}
sp1C = sins(o->oMoveAnglePitch * 4) * 23.0;
diff --git a/src/game/behaviors/spiny.inc.c b/src/game/behaviors/spiny.inc.c
index 7b8559e03..e8c527600 100644
--- a/src/game/behaviors/spiny.inc.c
+++ b/src/game/behaviors/spiny.inc.c
@@ -201,7 +201,7 @@ static void spiny_act_thrown_by_lakitu(void) {
cur_obj_init_animation_with_sound(0);
if (o->oMoveFlags & OBJ_MOVE_LANDED) {
- cur_obj_play_sound_2(SOUND_OBJ_SPINY_UNK59);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SPINY_UNK59);
cur_obj_set_model(smlua_model_util_load(E_MODEL_SPINY));
obj_init_animation_with_sound(o, (struct AnimationTable*)&spiny_seg5_anims_05016EAC, 0);
o->oGraphYOffset = -17.0f;
diff --git a/src/game/behaviors/star_door.inc.c b/src/game/behaviors/star_door.inc.c
index bcdc77cb1..31c8ae4d9 100644
--- a/src/game/behaviors/star_door.inc.c
+++ b/src/game/behaviors/star_door.inc.c
@@ -21,7 +21,7 @@ void bhv_star_door_loop(void) {
break;
case 1:
if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_OPEN);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_STAR_DOOR_OPEN);
queue_rumble_data_object(o, 35, 30);
}
cur_obj_become_intangible();
@@ -36,7 +36,7 @@ void bhv_star_door_loop(void) {
break;
case 3:
if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_CLOSE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_STAR_DOOR_CLOSE);
queue_rumble_data_object(o, 35, 30);
}
o->oUnkBC = 8.0f;
diff --git a/src/game/behaviors/sushi.inc.c b/src/game/behaviors/sushi.inc.c
index af9990529..c92f0519d 100644
--- a/src/game/behaviors/sushi.inc.c
+++ b/src/game/behaviors/sushi.inc.c
@@ -21,6 +21,6 @@ void bhv_sushi_shark_loop(void) {
if (o->oPosY - sp1C > -200.0f)
spawn_object_with_scale(o, MODEL_WAVE_TRAIL, bhvObjectWaveTrail, 4.0f);
if ((o->oTimer & 0xF) == 0)
- cur_obj_play_sound_2(SOUND_OBJ_SUSHI_SHARK_WATER_SOUND);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SUSHI_SHARK_WATER_SOUND);
o->oInteractStatus = 0;
}
diff --git a/src/game/behaviors/switch_hidden_objects.inc.c b/src/game/behaviors/switch_hidden_objects.inc.c
index fa822e7bc..d138dd5d9 100644
--- a/src/game/behaviors/switch_hidden_objects.inc.c
+++ b/src/game/behaviors/switch_hidden_objects.inc.c
@@ -57,7 +57,7 @@ void hidden_breakable_box_actions(void) {
spawn_mist_particles();
spawn_triangle_break_particles(30, 138, 3.0f, 4);
o->oAction++;
- cur_obj_play_sound_2(SOUND_GENERAL_BREAK_BOX);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_BREAK_BOX);
}
load_object_collision_model();
} else {
diff --git a/src/game/behaviors/swoop.inc.c b/src/game/behaviors/swoop.inc.c
index fdaa6af7e..71e380cae 100644
--- a/src/game/behaviors/swoop.inc.c
+++ b/src/game/behaviors/swoop.inc.c
@@ -32,7 +32,7 @@ static void swoop_act_idle(void) {
if (approach_f32_ptr(&o->header.gfx.scale[0], 1.0f, 0.05f) && distanceToPlayer < 1500.0f) {
if (cur_obj_rotate_yaw_toward(angleToPlayer, 800)) {
- cur_obj_play_sound_2(SOUND_OBJ2_SWOOP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_SWOOP);
o->oAction = SWOOP_ACT_MOVE;
o->oVelY = -12.0f;
}
@@ -51,7 +51,7 @@ static void swoop_act_move(void) {
cur_obj_init_animation_with_accel_and_sound(0, 2.0f);
if (cur_obj_check_if_near_animation_end()) {
- cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN6);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_UNKNOWN6);
}
if (o->oForwardVel == 0.0f) {
diff --git a/src/game/behaviors/thi_top.inc.c b/src/game/behaviors/thi_top.inc.c
index e045ab830..3cab228a7 100644
--- a/src/game/behaviors/thi_top.inc.c
+++ b/src/game/behaviors/thi_top.inc.c
@@ -35,14 +35,14 @@ void bhv_thi_tiny_island_top_loop(void) {
o->oAction++;
cur_obj_spawn_particles(&D_8032F134);
spawn_triangle_break_particles(20, 138, 0.3f, 3);
- cur_obj_play_sound_2(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
cur_obj_hide();
network_send_object(o);
}
} else {
if (o->oTimer < 50) {
if (gEnvironmentRegions && gEnvironmentRegionsLength > 18) { gEnvironmentRegions[18]--; }
- cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER_DRAIN);
} else {
gTHIWaterDrained |= 1;
play_puzzle_jingle();
diff --git a/src/game/behaviors/thwomp.inc.c b/src/game/behaviors/thwomp.inc.c
index 3c3101090..9174b09b1 100644
--- a/src/game/behaviors/thwomp.inc.c
+++ b/src/game/behaviors/thwomp.inc.c
@@ -24,7 +24,7 @@ void grindel_thwomp_act_3(void) {
s32 distanceToPlayer = dist_between_objects(o, gMarioStates[0].marioObj);
if (distanceToPlayer < 1500.0f) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
- cur_obj_play_sound_2(SOUND_OBJ_THWOMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_THWOMP);
}
}
if (o->oTimer > 9) {
diff --git a/src/game/behaviors/tower_platform.inc.c b/src/game/behaviors/tower_platform.inc.c
index e063d5de4..ff09b5f92 100644
--- a/src/game/behaviors/tower_platform.inc.c
+++ b/src/game/behaviors/tower_platform.inc.c
@@ -27,7 +27,7 @@ void bhv_wf_elevator_tower_platform_loop(void) {
}
break;
case 1:
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR1);
if (o->oTimer > 140)
o->oAction++;
else
@@ -38,7 +38,7 @@ void bhv_wf_elevator_tower_platform_loop(void) {
o->oAction++;
break;
case 3:
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR1);
if (o->oTimer > 140)
o->oAction = 0;
else
diff --git a/src/game/behaviors/tox_box.inc.c b/src/game/behaviors/tox_box.inc.c
index d6fb61c18..ead26ddda 100644
--- a/src/game/behaviors/tox_box.inc.c
+++ b/src/game/behaviors/tox_box.inc.c
@@ -27,9 +27,9 @@ void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll)
if (o->oTimer == 7) {
o->oAction = cur_obj_progress_direction_table();
#ifndef VERSION_JP
- cur_obj_play_sound_2(SOUND_GENERAL_UNK46);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNK46);
#else
- cur_obj_play_sound_2(SOUND_GENERAL_UNK46_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_UNK46_LOWPRIO);
#endif
}
}
diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c
index 0b66bb7b4..d37fecc33 100644
--- a/src/game/behaviors/treasure_chest.inc.c
+++ b/src/game/behaviors/treasure_chest.inc.c
@@ -195,7 +195,7 @@ void bhv_treasure_chest_ship_loop(void) {
o->activeFlags = 0;
}
#ifdef VERSION_SH
- reset_rumble_timers_2(2);
+ reset_rumble_timers_vibrate(2);
#endif
}
break;
diff --git a/src/game/behaviors/ttc_pendulum.inc.c b/src/game/behaviors/ttc_pendulum.inc.c
index 0f743ae03..543f45886 100644
--- a/src/game/behaviors/ttc_pendulum.inc.c
+++ b/src/game/behaviors/ttc_pendulum.inc.c
@@ -47,7 +47,7 @@ void bhv_ttc_pendulum_update(void) {
// Play sound
if (o->oTTCPendulumSoundTimer != 0) {
if (--o->oTTCPendulumSoundTimer == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL_PENDULUM_SWING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_PENDULUM_SWING);
}
}
diff --git a/src/game/behaviors/ttc_rotating_solid.inc.c b/src/game/behaviors/ttc_rotating_solid.inc.c
index f15a94a85..a6ec20e21 100644
--- a/src/game/behaviors/ttc_rotating_solid.inc.c
+++ b/src/game/behaviors/ttc_rotating_solid.inc.c
@@ -56,7 +56,7 @@ void bhv_ttc_rotating_solid_update(void) {
if (o->oTTCRotatingSolidSoundTimer != 0) {
// 3. Play a sound after 6 frames
if (--o->oTTCRotatingSolidSoundTimer == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL2_ROTATING_BLOCK_ALERT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_ROTATING_BLOCK_ALERT);
}
} else if (o->oTTCRotatingSolidVelY > 0.0f && o->oPosY >= o->oHomeY) {
// 4. Rotate
@@ -68,7 +68,7 @@ void bhv_ttc_rotating_solid_update(void) {
o->oAngleVelRoll = o->oFaceAngleRoll - startRoll;
if (o->oAngleVelRoll == 0) {
- cur_obj_play_sound_2(SOUND_GENERAL2_ROTATING_BLOCK_CLICK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL2_ROTATING_BLOCK_CLICK);
if (o->oTTCRotatingSolidNumSides) {
o->oTTCRotatingSolidNumTurns = (o->oTTCRotatingSolidNumTurns + 1) % o->oTTCRotatingSolidNumSides;
diff --git a/src/game/behaviors/ttc_treadmill.inc.c b/src/game/behaviors/ttc_treadmill.inc.c
index b504f53f7..9bb669aaa 100644
--- a/src/game/behaviors/ttc_treadmill.inc.c
+++ b/src/game/behaviors/ttc_treadmill.inc.c
@@ -50,7 +50,7 @@ void bhv_ttc_treadmill_update(void) {
if (sMasterTreadmill == o || sMasterTreadmill == NULL) {
sMasterTreadmill = o;
- cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
+ cur_obj_play_sound_if_visible(SOUND_ENV_ELEVATOR2);
if (gTTCSpeedSetting == TTC_SPEED_RANDOM) {
// Stay still for 5 frames, then accelerate toward the target speed
diff --git a/src/game/behaviors/tumbling_bridge.inc.c b/src/game/behaviors/tumbling_bridge.inc.c
index b90368657..783565574 100644
--- a/src/game/behaviors/tumbling_bridge.inc.c
+++ b/src/game/behaviors/tumbling_bridge.inc.c
@@ -55,7 +55,7 @@ void bhv_tumbling_bridge_platform_loop(void) {
cur_obj_update_floor_height();
if (o->oTimer > 5) {
o->oAction++;
- cur_obj_play_sound_2(SOUND_GENERAL_PLATFORM);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_PLATFORM);
}
break;
case 2:
diff --git a/src/game/behaviors/tuxie.inc.c b/src/game/behaviors/tuxie.inc.c
index d0ec006a6..dbdd9a5b2 100644
--- a/src/game/behaviors/tuxie.inc.c
+++ b/src/game/behaviors/tuxie.inc.c
@@ -131,7 +131,7 @@ void tuxies_mother_act_0(void) {
} else {
switch (o->oSubAction) {
case 0:
- if (cur_obj_can_mario_activate_textbox_2(marioState, 300.0f, 100.0f))
+ if (cur_obj_can_mario_activate_textbox(marioState, 300.0f, 100.0f, 0x1000))
if (sp2C == 0)
o->oSubAction++;
break;
@@ -146,7 +146,7 @@ void tuxies_mother_act_0(void) {
}
}
if (cur_obj_check_anim_frame(1))
- cur_obj_play_sound_2(SOUND_OBJ_BIG_PENGUIN_YELL);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BIG_PENGUIN_YELL);
}
void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_1,
@@ -212,7 +212,7 @@ void small_penguin_act_1(void) {
void small_penguin_act_3(void) {
if (o->oTimer > 5) {
if (o->oTimer == 6)
- cur_obj_play_sound_2(SOUND_OBJ_BABY_PENGUIN_DIVE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BABY_PENGUIN_DIVE);
cur_obj_init_animation_with_sound(1);
if (o->oTimer > 25) {
if (o->heldByPlayerIndex < MAX_PLAYERS && !mario_is_dive_sliding(&gMarioStates[o->heldByPlayerIndex])) {
diff --git a/src/game/behaviors/tweester.inc.c b/src/game/behaviors/tweester.inc.c
index be31a399d..78593c2a6 100644
--- a/src/game/behaviors/tweester.inc.c
+++ b/src/game/behaviors/tweester.inc.c
@@ -60,7 +60,7 @@ void tweester_act_idle(void) {
o->oTimer = 0;
} else {
- cur_obj_play_sound_1(SOUND_ENV_WIND1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WIND1);
tweester_scale_and_move(o->oTimer / 60.0f);
if (o->oTimer > 59)
o->oAction = TWEESTER_ACT_CHASE;
@@ -80,7 +80,7 @@ void tweester_act_chase(void) {
f32 activationRadius = o->oBehParams2ndByte * 100;
o->oAngleToHome = cur_obj_angle_to_home();
- cur_obj_play_sound_1(SOUND_ENV_WIND1);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WIND1);
if (player
&& cur_obj_lateral_dist_from_obj_to_home(player) < activationRadius
diff --git a/src/game/behaviors/unagi.inc.c b/src/game/behaviors/unagi.inc.c
index e925f5a98..a691e607d 100644
--- a/src/game/behaviors/unagi.inc.c
+++ b/src/game/behaviors/unagi.inc.c
@@ -79,7 +79,7 @@ void unagi_act_1_4(s32 arg0) {
}
if (cur_obj_check_anim_frame(6)) {
- cur_obj_play_sound_2(SOUND_GENERAL_MOVING_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_MOVING_WATER);
}
if (cur_obj_follow_path(0) == -1) {
@@ -125,7 +125,7 @@ void unagi_act_3(void) {
cur_obj_init_animation_with_sound(6);
if (o->oTimer > 60 && o->oUnagiUnk1AC < 1000.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_EEL_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_EEL_2);
o->oUnagiUnkF8 = o->oUnagiUnk110 = 30.0f;
} else {
o->oUnagiUnk110 = 0.0f;
diff --git a/src/game/behaviors/water_bomb.inc.c b/src/game/behaviors/water_bomb.inc.c
index 3ca1f5ed3..f531e5b28 100644
--- a/src/game/behaviors/water_bomb.inc.c
+++ b/src/game/behaviors/water_bomb.inc.c
@@ -130,7 +130,7 @@ void water_bomb_spawn_explode_particles(s8 offsetY, s8 forwardVelRange, s8 velYB
* Enter the drop action with -40 y vel.
*/
static void water_bomb_act_init(void) {
- cur_obj_play_sound_2(SOUND_OBJ_SOMETHING_LANDING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_SOMETHING_LANDING);
o->oAction = WATER_BOMB_ACT_DROP;
o->oMoveFlags = 0;
@@ -157,7 +157,7 @@ static void water_bomb_act_drop(void) {
o->oWaterBombOnGround = TRUE;
if ((o->oWaterBombNumBounces += 1.0f) < 3.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_WATER_BOMB_BOUNCING);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_WATER_BOMB_BOUNCING);
} else {
create_sound_spawner(SOUND_OBJ_DIVING_IN_WATER);
}
diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c
index a14cf2e91..63c4da9a2 100644
--- a/src/game/behaviors/water_bomb_cannon.inc.c
+++ b/src/game/behaviors/water_bomb_cannon.inc.c
@@ -57,7 +57,7 @@ void water_bomb_cannon_act_1(void) {
if (o->oWaterCannonUnkF8 != 0) {
o->oWaterCannonUnkF8 -= 1;
} else {
- cur_obj_play_sound_2(SOUND_OBJ_CANNON4);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_CANNON4);
o->oWaterCannonUnkF4 = 70;
o->oWaterCannonUnkFC = 0x1000 + 0x400 * (random_u16() & 0x3);
o->oWaterCannonUnk100 = -0x2000 + o->oMoveAngleYaw + 0x1000 * (random_u16() % 5);
diff --git a/src/game/behaviors/water_objs.inc.c b/src/game/behaviors/water_objs.inc.c
index e829ebf20..64982b7a8 100644
--- a/src/game/behaviors/water_objs.inc.c
+++ b/src/game/behaviors/water_objs.inc.c
@@ -24,7 +24,7 @@ void bhv_water_air_bubble_loop(void) {
o->oPosX += random_float() * 4.0f - 2.0f;
o->oPosZ += random_float() * 4.0f - 2.0f;
if (o->oInteractStatus & INT_STATUS_INTERACTED || o->oTimer > 200) {
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_BUBBLE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_BUBBLE);
obj_mark_for_deletion(o);
for (i = 0; i < 30; i++)
spawn_object(o, MODEL_BUBBLE, bhvBubbleMaybe);
@@ -37,7 +37,7 @@ void bhv_water_air_bubble_loop(void) {
void bhv_bubble_wave_init(void) {
o->oWaterObjUnkFC = 0x800 + (s32)(random_float() * 2048.0f);
o->oWaterObjUnk100 = 0x800 + (s32)(random_float() * 2048.0f);
- cur_obj_play_sound_2(SOUND_GENERAL_QUIET_BUBBLE);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_QUIET_BUBBLE);
}
void scale_bubble_random(void) {
diff --git a/src/game/behaviors/water_pillar.inc.c b/src/game/behaviors/water_pillar.inc.c
index 70d1bf897..061119bf5 100644
--- a/src/game/behaviors/water_pillar.inc.c
+++ b/src/game/behaviors/water_pillar.inc.c
@@ -35,13 +35,13 @@ void water_level_pillar_undrained(void) {
}
break;
case 4:
- cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER_DRAIN);
if (o->oTimer < 300) {
gEnvironmentLevels[2] =
(s32) approach_f32_symmetric(gEnvironmentLevels[2], -2450.0f, 5.0f);
gEnvironmentLevels[0] =
(s32) approach_f32_symmetric(gEnvironmentLevels[0], -2450.0f, 5.0f);
- reset_rumble_timers_2(&gMarioStates[0], 2);
+ reset_rumble_timers_vibrate(&gMarioStates[0], 2);
} else
o->oAction++;
break;
diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c
index 95e292afa..ef00e6f6f 100644
--- a/src/game/behaviors/wdw_water_level.inc.c
+++ b/src/game/behaviors/wdw_water_level.inc.c
@@ -80,15 +80,15 @@ void bhv_water_level_diamond_loop(void) {
o->oAngleVelYaw = 0x800;
} else {
if (o->oTimer == 0)
- cur_obj_play_sound_2(SOUND_GENERAL_WATER_LEVEL_TRIG);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_WATER_LEVEL_TRIG);
else {
if (*gEnvironmentLevels > o->oWaterLevelTriggerTargetWaterLevel)
- cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER_DRAIN);
else
- cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); // same as above
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER_DRAIN); // same as above
}
o->oAngleVelYaw = 0x800;
- reset_rumble_timers_2(&gMarioStates[0], 2);
+ reset_rumble_timers_vibrate(&gMarioStates[0], 2);
}
break;
case WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING:
diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c
index 7034e4f0f..096388477 100644
--- a/src/game/behaviors/whirlpool.inc.c
+++ b/src/game/behaviors/whirlpool.inc.c
@@ -70,7 +70,7 @@ void bhv_whirlpool_loop(void) {
o->oFaceAngleYaw += 0x1F40;
- cur_obj_play_sound_1(SOUND_ENV_WATER);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER);
whirlpool_set_hitbox();
}
@@ -85,5 +85,5 @@ void bhv_jet_stream_loop(void) {
} else
gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0;
- cur_obj_play_sound_1(SOUND_ENV_WATER);
+ cur_obj_play_sound_if_visible(SOUND_ENV_WATER);
}
diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c
index ba00e33a2..2ef6d4a55 100644
--- a/src/game/behaviors/whomp.inc.c
+++ b/src/game/behaviors/whomp.inc.c
@@ -11,7 +11,7 @@ void whomp_play_sfx_from_pound_animation(void) {
sp28 |= cur_obj_check_anim_frame_in_range(23, 3);
}
if (sp28)
- cur_obj_play_sound_2(SOUND_OBJ_POUNDING1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_POUNDING1);
}
u8 whomp_act_0_continue_dialog(void) { return o->oAction == 0; }
@@ -139,7 +139,7 @@ void whomp_act_4(void) {
void whomp_act_5(void) {
if (o->oSubAction == 0 && o->oMoveFlags & OBJ_MOVE_LANDED) {
- cur_obj_play_sound_2(SOUND_OBJ_WHOMP_LOWPRIO);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_WHOMP_LOWPRIO);
cur_obj_shake_screen(SHAKE_POS_SMALL);
o->oVelY = 0.0f;
o->oSubAction++;
@@ -155,8 +155,8 @@ void king_whomp_on_ground(void) {
if (o->oSubAction == 0) {
if (cur_obj_is_mario_ground_pounding_platform()) {
o->oHealth--;
- cur_obj_play_sound_2(SOUND_OBJ2_WHOMP_SOUND_SHORT);
- cur_obj_play_sound_2(SOUND_OBJ_KING_WHOMP_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ2_WHOMP_SOUND_SHORT);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_WHOMP_DEATH);
if (o->oHealth == 0)
o->oAction = 8;
else {
@@ -249,7 +249,7 @@ void whomp_act_8(void) {
f32* starPos = gLevelValues.starPositions.KingWhompStarPos;
spawn_default_star(starPos[0], starPos[1], starPos[2]);
- cur_obj_play_sound_2(SOUND_OBJ_KING_WHOMP_DEATH);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_KING_WHOMP_DEATH);
o->oAction = 9;
network_send_object(o);
}
diff --git a/src/game/behaviors/wiggler.inc.c b/src/game/behaviors/wiggler.inc.c
index 0564fbd7f..4407604f3 100644
--- a/src/game/behaviors/wiggler.inc.c
+++ b/src/game/behaviors/wiggler.inc.c
@@ -331,7 +331,7 @@ static void wiggler_act_jumped_on(void) {
o->oMoveAngleYaw = o->oFaceAngleYaw;
if (o->oHealth == 2) {
- cur_obj_play_sound_2(SOUND_OBJ_WIGGLER_JUMP);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_WIGGLER_JUMP);
o->oForwardVel = 10.0f;
o->oVelY = 70.0f;
}
@@ -370,7 +370,7 @@ static void wiggler_act_knockback(void) {
static void wiggler_act_shrink(void) {
if (o->oTimer >= 20) {
if (o->oTimer == 20) {
- cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
}
// 4 is the default scale, so shrink to 1/4 of regular size
@@ -415,7 +415,7 @@ static void wiggler_act_fall_through_floor(void) {
* Stop and enter the jumped on action.
*/
void wiggler_jumped_on_attack_handler(void) {
- cur_obj_play_sound_2(SOUND_OBJ_WIGGLER_ATTACKED);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_WIGGLER_ATTACKED);
// Check for if we've already defeated the Wiggler.
if (o->header.gfx.scale[0] == 1.0f) {
o->oAction = WIGGLER_ACT_KNOCKBACK;
diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c
index 86fd91a40..d6dbf40ef 100644
--- a/src/game/behaviors/yoshi.inc.c
+++ b/src/game/behaviors/yoshi.inc.c
@@ -62,7 +62,7 @@ void yoshi_walk_loop(void) {
cur_obj_init_animation(1);
if (animFrame == 0 || animFrame == 15)
- cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_YOSHI_WALK);
if (o->oInteractStatus == INT_STATUS_INTERACTED) {
struct MarioState* marioState = nearest_mario_state_to_object(o);
@@ -169,7 +169,7 @@ void yoshi_walk_and_jump_off_roof_loop(void) {
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oYoshiTargetYaw, 0x500);
if (is_point_close_to_object(o, o->oHomeX, 3174.0f, o->oHomeZ, 200)) {
cur_obj_init_animation(2);
- cur_obj_play_sound_2(SOUND_GENERAL_ENEMY_ALERT1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ENEMY_ALERT1);
o->oForwardVel = 50.0f;
o->oVelY = 40.0f;
o->oMoveAngleYaw = -0x3FFF;
@@ -177,7 +177,7 @@ void yoshi_walk_and_jump_off_roof_loop(void) {
}
if (animFrame == 0 || animFrame == 15) {
- cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_YOSHI_WALK);
}
}
@@ -234,7 +234,7 @@ void yoshi_reappear(void) {
o->oVelY = 0.0f;
cur_obj_init_animation(0);
spawn_mist_particles();
- cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_YOSHI_WALK);
o->oAction = YOSHI_ACT_IDLE;
return;
}
@@ -248,7 +248,7 @@ void yoshi_reappear(void) {
o->oPosY = sYoshiRespawnPos[1];
o->oPosZ = sYoshiRespawnPos[2];
cur_obj_init_animation(2);
- cur_obj_play_sound_2(SOUND_GENERAL_ENEMY_ALERT1);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_ENEMY_ALERT1);
spawn_mist_particles();
o->oVelY = 160;
}
@@ -267,7 +267,7 @@ void yoshi_reappear(void) {
o->oPosZ = o->oHomeZ;
cur_obj_init_animation(0);
spawn_mist_particles();
- cur_obj_play_sound_2(SOUND_GENERAL_YOSHI_WALK);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_GENERAL_YOSHI_WALK);
o->oForwardVel = 0.0f;
o->oVelY = 0.0f;
o->oAction = YOSHI_ACT_IDLE;
diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c
index 344a370ad..18bb767e7 100644
--- a/src/game/hardcoded.c
+++ b/src/game/hardcoded.c
@@ -352,26 +352,25 @@ AT_STARTUP void hardcoded_reset_default_values(void) {
gLevelValues = gDefaultLevelValues;
gBehaviorValues = gDefaultBehaviorValues;
- memcpy(&cotmc_painting, &default_cotmc_painting, sizeof(struct Painting));
- memcpy(&bob_painting, &default_bob_painting, sizeof(struct Painting));
- memcpy(&ccm_painting, &default_ccm_painting, sizeof(struct Painting));
- memcpy(&wf_painting, &default_wf_painting, sizeof(struct Painting));
- memcpy(&jrb_painting, &default_jrb_painting, sizeof(struct Painting));
- memcpy(&lll_painting, &default_lll_painting, sizeof(struct Painting));
- memcpy(&ssl_painting, &default_ssl_painting, sizeof(struct Painting));
- memcpy(&hmc_painting, &default_hmc_painting, sizeof(struct Painting));
- memcpy(&ddd_painting, &default_ddd_painting, sizeof(struct Painting));
- memcpy(&wdw_painting, &default_wdw_painting, sizeof(struct Painting));
- memcpy(&thi_tiny_painting, &default_thi_tiny_painting, sizeof(struct Painting));
- memcpy(&ttm_painting, &default_ttm_painting, sizeof(struct Painting));
- memcpy(&ttc_painting, &default_ttc_painting, sizeof(struct Painting));
- memcpy(&sl_painting, &default_sl_painting, sizeof(struct Painting));
- memcpy(&thi_huge_painting, &default_thi_huge_painting, sizeof(struct Painting));
- memcpy(&ttm_slide_painting, &default_ttm_slide_painting, sizeof(struct Painting));
- memcpy(sDummyContents, sDefaultExclamationBoxContents, sizeof(struct ExclamationBoxContent) * 15);
-
- gExclamationBoxContents = sDummyContents;
- gExclamationBoxSize = 15;
-
+ RESTORE_PAINTING(cotmc_painting);
+ RESTORE_PAINTING(bob_painting);
+ RESTORE_PAINTING(ccm_painting);
+ RESTORE_PAINTING(wf_painting);
+ RESTORE_PAINTING(jrb_painting);
+ RESTORE_PAINTING(lll_painting);
+ RESTORE_PAINTING(ssl_painting);
+ RESTORE_PAINTING(hmc_painting);
+ RESTORE_PAINTING(ddd_painting);
+ RESTORE_PAINTING(wdw_painting);
+ RESTORE_PAINTING(thi_tiny_painting);
+ RESTORE_PAINTING(ttm_painting);
+ RESTORE_PAINTING(ttc_painting);
+ RESTORE_PAINTING(sl_painting);
+ RESTORE_PAINTING(thi_huge_painting);
+ RESTORE_PAINTING(ttm_slide_painting);
gPaintingValues = gDefaultPaintingValues;
+
+ memcpy(sDummyContents, sDefaultExclamationBoxContents, sizeof(sDefaultExclamationBoxContents));
+ gExclamationBoxContents = sDummyContents;
+ gExclamationBoxSize = ARRAY_COUNT(sDefaultExclamationBoxContents);
}
diff --git a/src/game/level_update.c b/src/game/level_update.c
index 02b821633..fdc255eef 100644
--- a/src/game/level_update.c
+++ b/src/game/level_update.c
@@ -838,7 +838,7 @@ static void initiate_painting_warp_node(struct WarpNode *pWarpNode) {
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
fadeout_music(398);
queue_rumble_data(80, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
}
/**
@@ -861,7 +861,7 @@ void initiate_painting_warp(s16 paintingIndex) {
fadeout_music(398);
#ifdef VERSION_SH
queue_rumble_data(80, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
}
}
@@ -1544,30 +1544,36 @@ s32 update_current_play_mode() {
return changeLevel;
}
+s16 get_menu_level(void) {
+ static enum LevelNum sMenuLevels[] = {
+ LEVEL_CASTLE_GROUNDS,
+ LEVEL_BOB,
+ LEVEL_WF,
+ LEVEL_WMOTR,
+ LEVEL_JRB,
+ LEVEL_SSL,
+ LEVEL_TTM,
+ LEVEL_SL,
+ LEVEL_BBH,
+ LEVEL_LLL,
+ LEVEL_THI,
+ LEVEL_HMC,
+ LEVEL_CCM,
+ LEVEL_RR,
+ LEVEL_BITDW,
+ LEVEL_PSS,
+ LEVEL_TTC,
+ LEVEL_WDW,
+ };
+ if (configMenuLevel < ARRAY_COUNT(sMenuLevels)) {
+ return sMenuLevels[configMenuLevel];
+ }
+ return LEVEL_CASTLE_GROUNDS;
+}
+
void update_menu_level(void) {
// figure out level
- s32 curLevel = 0;
- switch (configMenuLevel) {
- case 0: curLevel = LEVEL_CASTLE_GROUNDS; break;
- case 1: curLevel = LEVEL_BOB; break;
- case 2: curLevel = LEVEL_WF; break;
- case 3: curLevel = LEVEL_WMOTR; break;
- case 4: curLevel = LEVEL_JRB; break;
- case 5: curLevel = LEVEL_SSL; break;
- case 6: curLevel = LEVEL_TTM; break;
- case 7: curLevel = LEVEL_SL; break;
- case 8: curLevel = LEVEL_BBH; break;
- case 9: curLevel = LEVEL_LLL; break;
- case 10: curLevel = LEVEL_THI; break;
- case 11: curLevel = LEVEL_HMC; break;
- case 12: curLevel = LEVEL_CCM; break;
- case 13: curLevel = LEVEL_RR; break;
- case 14: curLevel = LEVEL_BITDW; break;
- case 15: curLevel = LEVEL_PSS; break;
- case 16: curLevel = LEVEL_TTC; break;
- case 17: curLevel = LEVEL_WDW; break;
- default: curLevel = LEVEL_CASTLE_GROUNDS; break;
- }
+ s16 curLevel = get_menu_level();
// figure out music
stop_cap_music();
diff --git a/src/game/level_update.h b/src/game/level_update.h
index d215e5793..26a0a1615 100644
--- a/src/game/level_update.h
+++ b/src/game/level_update.h
@@ -216,6 +216,7 @@ s32 lvl_exiting_credits(UNUSED s16 arg0, UNUSED s32 arg1);
void fake_lvl_init_from_save_file(void);
void lvl_skip_credits(void);
+s16 get_menu_level(void);
void update_menu_level(void);
void stop_demo(UNUSED struct DjuiBase* caller);
diff --git a/src/game/main.h b/src/game/main.h
index 3ea959205..1d709420b 100644
--- a/src/game/main.h
+++ b/src/game/main.h
@@ -2,21 +2,21 @@
#define MAIN_H
struct RumbleData {
- u8 unk00;
- u8 unk01;
- s16 unk02;
- s16 unk04;
+ u8 comm;
+ u8 level;
+ s16 time;
+ s16 decay;
};
-struct StructSH8031D9B0 {
- s16 unk00;
- s16 unk02;
- s16 unk04;
- s16 unk06;
- s16 unk08;
- s16 unk0A;
- s16 unk0C;
- s16 unk0E;
+struct RumbleSettings {
+ s16 event;
+ s16 level;
+ s16 timer;
+ s16 count;
+ s16 start;
+ s16 slip;
+ s16 vibrate;
+ s16 decay;
};
extern OSThread D_80339210;
@@ -49,7 +49,7 @@ extern OSMesgQueue gRumbleThreadVIMesgQueue;
extern s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet
extern struct RumbleData gRumbleDataQueue[3];
-extern struct StructSH8031D9B0 gCurrRumbleSettings;
+extern struct RumbleSettings gCurrRumbleSettings;
extern struct VblankHandler *gVblankHandler1;
extern struct VblankHandler *gVblankHandler2;
diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c
index 1a8bca341..b8fe0777e 100644
--- a/src/game/mario_actions_automatic.c
+++ b/src/game/mario_actions_automatic.c
@@ -862,7 +862,7 @@ s32 act_in_cannon(struct MarioState *m) {
} else {
if (m->faceAngle[0] != startFacePitch || m->faceAngle[1] != startFaceYaw) {
play_sound(SOUND_MOVING_AIM_CANNON, m->marioObj->header.gfx.cameraToObject);
- reset_rumble_timers_2(m, 0);
+ reset_rumble_timers_vibrate(m, 0);
}
}
}
diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c
index 89e46a1eb..0f03d9319 100644
--- a/src/game/mario_actions_cutscene.c
+++ b/src/game/mario_actions_cutscene.c
@@ -1687,7 +1687,7 @@ s32 act_teleport_fade_out(struct MarioState *m) {
if (m->actionTimer == 0) {
queue_rumble_data_mario(m, 30, 70);
if (m->playerIndex == 0) {
- func_sh_8024C89C(2);
+ queue_rumble_decay(2);
}
}
@@ -1717,7 +1717,7 @@ s32 act_teleport_fade_in(struct MarioState *m) {
if (m->actionTimer == 0) {
queue_rumble_data_mario(m, 30, 70);
if (m->playerIndex == 0) {
- func_sh_8024C89C(2);
+ queue_rumble_decay(2);
}
}
diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c
index 7aae77ec4..51cf2d247 100644
--- a/src/game/mario_actions_submerged.c
+++ b/src/game/mario_actions_submerged.c
@@ -611,7 +611,7 @@ static s32 act_breaststroke(struct MarioState *m) {
}
if (m->actionTimer < 6 && m->playerIndex == 0) {
- func_sh_8024CA04();
+ queue_rumble_submerged();
}
set_character_animation(m, CHAR_ANIM_SWIM_PART1);
diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c
index 2366ccfbb..f159f1388 100644
--- a/src/game/obj_behaviors.c
+++ b/src/game/obj_behaviors.c
@@ -125,14 +125,6 @@ Gfx UNUSED *geo_obj_transparency_something(s32 callContext, struct GraphNode *no
return gfxHead;
}
-/* |description|Absolute value (always positive) function|descriptionEnd| */
-f32 absf_2(f32 f) {
- if (f < 0) {
- f *= -1.0f;
- }
- return f;
-}
-
/**
* Turns an object away from floors/walls that it runs into.
*/
@@ -411,7 +403,7 @@ void obj_splash(s32 waterY, s32 objY) {
spawn_object(o, MODEL_IDLE_WATER_WAVE, bhvObjectWaterWave);
if (o->oVelY < -20.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_DIVING_INTO_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DIVING_INTO_WATER);
}
}
@@ -917,7 +909,7 @@ s8 obj_lava_death(void) {
}
if ((o->oTimer % 8) == 0) {
- cur_obj_play_sound_2(SOUND_OBJ_BULLY_EXPLODE_2);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_BULLY_EXPLODE_2);
deathSmoke = spawn_object(o, MODEL_SMOKE, bhvBobombBullyDeathSmoke);
if (deathSmoke != NULL) {
deathSmoke->oPosX += random_float() * 20.0f;
diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c
index dcc1facf4..3c3030d17 100644
--- a/src/game/obj_behaviors_2.c
+++ b/src/game/obj_behaviors_2.c
@@ -397,7 +397,7 @@ s32 cur_obj_play_sound_at_anim_range(s8 startFrame, s8 endFrame, u32 sound) {
}
if (cur_obj_check_anim_frame_in_range(startFrame, val04) || cur_obj_check_anim_frame_in_range(endFrame, val04)) {
- cur_obj_play_sound_2(sound);
+ cur_obj_play_sound_and_rumble_if_visible(sound);
return TRUE;
}
@@ -739,7 +739,7 @@ void obj_set_knockback_action(s32 attackType) {
/* |description|Plays `SOUND_OBJ_STOMPED` and sets the current object's action to `OBJ_ACT_SQUISHED`|descriptionEnd| */
void obj_set_squished_action(void) {
if (!o) { return; }
- cur_obj_play_sound_2(SOUND_OBJ_STOMPED);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_STOMPED);
o->oAction = OBJ_ACT_SQUISHED;
}
@@ -754,9 +754,9 @@ s32 obj_die_if_above_lava_and_health_non_positive(void) {
} else if (!(o->oMoveFlags & OBJ_MOVE_ABOVE_LAVA)) {
if (o->oMoveFlags & OBJ_MOVE_ENTERED_WATER) {
if (o->oWallHitboxRadius < 200.0f) {
- cur_obj_play_sound_2(SOUND_OBJ_DIVING_INTO_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DIVING_INTO_WATER);
} else {
- cur_obj_play_sound_2(SOUND_OBJ_DIVING_IN_WATER);
+ cur_obj_play_sound_and_rumble_if_visible(SOUND_OBJ_DIVING_IN_WATER);
}
}
return FALSE;
diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c
index 23c12cc2c..b8b290e49 100644
--- a/src/game/object_helpers.c
+++ b/src/game/object_helpers.c
@@ -265,15 +265,15 @@ Gfx *geo_choose_area_ext(UNUSED s32 callContext, struct GraphNode *node, UNUSED
}
/* |description|Updates an object's position based on a parent transformation matrix|descriptionEnd| */
-void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1) {
- if (a1 == NULL) { return; }
- f32 spC = a1->oParentRelativePosX;
- f32 sp8 = a1->oParentRelativePosY;
- f32 sp4 = a1->oParentRelativePosZ;
+void obj_update_pos_from_parent_transformation(Mat4 mtx, struct Object *obj) {
+ if (obj == NULL) { return; }
+ f32 relPosX = obj->oParentRelativePosX;
+ f32 relPosY = obj->oParentRelativePosY;
+ f32 relPosZ = obj->oParentRelativePosZ;
- a1->oPosX = spC * a0[0][0] + sp8 * a0[1][0] + sp4 * a0[2][0] + a0[3][0];
- a1->oPosY = spC * a0[0][1] + sp8 * a0[1][1] + sp4 * a0[2][1] + a0[3][1];
- a1->oPosZ = spC * a0[0][2] + sp8 * a0[1][2] + sp4 * a0[2][2] + a0[3][2];
+ obj->oPosX = relPosX * mtx[0][0] + relPosY * mtx[1][0] + relPosZ * mtx[2][0] + mtx[3][0];
+ obj->oPosY = relPosX * mtx[0][1] + relPosY * mtx[1][1] + relPosZ * mtx[2][1] + mtx[3][1];
+ obj->oPosZ = relPosX * mtx[0][2] + relPosY * mtx[1][2] + relPosZ * mtx[2][2] + mtx[3][2];
}
/* |description|Applies an object's scale to a transformation matrix|descriptionEnd| */
@@ -301,33 +301,33 @@ void obj_apply_scale_to_matrix(struct Object *obj, VEC_OUT Mat4 dst, Mat4 src) {
}
/* |description|Combines two transformation matrices into a single result matrix|descriptionEnd| */
-void create_transformation_from_matrices(VEC_OUT Mat4 a0, Mat4 a1, Mat4 a2) {
+void create_transformation_from_matrices(VEC_OUT Mat4 dest, Mat4 src1, Mat4 src2) {
f32 spC, sp8, sp4;
- spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2];
- sp8 = a2[3][0] * a2[1][0] + a2[3][1] * a2[1][1] + a2[3][2] * a2[1][2];
- sp4 = a2[3][0] * a2[2][0] + a2[3][1] * a2[2][1] + a2[3][2] * a2[2][2];
+ spC = src2[3][0] * src2[0][0] + src2[3][1] * src2[0][1] + src2[3][2] * src2[0][2];
+ sp8 = src2[3][0] * src2[1][0] + src2[3][1] * src2[1][1] + src2[3][2] * src2[1][2];
+ sp4 = src2[3][0] * src2[2][0] + src2[3][1] * src2[2][1] + src2[3][2] * src2[2][2];
- a0[0][0] = a1[0][0] * a2[0][0] + a1[0][1] * a2[0][1] + a1[0][2] * a2[0][2];
- a0[0][1] = a1[0][0] * a2[1][0] + a1[0][1] * a2[1][1] + a1[0][2] * a2[1][2];
- a0[0][2] = a1[0][0] * a2[2][0] + a1[0][1] * a2[2][1] + a1[0][2] * a2[2][2];
+ dest[0][0] = src1[0][0] * src2[0][0] + src1[0][1] * src2[0][1] + src1[0][2] * src2[0][2];
+ dest[0][1] = src1[0][0] * src2[1][0] + src1[0][1] * src2[1][1] + src1[0][2] * src2[1][2];
+ dest[0][2] = src1[0][0] * src2[2][0] + src1[0][1] * src2[2][1] + src1[0][2] * src2[2][2];
- a0[1][0] = a1[1][0] * a2[0][0] + a1[1][1] * a2[0][1] + a1[1][2] * a2[0][2];
- a0[1][1] = a1[1][0] * a2[1][0] + a1[1][1] * a2[1][1] + a1[1][2] * a2[1][2];
- a0[1][2] = a1[1][0] * a2[2][0] + a1[1][1] * a2[2][1] + a1[1][2] * a2[2][2];
+ dest[1][0] = src1[1][0] * src2[0][0] + src1[1][1] * src2[0][1] + src1[1][2] * src2[0][2];
+ dest[1][1] = src1[1][0] * src2[1][0] + src1[1][1] * src2[1][1] + src1[1][2] * src2[1][2];
+ dest[1][2] = src1[1][0] * src2[2][0] + src1[1][1] * src2[2][1] + src1[1][2] * src2[2][2];
- a0[2][0] = a1[2][0] * a2[0][0] + a1[2][1] * a2[0][1] + a1[2][2] * a2[0][2];
- a0[2][1] = a1[2][0] * a2[1][0] + a1[2][1] * a2[1][1] + a1[2][2] * a2[1][2];
- a0[2][2] = a1[2][0] * a2[2][0] + a1[2][1] * a2[2][1] + a1[2][2] * a2[2][2];
+ dest[2][0] = src1[2][0] * src2[0][0] + src1[2][1] * src2[0][1] + src1[2][2] * src2[0][2];
+ dest[2][1] = src1[2][0] * src2[1][0] + src1[2][1] * src2[1][1] + src1[2][2] * src2[1][2];
+ dest[2][2] = src1[2][0] * src2[2][0] + src1[2][1] * src2[2][1] + src1[2][2] * src2[2][2];
- a0[3][0] = a1[3][0] * a2[0][0] + a1[3][1] * a2[0][1] + a1[3][2] * a2[0][2] - spC;
- a0[3][1] = a1[3][0] * a2[1][0] + a1[3][1] * a2[1][1] + a1[3][2] * a2[1][2] - sp8;
- a0[3][2] = a1[3][0] * a2[2][0] + a1[3][1] * a2[2][1] + a1[3][2] * a2[2][2] - sp4;
+ dest[3][0] = src1[3][0] * src2[0][0] + src1[3][1] * src2[0][1] + src1[3][2] * src2[0][2] - spC;
+ dest[3][1] = src1[3][0] * src2[1][0] + src1[3][1] * src2[1][1] + src1[3][2] * src2[1][2] - sp8;
+ dest[3][2] = src1[3][0] * src2[2][0] + src1[3][1] * src2[2][1] + src1[3][2] * src2[2][2] - sp4;
- a0[0][3] = 0;
- a0[1][3] = 0;
- a0[2][3] = 0;
- a0[3][3] = 1.0f;
+ dest[0][3] = 0;
+ dest[1][3] = 0;
+ dest[2][3] = 0;
+ dest[3][3] = 1.0f;
}
/* |description|Sets an object's held state based on the behavior script it will perform|descriptionEnd| */
@@ -1047,11 +1047,6 @@ void cur_obj_set_pos_relative_to_parent(f32 dleft, f32 dy, f32 dforward) {
cur_obj_set_pos_relative(o->parentObj, dleft, dy, dforward);
}
-/* |description|Alternative function that enables rendering for the current object|descriptionEnd| */
-void cur_obj_enable_rendering_2(void) {
- cur_obj_enable_rendering();
-}
-
/* |description|Unused function that initializes the current object on the floor|descriptionEnd| */
void cur_obj_unused_init_on_floor(void) {
if (!o) { return; }
@@ -1429,23 +1424,23 @@ s32 mario_is_dive_sliding(struct MarioState* m) {
}
/* |description|Sets the current object's vertical velocity and initializes an animation|descriptionEnd| */
-void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C) {
+void cur_obj_set_y_vel_and_animation(f32 velY, s32 animIndex) {
if (!o) { return; }
- o->oVelY = sp18;
- cur_obj_init_animation_with_sound(sp1C);
+ o->oVelY = velY;
+ cur_obj_init_animation_with_sound(animIndex);
}
-/* |description|Disables rendering, makes intangible, and resets action and animation|descriptionEnd| */
-void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C) {
+/* |description|Disables rendering, makes intangible, and resets animation and action|descriptionEnd| */
+void cur_obj_unrender_and_reset_state(s32 animIndex, s32 action) {
if (!o) { return; }
cur_obj_become_intangible();
cur_obj_disable_rendering();
- if (sp18 >= 0) {
- cur_obj_init_animation_with_sound(sp18);
+ if (animIndex >= 0) {
+ cur_obj_init_animation_with_sound(animIndex);
}
- o->oAction = sp1C;
+ o->oAction = action;
}
/* |description|Moves an object after being thrown or dropped with gravity applied|descriptionEnd| */
@@ -2042,10 +2037,10 @@ void cur_obj_start_cam_event(UNUSED struct Object *obj, s32 cameraEvent) {
gSecondCameraFocus = o;
}
-/* |description|Sets Mario's interact status to hoot-grabbed if Mario is within range|descriptionEnd| */
-void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8) {
+/* |description|Sets Mario's interact status to hoot-grabbed if Mario is within range `maxDistanceToMario`|descriptionEnd| */
+void set_mario_interact_hoot_if_in_range(UNUSED s32 unused1, UNUSED s32 unused2, f32 maxDistanceToMario) {
if (!o || !gMarioObject) { return; }
- if (o->oDistanceToMario < sp8) {
+ if (o->oDistanceToMario < maxDistanceToMario) {
gMarioObject->oInteractStatus = INT_STATUS_HOOT_GRABBED_BY_MARIO;
}
}
@@ -2105,7 +2100,7 @@ void cur_obj_set_hurtbox_radius_and_height(f32 radius, f32 height) {
}
/* |description|Spawns loot coins from an object using the specified behavior, jitter, and model|descriptionEnd| */
-void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model) {
+void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 baseYVel, const BehaviorScript *coinBehavior, s16 posJitter, s16 model) {
if (obj == NULL) { return; }
s32 i;
f32 spawnHeight;
@@ -2128,18 +2123,18 @@ void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const Beha
if (coin == NULL) { return; }
obj_translate_xz_random(coin, posJitter);
coin->oPosY = spawnHeight;
- coin->oCoinUnk110 = sp30;
+ coin->oCoinBaseYVel = baseYVel;
}
}
/* |description|Spawns blue loot coins from an object|descriptionEnd| */
-void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter) {
- obj_spawn_loot_coins(obj, numCoins, sp28, bhvBlueCoinJumping, posJitter, MODEL_BLUE_COIN);
+void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 baseYVel, s16 posJitter) {
+ obj_spawn_loot_coins(obj, numCoins, baseYVel, bhvBlueCoinJumping, posJitter, MODEL_BLUE_COIN);
}
/* |description|Spawns yellow loot coins from an object|descriptionEnd| */
-void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28) {
- obj_spawn_loot_coins(obj, numCoins, sp28, bhvSingleCoinGetsSpawned, 0, MODEL_YELLOW_COIN);
+void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 baseYVel) {
+ obj_spawn_loot_coins(obj, numCoins, baseYVel, bhvSingleCoinGetsSpawned, 0, MODEL_YELLOW_COIN);
}
/* |description|Spawns a yellow coin at Mario's position and decrements the current object's loot count|descriptionEnd| */
@@ -2649,15 +2644,15 @@ void obj_translate_xz_random(struct Object *obj, f32 rangeLength) {
}
/* |description|Builds the object's world velocity from its transform basis vectors|descriptionEnd| */
-void obj_build_vel_from_transform(struct Object *a0) {
- if (a0 == NULL) { return; }
- f32 spC = a0->oUnkC0;
- f32 sp8 = a0->oUnkBC;
- f32 sp4 = a0->oForwardVel;
+void obj_build_vel_from_transform(struct Object *obj) {
+ if (obj == NULL) { return; }
+ f32 spC = obj->oUnkC0;
+ f32 sp8 = obj->oUnkBC;
+ f32 sp4 = obj->oForwardVel;
- a0->oVelX = a0->transform[0][0] * spC + a0->transform[1][0] * sp8 + a0->transform[2][0] * sp4;
- a0->oVelY = a0->transform[0][1] * spC + a0->transform[1][1] * sp8 + a0->transform[2][1] * sp4;
- a0->oVelZ = a0->transform[0][2] * spC + a0->transform[1][2] * sp8 + a0->transform[2][2] * sp4;
+ obj->oVelX = obj->transform[0][0] * spC + obj->transform[1][0] * sp8 + obj->transform[2][0] * sp4;
+ obj->oVelY = obj->transform[0][1] * spC + obj->transform[1][1] * sp8 + obj->transform[2][1] * sp4;
+ obj->oVelZ = obj->transform[0][2] * spC + obj->transform[1][2] * sp8 + obj->transform[2][2] * sp4;
}
/* |description|Moves the current object using its transform-derived velocity|descriptionEnd| */
@@ -2911,26 +2906,25 @@ s32 cur_obj_progress_direction_table(void) {
return ret;
}
-/* |description|Placeholder function with no behavior|descriptionEnd| */
void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4) {
}
-/* |description|Smoothly scales the current object over time using enabled axes|descriptionEnd| */
-void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14) {
+/* |description|Smoothly scales between `minScale` and `maxScale` the current object over a `duration` using enabled `axes` (1 = x, 2 = y, 4 = z, can be combined)|descriptionEnd| */
+void cur_obj_scale_over_time(s32 axes, s32 duration, f32 minScale, f32 maxScale) {
if (!o) { return; }
- f32 sp4 = sp14 - sp10;
- f32 sp0 = (f32) o->oTimer / a1;
+ f32 diffScale = maxScale - minScale;
+ f32 scaleFactor = (f32) o->oTimer / duration;
- if (a0 & 0x01) {
- o->header.gfx.scale[0] = sp4 * sp0 + sp10;
+ if (axes & 0x01) {
+ o->header.gfx.scale[0] = diffScale * scaleFactor + minScale;
}
- if (a0 & 0x02) {
- o->header.gfx.scale[1] = sp4 * sp0 + sp10;
+ if (axes & 0x02) {
+ o->header.gfx.scale[1] = diffScale * scaleFactor + minScale;
}
- if (a0 & 0x04) {
- o->header.gfx.scale[2] = sp4 * sp0 + sp10;
+ if (axes & 0x04) {
+ o->header.gfx.scale[2] = diffScale * scaleFactor + minScale;
}
}
@@ -2943,7 +2937,6 @@ void cur_obj_set_pos_to_home_with_debug(void) {
cur_obj_scale(gDebugInfo[5][3] / 100.0f + 1.0l);
}
-/* |description|Placeholder function with no behavior|descriptionEnd| */
void stub_obj_helpers_4(void) {
}
@@ -2984,13 +2977,13 @@ s32 cur_obj_shake_y_until(s32 cycles, s32 amount) {
}
/* |description|Moves the current object up and down along a preset displacement table|descriptionEnd| */
-s32 cur_obj_move_up_and_down(s32 a0) {
+s32 cur_obj_move_up_and_down(s32 index) {
if (!o) { return 0; }
- if (a0 >= 4 || a0 < 0) {
+ if (index >= 4 || index < 0) {
return TRUE;
}
- o->oPosY += D_8032F0A0[a0];
+ o->oPosY += D_8032F0A0[index];
return FALSE;
}
@@ -3005,15 +2998,15 @@ void cur_obj_call_action_function(void (*actionFunctions[])(void), uint32_t acti
}
/* |description|Spawns a star object without triggering level exit behavior|descriptionEnd| */
-struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24) {
+struct Object *spawn_star_with_no_lvl_exit(s32 setHomeToMario, s32 unused) {
if (!o) { return NULL; }
- struct Object *sp1C = spawn_object(o, MODEL_STAR, bhvSpawnedStarNoLevelExit);
- if (sp1C == NULL) { return NULL; }
- sp1C->oSparkleSpawnUnk1B0 = sp24;
- sp1C->oBehParams = o->oBehParams;
- sp1C->oBehParams2ndByte = sp20;
+ struct Object *star = spawn_object(o, MODEL_STAR, bhvSpawnedStarNoLevelExit);
+ if (star == NULL) { return NULL; }
+ star->oSparkleSpawnUnk1B0 = unused;
+ star->oBehParams = o->oBehParams;
+ star->oBehParams2ndByte = setHomeToMario;
- return sp1C;
+ return star;
}
/* |description|Spawns a base star with default parameters and no level exit behavior|descriptionEnd| */
@@ -3021,7 +3014,6 @@ void spawn_base_star_with_no_lvl_exit(void) {
spawn_star_with_no_lvl_exit(0, 0);
}
-/* |description|Returns the value at index a0 from a behavior-specific left-shift table|descriptionEnd| */
s32 bit_shift_left(s32 a0) {
return BHV_ARR(D_8032F0A4, a0, s16);
}
@@ -3170,15 +3162,15 @@ s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox *hitbox, s32 deat
}
/* |description|Explodes the current object, spawns particles, and optionally spawns coins|descriptionEnd| */
-void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C) {
+void obj_explode_and_spawn_coins(f32 mistSize, enum CoinType coinType) {
if (!o) { return; }
- spawn_mist_particles_variable(0, 0, sp18);
+ spawn_mist_particles_variable(0, 0, mistSize);
spawn_triangle_break_particles(30, 138, 3.0f, 4);
obj_mark_for_deletion(o);
- if (sp1C == 1) {
+ if (coinType == COIN_TYPE_YELLOW) {
obj_spawn_loot_yellow_coins(o, o->oNumLootCoins, 20.0f);
- } else if (sp1C == 2) {
+ } else if (coinType == COIN_TYPE_BLUE) {
obj_spawn_loot_blue_coins(o, o->oNumLootCoins, 20.0f, 150);
}
}
@@ -3282,7 +3274,7 @@ void clear_time_stop_flags(s32 flags) {
}
/* |description|Checks whether Mario can activate the current object's textbox within a vertical and horizontal range|descriptionEnd| */
-s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused) {
+s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, OPTIONAL UNUSED s32 unused) {
if (!o || !m) { return 0; }
if (!m->visibleToObjects) { return FALSE; }
if (o->oDistanceToMario < 1500.0f) {
@@ -3299,12 +3291,6 @@ s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 hei
return FALSE;
}
-/* |description|Wrapper that checks Mario textbox activation using a fixed unused parameter value|descriptionEnd| */
-s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height) {
- // The last argument here is unused. When this function is called directly the argument is always set to 0x7FFF.
- return cur_obj_can_mario_activate_textbox(m, radius, height, 0x1000);
-}
-
/* |description|Ends dialog state for the current object and records Mario's response|descriptionEnd| */
void cur_obj_end_dialog(struct MarioState* m, s32 dialogFlags, s32 dialogResult) {
if (!o || !m) { return; }
@@ -3638,7 +3624,7 @@ s32 player_performed_grab_escape_action(void) {
/* |description|Plays a footstep sound when the current animation reaches one of two frames|descriptionEnd| */
void cur_obj_unused_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound) {
if (cur_obj_check_anim_frame(animFrame1) || cur_obj_check_anim_frame(animFrame2)) {
- cur_obj_play_sound_2(sound);
+ cur_obj_play_sound_and_rumble_if_visible(sound);
}
}
diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h
index 18d085648..5bc41f049 100644
--- a/src/game/object_helpers.h
+++ b/src/game/object_helpers.h
@@ -6,10 +6,10 @@
#include "macros.h"
#include "types.h"
#include "pc/lua/utils/smlua_model_utils.h"
+#include "object_constants.h"
// used for chain chomp and wiggler
-struct ChainSegment
-{
+struct ChainSegment {
f32 posX;
f32 posY;
f32 posZ;
@@ -26,8 +26,7 @@ struct ChainSegment
#define WATER_DROPLET_FLAG_RAND_ANGLE_INCR 0x80 // Unused
// Call spawn_water_droplet with this struct to spawn an object.
-struct WaterDropletParams
-{
+struct WaterDropletParams {
s16 flags; // Droplet spawn flags, see defines above
s16 model;
const BehaviorScript *behavior;
@@ -41,9 +40,7 @@ struct WaterDropletParams
f32 randSizeScale;
};
-// TODO: Field names
-struct SpawnParticlesInfo
-{
+struct SpawnParticlesInfo {
/*0x00*/ s8 behParam;
/*0x01*/ s8 count;
/*0x02*/ u16 model;
@@ -72,9 +69,9 @@ Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node);
Gfx *geo_switch_area(s32 callContext, struct GraphNode *node);
#endif
Gfx *geo_choose_area_ext(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx);
-void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1);
+void obj_update_pos_from_parent_transformation(Mat4 mtx, struct Object *obj);
void obj_apply_scale_to_matrix(struct Object *obj, VEC_OUT Mat4 dst, Mat4 src);
-void create_transformation_from_matrices(VEC_OUT Mat4 a0, Mat4 a1, Mat4 a2);
+void create_transformation_from_matrices(VEC_OUT Mat4 dest, Mat4 src1, Mat4 src2);
void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior);
f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2);
f32 dist_between_objects(struct Object *obj1, struct Object *obj2);
@@ -137,7 +134,6 @@ void cur_obj_unhide(void);
void cur_obj_hide(void);
void cur_obj_set_pos_relative(struct Object *other, f32 dleft, f32 dy, f32 dforward);
void cur_obj_set_pos_relative_to_parent(f32 dleft, f32 dy, f32 dforward);
-void cur_obj_enable_rendering_2(void);
void obj_set_face_angle_to_move_angle(struct Object *obj);
u32 get_object_list_from_behavior(const BehaviorScript *behavior);
struct Object *cur_obj_nearest_object_with_behavior(const BehaviorScript *behavior);
@@ -160,8 +156,8 @@ s32 cur_obj_check_anim_frame(s32 frame);
s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength);
s32 mario_is_in_air_action(struct MarioState* m);
s32 mario_is_dive_sliding(struct MarioState* m);
-void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);
-void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C);
+void cur_obj_set_y_vel_and_animation(f32 velY, s32 animIndex);
+void cur_obj_unrender_and_reset_state(s32 animIndex, s32 action);
void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction);
void cur_obj_get_dropped(void);
void cur_obj_set_model(s32 modelID);
@@ -194,7 +190,7 @@ void cur_obj_set_pos_to_home(void);
void cur_obj_set_pos_to_home_and_stop(void);
void cur_obj_shake_y(f32 amount);
void cur_obj_start_cam_event(UNUSED struct Object *obj, s32 cameraEvent);
-void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8);
+void set_mario_interact_hoot_if_in_range(UNUSED s32 unused1, UNUSED s32 unused2, f32 maxDistanceToMario);
void obj_set_billboard(struct Object *obj);
void obj_set_cylboard(struct Object *obj);
void cur_obj_set_billboard_if_vanilla_cam(void);
@@ -264,10 +260,10 @@ void cur_obj_push_mario_away_from_cylinder(f32 radius, f32 extentY);
s32 cur_obj_set_direction_table(s8 *a0);
s32 cur_obj_progress_direction_table(void);
void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4);
-void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14);
+void cur_obj_scale_over_time(s32 axes, s32 duration, f32 minScale, f32 maxScale);
void cur_obj_set_pos_to_home_with_debug(void);
s32 cur_obj_is_mario_on_platform(void);
-s32 cur_obj_move_up_and_down(s32 a0);
+s32 cur_obj_move_up_and_down(s32 index);
void cur_obj_call_action_function(void (*actionFunctions[])(void), uint32_t actionFunctionsLength);
void spawn_base_star_with_no_lvl_exit(void);
s32 bit_shift_left(s32 a0);
@@ -276,7 +272,7 @@ s32 is_mario_moving_fast_or_in_air(s32 speedThreshold);
s32 is_item_in_array(s8 item, s8 *array);
void cur_obj_enable_rendering_if_mario_in_room(void);
s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox *hitbox, s32 deathSound, s32 noLootCoins);
-void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C);
+void obj_explode_and_spawn_coins(f32 mistSize, enum CoinType coinType);
void obj_set_collision_data(struct Object *obj, const void *segAddr);
void cur_obj_if_hit_wall_bounce_away(void);
s32 cur_obj_hide_if_mario_far_away_y(f32 distY);
@@ -289,8 +285,7 @@ void disable_time_stop(void);
void set_time_stop_flags(s32 flags);
void set_time_stop_flags_if_alone(s32 flags);
void clear_time_stop_flags(s32 flags);
-s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused);
-s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height);
+s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, OPTIONAL UNUSED s32 unused);
s32 cur_obj_update_dialog(struct MarioState* m, s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s32 unused, u8 (*inContinueDialogFunction)(void));
s32 cur_obj_update_dialog_with_cutscene(struct MarioState* m, s32 actionArg, s32 dialogFlags, s32 cutsceneTable, s32 dialogID, u8 (*inContinueDialogFunction)(void));
s32 cur_obj_has_model(u16 modelID);
diff --git a/src/game/paintings.h b/src/game/paintings.h
index 98fe85fd8..c5e661a0e 100644
--- a/src/game/paintings.h
+++ b/src/game/paintings.h
@@ -48,6 +48,12 @@ typedef struct {
signed char n[3]; /* normal */
} Vtx_Interp;
+#define DEFINE_PAINTING(name, ...) \
+struct Painting name = __VA_ARGS__; \
+const struct Painting default_ ## name = __VA_ARGS__
+
+#define RESTORE_PAINTING(name) name = default_ ## name
+
struct Painting
{
s16 id;
diff --git a/src/game/rumble_init.c b/src/game/rumble_init.c
index 9236597aa..aac605bf0 100644
--- a/src/game/rumble_init.c
+++ b/src/game/rumble_init.c
@@ -15,7 +15,7 @@ OSMesg gRumbleThreadVIMesgBuf[1];
OSMesgQueue gRumbleThreadVIMesgQueue;
struct RumbleData gRumbleDataQueue[3];
-struct StructSH8031D9B0 gCurrRumbleSettings;
+struct RumbleSettings gCurrRumbleSettings;
s32 sRumblePakThreadActive = 0;
s32 sRumblePakActive = 0;
@@ -80,109 +80,109 @@ static void update_rumble_pak(void) {
return;
}
- if (gCurrRumbleSettings.unk08 > 0) {
- gCurrRumbleSettings.unk08--;
+ if (gCurrRumbleSettings.start > 0) {
+ gCurrRumbleSettings.start--;
start_rumble();
- } else if (gCurrRumbleSettings.unk04 > 0) {
- gCurrRumbleSettings.unk04--;
+ } else if (gCurrRumbleSettings.timer > 0) {
+ gCurrRumbleSettings.timer--;
- gCurrRumbleSettings.unk02 -= gCurrRumbleSettings.unk0E;
- if (gCurrRumbleSettings.unk02 < 0) {
- gCurrRumbleSettings.unk02 = 0;
+ gCurrRumbleSettings.level -= gCurrRumbleSettings.decay;
+ if (gCurrRumbleSettings.level < 0) {
+ gCurrRumbleSettings.level = 0;
}
- if (gCurrRumbleSettings.unk00 == 1) {
+ if (gCurrRumbleSettings.event == 1) {
start_rumble();
- } else if (gCurrRumbleSettings.unk06 >= 0x100) {
- gCurrRumbleSettings.unk06 -= 0x100;
+ } else if (gCurrRumbleSettings.count >= 0x100) {
+ gCurrRumbleSettings.count -= 0x100;
start_rumble();
} else {
- gCurrRumbleSettings.unk06 +=
- ((gCurrRumbleSettings.unk02 * gCurrRumbleSettings.unk02 * gCurrRumbleSettings.unk02) / (1 << 9)) + 4;
+ gCurrRumbleSettings.count +=
+ ((gCurrRumbleSettings.level * gCurrRumbleSettings.level * gCurrRumbleSettings.level) / (1 << 9)) + 4;
stop_rumble();
}
} else {
- gCurrRumbleSettings.unk04 = 0;
+ gCurrRumbleSettings.timer = 0;
- if (gCurrRumbleSettings.unk0A >= 5) {
+ if (gCurrRumbleSettings.slip >= 5) {
start_rumble();
- } else if ((gCurrRumbleSettings.unk0A >= 2) && gCurrRumbleSettings.unk0C && (gNumVblanks % gCurrRumbleSettings.unk0C == 0)) {
+ } else if ((gCurrRumbleSettings.slip >= 2) && gCurrRumbleSettings.vibrate && (gNumVblanks % gCurrRumbleSettings.vibrate == 0)) {
start_rumble();
} else {
stop_rumble();
}
}
- if (gCurrRumbleSettings.unk0A > 0) {
- gCurrRumbleSettings.unk0A--;
+ if (gCurrRumbleSettings.slip > 0) {
+ gCurrRumbleSettings.slip--;
}
}
static void update_rumble_data_queue(void) {
- if (gRumbleDataQueue[0].unk00) {
- gCurrRumbleSettings.unk06 = 0;
- gCurrRumbleSettings.unk08 = 4;
- gCurrRumbleSettings.unk00 = gRumbleDataQueue[0].unk00;
- gCurrRumbleSettings.unk04 = gRumbleDataQueue[0].unk02;
- gCurrRumbleSettings.unk02 = gRumbleDataQueue[0].unk01;
- gCurrRumbleSettings.unk0E = gRumbleDataQueue[0].unk04;
+ if (gRumbleDataQueue[0].comm) {
+ gCurrRumbleSettings.count = 0;
+ gCurrRumbleSettings.start = 4;
+ gCurrRumbleSettings.event = gRumbleDataQueue[0].comm;
+ gCurrRumbleSettings.timer = gRumbleDataQueue[0].time;
+ gCurrRumbleSettings.level = gRumbleDataQueue[0].level;
+ gCurrRumbleSettings.decay = gRumbleDataQueue[0].decay;
}
gRumbleDataQueue[0] = gRumbleDataQueue[1];
gRumbleDataQueue[1] = gRumbleDataQueue[2];
- gRumbleDataQueue[2].unk00 = 0;
+ gRumbleDataQueue[2].comm = 0;
}
-void queue_rumble_data(s16 a0, s16 a1) {
+void queue_rumble_data(s16 time, s16 level) {
if (gCurrDemoInput != NULL || gDjuiInMainMenu) {
return;
}
- if (a1 > 70) {
- gRumbleDataQueue[2].unk00 = 1;
+ if (level > 70) {
+ gRumbleDataQueue[2].comm = 1;
} else {
- gRumbleDataQueue[2].unk00 = 2;
+ gRumbleDataQueue[2].comm = 2;
}
- gRumbleDataQueue[2].unk01 = a1;
- gRumbleDataQueue[2].unk02 = a0;
- gRumbleDataQueue[2].unk04 = 0;
+ gRumbleDataQueue[2].level = level;
+ gRumbleDataQueue[2].time = time;
+ gRumbleDataQueue[2].decay = 0;
}
-void queue_rumble_data_object(struct Object* object, s16 a0, s16 a1) {
+void queue_rumble_data_object(struct Object* object, s16 time, s16 level) {
extern struct MarioState gMarioStates[];
f32 dist = dist_between_objects(object, gMarioStates[0].marioObj);
if (dist > 5000) { return; }
- a0 = a0 * (1.0f - (dist / 5000.0f));
- a1 = a1 * (1.0f - (dist / 5000.0f));
- queue_rumble_data(a0, a1);
+ time = time * (1.0f - (dist / 5000.0f));
+ level = level * (1.0f - (dist / 5000.0f));
+ queue_rumble_data(time, level);
}
-void queue_rumble_data_mario(struct MarioState* m, s16 a0, s16 a1) {
+void queue_rumble_data_mario(struct MarioState* m, s16 time, s16 level) {
if (!m || m->playerIndex != 0) { return; }
- queue_rumble_data(a0, a1);
+ queue_rumble_data(time, level);
}
-void func_sh_8024C89C(s16 a0) {
- gRumbleDataQueue[2].unk04 = a0;
+void queue_rumble_decay(s16 decay) {
+ gRumbleDataQueue[2].decay = decay;
}
u8 is_rumble_finished_and_queue_empty(void) {
- if (gCurrRumbleSettings.unk08 + gCurrRumbleSettings.unk04 >= 4) {
+ if (gCurrRumbleSettings.start + gCurrRumbleSettings.timer >= 4) {
return FALSE;
}
- if (gRumbleDataQueue[0].unk00 != 0) {
+ if (gRumbleDataQueue[0].comm != 0) {
return FALSE;
}
- if (gRumbleDataQueue[1].unk00 != 0) {
+ if (gRumbleDataQueue[1].comm != 0) {
return FALSE;
}
- if (gRumbleDataQueue[2].unk00 != 0) {
+ if (gRumbleDataQueue[2].comm != 0) {
return FALSE;
}
@@ -196,60 +196,48 @@ void reset_rumble_timers(struct MarioState* m) {
return;
}
- if (gCurrRumbleSettings.unk0A == 0) {
- gCurrRumbleSettings.unk0A = 7;
+ if (gCurrRumbleSettings.slip == 0) {
+ gCurrRumbleSettings.slip = 7;
}
- if (gCurrRumbleSettings.unk0A < 4) {
- gCurrRumbleSettings.unk0A = 4;
+ if (gCurrRumbleSettings.slip < 4) {
+ gCurrRumbleSettings.slip = 4;
}
- gCurrRumbleSettings.unk0C = 7;
+ gCurrRumbleSettings.vibrate = 7;
}
-void reset_rumble_timers_2(struct MarioState* m, s32 a0) {
+void reset_rumble_timers_vibrate(struct MarioState* m, s32 level) {
if (!m || m->playerIndex != 0) { return; }
if (gCurrDemoInput != NULL) {
return;
}
- if (gCurrRumbleSettings.unk0A == 0) {
- gCurrRumbleSettings.unk0A = 7;
+ if (gCurrRumbleSettings.slip == 0) {
+ gCurrRumbleSettings.slip = 7;
}
- if (gCurrRumbleSettings.unk0A < 4) {
- gCurrRumbleSettings.unk0A = 4;
+ if (gCurrRumbleSettings.slip < 4) {
+ gCurrRumbleSettings.slip = 4;
}
- if (a0 == 4) {
- gCurrRumbleSettings.unk0C = 1;
- }
-
- if (a0 == 3) {
- gCurrRumbleSettings.unk0C = 2;
- }
-
- if (a0 == 2) {
- gCurrRumbleSettings.unk0C = 3;
- }
-
- if (a0 == 1) {
- gCurrRumbleSettings.unk0C = 4;
- }
-
- if (a0 == 0) {
- gCurrRumbleSettings.unk0C = 5;
+ switch (level) {
+ case 0: gCurrRumbleSettings.vibrate = 5; break;
+ case 1: gCurrRumbleSettings.vibrate = 4; break;
+ case 2: gCurrRumbleSettings.vibrate = 3; break;
+ case 3: gCurrRumbleSettings.vibrate = 2; break;
+ case 4: gCurrRumbleSettings.vibrate = 1; break;
}
}
-void func_sh_8024CA04(void) {
+void queue_rumble_submerged(void) {
if (gCurrDemoInput != NULL) {
return;
}
- gCurrRumbleSettings.unk0A = 4;
- gCurrRumbleSettings.unk0C = 4;
+ gCurrRumbleSettings.slip = 4;
+ gCurrRumbleSettings.vibrate = 4;
}
void thread6_rumble_loop(UNUSED void *a0) {
@@ -280,12 +268,12 @@ void cancel_rumble(void) {
osMotorStop(&gRumblePakPfs);
}
- gRumbleDataQueue[0].unk00 = 0;
- gRumbleDataQueue[1].unk00 = 0;
- gRumbleDataQueue[2].unk00 = 0;
+ gRumbleDataQueue[0].comm = 0;
+ gRumbleDataQueue[1].comm = 0;
+ gRumbleDataQueue[2].comm = 0;
- gCurrRumbleSettings.unk04 = 0;
- gCurrRumbleSettings.unk0A = 0;
+ gCurrRumbleSettings.timer = 0;
+ gCurrRumbleSettings.slip = 0;
gRumblePakTimer = 0;
}
diff --git a/src/game/rumble_init.h b/src/game/rumble_init.h
index e6e6329f4..1405e6ae5 100644
--- a/src/game/rumble_init.h
+++ b/src/game/rumble_init.h
@@ -8,22 +8,26 @@ extern s32 gRumblePakTimer;
void init_rumble_pak_scheduler_queue(void);
void block_until_rumble_pak_free(void);
void release_rumble_pak_control(void);
-/* |description|Queues rumble data|descriptionEnd| */
-void queue_rumble_data(s16 a0, s16 a1);
-/* |description|Queues rumble data for object, factoring in its distance from Mario|descriptionEnd| */
-void queue_rumble_data_object(struct Object* object, s16 a0, s16 a1);
-/* |description|Queues rumble data for Mario|descriptionEnd| */
-void queue_rumble_data_mario(struct MarioState* m, s16 a0, s16 a1);
-void func_sh_8024C89C(s16 a0);
+/* |description|Queues rumble data with `time` and `level`|descriptionEnd| */
+void queue_rumble_data(s16 time, s16 level);
+/* |description|Queues rumble data for object with `time` and `level`, factoring in its distance from Mario|descriptionEnd| */
+void queue_rumble_data_object(struct Object* object, s16 time, s16 level);
+/* |description|Queues rumble data with `time` and `level` only if `m` is the local Mario|descriptionEnd| */
+void queue_rumble_data_mario(struct MarioState* m, s16 time, s16 level);
+/* |description|Queues rumble `decay`|descriptionEnd| */
+void queue_rumble_decay(s16 decay);
+/* |description|Checks if rumble is finished and there is no rumble queued|descriptionEnd| */
u8 is_rumble_finished_and_queue_empty(void);
-/* |description|Resets rumble timers|descriptionEnd| */
+/* |description|Resets rumble timers only if `m` is the local Mario|descriptionEnd| */
void reset_rumble_timers(struct MarioState* m);
-/* |description|Resets rumble timers and sets a field based on `a0`|descriptionEnd| */
-void reset_rumble_timers_2(struct MarioState* m, s32 a0);
-void func_sh_8024CA04(void);
+/* |description|Resets rumble timers and sets vibrate based on `level`|descriptionEnd| */
+void reset_rumble_timers_vibrate(struct MarioState* m, s32 level);
+/* |description|Queues rumble data for submerged actions|descriptionEnd| */
+void queue_rumble_submerged(void);
+/* |description|Cancels all currently queued rumble data|descriptionEnd| */
void cancel_rumble(void);
void create_thread_6(void);
void rumble_thread_update_vi(void);
-void thread6_rumble_loop(void *a0);
+void thread6_rumble_loop(UNUSED void *a0);
#endif // RUMBLE_INIT_H
diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c
index c596a9004..2d04a4b1b 100644
--- a/src/game/spawn_object.c
+++ b/src/game/spawn_object.c
@@ -193,7 +193,7 @@ UNUSED static void unused_delete_leaf_nodes(struct Object *obj) {
unused_delete_leaf_nodes(children);
} else {
// No children
- mark_obj_for_deletion(obj);
+ obj_mark_for_deletion(obj);
}
while ((sibling = (struct Object *) obj->header.gfx.node.next) != obj0) {
@@ -421,12 +421,3 @@ struct Object *create_object(const BehaviorScript *bhvScript) {
return obj;
}
-
-/**
- * Mark an object to be unloaded at the end of the frame.
- */
-void mark_obj_for_deletion(struct Object *obj) {
- if (!obj) { return; }
- //! Same issue as obj_mark_for_deletion
- obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
-}
diff --git a/src/game/spawn_object.h b/src/game/spawn_object.h
index acb9cd038..78ac92b86 100644
--- a/src/game/spawn_object.h
+++ b/src/game/spawn_object.h
@@ -7,6 +7,5 @@ void init_free_object_list(void);
void clear_object_lists(struct ObjectNode *objLists);
void unload_object(struct Object *obj);
struct Object *create_object(const BehaviorScript *bhvScript);
-void mark_obj_for_deletion(struct Object *obj);
#endif // SPAWN_OBJECT_H
diff --git a/src/game/spawn_sound.c b/src/game/spawn_sound.c
index 45ccade9a..4ec4d9d40 100644
--- a/src/game/spawn_sound.c
+++ b/src/game/spawn_sound.c
@@ -33,13 +33,13 @@ void exec_anim_sound_state(struct SoundState *soundStates, u16 maxSoundStates) {
// animFrame entries. These checks skips them.
if ((animFrame = soundStates[stateIdx].animFrame1) >= 0) {
if (cur_obj_check_anim_frame(animFrame)) {
- cur_obj_play_sound_2(soundStates[stateIdx].soundMagic);
+ cur_obj_play_sound_and_rumble_if_visible(soundStates[stateIdx].soundMagic);
}
}
if ((animFrame = soundStates[stateIdx].animFrame2) >= 0) {
if (cur_obj_check_anim_frame(animFrame)) {
- cur_obj_play_sound_2(soundStates[stateIdx].soundMagic);
+ cur_obj_play_sound_and_rumble_if_visible(soundStates[stateIdx].soundMagic);
}
}
} break;
@@ -59,17 +59,17 @@ void create_sound_spawner(s32 soundMagic) {
/*
* The following 2 functions are relevant to the sound state function
- * above. While only cur_obj_play_sound_2 is used, they may have been intended as
+ * above. While only cur_obj_play_sound_and_rumble_if_visible is used, they may have been intended as
* separate left/right leg functions that went unused.
*/
-void cur_obj_play_sound_1(s32 soundMagic) {
+void cur_obj_play_sound_if_visible(s32 soundMagic) {
if (!gCurrentObject) { return; }
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) {
play_sound(soundMagic, gCurrentObject->header.gfx.cameraToObject);
}
}
-void cur_obj_play_sound_2(s32 soundMagic) {
+void cur_obj_play_sound_and_rumble_if_visible(s32 soundMagic) {
if (!gCurrentObject) { return; }
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) {
play_sound(soundMagic, gCurrentObject->header.gfx.cameraToObject);
diff --git a/src/game/spawn_sound.h b/src/game/spawn_sound.h
index 64dab86b5..9f5edc5b8 100644
--- a/src/game/spawn_sound.h
+++ b/src/game/spawn_sound.h
@@ -20,28 +20,18 @@ void exec_anim_sound_state(struct SoundState *soundStates, u16 maxSoundStates);
/* |description|
Plays a sound if the current object is visible
|descriptionEnd| */
-void cur_obj_play_sound_1(s32 soundMagic);
+void cur_obj_play_sound_if_visible(s32 soundMagic);
/* |description|
-Plays a sound if the current object is visible and queues rumble for specific sounds
+Plays a sound if the current object is visible and queues rumble for the following sounds: `SOUND_OBJ_BOWSER_WALK`, `SOUND_OBJ_POUNDING_LOUD`, `SOUND_OBJ_WHOMP_LOWPRIO`
|descriptionEnd| */
-void cur_obj_play_sound_2(s32 soundMagic);
+void cur_obj_play_sound_and_rumble_if_visible(s32 soundMagic);
/* |description|
Create a sound spawner for objects that need a sound play once.
(Breakable walls, King Bobomb exploding, etc)
|descriptionEnd| */
void create_sound_spawner(s32 soundMagic);
-/* |description|
-Unused vanilla function, calculates a volume based on `distance`.
-If `distance` is less than 500 then 127, if `distance` is greater than 1500 then 0, if `distance` is between 500 and 1500 then it ranges linearly from 60 to 124.
-What an even more strange and confusing function
-|descriptionEnd| */
s32 calc_dist_to_volume_range_1(f32 distance);
-/* |description|
-Unused vanilla function, calculates a volume based on `distance`.
-If `distance` is less than 1300 then 127, if `distance` is greater than 2300 then 0, if `distance` is between 1300 and 2300 then it ranges linearly from 60 to 127.
-What a strange and confusing function
-|descriptionEnd| */
s32 calc_dist_to_volume_range_2(f32 distance);
#endif // SPAWN_SOUND_H
diff --git a/src/menu/file_select.c b/src/menu/file_select.c
index 6caef0edc..4c929ee43 100644
--- a/src/menu/file_select.c
+++ b/src/menu/file_select.c
@@ -1165,22 +1165,22 @@ void return_to_main_menu(s16 prevMenuButtonID, struct Object *sourceButton) {
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_SOUND_MODE) {
for (buttonID = MENU_BUTTON_OPTION_MIN; buttonID < MENU_BUTTON_OPTION_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
}
@@ -1206,17 +1206,17 @@ void load_score_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut
//! was opened from the score menu!
{
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select score menu and render it's buttons
@@ -1245,19 +1245,19 @@ void load_copy_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceButt
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) //! Not possible, this is checking if the copy menu
//! was opened from the copy menu!
{
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select copy menu and render it's buttons
@@ -1286,19 +1286,19 @@ void load_erase_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) //! Not possible, this is checking if the erase menu
//! was opened from the erase menu!
{
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
- mark_obj_for_deletion(sMainMenuButtons[buttonID]);
+ obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select erase menu and render it's buttons
@@ -1432,28 +1432,28 @@ void check_main_menu_clicked_buttons(void) {
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
break;
case MENU_BUTTON_PLAY_FILE_B:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
break;
case MENU_BUTTON_PLAY_FILE_C:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
break;
case MENU_BUTTON_PLAY_FILE_D:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
break;
// Play sound of the button clicked and render buttons of that menu.
diff --git a/src/menu/level_select_menu.c b/src/menu/level_select_menu.c
index ef26e0917..2c0ca63e7 100644
--- a/src/menu/level_select_menu.c
+++ b/src/menu/level_select_menu.c
@@ -190,7 +190,7 @@ s32 intro_default(void) {
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
sp1C = 100 + gDebugLevelSelect;
#ifndef VERSION_JP
@@ -216,7 +216,7 @@ s32 intro_game_over(void) {
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
sp1C = 100 + gDebugLevelSelect;
#ifndef VERSION_JP
diff --git a/src/menu/star_select.c b/src/menu/star_select.c
index f3f651e2f..2a0471489 100644
--- a/src/menu/star_select.c
+++ b/src/menu/star_select.c
@@ -495,7 +495,7 @@ void star_select_finish_selection(void) {
#endif
#ifdef VERSION_SH
queue_rumble_data(60, 70);
- func_sh_8024C89C(1);
+ queue_rumble_decay(1);
#endif
if (sInitSelectedActNum >= sSelectedActIndex + 1) {
sLoadedActNum = sSelectedActIndex + 1;
diff --git a/src/pc/audio/audio_sdl.c b/src/pc/audio/audio_sdl.c
index 6c805a1fb..88d209b5b 100644
--- a/src/pc/audio/audio_sdl.c
+++ b/src/pc/audio/audio_sdl.c
@@ -53,7 +53,7 @@ static bool audio_sdl_reopen_speaker(const char* name) {
SDL_AudioDeviceID dev = SDL_OpenAudioDevice(name, AudioDevType_Speakers, &sSpeakerSpec, NULL, 0);
if (dev == 0) {
- fprintf(stderr, "SDL_OpenAudio playback error: %s\n", SDL_GetError());
+ fprintf(stderr, "SDL_OpenAudioDevice playback error: %s\n", SDL_GetError());
return false;
}
if (sSpeakerDev != 0) SDL_CloseAudioDevice(sSpeakerDev);
@@ -72,7 +72,7 @@ static bool audio_sdl_reopen_microphone(const char* name) {
SDL_AudioDeviceID dev = SDL_OpenAudioDevice(name, AudioDevType_Microphone, &sMicrophoneSpec, NULL, 0);
if (dev == 0) {
gVoicePlayer->error = VOICECHAT_ERR_NO_MICROPHONE;
- fprintf(stderr, "SDL_OpenAudio capture error: %s\n", SDL_GetError());
+ fprintf(stderr, "SDL_OpenAudioDevice capture error: %s\n", SDL_GetError());
return false;
}
if (sMicrophoneDev != 0) SDL_CloseAudioDevice(sMicrophoneDev);
@@ -87,7 +87,7 @@ static bool audio_sdl_reopen_microphone(const char* name) {
static bool audio_sdl_init(const char* speaker, const char* microphone) {
if (SDL_Init(SDL_INIT_AUDIO) != 0) {
- fprintf(stderr, "SDL init error: %s\n", SDL_GetError());
+ fprintf(stderr, "SDL_InitSubSystem error: %s\n", SDL_GetError());
return false;
}
@@ -168,10 +168,14 @@ static void audio_sdl_shutdown(void)
{
if (SDL_WasInit(SDL_INIT_AUDIO)) {
if (sSpeakerDev != 0) {
+ SDL_PauseAudioDevice(sSpeakerDev, 1);
+ SDL_ClearQueuedAudio(sSpeakerDev);
SDL_CloseAudioDevice(sSpeakerDev);
sSpeakerDev = 0;
}
if (sMicrophoneDev != 0) {
+ SDL_PauseAudioDevice(sMicrophoneDev, 1);
+ SDL_ClearQueuedAudio(sMicrophoneDev);
SDL_CloseAudioDevice(sMicrophoneDev);
sMicrophoneDev = 0;
}
diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c
index 0e61d8ca0..c4384e85a 100644
--- a/src/pc/lua/smlua_cobject_autogen.c
+++ b/src/pc/lua/smlua_cobject_autogen.c
@@ -379,20 +379,23 @@ static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COU
{ "trajectories", LVT_COBJECT, offsetof(struct BehaviorValues, trajectories), true, LOT_BEHAVIORTRAJECTORIES },
};
-#define LUA_CAMERA_FIELD_COUNT 12
+#define LUA_CAMERA_FIELD_COUNT 15
static struct LuaObjectField sCameraFields[LUA_CAMERA_FIELD_COUNT] = {
- { "areaCenX", LVT_F32, offsetof(struct Camera, areaCenX), false, LOT_NONE },
- { "areaCenY", LVT_F32, offsetof(struct Camera, areaCenY), false, LOT_NONE },
- { "areaCenZ", LVT_F32, offsetof(struct Camera, areaCenZ), false, LOT_NONE },
- { "cutscene", LVT_U8, offsetof(struct Camera, cutscene), false, LOT_NONE },
- { "defMode", LVT_U8, offsetof(struct Camera, defMode), false, LOT_NONE },
- { "doorStatus", LVT_U8, offsetof(struct Camera, doorStatus), false, LOT_NONE },
- { "focus", LVT_COBJECT, offsetof(struct Camera, focus), true, LOT_VEC3F },
- { "mode", LVT_U8, offsetof(struct Camera, mode), false, LOT_NONE },
- { "mtx", LVT_COBJECT, offsetof(struct Camera, mtx), true, LOT_MAT4 },
- { "nextYaw", LVT_S16, offsetof(struct Camera, nextYaw), false, LOT_NONE },
- { "pos", LVT_COBJECT, offsetof(struct Camera, pos), true, LOT_VEC3F },
- { "yaw", LVT_S16, offsetof(struct Camera, yaw), false, LOT_NONE },
+ { "areaCenX", LVT_F32, offsetof(struct Camera, areaCenX), false, LOT_NONE },
+ { "areaCenY", LVT_F32, offsetof(struct Camera, areaCenY), false, LOT_NONE },
+ { "areaCenZ", LVT_F32, offsetof(struct Camera, areaCenZ), false, LOT_NONE },
+ { "cutscene", LVT_U8, offsetof(struct Camera, cutscene), false, LOT_NONE },
+ { "defMode", LVT_U8, offsetof(struct Camera, defMode), false, LOT_NONE },
+ { "doorStatus", LVT_U8, offsetof(struct Camera, doorStatus), false, LOT_NONE },
+ { "filler31", LVT_U8, offsetof(struct Camera, filler31), false, LOT_NONE, 8, sizeof(u8) },
+ { "filler3C", LVT_U8, offsetof(struct Camera, filler3C), false, LOT_NONE, 40, sizeof(u8) },
+ { "focus", LVT_COBJECT, offsetof(struct Camera, focus), true, LOT_VEC3F },
+ { "mode", LVT_U8, offsetof(struct Camera, mode), false, LOT_NONE },
+ { "mtx", LVT_COBJECT, offsetof(struct Camera, mtx), true, LOT_MAT4 },
+ { "nextYaw", LVT_S16, offsetof(struct Camera, nextYaw), false, LOT_NONE },
+ { "pos", LVT_COBJECT, offsetof(struct Camera, pos), true, LOT_VEC3F },
+ { "unusedVec1", LVT_COBJECT, offsetof(struct Camera, unusedVec1), true, LOT_VEC3F },
+ { "yaw", LVT_S16, offsetof(struct Camera, yaw), false, LOT_NONE },
};
#define LUA_CHAIN_SEGMENT_FIELD_COUNT 6
@@ -1240,41 +1243,46 @@ static struct LuaObjectField sInstantWarpFields[LUA_INSTANT_WARP_FIELD_COUNT] =
{ "id", LVT_U8, offsetof(struct InstantWarp, id), false, LOT_NONE },
};
-#define LUA_LAKITU_STATE_FIELD_COUNT 33
+#define LUA_LAKITU_STATE_FIELD_COUNT 38
static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = {
- { "curFocus", LVT_COBJECT, offsetof(struct LakituState, curFocus), true, LOT_VEC3F },
- { "curPos", LVT_COBJECT, offsetof(struct LakituState, curPos), true, LOT_VEC3F },
- { "defMode", LVT_U8, offsetof(struct LakituState, defMode), false, LOT_NONE },
- { "focHSpeed", LVT_F32, offsetof(struct LakituState, focHSpeed), false, LOT_NONE },
- { "focVSpeed", LVT_F32, offsetof(struct LakituState, focVSpeed), false, LOT_NONE },
- { "focus", LVT_COBJECT, offsetof(struct LakituState, focus), true, LOT_VEC3F },
- { "focusDistance", LVT_F32, offsetof(struct LakituState, focusDistance), false, LOT_NONE },
- { "goalFocus", LVT_COBJECT, offsetof(struct LakituState, goalFocus), true, LOT_VEC3F },
- { "goalPos", LVT_COBJECT, offsetof(struct LakituState, goalPos), true, LOT_VEC3F },
- { "keyDanceRoll", LVT_S16, offsetof(struct LakituState, keyDanceRoll), false, LOT_NONE },
- { "lastFrameAction", LVT_U32, offsetof(struct LakituState, lastFrameAction), false, LOT_NONE },
- { "mode", LVT_U8, offsetof(struct LakituState, mode), false, LOT_NONE },
- { "nextYaw", LVT_S16, offsetof(struct LakituState, nextYaw), false, LOT_NONE },
- { "oldPitch", LVT_S16, offsetof(struct LakituState, oldPitch), false, LOT_NONE },
- { "oldRoll", LVT_S16, offsetof(struct LakituState, oldRoll), false, LOT_NONE },
- { "oldYaw", LVT_S16, offsetof(struct LakituState, oldYaw), false, LOT_NONE },
- { "pos", LVT_COBJECT, offsetof(struct LakituState, pos), true, LOT_VEC3F },
- { "posHSpeed", LVT_F32, offsetof(struct LakituState, posHSpeed), false, LOT_NONE },
- { "posVSpeed", LVT_F32, offsetof(struct LakituState, posVSpeed), false, LOT_NONE },
- { "roll", LVT_S16, offsetof(struct LakituState, roll), false, LOT_NONE },
- { "shakeMagnitude", LVT_COBJECT, offsetof(struct LakituState, shakeMagnitude), true, LOT_VEC3S },
- { "shakePitchDecay", LVT_S16, offsetof(struct LakituState, shakePitchDecay), false, LOT_NONE },
- { "shakePitchPhase", LVT_S16, offsetof(struct LakituState, shakePitchPhase), false, LOT_NONE },
- { "shakePitchVel", LVT_S16, offsetof(struct LakituState, shakePitchVel), false, LOT_NONE },
- { "shakeRollDecay", LVT_S16, offsetof(struct LakituState, shakeRollDecay), false, LOT_NONE },
- { "shakeRollPhase", LVT_S16, offsetof(struct LakituState, shakeRollPhase), false, LOT_NONE },
- { "shakeRollVel", LVT_S16, offsetof(struct LakituState, shakeRollVel), false, LOT_NONE },
- { "shakeYawDecay", LVT_S16, offsetof(struct LakituState, shakeYawDecay), false, LOT_NONE },
- { "shakeYawPhase", LVT_S16, offsetof(struct LakituState, shakeYawPhase), false, LOT_NONE },
- { "shakeYawVel", LVT_S16, offsetof(struct LakituState, shakeYawVel), false, LOT_NONE },
- { "skipCameraInterpolationTimestamp", LVT_U32, offsetof(struct LakituState, skipCameraInterpolationTimestamp), false, LOT_NONE },
- { "unused", LVT_S16, offsetof(struct LakituState, unused), false, LOT_NONE },
- { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
+ { "curFocus", LVT_COBJECT, offsetof(struct LakituState, curFocus), true, LOT_VEC3F },
+ { "curPos", LVT_COBJECT, offsetof(struct LakituState, curPos), true, LOT_VEC3F },
+ { "defMode", LVT_U8, offsetof(struct LakituState, defMode), false, LOT_NONE },
+ { "filler30", LVT_U8, offsetof(struct LakituState, filler30), false, LOT_NONE, 12, sizeof(u8) },
+ { "filler3E", LVT_U8, offsetof(struct LakituState, filler3E), false, LOT_NONE, 10, sizeof(u8) },
+ { "filler72", LVT_U8, offsetof(struct LakituState, filler72), false, LOT_NONE, 8, sizeof(u8) },
+ { "focHSpeed", LVT_F32, offsetof(struct LakituState, focHSpeed), false, LOT_NONE },
+ { "focVSpeed", LVT_F32, offsetof(struct LakituState, focVSpeed), false, LOT_NONE },
+ { "focus", LVT_COBJECT, offsetof(struct LakituState, focus), true, LOT_VEC3F },
+ { "focusDistance", LVT_F32, offsetof(struct LakituState, focusDistance), false, LOT_NONE },
+ { "goalFocus", LVT_COBJECT, offsetof(struct LakituState, goalFocus), true, LOT_VEC3F },
+ { "goalPos", LVT_COBJECT, offsetof(struct LakituState, goalPos), true, LOT_VEC3F },
+ { "keyDanceRoll", LVT_S16, offsetof(struct LakituState, keyDanceRoll), false, LOT_NONE },
+ { "lastFrameAction", LVT_U32, offsetof(struct LakituState, lastFrameAction), false, LOT_NONE },
+ { "mode", LVT_U8, offsetof(struct LakituState, mode), false, LOT_NONE },
+ { "nextYaw", LVT_S16, offsetof(struct LakituState, nextYaw), false, LOT_NONE },
+ { "oldPitch", LVT_S16, offsetof(struct LakituState, oldPitch), false, LOT_NONE },
+ { "oldRoll", LVT_S16, offsetof(struct LakituState, oldRoll), false, LOT_NONE },
+ { "oldYaw", LVT_S16, offsetof(struct LakituState, oldYaw), false, LOT_NONE },
+ { "pos", LVT_COBJECT, offsetof(struct LakituState, pos), true, LOT_VEC3F },
+ { "posHSpeed", LVT_F32, offsetof(struct LakituState, posHSpeed), false, LOT_NONE },
+ { "posVSpeed", LVT_F32, offsetof(struct LakituState, posVSpeed), false, LOT_NONE },
+ { "roll", LVT_S16, offsetof(struct LakituState, roll), false, LOT_NONE },
+ { "shakeMagnitude", LVT_COBJECT, offsetof(struct LakituState, shakeMagnitude), true, LOT_VEC3S },
+ { "shakePitchDecay", LVT_S16, offsetof(struct LakituState, shakePitchDecay), false, LOT_NONE },
+ { "shakePitchPhase", LVT_S16, offsetof(struct LakituState, shakePitchPhase), false, LOT_NONE },
+ { "shakePitchVel", LVT_S16, offsetof(struct LakituState, shakePitchVel), false, LOT_NONE },
+ { "shakeRollDecay", LVT_S16, offsetof(struct LakituState, shakeRollDecay), false, LOT_NONE },
+ { "shakeRollPhase", LVT_S16, offsetof(struct LakituState, shakeRollPhase), false, LOT_NONE },
+ { "shakeRollVel", LVT_S16, offsetof(struct LakituState, shakeRollVel), false, LOT_NONE },
+ { "shakeYawDecay", LVT_S16, offsetof(struct LakituState, shakeYawDecay), false, LOT_NONE },
+ { "shakeYawPhase", LVT_S16, offsetof(struct LakituState, shakeYawPhase), false, LOT_NONE },
+ { "shakeYawVel", LVT_S16, offsetof(struct LakituState, shakeYawVel), false, LOT_NONE },
+ { "skipCameraInterpolationTimestamp", LVT_U32, offsetof(struct LakituState, skipCameraInterpolationTimestamp), false, LOT_NONE },
+ { "unused", LVT_S16, offsetof(struct LakituState, unused), false, LOT_NONE },
+ { "unusedVec1", LVT_COBJECT, offsetof(struct LakituState, unusedVec1), true, LOT_VEC3F },
+ { "unusedVec2", LVT_COBJECT, offsetof(struct LakituState, unusedVec2), true, LOT_VEC3S },
+ { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
};
#define LUA_LEVEL_VALUES_FIELD_COUNT 56
@@ -1589,7 +1597,7 @@ static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT
{ "type", LVT_U8, offsetof(struct NetworkPlayer, type), true, LOT_NONE },
};
-#define LUA_OBJECT_FIELD_COUNT 762
+#define LUA_OBJECT_FIELD_COUNT 763
static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = {
{ "activeFlags", LVT_S16, offsetof(struct Object, activeFlags), false, LOT_NONE },
{ "allowRemoteInteractions", LVT_U8, offsetof(struct Object, allowRemoteInteractions), false, LOT_NONE },
@@ -1785,6 +1793,7 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = {
{ "oCloudCenterY", LVT_F32, offsetof(struct Object, oCloudCenterY), false, LOT_NONE },
{ "oCloudFwooshMovementRadius", LVT_S16, offsetof(struct Object, oCloudFwooshMovementRadius), false, LOT_NONE },
{ "oCloudGrowSpeed", LVT_F32, offsetof(struct Object, oCloudGrowSpeed), false, LOT_NONE },
+ { "oCoinBaseYVel", LVT_F32, offsetof(struct Object, oCoinBaseYVel), false, LOT_NONE },
{ "oCoinUnk110", LVT_F32, offsetof(struct Object, oCoinUnk110), false, LOT_NONE },
#ifndef VERSION_JP
{ "oCoinUnk1B0", LVT_S32, offsetof(struct Object, oCoinUnk1B0), false, LOT_NONE },
@@ -2510,7 +2519,7 @@ static struct LuaObjectField sServerSettingsFields[LUA_SERVER_SETTINGS_FIELD_COU
{ "voiceChat", LVT_U8, offsetof(struct ServerSettings, voiceChat), false, LOT_NONE },
};
-#define LUA_SPAWN_INFO_FIELD_COUNT 7
+#define LUA_SPAWN_INFO_FIELD_COUNT 8
static struct LuaObjectField sSpawnInfoFields[LUA_SPAWN_INFO_FIELD_COUNT] = {
{ "activeAreaIndex", LVT_S8, offsetof(struct SpawnInfo, activeAreaIndex), false, LOT_NONE },
{ "areaIndex", LVT_S8, offsetof(struct SpawnInfo, areaIndex), false, LOT_NONE },
@@ -2520,6 +2529,7 @@ static struct LuaObjectField sSpawnInfoFields[LUA_SPAWN_INFO_FIELD_COUNT] = {
{ "startAngle", LVT_COBJECT, offsetof(struct SpawnInfo, startAngle), true, LOT_VEC3S },
{ "startPos", LVT_COBJECT, offsetof(struct SpawnInfo, startPos), true, LOT_VEC3S },
{ "syncID", LVT_U32, offsetof(struct SpawnInfo, syncID), true, LOT_NONE },
+ { "unk18", LVT_COBJECT_P, offsetof(struct SpawnInfo, unk18), true, LOT_GRAPHNODE },
};
#define LUA_SPAWN_PARTICLES_INFO_FIELD_COUNT 12
@@ -2626,6 +2636,13 @@ static struct LuaObjectField sVoicePlayerFields[LUA_VOICE_PLAYER_FIELD_COUNT] =
{ "volume", LVT_U32, offsetof(struct VoicePlayer, volume), false, LOT_NONE },
};
+#define LUA_VOICE_PLAYER_INTERNAL_FIELD_COUNT 1
+static struct LuaObjectField sVoicePlayerInternalFields[LUA_VOICE_PLAYER_INTERNAL_FIELD_COUNT] = {
+ { "buffer", LVT_COBJECT, offsetof(struct VoicePlayerInternal, buffer), true, LOT_VOICEBUFFER },
+// { "decoder", LVT_???, offsetof(struct VoicePlayerInternal, decoder), false, LOT_??? }, <--- UNIMPLEMENTED
+// { "encoder", LVT_???, offsetof(struct VoicePlayerInternal, encoder), false, LOT_??? }, <--- UNIMPLEMENTED
+};
+
#define LUA_VTX_FIELD_COUNT 13
static struct LuaObjectField sVtxFields[LUA_VTX_FIELD_COUNT] = {
{ "a", LVT_U8, offsetof(Vtx_L, a), false, LOT_NONE },
@@ -2776,6 +2793,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
{ LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT },
{ LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT },
{ LOT_VOICEPLAYER, sVoicePlayerFields, LUA_VOICE_PLAYER_FIELD_COUNT },
+ { LOT_VOICEPLAYERINTERNAL, sVoicePlayerInternalFields, LUA_VOICE_PLAYER_INTERNAL_FIELD_COUNT },
{ LOT_VTX, sVtxFields, LUA_VTX_FIELD_COUNT },
{ LOT_WALLCOLLISIONDATA, sWallCollisionDataFields, LUA_WALL_COLLISION_DATA_FIELD_COUNT },
{ LOT_WARPNODE, sWarpNodeFields, LUA_WARP_NODE_FIELD_COUNT },
@@ -2883,6 +2901,7 @@ const char *sLuaLotNames[] = {
[LOT_SURFACE] = "Surface",
[LOT_TEXTUREINFO] = "TextureInfo",
[LOT_VOICEPLAYER] = "VoicePlayer",
+ [LOT_VOICEPLAYERINTERNAL] = "VoicePlayerInternal",
[LOT_VTX] = "Vtx",
[LOT_WALLCOLLISIONDATA] = "WallCollisionData",
[LOT_WARPNODE] = "WarpNode",
diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h
index 1998d39f1..f6a2c3edf 100644
--- a/src/pc/lua/smlua_cobject_autogen.h
+++ b/src/pc/lua/smlua_cobject_autogen.h
@@ -106,6 +106,7 @@ enum LuaObjectAutogenType {
LOT_SURFACE,
LOT_TEXTUREINFO,
LOT_VOICEPLAYER,
+ LOT_VOICEPLAYERINTERNAL,
LOT_VTX,
LOT_WALLCOLLISIONDATA,
LOT_WARPNODE,
diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c
index 3ca105743..b809075ff 100644
--- a/src/pc/lua/smlua_constants_autogen.c
+++ b/src/pc/lua/smlua_constants_autogen.c
@@ -70,69 +70,6 @@ const char gSmluaConstants[] = ""
"SOUND_STATUS_WAITING\n"
")\n"
"end\n"
-"-------------\n"
-"-- courses --\n"
-"-------------\n"
-"--- @type integer\n"
-"COURSE_NONE = 0\n"
-"--- @type integer\n"
-"COURSE_BOB = 1\n"
-"--- @type integer\n"
-"COURSE_WF = 2\n"
-"--- @type integer\n"
-"COURSE_JRB = 3\n"
-"--- @type integer\n"
-"COURSE_CCM = 4\n"
-"--- @type integer\n"
-"COURSE_BBH = 5\n"
-"--- @type integer\n"
-"COURSE_HMC = 6\n"
-"--- @type integer\n"
-"COURSE_LLL = 7\n"
-"--- @type integer\n"
-"COURSE_SSL = 8\n"
-"--- @type integer\n"
-"COURSE_DDD = 9\n"
-"--- @type integer\n"
-"COURSE_SL = 10\n"
-"--- @type integer\n"
-"COURSE_WDW = 11\n"
-"--- @type integer\n"
-"COURSE_TTM = 12\n"
-"--- @type integer\n"
-"COURSE_THI = 13\n"
-"--- @type integer\n"
-"COURSE_TTC = 14\n"
-"--- @type integer\n"
-"COURSE_RR = 15\n"
-"--- @type integer\n"
-"COURSE_BITDW = 16\n"
-"--- @type integer\n"
-"COURSE_BITFS = 17\n"
-"--- @type integer\n"
-"COURSE_BITS = 18\n"
-"--- @type integer\n"
-"COURSE_PSS = 19\n"
-"--- @type integer\n"
-"COURSE_COTMC = 20\n"
-"--- @type integer\n"
-"COURSE_TOTWC = 21\n"
-"--- @type integer\n"
-"COURSE_VCUTM = 22\n"
-"--- @type integer\n"
-"COURSE_WMOTR = 23\n"
-"--- @type integer\n"
-"COURSE_SA = 24\n"
-"--- @type integer\n"
-"COURSE_CAKE_END = 25\n"
-"--- @type integer\n"
-"COURSE_END = 26\n"
-"--- @type integer\n"
-"COURSE_MAX = 25\n"
-"--- @type integer\n"
-"COURSE_COUNT = 25\n"
-"--- @type integer\n"
-"COURSE_MIN = 1\n"
"------------------------------\n"
"-- player palette functions --\n"
"------------------------------\n"
@@ -160,14 +97,10 @@ const char gSmluaConstants[] = ""
"}\n"
"return color\n"
"end\n"
-"--------------------------\n"
-"-- local math functions --\n"
-"--------------------------\n"
"local __math_min, __math_max, __math_sqrt, __math_floor, __math_ceil, __math_cos, __math_sin, __math_pi = math.min, math.max, math.sqrt, math.floor, math.ceil, math.cos, math.sin, math.pi\n"
"------------\n"
"-- tweens --\n"
"------------\n"
-"-- Unrelated to SM64, but these are for `math.tween`\n"
"---@param x number\n"
"---@return number\n"
"IN_SINE = function (x) return 1 - __math_cos((x * __math_pi) / 2) end\n"
@@ -473,6 +406,14 @@ const char gSmluaConstants[] = ""
"rom_hack_cam_set_collisions = camera_romhack_set_collisions\n"
"camera_romhack_allow_centering = camera_romhack_allow_switchable\n"
"camera_romhack_get_allow_centering = camera_romhack_get_allow_switchable\n"
+"bhv_star_door_loop_2 = bhv_star_door_loop_update_render_state\n"
+"absf_2 = math.abs\n"
+"cur_obj_enable_rendering_2 = cur_obj_enable_rendering\n"
+"cur_obj_can_mario_activate_textbox_2 = cur_obj_can_mario_activate_textbox\n"
+"reset_rumble_timers_2 = reset_rumble_timers_vibrate\n"
+"cur_obj_play_sound_1 = cur_obj_play_sound_if_visible\n"
+"cur_obj_play_sound_2 = cur_obj_play_sound_and_rumble_if_visible\n"
+"bit_shift_left = function (shift) return math.u8(1 << shift) end\n"
"--------------------\n"
"-- Math functions --\n"
"--------------------\n"
@@ -1315,6 +1256,36 @@ const char gSmluaConstants[] = ""
"L_MOUSE_BUTTON=MOUSE_BUTTON_1\n"
"M_MOUSE_BUTTON=MOUSE_BUTTON_2\n"
"R_MOUSE_BUTTON=MOUSE_BUTTON_3\n"
+"COURSE_NONE=0\n"
+"COURSE_BOB=1\n"
+"COURSE_WF=2\n"
+"COURSE_JRB=3\n"
+"COURSE_CCM=4\n"
+"COURSE_BBH=5\n"
+"COURSE_HMC=6\n"
+"COURSE_LLL=7\n"
+"COURSE_SSL=8\n"
+"COURSE_DDD=9\n"
+"COURSE_SL=10\n"
+"COURSE_WDW=11\n"
+"COURSE_TTM=12\n"
+"COURSE_THI=13\n"
+"COURSE_TTC=14\n"
+"COURSE_RR=15\n"
+"COURSE_BITDW=16\n"
+"COURSE_BITFS=17\n"
+"COURSE_BITS=18\n"
+"COURSE_PSS=19\n"
+"COURSE_COTMC=20\n"
+"COURSE_TOTWC=21\n"
+"COURSE_VCUTM=22\n"
+"COURSE_WMOTR=23\n"
+"COURSE_SA=24\n"
+"COURSE_CAKE_END=25\n"
+"COURSE_END=26\n"
+"COURSE_COUNT=COURSE_END - 1\n"
+"COURSE_MAX=COURSE_COUNT\n"
+"COURSE_MIN=1\n"
"DIALOG_NONE=-1\n"
"DIALOG_000=0\n"
"DIALOG_001=1\n"
@@ -2485,6 +2456,9 @@ const char gSmluaConstants[] = ""
"BOBOMB_ACT_EXPLODE=3\n"
"BOBOMB_ACT_LAVA_DEATH=100\n"
"BOBOMB_ACT_DEATH_PLANE_DEATH=101\n"
+"COIN_TYPE_NONE=0\n"
+"COIN_TYPE_YELLOW=1\n"
+"COIN_TYPE_BLUE=2\n"
"HIDDEN_BLUE_COIN_ACT_INACTIVE=0\n"
"HIDDEN_BLUE_COIN_ACT_WAITING=1\n"
"HIDDEN_BLUE_COIN_ACT_ACTIVE=2\n"
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index e4a626fd7..0e62cff06 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -694,12 +694,12 @@ int smlua_func_check_if_moving_over_floor(lua_State* L) {
return 0;
}
- f32 a0 = smlua_to_number(L, 1);
+ f32 maxDistToFloor = smlua_to_number(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "check_if_moving_over_floor"); return 0; }
- f32 a1 = smlua_to_number(L, 2);
+ f32 distance = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "check_if_moving_over_floor"); return 0; }
- lua_pushinteger(L, check_if_moving_over_floor(a0, a1));
+ lua_pushinteger(L, check_if_moving_over_floor(maxDistToFloor, distance));
return 1;
}
@@ -816,18 +816,18 @@ int smlua_func_cur_obj_spawn_strong_wind_particles(lua_State* L) {
return 1;
}
-int smlua_func_bhv_star_door_loop_2(lua_State* L) {
+int smlua_func_bhv_star_door_loop_update_render_state(lua_State* L) {
if (!gCurrentObject) { return 0; }
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "bhv_star_door_loop_2", 0, top);
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "bhv_star_door_loop_update_render_state", 0, top);
return 0;
}
- bhv_star_door_loop_2();
+ bhv_star_door_loop_update_render_state();
return 1;
}
@@ -1385,14 +1385,14 @@ int smlua_func_common_anchor_mario_behavior(lua_State* L) {
return 0;
}
- f32 sp28 = smlua_to_number(L, 1);
+ f32 forwardVel = smlua_to_number(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "common_anchor_mario_behavior"); return 0; }
- f32 sp2C = smlua_to_number(L, 2);
+ f32 upwardsVel = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "common_anchor_mario_behavior"); return 0; }
- s32 sp30 = smlua_to_integer(L, 3);
+ s32 interactStatusFlags = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "common_anchor_mario_behavior"); return 0; }
- common_anchor_mario_behavior(sp28, sp2C, sp30);
+ common_anchor_mario_behavior(forwardVel, upwardsVel, interactStatusFlags);
return 1;
}
@@ -23756,24 +23756,6 @@ int smlua_func_set_yoshi_as_not_dead(lua_State* L) {
return 1;
}
-int smlua_func_absf_2(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", "absf_2", 1, top);
- return 0;
- }
-
- f32 f = smlua_to_number(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "absf_2"); return 0; }
-
- extern f32 absf_2(f32 f);
- lua_pushnumber(L, absf_2(f));
-
- return 1;
-}
-
int smlua_func_obj_find_wall(lua_State* L) {
if (L == NULL) { return 0; }
@@ -25510,14 +25492,14 @@ int smlua_func_obj_update_pos_from_parent_transformation(lua_State* L) {
}
- Mat4 a0;
- smlua_get_mat4(a0, 1);
+ Mat4 mtx;
+ smlua_get_mat4(mtx, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_update_pos_from_parent_transformation"); return 0; }
- struct Object* a1 = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT);
+ struct Object* obj = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_update_pos_from_parent_transformation"); return 0; }
- extern void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1);
- obj_update_pos_from_parent_transformation(a0, a1);
+ extern void obj_update_pos_from_parent_transformation(Mat4 mtx, struct Object *obj);
+ obj_update_pos_from_parent_transformation(mtx, obj);
return 1;
}
@@ -25560,22 +25542,22 @@ int smlua_func_create_transformation_from_matrices(lua_State* L) {
}
- Mat4 a0;
- smlua_get_mat4(a0, 1);
+ Mat4 dest;
+ smlua_get_mat4(dest, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "create_transformation_from_matrices"); return 0; }
- Mat4 a1;
- smlua_get_mat4(a1, 2);
+ Mat4 src1;
+ smlua_get_mat4(src1, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "create_transformation_from_matrices"); return 0; }
- Mat4 a2;
- smlua_get_mat4(a2, 3);
+ Mat4 src2;
+ smlua_get_mat4(src2, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "create_transformation_from_matrices"); return 0; }
- extern void create_transformation_from_matrices(VEC_OUT Mat4 a0, Mat4 a1, Mat4 a2);
- create_transformation_from_matrices(a0, a1, a2);
+ extern void create_transformation_from_matrices(VEC_OUT Mat4 dest, Mat4 src1, Mat4 src2);
+ create_transformation_from_matrices(dest, src1, src2);
- smlua_push_mat4(a0, 1);
+ smlua_push_mat4(dest, 1);
return 1;
}
@@ -26631,22 +26613,6 @@ int smlua_func_cur_obj_set_pos_relative_to_parent(lua_State* L) {
return 1;
}
-int smlua_func_cur_obj_enable_rendering_2(lua_State* L) {
- if (L == NULL) { return 0; }
-
- int top = lua_gettop(L);
- if (top != 0) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "cur_obj_enable_rendering_2", 0, top);
- return 0;
- }
-
-
- extern void cur_obj_enable_rendering_2(void);
- cur_obj_enable_rendering_2();
-
- return 1;
-}
-
int smlua_func_cur_obj_unused_init_on_floor(lua_State* L) {
if (L == NULL) { return 0; }
@@ -27084,13 +27050,13 @@ int smlua_func_cur_obj_set_y_vel_and_animation(lua_State* L) {
return 0;
}
- f32 sp18 = smlua_to_number(L, 1);
+ f32 velY = smlua_to_number(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_set_y_vel_and_animation"); return 0; }
- s32 sp1C = smlua_to_integer(L, 2);
+ s32 animIndex = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "cur_obj_set_y_vel_and_animation"); return 0; }
- extern void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);
- cur_obj_set_y_vel_and_animation(sp18, sp1C);
+ extern void cur_obj_set_y_vel_and_animation(f32 velY, s32 animIndex);
+ cur_obj_set_y_vel_and_animation(velY, animIndex);
return 1;
}
@@ -27104,13 +27070,13 @@ int smlua_func_cur_obj_unrender_and_reset_state(lua_State* L) {
return 0;
}
- s32 sp18 = smlua_to_integer(L, 1);
+ s32 animIndex = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_unrender_and_reset_state"); return 0; }
- s32 sp1C = smlua_to_integer(L, 2);
+ s32 action = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "cur_obj_unrender_and_reset_state"); return 0; }
- extern void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C);
- cur_obj_unrender_and_reset_state(sp18, sp1C);
+ extern void cur_obj_unrender_and_reset_state(s32 animIndex, s32 action);
+ cur_obj_unrender_and_reset_state(animIndex, action);
return 1;
}
@@ -27843,15 +27809,15 @@ int smlua_func_set_mario_interact_hoot_if_in_range(lua_State* L) {
return 0;
}
- s32 sp0 = smlua_to_integer(L, 1);
+ s32 unused1 = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_mario_interact_hoot_if_in_range"); return 0; }
- s32 sp4 = smlua_to_integer(L, 2);
+ s32 unused2 = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_mario_interact_hoot_if_in_range"); return 0; }
- f32 sp8 = smlua_to_number(L, 3);
+ f32 maxDistanceToMario = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "set_mario_interact_hoot_if_in_range"); return 0; }
- extern void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8);
- set_mario_interact_hoot_if_in_range(sp0, sp4, sp8);
+ extern void set_mario_interact_hoot_if_in_range(UNUSED s32 unused1, UNUSED s32 unused2, f32 maxDistanceToMario);
+ set_mario_interact_hoot_if_in_range(unused1, unused2, maxDistanceToMario);
return 1;
}
@@ -28005,7 +27971,7 @@ int smlua_func_obj_spawn_loot_coins(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_spawn_loot_coins"); return 0; }
s32 numCoins = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_spawn_loot_coins"); return 0; }
- f32 sp30 = smlua_to_number(L, 3);
+ f32 baseYVel = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "obj_spawn_loot_coins"); return 0; }
BehaviorScript * coinBehavior = (BehaviorScript *)smlua_to_cpointer(L, 4, LVT_BEHAVIORSCRIPT_P);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "obj_spawn_loot_coins"); return 0; }
@@ -28014,8 +27980,8 @@ int smlua_func_obj_spawn_loot_coins(lua_State* L) {
s16 model = smlua_to_integer(L, 6);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "obj_spawn_loot_coins"); return 0; }
- extern void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model);
- obj_spawn_loot_coins(obj, numCoins, sp30, coinBehavior, posJitter, model);
+ extern void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 baseYVel, const BehaviorScript *coinBehavior, s16 posJitter, s16 model);
+ obj_spawn_loot_coins(obj, numCoins, baseYVel, coinBehavior, posJitter, model);
return 1;
}
@@ -28033,13 +27999,13 @@ int smlua_func_obj_spawn_loot_blue_coins(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_spawn_loot_blue_coins"); return 0; }
s32 numCoins = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_spawn_loot_blue_coins"); return 0; }
- f32 sp28 = smlua_to_number(L, 3);
+ f32 baseYVel = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "obj_spawn_loot_blue_coins"); return 0; }
s16 posJitter = smlua_to_integer(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "obj_spawn_loot_blue_coins"); return 0; }
- extern void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter);
- obj_spawn_loot_blue_coins(obj, numCoins, sp28, posJitter);
+ extern void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 baseYVel, s16 posJitter);
+ obj_spawn_loot_blue_coins(obj, numCoins, baseYVel, posJitter);
return 1;
}
@@ -28057,11 +28023,11 @@ int smlua_func_obj_spawn_loot_yellow_coins(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_spawn_loot_yellow_coins"); return 0; }
s32 numCoins = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_spawn_loot_yellow_coins"); return 0; }
- f32 sp28 = smlua_to_number(L, 3);
+ f32 baseYVel = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "obj_spawn_loot_yellow_coins"); return 0; }
- extern void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28);
- obj_spawn_loot_yellow_coins(obj, numCoins, sp28);
+ extern void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 baseYVel);
+ obj_spawn_loot_yellow_coins(obj, numCoins, baseYVel);
return 1;
}
@@ -28599,11 +28565,11 @@ int smlua_func_obj_build_vel_from_transform(lua_State* L) {
return 0;
}
- struct Object* a0 = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
+ struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_build_vel_from_transform"); return 0; }
- extern void obj_build_vel_from_transform(struct Object *a0);
- obj_build_vel_from_transform(a0);
+ extern void obj_build_vel_from_transform(struct Object *obj);
+ obj_build_vel_from_transform(obj);
return 1;
}
@@ -28840,26 +28806,6 @@ int smlua_func_bhv_dust_smoke_loop(lua_State* L) {
return 1;
}
-int smlua_func_stub_obj_helpers_3(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", "stub_obj_helpers_3", 2, top);
- return 0;
- }
-
- s32 sp0 = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stub_obj_helpers_3"); return 0; }
- s32 sp4 = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "stub_obj_helpers_3"); return 0; }
-
- extern void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4);
- stub_obj_helpers_3(sp0, sp4);
-
- return 1;
-}
-
int smlua_func_cur_obj_scale_over_time(lua_State* L) {
if (L == NULL) { return 0; }
@@ -28869,17 +28815,17 @@ int smlua_func_cur_obj_scale_over_time(lua_State* L) {
return 0;
}
- s32 a0 = smlua_to_integer(L, 1);
+ s32 axes = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_scale_over_time"); return 0; }
- s32 a1 = smlua_to_integer(L, 2);
+ s32 duration = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "cur_obj_scale_over_time"); return 0; }
- f32 sp10 = smlua_to_number(L, 3);
+ f32 minScale = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "cur_obj_scale_over_time"); return 0; }
- f32 sp14 = smlua_to_number(L, 4);
+ f32 maxScale = smlua_to_number(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "cur_obj_scale_over_time"); return 0; }
- extern void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14);
- cur_obj_scale_over_time(a0, a1, sp10, sp14);
+ extern void cur_obj_scale_over_time(s32 axes, s32 duration, f32 minScale, f32 maxScale);
+ cur_obj_scale_over_time(axes, duration, minScale, maxScale);
return 1;
}
@@ -28900,22 +28846,6 @@ int smlua_func_cur_obj_set_pos_to_home_with_debug(lua_State* L) {
return 1;
}
-int smlua_func_stub_obj_helpers_4(lua_State* L) {
- if (L == NULL) { return 0; }
-
- int top = lua_gettop(L);
- if (top != 0) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "stub_obj_helpers_4", 0, top);
- return 0;
- }
-
-
- extern void stub_obj_helpers_4(void);
- stub_obj_helpers_4();
-
- return 1;
-}
-
int smlua_func_cur_obj_is_mario_on_platform(lua_State* L) {
if (L == NULL) { return 0; }
@@ -28977,11 +28907,11 @@ int smlua_func_cur_obj_move_up_and_down(lua_State* L) {
return 0;
}
- s32 a0 = smlua_to_integer(L, 1);
+ s32 index = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_move_up_and_down"); return 0; }
- extern s32 cur_obj_move_up_and_down(s32 a0);
- lua_pushinteger(L, cur_obj_move_up_and_down(a0));
+ extern s32 cur_obj_move_up_and_down(s32 index);
+ lua_pushinteger(L, cur_obj_move_up_and_down(index));
return 1;
}
@@ -28995,13 +28925,13 @@ int smlua_func_spawn_star_with_no_lvl_exit(lua_State* L) {
return 0;
}
- s32 sp20 = smlua_to_integer(L, 1);
+ s32 setHomeToMario = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "spawn_star_with_no_lvl_exit"); return 0; }
- s32 sp24 = smlua_to_integer(L, 2);
+ s32 unused = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "spawn_star_with_no_lvl_exit"); return 0; }
- extern struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24);
- smlua_push_object(L, LOT_OBJECT, spawn_star_with_no_lvl_exit(sp20, sp24), NULL);
+ extern struct Object *spawn_star_with_no_lvl_exit(s32 setHomeToMario, s32 unused);
+ smlua_push_object(L, LOT_OBJECT, spawn_star_with_no_lvl_exit(setHomeToMario, unused), NULL);
return 1;
}
@@ -29022,24 +28952,6 @@ int smlua_func_spawn_base_star_with_no_lvl_exit(lua_State* L) {
return 1;
}
-int smlua_func_bit_shift_left(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", "bit_shift_left", 1, top);
- return 0;
- }
-
- s32 a0 = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "bit_shift_left"); return 0; }
-
- extern s32 bit_shift_left(s32 a0);
- lua_pushinteger(L, bit_shift_left(a0));
-
- return 1;
-}
-
int smlua_func_cur_obj_mario_far_away(lua_State* L) {
if (L == NULL) { return 0; }
@@ -29157,13 +29069,13 @@ int smlua_func_obj_explode_and_spawn_coins(lua_State* L) {
return 0;
}
- f32 sp18 = smlua_to_number(L, 1);
+ f32 mistSize = smlua_to_number(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_explode_and_spawn_coins"); return 0; }
- s32 sp1C = smlua_to_integer(L, 2);
+ enum CoinType coinType = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_explode_and_spawn_coins"); return 0; }
- extern void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C);
- obj_explode_and_spawn_coins(sp18, sp1C);
+ extern void obj_explode_and_spawn_coins(f32 mistSize, enum CoinType coinType);
+ obj_explode_and_spawn_coins(mistSize, coinType);
return 1;
}
@@ -29348,8 +29260,8 @@ int smlua_func_cur_obj_can_mario_activate_textbox(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
- if (top != 4) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "cur_obj_can_mario_activate_textbox", 4, top);
+ if (top < 3 || top > 4) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "cur_obj_can_mario_activate_textbox", 3, 4, top);
return 0;
}
@@ -29359,33 +29271,14 @@ int smlua_func_cur_obj_can_mario_activate_textbox(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "cur_obj_can_mario_activate_textbox"); return 0; }
f32 height = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "cur_obj_can_mario_activate_textbox"); return 0; }
- s32 unused = smlua_to_integer(L, 4);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "cur_obj_can_mario_activate_textbox"); return 0; }
-
- extern s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused);
- lua_pushinteger(L, cur_obj_can_mario_activate_textbox(m, radius, height, unused));
-
- return 1;
-}
-
-int smlua_func_cur_obj_can_mario_activate_textbox_2(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", "cur_obj_can_mario_activate_textbox_2", 3, top);
- return 0;
+ s32 unused = (s32) 0;
+ if (top >= 4) {
+ unused = smlua_to_integer(L, 4);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "cur_obj_can_mario_activate_textbox"); return 0; }
}
- struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_can_mario_activate_textbox_2"); return 0; }
- f32 radius = smlua_to_number(L, 2);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "cur_obj_can_mario_activate_textbox_2"); return 0; }
- f32 height = smlua_to_number(L, 3);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "cur_obj_can_mario_activate_textbox_2"); return 0; }
-
- extern s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height);
- lua_pushinteger(L, cur_obj_can_mario_activate_textbox_2(m, radius, height));
+ extern s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, OPTIONAL UNUSED s32 unused);
+ lua_pushinteger(L, cur_obj_can_mario_activate_textbox(m, radius, height, unused));
return 1;
}
@@ -29835,12 +29728,12 @@ int smlua_func_queue_rumble_data(lua_State* L) {
return 0;
}
- s16 a0 = smlua_to_integer(L, 1);
+ s16 time = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "queue_rumble_data"); return 0; }
- s16 a1 = smlua_to_integer(L, 2);
+ s16 level = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "queue_rumble_data"); return 0; }
- queue_rumble_data(a0, a1);
+ queue_rumble_data(time, level);
return 1;
}
@@ -29856,12 +29749,12 @@ int smlua_func_queue_rumble_data_object(lua_State* L) {
struct Object* object = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "queue_rumble_data_object"); return 0; }
- s16 a0 = smlua_to_integer(L, 2);
+ s16 time = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "queue_rumble_data_object"); return 0; }
- s16 a1 = smlua_to_integer(L, 3);
+ s16 level = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "queue_rumble_data_object"); return 0; }
- queue_rumble_data_object(object, a0, a1);
+ queue_rumble_data_object(object, time, level);
return 1;
}
@@ -29877,12 +29770,44 @@ int smlua_func_queue_rumble_data_mario(lua_State* L) {
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "queue_rumble_data_mario"); return 0; }
- s16 a0 = smlua_to_integer(L, 2);
+ s16 time = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "queue_rumble_data_mario"); return 0; }
- s16 a1 = smlua_to_integer(L, 3);
+ s16 level = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "queue_rumble_data_mario"); return 0; }
- queue_rumble_data_mario(m, a0, a1);
+ queue_rumble_data_mario(m, time, level);
+
+ return 1;
+}
+
+int smlua_func_queue_rumble_decay(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", "queue_rumble_decay", 1, top);
+ return 0;
+ }
+
+ s16 decay = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "queue_rumble_decay"); return 0; }
+
+ queue_rumble_decay(decay);
+
+ return 1;
+}
+
+int smlua_func_is_rumble_finished_and_queue_empty(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 0) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "is_rumble_finished_and_queue_empty", 0, top);
+ return 0;
+ }
+
+
+ lua_pushinteger(L, is_rumble_finished_and_queue_empty());
return 1;
}
@@ -29904,21 +29829,51 @@ int smlua_func_reset_rumble_timers(lua_State* L) {
return 1;
}
-int smlua_func_reset_rumble_timers_2(lua_State* L) {
+int smlua_func_reset_rumble_timers_vibrate(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", "reset_rumble_timers_2", 2, top);
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "reset_rumble_timers_vibrate", 2, top);
return 0;
}
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "reset_rumble_timers_2"); return 0; }
- s32 a0 = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "reset_rumble_timers_2"); return 0; }
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "reset_rumble_timers_vibrate"); return 0; }
+ s32 level = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "reset_rumble_timers_vibrate"); return 0; }
- reset_rumble_timers_2(m, a0);
+ reset_rumble_timers_vibrate(m, level);
+
+ return 1;
+}
+
+int smlua_func_queue_rumble_submerged(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 0) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "queue_rumble_submerged", 0, top);
+ return 0;
+ }
+
+
+ queue_rumble_submerged();
+
+ return 1;
+}
+
+int smlua_func_cancel_rumble(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 0) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "cancel_rumble", 0, top);
+ return 0;
+ }
+
+
+ cancel_rumble();
return 1;
}
@@ -35014,8 +34969,8 @@ int smlua_func_spawn_sync_object(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
- if (top != 6) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "spawn_sync_object", 6, top);
+ if (top < 5 || top > 6) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "spawn_sync_object", 5, 6, top);
return 0;
}
@@ -35029,8 +34984,11 @@ int smlua_func_spawn_sync_object(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "spawn_sync_object"); return 0; }
f32 z = smlua_to_number(L, 5);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "spawn_sync_object"); return 0; }
- LuaFunction objSetupFunction = smlua_to_lua_function(L, 6);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_sync_object"); return 0; }
+ LuaFunction objSetupFunction = (LuaFunction) 0;
+ if (top >= 6) {
+ objSetupFunction = smlua_to_lua_function(L, 6);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_sync_object"); return 0; }
+ }
smlua_push_object(L, LOT_OBJECT, spawn_sync_object(behaviorId, modelId, x, y, z, objSetupFunction), NULL);
@@ -35041,8 +34999,8 @@ int smlua_func_spawn_non_sync_object(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
- if (top != 6) {
- LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "spawn_non_sync_object", 6, top);
+ if (top < 5 || top > 6) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "spawn_non_sync_object", 5, 6, top);
return 0;
}
@@ -35056,8 +35014,11 @@ int smlua_func_spawn_non_sync_object(lua_State* L) {
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "spawn_non_sync_object"); return 0; }
f32 z = smlua_to_number(L, 5);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "spawn_non_sync_object"); return 0; }
- LuaFunction objSetupFunction = smlua_to_lua_function(L, 6);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_non_sync_object"); return 0; }
+ LuaFunction objSetupFunction = (LuaFunction) 0;
+ if (top >= 6) {
+ objSetupFunction = smlua_to_lua_function(L, 6);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "spawn_non_sync_object"); return 0; }
+ }
smlua_push_object(L, LOT_OBJECT, spawn_non_sync_object(behaviorId, modelId, x, y, z, objSetupFunction), NULL);
@@ -36764,36 +36725,36 @@ int smlua_func_stop_cap_music(lua_State* L) {
// spawn_sound.h //
///////////////////
-int smlua_func_cur_obj_play_sound_1(lua_State* L) {
+int smlua_func_cur_obj_play_sound_if_visible(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", "cur_obj_play_sound_1", 1, top);
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "cur_obj_play_sound_if_visible", 1, top);
return 0;
}
s32 soundMagic = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_play_sound_1"); return 0; }
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_play_sound_if_visible"); return 0; }
- cur_obj_play_sound_1(soundMagic);
+ cur_obj_play_sound_if_visible(soundMagic);
return 1;
}
-int smlua_func_cur_obj_play_sound_2(lua_State* L) {
+int smlua_func_cur_obj_play_sound_and_rumble_if_visible(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", "cur_obj_play_sound_2", 1, top);
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "cur_obj_play_sound_and_rumble_if_visible", 1, top);
return 0;
}
s32 soundMagic = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_play_sound_2"); return 0; }
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "cur_obj_play_sound_and_rumble_if_visible"); return 0; }
- cur_obj_play_sound_2(soundMagic);
+ cur_obj_play_sound_and_rumble_if_visible(soundMagic);
return 1;
}
@@ -36815,40 +36776,6 @@ int smlua_func_create_sound_spawner(lua_State* L) {
return 1;
}
-int smlua_func_calc_dist_to_volume_range_1(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", "calc_dist_to_volume_range_1", 1, top);
- return 0;
- }
-
- f32 distance = smlua_to_number(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "calc_dist_to_volume_range_1"); return 0; }
-
- lua_pushinteger(L, calc_dist_to_volume_range_1(distance));
-
- return 1;
-}
-
-int smlua_func_calc_dist_to_volume_range_2(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", "calc_dist_to_volume_range_2", 1, top);
- return 0;
- }
-
- f32 distance = smlua_to_number(L, 1);
- if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "calc_dist_to_volume_range_2"); return 0; }
-
- lua_pushinteger(L, calc_dist_to_volume_range_2(distance));
-
- return 1;
-}
-
/////////////////////////
// surface_collision.h //
/////////////////////////
@@ -37526,7 +37453,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "play_penguin_walking_sound", smlua_func_play_penguin_walking_sound);
smlua_bind_function(L, "update_angle_from_move_flags", smlua_func_update_angle_from_move_flags);
smlua_bind_function(L, "cur_obj_spawn_strong_wind_particles", smlua_func_cur_obj_spawn_strong_wind_particles);
- smlua_bind_function(L, "bhv_star_door_loop_2", smlua_func_bhv_star_door_loop_2);
+ smlua_bind_function(L, "bhv_star_door_loop_update_render_state", smlua_func_bhv_star_door_loop_update_render_state);
smlua_bind_function(L, "bhv_cap_switch_loop", smlua_func_bhv_cap_switch_loop);
smlua_bind_function(L, "bhv_tiny_star_particles_init", smlua_func_bhv_tiny_star_particles_init);
smlua_bind_function(L, "bhv_grindel_thwomp_loop", smlua_func_bhv_grindel_thwomp_loop);
@@ -38856,7 +38783,6 @@ void smlua_bind_functions_autogen(void) {
// obj_behaviors.c
smlua_bind_function(L, "set_yoshi_as_not_dead", smlua_func_set_yoshi_as_not_dead);
- smlua_bind_function(L, "absf_2", smlua_func_absf_2);
smlua_bind_function(L, "obj_find_wall", smlua_func_obj_find_wall);
smlua_bind_function(L, "turn_obj_away_from_steep_floor", smlua_func_turn_obj_away_from_steep_floor);
smlua_bind_function(L, "obj_orient_graph", smlua_func_obj_orient_graph);
@@ -38997,7 +38923,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "cur_obj_hide", smlua_func_cur_obj_hide);
smlua_bind_function(L, "cur_obj_set_pos_relative", smlua_func_cur_obj_set_pos_relative);
smlua_bind_function(L, "cur_obj_set_pos_relative_to_parent", smlua_func_cur_obj_set_pos_relative_to_parent);
- smlua_bind_function(L, "cur_obj_enable_rendering_2", smlua_func_cur_obj_enable_rendering_2);
smlua_bind_function(L, "cur_obj_unused_init_on_floor", smlua_func_cur_obj_unused_init_on_floor);
smlua_bind_function(L, "obj_set_face_angle_to_move_angle", smlua_func_obj_set_face_angle_to_move_angle);
smlua_bind_function(L, "get_object_list_from_behavior", smlua_func_get_object_list_from_behavior);
@@ -39117,17 +39042,14 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "cur_obj_push_mario_away", smlua_func_cur_obj_push_mario_away);
smlua_bind_function(L, "cur_obj_push_mario_away_from_cylinder", smlua_func_cur_obj_push_mario_away_from_cylinder);
smlua_bind_function(L, "bhv_dust_smoke_loop", smlua_func_bhv_dust_smoke_loop);
- smlua_bind_function(L, "stub_obj_helpers_3", smlua_func_stub_obj_helpers_3);
smlua_bind_function(L, "cur_obj_scale_over_time", smlua_func_cur_obj_scale_over_time);
smlua_bind_function(L, "cur_obj_set_pos_to_home_with_debug", smlua_func_cur_obj_set_pos_to_home_with_debug);
- smlua_bind_function(L, "stub_obj_helpers_4", smlua_func_stub_obj_helpers_4);
smlua_bind_function(L, "cur_obj_is_mario_on_platform", smlua_func_cur_obj_is_mario_on_platform);
smlua_bind_function(L, "cur_obj_is_any_player_on_platform", smlua_func_cur_obj_is_any_player_on_platform);
smlua_bind_function(L, "cur_obj_shake_y_until", smlua_func_cur_obj_shake_y_until);
smlua_bind_function(L, "cur_obj_move_up_and_down", smlua_func_cur_obj_move_up_and_down);
smlua_bind_function(L, "spawn_star_with_no_lvl_exit", smlua_func_spawn_star_with_no_lvl_exit);
smlua_bind_function(L, "spawn_base_star_with_no_lvl_exit", smlua_func_spawn_base_star_with_no_lvl_exit);
- smlua_bind_function(L, "bit_shift_left", smlua_func_bit_shift_left);
smlua_bind_function(L, "cur_obj_mario_far_away", smlua_func_cur_obj_mario_far_away);
smlua_bind_function(L, "is_mario_moving_fast_or_in_air", smlua_func_is_mario_moving_fast_or_in_air);
smlua_bind_function(L, "is_item_in_array", smlua_func_is_item_in_array);
@@ -39146,7 +39068,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "set_time_stop_flags_if_alone", smlua_func_set_time_stop_flags_if_alone);
smlua_bind_function(L, "clear_time_stop_flags", smlua_func_clear_time_stop_flags);
smlua_bind_function(L, "cur_obj_can_mario_activate_textbox", smlua_func_cur_obj_can_mario_activate_textbox);
- smlua_bind_function(L, "cur_obj_can_mario_activate_textbox_2", smlua_func_cur_obj_can_mario_activate_textbox_2);
smlua_bind_function(L, "cur_obj_end_dialog", smlua_func_cur_obj_end_dialog);
smlua_bind_function(L, "cur_obj_has_model", smlua_func_cur_obj_has_model);
smlua_bind_function(L, "cur_obj_align_gfx_with_floor", smlua_func_cur_obj_align_gfx_with_floor);
@@ -39181,8 +39102,12 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "queue_rumble_data", smlua_func_queue_rumble_data);
smlua_bind_function(L, "queue_rumble_data_object", smlua_func_queue_rumble_data_object);
smlua_bind_function(L, "queue_rumble_data_mario", smlua_func_queue_rumble_data_mario);
+ smlua_bind_function(L, "queue_rumble_decay", smlua_func_queue_rumble_decay);
+ smlua_bind_function(L, "is_rumble_finished_and_queue_empty", smlua_func_is_rumble_finished_and_queue_empty);
smlua_bind_function(L, "reset_rumble_timers", smlua_func_reset_rumble_timers);
- smlua_bind_function(L, "reset_rumble_timers_2", smlua_func_reset_rumble_timers_2);
+ smlua_bind_function(L, "reset_rumble_timers_vibrate", smlua_func_reset_rumble_timers_vibrate);
+ smlua_bind_function(L, "queue_rumble_submerged", smlua_func_queue_rumble_submerged);
+ smlua_bind_function(L, "cancel_rumble", smlua_func_cancel_rumble);
// save_file.h
smlua_bind_function(L, "get_level_num_from_course_num", smlua_func_get_level_num_from_course_num);
@@ -39600,11 +39525,9 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "stop_cap_music", smlua_func_stop_cap_music);
// spawn_sound.h
- smlua_bind_function(L, "cur_obj_play_sound_1", smlua_func_cur_obj_play_sound_1);
- smlua_bind_function(L, "cur_obj_play_sound_2", smlua_func_cur_obj_play_sound_2);
+ smlua_bind_function(L, "cur_obj_play_sound_if_visible", smlua_func_cur_obj_play_sound_if_visible);
+ smlua_bind_function(L, "cur_obj_play_sound_and_rumble_if_visible", smlua_func_cur_obj_play_sound_and_rumble_if_visible);
smlua_bind_function(L, "create_sound_spawner", smlua_func_create_sound_spawner);
- smlua_bind_function(L, "calc_dist_to_volume_range_1", smlua_func_calc_dist_to_volume_range_1);
- smlua_bind_function(L, "calc_dist_to_volume_range_2", smlua_func_calc_dist_to_volume_range_2);
// surface_collision.h
smlua_bind_function(L, "find_wall_collisions", smlua_func_find_wall_collisions);
diff --git a/src/pc/lua/utils/smlua_obj_utils.c b/src/pc/lua/utils/smlua_obj_utils.c
index 3b0ad77cf..a5d9b1dc5 100644
--- a/src/pc/lua/utils/smlua_obj_utils.c
+++ b/src/pc/lua/utils/smlua_obj_utils.c
@@ -76,11 +76,11 @@ static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum Mod
return obj;
}
-struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
+struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction) {
return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true);
}
-struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
+struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction) {
return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false);
}
diff --git a/src/pc/lua/utils/smlua_obj_utils.h b/src/pc/lua/utils/smlua_obj_utils.h
index 9999e1990..744ab073c 100644
--- a/src/pc/lua/utils/smlua_obj_utils.h
+++ b/src/pc/lua/utils/smlua_obj_utils.h
@@ -9,12 +9,12 @@
Spawns a synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
You can change the fields of the object in `objSetupFunction`
|descriptionEnd| */
-struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
+struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);
/* |description|
Spawns a non-synchronized object at `x`, `y`, and `z` as a child object of the local Mario with his rotation.
You can change the fields of the object in `objSetupFunction`
|descriptionEnd| */
-struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
+struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, OPTIONAL LuaFunction objSetupFunction);
/* |description|Checks if an object has `behaviorId`|descriptionEnd| */
s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId);
diff --git a/src/pc/network/network.c b/src/pc/network/network.c
index 74c0d919d..7d69bc617 100644
--- a/src/pc/network/network.c
+++ b/src/pc/network/network.c
@@ -743,7 +743,8 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
mods_clear(&gRemoteMods);
smlua_shutdown();
extern s16 gChangeLevel;
- gChangeLevel = LEVEL_CASTLE_GROUNDS;
+ s16 menuLevel = get_menu_level();
+ gChangeLevel = menuLevel;
network_player_init();
gMarioStates[0].cap = 0;
gMarioStates[0].input = 0;
diff --git a/src/pc/pc_main.h b/src/pc/pc_main.h
index 7c6bbbe74..92969e4bc 100644
--- a/src/pc/pc_main.h
+++ b/src/pc/pc_main.h
@@ -40,7 +40,6 @@ extern u8 gLuaVolumeLevel;
extern u8 gLuaVolumeSfx;
extern u8 gLuaVolumeEnv;
-extern struct GfxWindowManagerAPI* wm_api;
void produce_one_dummy_frame(void (*callback)(), u8 clearColorR, u8 clearColorG, u8 clearColorB);
void game_deinit(void);
void game_exit(void);