diff --git a/Makefile b/Makefile index 3f0b5653a..7e942ece2 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ COOPNET ?= 1 # Enable docker build workarounds DOCKERBUILD ?= 0 # Sets your optimization level for building. -# A choose is chosen by default for you. +# A choice is made by default for you. OPT_LEVEL ?= -1 # Enable compiling with more debug info. DEBUG_INFO_LEVEL ?= 2 @@ -66,8 +66,6 @@ ifeq ($(shell arch),arm64) else MIN_MACOS_VERSION ?= 10.15 endif -# Homebrew Prefix -BREW_PREFIX ?= $(shell brew --prefix) # Make some small adjustments for handheld devices HANDHELD ?= 0 @@ -122,6 +120,10 @@ endif ifeq ($(HOST_OS),Darwin) OSX_BUILD := 1 + + ifndef BREW_PREFIX + BREW_PREFIX := $(shell brew --prefix) + endif endif # MXE overrides @@ -1327,9 +1329,6 @@ $(SOUND_BIN_DIR)/tbl_header: $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/samples_offsets.inc.c: $(SOUND_BIN_DIR)/sound_data.ctl @true -$(SOUND_BIN_DIR)/sequences_offsets.inc.c: $(SOUND_BIN_DIR)/sound_data.ctl - @true - $(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json $(SOUND_SEQUENCE_DIRS) $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH) @$(PRINT) "$(GREEN)Generating: $(BLUE)$@ $(NO_COL)\n" $(V)$(PYTHON) $(TOOLS_DIR)/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/sequences_header $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(C_DEFINES) $$(cat $(ENDIAN_BITWIDTH)) @@ -1340,6 +1339,9 @@ $(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin $(SOUND_BIN_DIR)/sequences_header: $(SOUND_BIN_DIR)/sequences.bin @true +$(SOUND_BIN_DIR)/sequences_offsets.inc.c: $(SOUND_BIN_DIR)/sequences.bin + @true + $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o $(call print,Converting to M64:,$<,$@) $(V)$(OBJCOPY) -j .rodata $< -O binary $@ diff --git a/README.md b/README.md index da70fe292..36ecd0822 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,6 @@ Interestingly enough though, the goal of the project has slowly evolved over tim ## Lua sm64coopdx is moddable via Lua, similar to Roblox and Garry's Mod's Lua APIs. To get started, click [here](docs/lua/lua.md) to see the Lua documentation. + +## Wiki +The wiki is made using GitHub's wiki feature, you can go to the wiki tab or click [here](https://github.com/coop-deluxe/sm64coopdx/wiki). diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index cc77a0e1d..593d36259 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -88,7 +88,7 @@ override_allowed_functions = { override_disallowed_functions = { "src/audio/external.h": [ " func_" ], - "src/engine/math_util.h": [ "atan2s", "atan2f", "vec3s_sub" ], + "src/engine/math_util.h": [ "atan2f", "vec3s_sub" ], "src/engine/surface_load.h": [ "alloc_surface_poools" ], "src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ], "src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ], @@ -114,7 +114,7 @@ override_disallowed_functions = { "src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ], "src/game/camera.h": [ "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline" ], "src/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room" ], - "src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown", "smlua_audio_custom_init", "smlua_audio_custom_deinit", "audio_sample_destroy_pending_copies", "audio_custom_update_volume" ], + "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/djui/djui_hud_utils.h": [ "djui_hud_render_texture", "djui_hud_render_texture_raw", "djui_hud_render_texture_tile", "djui_hud_render_texture_tile_raw" ], "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_reset_all" ], diff --git a/autogen/lua_constants/built-in.lua b/autogen/lua_constants/built-in.lua index 8cb619784..29266a674 100644 --- a/autogen/lua_constants/built-in.lua +++ b/autogen/lua_constants/built-in.lua @@ -1,77 +1,5 @@ math.randomseed(get_time()) - --------------- --- CObjects -- --------------- - -_CObjectPool = {} - -_CObject = { - __index = function (t,k) - return _get_field(t['_lot'], t['_pointer'], k, t) - end, - __newindex = function (t,k,v) - _set_field(t['_lot'], t['_pointer'], k, v, t) - end, - __tostring = function(t) - return 'CObject: ' .. t['_lot'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']' - end, - __eq = function (a, b) - return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil - end -} - -function _NewCObject(lot, pointer) - if _CObjectPool[lot] == nil then - _CObjectPool[lot] = {} - end - - if _CObjectPool[lot][pointer] == nil then - local obj = {} - rawset(obj, '_pointer', pointer) - rawset(obj, '_lot', lot) - setmetatable(obj, _CObject) - _CObjectPool[lot][pointer] = obj - return obj - end - - return _CObjectPool[lot][pointer] -end - -local _CPointerPool = {} - -_CPointer = { - __index = function (t,k) - return nil - end, - __newindex = function (t,k,v) - end, - __tostring = function(t) - return 'CPointer: ' .. t['_lvt'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']' - end, - __eq = function (a, b) - return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil - end -} - -function _NewCPointer(lvt, pointer) - if _CPointerPool[lvt] == nil then - _CPointerPool[lvt] = {} - end - - if _CPointerPool[lvt][pointer] == nil then - local obj = {} - rawset(obj, '_pointer', pointer) - rawset(obj, '_lvt', lvt) - setmetatable(obj, _CPointer) - _CPointerPool[lvt][pointer] = obj - return obj - end - - return _CPointerPool[lvt][pointer] -end - _SyncTable = { __index = function (t,k) local _table = rawget(t, '_table') diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 3c6e3af9d..d65909bd6 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -2,78 +2,6 @@ math.randomseed(get_time()) - --------------- --- CObjects -- --------------- - -_CObjectPool = {} - -_CObject = { - __index = function (t,k) - return _get_field(t['_lot'], t['_pointer'], k, t) - end, - __newindex = function (t,k,v) - _set_field(t['_lot'], t['_pointer'], k, v, t) - end, - __tostring = function(t) - return 'CObject: ' .. t['_lot'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']' - end, - __eq = function (a, b) - return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil - end -} - -function _NewCObject(lot, pointer) - if _CObjectPool[lot] == nil then - _CObjectPool[lot] = {} - end - - if _CObjectPool[lot][pointer] == nil then - local obj = {} - rawset(obj, '_pointer', pointer) - rawset(obj, '_lot', lot) - setmetatable(obj, _CObject) - _CObjectPool[lot][pointer] = obj - return obj - end - - return _CObjectPool[lot][pointer] -end - -local _CPointerPool = {} - -_CPointer = { - __index = function (t,k) - return nil - end, - __newindex = function (t,k,v) - end, - __tostring = function(t) - return 'CPointer: ' .. t['_lvt'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']' - end, - __eq = function (a, b) - return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil - end -} - -function _NewCPointer(lvt, pointer) - if _CPointerPool[lvt] == nil then - _CPointerPool[lvt] = {} - end - - if _CPointerPool[lvt][pointer] == nil then - local obj = {} - rawset(obj, '_pointer', pointer) - rawset(obj, '_lvt', lvt) - setmetatable(obj, _CPointer) - _CPointerPool[lvt][pointer] = obj - return obj - end - - return _CPointerPool[lvt][pointer] -end - _SyncTable = { __index = function (t,k) local _table = rawget(t, '_table') @@ -3779,6 +3707,9 @@ INT_TWIRL = (1 << 8) --- @type InteractionFlag INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL) +--- @type InteractionFlag +INT_LUA = (1 << 31) + --- @class InteractionType --- @type InteractionType @@ -5571,7 +5502,7 @@ MARIO_HAND_RIGHT_OPEN = 5 MAX_KEYS = 512 --- @type integer -MAX_KEY_VALUE_LENGTH = 256 +MAX_KEY_VALUE_LENGTH = 512 --- @type integer PACKET_LENGTH = 3000 @@ -9230,7 +9161,10 @@ HOOK_ON_LANGUAGE_CHANGED = 44 HOOK_ON_MODS_LOADED = 45 --- @type LuaHookedEventType -HOOK_MAX = 46 +HOOK_ON_NAMETAGS_RENDER = 46 + +--- @type LuaHookedEventType +HOOK_MAX = 47 --- @class LuaModMenuElementType @@ -12557,10 +12491,10 @@ SPTASK_STATE_FINISHED_DP = 4 MAX_VERSION_LENGTH = 32 --- @type integer -MINOR_VERSION_NUMBER = 2 +MINOR_VERSION_NUMBER = 3 --- @type string -SM64COOPDX_VERSION = "v1.0.3" +SM64COOPDX_VERSION = "v1.0.4" --- @type integer VERSION_NUMBER = 37 diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 29da577d8..7d1ee3f53 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3070,6 +3070,11 @@ function djui_hud_get_font() -- ... end +--- @return number +function djui_hud_get_fov_coeff() + -- ... +end + --- @return number function djui_hud_get_mouse_x() -- ... @@ -3220,6 +3225,11 @@ function djui_open_pause_menu() -- ... end +--- @return number +function get_current_fov() + -- ... +end + --- @param message string --- @param lines integer function djui_popup_create(message, lines) @@ -5024,6 +5034,19 @@ function approach_s32(current, target, inc, dec) -- ... end +--- @param y number +--- @param x number +--- @return integer +function atan2s(y, x) + -- ... +end + +--- @param sm64Angle integer +--- @return number +function coss(sm64Angle) + -- ... +end + --- @param dest Vec3f --- @param a Vec3f --- @param b Vec3f @@ -5040,6 +5063,34 @@ function get_pos_from_transform_mtx(dest, objMtx, camMtx) -- ... end +--- @param a integer +--- @param b integer +--- @return integer +function max(a, b) + -- ... +end + +--- @param a number +--- @param b number +--- @return number +function maxf(a, b) + -- ... +end + +--- @param a integer +--- @param b integer +--- @return integer +function min(a, b) + -- ... +end + +--- @param a number +--- @param b number +--- @return number +function minf(a, b) + -- ... +end + --- @param dest Mat4 --- @param upDir Vec3f --- @param pos Vec3f @@ -5156,6 +5207,12 @@ function not_zero(value, replacement) -- ... end +--- @param sm64Angle integer +--- @return number +function sins(sm64Angle) + -- ... +end + --- @param m MarioState --- @param result Vec4f --- @param t number @@ -5164,6 +5221,18 @@ function spline_get_weights(m, result, t, c) -- ... end +--- @param x integer +--- @return integer +function sqr(x) + -- ... +end + +--- @param x number +--- @return number +function sqrf(x) + -- ... +end + --- @param dest Vec3f --- @param a Vec3f --- @return void* @@ -5454,6 +5523,12 @@ function network_player_set_description(np, description, r, g, b, a) -- ... end +--- @param np NetworkPlayer +--- @param location string +function network_player_set_override_location(np, location) + -- ... +end + --- @param np NetworkPlayer --- @param part PlayerPart --- @param color Color @@ -7807,6 +7882,11 @@ function camera_freeze() -- ... end +--- @return boolean +function camera_get_checking_surfaces() + -- ... +end + --- @return boolean function camera_is_frozen() -- ... @@ -7826,6 +7906,11 @@ function camera_romhack_allow_dpad_usage(allow) -- ... end +--- @param value boolean +function camera_set_checking_surfaces(value) + -- ... +end + --- @param rco RomhackCameraOverride function camera_set_romhack_override(rco) -- ... @@ -8123,43 +8208,34 @@ function clampf(a, b, c) -- ... end ---- @param a integer ---- @param b integer +--- @param degreesAngle number --- @return integer -function max(a, b) +function degrees_to_sm64(degreesAngle) -- ... end --- @param a number --- @param b number --- @return number -function maxf(a, b) +function hypotf(a, b) -- ... end ---- @param a integer ---- @param b integer +--- @param radiansAngle number --- @return integer -function min(a, b) +function radians_to_sm64(radiansAngle) -- ... end ---- @param a number ---- @param b number +--- @param sm64Angle integer --- @return number -function minf(a, b) +function sm64_to_degrees(sm64Angle) -- ... end ---- @param x integer ---- @return integer -function sqr(x) - -- ... -end - ---- @param x number +--- @param sm64Angle integer --- @return number -function sqrf(x) +function sm64_to_radians(sm64Angle) -- ... end @@ -8181,6 +8257,11 @@ function deref_s32_pointer(pointer) -- ... end +--- @return boolean +function djui_attempting_to_open_playerlist() + -- ... +end + --- @return boolean function djui_is_playerlist_open() -- ... @@ -8211,6 +8292,12 @@ function djui_set_popup_disabled_override(value) -- ... end +--- @param localIndex integer +--- @return string +function get_coopnet_id(localIndex) + -- ... +end + --- @return integer function get_current_save_file_num() -- ... diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index 67caa7858..5f4478243 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -192,29 +192,34 @@ function update_mod_menu_element_name(index, name) -- ... end +--- @param index integer The index of the element in the order in which they were hooked +--- @param value boolean The boolean value to change to +--- Updates a mod menu checkbox element's boolean value +--- - NOTE: `index` is zero-indexed +function update_mod_menu_element_checkbox(index, value) + -- ... +end + +--- @param index integer The index of the element in the order in which they were hooked +--- @param value number The number value to change to +--- Updates a mod menu slider element's numerical value +--- - NOTE: `index` is zero-indexed +function update_mod_menu_element_slider(index, value) + -- ... +end + +--- @param index integer The index of the element in the order in which they were hooked +--- @param value string The text to change to +--- Updates a mod menu inputbox element's string value +--- - NOTE: `index` is zero-indexed +function update_mod_menu_element_inputbox(index, value) + -- ... +end + --------------- -- functions -- --------------- ---- @param t number Angle ---- @return number -function sins(t) - -- ... -end - ---- @param t number Angle ---- @return number -function coss(t) - -- ... -end - ---- @param y number ---- @param x number ---- @return integer -function atan2s(y, x) - -- ... -end - --- @param objFieldTable table --- Keys must start with `o` and values must be `"u32"`, `"s32"`, or `"f32"` function define_custom_obj_fields(objFieldTable) @@ -382,4 +387,4 @@ end --- Shoots a raycast from `startX`, `startY`, and `startZ` in the direction of `dirX`, `dirY`, and `dirZ` function collision_find_surface_on_ray(startX, startY, startZ, dirX, dirY, dirZ, precision) -- ... -end \ No newline at end of file +end diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index c52b81ccc..bbb761c31 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -537,6 +537,7 @@ --- @class Controller --- @field public buttonDown integer --- @field public buttonPressed integer +--- @field public buttonReleased integer --- @field public extStickX integer --- @field public extStickY integer --- @field public port integer @@ -1125,6 +1126,7 @@ --- @field public modelIndex integer --- @field public name string --- @field public onRxSeqId integer +--- @field public overrideLocation string --- @field public overrideModelIndex integer --- @field public overridePalette PlayerPalette --- @field public overridePaletteIndex integer diff --git a/data/dynos_bin_actor.cpp b/data/dynos_bin_actor.cpp index aa49a2fa1..60d62bcf1 100644 --- a/data/dynos_bin_actor.cpp +++ b/data/dynos_bin_actor.cpp @@ -149,12 +149,12 @@ static void DynOS_Actor_Generate(const SysPath &aPackFolder, Arrayd_name) == ".") continue; if (SysPath(_PackEnt->d_name) == "..") continue; -#ifdef DEVELOPMENT // Compress .bin files to gain some space - SysPath _Filename = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); - if (SysPath(_PackEnt->d_name).find(".bin") != SysPath::npos && !DynOS_Bin_IsCompressed(_Filename)) { - DynOS_Bin_Compress(_Filename); - continue; + if (configCompressOnStartup) { + SysPath _Filename = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); + if (SysPath(_PackEnt->d_name).find(".bin") != SysPath::npos && !DynOS_Bin_IsCompressed(_Filename)) { + DynOS_Bin_Compress(_Filename); + continue; + } } -#endif // For each subfolder, read tokens from model.inc.c and geo.inc.c SysPath _Folder = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); diff --git a/data/dynos_bin_col.cpp b/data/dynos_bin_col.cpp index d17c47c37..cebc98cae 100644 --- a/data/dynos_bin_col.cpp +++ b/data/dynos_bin_col.cpp @@ -691,13 +691,13 @@ void DynOS_Col_Generate(const SysPath &aPackFolder, Array> _Ac // If there is an existing binary file for this collision, skip and go to the next actor SysPath _ColFilename = fstring("%s/%s.col", aPackFolder.c_str(), _ColRootName.begin()); if (fs_sys_file_exists(_ColFilename.c_str())) { -#ifdef DEVELOPMENT + // Compress file to gain some space - if (!DynOS_Bin_IsCompressed(_ColFilename)) { + if (configCompressOnStartup && !DynOS_Bin_IsCompressed(_ColFilename)) { DynOS_Bin_Compress(_ColFilename); } + continue; -#endif } // Init diff --git a/data/dynos_bin_lvl.cpp b/data/dynos_bin_lvl.cpp index d8f0dc9c1..c991c8d63 100644 --- a/data/dynos_bin_lvl.cpp +++ b/data/dynos_bin_lvl.cpp @@ -1119,12 +1119,12 @@ static bool DynOS_Lvl_GeneratePack_Internal(const SysPath &aPackFolder, Arrayd_name) == ".") continue; if (SysPath(_PackEnt->d_name) == "..") continue; -#ifdef DEVELOPMENT // Compress .lvl files to gain some space - // TODO: is this required anymore? - /*SysPath _Filename = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); - if (SysPath(_PackEnt->d_name).find(".lvl") != SysPath::npos && !DynOS_Bin_IsCompressed(_Filename)) { - DynOS_Bin_Compress(_Filename); - continue; - }*/ -#endif + if (configCompressOnStartup) { + SysPath _Filename = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); + if (SysPath(_PackEnt->d_name).find(".lvl") != SysPath::npos && !DynOS_Bin_IsCompressed(_Filename)) { + DynOS_Bin_Compress(_Filename); + continue; + } + } // For each subfolder, read tokens from script.c SysPath _Folder = fstring("%s/%s", aPackFolder.c_str(), _PackEnt->d_name); diff --git a/data/dynos_bin_read.cpp b/data/dynos_bin_read.cpp index b36768442..d6e3c72fe 100644 --- a/data/dynos_bin_read.cpp +++ b/data/dynos_bin_read.cpp @@ -36,14 +36,18 @@ char *DynOS_Read_Buffer(FILE* aFile, GfxData* aGfxData) { aGfxData->mModelIdentifier = (u32) _Length; } - // Remove comments + char *_OrigFileBuffer = New(_Length + 1); + char *pOrigFileBuffer = _OrigFileBuffer; rewind(aFile); + _OrigFileBuffer[fread(_OrigFileBuffer, 1, _Length, aFile)] = 0; + + // Remove comments char *_FileBuffer = New(_Length + 1); char *pFileBuffer = _FileBuffer; char _Previous = 0; char _Current = 0; s32 _CommentType = 0; - while (fread(&_Current, 1, 1, aFile)) { + while ((_Current = *pOrigFileBuffer++)) { if (_CommentType == COMMENT_NONE) { if (_Current == '/') { _CommentType = COMMENT_START; @@ -79,6 +83,7 @@ char *DynOS_Read_Buffer(FILE* aFile, GfxData* aGfxData) { _Previous = _Current; } *(pFileBuffer++) = 0; + Delete(_OrigFileBuffer); // Remove ifdef blocks // Doesn't support nested blocks diff --git a/data/dynos_gfx_init.cpp b/data/dynos_gfx_init.cpp index c1f3b10b2..3fbae797c 100644 --- a/data/dynos_gfx_init.cpp +++ b/data/dynos_gfx_init.cpp @@ -1,8 +1,13 @@ #include "dynos.cpp.h" +extern "C" { #include "pc/loading.h" +} void DynOS_Gfx_GeneratePacks(const char* directory) { - LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In Path:\n\\#808080\\%s", directory)); + LOADING_SCREEN_MUTEX( + loading_screen_reset_progress_bar(); + snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In Path:\n\\#808080\\%s", directory); + ); DIR *modsDir = opendir(directory); if (!modsDir) { return; } diff --git a/data/dynos_mgr_builtin.cpp b/data/dynos_mgr_builtin.cpp index e4a836e37..22e3fa6b5 100644 --- a/data/dynos_mgr_builtin.cpp +++ b/data/dynos_mgr_builtin.cpp @@ -1975,6 +1975,7 @@ static const void* sDynosBuiltinFuncs[] = { define_builtin(bhv_star_number_loop), define_builtin(spawn_star_number), define_builtin(bhv_ferris_wheel_platform_init), + define_builtin(geo_mario_cap_display_list), }; const void* DynOS_Builtin_Func_GetFromName(const char* aDataName) { diff --git a/data/dynos_mgr_builtin_tex.cpp b/data/dynos_mgr_builtin_tex.cpp index e4a8d8302..9c70fb4e1 100644 --- a/data/dynos_mgr_builtin_tex.cpp +++ b/data/dynos_mgr_builtin_tex.cpp @@ -1055,7 +1055,7 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { define_builtin_tex(mario_texture_metal_light, "actors/mario/custom_mario_metal_light.rgba16.png", 64, 32, 16), define_builtin_tex(mario_texture_yellow_button, "actors/mario/mario_overalls_button.rgba16.png", 32, 32, 16), define_builtin_tex(mario_texture_m_logo, "actors/mario/custom_mario_logo.rgba16.png", 32, 32, 16), - define_builtin_tex(mario_texture_m_blend, "actors/mario/custom_mario_m_blend.rgba16.png", 32, 32, 16), + define_builtin_tex(mario_texture_m_blend, "actors/mario/custom_mario_logo_blend.rgba16.png", 32, 32, 16), define_builtin_tex(mario_texture_m_cap, "actors/mario/custom_mario_cap.rgba16.png", 32, 32, 16), define_builtin_tex(mario_texture_hair_sideburn, "actors/mario/custom_mario_sideburn.rgba16.png", 32, 32, 16), define_builtin_tex(mario_texture_add_sideburn, "actors/mario/custom_mario_sideburn_add.rgba16.png", 32, 32, 16), @@ -1544,594 +1544,594 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { define_builtin_tex(texture_font_char_us_button_C_right, "textures/segment2/font_graphics.06FC0.ia4.png", 16, 8, 16), #endif - define_builtin_tex(water_skybox_texture_00000, "textures/skyboxes/water.00.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00001, "textures/skyboxes/water.01.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00002, "textures/skyboxes/water.02.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00003, "textures/skyboxes/water.03.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00004, "textures/skyboxes/water.04.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00005, "textures/skyboxes/water.05.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00006, "textures/skyboxes/water.06.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00007, "textures/skyboxes/water.07.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00008, "textures/skyboxes/water.08.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00009, "textures/skyboxes/water.09.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000A, "textures/skyboxes/water.10.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000B, "textures/skyboxes/water.11.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000C, "textures/skyboxes/water.12.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000D, "textures/skyboxes/water.13.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000E, "textures/skyboxes/water.14.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0000F, "textures/skyboxes/water.15.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00010, "textures/skyboxes/water.16.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00011, "textures/skyboxes/water.17.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00012, "textures/skyboxes/water.18.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00013, "textures/skyboxes/water.19.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00014, "textures/skyboxes/water.20.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00015, "textures/skyboxes/water.21.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00016, "textures/skyboxes/water.22.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00017, "textures/skyboxes/water.23.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00018, "textures/skyboxes/water.24.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00019, "textures/skyboxes/water.25.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001A, "textures/skyboxes/water.26.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001B, "textures/skyboxes/water.27.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001C, "textures/skyboxes/water.28.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001D, "textures/skyboxes/water.29.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001E, "textures/skyboxes/water.30.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0001F, "textures/skyboxes/water.31.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00020, "textures/skyboxes/water.32.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00021, "textures/skyboxes/water.33.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00022, "textures/skyboxes/water.34.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00023, "textures/skyboxes/water.35.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00024, "textures/skyboxes/water.36.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00025, "textures/skyboxes/water.37.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00026, "textures/skyboxes/water.38.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00027, "textures/skyboxes/water.39.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00028, "textures/skyboxes/water.40.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00029, "textures/skyboxes/water.41.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002A, "textures/skyboxes/water.42.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002B, "textures/skyboxes/water.43.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002C, "textures/skyboxes/water.44.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002D, "textures/skyboxes/water.45.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002E, "textures/skyboxes/water.46.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0002F, "textures/skyboxes/water.47.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00030, "textures/skyboxes/water.48.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00031, "textures/skyboxes/water.49.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00032, "textures/skyboxes/water.50.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00033, "textures/skyboxes/water.51.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00034, "textures/skyboxes/water.52.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00035, "textures/skyboxes/water.53.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00036, "textures/skyboxes/water.54.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00037, "textures/skyboxes/water.55.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00038, "textures/skyboxes/water.56.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_00039, "textures/skyboxes/water.57.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003A, "textures/skyboxes/water.58.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003B, "textures/skyboxes/water.59.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003C, "textures/skyboxes/water.60.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003D, "textures/skyboxes/water.61.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003E, "textures/skyboxes/water.62.rgba16.png", 32, 32, 16), - define_builtin_tex(water_skybox_texture_0003F, "textures/skyboxes/water.63.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00000, "textures/skybox_tiles/water.00.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00001, "textures/skybox_tiles/water.01.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00002, "textures/skybox_tiles/water.02.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00003, "textures/skybox_tiles/water.03.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00004, "textures/skybox_tiles/water.04.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00005, "textures/skybox_tiles/water.05.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00006, "textures/skybox_tiles/water.06.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00007, "textures/skybox_tiles/water.07.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00008, "textures/skybox_tiles/water.08.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00009, "textures/skybox_tiles/water.09.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000A, "textures/skybox_tiles/water.10.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000B, "textures/skybox_tiles/water.11.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000C, "textures/skybox_tiles/water.12.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000D, "textures/skybox_tiles/water.13.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000E, "textures/skybox_tiles/water.14.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0000F, "textures/skybox_tiles/water.15.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00010, "textures/skybox_tiles/water.16.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00011, "textures/skybox_tiles/water.17.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00012, "textures/skybox_tiles/water.18.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00013, "textures/skybox_tiles/water.19.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00014, "textures/skybox_tiles/water.20.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00015, "textures/skybox_tiles/water.21.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00016, "textures/skybox_tiles/water.22.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00017, "textures/skybox_tiles/water.23.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00018, "textures/skybox_tiles/water.24.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00019, "textures/skybox_tiles/water.25.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001A, "textures/skybox_tiles/water.26.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001B, "textures/skybox_tiles/water.27.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001C, "textures/skybox_tiles/water.28.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001D, "textures/skybox_tiles/water.29.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001E, "textures/skybox_tiles/water.30.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0001F, "textures/skybox_tiles/water.31.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00020, "textures/skybox_tiles/water.32.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00021, "textures/skybox_tiles/water.33.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00022, "textures/skybox_tiles/water.34.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00023, "textures/skybox_tiles/water.35.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00024, "textures/skybox_tiles/water.36.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00025, "textures/skybox_tiles/water.37.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00026, "textures/skybox_tiles/water.38.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00027, "textures/skybox_tiles/water.39.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00028, "textures/skybox_tiles/water.40.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00029, "textures/skybox_tiles/water.41.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002A, "textures/skybox_tiles/water.42.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002B, "textures/skybox_tiles/water.43.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002C, "textures/skybox_tiles/water.44.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002D, "textures/skybox_tiles/water.45.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002E, "textures/skybox_tiles/water.46.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0002F, "textures/skybox_tiles/water.47.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00030, "textures/skybox_tiles/water.48.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00031, "textures/skybox_tiles/water.49.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00032, "textures/skybox_tiles/water.50.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00033, "textures/skybox_tiles/water.51.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00034, "textures/skybox_tiles/water.52.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00035, "textures/skybox_tiles/water.53.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00036, "textures/skybox_tiles/water.54.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00037, "textures/skybox_tiles/water.55.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00038, "textures/skybox_tiles/water.56.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_00039, "textures/skybox_tiles/water.57.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003A, "textures/skybox_tiles/water.58.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003B, "textures/skybox_tiles/water.59.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003C, "textures/skybox_tiles/water.60.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003D, "textures/skybox_tiles/water.61.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003E, "textures/skybox_tiles/water.62.rgba16.png", 32, 32, 16), + define_builtin_tex(water_skybox_texture_0003F, "textures/skybox_tiles/water.63.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00000, "textures/skyboxes/bitfs.00.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00001, "textures/skyboxes/bitfs.01.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00002, "textures/skyboxes/bitfs.02.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00003, "textures/skyboxes/bitfs.03.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00004, "textures/skyboxes/bitfs.04.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00005, "textures/skyboxes/bitfs.05.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00006, "textures/skyboxes/bitfs.06.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00007, "textures/skyboxes/bitfs.07.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00008, "textures/skyboxes/bitfs.08.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00009, "textures/skyboxes/bitfs.09.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000A, "textures/skyboxes/bitfs.10.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000B, "textures/skyboxes/bitfs.11.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000C, "textures/skyboxes/bitfs.12.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000D, "textures/skyboxes/bitfs.13.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000E, "textures/skyboxes/bitfs.14.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0000F, "textures/skyboxes/bitfs.15.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00010, "textures/skyboxes/bitfs.16.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00011, "textures/skyboxes/bitfs.17.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00012, "textures/skyboxes/bitfs.18.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00013, "textures/skyboxes/bitfs.19.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00014, "textures/skyboxes/bitfs.20.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00015, "textures/skyboxes/bitfs.21.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00016, "textures/skyboxes/bitfs.22.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00017, "textures/skyboxes/bitfs.23.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00018, "textures/skyboxes/bitfs.24.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00019, "textures/skyboxes/bitfs.25.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001A, "textures/skyboxes/bitfs.26.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001B, "textures/skyboxes/bitfs.27.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001C, "textures/skyboxes/bitfs.28.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001D, "textures/skyboxes/bitfs.29.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001E, "textures/skyboxes/bitfs.30.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0001F, "textures/skyboxes/bitfs.31.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00020, "textures/skyboxes/bitfs.32.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00021, "textures/skyboxes/bitfs.33.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00022, "textures/skyboxes/bitfs.34.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00023, "textures/skyboxes/bitfs.35.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00024, "textures/skyboxes/bitfs.36.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00025, "textures/skyboxes/bitfs.37.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00026, "textures/skyboxes/bitfs.38.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00027, "textures/skyboxes/bitfs.39.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00028, "textures/skyboxes/bitfs.40.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00029, "textures/skyboxes/bitfs.41.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002A, "textures/skyboxes/bitfs.42.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002B, "textures/skyboxes/bitfs.43.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002C, "textures/skyboxes/bitfs.44.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002D, "textures/skyboxes/bitfs.45.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002E, "textures/skyboxes/bitfs.46.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_0002F, "textures/skyboxes/bitfs.47.rgba16.png", 32, 32, 16), - define_builtin_tex(bitfs_skybox_texture_00030, "textures/skyboxes/bitfs.48.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00000, "textures/skybox_tiles/bitfs.00.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00001, "textures/skybox_tiles/bitfs.01.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00002, "textures/skybox_tiles/bitfs.02.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00003, "textures/skybox_tiles/bitfs.03.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00004, "textures/skybox_tiles/bitfs.04.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00005, "textures/skybox_tiles/bitfs.05.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00006, "textures/skybox_tiles/bitfs.06.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00007, "textures/skybox_tiles/bitfs.07.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00008, "textures/skybox_tiles/bitfs.08.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00009, "textures/skybox_tiles/bitfs.09.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000A, "textures/skybox_tiles/bitfs.10.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000B, "textures/skybox_tiles/bitfs.11.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000C, "textures/skybox_tiles/bitfs.12.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000D, "textures/skybox_tiles/bitfs.13.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000E, "textures/skybox_tiles/bitfs.14.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0000F, "textures/skybox_tiles/bitfs.15.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00010, "textures/skybox_tiles/bitfs.16.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00011, "textures/skybox_tiles/bitfs.17.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00012, "textures/skybox_tiles/bitfs.18.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00013, "textures/skybox_tiles/bitfs.19.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00014, "textures/skybox_tiles/bitfs.20.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00015, "textures/skybox_tiles/bitfs.21.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00016, "textures/skybox_tiles/bitfs.22.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00017, "textures/skybox_tiles/bitfs.23.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00018, "textures/skybox_tiles/bitfs.24.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00019, "textures/skybox_tiles/bitfs.25.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001A, "textures/skybox_tiles/bitfs.26.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001B, "textures/skybox_tiles/bitfs.27.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001C, "textures/skybox_tiles/bitfs.28.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001D, "textures/skybox_tiles/bitfs.29.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001E, "textures/skybox_tiles/bitfs.30.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0001F, "textures/skybox_tiles/bitfs.31.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00020, "textures/skybox_tiles/bitfs.32.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00021, "textures/skybox_tiles/bitfs.33.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00022, "textures/skybox_tiles/bitfs.34.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00023, "textures/skybox_tiles/bitfs.35.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00024, "textures/skybox_tiles/bitfs.36.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00025, "textures/skybox_tiles/bitfs.37.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00026, "textures/skybox_tiles/bitfs.38.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00027, "textures/skybox_tiles/bitfs.39.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00028, "textures/skybox_tiles/bitfs.40.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00029, "textures/skybox_tiles/bitfs.41.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002A, "textures/skybox_tiles/bitfs.42.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002B, "textures/skybox_tiles/bitfs.43.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002C, "textures/skybox_tiles/bitfs.44.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002D, "textures/skybox_tiles/bitfs.45.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002E, "textures/skybox_tiles/bitfs.46.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_0002F, "textures/skybox_tiles/bitfs.47.rgba16.png", 32, 32, 16), + define_builtin_tex(bitfs_skybox_texture_00030, "textures/skybox_tiles/bitfs.48.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00000, "textures/skyboxes/wdw.00.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00001, "textures/skyboxes/wdw.01.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00002, "textures/skyboxes/wdw.02.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00003, "textures/skyboxes/wdw.03.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00004, "textures/skyboxes/wdw.04.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00005, "textures/skyboxes/wdw.05.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00006, "textures/skyboxes/wdw.06.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00007, "textures/skyboxes/wdw.07.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00008, "textures/skyboxes/wdw.08.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00009, "textures/skyboxes/wdw.09.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000A, "textures/skyboxes/wdw.10.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000B, "textures/skyboxes/wdw.11.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000C, "textures/skyboxes/wdw.12.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000D, "textures/skyboxes/wdw.13.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000E, "textures/skyboxes/wdw.14.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0000F, "textures/skyboxes/wdw.15.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00010, "textures/skyboxes/wdw.16.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00011, "textures/skyboxes/wdw.17.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00012, "textures/skyboxes/wdw.18.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00013, "textures/skyboxes/wdw.19.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00014, "textures/skyboxes/wdw.20.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00015, "textures/skyboxes/wdw.21.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00016, "textures/skyboxes/wdw.22.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00017, "textures/skyboxes/wdw.23.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00018, "textures/skyboxes/wdw.24.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00019, "textures/skyboxes/wdw.25.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001A, "textures/skyboxes/wdw.26.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001B, "textures/skyboxes/wdw.27.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001C, "textures/skyboxes/wdw.28.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001D, "textures/skyboxes/wdw.29.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001E, "textures/skyboxes/wdw.30.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0001F, "textures/skyboxes/wdw.31.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00020, "textures/skyboxes/wdw.32.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00021, "textures/skyboxes/wdw.33.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00022, "textures/skyboxes/wdw.34.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00023, "textures/skyboxes/wdw.35.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00024, "textures/skyboxes/wdw.36.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00025, "textures/skyboxes/wdw.37.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00026, "textures/skyboxes/wdw.38.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00027, "textures/skyboxes/wdw.39.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00028, "textures/skyboxes/wdw.40.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00029, "textures/skyboxes/wdw.41.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002A, "textures/skyboxes/wdw.42.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002B, "textures/skyboxes/wdw.43.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002C, "textures/skyboxes/wdw.44.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002D, "textures/skyboxes/wdw.45.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002E, "textures/skyboxes/wdw.46.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0002F, "textures/skyboxes/wdw.47.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00030, "textures/skyboxes/wdw.48.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00031, "textures/skyboxes/wdw.49.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00032, "textures/skyboxes/wdw.50.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00033, "textures/skyboxes/wdw.51.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00034, "textures/skyboxes/wdw.52.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00035, "textures/skyboxes/wdw.53.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00036, "textures/skyboxes/wdw.54.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00037, "textures/skyboxes/wdw.55.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00038, "textures/skyboxes/wdw.56.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_00039, "textures/skyboxes/wdw.57.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003A, "textures/skyboxes/wdw.58.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003B, "textures/skyboxes/wdw.59.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003C, "textures/skyboxes/wdw.60.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003D, "textures/skyboxes/wdw.61.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003E, "textures/skyboxes/wdw.62.rgba16.png", 32, 32, 16), - define_builtin_tex(wdw_skybox_texture_0003F, "textures/skyboxes/wdw.63.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00000, "textures/skybox_tiles/wdw.00.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00001, "textures/skybox_tiles/wdw.01.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00002, "textures/skybox_tiles/wdw.02.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00003, "textures/skybox_tiles/wdw.03.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00004, "textures/skybox_tiles/wdw.04.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00005, "textures/skybox_tiles/wdw.05.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00006, "textures/skybox_tiles/wdw.06.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00007, "textures/skybox_tiles/wdw.07.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00008, "textures/skybox_tiles/wdw.08.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00009, "textures/skybox_tiles/wdw.09.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000A, "textures/skybox_tiles/wdw.10.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000B, "textures/skybox_tiles/wdw.11.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000C, "textures/skybox_tiles/wdw.12.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000D, "textures/skybox_tiles/wdw.13.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000E, "textures/skybox_tiles/wdw.14.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0000F, "textures/skybox_tiles/wdw.15.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00010, "textures/skybox_tiles/wdw.16.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00011, "textures/skybox_tiles/wdw.17.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00012, "textures/skybox_tiles/wdw.18.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00013, "textures/skybox_tiles/wdw.19.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00014, "textures/skybox_tiles/wdw.20.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00015, "textures/skybox_tiles/wdw.21.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00016, "textures/skybox_tiles/wdw.22.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00017, "textures/skybox_tiles/wdw.23.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00018, "textures/skybox_tiles/wdw.24.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00019, "textures/skybox_tiles/wdw.25.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001A, "textures/skybox_tiles/wdw.26.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001B, "textures/skybox_tiles/wdw.27.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001C, "textures/skybox_tiles/wdw.28.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001D, "textures/skybox_tiles/wdw.29.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001E, "textures/skybox_tiles/wdw.30.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0001F, "textures/skybox_tiles/wdw.31.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00020, "textures/skybox_tiles/wdw.32.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00021, "textures/skybox_tiles/wdw.33.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00022, "textures/skybox_tiles/wdw.34.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00023, "textures/skybox_tiles/wdw.35.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00024, "textures/skybox_tiles/wdw.36.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00025, "textures/skybox_tiles/wdw.37.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00026, "textures/skybox_tiles/wdw.38.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00027, "textures/skybox_tiles/wdw.39.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00028, "textures/skybox_tiles/wdw.40.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00029, "textures/skybox_tiles/wdw.41.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002A, "textures/skybox_tiles/wdw.42.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002B, "textures/skybox_tiles/wdw.43.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002C, "textures/skybox_tiles/wdw.44.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002D, "textures/skybox_tiles/wdw.45.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002E, "textures/skybox_tiles/wdw.46.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0002F, "textures/skybox_tiles/wdw.47.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00030, "textures/skybox_tiles/wdw.48.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00031, "textures/skybox_tiles/wdw.49.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00032, "textures/skybox_tiles/wdw.50.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00033, "textures/skybox_tiles/wdw.51.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00034, "textures/skybox_tiles/wdw.52.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00035, "textures/skybox_tiles/wdw.53.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00036, "textures/skybox_tiles/wdw.54.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00037, "textures/skybox_tiles/wdw.55.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00038, "textures/skybox_tiles/wdw.56.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_00039, "textures/skybox_tiles/wdw.57.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003A, "textures/skybox_tiles/wdw.58.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003B, "textures/skybox_tiles/wdw.59.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003C, "textures/skybox_tiles/wdw.60.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003D, "textures/skybox_tiles/wdw.61.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003E, "textures/skybox_tiles/wdw.62.rgba16.png", 32, 32, 16), + define_builtin_tex(wdw_skybox_texture_0003F, "textures/skybox_tiles/wdw.63.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00000, "textures/skyboxes/cloud_floor.00.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00001, "textures/skyboxes/cloud_floor.01.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00002, "textures/skyboxes/cloud_floor.02.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00003, "textures/skyboxes/cloud_floor.03.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00004, "textures/skyboxes/cloud_floor.04.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00005, "textures/skyboxes/cloud_floor.05.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00006, "textures/skyboxes/cloud_floor.06.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00007, "textures/skyboxes/cloud_floor.07.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00008, "textures/skyboxes/cloud_floor.08.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00009, "textures/skyboxes/cloud_floor.09.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000A, "textures/skyboxes/cloud_floor.10.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000B, "textures/skyboxes/cloud_floor.11.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000C, "textures/skyboxes/cloud_floor.12.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000D, "textures/skyboxes/cloud_floor.13.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000E, "textures/skyboxes/cloud_floor.14.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0000F, "textures/skyboxes/cloud_floor.15.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00010, "textures/skyboxes/cloud_floor.16.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00011, "textures/skyboxes/cloud_floor.17.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00012, "textures/skyboxes/cloud_floor.18.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00013, "textures/skyboxes/cloud_floor.19.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00014, "textures/skyboxes/cloud_floor.20.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00015, "textures/skyboxes/cloud_floor.21.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00016, "textures/skyboxes/cloud_floor.22.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00017, "textures/skyboxes/cloud_floor.23.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00018, "textures/skyboxes/cloud_floor.24.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00019, "textures/skyboxes/cloud_floor.25.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001A, "textures/skyboxes/cloud_floor.26.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001B, "textures/skyboxes/cloud_floor.27.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001C, "textures/skyboxes/cloud_floor.28.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001D, "textures/skyboxes/cloud_floor.29.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001E, "textures/skyboxes/cloud_floor.30.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0001F, "textures/skyboxes/cloud_floor.31.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00020, "textures/skyboxes/cloud_floor.32.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00021, "textures/skyboxes/cloud_floor.33.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00022, "textures/skyboxes/cloud_floor.34.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00023, "textures/skyboxes/cloud_floor.35.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00024, "textures/skyboxes/cloud_floor.36.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00025, "textures/skyboxes/cloud_floor.37.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00026, "textures/skyboxes/cloud_floor.38.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00027, "textures/skyboxes/cloud_floor.39.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00028, "textures/skyboxes/cloud_floor.40.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00029, "textures/skyboxes/cloud_floor.41.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002A, "textures/skyboxes/cloud_floor.42.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002B, "textures/skyboxes/cloud_floor.43.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002C, "textures/skyboxes/cloud_floor.44.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002D, "textures/skyboxes/cloud_floor.45.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002E, "textures/skyboxes/cloud_floor.46.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0002F, "textures/skyboxes/cloud_floor.47.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00030, "textures/skyboxes/cloud_floor.48.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00031, "textures/skyboxes/cloud_floor.49.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00032, "textures/skyboxes/cloud_floor.50.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00033, "textures/skyboxes/cloud_floor.51.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00034, "textures/skyboxes/cloud_floor.52.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00035, "textures/skyboxes/cloud_floor.53.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00036, "textures/skyboxes/cloud_floor.54.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00037, "textures/skyboxes/cloud_floor.55.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00038, "textures/skyboxes/cloud_floor.56.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_00039, "textures/skyboxes/cloud_floor.57.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003A, "textures/skyboxes/cloud_floor.58.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003B, "textures/skyboxes/cloud_floor.59.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003C, "textures/skyboxes/cloud_floor.60.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003D, "textures/skyboxes/cloud_floor.61.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003E, "textures/skyboxes/cloud_floor.62.rgba16.png", 32, 32, 16), - define_builtin_tex(cloud_floor_skybox_texture_0003F, "textures/skyboxes/cloud_floor.63.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00000, "textures/skybox_tiles/cloud_floor.00.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00001, "textures/skybox_tiles/cloud_floor.01.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00002, "textures/skybox_tiles/cloud_floor.02.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00003, "textures/skybox_tiles/cloud_floor.03.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00004, "textures/skybox_tiles/cloud_floor.04.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00005, "textures/skybox_tiles/cloud_floor.05.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00006, "textures/skybox_tiles/cloud_floor.06.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00007, "textures/skybox_tiles/cloud_floor.07.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00008, "textures/skybox_tiles/cloud_floor.08.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00009, "textures/skybox_tiles/cloud_floor.09.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000A, "textures/skybox_tiles/cloud_floor.10.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000B, "textures/skybox_tiles/cloud_floor.11.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000C, "textures/skybox_tiles/cloud_floor.12.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000D, "textures/skybox_tiles/cloud_floor.13.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000E, "textures/skybox_tiles/cloud_floor.14.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0000F, "textures/skybox_tiles/cloud_floor.15.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00010, "textures/skybox_tiles/cloud_floor.16.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00011, "textures/skybox_tiles/cloud_floor.17.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00012, "textures/skybox_tiles/cloud_floor.18.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00013, "textures/skybox_tiles/cloud_floor.19.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00014, "textures/skybox_tiles/cloud_floor.20.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00015, "textures/skybox_tiles/cloud_floor.21.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00016, "textures/skybox_tiles/cloud_floor.22.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00017, "textures/skybox_tiles/cloud_floor.23.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00018, "textures/skybox_tiles/cloud_floor.24.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00019, "textures/skybox_tiles/cloud_floor.25.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001A, "textures/skybox_tiles/cloud_floor.26.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001B, "textures/skybox_tiles/cloud_floor.27.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001C, "textures/skybox_tiles/cloud_floor.28.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001D, "textures/skybox_tiles/cloud_floor.29.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001E, "textures/skybox_tiles/cloud_floor.30.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0001F, "textures/skybox_tiles/cloud_floor.31.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00020, "textures/skybox_tiles/cloud_floor.32.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00021, "textures/skybox_tiles/cloud_floor.33.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00022, "textures/skybox_tiles/cloud_floor.34.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00023, "textures/skybox_tiles/cloud_floor.35.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00024, "textures/skybox_tiles/cloud_floor.36.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00025, "textures/skybox_tiles/cloud_floor.37.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00026, "textures/skybox_tiles/cloud_floor.38.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00027, "textures/skybox_tiles/cloud_floor.39.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00028, "textures/skybox_tiles/cloud_floor.40.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00029, "textures/skybox_tiles/cloud_floor.41.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002A, "textures/skybox_tiles/cloud_floor.42.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002B, "textures/skybox_tiles/cloud_floor.43.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002C, "textures/skybox_tiles/cloud_floor.44.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002D, "textures/skybox_tiles/cloud_floor.45.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002E, "textures/skybox_tiles/cloud_floor.46.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0002F, "textures/skybox_tiles/cloud_floor.47.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00030, "textures/skybox_tiles/cloud_floor.48.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00031, "textures/skybox_tiles/cloud_floor.49.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00032, "textures/skybox_tiles/cloud_floor.50.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00033, "textures/skybox_tiles/cloud_floor.51.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00034, "textures/skybox_tiles/cloud_floor.52.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00035, "textures/skybox_tiles/cloud_floor.53.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00036, "textures/skybox_tiles/cloud_floor.54.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00037, "textures/skybox_tiles/cloud_floor.55.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00038, "textures/skybox_tiles/cloud_floor.56.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_00039, "textures/skybox_tiles/cloud_floor.57.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003A, "textures/skybox_tiles/cloud_floor.58.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003B, "textures/skybox_tiles/cloud_floor.59.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003C, "textures/skybox_tiles/cloud_floor.60.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003D, "textures/skybox_tiles/cloud_floor.61.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003E, "textures/skybox_tiles/cloud_floor.62.rgba16.png", 32, 32, 16), + define_builtin_tex(cloud_floor_skybox_texture_0003F, "textures/skybox_tiles/cloud_floor.63.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00000, "textures/skyboxes/ccm.00.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00001, "textures/skyboxes/ccm.01.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00002, "textures/skyboxes/ccm.02.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00003, "textures/skyboxes/ccm.03.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00004, "textures/skyboxes/ccm.04.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00005, "textures/skyboxes/ccm.05.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00006, "textures/skyboxes/ccm.06.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00007, "textures/skyboxes/ccm.07.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00008, "textures/skyboxes/ccm.08.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00009, "textures/skyboxes/ccm.09.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000A, "textures/skyboxes/ccm.10.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000B, "textures/skyboxes/ccm.11.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000C, "textures/skyboxes/ccm.12.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000D, "textures/skyboxes/ccm.13.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000E, "textures/skyboxes/ccm.14.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0000F, "textures/skyboxes/ccm.15.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00010, "textures/skyboxes/ccm.16.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00011, "textures/skyboxes/ccm.17.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00012, "textures/skyboxes/ccm.18.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00013, "textures/skyboxes/ccm.19.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00014, "textures/skyboxes/ccm.20.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00015, "textures/skyboxes/ccm.21.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00016, "textures/skyboxes/ccm.22.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00017, "textures/skyboxes/ccm.23.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00018, "textures/skyboxes/ccm.24.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00019, "textures/skyboxes/ccm.25.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001A, "textures/skyboxes/ccm.26.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001B, "textures/skyboxes/ccm.27.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001C, "textures/skyboxes/ccm.28.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001D, "textures/skyboxes/ccm.29.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001E, "textures/skyboxes/ccm.30.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0001F, "textures/skyboxes/ccm.31.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00020, "textures/skyboxes/ccm.32.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00021, "textures/skyboxes/ccm.33.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00022, "textures/skyboxes/ccm.34.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00023, "textures/skyboxes/ccm.35.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00024, "textures/skyboxes/ccm.36.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00025, "textures/skyboxes/ccm.37.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00026, "textures/skyboxes/ccm.38.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00027, "textures/skyboxes/ccm.39.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00028, "textures/skyboxes/ccm.40.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00029, "textures/skyboxes/ccm.41.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002A, "textures/skyboxes/ccm.42.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002B, "textures/skyboxes/ccm.43.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002C, "textures/skyboxes/ccm.44.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002D, "textures/skyboxes/ccm.45.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002E, "textures/skyboxes/ccm.46.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0002F, "textures/skyboxes/ccm.47.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00030, "textures/skyboxes/ccm.48.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00031, "textures/skyboxes/ccm.49.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00032, "textures/skyboxes/ccm.50.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00033, "textures/skyboxes/ccm.51.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00034, "textures/skyboxes/ccm.52.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00035, "textures/skyboxes/ccm.53.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00036, "textures/skyboxes/ccm.54.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00037, "textures/skyboxes/ccm.55.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00038, "textures/skyboxes/ccm.56.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_00039, "textures/skyboxes/ccm.57.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003A, "textures/skyboxes/ccm.58.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003B, "textures/skyboxes/ccm.59.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003C, "textures/skyboxes/ccm.60.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003D, "textures/skyboxes/ccm.61.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003E, "textures/skyboxes/ccm.62.rgba16.png", 32, 32, 16), - define_builtin_tex(ccm_skybox_texture_0003F, "textures/skyboxes/ccm.63.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00000, "textures/skybox_tiles/ccm.00.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00001, "textures/skybox_tiles/ccm.01.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00002, "textures/skybox_tiles/ccm.02.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00003, "textures/skybox_tiles/ccm.03.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00004, "textures/skybox_tiles/ccm.04.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00005, "textures/skybox_tiles/ccm.05.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00006, "textures/skybox_tiles/ccm.06.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00007, "textures/skybox_tiles/ccm.07.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00008, "textures/skybox_tiles/ccm.08.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00009, "textures/skybox_tiles/ccm.09.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000A, "textures/skybox_tiles/ccm.10.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000B, "textures/skybox_tiles/ccm.11.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000C, "textures/skybox_tiles/ccm.12.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000D, "textures/skybox_tiles/ccm.13.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000E, "textures/skybox_tiles/ccm.14.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0000F, "textures/skybox_tiles/ccm.15.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00010, "textures/skybox_tiles/ccm.16.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00011, "textures/skybox_tiles/ccm.17.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00012, "textures/skybox_tiles/ccm.18.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00013, "textures/skybox_tiles/ccm.19.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00014, "textures/skybox_tiles/ccm.20.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00015, "textures/skybox_tiles/ccm.21.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00016, "textures/skybox_tiles/ccm.22.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00017, "textures/skybox_tiles/ccm.23.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00018, "textures/skybox_tiles/ccm.24.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00019, "textures/skybox_tiles/ccm.25.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001A, "textures/skybox_tiles/ccm.26.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001B, "textures/skybox_tiles/ccm.27.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001C, "textures/skybox_tiles/ccm.28.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001D, "textures/skybox_tiles/ccm.29.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001E, "textures/skybox_tiles/ccm.30.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0001F, "textures/skybox_tiles/ccm.31.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00020, "textures/skybox_tiles/ccm.32.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00021, "textures/skybox_tiles/ccm.33.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00022, "textures/skybox_tiles/ccm.34.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00023, "textures/skybox_tiles/ccm.35.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00024, "textures/skybox_tiles/ccm.36.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00025, "textures/skybox_tiles/ccm.37.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00026, "textures/skybox_tiles/ccm.38.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00027, "textures/skybox_tiles/ccm.39.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00028, "textures/skybox_tiles/ccm.40.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00029, "textures/skybox_tiles/ccm.41.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002A, "textures/skybox_tiles/ccm.42.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002B, "textures/skybox_tiles/ccm.43.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002C, "textures/skybox_tiles/ccm.44.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002D, "textures/skybox_tiles/ccm.45.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002E, "textures/skybox_tiles/ccm.46.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0002F, "textures/skybox_tiles/ccm.47.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00030, "textures/skybox_tiles/ccm.48.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00031, "textures/skybox_tiles/ccm.49.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00032, "textures/skybox_tiles/ccm.50.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00033, "textures/skybox_tiles/ccm.51.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00034, "textures/skybox_tiles/ccm.52.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00035, "textures/skybox_tiles/ccm.53.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00036, "textures/skybox_tiles/ccm.54.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00037, "textures/skybox_tiles/ccm.55.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00038, "textures/skybox_tiles/ccm.56.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_00039, "textures/skybox_tiles/ccm.57.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003A, "textures/skybox_tiles/ccm.58.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003B, "textures/skybox_tiles/ccm.59.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003C, "textures/skybox_tiles/ccm.60.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003D, "textures/skybox_tiles/ccm.61.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003E, "textures/skybox_tiles/ccm.62.rgba16.png", 32, 32, 16), + define_builtin_tex(ccm_skybox_texture_0003F, "textures/skybox_tiles/ccm.63.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00000, "textures/skyboxes/ssl.00.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00001, "textures/skyboxes/ssl.01.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00002, "textures/skyboxes/ssl.02.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00003, "textures/skyboxes/ssl.03.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00004, "textures/skyboxes/ssl.04.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00005, "textures/skyboxes/ssl.05.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00006, "textures/skyboxes/ssl.06.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00007, "textures/skyboxes/ssl.07.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00008, "textures/skyboxes/ssl.08.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00009, "textures/skyboxes/ssl.09.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000A, "textures/skyboxes/ssl.10.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000B, "textures/skyboxes/ssl.11.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000C, "textures/skyboxes/ssl.12.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000D, "textures/skyboxes/ssl.13.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000E, "textures/skyboxes/ssl.14.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0000F, "textures/skyboxes/ssl.15.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00010, "textures/skyboxes/ssl.16.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00011, "textures/skyboxes/ssl.17.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00012, "textures/skyboxes/ssl.18.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00013, "textures/skyboxes/ssl.19.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00014, "textures/skyboxes/ssl.20.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00015, "textures/skyboxes/ssl.21.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00016, "textures/skyboxes/ssl.22.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00017, "textures/skyboxes/ssl.23.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00018, "textures/skyboxes/ssl.24.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00019, "textures/skyboxes/ssl.25.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001A, "textures/skyboxes/ssl.26.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001B, "textures/skyboxes/ssl.27.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001C, "textures/skyboxes/ssl.28.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001D, "textures/skyboxes/ssl.29.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001E, "textures/skyboxes/ssl.30.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0001F, "textures/skyboxes/ssl.31.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00020, "textures/skyboxes/ssl.32.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00021, "textures/skyboxes/ssl.33.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00022, "textures/skyboxes/ssl.34.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00023, "textures/skyboxes/ssl.35.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00024, "textures/skyboxes/ssl.36.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00025, "textures/skyboxes/ssl.37.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00026, "textures/skyboxes/ssl.38.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00027, "textures/skyboxes/ssl.39.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00028, "textures/skyboxes/ssl.40.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00029, "textures/skyboxes/ssl.41.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002A, "textures/skyboxes/ssl.42.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002B, "textures/skyboxes/ssl.43.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002C, "textures/skyboxes/ssl.44.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002D, "textures/skyboxes/ssl.45.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002E, "textures/skyboxes/ssl.46.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0002F, "textures/skyboxes/ssl.47.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00030, "textures/skyboxes/ssl.48.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00031, "textures/skyboxes/ssl.49.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00032, "textures/skyboxes/ssl.50.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00033, "textures/skyboxes/ssl.51.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00034, "textures/skyboxes/ssl.52.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00035, "textures/skyboxes/ssl.53.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00036, "textures/skyboxes/ssl.54.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00037, "textures/skyboxes/ssl.55.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00038, "textures/skyboxes/ssl.56.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_00039, "textures/skyboxes/ssl.57.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003A, "textures/skyboxes/ssl.58.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003B, "textures/skyboxes/ssl.59.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003C, "textures/skyboxes/ssl.60.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003D, "textures/skyboxes/ssl.61.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003E, "textures/skyboxes/ssl.62.rgba16.png", 32, 32, 16), - define_builtin_tex(ssl_skybox_texture_0003F, "textures/skyboxes/ssl.63.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00000, "textures/skybox_tiles/ssl.00.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00001, "textures/skybox_tiles/ssl.01.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00002, "textures/skybox_tiles/ssl.02.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00003, "textures/skybox_tiles/ssl.03.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00004, "textures/skybox_tiles/ssl.04.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00005, "textures/skybox_tiles/ssl.05.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00006, "textures/skybox_tiles/ssl.06.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00007, "textures/skybox_tiles/ssl.07.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00008, "textures/skybox_tiles/ssl.08.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00009, "textures/skybox_tiles/ssl.09.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000A, "textures/skybox_tiles/ssl.10.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000B, "textures/skybox_tiles/ssl.11.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000C, "textures/skybox_tiles/ssl.12.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000D, "textures/skybox_tiles/ssl.13.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000E, "textures/skybox_tiles/ssl.14.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0000F, "textures/skybox_tiles/ssl.15.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00010, "textures/skybox_tiles/ssl.16.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00011, "textures/skybox_tiles/ssl.17.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00012, "textures/skybox_tiles/ssl.18.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00013, "textures/skybox_tiles/ssl.19.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00014, "textures/skybox_tiles/ssl.20.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00015, "textures/skybox_tiles/ssl.21.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00016, "textures/skybox_tiles/ssl.22.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00017, "textures/skybox_tiles/ssl.23.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00018, "textures/skybox_tiles/ssl.24.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00019, "textures/skybox_tiles/ssl.25.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001A, "textures/skybox_tiles/ssl.26.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001B, "textures/skybox_tiles/ssl.27.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001C, "textures/skybox_tiles/ssl.28.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001D, "textures/skybox_tiles/ssl.29.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001E, "textures/skybox_tiles/ssl.30.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0001F, "textures/skybox_tiles/ssl.31.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00020, "textures/skybox_tiles/ssl.32.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00021, "textures/skybox_tiles/ssl.33.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00022, "textures/skybox_tiles/ssl.34.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00023, "textures/skybox_tiles/ssl.35.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00024, "textures/skybox_tiles/ssl.36.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00025, "textures/skybox_tiles/ssl.37.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00026, "textures/skybox_tiles/ssl.38.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00027, "textures/skybox_tiles/ssl.39.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00028, "textures/skybox_tiles/ssl.40.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00029, "textures/skybox_tiles/ssl.41.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002A, "textures/skybox_tiles/ssl.42.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002B, "textures/skybox_tiles/ssl.43.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002C, "textures/skybox_tiles/ssl.44.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002D, "textures/skybox_tiles/ssl.45.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002E, "textures/skybox_tiles/ssl.46.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0002F, "textures/skybox_tiles/ssl.47.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00030, "textures/skybox_tiles/ssl.48.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00031, "textures/skybox_tiles/ssl.49.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00032, "textures/skybox_tiles/ssl.50.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00033, "textures/skybox_tiles/ssl.51.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00034, "textures/skybox_tiles/ssl.52.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00035, "textures/skybox_tiles/ssl.53.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00036, "textures/skybox_tiles/ssl.54.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00037, "textures/skybox_tiles/ssl.55.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00038, "textures/skybox_tiles/ssl.56.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_00039, "textures/skybox_tiles/ssl.57.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003A, "textures/skybox_tiles/ssl.58.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003B, "textures/skybox_tiles/ssl.59.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003C, "textures/skybox_tiles/ssl.60.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003D, "textures/skybox_tiles/ssl.61.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003E, "textures/skybox_tiles/ssl.62.rgba16.png", 32, 32, 16), + define_builtin_tex(ssl_skybox_texture_0003F, "textures/skybox_tiles/ssl.63.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00000, "textures/skyboxes/bbh.00.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00001, "textures/skyboxes/bbh.01.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00002, "textures/skyboxes/bbh.02.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00003, "textures/skyboxes/bbh.03.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00004, "textures/skyboxes/bbh.04.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00005, "textures/skyboxes/bbh.05.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00006, "textures/skyboxes/bbh.06.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00007, "textures/skyboxes/bbh.07.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00008, "textures/skyboxes/bbh.08.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00009, "textures/skyboxes/bbh.09.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000A, "textures/skyboxes/bbh.10.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000B, "textures/skyboxes/bbh.11.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000C, "textures/skyboxes/bbh.12.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000D, "textures/skyboxes/bbh.13.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000E, "textures/skyboxes/bbh.14.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0000F, "textures/skyboxes/bbh.15.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00010, "textures/skyboxes/bbh.16.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00011, "textures/skyboxes/bbh.17.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00012, "textures/skyboxes/bbh.18.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00013, "textures/skyboxes/bbh.19.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00014, "textures/skyboxes/bbh.20.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00015, "textures/skyboxes/bbh.21.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00016, "textures/skyboxes/bbh.22.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00017, "textures/skyboxes/bbh.23.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00018, "textures/skyboxes/bbh.24.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00019, "textures/skyboxes/bbh.25.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001A, "textures/skyboxes/bbh.26.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001B, "textures/skyboxes/bbh.27.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001C, "textures/skyboxes/bbh.28.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001D, "textures/skyboxes/bbh.29.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001E, "textures/skyboxes/bbh.30.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_0001F, "textures/skyboxes/bbh.31.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00020, "textures/skyboxes/bbh.32.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00021, "textures/skyboxes/bbh.33.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00022, "textures/skyboxes/bbh.34.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00023, "textures/skyboxes/bbh.35.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00024, "textures/skyboxes/bbh.36.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00025, "textures/skyboxes/bbh.37.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00026, "textures/skyboxes/bbh.38.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00027, "textures/skyboxes/bbh.39.rgba16.png", 32, 32, 16), - define_builtin_tex(bbh_skybox_texture_00028, "textures/skyboxes/bbh.40.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00000, "textures/skybox_tiles/bbh.00.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00001, "textures/skybox_tiles/bbh.01.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00002, "textures/skybox_tiles/bbh.02.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00003, "textures/skybox_tiles/bbh.03.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00004, "textures/skybox_tiles/bbh.04.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00005, "textures/skybox_tiles/bbh.05.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00006, "textures/skybox_tiles/bbh.06.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00007, "textures/skybox_tiles/bbh.07.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00008, "textures/skybox_tiles/bbh.08.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00009, "textures/skybox_tiles/bbh.09.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000A, "textures/skybox_tiles/bbh.10.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000B, "textures/skybox_tiles/bbh.11.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000C, "textures/skybox_tiles/bbh.12.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000D, "textures/skybox_tiles/bbh.13.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000E, "textures/skybox_tiles/bbh.14.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0000F, "textures/skybox_tiles/bbh.15.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00010, "textures/skybox_tiles/bbh.16.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00011, "textures/skybox_tiles/bbh.17.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00012, "textures/skybox_tiles/bbh.18.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00013, "textures/skybox_tiles/bbh.19.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00014, "textures/skybox_tiles/bbh.20.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00015, "textures/skybox_tiles/bbh.21.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00016, "textures/skybox_tiles/bbh.22.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00017, "textures/skybox_tiles/bbh.23.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00018, "textures/skybox_tiles/bbh.24.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00019, "textures/skybox_tiles/bbh.25.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001A, "textures/skybox_tiles/bbh.26.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001B, "textures/skybox_tiles/bbh.27.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001C, "textures/skybox_tiles/bbh.28.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001D, "textures/skybox_tiles/bbh.29.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001E, "textures/skybox_tiles/bbh.30.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_0001F, "textures/skybox_tiles/bbh.31.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00020, "textures/skybox_tiles/bbh.32.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00021, "textures/skybox_tiles/bbh.33.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00022, "textures/skybox_tiles/bbh.34.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00023, "textures/skybox_tiles/bbh.35.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00024, "textures/skybox_tiles/bbh.36.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00025, "textures/skybox_tiles/bbh.37.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00026, "textures/skybox_tiles/bbh.38.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00027, "textures/skybox_tiles/bbh.39.rgba16.png", 32, 32, 16), + define_builtin_tex(bbh_skybox_texture_00028, "textures/skybox_tiles/bbh.40.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00000, "textures/skyboxes/bitdw.00.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00001, "textures/skyboxes/bitdw.01.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00002, "textures/skyboxes/bitdw.02.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00003, "textures/skyboxes/bitdw.03.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00004, "textures/skyboxes/bitdw.04.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00005, "textures/skyboxes/bitdw.05.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00006, "textures/skyboxes/bitdw.06.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00007, "textures/skyboxes/bitdw.07.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00008, "textures/skyboxes/bitdw.08.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00009, "textures/skyboxes/bitdw.09.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000A, "textures/skyboxes/bitdw.10.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000B, "textures/skyboxes/bitdw.11.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000C, "textures/skyboxes/bitdw.12.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000D, "textures/skyboxes/bitdw.13.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000E, "textures/skyboxes/bitdw.14.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0000F, "textures/skyboxes/bitdw.15.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00010, "textures/skyboxes/bitdw.16.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00011, "textures/skyboxes/bitdw.17.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00012, "textures/skyboxes/bitdw.18.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00013, "textures/skyboxes/bitdw.19.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00014, "textures/skyboxes/bitdw.20.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00015, "textures/skyboxes/bitdw.21.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00016, "textures/skyboxes/bitdw.22.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00017, "textures/skyboxes/bitdw.23.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00018, "textures/skyboxes/bitdw.24.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00019, "textures/skyboxes/bitdw.25.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001A, "textures/skyboxes/bitdw.26.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001B, "textures/skyboxes/bitdw.27.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001C, "textures/skyboxes/bitdw.28.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001D, "textures/skyboxes/bitdw.29.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001E, "textures/skyboxes/bitdw.30.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0001F, "textures/skyboxes/bitdw.31.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00020, "textures/skyboxes/bitdw.32.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00021, "textures/skyboxes/bitdw.33.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00022, "textures/skyboxes/bitdw.34.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00023, "textures/skyboxes/bitdw.35.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00024, "textures/skyboxes/bitdw.36.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00025, "textures/skyboxes/bitdw.37.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00026, "textures/skyboxes/bitdw.38.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00027, "textures/skyboxes/bitdw.39.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00028, "textures/skyboxes/bitdw.40.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00029, "textures/skyboxes/bitdw.41.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002A, "textures/skyboxes/bitdw.42.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002B, "textures/skyboxes/bitdw.43.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002C, "textures/skyboxes/bitdw.44.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002D, "textures/skyboxes/bitdw.45.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002E, "textures/skyboxes/bitdw.46.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0002F, "textures/skyboxes/bitdw.47.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00030, "textures/skyboxes/bitdw.48.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00031, "textures/skyboxes/bitdw.49.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00032, "textures/skyboxes/bitdw.50.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00033, "textures/skyboxes/bitdw.51.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00034, "textures/skyboxes/bitdw.52.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00035, "textures/skyboxes/bitdw.53.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00036, "textures/skyboxes/bitdw.54.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00037, "textures/skyboxes/bitdw.55.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00038, "textures/skyboxes/bitdw.56.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_00039, "textures/skyboxes/bitdw.57.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003A, "textures/skyboxes/bitdw.58.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003B, "textures/skyboxes/bitdw.59.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003C, "textures/skyboxes/bitdw.60.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003D, "textures/skyboxes/bitdw.61.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003E, "textures/skyboxes/bitdw.62.rgba16.png", 32, 32, 16), - define_builtin_tex(bitdw_skybox_texture_0003F, "textures/skyboxes/bitdw.63.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00000, "textures/skybox_tiles/bitdw.00.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00001, "textures/skybox_tiles/bitdw.01.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00002, "textures/skybox_tiles/bitdw.02.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00003, "textures/skybox_tiles/bitdw.03.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00004, "textures/skybox_tiles/bitdw.04.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00005, "textures/skybox_tiles/bitdw.05.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00006, "textures/skybox_tiles/bitdw.06.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00007, "textures/skybox_tiles/bitdw.07.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00008, "textures/skybox_tiles/bitdw.08.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00009, "textures/skybox_tiles/bitdw.09.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000A, "textures/skybox_tiles/bitdw.10.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000B, "textures/skybox_tiles/bitdw.11.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000C, "textures/skybox_tiles/bitdw.12.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000D, "textures/skybox_tiles/bitdw.13.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000E, "textures/skybox_tiles/bitdw.14.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0000F, "textures/skybox_tiles/bitdw.15.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00010, "textures/skybox_tiles/bitdw.16.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00011, "textures/skybox_tiles/bitdw.17.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00012, "textures/skybox_tiles/bitdw.18.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00013, "textures/skybox_tiles/bitdw.19.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00014, "textures/skybox_tiles/bitdw.20.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00015, "textures/skybox_tiles/bitdw.21.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00016, "textures/skybox_tiles/bitdw.22.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00017, "textures/skybox_tiles/bitdw.23.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00018, "textures/skybox_tiles/bitdw.24.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00019, "textures/skybox_tiles/bitdw.25.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001A, "textures/skybox_tiles/bitdw.26.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001B, "textures/skybox_tiles/bitdw.27.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001C, "textures/skybox_tiles/bitdw.28.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001D, "textures/skybox_tiles/bitdw.29.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001E, "textures/skybox_tiles/bitdw.30.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0001F, "textures/skybox_tiles/bitdw.31.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00020, "textures/skybox_tiles/bitdw.32.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00021, "textures/skybox_tiles/bitdw.33.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00022, "textures/skybox_tiles/bitdw.34.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00023, "textures/skybox_tiles/bitdw.35.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00024, "textures/skybox_tiles/bitdw.36.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00025, "textures/skybox_tiles/bitdw.37.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00026, "textures/skybox_tiles/bitdw.38.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00027, "textures/skybox_tiles/bitdw.39.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00028, "textures/skybox_tiles/bitdw.40.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00029, "textures/skybox_tiles/bitdw.41.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002A, "textures/skybox_tiles/bitdw.42.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002B, "textures/skybox_tiles/bitdw.43.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002C, "textures/skybox_tiles/bitdw.44.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002D, "textures/skybox_tiles/bitdw.45.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002E, "textures/skybox_tiles/bitdw.46.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0002F, "textures/skybox_tiles/bitdw.47.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00030, "textures/skybox_tiles/bitdw.48.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00031, "textures/skybox_tiles/bitdw.49.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00032, "textures/skybox_tiles/bitdw.50.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00033, "textures/skybox_tiles/bitdw.51.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00034, "textures/skybox_tiles/bitdw.52.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00035, "textures/skybox_tiles/bitdw.53.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00036, "textures/skybox_tiles/bitdw.54.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00037, "textures/skybox_tiles/bitdw.55.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00038, "textures/skybox_tiles/bitdw.56.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_00039, "textures/skybox_tiles/bitdw.57.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003A, "textures/skybox_tiles/bitdw.58.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003B, "textures/skybox_tiles/bitdw.59.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003C, "textures/skybox_tiles/bitdw.60.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003D, "textures/skybox_tiles/bitdw.61.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003E, "textures/skybox_tiles/bitdw.62.rgba16.png", 32, 32, 16), + define_builtin_tex(bitdw_skybox_texture_0003F, "textures/skybox_tiles/bitdw.63.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00000, "textures/skyboxes/clouds.00.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00001, "textures/skyboxes/clouds.01.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00002, "textures/skyboxes/clouds.02.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00003, "textures/skyboxes/clouds.03.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00004, "textures/skyboxes/clouds.04.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00005, "textures/skyboxes/clouds.05.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00006, "textures/skyboxes/clouds.06.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00007, "textures/skyboxes/clouds.07.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00008, "textures/skyboxes/clouds.08.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00009, "textures/skyboxes/clouds.09.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000A, "textures/skyboxes/clouds.10.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000B, "textures/skyboxes/clouds.11.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000C, "textures/skyboxes/clouds.12.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000D, "textures/skyboxes/clouds.13.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000E, "textures/skyboxes/clouds.14.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0000F, "textures/skyboxes/clouds.15.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00010, "textures/skyboxes/clouds.16.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00011, "textures/skyboxes/clouds.17.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00012, "textures/skyboxes/clouds.18.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00013, "textures/skyboxes/clouds.19.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00014, "textures/skyboxes/clouds.20.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00015, "textures/skyboxes/clouds.21.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00016, "textures/skyboxes/clouds.22.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00017, "textures/skyboxes/clouds.23.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00018, "textures/skyboxes/clouds.24.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00019, "textures/skyboxes/clouds.25.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001A, "textures/skyboxes/clouds.26.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001B, "textures/skyboxes/clouds.27.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001C, "textures/skyboxes/clouds.28.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001D, "textures/skyboxes/clouds.29.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001E, "textures/skyboxes/clouds.30.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_0001F, "textures/skyboxes/clouds.31.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00020, "textures/skyboxes/clouds.32.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00021, "textures/skyboxes/clouds.33.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00022, "textures/skyboxes/clouds.34.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00023, "textures/skyboxes/clouds.35.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00024, "textures/skyboxes/clouds.36.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00025, "textures/skyboxes/clouds.37.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00026, "textures/skyboxes/clouds.38.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00027, "textures/skyboxes/clouds.39.rgba16.png", 32, 32, 16), - define_builtin_tex(clouds_skybox_texture_00028, "textures/skyboxes/clouds.40.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00000, "textures/skybox_tiles/clouds.00.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00001, "textures/skybox_tiles/clouds.01.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00002, "textures/skybox_tiles/clouds.02.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00003, "textures/skybox_tiles/clouds.03.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00004, "textures/skybox_tiles/clouds.04.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00005, "textures/skybox_tiles/clouds.05.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00006, "textures/skybox_tiles/clouds.06.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00007, "textures/skybox_tiles/clouds.07.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00008, "textures/skybox_tiles/clouds.08.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00009, "textures/skybox_tiles/clouds.09.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000A, "textures/skybox_tiles/clouds.10.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000B, "textures/skybox_tiles/clouds.11.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000C, "textures/skybox_tiles/clouds.12.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000D, "textures/skybox_tiles/clouds.13.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000E, "textures/skybox_tiles/clouds.14.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0000F, "textures/skybox_tiles/clouds.15.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00010, "textures/skybox_tiles/clouds.16.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00011, "textures/skybox_tiles/clouds.17.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00012, "textures/skybox_tiles/clouds.18.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00013, "textures/skybox_tiles/clouds.19.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00014, "textures/skybox_tiles/clouds.20.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00015, "textures/skybox_tiles/clouds.21.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00016, "textures/skybox_tiles/clouds.22.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00017, "textures/skybox_tiles/clouds.23.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00018, "textures/skybox_tiles/clouds.24.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00019, "textures/skybox_tiles/clouds.25.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001A, "textures/skybox_tiles/clouds.26.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001B, "textures/skybox_tiles/clouds.27.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001C, "textures/skybox_tiles/clouds.28.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001D, "textures/skybox_tiles/clouds.29.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001E, "textures/skybox_tiles/clouds.30.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_0001F, "textures/skybox_tiles/clouds.31.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00020, "textures/skybox_tiles/clouds.32.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00021, "textures/skybox_tiles/clouds.33.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00022, "textures/skybox_tiles/clouds.34.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00023, "textures/skybox_tiles/clouds.35.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00024, "textures/skybox_tiles/clouds.36.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00025, "textures/skybox_tiles/clouds.37.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00026, "textures/skybox_tiles/clouds.38.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00027, "textures/skybox_tiles/clouds.39.rgba16.png", 32, 32, 16), + define_builtin_tex(clouds_skybox_texture_00028, "textures/skybox_tiles/clouds.40.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00000, "textures/skyboxes/bits.00.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00001, "textures/skyboxes/bits.01.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00002, "textures/skyboxes/bits.02.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00003, "textures/skyboxes/bits.03.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00004, "textures/skyboxes/bits.04.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00005, "textures/skyboxes/bits.05.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00006, "textures/skyboxes/bits.06.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00007, "textures/skyboxes/bits.07.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00008, "textures/skyboxes/bits.08.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00009, "textures/skyboxes/bits.09.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000A, "textures/skyboxes/bits.10.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000B, "textures/skyboxes/bits.11.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000C, "textures/skyboxes/bits.12.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000D, "textures/skyboxes/bits.13.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000E, "textures/skyboxes/bits.14.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0000F, "textures/skyboxes/bits.15.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00010, "textures/skyboxes/bits.16.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00011, "textures/skyboxes/bits.17.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00012, "textures/skyboxes/bits.18.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00013, "textures/skyboxes/bits.19.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00014, "textures/skyboxes/bits.20.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00015, "textures/skyboxes/bits.21.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00016, "textures/skyboxes/bits.22.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00017, "textures/skyboxes/bits.23.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00018, "textures/skyboxes/bits.24.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00019, "textures/skyboxes/bits.25.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001A, "textures/skyboxes/bits.26.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001B, "textures/skyboxes/bits.27.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001C, "textures/skyboxes/bits.28.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001D, "textures/skyboxes/bits.29.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001E, "textures/skyboxes/bits.30.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0001F, "textures/skyboxes/bits.31.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00020, "textures/skyboxes/bits.32.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00021, "textures/skyboxes/bits.33.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00022, "textures/skyboxes/bits.34.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00023, "textures/skyboxes/bits.35.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00024, "textures/skyboxes/bits.36.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00025, "textures/skyboxes/bits.37.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00026, "textures/skyboxes/bits.38.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00027, "textures/skyboxes/bits.39.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00028, "textures/skyboxes/bits.40.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00029, "textures/skyboxes/bits.41.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002A, "textures/skyboxes/bits.42.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002B, "textures/skyboxes/bits.43.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002C, "textures/skyboxes/bits.44.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002D, "textures/skyboxes/bits.45.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002E, "textures/skyboxes/bits.46.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0002F, "textures/skyboxes/bits.47.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00030, "textures/skyboxes/bits.48.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00031, "textures/skyboxes/bits.49.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00032, "textures/skyboxes/bits.50.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00033, "textures/skyboxes/bits.51.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00034, "textures/skyboxes/bits.52.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00035, "textures/skyboxes/bits.53.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00036, "textures/skyboxes/bits.54.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00037, "textures/skyboxes/bits.55.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00038, "textures/skyboxes/bits.56.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_00039, "textures/skyboxes/bits.57.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003A, "textures/skyboxes/bits.58.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003B, "textures/skyboxes/bits.59.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003C, "textures/skyboxes/bits.60.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003D, "textures/skyboxes/bits.61.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003E, "textures/skyboxes/bits.62.rgba16.png", 32, 32, 16), - define_builtin_tex(bits_skybox_texture_0003F, "textures/skyboxes/bits.63.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00000, "textures/skybox_tiles/bits.00.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00001, "textures/skybox_tiles/bits.01.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00002, "textures/skybox_tiles/bits.02.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00003, "textures/skybox_tiles/bits.03.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00004, "textures/skybox_tiles/bits.04.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00005, "textures/skybox_tiles/bits.05.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00006, "textures/skybox_tiles/bits.06.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00007, "textures/skybox_tiles/bits.07.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00008, "textures/skybox_tiles/bits.08.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00009, "textures/skybox_tiles/bits.09.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000A, "textures/skybox_tiles/bits.10.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000B, "textures/skybox_tiles/bits.11.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000C, "textures/skybox_tiles/bits.12.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000D, "textures/skybox_tiles/bits.13.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000E, "textures/skybox_tiles/bits.14.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0000F, "textures/skybox_tiles/bits.15.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00010, "textures/skybox_tiles/bits.16.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00011, "textures/skybox_tiles/bits.17.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00012, "textures/skybox_tiles/bits.18.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00013, "textures/skybox_tiles/bits.19.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00014, "textures/skybox_tiles/bits.20.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00015, "textures/skybox_tiles/bits.21.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00016, "textures/skybox_tiles/bits.22.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00017, "textures/skybox_tiles/bits.23.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00018, "textures/skybox_tiles/bits.24.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00019, "textures/skybox_tiles/bits.25.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001A, "textures/skybox_tiles/bits.26.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001B, "textures/skybox_tiles/bits.27.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001C, "textures/skybox_tiles/bits.28.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001D, "textures/skybox_tiles/bits.29.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001E, "textures/skybox_tiles/bits.30.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0001F, "textures/skybox_tiles/bits.31.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00020, "textures/skybox_tiles/bits.32.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00021, "textures/skybox_tiles/bits.33.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00022, "textures/skybox_tiles/bits.34.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00023, "textures/skybox_tiles/bits.35.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00024, "textures/skybox_tiles/bits.36.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00025, "textures/skybox_tiles/bits.37.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00026, "textures/skybox_tiles/bits.38.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00027, "textures/skybox_tiles/bits.39.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00028, "textures/skybox_tiles/bits.40.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00029, "textures/skybox_tiles/bits.41.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002A, "textures/skybox_tiles/bits.42.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002B, "textures/skybox_tiles/bits.43.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002C, "textures/skybox_tiles/bits.44.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002D, "textures/skybox_tiles/bits.45.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002E, "textures/skybox_tiles/bits.46.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0002F, "textures/skybox_tiles/bits.47.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00030, "textures/skybox_tiles/bits.48.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00031, "textures/skybox_tiles/bits.49.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00032, "textures/skybox_tiles/bits.50.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00033, "textures/skybox_tiles/bits.51.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00034, "textures/skybox_tiles/bits.52.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00035, "textures/skybox_tiles/bits.53.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00036, "textures/skybox_tiles/bits.54.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00037, "textures/skybox_tiles/bits.55.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00038, "textures/skybox_tiles/bits.56.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_00039, "textures/skybox_tiles/bits.57.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003A, "textures/skybox_tiles/bits.58.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003B, "textures/skybox_tiles/bits.59.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003C, "textures/skybox_tiles/bits.60.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003D, "textures/skybox_tiles/bits.61.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003E, "textures/skybox_tiles/bits.62.rgba16.png", 32, 32, 16), + define_builtin_tex(bits_skybox_texture_0003F, "textures/skybox_tiles/bits.63.rgba16.png", 32, 32, 16), #if defined(VERSION_JP) define_builtin_tex(texture_menu_font_char_jp_0, "levels/menu/main_menu_seg7.0AC48.ia8.png", 8, 8, 8), diff --git a/data/dynos_warps.cpp b/data/dynos_warps.cpp index f90a8e2dd..e50b53105 100644 --- a/data/dynos_warps.cpp +++ b/data/dynos_warps.cpp @@ -176,6 +176,7 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { gMarioState->numCoins = 0; gMarioState->input = 0; gMarioState->controller->buttonPressed = 0; + gMarioState->controller->buttonReleased = 0; gHudDisplay.coins = 0; // Set up new level values @@ -337,6 +338,7 @@ static void *DynOS_Warp_UpdateExit(void *aCmd, bool aIsLevelInitDone) { gMarioState->numCoins = 0; gMarioState->input = 0; gMarioState->controller->buttonPressed = 0; + gMarioState->controller->buttonReleased = 0; gHudDisplay.coins = 0; // Set up new level values diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 6dce0480d..683e6a3ba 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1309,6 +1309,7 @@ | INT_HIT_FROM_BELOW | (1 << 7) | | INT_TWIRL | (1 << 8) | | INT_GROUND_POUND_OR_TWIRL | (INT_GROUND_POUND | INT_TWIRL) | +| INT_LUA | (1 << 31) | ### [enum InteractionType](#InteractionType) | Identifier | Value | @@ -3297,7 +3298,8 @@ | HOOK_ON_ATTACK_OBJECT | 43 | | HOOK_ON_LANGUAGE_CHANGED | 44 | | HOOK_ON_MODS_LOADED | 45 | -| HOOK_MAX | 46 | +| HOOK_ON_NAMETAGS_RENDER | 46 | +| HOOK_MAX | 47 | ### [enum LuaModMenuElementType](#LuaModMenuElementType) | Identifier | Value | diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 961ffb8e3..185315d7d 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2170,6 +2170,24 @@
+## [djui_hud_get_fov_coeff](#djui_hud_get_fov_coeff) + +### Lua Example +`local numberValue = djui_hud_get_fov_coeff()` + +### Parameters +- None + +### Returns +- `number` + +### C Prototype +`f32 djui_hud_get_fov_coeff();` + +[:arrow_up_small:](#) + +
+ ## [djui_hud_get_mouse_x](#djui_hud_get_mouse_x) ### Lua Example @@ -2658,6 +2676,24 @@
+## [get_current_fov](#get_current_fov) + +### Lua Example +`local numberValue = get_current_fov()` + +### Parameters +- None + +### Returns +- `number` + +### C Prototype +`f32 get_current_fov();` + +[:arrow_up_small:](#) + +
+ --- # functions from djui_popup.h diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index a78d3cdd0..4f394f0b7 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -99,6 +99,47 @@
+## [atan2s](#atan2s) + +### Lua Example +`local integerValue = atan2s(y, x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| y | `number` | +| x | `number` | + +### Returns +- `integer` + +### C Prototype +`s16 atan2s(f32 y, f32 x);` + +[:arrow_up_small:](#) + +
+ +## [coss](#coss) + +### Lua Example +`local numberValue = coss(sm64Angle)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sm64Angle | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 coss(s16 sm64Angle);` + +[:arrow_up_small:](#) + +
+ ## [find_vector_perpendicular_to_plane](#find_vector_perpendicular_to_plane) ### Lua Example @@ -144,6 +185,90 @@
+## [max](#max) + +### Lua Example +`local integerValue = max(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `integer` | +| b | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 max(s16 a, s16 b);` + +[:arrow_up_small:](#) + +
+ +## [maxf](#maxf) + +### Lua Example +`local numberValue = maxf(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `number` | +| b | `number` | + +### Returns +- `number` + +### C Prototype +`f32 maxf(f32 a, f32 b);` + +[:arrow_up_small:](#) + +
+ +## [min](#min) + +### Lua Example +`local integerValue = min(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `integer` | +| b | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 min(s16 a, s16 b);` + +[:arrow_up_small:](#) + +
+ +## [minf](#minf) + +### Lua Example +`local numberValue = minf(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `number` | +| b | `number` | + +### Returns +- `number` + +### C Prototype +`f32 minf(f32 a, f32 b);` + +[:arrow_up_small:](#) + +
+ ## [mtxf_align_terrain_normal](#mtxf_align_terrain_normal) ### Lua Example @@ -514,6 +639,26 @@
+## [sins](#sins) + +### Lua Example +`local numberValue = sins(sm64Angle)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sm64Angle | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 sins(s16 sm64Angle);` + +[:arrow_up_small:](#) + +
+ ## [spline_get_weights](#spline_get_weights) ### Lua Example @@ -537,6 +682,46 @@
+## [sqr](#sqr) + +### Lua Example +`local integerValue = sqr(x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 sqr(s16 x);` + +[:arrow_up_small:](#) + +
+ +## [sqrf](#sqrf) + +### Lua Example +`local numberValue = sqrf(x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | + +### Returns +- `number` + +### C Prototype +`f32 sqrf(f32 x);` + +[:arrow_up_small:](#) + +
+ ## [vec3f_add](#vec3f_add) ### Lua Example @@ -1378,6 +1563,27 @@
+## [network_player_set_override_location](#network_player_set_override_location) + +### Lua Example +`network_player_set_override_location(np, location)` + +### Parameters +| Field | Type | +| ----- | ---- | +| np | [NetworkPlayer](structs.md#NetworkPlayer) | +| location | `string` | + +### Returns +- None + +### C Prototype +`void network_player_set_override_location(struct NetworkPlayer *np, const char *location);` + +[:arrow_up_small:](#) + +
+ ## [network_player_set_override_palette_color](#network_player_set_override_palette_color) ### Lua Example diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 9e36d7a89..74826ced0 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -824,6 +824,24 @@
+## [camera_get_checking_surfaces](#camera_get_checking_surfaces) + +### Lua Example +`local booleanValue = camera_get_checking_surfaces()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_get_checking_surfaces(void);` + +[:arrow_up_small:](#) + +
+ ## [camera_is_frozen](#camera_is_frozen) ### Lua Example @@ -900,6 +918,26 @@
+## [camera_set_checking_surfaces](#camera_set_checking_surfaces) + +### Lua Example +`camera_set_checking_surfaces(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_set_checking_surfaces(bool value);` + +[:arrow_up_small:](#) + +
+ ## [camera_set_romhack_override](#camera_set_romhack_override) ### Lua Example @@ -1763,31 +1801,30 @@
-## [max](#max) +## [degrees_to_sm64](#degrees_to_sm64) ### Lua Example -`local integerValue = max(a, b)` +`local integerValue = degrees_to_sm64(degreesAngle)` ### Parameters | Field | Type | | ----- | ---- | -| a | `integer` | -| b | `integer` | +| degreesAngle | `number` | ### Returns - `integer` ### C Prototype -`s32 max(s32 a, s32 b);` +`s16 degrees_to_sm64(f32 degreesAngle);` [:arrow_up_small:](#)
-## [maxf](#maxf) +## [hypotf](#hypotf) ### Lua Example -`local numberValue = maxf(a, b)` +`local numberValue = hypotf(a, b)` ### Parameters | Field | Type | @@ -1799,89 +1836,67 @@ - `number` ### C Prototype -`f32 maxf(f32 a, f32 b);` +`f32 hypotf(f32 a, f32 b);` [:arrow_up_small:](#)
-## [min](#min) +## [radians_to_sm64](#radians_to_sm64) ### Lua Example -`local integerValue = min(a, b)` +`local integerValue = radians_to_sm64(radiansAngle)` ### Parameters | Field | Type | | ----- | ---- | -| a | `integer` | -| b | `integer` | +| radiansAngle | `number` | ### Returns - `integer` ### C Prototype -`s32 min(s32 a, s32 b);` +`s16 radians_to_sm64(f32 radiansAngle);` [:arrow_up_small:](#)
-## [minf](#minf) +## [sm64_to_degrees](#sm64_to_degrees) ### Lua Example -`local numberValue = minf(a, b)` +`local numberValue = sm64_to_degrees(sm64Angle)` ### Parameters | Field | Type | | ----- | ---- | -| a | `number` | -| b | `number` | +| sm64Angle | `integer` | ### Returns - `number` ### C Prototype -`f32 minf(f32 a, f32 b);` +`f32 sm64_to_degrees(s16 sm64Angle);` [:arrow_up_small:](#)
-## [sqr](#sqr) +## [sm64_to_radians](#sm64_to_radians) ### Lua Example -`local integerValue = sqr(x)` +`local numberValue = sm64_to_radians(sm64Angle)` ### Parameters | Field | Type | | ----- | ---- | -| x | `integer` | - -### Returns -- `integer` - -### C Prototype -`s32 sqr(s32 x);` - -[:arrow_up_small:](#) - -
- -## [sqrf](#sqrf) - -### Lua Example -`local numberValue = sqrf(x)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | +| sm64Angle | `integer` | ### Returns - `number` ### C Prototype -`f32 sqrf(f32 x);` +`f32 sm64_to_radians(s16 sm64Angle);` [:arrow_up_small:](#) @@ -1953,6 +1968,24 @@
+## [djui_attempting_to_open_playerlist](#djui_attempting_to_open_playerlist) + +### Lua Example +`local booleanValue = djui_attempting_to_open_playerlist()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool djui_attempting_to_open_playerlist(void);` + +[:arrow_up_small:](#) + +
+ ## [djui_is_playerlist_open](#djui_is_playerlist_open) ### Lua Example @@ -2066,6 +2099,26 @@
+## [get_coopnet_id](#get_coopnet_id) + +### Lua Example +`local stringValue = get_coopnet_id(localIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| localIndex | `integer` | + +### Returns +- `string` + +### C Prototype +`const char* get_coopnet_id(s8 localIndex);` + +[:arrow_up_small:](#) + +
+ ## [get_current_save_file_num](#get_current_save_file_num) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 51c3307ec..a762da90f 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -748,6 +748,7 @@ - [djui_hud_get_color](functions-3.md#djui_hud_get_color) - [djui_hud_get_filter](functions-3.md#djui_hud_get_filter) - [djui_hud_get_font](functions-3.md#djui_hud_get_font) + - [djui_hud_get_fov_coeff](functions-3.md#djui_hud_get_fov_coeff) - [djui_hud_get_mouse_x](functions-3.md#djui_hud_get_mouse_x) - [djui_hud_get_mouse_y](functions-3.md#djui_hud_get_mouse_y) - [djui_hud_get_raw_mouse_x](functions-3.md#djui_hud_get_raw_mouse_x) @@ -772,6 +773,7 @@ - [djui_hud_set_rotation_interpolated](functions-3.md#djui_hud_set_rotation_interpolated) - [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos) - [djui_open_pause_menu](functions-3.md#djui_open_pause_menu) + - [get_current_fov](functions-3.md#get_current_fov)
@@ -1134,8 +1136,14 @@ - [anim_spline_poll](functions-4.md#anim_spline_poll) - [approach_f32](functions-4.md#approach_f32) - [approach_s32](functions-4.md#approach_s32) + - [atan2s](functions-4.md#atan2s) + - [coss](functions-4.md#coss) - [find_vector_perpendicular_to_plane](functions-4.md#find_vector_perpendicular_to_plane) - [get_pos_from_transform_mtx](functions-4.md#get_pos_from_transform_mtx) + - [max](functions-4.md#max) + - [maxf](functions-4.md#maxf) + - [min](functions-4.md#min) + - [minf](functions-4.md#minf) - [mtxf_align_terrain_normal](functions-4.md#mtxf_align_terrain_normal) - [mtxf_align_terrain_triangle](functions-4.md#mtxf_align_terrain_triangle) - [mtxf_billboard](functions-4.md#mtxf_billboard) @@ -1153,7 +1161,10 @@ - [mtxf_to_mtx](functions-4.md#mtxf_to_mtx) - [mtxf_translate](functions-4.md#mtxf_translate) - [not_zero](functions-4.md#not_zero) + - [sins](functions-4.md#sins) - [spline_get_weights](functions-4.md#spline_get_weights) + - [sqr](functions-4.md#sqr) + - [sqrf](functions-4.md#sqrf) - [vec3f_add](functions-4.md#vec3f_add) - [vec3f_combine](functions-4.md#vec3f_combine) - [vec3f_copy](functions-4.md#vec3f_copy) @@ -1205,6 +1216,7 @@ - [network_player_is_override_palette_same](functions-4.md#network_player_is_override_palette_same) - [network_player_reset_override_palette](functions-4.md#network_player_reset_override_palette) - [network_player_set_description](functions-4.md#network_player_set_description) + - [network_player_set_override_location](functions-4.md#network_player_set_override_location) - [network_player_set_override_palette_color](functions-4.md#network_player_set_override_palette_color)
@@ -1641,10 +1653,12 @@ - [camera_config_set_x_sensitivity](functions-5.md#camera_config_set_x_sensitivity) - [camera_config_set_y_sensitivity](functions-5.md#camera_config_set_y_sensitivity) - [camera_freeze](functions-5.md#camera_freeze) + - [camera_get_checking_surfaces](functions-5.md#camera_get_checking_surfaces) - [camera_is_frozen](functions-5.md#camera_is_frozen) - [camera_reset_overrides](functions-5.md#camera_reset_overrides) - [camera_romhack_allow_centering](functions-5.md#camera_romhack_allow_centering) - [camera_romhack_allow_dpad_usage](functions-5.md#camera_romhack_allow_dpad_usage) + - [camera_set_checking_surfaces](functions-5.md#camera_set_checking_surfaces) - [camera_set_romhack_override](functions-5.md#camera_set_romhack_override) - [camera_unfreeze](functions-5.md#camera_unfreeze) @@ -1706,12 +1720,11 @@ - smlua_math_utils.h - [clamp](functions-5.md#clamp) - [clampf](functions-5.md#clampf) - - [max](functions-5.md#max) - - [maxf](functions-5.md#maxf) - - [min](functions-5.md#min) - - [minf](functions-5.md#minf) - - [sqr](functions-5.md#sqr) - - [sqrf](functions-5.md#sqrf) + - [degrees_to_sm64](functions-5.md#degrees_to_sm64) + - [hypotf](functions-5.md#hypotf) + - [radians_to_sm64](functions-5.md#radians_to_sm64) + - [sm64_to_degrees](functions-5.md#sm64_to_degrees) + - [sm64_to_radians](functions-5.md#sm64_to_radians)
@@ -1719,12 +1732,14 @@ - [allocate_mario_action](functions-5.md#allocate_mario_action) - [course_is_main_course](functions-5.md#course_is_main_course) - [deref_s32_pointer](functions-5.md#deref_s32_pointer) + - [djui_attempting_to_open_playerlist](functions-5.md#djui_attempting_to_open_playerlist) - [djui_is_playerlist_open](functions-5.md#djui_is_playerlist_open) - [djui_is_popup_disabled](functions-5.md#djui_is_popup_disabled) - [djui_menu_get_font](functions-5.md#djui_menu_get_font) - [djui_popup_create_global](functions-5.md#djui_popup_create_global) - [djui_reset_popup_disabled_override](functions-5.md#djui_reset_popup_disabled_override) - [djui_set_popup_disabled_override](functions-5.md#djui_set_popup_disabled_override) + - [get_coopnet_id](functions-5.md#get_coopnet_id) - [get_current_save_file_num](functions-5.md#get_current_save_file_num) - [get_date_and_time](functions-5.md#get_date_and_time) - [get_dialog_box_state](functions-5.md#get_dialog_box_state) diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index 554ba2f37..9fbfa6a32 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -137,6 +137,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | HOOK_ON_ATTACK_OBJECT | Called when a player attacks an object. May be double-fired in some cases, you'll need to write special code for this | [MarioState](structs.md#MarioState) attacker, [Object](structs.md#Object) victim, `integer` interactionId | | HOOK_ON_LANGUAGE_CHANGED | Called when the language is changed | `string` language | | HOOK_ON_MODS_LOADED | Called directly after every mod file is loaded in by smlua | None | +| HOOK_ON_NAMETAGS_RENDER | Called when nametags are rendered. Return a `string` to change what renders on the nametag, return an empty `string` to render nothing. | `string` playerIndex | ### Parameters diff --git a/docs/lua/guides/vs-code-setup.md b/docs/lua/guides/vs-code-setup.md index bb4ccac60..ff4da1012 100644 --- a/docs/lua/guides/vs-code-setup.md +++ b/docs/lua/guides/vs-code-setup.md @@ -28,7 +28,7 @@ Setting up Visual Studio Code will allow you to have all of the modern benefits --- -5. Add a new item containing the location of `/autogen/lua_definitions` +5. Add a new item containing the location of `/autogen/lua_definitions` ![lua-definitions](https://user-images.githubusercontent.com/12403224/158046824-1894318a-7ce9-41ef-bacc-17f95fa05f31.png) diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 619a95dc7..ea9e66cf9 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -745,6 +745,7 @@ | ----- | ---- | ------ | | buttonDown | `integer` | | | buttonPressed | `integer` | | +| buttonReleased | `integer` | | | extStickX | `integer` | | | extStickY | `integer` | | | port | `integer` | | @@ -1543,6 +1544,7 @@ | modelIndex | `integer` | read-only | | name | `string` | read-only | | onRxSeqId | `integer` | read-only | +| overrideLocation | `string` | read-only | | overrideModelIndex | `integer` | | | overridePalette | [PlayerPalette](structs.md#PlayerPalette) | | | palette | [PlayerPalette](structs.md#PlayerPalette) | read-only | diff --git a/include/types.h b/include/types.h index a39ec00be..9ff10e0f2 100644 --- a/include/types.h +++ b/include/types.h @@ -28,9 +28,10 @@ struct Controller /*0x0C*/ f32 stickMag; // distance from center [0, 64] /*0x10*/ u16 buttonDown; /*0x12*/ u16 buttonPressed; - /*0x14*/ OSContStatus *statusData; - /*0x18*/ OSContPad *controllerData; - /*0x1C*/ s32 port; + /*0x14*/ u16 buttonReleased; + /*0x18*/ OSContStatus *statusData; + /*0x1C*/ OSContPad *controllerData; + /*0x20*/ s32 port; /*ext */ s16 extStickX; // additional (right) stick values /*ext */ s16 extStickY; }; diff --git a/levels/intro/script.c b/levels/intro/script.c index a130cc04e..f5fcbfb1b 100644 --- a/levels/intro/script.c +++ b/levels/intro/script.c @@ -63,7 +63,8 @@ const LevelScript level_intro_mario_head_regular[] = { TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_STAR, /*time*/ 20, /*color*/ 0x00, 0x00, 0x00), SLEEP(/*frames*/ 20), CALL_LOOP(/*arg*/ 1, /*func*/ lvl_intro_update), - JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1), + // JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1), + JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L4), JUMP_IF(/*op*/ OP_EQ, /*arg*/ 101, script_intro_L2), JUMP(script_intro_L4), }; @@ -88,7 +89,8 @@ const LevelScript level_intro_mario_head_dizzy[] = { TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_STAR, /*time*/ 20, /*color*/ 0x00, 0x00, 0x00), SLEEP(/*frames*/ 20), CALL_LOOP(/*arg*/ 2, /*func*/ lvl_intro_update), - JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1), + // JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1), + JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L4), JUMP_IF(/*op*/ OP_EQ, /*arg*/ 101, script_intro_L2), JUMP(script_intro_L4), }; diff --git a/lib/coopnet/README.md b/lib/coopnet/README.md new file mode 100644 index 000000000..d0d2257e8 --- /dev/null +++ b/lib/coopnet/README.md @@ -0,0 +1 @@ +Source code for coopnet is available at https://github.com/Isaac0-dev/coopnet diff --git a/lib/coopnet/linux/libcoopnet.a b/lib/coopnet/linux/libcoopnet.a index 5625c083e..161180ba9 100644 Binary files a/lib/coopnet/linux/libcoopnet.a and b/lib/coopnet/linux/libcoopnet.a differ diff --git a/lib/coopnet/win64/libcoopnet.a b/lib/coopnet/win64/libcoopnet.a index 2362238a1..1613bb7c5 100644 Binary files a/lib/coopnet/win64/libcoopnet.a and b/lib/coopnet/win64/libcoopnet.a differ diff --git a/mods/char-select-cjes-and-vl/a-constants.lua b/mods/char-select-cjes-and-vl/a-constants.lua index 2c2e5219f..84a3a77c9 100644 --- a/mods/char-select-cjes-and-vl/a-constants.lua +++ b/mods/char-select-cjes-and-vl/a-constants.lua @@ -4,7 +4,7 @@ if not _G.charSelectExists then if not first then first = true play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource) - djui_chat_message_create("\\#ffffa0\\Extra Characters requires Character Select to be enabled.\nPlease rehost with it enabled.") + djui_chat_message_create("\\#ffffa0\\[CS] VL-Tone & Cjes Luigi requires Character Select to be enabled.\nPlease rehost with it enabled.") end end) return @@ -13,4 +13,4 @@ end MOD_VERSION = "v4.1" E_MODEL_VL = smlua_model_util_get_id("vl_geo") -E_MODEL_CJES = smlua_model_util_get_id("cjes_geo") \ No newline at end of file +E_MODEL_CJES = smlua_model_util_get_id("cjes_geo") diff --git a/mods/char-select-extra-chars/birdo.lua b/mods/char-select-extra-chars/birdo.lua index 4879b6597..1c827b76b 100644 --- a/mods/char-select-extra-chars/birdo.lua +++ b/mods/char-select-extra-chars/birdo.lua @@ -33,7 +33,7 @@ VOICETABLE_BIRDO = { [CHAR_SOUND_SO_LONGA_BOWSER] = "birdo_solonga_bowser.ogg", [CHAR_SOUND_SNORING1] = "birdo_snoring1.ogg", [CHAR_SOUND_SNORING2] = "birdo_snoring2.ogg", - [CHAR_SOUND_SNORING3] = { "birdo_snoring2.ogg", "birdo_snoring1.ogg", "birdo_snoring3.ogg" }, + [CHAR_SOUND_SNORING3] = { "birdo_snoring1.ogg", "birdo_snoring2.ogg" }, [CHAR_SOUND_TWIRL_BOUNCE] = "birdo_twirl_bounce.ogg", [CHAR_SOUND_UH] = "birdo_uh.ogg", [CHAR_SOUND_UH2] = "birdo_uh2.ogg", diff --git a/mods/char-select-extra-chars/sound/yoshi_yah_wah_hoo1.ogg b/mods/char-select-extra-chars/sound/yoshi_yah_wah_hoo1.ogg index 1aa31fdda..c3c2a958a 100644 Binary files a/mods/char-select-extra-chars/sound/yoshi_yah_wah_hoo1.ogg and b/mods/char-select-extra-chars/sound/yoshi_yah_wah_hoo1.ogg differ diff --git a/mods/char-select-extra-chars/textures/toadette_icon.tex b/mods/char-select-extra-chars/textures/toadette_icon.tex index 38e92173b..098718018 100644 Binary files a/mods/char-select-extra-chars/textures/toadette_icon.tex and b/mods/char-select-extra-chars/textures/toadette_icon.tex differ diff --git a/mods/char-select-extra-chars/toadette.lua b/mods/char-select-extra-chars/toadette.lua index 8011dba56..cab51439b 100644 --- a/mods/char-select-extra-chars/toadette.lua +++ b/mods/char-select-extra-chars/toadette.lua @@ -66,7 +66,7 @@ local PALETTE_TOADETTE = { [SHIRT] = { r = 0xFF, g = 0x00, b = 0x00 }, [GLOVES] = { r = 0xFF, g = 0xFF, b = 0xFF }, [SHOES] = { r = 0x68, g = 0x40, b = 0x1B }, - [HAIR] = { r = 0xFF, g = 0x00, b = 0x00 }, + [HAIR] = { r = 0x73, g = 0x06, b = 0x00 }, [SKIN] = { r = 0xFE, g = 0xD5, b = 0xA1 }, [CAP] = { r = 0xF3, g = 0x00, b = 0x80 }, [EMBLEM] = { r = 0xF3, g = 0x00, b = 0x80 } @@ -74,4 +74,4 @@ local PALETTE_TOADETTE = { _G.CT_TOADETTE = _G.charSelect.character_add("Toadette", {"A very bubbly female toad", "who has a hobby of construction!", "Although she hates the union.", "Wonder why?", "", "Voiced by: Melissa Mekrose."}, "FluffaMario & AngelicMiracles", { r = 255, g = 70, b = 161 }, E_MODEL_TOADETTE, CT_TOAD, TEX_TOADETTE) _G.charSelect.character_add_voice(E_MODEL_TOADETTE, VOICETABLE_TOADETTE) -_G.charSelect.character_add_palette_preset(E_MODEL_TOADETTE, PALETTE_TOADETTE) \ No newline at end of file +_G.charSelect.character_add_palette_preset(E_MODEL_TOADETTE, PALETTE_TOADETTE) diff --git a/mods/char-select-extra-chars/z-voices.lua b/mods/char-select-extra-chars/z-voices.lua index d47e9f745..da8615396 100644 --- a/mods/char-select-extra-chars/z-voices.lua +++ b/mods/char-select-extra-chars/z-voices.lua @@ -3,11 +3,19 @@ if not _G.charSelectExists then return end +local voiceTables = { + [VOICETABLE_TOADETTE] = true, + [VOICETABLE_YOSHI] = true, + [VOICETABLE_PEACH] = true, + [VOICETABLE_DAISY] = true, + [VOICETABLE_BIRDO] = true +} + --- @param m MarioState local function mario_update(m) if is_player_active(m) == 0 then return end local voiceTable = charSelect.character_get_voice(m) - if voiceTable then + if voiceTables[voiceTable] then return charSelect.voice.snore(m) end end @@ -16,7 +24,7 @@ end --- @param sound CharacterSound local function character_sound(m, sound) local voiceTable = charSelect.character_get_voice(m) - if voiceTable then + if voiceTables[voiceTable] then return charSelect.voice.sound(m, sound) end end diff --git a/mods/character-select-coop/a-utils.lua b/mods/character-select-coop/a-utils.lua index 6d6e2f383..25c788c08 100644 --- a/mods/character-select-coop/a-utils.lua +++ b/mods/character-select-coop/a-utils.lua @@ -118,7 +118,7 @@ charBeingSet = false stopPalettes = false for i in pairs(gActiveMods) do - if (gActiveMods[i].incompatible ~= nil and gActiveMods[i].incompatible:find("gamemode")) and not (gActiveMods[i].name:find("Personal Star Counter EX+")) then + if (gActiveMods[i].incompatible ~= nil and gActiveMods[i].incompatible:find("gamemode")) and not (gActiveMods[i].name:find("Personal Star Counter")) then stopPalettes = true end end diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 021f2b551..65a62c044 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -12,6 +12,55 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wreturn-local-addr" +#if defined(__clang__) || defined(__GNUC__) + +// Use built-in functions when using Clang or GCC +inline f32 minf(f32 a, f32 b) { + return __builtin_fminf(a, b); +} + +inline f32 maxf(f32 a, f32 b) { + return __builtin_fmaxf(a, b); +} + +#else + +// Fallback to the original implementation for iDO +inline f32 minf(f32 a, f32 b) { + return (a <= b) ? a : b; +} + +inline f32 maxf(f32 a, f32 b) { + return (a > b) ? a : b; +} + +#endif + +// The sqr, min, max, and trig functions do not have/need built-ins, so it's safe to leave them as is +inline s16 (min)(s16 a, s16 b) { + return (a <= b) ? a : b; +} + +inline s16 (max)(s16 a, s16 b) { + return (a > b) ? a : b; +} + +inline f32 sqrf(f32 x) { + return x * x; +} + +inline s16 (sqr)(s16 x) { + return x * x; +} + +inline f32 sins(s16 sm64Angle) { + return gSineTable[(u16) (sm64Angle) >> 4]; +} + +inline f32 coss(s16 sm64Angle) { + return gCosineTable[(u16) (sm64Angle) >> 4]; +} + /// Copy vector 'src' to 'dest' void *vec3f_copy(Vec3f dest, Vec3f src) { dest[0] = src[0]; @@ -244,77 +293,67 @@ void mtxf_translate(Mat4 dest, Vec3f b) { * angle allows a bank rotation of the camera. */ void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) { - register f32 invLength; - f32 dx; - f32 dz; - f32 xColY; - f32 yColY; - f32 zColY; - f32 xColZ; - f32 yColZ; - f32 zColZ; - f32 xColX; - f32 yColX; - f32 zColX; + Vec3f forward, right, up; + f32 sinRoll, cosRoll; + f32 dx, dz, xzDist; + f32 invLength; + + forward[0] = from[0] - to[0]; + forward[1] = from[1] - to[1]; + forward[2] = from[2] - to[2]; + invLength = 1.0f / sqrtf(forward[0] * forward[0] + forward[1] * forward[1] + forward[2] * forward[2]); + forward[0] *= invLength; + forward[1] *= invLength; + forward[2] *= invLength; dx = to[0] - from[0]; dz = to[2] - from[2]; + xzDist = dx * dx + dz * dz; + if (xzDist != 0.0f) { + invLength = -1.0f / sqrtf(xzDist); + dx *= invLength; + dz *= invLength; + } else { + dx = dz = 0.0f; + } + + sinRoll = sins(roll); + cosRoll = coss(roll); - invLength = -1.0 / sqrtf(dx * dx + dz * dz); - dx *= invLength; - dz *= invLength; + up[0] = sinRoll * dz; + up[1] = cosRoll; + up[2] = -sinRoll * dx; - yColY = coss(roll); - xColY = sins(roll) * dz; - zColY = -sins(roll) * dx; + right[0] = up[1] * forward[2] - up[2] * forward[1]; + right[1] = up[2] * forward[0] - up[0] * forward[2]; + right[2] = up[0] * forward[1] - up[1] * forward[0]; - xColZ = to[0] - from[0]; - yColZ = to[1] - from[1]; - zColZ = to[2] - from[2]; + invLength = 1.0f / sqrtf(right[0] * right[0] + right[1] * right[1] + right[2] * right[2]); + right[0] *= invLength; + right[1] *= invLength; + right[2] *= invLength; - invLength = -1.0 / sqrtf(xColZ * xColZ + yColZ * yColZ + zColZ * zColZ); - xColZ *= invLength; - yColZ *= invLength; - zColZ *= invLength; + up[0] = forward[1] * right[2] - forward[2] * right[1]; + up[1] = forward[2] * right[0] - forward[0] * right[2]; + up[2] = forward[0] * right[1] - forward[1] * right[0]; + + mtx[0][0] = right[0]; + mtx[1][0] = right[1]; + mtx[2][0] = right[2]; + mtx[3][0] = -(from[0] * right[0] + from[1] * right[1] + from[2] * right[2]); - xColX = yColY * zColZ - zColY * yColZ; - yColX = zColY * xColZ - xColY * zColZ; - zColX = xColY * yColZ - yColY * xColZ; + mtx[0][1] = up[0]; + mtx[1][1] = up[1]; + mtx[2][1] = up[2]; + mtx[3][1] = -(from[0] * up[0] + from[1] * up[1] + from[2] * up[2]); - invLength = 1.0 / sqrtf(xColX * xColX + yColX * yColX + zColX * zColX); + mtx[0][2] = forward[0]; + mtx[1][2] = forward[1]; + mtx[2][2] = forward[2]; + mtx[3][2] = -(from[0] * forward[0] + from[1] * forward[1] + from[2] * forward[2]); - xColX *= invLength; - yColX *= invLength; - zColX *= invLength; - - xColY = yColZ * zColX - zColZ * yColX; - yColY = zColZ * xColX - xColZ * zColX; - zColY = xColZ * yColX - yColZ * xColX; - - invLength = 1.0 / sqrtf(xColY * xColY + yColY * yColY + zColY * zColY); - xColY *= invLength; - yColY *= invLength; - zColY *= invLength; - - mtx[0][0] = xColX; - mtx[1][0] = yColX; - mtx[2][0] = zColX; - mtx[3][0] = -(from[0] * xColX + from[1] * yColX + from[2] * zColX); - - mtx[0][1] = xColY; - mtx[1][1] = yColY; - mtx[2][1] = zColY; - mtx[3][1] = -(from[0] * xColY + from[1] * yColY + from[2] * zColY); - - mtx[0][2] = xColZ; - mtx[1][2] = yColZ; - mtx[2][2] = zColZ; - mtx[3][2] = -(from[0] * xColZ + from[1] * yColZ + from[2] * zColZ); - - mtx[0][3] = 0; - mtx[1][3] = 0; - mtx[2][3] = 0; - mtx[3][3] = 1; + mtx[0][3] = mtx[1][3] = mtx[2][3] = 0.0f; + mtx[3][3] = 1.0f; } /** @@ -823,58 +862,36 @@ f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) { * the resulting angle is in range [0, 0x2000] (1/8 of a circle). */ static u16 atan2_lookup(f32 y, f32 x) { - u16 ret; - - if (x == 0) { - ret = gArctanTable[0]; - } else { - s32 index = (s32)(y / x * 1024 + 0.5f); - if (index >= 0x401 || index < 0) { index = 0; } - ret = gArctanTable[index]; - } - return ret; + s16 idx = (s16)(y / x * 1024.0f + 0.5f); + idx = (idx >= 0 && idx < 0x401) ? idx : 0; + return gArctanTable[idx]; } /** * Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in * the xz-plane, this is commonly called with (z, x) to get a yaw angle. */ -s16 atan2s(f32 y, f32 x) { - u16 ret; +inline s16 atan2s(f32 y, f32 x) { + // Extract sign bits: 1 if negative, 0 otherwise + u8 signx = (x < 0.0f); + u8 signy = (y < 0.0f); - if (x >= 0) { - if (y >= 0) { - if (y >= x) { - ret = atan2_lookup(x, y); - } else { - ret = 0x4000 - atan2_lookup(y, x); - } - } else { - y = -y; - if (y < x) { - ret = 0x4000 + atan2_lookup(y, x); - } else { - ret = 0x8000 - atan2_lookup(x, y); - } - } - } else { - x = -x; - if (y < 0) { - y = -y; - if (y >= x) { - ret = 0x8000 + atan2_lookup(x, y); - } else { - ret = 0xC000 - atan2_lookup(y, x); - } - } else { - if (y < x) { - ret = 0xC000 + atan2_lookup(y, x); - } else { - ret = -atan2_lookup(x, y); - } - } - } - return ret; + // Take absolute values + f32 absx = absx(x); + f32 absy = absx(y); + + // Compute the angle in the first octant + u16 angle = atan2_lookup(min(absx, absy), max(absy, absx)); + + // Create an index based on the signs and swap status + u8 idx = ((absy > absx) << 2) | (signx << 1) | signy; + + // Combined lookup tables for offsets and sign multipliers + static const s16 offsets[] = {0x4000, 0x4000, 0xC000, 0xC000, 0x0000, 0x8000, 0x0000, 0x8000}; + static const s8 signs[] = {-1, 1, 1, -1, 1, -1, -1, 1}; + + // Ensure the result fits into 16 bits via an explicit cast on angle + return (offsets[idx] + (signs[idx] * (s16)angle)) & 0xFFFF; } /** diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 65c9ba6e5..6df41f3af 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -24,9 +24,6 @@ extern f32 gSineTable[]; extern f32 gCosineTable[]; #endif -#define sins(x) gSineTable[(u16) (x) >> 4] -#define coss(x) gCosineTable[(u16) (x) >> 4] - #if defined(min) #undef min #endif @@ -35,13 +32,45 @@ extern f32 gCosineTable[]; #undef max #endif -#define min(a, b) ((a) <= (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) +// Inline Function prototypes +f32 minf(f32 a, f32 b); +s16 min(s16 a, s16 b); +f32 maxf(f32 a, f32 b); +s16 max(s16 a, s16 b); +f32 sqrf(f32 x); +s16 sqr(s16 x); +f32 sins(s16 sm64Angle); +f32 coss(s16 sm64Angle); -#define sqr(x) ((x) * (x)) +#define min(a, b) _Generic((a), \ + f32: minf, \ + default: min \ +)(a, b) + +#define max(a, b) _Generic((a), \ + f32: maxf, \ + default: max \ +)(a, b) + +#define sqr(x) _Generic((x), \ + f32: sqrf, \ + default: sqr \ +)(x) + +#if defined(__clang__) || defined(__GNUC__) + +#define absx(x) _Generic((x), \ + f32: __builtin_fabsf, \ + double: __builtin_fabs, \ + default: __builtin_abs \ +)(x) + +#else #define absx(x) ((x) < 0 ? -(x) : (x)) +#endif + #include "../../include/libc/stdlib.h" void *vec3f_copy(Vec3f dest, Vec3f src); diff --git a/src/game/behaviors/cap.inc.c b/src/game/behaviors/cap.inc.c index 1c9ae2102..84f58e67e 100644 --- a/src/game/behaviors/cap.inc.c +++ b/src/game/behaviors/cap.inc.c @@ -253,6 +253,10 @@ void bhv_normal_cap_loop(void) { if (cap_set_hitbox() == 1) save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND); + if (o->globalPlayerIndex >= MAX_PLAYERS) { + o->globalPlayerIndex = 0; + } + obj_set_model(o, gMarioStates[network_local_index_from_global(o->globalPlayerIndex)].character->capModelId); } diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index f4914c81c..00c1e699c 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -251,6 +251,10 @@ static void chain_chomp_sub_act_lunge(void) { } } +static u8 chain_chomp_released_trigger_cutscene_continue_dialog(void) { + return (o->oChainChompReleaseStatus != CHAIN_CHOMP_RELEASED_END_CUTSCENE); +} + /** * Fall to the ground and interrupt mario into a cutscene action. */ @@ -260,9 +264,20 @@ static void chain_chomp_released_trigger_cutscene(void) { //! Can delay this if we get into a cutscene-unfriendly action after the // last post ground pound and before this - if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { - o->oChainChompReleaseStatus = CHAIN_CHOMP_RELEASED_LUNGE_AROUND; - o->oTimer = 0; + // hack: get the nearest wooden post, this will work properly 99% of the time + struct Object* woodenPost = cur_obj_nearest_object_with_behavior(bhvWoodenPost); + struct MarioState* marioState = nearest_mario_state_to_object(woodenPost); + if (&gMarioStates[0] == marioState) { + if (set_mario_npc_dialog(&gMarioStates[0], 2, chain_chomp_released_trigger_cutscene_continue_dialog) == 2 + && (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) && cutscene_object(CUTSCENE_STAR_SPAWN, o) == 1) { + o->oChainChompReleaseStatus = CHAIN_CHOMP_RELEASED_LUNGE_AROUND; + o->oTimer = 0; + } + } else { + if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { + o->oChainChompReleaseStatus = CHAIN_CHOMP_RELEASED_LUNGE_AROUND; + o->oTimer = 0; + } } } diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index d42787dea..67010f5ab 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -118,16 +118,16 @@ static void eyerok_boss_act_wake_up(void) { } } -u8 eyerok_boss_act_show_intro_text_continue_dialog(void) { return o->oAction == EYEROK_BOSS_ACT_SHOW_INTRO_TEXT; } +static u8 eyerok_boss_act_show_intro_text_continue_dialog(void) { + return o->oAction == EYEROK_BOSS_ACT_SHOW_INTRO_TEXT; +} static void eyerok_boss_act_show_intro_text(void) { - // todo: get dialog working again - /*struct MarioState* marioState = nearest_mario_state_to_object(o); + struct MarioState* marioState = nearest_mario_state_to_object(o); if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 0, CUTSCENE_DIALOG, gBehaviorValues.dialogs.EyerokIntroDialog, eyerok_boss_act_show_intro_text_continue_dialog)) { o->oAction = EYEROK_BOSS_ACT_FIGHT; network_send_object_reliability(o, TRUE); - }*/ - o->oAction = EYEROK_BOSS_ACT_FIGHT; + } } static void eyerok_boss_act_fight(void) { diff --git a/src/game/behaviors/piranha_bubbles.inc.c b/src/game/behaviors/piranha_bubbles.inc.c index b58dfca06..456810396 100644 --- a/src/game/behaviors/piranha_bubbles.inc.c +++ b/src/game/behaviors/piranha_bubbles.inc.c @@ -32,6 +32,9 @@ void bhv_piranha_plant_bubble_loop(void) { f32 scale = 0; s32 i; s32 frame = parent->header.gfx.animInfo.animFrame; + if (frame < 0) { + frame = 0; + } // TODO: rename lastFrame if it is inaccurate if (parent->header.gfx.animInfo.curAnim == NULL) { return; } s32 lastFrame = parent->header.gfx.animInfo.curAnim->loopEnd - 2; diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 3ed0a414a..826802f9c 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -122,6 +122,7 @@ void piranha_plant_act_woken_up(void) { */ o->oDamageOrCoinValue = 3; #endif + if (o->oTimer == 0) stop_secondary_music(50); @@ -270,6 +271,9 @@ void piranha_plant_act_biting(void) { cur_obj_init_animation_with_sound(0); + cur_obj_set_hitbox_radius_and_height(150.0f, 100.0f); + cur_obj_set_hurtbox_radius_and_height(150.0f, 100.0f); + // 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); @@ -368,9 +372,6 @@ void bhv_piranha_plant_loop(void) { sync_object_init_field(o, &o->oTimer); } - cur_obj_set_hitbox_radius_and_height(150.0f, 100.0f); - cur_obj_set_hurtbox_radius_and_height(150.0f, 100.0f); - CUR_OBJ_CALL_ACTION_FUNCTION(TablePiranhaPlantActions); // In WF, hide all Piranha Plants once high enough up. if (gCurrLevelNum == LEVEL_WF) { diff --git a/src/game/behaviors/texscroll.inc.c b/src/game/behaviors/texscroll.inc.c index fc02b2251..a8a8df046 100644 --- a/src/game/behaviors/texscroll.inc.c +++ b/src/game/behaviors/texscroll.inc.c @@ -70,17 +70,14 @@ static inline void shift_UV_NORMAL(struct ScrollTarget *scroll, u16 vertcount, s verts[0]->n.flag++; } else { if (bhv < SCROLL_UV_X) { - u8 bhvIndex = MIN(bhv, 2); for (i = 0; i < vertcount; i++) { - verts[i]->n.ob[bhvIndex] = scroll->interpF32[i]; + scroll->prevF32[i] = scroll->interpF32[i]; } } else { - u8 bhvIndex = MIN(bhv-SCROLL_UV_X, 1); for (i = 0; i < vertcount; i++) { - verts[i]->n.tc[bhvIndex] = scroll->interpS16[i]; + scroll->prevS16[i] = scroll->interpS16[i]; } } - scroll->needInterp = false; } } diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 6d3a861dc..be50ca65c 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -122,26 +122,28 @@ s16 newcam_saved_defmode = -1; extern bool gDjuiInMainMenu; ///This is called at every level initialisation. -void newcam_init(struct Camera *c, UNUSED u8 dv) { +void newcam_init(struct Camera *c, u8 isSoftReset) { newcam_tilt = 1500; newcam_yaw = -c->yaw+0x4000; //Mario and the camera's yaw have this offset between them. newcam_mode = NC_MODE_NORMAL; ///This here will dictate what modes the camera will start in at the beginning of a level. Below are some examples. - switch (gCurrLevelNum) { - case LEVEL_BITDW: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; - case LEVEL_BITFS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; - case LEVEL_BITS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; - case LEVEL_WF: newcam_yaw = 0x4000; newcam_tilt = 2000; break; - case LEVEL_RR: newcam_yaw = 0x6000; newcam_tilt = 2000; break; - case LEVEL_CCM: if (gCurrAreaIndex == 1) {newcam_yaw = -0x4000; newcam_tilt = 2000; } else newcam_mode = NC_MODE_SLIDE; break; - case LEVEL_WDW: newcam_yaw = 0x2000; newcam_tilt = 3000; break; - case 27: newcam_mode = NC_MODE_SLIDE; break; - case LEVEL_TTM: if (gCurrAreaIndex == 2) newcam_mode = NC_MODE_SLIDE; break; - } + if (!isSoftReset) { + switch (gCurrLevelNum) { + case LEVEL_BITDW: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; + case LEVEL_BITFS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; + case LEVEL_BITS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break; + case LEVEL_WF: newcam_yaw = 0x4000; newcam_tilt = 2000; break; + case LEVEL_RR: newcam_yaw = 0x6000; newcam_tilt = 2000; break; + case LEVEL_CCM: if (gCurrAreaIndex == 1) {newcam_yaw = -0x4000; newcam_tilt = 2000; } else newcam_mode = NC_MODE_SLIDE; break; + case LEVEL_WDW: newcam_yaw = 0x2000; newcam_tilt = 3000; break; + case 27: newcam_mode = NC_MODE_SLIDE; break; + case LEVEL_TTM: if (gCurrAreaIndex == 2) newcam_mode = NC_MODE_SLIDE; break; + } - // clear these out when entering a new level to prevent "camera mode buffering" - newcam_saved_defmode = -1; - newcam_saved_mode = -1; + // clear these out when entering a new level to prevent "camera mode buffering" + newcam_saved_defmode = -1; + newcam_saved_mode = -1; + } // this will be set in init_settings() if enabled newcam_active = 0; diff --git a/src/game/camera.c b/src/game/camera.c index 07c2ff451..ddb7545a6 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -36,6 +36,7 @@ #include "pc/lua/smlua_hooks.h" #include "pc/djui/djui.h" #include "first_person_cam.h" +#include "rendering_graph_node.h" #define CBUTTON_MASK (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS) @@ -907,20 +908,21 @@ void pan_ahead_of_player(struct Camera *c) { } s16 find_in_bounds_yaw_wdw_bob_thi(UNUSED Vec3f pos, UNUSED Vec3f origin, s16 yaw) { - // switch (gCurrLevelArea) { - // case AREA_WDW_MAIN: - // yaw = clamp_positions_and_find_yaw(pos, origin, 4508.f, -3739.f, 4508.f, -3739.f); - // break; - // case AREA_BOB: - // yaw = clamp_positions_and_find_yaw(pos, origin, 8000.f, -8000.f, 7050.f, -8000.f); - // break; - // case AREA_THI_HUGE: - // yaw = clamp_positions_and_find_yaw(pos, origin, 8192.f, -8192.f, 8192.f, -8192.f); - // break; - // case AREA_THI_TINY: - // yaw = clamp_positions_and_find_yaw(pos, origin, 2458.f, -2458.f, 2458.f, -2458.f); - // break; - // } + if (!gCameraUseCourseSpecificSettings) { return yaw; } + switch (gCurrLevelArea) { + case AREA_WDW_MAIN: + yaw = clamp_positions_and_find_yaw(pos, origin, 4508.f, -3739.f, 4508.f, -3739.f); + break; + case AREA_BOB: + yaw = clamp_positions_and_find_yaw(pos, origin, 8000.f, -8000.f, 7050.f, -8000.f); + break; + case AREA_THI_HUGE: + yaw = clamp_positions_and_find_yaw(pos, origin, 8192.f, -8192.f, 8192.f, -8192.f); + break; + case AREA_THI_TINY: + yaw = clamp_positions_and_find_yaw(pos, origin, 2458.f, -2458.f, 2458.f, -2458.f); + break; + } return yaw; } @@ -1925,14 +1927,18 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { dist = 300.f; } vec3f_set_dist_and_angle(focus, pos, dist, pitch, yaw); - if (gCurrLevelArea == AREA_WDW_MAIN) { - yaw = clamp_positions_and_find_yaw(pos, focus, 4508.f, -3739.f, 4508.f, -3739.f); - } - if (gCurrLevelArea == AREA_THI_HUGE) { - yaw = clamp_positions_and_find_yaw(pos, focus, 8192.f, -8192.f, 8192.f, -8192.f); - } - if (gCurrLevelArea == AREA_THI_TINY) { - yaw = clamp_positions_and_find_yaw(pos, focus, 2458.f, -2458.f, 2458.f, -2458.f); + + if (!gCameraUseCourseSpecificSettings) { return yaw; } + switch (gCurrLevelArea) { + case AREA_WDW_MAIN: + yaw = clamp_positions_and_find_yaw(pos, focus, 4508.f, -3739.f, 4508.f, -3739.f); + break; + case AREA_THI_HUGE: + yaw = clamp_positions_and_find_yaw(pos, focus, 8192.f, -8192.f, 8192.f, -8192.f); + break; + case AREA_THI_TINY: + yaw = clamp_positions_and_find_yaw(pos, focus, 2458.f, -2458.f, 2458.f, -2458.f); + break; } return yaw; @@ -2424,7 +2430,7 @@ s16 update_default_camera(struct Camera *c) { c->pos[1] = ceilHeight; } } - if (gCurrLevelArea == AREA_WDW_TOWN) { + if (gCameraUseCourseSpecificSettings && gCurrLevelArea == AREA_WDW_TOWN) { yaw = clamp_positions_and_find_yaw(c->pos, c->focus, 2254.f, -3789.f, 3790.f, -2253.f); } return yaw; @@ -3085,7 +3091,7 @@ void update_lakitu(struct Camera *c) { distToFloor = find_floor(gLakituState.pos[0], gLakituState.pos[1] + 20.0f, gLakituState.pos[2], &floor); - gCheckingSurfaceCollisionsForCamera = false; + gCheckingSurfaceCollisionsForCamera = FALSE; if (distToFloor != gLevelValues.floorLowerLimit) { if (gLakituState.pos[1] < (distToFloor += 100.0f)) { gLakituState.pos[1] = distToFloor; @@ -3500,103 +3506,106 @@ void init_camera(struct Camera *c) { marioOffset[2] = 400.f; // Set the camera's starting position or start a cutscene for certain levels - switch (gCurrLevelNum) { - case LEVEL_BOWSER_1: + if (!sSoftResettingCamera) { + switch (gCurrLevelNum) { + case LEVEL_BOWSER_1: #ifndef VERSION_JP - if (gCurrDemoInput == NULL) { + if (gCurrDemoInput == NULL) { + // Make sure Bowser is in a state that we'd start speaking to him in. + obj = find_object_with_behavior(bhvBowser); + if (obj != NULL && obj->oAction != 5) { break; } + + start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); + } else if (gSecondCameraFocus != NULL) { + gSecondCameraFocus->oBowserUnk88 = 2; + } +#else // Make sure Bowser is in a state that we'd start speaking to him in. obj = find_object_with_behavior(bhvBowser); if (obj != NULL && obj->oAction != 5) { break; } start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); - } else if (gSecondCameraFocus != NULL) { - gSecondCameraFocus->oBowserUnk88 = 2; - } -#else - // Make sure Bowser is in a state that we'd start speaking to him in. - obj = find_object_with_behavior(bhvBowser); - if (obj != NULL && obj->oAction != 5) { break; } - - start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); #endif - break; - case LEVEL_BOWSER_2: - // Make sure Bowser is in a state that we'd start speaking to him in. - obj = find_object_with_behavior(bhvBowser); - if (obj != NULL && obj->oAction != 5) { break; } + break; + case LEVEL_BOWSER_2: + // Make sure Bowser is in a state that we'd start speaking to him in. + obj = find_object_with_behavior(bhvBowser); + if (obj != NULL && obj->oAction != 5) { break; } - start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); - break; - case LEVEL_BOWSER_3: - // Make sure Bowser is in a state that we'd start speaking to him in. - obj = find_object_with_behavior(bhvBowser); - if (obj != NULL && obj->oAction != 5) { break; } + start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); + break; + case LEVEL_BOWSER_3: + // Make sure Bowser is in a state that we'd start speaking to him in. + obj = find_object_with_behavior(bhvBowser); + if (obj != NULL && obj->oAction != 5) { break; } - start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); - break; + start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); + break; - //! Hardcoded position checks determine which cutscene to play when Mario enters castle grounds. - case LEVEL_CASTLE_GROUNDS: - if (is_within_100_units_of_mario(-1328.f, 260.f, 4664.f) != 1) { - marioOffset[0] = -400.f; - marioOffset[2] = -800.f; - } - if (is_within_100_units_of_mario(-6901.f, 2376.f, -6509.f) == 1) { - start_cutscene(c, CUTSCENE_EXIT_WATERFALL); - } - if (is_within_100_units_of_mario(5408.f, 4500.f, 3637.f) == 1) { - start_cutscene(c, CUTSCENE_EXIT_FALL_WMOTR); - } - gLakituState.mode = CAMERA_MODE_FREE_ROAM; - break; - case LEVEL_SA: - marioOffset[2] = 200.f; - break; - case LEVEL_CASTLE_COURTYARD: - marioOffset[2] = -300.f; - break; - case LEVEL_LLL: - gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT; - break; - case LEVEL_CASTLE: - marioOffset[2] = 150.f; - break; - case LEVEL_RR: - vec3f_set(sFixedModeBasePosition, -2985.f, 478.f, -5568.f); - break; - } - if ((c->mode == CAMERA_MODE_8_DIRECTIONS) || c->mode == CAMERA_MODE_ROM_HACK) { - gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT; - } - switch (gCurrLevelArea) { - case AREA_SSL_EYEROK: - vec3f_set(marioOffset, 0.f, 500.f, -100.f); - break; - case AREA_CCM_SLIDE: - marioOffset[2] = -300.f; - break; - case AREA_THI_WIGGLER: - marioOffset[2] = -300.f; - break; - case AREA_SL_IGLOO: - marioOffset[2] = -300.f; - break; - case AREA_SL_OUTSIDE: - if (is_within_100_units_of_mario(257.f, 2150.f, 1399.f) == 1) { + //! Hardcoded position checks determine which cutscene to play when Mario enters castle grounds. + case LEVEL_CASTLE_GROUNDS: + if (is_within_100_units_of_mario(-1328.f, 260.f, 4664.f) != 1) { + marioOffset[0] = -400.f; + marioOffset[2] = -800.f; + } + if (is_within_100_units_of_mario(-6901.f, 2376.f, -6509.f) == 1) { + start_cutscene(c, CUTSCENE_EXIT_WATERFALL); + } + if (is_within_100_units_of_mario(5408.f, 4500.f, 3637.f) == 1) { + start_cutscene(c, CUTSCENE_EXIT_FALL_WMOTR); + } + gLakituState.mode = CAMERA_MODE_FREE_ROAM; + break; + case LEVEL_SA: + marioOffset[2] = 200.f; + break; + case LEVEL_CASTLE_COURTYARD: marioOffset[2] = -300.f; - } - break; - case AREA_CCM_OUTSIDE: + break; + case LEVEL_LLL: + gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT; + break; + case LEVEL_CASTLE: + marioOffset[2] = 150.f; + break; + case LEVEL_RR: + vec3f_set(sFixedModeBasePosition, -2985.f, 478.f, -5568.f); + break; + } + + if ((c->mode == CAMERA_MODE_8_DIRECTIONS) || c->mode == CAMERA_MODE_ROM_HACK) { gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT; - break; - case AREA_TTM_OUTSIDE: - gLakituState.mode = CAMERA_MODE_RADIAL; - break; + } + + switch (gCurrLevelArea) { + case AREA_SSL_EYEROK: + vec3f_set(marioOffset, 0.f, 500.f, -100.f); + break; + case AREA_CCM_SLIDE: + marioOffset[2] = -300.f; + break; + case AREA_THI_WIGGLER: + marioOffset[2] = -300.f; + break; + case AREA_SL_IGLOO: + marioOffset[2] = -300.f; + break; + case AREA_SL_OUTSIDE: + if (is_within_100_units_of_mario(257.f, 2150.f, 1399.f) == 1) { + marioOffset[2] = -300.f; + } + break; + case AREA_CCM_OUTSIDE: + gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT; + break; + case AREA_TTM_OUTSIDE: + gLakituState.mode = CAMERA_MODE_RADIAL; + break; + } } if (sSoftResettingCamera) { c->cutscene = 0; - sSoftResettingCamera = FALSE; } else { // Set the camera pos to marioOffset (relative to Mario), added to Mario's position offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle); @@ -3621,8 +3630,10 @@ void init_camera(struct Camera *c) { c->yaw = gLakituState.yaw; c->nextYaw = gLakituState.yaw; - newcam_init(c, 0); + newcam_init(c, sSoftResettingCamera); newcam_init_settings(); + + sSoftResettingCamera = FALSE; } /** @@ -12027,7 +12038,7 @@ Gfx *geo_camera_fov(s32 callContext, struct GraphNode *g, UNUSED void *context) } } - perspective->fov = gFOVState.fov; + perspective->fov = get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(gFOVState.fov, gOverrideFOV); shake_camera_fov(perspective); return NULL; } @@ -12299,9 +12310,9 @@ void mode_rom_hack_camera(struct Camera *c) { if (gMarioStates[0].controller->buttonPressed & U_JPAD) { sRomHackYaw = DEGREES(180 + 90) - gMarioStates[0].faceAngle[1]; } else if (gMarioStates[0].controller->buttonDown & L_JPAD) { - sRomHackYaw -= DEGREES(1) * (camera_config_is_x_inverted() ? -1 : 1); + sRomHackYaw -= DEGREES(0.5) * (camera_config_is_x_inverted() ? -1 : 1); } else if (gMarioStates[0].controller->buttonDown & R_JPAD) { - sRomHackYaw += DEGREES(1) * (camera_config_is_x_inverted() ? -1 : 1); + sRomHackYaw += DEGREES(0.5) * (camera_config_is_x_inverted() ? -1 : 1); } else if (gMarioStates[0].controller->buttonPressed & D_JPAD) { sRomHackYaw = snap_to_45_degrees(sRomHackYaw); } @@ -12331,6 +12342,22 @@ void mode_rom_hack_camera(struct Camera *c) { pos[1] = mPos[1] + desiredHeight; pos[2] = mPos[2] + sins(sRomHackYaw) * desiredDist; + // Move camera down for hangable ceilings + if (sMarioCamState->action & ACT_FLAG_HANGING) { + f32 marioCeilHeight = sMarioGeometry.currCeilHeight; + f32 marioFloorHeight = sMarioGeometry.currFloorHeight; + + if (marioFloorHeight < marioCeilHeight - 400.f) { + marioFloorHeight = marioCeilHeight - 400.f; + } + + f32 goalHeight = marioFloorHeight + (marioCeilHeight - marioFloorHeight) * 0.4f; + + if (pos[1] - 400 > goalHeight) { + pos[1] -= 400; + } + } + if (rom_hack_cam_can_see_mario(pos)) { // we can see mario, no need to adjust c->pos[0] = pos[0]; diff --git a/src/game/game_init.c b/src/game/game_init.c index b1ffd6547..17928cafc 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -476,8 +476,8 @@ void read_controller_inputs(void) { controller->rawStickY = controller->controllerData->stick_y; controller->extStickX = controller->controllerData->ext_stick_x; controller->extStickY = controller->controllerData->ext_stick_y; - controller->buttonPressed = controller->controllerData->button - & (controller->controllerData->button ^ controller->buttonDown); + controller->buttonPressed = (~controller->buttonDown & controller->controllerData->button); + controller->buttonReleased = (~controller->controllerData->button & controller->buttonDown); // 0.5x A presses are a good meme controller->buttonDown = controller->controllerData->button; adjust_analog_stick(controller); @@ -488,6 +488,7 @@ void read_controller_inputs(void) { controller->extStickX = 0; controller->extStickY = 0; controller->buttonPressed = 0; + controller->buttonReleased = 0; controller->buttonDown = 0; controller->stickX = 0; controller->stickY = 0; @@ -505,6 +506,7 @@ void read_controller_inputs(void) { gPlayer3Controller->stickY = gPlayer1Controller->stickY; gPlayer3Controller->stickMag = gPlayer1Controller->stickMag; gPlayer3Controller->buttonPressed = gPlayer1Controller->buttonPressed; + gPlayer3Controller->buttonReleased = gPlayer1Controller->buttonReleased; gPlayer3Controller->buttonDown = gPlayer1Controller->buttonDown;*/ } diff --git a/src/game/hud.c b/src/game/hud.c index ce35b8e62..f28dca432 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -666,18 +666,5 @@ void render_hud(void) { if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && showHud) { render_hud_timer(); } - - extern bool configLuaProfiler; - if (configLuaProfiler) { - extern void lua_profiler_update_counters(); - lua_profiler_update_counters(); - } -#ifdef DEVELOPMENT - extern bool configCtxProfiler; - if (configCtxProfiler) { - extern void ctx_profiler_update_counters(); - ctx_profiler_update_counters(); - } -#endif } } diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index a559852e8..bf7304bf2 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -3269,7 +3269,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) { gMarioStates[0].numLives++; } } else { - if (gCourseCompleteCoins % gLevelValues.numCoinsToLife == 0 && gCourseCompleteCoins > 0) { + if (gLevelValues.numCoinsToLife != 0 && gCourseCompleteCoins % gLevelValues.numCoinsToLife == 0 && gCourseCompleteCoins > 0) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); gMarioStates[0].numLives++; } diff --git a/src/game/interaction.c b/src/game/interaction.c index 21c0a24b3..b6f34487b 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -88,7 +88,6 @@ static u32 sBackwardKnockbackActions[][3] = { }; static u8 sDisplayingDoorText = FALSE; -static u8 sCanInteractDoor = TRUE; static u8 sJustTeleported = FALSE; u8 gPssSlideStarted = FALSE; extern u8 gLastCollectedStarOrKey; @@ -158,8 +157,9 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) { } if (interaction == 0 && action & ACT_FLAG_ATTACKING) { - u32 flags = (o->oInteractType & INTERACT_PLAYER) ? (MARIO_PUNCHING | MARIO_KICKING) : (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING); - if (m->flags & flags) { + u32 flags = (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING); + if ((action == ACT_PUNCHING || action == ACT_MOVE_PUNCHING || action == ACT_JUMP_KICK) || + (m->flags & flags && interaction & INT_LUA)) { s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; if (m->flags & MARIO_PUNCHING) { @@ -237,6 +237,7 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) { u32 attack_object(struct MarioState* m, struct Object *o, s32 interaction) { if (!o) { return 0; } u32 attackType = 0; + interaction &= ~INT_LUA; switch (interaction) { case INT_GROUND_POUND: @@ -672,7 +673,8 @@ u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { if (!is_player_active(m2)) { continue; } if (m2->marioObj == NULL) { continue; } if (m2->marioObj != m->interactObj) { continue; } - if (m2->action == ACT_JUMP_KICK) { scaler = 2; } + if (m2->action == ACT_JUMP_KICK) { scaler = 2.0f; } + if (m2->action == ACT_DIVE) { scaler += fabs(m2->forwardVel * 0.01); } if (m2->flags & MARIO_METAL_CAP) { scaler *= 1.25f; } break; } @@ -1048,7 +1050,7 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object * u32 display_door_dialog(struct MarioState *m, u32 actionArg) { if (!m) { return FALSE; } if (m != &gMarioStates[0]) { return FALSE; } - return sCanInteractDoor ? set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, actionArg) : FALSE; + return (!sDisplayingDoorText) ? set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, actionArg) : FALSE; } u8 prevent_interact_door(struct MarioState* m, struct Object* o) { @@ -1082,7 +1084,6 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj if (!(saveFlags & SAVE_FLAG_HAVE_KEY_2)) { if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_1) ? gBehaviorValues.dialogs.KeyDoor1HaveDialog : gBehaviorValues.dialogs.KeyDoor1DontHaveDialog)) { sDisplayingDoorText = TRUE; - sCanInteractDoor = FALSE; } return FALSE; } @@ -1094,7 +1095,6 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj if (!(saveFlags & SAVE_FLAG_HAVE_KEY_1)) { if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_2) ? gBehaviorValues.dialogs.KeyDoor2HaveDialog : gBehaviorValues.dialogs.KeyDoor2DontHaveDialog)) { sDisplayingDoorText = TRUE; - sCanInteractDoor = FALSE; } return FALSE; } @@ -1225,16 +1225,8 @@ u32 interact_door(struct MarioState *m, UNUSED u32 interactType, struct Object * text += requiredNumStars - numStars; - if ((requiredNumStars == 70) || display_door_dialog(m, text)) { - if (requiredNumStars == 70) { - m->interactObj = o; - m->usedObj = o; - set_mario_action(m, ACT_ENTERING_STAR_DOOR, should_push_or_pull_door(m, o)); - } - sDisplayingDoorText = TRUE; - sCanInteractDoor = FALSE; - return TRUE; - } + sDisplayingDoorText = TRUE; + return set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, text); } } else if (m->action == ACT_IDLE && sDisplayingDoorText == TRUE && requiredNumStars == 70) { m->interactObj = o; @@ -1327,10 +1319,11 @@ static u8 resolve_player_collision(struct MarioState* m, struct MarioState* m2) } u8 determine_player_damage_value(u32 interaction) { - if (interaction & INT_GROUND_POUND_OR_TWIRL) { return 3; } + if (interaction & INT_GROUND_POUND) { return 4; } + if (interaction & (INT_TWIRL | INT_PUNCH | INT_TRIP)) { return 3; } if (interaction & INT_KICK) { return 2; } - if (interaction & INT_ATTACK_SLIDE) { return 1; } - return 2; + if (interaction & INT_SLIDE_KICK) { return 2; } + return 1; } u8 player_is_sliding(struct MarioState* m) { @@ -1877,7 +1870,7 @@ u32 interact_breakable(struct MarioState *m, UNUSED u32 interactType, struct Obj m->interactObj = o; - switch (interaction) { + switch (interaction & ~INT_LUA) { case INT_HIT_FROM_ABOVE: bounce_off_object(m, o, 30.0f); //! Not in the 0x8F mask break; @@ -1909,7 +1902,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O if (!(m->action & ACT_FLAG_RIDING_SHELL)) { u32 interaction = determine_interaction(m, o); - if (interaction == INT_HIT_FROM_ABOVE || m->action == ACT_WALKING + if (interaction & INT_HIT_FROM_ABOVE || m->action == ACT_WALKING || m->action == ACT_HOLD_WALKING) { m->interactObj = o; m->usedObj = o; @@ -2322,13 +2315,12 @@ void mario_process_interactions(struct MarioState *m) { check_kick_or_punch_wall(m); m->flags &= ~MARIO_PUNCHING & ~MARIO_KICKING & ~MARIO_TRIPPING; - if (!(m->marioObj->collidedObjInteractTypes & (INTERACT_WARP_DOOR | INTERACT_DOOR))) { - sDisplayingDoorText = FALSE; - sCanInteractDoor = TRUE; - } - if (!(m->marioObj->collidedObjInteractTypes & INTERACT_WARP)) { - if (m == &gMarioStates[0]) { - // limit to only local mario + // limit to only local mario + if (m == &gMarioStates[0]) { + if (!(m->marioObj->collidedObjInteractTypes & (INTERACT_WARP_DOOR | INTERACT_DOOR))) { + sDisplayingDoorText = FALSE; + } + if (!(m->marioObj->collidedObjInteractTypes & INTERACT_WARP)) { sJustTeleported = FALSE; } } diff --git a/src/game/interaction.h b/src/game/interaction.h index 9f5526c2b..045937a87 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -53,6 +53,7 @@ enum InteractionFlag { INT_HIT_FROM_BELOW = /* 0x00000080 */ (1 << 7), INT_TWIRL = /* 0x00000100 */ (1 << 8), INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL), + INT_LUA = /* 0x10000000 */ (1 << 31) , }; #define INT_ATTACK_NOT_FROM_BELOW (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE) diff --git a/src/game/level_update.c b/src/game/level_update.c index 14f5a948b..b14fa4698 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -251,7 +251,7 @@ u16 level_control_timer(s32 timerOp) { u32 pressed_pause(void) { if (gServerSettings.pauseAnywhere) { - if (get_dialog_id() < 0 && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE) { + if (get_dialog_id() < 0) { return gPlayer1Controller->buttonPressed & START_BUTTON; } } else { @@ -1121,7 +1121,7 @@ void update_hud_values(void) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); } } else { - if (gHudDisplay.coins % gLevelValues.numCoinsToLife == 0 && gHudDisplay.coins > 0) { + if (gLevelValues.numCoinsToLife != 0 && gHudDisplay.coins % gLevelValues.numCoinsToLife == 0 && gHudDisplay.coins > 0) { gMarioState->numLives++; play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 7db25ecf8..d7394b9b2 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -389,7 +389,7 @@ u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object) // 0 = not in dialog // 1 = starting dialog // 2 = speaking -s32 set_mario_npc_dialog(struct MarioState* m, s32 actionArg, UNUSED u8 (*inContinueDialogFunction)(void)) { +s32 set_mario_npc_dialog(struct MarioState* m, s32 actionArg, u8 (*inContinueDialogFunction)(void)) { if (!m) { return 0; } s32 dialogState = 0; diff --git a/src/game/memory.c b/src/game/memory.c index a4da7b705..5a58b85e3 100644 --- a/src/game/memory.c +++ b/src/game/memory.c @@ -4,6 +4,7 @@ #include "memory.h" #include "print.h" #include "pc/debuglog.h" +#include "pc/lua/smlua.h" #define ALIGN16(val) (((val) + 0xF) & ~0xF) @@ -222,7 +223,7 @@ void growing_array_free(struct GrowingArray **array) { if (*array) { for (u32 i = 0; i != (*array)->capacity; ++i) { if ((*array)->buffer[i]) { - free((*array)->buffer[i]); + smlua_free((*array)->buffer[i]); } } free((*array)->buffer); diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 5f2f84536..6db7b6046 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2635,7 +2635,8 @@ s32 cur_obj_is_mario_ground_pounding_platform(void) { if (!is_player_active(&gMarioStates[i])) { continue; } if (!gMarioStates[i].marioObj) { continue; } if (gMarioStates[i].marioObj->platform == o) { - if ((determine_interaction(&gMarioStates[i], o) & INT_GROUND_POUND) || (gMarioStates[i].action == ACT_GROUND_POUND_LAND)) { + u32 interaction = determine_interaction(&gMarioStates[i], o); + if ((gMarioStates[i].action == ACT_GROUND_POUND_LAND) || (interaction & INT_GROUND_POUND && interaction & INT_LUA)) { return TRUE; } } diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index d581145d1..46b66a780 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -237,7 +237,7 @@ void patch_mtx_interpolated(f32 delta) { u16 perspNorm; f32 fovInterpolated = delta_interpolate_f32(sPerspectiveNode->prevFov, sPerspectiveNode->fov, delta); f32 near = MIN(sPerspectiveNode->near, gProjectionMaxNearValue); - guPerspective(sPerspectiveMtx, &perspNorm, get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(fovInterpolated, gOverrideFOV), sPerspectiveAspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(sPerspectiveNode->far, gOverrideFar), 1.0f); + guPerspective(sPerspectiveMtx, &perspNorm, fovInterpolated, sPerspectiveAspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(sPerspectiveNode->far, gOverrideFar), 1.0f); gSPMatrix(sPerspectivePos, VIRTUAL_TO_PHYSICAL(sPerspectiveNode), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH); } @@ -488,7 +488,7 @@ static void geo_process_perspective(struct GraphNodePerspective *node) { gProjectionVanillaNearValue = node->near; gProjectionVanillaFarValue = node->far; f32 near = MIN(node->near, gProjectionMaxNearValue); - guPerspective(mtx, &perspNorm, not_zero(node->prevFov, gOverrideFOV), aspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(node->far, gOverrideFar), 1.0f); + guPerspective(mtx, &perspNorm, node->prevFov, aspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(node->far, gOverrideFar), 1.0f); sPerspectiveNode = node; sPerspectiveMtx = mtx; @@ -616,7 +616,7 @@ static void geo_process_translation_rotation(struct GraphNodeTranslationRotation Mat4 mtxf; Vec3f translation; - // Sanity check our stack index, If we above or equal to our stack size. Return to prevent OOB\. + // Sanity check our stack index, If we above or equal to our stack size. Return to prevent OOB. if ((gMatStackIndex + 1) >= MATRIX_STACK_SIZE) { LOG_ERROR("Preventing attempt to exceed the maximum size %i for our matrix stack with size of %i.", MATRIX_STACK_SIZE - 1, gMatStackIndex); return; } vec3s_to_vec3f(translation, node->translation); @@ -1156,7 +1156,7 @@ static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) { // visibly pop in or out at the edge of the screen. // // Half of the fov in in-game angle units instead of degrees. - s16 halfFov = ((get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(gCurGraphNodeCamFrustum->fov, gOverrideFOV)) / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f; + s16 halfFov = (gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f; f32 divisor = coss(halfFov); if (divisor == 0) { divisor = 1; } diff --git a/src/game/scroll_targets.c b/src/game/scroll_targets.c index 1c796c2c7..7bcba018d 100644 --- a/src/game/scroll_targets.c +++ b/src/game/scroll_targets.c @@ -140,7 +140,7 @@ void patch_scroll_targets_before(void) { } } -#define SHORT_RANGE 32767 +#define SHORT_RANGE 0x7FFF void patch_scroll_targets_interpolated(f32 delta) { f32 antiDelta = 1.0f - delta; diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 845c723d7..0ac1be2f5 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -186,6 +186,10 @@ unsigned int configDjuiThemeFont = FONT_NORMAL; unsigned int configDjuiScale = 0; // other unsigned int configRulesVersion = 0; +bool configCompressOnStartup = false; + +// secrets +bool configExCoopTheme = false; static const struct ConfigOption options[] = { // window settings @@ -311,7 +315,27 @@ static const struct ConfigOption options[] = { {.name = "djui_theme_font", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiThemeFont}, {.name = "djui_scale", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiScale}, // other - {.name = "rules_version", .type = CONFIG_TYPE_UINT, .uintValue = &configRulesVersion} + {.name = "rules_version", .type = CONFIG_TYPE_UINT, .uintValue = &configRulesVersion}, + {.name = "compress_on_startup", .type = CONFIG_TYPE_BOOL, .boolValue = &configCompressOnStartup}, +}; + +struct SecretConfigOption { + const char *name; + enum ConfigOptionType type; + union { + bool *boolValue; + unsigned int *uintValue; + float* floatValue; + char* stringValue; + u64* u64Value; + u8 (*colorValue)[3]; + }; + int maxStringLength; + bool inConfig; +}; + +static struct SecretConfigOption secret_options[] = { + {.name = "ex_coop_theme", .type = CONFIG_TYPE_BOOL, .boolValue = &configExCoopTheme}, }; // FunctionConfigOption functions @@ -619,6 +643,15 @@ static void configfile_load_internal(const char *filename, bool* error) { } } + // secret options + for (unsigned int i = 0; i < ARRAY_LEN(secret_options); i++) { + if (strcmp(tokens[0], secret_options[i].name) == 0) { + secret_options[i].inConfig = true; + option = (const struct ConfigOption *) &secret_options[i]; + break; + } + } + if (option == NULL) { #ifdef DEVELOPMENT printf("unknown option '%s'\n", tokens[0]); @@ -689,6 +722,12 @@ NEXT_OPTION: if (configDjuiTheme >= DJUI_THEME_MAX) { configDjuiTheme = 0; } if (configDjuiScale >= 5) { configDjuiScale = 0; } + if (configExCoopTheme) { + configDjuiTheme = DJUI_THEME_LIGHT; + configDjuiThemeCenter = false; + configDjuiThemeFont = 1; + } + #ifndef COOPNET configNetworkSystem = NS_SOCKET; #endif @@ -708,6 +747,42 @@ void configfile_load(void) { #endif } +static void configfile_save_option(FILE *file, const struct ConfigOption *option, bool isSecret) { + if (isSecret) { + const struct SecretConfigOption *secret_option = (const struct SecretConfigOption *) option; + if (!secret_option->inConfig) { return; } + } + switch (option->type) { + case CONFIG_TYPE_BOOL: + fprintf(file, "%s %s\n", option->name, *option->boolValue ? "true" : "false"); + break; + case CONFIG_TYPE_UINT: + fprintf(file, "%s %u\n", option->name, *option->uintValue); + break; + case CONFIG_TYPE_FLOAT: + fprintf(file, "%s %f\n", option->name, *option->floatValue); + break; + case CONFIG_TYPE_BIND: + fprintf(file, "%s ", option->name); + for (int i = 0; i < MAX_BINDS; ++i) + fprintf(file, "%04x ", option->uintValue[i]); + fprintf(file, "\n"); + break; + case CONFIG_TYPE_STRING: + fprintf(file, "%s %s\n", option->name, option->stringValue); + break; + case CONFIG_TYPE_U64: + fprintf(file, "%s %llu\n", option->name, *option->u64Value); + break; + case CONFIG_TYPE_COLOR: + fprintf(file, "%s %02x %02x %02x\n", option->name, (*option->colorValue)[0], (*option->colorValue)[1], (*option->colorValue)[2]); + break; + default: + LOG_ERROR("Configfile wrote bad type '%d': %s", (int)option->type, option->name); + break; + } +} + // Writes the config file to 'filename' void configfile_save(const char *filename) { FILE *file; @@ -722,36 +797,12 @@ void configfile_save(const char *filename) { for (unsigned int i = 0; i < ARRAY_LEN(options); i++) { const struct ConfigOption *option = &options[i]; + configfile_save_option(file, option, false); + } - switch (option->type) { - case CONFIG_TYPE_BOOL: - fprintf(file, "%s %s\n", option->name, *option->boolValue ? "true" : "false"); - break; - case CONFIG_TYPE_UINT: - fprintf(file, "%s %u\n", option->name, *option->uintValue); - break; - case CONFIG_TYPE_FLOAT: - fprintf(file, "%s %f\n", option->name, *option->floatValue); - break; - case CONFIG_TYPE_BIND: - fprintf(file, "%s ", option->name); - for (int i = 0; i < MAX_BINDS; ++i) - fprintf(file, "%04x ", option->uintValue[i]); - fprintf(file, "\n"); - break; - case CONFIG_TYPE_STRING: - fprintf(file, "%s %s\n", option->name, option->stringValue); - break; - case CONFIG_TYPE_U64: - fprintf(file, "%s %llu\n", option->name, *option->u64Value); - break; - case CONFIG_TYPE_COLOR: - fprintf(file, "%s %02x %02x %02x\n", option->name, (*option->colorValue)[0], (*option->colorValue)[1], (*option->colorValue)[2]); - break; - default: - LOG_ERROR("Configfile wrote bad type '%d': %s", (int)option->type, option->name); - break; - } + for (unsigned int i = 0; i < ARRAY_LEN(secret_options); i++) { + const struct ConfigOption *option = (const struct ConfigOption *) &secret_options[i]; + configfile_save_option(file, option, true); } // save function options diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 642f47e58..aa080e1e7 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -135,6 +135,10 @@ extern unsigned int configDjuiThemeFont; extern unsigned int configDjuiScale; // other extern unsigned int configRulesVersion; +extern bool configCompressOnStartup; + +// secrets +extern bool configExCoopTheme; void enable_queued_mods(void); void enable_queued_dynos_packs(void); diff --git a/src/pc/controller/controller_bind_mapping.c b/src/pc/controller/controller_bind_mapping.c index a255e6e4e..cbde338f8 100644 --- a/src/pc/controller/controller_bind_mapping.c +++ b/src/pc/controller/controller_bind_mapping.c @@ -1,7 +1,7 @@ #include #ifdef HAVE_SDL2 #include -#else +#else #ifdef HAVE_SDL #include @@ -145,7 +145,7 @@ const char* translate_bind_to_name(int bind) { if (sc == 0) { return name; } #ifdef HAVE_SDL2 - const char* sname = SDL_GetScancodeName(sc); + const char* sname = SDL_GetKeyName(SDL_GetKeyFromScancode(sc)); if (strlen(sname) <= 9) { return sname; } char* space = strchr(sname, ' '); diff --git a/src/pc/debug_context.c b/src/pc/debug_context.c index 9f09b748f..7b0cdfa80 100644 --- a/src/pc/debug_context.c +++ b/src/pc/debug_context.c @@ -2,8 +2,6 @@ #include "utils/misc.h" #include "debug_context.h" #include "debuglog.h" -#include "game/print.h" -#include "game/hud.h" #include "gfx_dimensions.h" static u32 sCtxDepth[CTX_MAX] = { 0 }; @@ -16,20 +14,6 @@ static f64 sCtxTime[CTX_MAX] = { 0 }; static f64 sCtxStartTimeStack[MAX_TIME_STACK] = { 0 }; static u32 sCtxStackIndex = 0; -static char* sDebugContextNames[] = { - "NONE", - "FRAME", - "NET", - "INTERP", - "GAME", - "SMLUA", - "AUDIO", - "RENDER", - "LEVEL", - "HOOK", - "MAX", -}; - #endif void debug_context_begin(enum DebugContext ctx) { @@ -71,29 +55,18 @@ void debug_context_reset(void) { } bool debug_context_within(enum DebugContext ctx) { - if (ctx > CTX_MAX) { return false; } + if (ctx >= CTX_MAX) { return false; } return sCtxDepth[ctx] > 0; } #ifdef DEVELOPMENT - -void ctx_profiler_update_counters(void) { - s32 y = SCREEN_HEIGHT - 60; - for (s32 i = 1; i < CTX_MAX; i++) { - const char *name = sDebugContextNames[i]; - s32 counterUs = (s32) (sCtxTime[i] * 1000000.0); - char text[256]; - snprintf(text, 256, " %05d", counterUs); - memcpy(text, name, MIN(12, strlen(name))); - for (s32 j = 0; j != 12; ++j) { - char c = text[j]; - if (c >= 'a' && c <= 'z') c -= ('a' - 'A'); - if ((c < '0' || c > '9') && (c < 'A' || c > 'Z')) c = ' '; - text[j] = c; - } - print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(4), y, text); - y -= 18; - } +void debug_context_set_time(enum DebugContext ctx, f64 time) { + if (ctx >= CTX_MAX) { return; } + sCtxTime[ctx] = time; } -#endif \ No newline at end of file +f64 debug_context_get_time(enum DebugContext ctx) { + if (ctx >= CTX_MAX) { return 0.0; } + return sCtxTime[ctx]; +} +#endif diff --git a/src/pc/debug_context.h b/src/pc/debug_context.h index e7dbe9c79..27048a91f 100644 --- a/src/pc/debug_context.h +++ b/src/pc/debug_context.h @@ -1,15 +1,17 @@ #pragma once +#include #include #define CTX_BEGIN(_ctx) debug_context_begin(_ctx) #define CTX_END(_ctx) debug_context_end(_ctx) #define CTX_WITHIN(_ctx) debug_context_within(_ctx) +#define CTX_TIME(_ctx, time) debug_context_set_time(_ctx, time) #define CTX_EXTENT(_ctx, _f) { CTX_BEGIN(_ctx); _f(); CTX_END(_ctx); } enum DebugContext { CTX_NONE, - CTX_FRAME, + CTX_TOTAL, CTX_NETWORK, CTX_INTERP, CTX_GAME_LOOP, @@ -26,3 +28,5 @@ void debug_context_begin(enum DebugContext ctx); void debug_context_end(enum DebugContext ctx); void debug_context_reset(void); bool debug_context_within(enum DebugContext ctx); +void debug_context_set_time(enum DebugContext ctx, f64 time); +f64 debug_context_get_time(enum DebugContext ctx); \ No newline at end of file diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index b559f1f8f..5109ac71c 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -5,7 +5,9 @@ #include "djui_panel_pause.h" #include "djui_panel_join.h" #include "djui_panel_join_message.h" +#include "djui_ctx_display.h" #include "djui_fps_display.h" +#include "djui_lua_profiler.h" #include "../debuglog.h" #include "pc/cliopts.h" #include "game/level_update.h" @@ -52,6 +54,8 @@ void djui_shutdown(void) { } djui_fps_display_destroy(); + djui_ctx_display_destroy(); + djui_lua_profiler_destroy(); gDjuiShuttingDown = false; sDjuiInited = false; @@ -97,6 +101,8 @@ void djui_init(void) { djui_console_create(); djui_fps_display_create(); + djui_ctx_display_create(); + djui_lua_profiler_create(); sDjuiInited = true; } @@ -128,6 +134,11 @@ void djui_lua_error(char* text, struct DjuiColor color) { sDjuiLuaErrorTimeout = 30 * 5; } +void djui_lua_error_clear(void) { + sDjuiLuaErrorTimeout = 0; + djui_base_set_visible(&sDjuiLuaError->base, false); +} + void djui_reset_hud_params(void) { djui_hud_set_resolution(RESOLUTION_DJUI); djui_hud_set_font(FONT_NORMAL); @@ -158,6 +169,8 @@ void djui_render(void) { } djui_fps_display_render(); + djui_ctx_display_render(); + djui_lua_profiler_render(); if (sDjuiLuaErrorTimeout > 0) { sDjuiLuaErrorTimeout--; diff --git a/src/pc/djui/djui.h b/src/pc/djui/djui.h index 99a4299f3..1263a5518 100644 --- a/src/pc/djui/djui.h +++ b/src/pc/djui/djui.h @@ -46,6 +46,7 @@ void djui_init(void); void djui_init_late(void); void djui_connect_menu_open(void); void djui_lua_error(char* text, struct DjuiColor color); +void djui_lua_error_clear(void); void djui_render(void); void djui_reset_hud_params(void); diff --git a/src/pc/djui/djui_ctx_display.c b/src/pc/djui/djui_ctx_display.c new file mode 100644 index 000000000..2477625f1 --- /dev/null +++ b/src/pc/djui/djui_ctx_display.c @@ -0,0 +1,141 @@ +#include "djui_ctx_display.h" + +#include "djui.h" +#include "pc/pc_main.h" +#include "pc/debug_context.h" + +#ifdef DEVELOPMENT + +static char* sDebugContextNames[] = { + "NONE", + "TOTAL", + "NET", + "INTERP", + "GAME", + "SMLUA", + "AUDIO", + "RENDER", + "LEVEL", + "HOOK", + "OTHER", + "MAX", +}; + +#endif + +struct DjuiCtxEntry { + struct DjuiText *name; + struct DjuiText *timing; +}; + +struct DjuiCtxDisplay { + struct DjuiCtxEntry topEntry; + struct DjuiCtxEntry entries[CTX_MAX]; + struct DjuiBase base; +}; + + +struct DjuiCtxDisplay *sCtxDisplay = NULL; + +void djui_ctx_display_update(void) { +#ifdef DEVELOPMENT + if (!configCtxProfiler || sCtxDisplay == NULL) { return; } + + // Time we have for a indivdual frame. If we exceed it. We are in the red. + f64 frameTime = 1.0 / 30.0; + s32 frameTimeMs = (s32)(frameTime * 1000000.0); + + struct DjuiCtxEntry *topEntry = &sCtxDisplay->topEntry; + + // If we've exceeded our available frame time. Make the top entry timing red - For dramatic effect. + // Otherwise. It's green! + if (debug_context_get_time(CTX_TOTAL) > frameTime) { + djui_base_set_color(&topEntry->timing->base, 255, 69, 0, 240); + } else { + djui_base_set_color(&topEntry->timing->base, 124, 252, 0, 240); + } + + djui_text_set_text(topEntry->name, "FRAME"); + char timing[32]; + snprintf(timing, 32, "%05d", frameTimeMs); + djui_text_set_text(topEntry->timing, timing); + + // Draw the counters. + for (s32 i = CTX_TOTAL; i < CTX_MAX; i++) { + struct DjuiCtxEntry *entry = &sCtxDisplay->entries[i]; + + const char *name = sDebugContextNames[i]; + djui_text_set_text(entry->name, name); + + // The timing is in microseconds. + s32 counterMs = (s32)(debug_context_get_time(i) * 1000000.0); + char timing[32]; + snprintf(timing, 32, "%05d", counterMs); + djui_text_set_text(entry->timing, timing); + } +#endif +} + +void djui_ctx_display_render(void) { +#ifdef DEVELOPMENT + if (!configCtxProfiler || sCtxDisplay == NULL) { return; } + + djui_rect_render(&sCtxDisplay->base); + djui_base_render(&sCtxDisplay->base); +#endif +} + +void djui_ctx_display_on_destroy(UNUSED struct DjuiBase* base) { + free(sCtxDisplay); +} + +void djui_ctx_display_initialize_entry(struct DjuiBase *base, struct DjuiCtxEntry *entry, f64 offset) { + struct DjuiText *name = djui_text_create(base, ""); + djui_text_set_alignment(name, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); + djui_base_set_size_type(&name->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&name->base, 1.0f, name->fontScale * 2); + djui_base_set_location(&name->base, 0, -name->fontScale / 3.0f + offset); + djui_base_set_color(&name->base, 255, 255, 255, 240); + + struct DjuiText *timing = djui_text_create(base, ""); + djui_text_set_alignment(timing, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); + djui_base_set_size_type(&timing->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&timing->base, 1.0f, timing->fontScale * 2); + djui_base_set_location(&timing->base, 0, -timing->fontScale / 3.0f + offset); + djui_base_set_color(&timing->base, 255, 255, 255, 240); + + entry->name = name; + entry->timing = timing; +} + +void djui_ctx_display_create(void) { + struct DjuiCtxDisplay *ctxDisplay = calloc(1, sizeof(struct DjuiCtxDisplay)); + struct DjuiBase *base = &ctxDisplay->base; + djui_base_init(NULL, base, NULL, djui_ctx_display_on_destroy); + djui_base_set_size(base, 220.0f, 39.0f + ((CTX_MAX - 2) * 26.0f)); + djui_base_set_color(base, 0, 0, 0, 240); + djui_base_set_border_color(base, 0, 0, 0, 200); + djui_base_set_border_width(base, 4); + djui_base_set_padding(base, 4, 4, 4, 4); + djui_base_set_location(base, 0, 52.0f); + + { + f64 offset = 4.0; + + djui_ctx_display_initialize_entry(base, &ctxDisplay->topEntry, offset); + offset += 35.0; + + for (s32 i = CTX_TOTAL; i < CTX_MAX; i++) { + djui_ctx_display_initialize_entry(base, &ctxDisplay->entries[i], offset); + offset += 22.0; + } + } + + sCtxDisplay = ctxDisplay; +} + +void djui_ctx_display_destroy(void) { + if (sCtxDisplay) { + djui_base_destroy(&sCtxDisplay->base); + } +} \ No newline at end of file diff --git a/src/pc/djui/djui_ctx_display.h b/src/pc/djui/djui_ctx_display.h new file mode 100644 index 000000000..ea2e28eaf --- /dev/null +++ b/src/pc/djui/djui_ctx_display.h @@ -0,0 +1,7 @@ +#pragma once +#include "djui.h" + +void djui_ctx_display_update(void); +void djui_ctx_display_render(void); +void djui_ctx_display_create(void); +void djui_ctx_display_destroy(void); \ No newline at end of file diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index ea495dd71..39457f704 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -20,7 +20,7 @@ static void djui_font_normal_render_char(char* c) { } static f32 djui_font_normal_char_width(char* c) { - if (*c == ' ') { return 0.30f; } + if (*c == ' ') { return configExCoopTheme ? 6 / 32.0f : 0.30f; } extern const f32 font_normal_widths[]; return djui_unicode_get_sprite_width(c, font_normal_widths, 32.0f); } @@ -62,7 +62,7 @@ static f32 djui_font_title_char_width(char* text) { if (c == ' ') { return 0.30f; } c = djui_unicode_get_base_char(text); extern const f32 font_title_widths[]; - return font_title_widths[(u8)c - '!'] * 1.1f; + return font_title_widths[(u8)c - '!'] * (configExCoopTheme ? 1.0f : 1.1f); } static const struct DjuiFont sDjuiFontTitle = { diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index cf0b8e4c4..d97faec67 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -131,11 +131,13 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, } f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; + f32 halfPxX = 1024.0f / (f32)w; + f32 halfPxY = 1024.0f / (f32)h; // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... - vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w - halfPxX, ((tileY + tileH) * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w - halfPxX, ((tileY + tileH) * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w - halfPxX, ( tileY * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w - halfPxX, ( tileY * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 9fbb72ca8..cf532ddbf 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -614,6 +614,19 @@ static void hud_rotate_and_translate_vec3f(Vec3f vec, Mat4* mtx, Vec3f out) { out[2] += (*mtx)[3][2]; } +f32 get_current_fov() { + return get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(gFOVState.fov, gOverrideFOV) + gFOVState.fovOffset; +} + +f32 djui_hud_get_fov_coeff() { + // fov of 45.0 is the default fov + f32 fov = get_current_fov(); + f32 fovDefault = tanf(45.f * ((f32)M_PI / 360.0f)); + f32 fovCurrent = tanf(fov * ((f32)M_PI / 360.0f)); + + return (fovDefault / fovCurrent) * 1.13f; +} + bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) { if (!gCamera) { return false; } hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out); @@ -624,15 +637,10 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) { out[0] *= 256.0f / -out[2]; out[1] *= 256.0f / out[2]; - // fov of 45.0 is the default fov - f32 fov = get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(45.0f, gOverrideFOV); - f32 fovDefault = tanf(fov * ((f32)M_PI / 360.0f)); - f32 fovCurrent = tanf((fov + gFOVState.fovOffset) * ((f32)M_PI / 360.0f)); + f32 fovCoeff = djui_hud_get_fov_coeff(); - f32 fovDifference = (fovDefault / fovCurrent) * 1.13f; - - out[0] *= fovDifference; - out[1] *= fovDifference; + out[0] *= fovCoeff; + out[1] *= fovCoeff; out[0] += djui_hud_get_screen_width() / 2.0f; out[1] += djui_hud_get_screen_height() / 2.0f; diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index d001fbd70..f2a382299 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -87,6 +87,8 @@ void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32 void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height); void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height); +f32 get_current_fov(); +f32 djui_hud_get_fov_coeff(); bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out); bool djui_hud_is_pause_menu_created(void); diff --git a/src/pc/djui/djui_interactable.c b/src/pc/djui/djui_interactable.c index 295f6e8b9..1a9e0e310 100644 --- a/src/pc/djui/djui_interactable.c +++ b/src/pc/djui/djui_interactable.c @@ -235,15 +235,18 @@ bool djui_interactable_on_key_down(int scancode) { } } - if ((gDjuiPlayerList != NULL || gDjuiModList != NULL) && gServerSettings.enablePlayerList) { + if ((gDjuiPlayerList != NULL || gDjuiModList != NULL)) { for (int i = 0; i < MAX_BINDS; i++) { if (scancode == (int)configKeyPlayerList[i] && !gDjuiInMainMenu && gNetworkType != NT_NONE) { - if (gDjuiPlayerList != NULL) { - djui_base_set_visible(&gDjuiPlayerList->base, true); - } - if (gDjuiModList != NULL) { - djui_base_set_visible(&gDjuiModList->base, true); + if (gServerSettings.enablePlayerList) { + if (gDjuiPlayerList != NULL) { + djui_base_set_visible(&gDjuiPlayerList->base, true); + } + if (gDjuiModList != NULL) { + djui_base_set_visible(&gDjuiModList->base, true); + } } + gAttemptingToOpenPlayerlist = true; break; } if (gDjuiPlayerList->base.visible) { @@ -295,6 +298,7 @@ void djui_interactable_on_key_up(int scancode) { if (gDjuiModList != NULL) { djui_base_set_visible(&gDjuiModList->base, false); } + gAttemptingToOpenPlayerlist = false; break; } } @@ -405,17 +409,15 @@ void djui_interactable_update(void) { if (gInteractableFocus) { u16 mainButtons = PAD_BUTTON_A | PAD_BUTTON_B; if ((mouseButtons & MOUSE_BUTTON_1) && !(sLastMouseButtons && MOUSE_BUTTON_1) && !djui_cursor_inside_base(gInteractableFocus)) { - // clicked outside of focused - // if (!gDjuiChatBoxFocus && gDjuiChatBox != NULL && gInteractableFocus != &gDjuiChatBox->chatInput->base) { - // djui_interactable_set_input_focus(NULL); - // } - djui_interactable_set_input_focus(NULL); + // clicked outside of focus + if (!gDjuiChatBoxFocus) { + djui_interactable_set_input_focus(NULL); + } } else if ((padButtons & mainButtons) && !(sLastInteractablePad.button & mainButtons)) { // pressed main face button - // if (!gDjuiChatBoxFocus && gDjuiChatBox != NULL && gInteractableFocus != &gDjuiChatBox->chatInput->base) { - // djui_interactable_set_input_focus(NULL); - // } - djui_interactable_set_input_focus(NULL); + if (!gDjuiChatBoxFocus) { + djui_interactable_set_input_focus(NULL); + } } else { djui_interactable_on_focus(gInteractableFocus); } diff --git a/src/pc/djui/djui_lua_profiler.c b/src/pc/djui/djui_lua_profiler.c new file mode 100644 index 000000000..57728e6a7 --- /dev/null +++ b/src/pc/djui/djui_lua_profiler.c @@ -0,0 +1,162 @@ +#include "djui_lua_profiler.h" + +#include "djui.h" +#include "pc/pc_main.h" +#include "pc/mods/mod.h" +#include "pc/mods/mods.h" + +#define MAX_PROFILED_MODS 16 +#define REFRESH_RATE 30 + +struct DjuiPrfCounter { + f64 start; + f64 end; + f64 sum; + f64 display; +}; + +struct DjuiPrfEntry { + struct DjuiText *name; + struct DjuiText *timing; + struct DjuiPrfCounter counter; +}; + +struct DjuiPrfDisplay { + struct DjuiPrfEntry entries[MAX_PROFILED_MODS]; + struct DjuiBase base; +}; + +static struct DjuiPrfDisplay *sPrfDisplay = NULL; +static u8 sPrfDisplayCount = 0; + +void lua_profiler_start_counter(UNUSED struct Mod *mod) { + if (!configLuaProfiler || sPrfDisplay == NULL) { return; } + +#ifndef WAPI_DUMMY + for (s32 i = 0; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i) { + if (gActiveMods.entries[i] == mod) { + f64 freq = SDL_GetPerformanceFrequency(); + f64 curr = SDL_GetPerformanceCounter(); + sPrfDisplay->entries[i].counter.start = curr / freq; + return; + } + } +#endif +} + +void lua_profiler_stop_counter(UNUSED struct Mod *mod) { + if (!configLuaProfiler || sPrfDisplay == NULL) { return; } + +#ifndef WAPI_DUMMY + for (s32 i = 0; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i) { + if (gActiveMods.entries[i] == mod) { + f64 freq = SDL_GetPerformanceFrequency(); + f64 curr = SDL_GetPerformanceCounter(); + + struct DjuiPrfCounter *counter = &sPrfDisplay->entries[i].counter; + counter->end = curr / freq; + counter->sum += counter->end - counter->start; + return; + } + } +#endif +} + +void djui_lua_profiler_initialize_entry(struct DjuiBase *base, struct DjuiPrfEntry *entry, f64 offset) { + struct DjuiText *name = djui_text_create(base, ""); + djui_text_set_alignment(name, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); + djui_base_set_size_type(&name->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&name->base, 1.0f, name->fontScale * 2); + djui_base_set_location(&name->base, 0, -name->fontScale / 3.0f + offset); + djui_base_set_color(&name->base, 255, 255, 255, 240); + + struct DjuiText *timing = djui_text_create(base, ""); + djui_text_set_alignment(timing, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); + djui_base_set_size_type(&timing->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&timing->base, 1.0f, timing->fontScale * 2); + djui_base_set_location(&timing->base, 0, -timing->fontScale / 3.0f + offset); + djui_base_set_color(&timing->base, 255, 255, 255, 240); + + entry->name = name; + entry->timing = timing; +} + +void djui_lua_profiler_update(void) { + if (!configLuaProfiler || sPrfDisplay == NULL) { return; } + + if (sPrfDisplayCount != gActiveMods.entryCount) { + for (s32 i = 0; i < MAX(sPrfDisplayCount, gActiveMods.entryCount); i++) { + struct DjuiPrfEntry *entry = &sPrfDisplay->entries[i]; + if (i >= sPrfDisplayCount) { + djui_lua_profiler_initialize_entry(&sPrfDisplay->base, entry, 4.0 + (i * 22.0)); + } + if (i >= gActiveMods.entryCount) { + djui_base_destroy(&entry->name->base); + djui_base_destroy(&entry->timing->base); + entry->name = NULL; + entry->timing = NULL; + } + } + sPrfDisplayCount = gActiveMods.entryCount; + } + + // Draw the counters. + for (s32 i = 0; i < MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); i++) { + struct DjuiPrfEntry *entry = &sPrfDisplay->entries[i]; + struct DjuiPrfCounter *counter = &entry->counter; + + if (gGlobalTimer % REFRESH_RATE == 0) { + counter->display = counter->sum / (f64) REFRESH_RATE; + counter->sum = 0; + } + + char name[256]; + memset(name, 0, 256); + const char *modName = gActiveMods.entries[i]->relativePath; + memcpy(name, modName, MIN(16, strlen(modName) - (gActiveMods.entries[i]->isDirectory ? 0 : 4))); + for (s32 j = 0; j != 16; ++j) { + char c = name[j]; + if (c >= 'a' && c <= 'z') c -= ('a' - 'A'); + if ((c < '0' || c > '9') && (c < 'A' || c > 'Z')) c = ' '; + name[j] = c; + } + djui_text_set_text(entry->name, name); + + // The timing is in microseconds. + s32 counterMs = (s32)(counter->display * 1000000.0); + char timing[32]; + snprintf(timing, 32, "%05d", counterMs); + djui_text_set_text(entry->timing, timing); + } +} + +void djui_lua_profiler_render(void) { + if (!configLuaProfiler || sPrfDisplay == NULL) { return; } + + djui_rect_render(&sPrfDisplay->base); + djui_base_render(&sPrfDisplay->base); +} + +void djui_lua_profiler_on_destroy(UNUSED struct DjuiBase* base) { + free(sPrfDisplay); +} + +void djui_lua_profiler_create(void) { + struct DjuiPrfDisplay *prfDisplay = calloc(1, sizeof(struct DjuiPrfDisplay)); + struct DjuiBase *base = &prfDisplay->base; + djui_base_init(NULL, base, NULL, djui_lua_profiler_on_destroy); + djui_base_set_size(base, 290.0f, MAX_PROFILED_MODS * 26.0f); + djui_base_set_color(base, 0, 0, 0, 240); + djui_base_set_border_color(base, 0, 0, 0, 200); + djui_base_set_border_width(base, 4); + djui_base_set_padding(base, 4, 4, 4, 4); + djui_base_set_location(base, 0, 300.0f); + + sPrfDisplay = prfDisplay; +} + +void djui_lua_profiler_destroy(void) { + if (sPrfDisplay) { + djui_base_destroy(&sPrfDisplay->base); + } +} \ No newline at end of file diff --git a/src/pc/djui/djui_lua_profiler.h b/src/pc/djui/djui_lua_profiler.h new file mode 100644 index 000000000..0ff5c3451 --- /dev/null +++ b/src/pc/djui/djui_lua_profiler.h @@ -0,0 +1,11 @@ +#pragma once +#include "djui.h" +#include "pc/mods/mod.h" + +void lua_profiler_start_counter(UNUSED struct Mod *mod); +void lua_profiler_stop_counter(UNUSED struct Mod *mod); + +void djui_lua_profiler_update(void); +void djui_lua_profiler_render(void); +void djui_lua_profiler_create(void); +void djui_lua_profiler_destroy(void); \ No newline at end of file diff --git a/src/pc/djui/djui_panel.c b/src/pc/djui/djui_panel.c index 95f31d053..e0253303e 100644 --- a/src/pc/djui/djui_panel.c +++ b/src/pc/djui/djui_panel.c @@ -58,6 +58,7 @@ struct DjuiPanel* djui_panel_add(struct DjuiBase* caller, struct DjuiThreePanel* panel->defaultElementBase = defaultElementBase; panel->on_back = threePanel->on_back; panel->on_panel_destroy = NULL; + panel->temporary = threePanel->temporary; sPanelList = panel; // find better defaultElementBase @@ -118,6 +119,7 @@ void djui_panel_back(void) { // set the previous active sPanelList = sPanelList->parent; + if (sPanelList->temporary) { sPanelList = sPanelList->parent; } // reset move amount sMoveAmount = 0; diff --git a/src/pc/djui/djui_panel_main.c b/src/pc/djui/djui_panel_main.c index 4b4b889e7..a32f3d415 100644 --- a/src/pc/djui/djui_panel_main.c +++ b/src/pc/djui/djui_panel_main.c @@ -25,30 +25,32 @@ static void djui_panel_main_quit(struct DjuiBase* caller) { } void djui_panel_main_create(struct DjuiBase* caller) { - struct DjuiThreePanel* panel = djui_panel_menu_create("", false); + struct DjuiThreePanel* panel = djui_panel_menu_create(configExCoopTheme ? "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP" : "", false); { struct DjuiBase* body = djui_three_panel_get_body(panel); { - struct DjuiImage* logo = djui_image_create(body, texture_coopdx_logo, 2048, 1024, 32); - if (configDjuiThemeCenter) { - djui_base_set_size(&logo->base, 550, 275); - } else { - djui_base_set_size(&logo->base, 480, 240); + if (!configExCoopTheme) { + struct DjuiImage* logo = djui_image_create(body, texture_coopdx_logo, 2048, 1024, 32); + if (configDjuiThemeCenter) { + djui_base_set_size(&logo->base, 550, 275); + } else { + djui_base_set_size(&logo->base, 480, 240); + } + djui_base_set_alignment(&logo->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); + djui_base_set_location_type(&logo->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_location(&logo->base, 0, -30); } - djui_base_set_alignment(&logo->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); - djui_base_set_location_type(&logo->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); - djui_base_set_location(&logo->base, 0, -30); struct DjuiButton* button1 = djui_button_create(body, DLANG(MAIN, HOST), DJUI_BUTTON_STYLE_NORMAL, djui_panel_host_create); - djui_base_set_location(&button1->base, 0, -30); + if (!configExCoopTheme) { djui_base_set_location(&button1->base, 0, -30); } djui_cursor_input_controlled_center(&button1->base); struct DjuiButton* button2 = djui_button_create(body, DLANG(MAIN, JOIN), DJUI_BUTTON_STYLE_NORMAL, djui_panel_join_create); - djui_base_set_location(&button2->base, 0, -30); + if (!configExCoopTheme) { djui_base_set_location(&button2->base, 0, -30); } struct DjuiButton* button3 = djui_button_create(body, DLANG(MAIN, OPTIONS), DJUI_BUTTON_STYLE_NORMAL, djui_panel_options_create); - djui_base_set_location(&button3->base, 0, -30); + if (!configExCoopTheme) { djui_base_set_location(&button3->base, 0, -30); } struct DjuiButton* button4 = djui_button_create(body, DLANG(MAIN, QUIT), DJUI_BUTTON_STYLE_BACK, djui_panel_main_quit); - djui_base_set_location(&button4->base, 0, -30); + if (!configExCoopTheme) { djui_base_set_location(&button4->base, 0, -30); } } // these two cannot co-exist for some reason diff --git a/src/pc/djui/djui_panel_menu.c b/src/pc/djui/djui_panel_menu.c index 7a6e3dd33..552cba5b3 100644 --- a/src/pc/djui/djui_panel_menu.c +++ b/src/pc/djui/djui_panel_menu.c @@ -13,6 +13,13 @@ char* sRainbowColors[] = { "\\#ffef40\\", }; +char* sExCoopRainbowColors[] = { + "\\#ff0800\\", + "\\#1be700\\", + "\\#00b3ff\\", + "\\#ffef00\\", +}; + char sRainbowText[RAINBOW_TEXT_LEN + 1] = { 0 }; static void generate_rainbow_text(char* text) { @@ -28,7 +35,7 @@ static void generate_rainbow_text(char* text) { } s32 restrictSize = RAINBOW_TEXT_LEN - (s32)(dst - sRainbowText); if (restrictSize <= 0) { break; } - snprintf(dst, restrictSize, "%s", sRainbowColors[i++ % 4]); + snprintf(dst, restrictSize, "%s", configExCoopTheme ? sExCoopRainbowColors[i++ % 4] : sRainbowColors[i++ % 4]); dst = &sRainbowText[strlen(sRainbowText)]; restrictSize = RAINBOW_TEXT_LEN - (s32)(dst - sRainbowText); @@ -75,7 +82,11 @@ struct DjuiThreePanel* djui_panel_menu_create(char* headerText, bool forcedLeftS djui_base_set_location(&header->base, 0, DJUI_PANEL_HEADER_OFFSET); djui_text_set_alignment(header, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM); djui_text_set_font(header, hudFontHeader ? gDjuiFonts[2] : gDjuiFonts[1]); - djui_text_set_font_scale(header, gDjuiFonts[1]->defaultFontScale * (hudFontHeader ? 0.7f : 1.0f) * (strlen(headerText) > 15 ? 0.9f : 1.0f)); + if (configExCoopTheme) { + djui_text_set_font_scale(header, gDjuiFonts[1]->defaultFontScale); + } else { + djui_text_set_font_scale(header, gDjuiFonts[1]->defaultFontScale * (hudFontHeader ? 0.7f : 1.0f) * (strlen(headerText) > 15 ? 0.9f : 1.0f)); + } struct DjuiFlowLayout* body = djui_flow_layout_create(&panel->base); djui_base_set_alignment(&body->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 3495f77f6..e6b887eab 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -89,16 +89,23 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { djui_themes_init(); { - djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_menu_options_djui_setting_change); + struct DjuiCheckbox* center = djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_menu_options_djui_setting_change); + if (configExCoopTheme) { djui_base_set_enabled(¢er->base, false); } + char* themeChoices[DJUI_THEME_MAX]; for (int i = 0; i < DJUI_THEME_MAX; i++) { themeChoices[i] = (char*)gDjuiThemes[i]->name; } - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_menu_options_djui_setting_change); + struct DjuiSelectionbox* theme = djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_menu_options_djui_setting_change); + if (configExCoopTheme) { djui_base_set_enabled(&theme->base, false); } + char* djuiScaleChoices[5] = {DLANG(DJUI_THEMES, AUTO), "x0.5", "x0.85", "x1.0", "x1.5"}; - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 5, &configDjuiScale, djui_panel_menu_options_djui_setting_change); + struct DjuiSelectionbox* scale = djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 5, &configDjuiScale, djui_panel_menu_options_djui_setting_change); + if (configExCoopTheme) { djui_base_set_enabled(&scale->base, false); } + char* djuiFontChoices[2] = {DLANG(DJUI_THEMES, FONT_NORMAL), DLANG(DJUI_THEMES, FONT_ALIASED)}; - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_FONT), djuiFontChoices, 2, &configDjuiThemeFont, djui_panel_menu_options_djui_setting_change); + struct DjuiSelectionbox* font = djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_FONT), djuiFontChoices, 2, &configDjuiThemeFont, djui_panel_menu_options_djui_setting_change); + if (configExCoopTheme) { djui_base_set_enabled(&font->base, false); } if (gDjuiInMainMenu) { // get level choices diff --git a/src/pc/djui/djui_panel_playerlist.c b/src/pc/djui/djui_panel_playerlist.c index f2f168a09..25c90f829 100644 --- a/src/pc/djui/djui_panel_playerlist.c +++ b/src/pc/djui/djui_panel_playerlist.c @@ -11,6 +11,7 @@ #include "pc/utils/misc.h" struct DjuiThreePanel* gDjuiPlayerList = NULL; +bool gAttemptingToOpenPlayerlist = false; static struct DjuiFlowLayout* djuiRow[MAX_PLAYERS] = { 0 }; static struct DjuiImage* djuiImages[MAX_PLAYERS] = { 0 }; @@ -53,7 +54,11 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { djui_base_set_color(&djuiTextDescriptions[i]->base, np->descriptionR, np->descriptionG, np->descriptionB, np->descriptionA); djui_text_set_text(djuiTextDescriptions[i], np->description); - djui_text_set_text(djuiTextLocations[i], get_level_name(np->currCourseNum, np->currLevelNum, np->currAreaIndex)); + djui_text_set_text(djuiTextLocations[i], + np->overrideLocation[0] == '\0' + ? get_level_name(np->currCourseNum, np->currLevelNum, np->currAreaIndex) + : np->overrideLocation + ); djui_text_set_text(djuiTextAct[i], sActNum); } diff --git a/src/pc/djui/djui_panel_playerlist.h b/src/pc/djui/djui_panel_playerlist.h index 7380b673b..2f4f3b117 100644 --- a/src/pc/djui/djui_panel_playerlist.h +++ b/src/pc/djui/djui_panel_playerlist.h @@ -2,6 +2,7 @@ #include "djui.h" extern struct DjuiThreePanel* gDjuiPlayerList; +extern bool gAttemptingToOpenPlayerlist; extern const u8 sPlayerListSize; extern u8 sPageIndex; diff --git a/src/pc/djui/djui_panel_rules.c b/src/pc/djui/djui_panel_rules.c index 17e6e569e..e2e8d0ba7 100644 --- a/src/pc/djui/djui_panel_rules.c +++ b/src/pc/djui/djui_panel_rules.c @@ -21,16 +21,7 @@ void djui_panel_rules_create(struct DjuiBase* caller) { struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(RULES, RULES_TITLE), false); struct DjuiBase* body = djui_three_panel_get_body(panel); { - snprintf(sRules, 512, "%s\n\ -%s\n\ -%s\n\ -%s\n\ -%s", -DLANG(RULES, RULE_1), -DLANG(RULES, RULE_2), -DLANG(RULES, RULE_3), -DLANG(RULES, RULE_4), -DLANG(RULES, RULE_5)); + snprintf(sRules, 512, "%s\n%s\n%s\n%s\n%s", DLANG(RULES, RULE_1), DLANG(RULES, RULE_2), DLANG(RULES, RULE_3), DLANG(RULES, RULE_4), DLANG(RULES, RULE_5)); struct DjuiText* text1 = djui_text_create(body, sRules); djui_base_set_location(&text1->base, 0, 0); @@ -65,6 +56,7 @@ DLANG(RULES, RULE_5)); } + panel->temporary = true; djui_panel_add(caller, panel, NULL); } #endif diff --git a/src/pc/djui/djui_progress_bar.c b/src/pc/djui/djui_progress_bar.c index 08a4b08a0..64cc86ad7 100644 --- a/src/pc/djui/djui_progress_bar.c +++ b/src/pc/djui/djui_progress_bar.c @@ -2,7 +2,7 @@ void djui_progress_bar_render_pre(struct DjuiBase* base, UNUSED bool* unused) { struct DjuiProgressBar* progress = (struct DjuiProgressBar*)base; - progress->smoothValue = progress->smoothValue * 0.95f + *progress->value * 0.05f; + progress->smoothValue = progress->smoothValue * progress->smoothenHigh + *progress->value * progress->smoothenLow; float min = progress->min; float max = progress->max; djui_base_set_size(&progress->rectValue->base, ((f32)progress->smoothValue - min) / ((f32)max - min), 1.0f); @@ -13,7 +13,7 @@ void djui_progress_bar_render_pre_infinite(struct DjuiBase* base, UNUSED bool* u float min = progress->min; float max = progress->max; - progress->smoothValue = progress->smoothValue * 0.95f + *progress->value * 0.05f; + progress->smoothValue = progress->smoothValue * progress->smoothenHigh + *progress->value * progress->smoothenLow; float modValue = progress->smoothValue - ((int)progress->smoothValue); float x = (modValue - min - 0.25f) / (max - min - 0.25f); float w = 0.25f; @@ -43,6 +43,8 @@ struct DjuiProgressBar* djui_progress_bar_create(struct DjuiBase* parent, float* progress->smoothValue = *value; progress->min = min; progress->max = max; + progress->smoothenHigh = 0.95f; + progress->smoothenLow = 0.05f; djui_base_init(parent, base, NULL, djui_progress_bar_destroy); djui_base_set_size_type(base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); diff --git a/src/pc/djui/djui_progress_bar.h b/src/pc/djui/djui_progress_bar.h index 08494301b..bc6bc2cec 100644 --- a/src/pc/djui/djui_progress_bar.h +++ b/src/pc/djui/djui_progress_bar.h @@ -9,6 +9,8 @@ struct DjuiProgressBar { float smoothValue; float min; float max; + float smoothenHigh; + float smoothenLow; }; struct DjuiProgressBar* djui_progress_bar_create(struct DjuiBase* parent, float* value, float min, float max, bool infinite); diff --git a/src/pc/djui/djui_theme.h b/src/pc/djui/djui_theme.h index 1cd69553c..89bc2089b 100644 --- a/src/pc/djui/djui_theme.h +++ b/src/pc/djui/djui_theme.h @@ -1,8 +1,8 @@ #pragma once #include "djui.h" -#define DJUI_THEME_CENTERED_WIDTH 1.25f -#define DJUI_THEME_CENTERED_HEIGHT 0.88f +#define DJUI_THEME_CENTERED_WIDTH 1.3f +#define DJUI_THEME_CENTERED_HEIGHT 0.9f enum DjuiThemeType { DJUI_THEME_LIGHT, diff --git a/src/pc/djui/djui_three_panel.h b/src/pc/djui/djui_three_panel.h index c00515d55..1cd96fd2c 100644 --- a/src/pc/djui/djui_three_panel.h +++ b/src/pc/djui/djui_three_panel.h @@ -6,6 +6,7 @@ struct DjuiThreePanel { struct DjuiScreenValue minHeaderSize; struct DjuiScreenValue bodySize; struct DjuiScreenValue minFooterSize; + bool temporary; bool (*on_back)(struct DjuiBase*); }; diff --git a/src/pc/fs/fs.c b/src/pc/fs/fs.c index 4e0746bf5..843ac1feb 100644 --- a/src/pc/fs/fs.c +++ b/src/pc/fs/fs.c @@ -11,6 +11,7 @@ #include #ifdef _WIN32 #include +#include #endif #include "macros.h" @@ -292,18 +293,32 @@ bool fs_sys_filename_is_portable(char const *filename) { /* these operate on the real file system */ bool fs_sys_path_exists(const char *name) { +#ifdef _WIN32 + return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES; +#else struct stat st; return (stat(name, &st) == 0); +#endif } bool fs_sys_file_exists(const char *name) { +#ifdef _WIN32 + DWORD attribs = GetFileAttributesA(name); + return attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY); +#else struct stat st; return (stat(name, &st) == 0 && S_ISREG(st.st_mode)); +#endif } bool fs_sys_dir_exists(const char *name) { +#ifdef _WIN32 + DWORD attribs = GetFileAttributesA(name); + return attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY); +#else struct stat st; return (stat(name, &st) == 0 && S_ISDIR(st.st_mode)); +#endif } bool fs_sys_dir_is_empty(const char *name) { diff --git a/src/pc/gfx/gfx_dummy.c b/src/pc/gfx/gfx_dummy.c index b0fda743e..b4a49b4e0 100644 --- a/src/pc/gfx/gfx_dummy.c +++ b/src/pc/gfx/gfx_dummy.c @@ -113,7 +113,7 @@ static void gfx_dummy_wm_start_text_input(void) { static void gfx_dummy_wm_stop_text_input(void) { } -static void gfx_dummy_wm_set_clipboard_text(UNUSED char* text) { +static void gfx_dummy_wm_set_clipboard_text(UNUSED const char* text) { } static void gfx_dummy_wm_set_cursor_visible(UNUSED bool visible) { diff --git a/src/pc/gfx/gfx_dxgi.cpp b/src/pc/gfx/gfx_dxgi.cpp index 0488c60d7..4441fe13f 100644 --- a/src/pc/gfx/gfx_dxgi.cpp +++ b/src/pc/gfx/gfx_dxgi.cpp @@ -719,26 +719,40 @@ void gfx_dxgi_start_text_input(void) { inTextInput = TRUE; } void gfx_dxgi_stop_text_input(void) { inTextInput = FALSE; } static char* gfx_dxgi_get_clipboard_text(void) { + static char clipboard_buf[WAPI_CLIPBOARD_BUFSIZ]; + clipboard_buf[0] = '\0'; + if (OpenClipboard(NULL)) { - HANDLE clip = GetClipboardData(CF_TEXT); + LPCWSTR text = (LPCWSTR)GetClipboardData(CF_UNICODETEXT); + if (text != NULL) { + WideCharToMultiByte(CP_UTF8, 0, text, (-1), clipboard_buf, WAPI_CLIPBOARD_BUFSIZ, NULL, NULL); + } CloseClipboard(); - return (char*)clip; } - return NULL; + + clipboard_buf[WAPI_CLIPBOARD_BUFSIZ - 1] = '\0'; + return clipboard_buf; } -void gfx_dxgi_set_clipboard_text(char* text) { - if (OpenClipboard(NULL)) { - HGLOBAL clipbuffer; - char *buffer; - EmptyClipboard(); - clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text) + 1); - buffer = (char *) GlobalLock(clipbuffer); - strcpy(buffer, LPCSTR(text)); - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); - CloseClipboard(); +void gfx_dxgi_set_clipboard_text(const char* text) { + if (!OpenClipboard(NULL)) { return; } + EmptyClipboard(); + + int cch = MultiByteToWideChar(CP_UTF8, 0, text, (-1), NULL, 0); + if (cch > 0) { + HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, cch * sizeof(WCHAR)); + if (hMem != NULL) { + LPWSTR wcsBuffer = (LPWSTR)GlobalLock(hMem); + if (wcsBuffer != NULL) { + MultiByteToWideChar(CP_UTF8, 0, text, (-1), wcsBuffer, cch); + GlobalUnlock(hMem); + SetClipboardData(CF_UNICODETEXT, hMem); + } else { + GlobalFree(hMem); + } + } } + CloseClipboard(); } void gfx_dxgi_set_cursor_visible(bool visible) { ShowCursor(visible); } diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index 0df60f58a..3da2dc5be 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -67,6 +67,7 @@ static struct ShaderProgram shader_program_pool[CC_MAX_SHADERS]; static uint8_t shader_program_pool_size = 0; static uint8_t shader_program_pool_index = 0; static GLuint opengl_vbo; +static GLuint opengl_vao; static int tex_cache_size = 0; static int num_textures = 0; @@ -707,6 +708,11 @@ static void gfx_opengl_init(void) { glGenBuffers(1, &opengl_vbo); glBindBuffer(GL_ARRAY_BUFFER, opengl_vbo); + + if (vmajor >= 3 && !is_es) { + glGenVertexArrays(1, &opengl_vao); + glBindVertexArray(opengl_vao); + } glDepthFunc(GL_LEQUAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index ba81e8836..8568c5ae2 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -6,6 +6,10 @@ #include #include +#ifdef __SSE__ +#include +#endif + #define STB_IMAGE_IMPLEMENTATION #include @@ -106,8 +110,8 @@ static struct RSP { float modelview_matrix_stack[11][4][4]; uint8_t modelview_matrix_stack_size; - float MP_matrix[4][4]; - float P_matrix[4][4]; + ALIGNED16 float MP_matrix[4][4]; + ALIGNED16 float P_matrix[4][4]; Light_t current_lights[MAX_LIGHTS + 1]; float current_lights_coeffs[MAX_LIGHTS][3]; @@ -760,19 +764,46 @@ static void gfx_sp_pop_matrix(uint32_t count) { } static float gfx_adjust_x_for_aspect_ratio(float x) { - return x * (4.0f / 3.0f) / ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height); + return x * gfx_current_dimensions.x_adjust_ratio; } static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *vertices, bool luaVertexColor) { + float globalLightCached[2][3]; + if (rsp.geometry_mode & G_LIGHTING) { + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 3; j++) + globalLightCached[i][j] = gLightingColor[i][j] / 255.0f; + } + } + +#ifdef __SSE__ + __m128 mat0 = _mm_load_ps(rsp.MP_matrix[0]); + __m128 mat1 = _mm_load_ps(rsp.MP_matrix[1]); + __m128 mat2 = _mm_load_ps(rsp.MP_matrix[2]); + __m128 mat3 = _mm_load_ps(rsp.MP_matrix[3]); +#endif + for (size_t i = 0; i < n_vertices; i++, dest_index++) { const Vtx_t *v = &vertices[i].v; const Vtx_tn *vn = &vertices[i].n; struct LoadedVertex *d = &rsp.loaded_vertices[dest_index]; +#ifdef __SSE__ + __m128 ob0 = _mm_set1_ps(v->ob[0]); + __m128 ob1 = _mm_set1_ps(v->ob[1]); + __m128 ob2 = _mm_set1_ps(v->ob[2]); + + __m128 pos = _mm_add_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(ob0, mat0), _mm_mul_ps(ob1, mat1)), _mm_mul_ps(ob2, mat2)), mat3); + float x = pos[0]; + float y = pos[1]; + float z = pos[2]; + float w = pos[3]; +#else float x = v->ob[0] * rsp.MP_matrix[0][0] + v->ob[1] * rsp.MP_matrix[1][0] + v->ob[2] * rsp.MP_matrix[2][0] + rsp.MP_matrix[3][0]; float y = v->ob[0] * rsp.MP_matrix[0][1] + v->ob[1] * rsp.MP_matrix[1][1] + v->ob[2] * rsp.MP_matrix[2][1] + rsp.MP_matrix[3][1]; float z = v->ob[0] * rsp.MP_matrix[0][2] + v->ob[1] * rsp.MP_matrix[1][2] + v->ob[2] * rsp.MP_matrix[2][2] + rsp.MP_matrix[3][2]; float w = v->ob[0] * rsp.MP_matrix[0][3] + v->ob[1] * rsp.MP_matrix[1][3] + v->ob[2] * rsp.MP_matrix[2][3] + rsp.MP_matrix[3][3]; +#endif x = gfx_adjust_x_for_aspect_ratio(x); @@ -792,9 +823,9 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons rsp.lights_changed = false; } - int r = rsp.current_lights[rsp.current_num_lights - 1].col[0] * gLightingColor[1][0] / 255.0f; - int g = rsp.current_lights[rsp.current_num_lights - 1].col[1] * gLightingColor[1][1] / 255.0f; - int b = rsp.current_lights[rsp.current_num_lights - 1].col[2] * gLightingColor[1][2] / 255.0f; + float r = rsp.current_lights[rsp.current_num_lights - 1].col[0] * globalLightCached[1][0]; + float g = rsp.current_lights[rsp.current_num_lights - 1].col[1] * globalLightCached[1][1]; + float b = rsp.current_lights[rsp.current_num_lights - 1].col[2] * globalLightCached[1][2]; for (int32_t i = 0; i < rsp.current_num_lights - 1; i++) { float intensity = 0; @@ -803,15 +834,15 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons intensity += vn->n[2] * rsp.current_lights_coeffs[i][2]; intensity /= 127.0f; if (intensity > 0.0f) { - r += intensity * rsp.current_lights[i].col[0] * gLightingColor[0][0] / 255.0f; - g += intensity * rsp.current_lights[i].col[1] * gLightingColor[0][1] / 255.0f; - b += intensity * rsp.current_lights[i].col[2] * gLightingColor[0][2] / 255.0f; + r += intensity * rsp.current_lights[i].col[0] * globalLightCached[0][0]; + g += intensity * rsp.current_lights[i].col[1] * globalLightCached[0][1]; + b += intensity * rsp.current_lights[i].col[2] * globalLightCached[0][2]; } } - d->color.r = r > 255 ? 255 : r; - d->color.g = g > 255 ? 255 : g; - d->color.b = b > 255 ? 255 : b; + d->color.r = r > 255.0f ? 255 : (uint8_t)r; + d->color.g = g > 255.0f ? 255 : (uint8_t)g; + d->color.b = b > 255.0f ? 255 : (uint8_t)b; if (rsp.geometry_mode & G_TEXTURE_GEN) { float dotx = 0, doty = 0; @@ -1823,6 +1854,7 @@ void gfx_start_frame(void) { gfx_current_dimensions.height = 1; } gfx_current_dimensions.aspect_ratio = ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height); + gfx_current_dimensions.x_adjust_ratio = (4.0f / 3.0f) / gfx_current_dimensions.aspect_ratio; } void gfx_run(Gfx *commands) { diff --git a/src/pc/gfx/gfx_pc.h b/src/pc/gfx/gfx_pc.h index 02a272216..1a89fbd32 100644 --- a/src/pc/gfx/gfx_pc.h +++ b/src/pc/gfx/gfx_pc.h @@ -9,6 +9,7 @@ struct GfxWindowManagerAPI; struct GfxDimensions { uint32_t width, height; float aspect_ratio; + float x_adjust_ratio; }; extern struct GfxDimensions gfx_current_dimensions; diff --git a/src/pc/gfx/gfx_sdl1.c b/src/pc/gfx/gfx_sdl1.c index 378c981aa..cf6b4a272 100644 --- a/src/pc/gfx/gfx_sdl1.c +++ b/src/pc/gfx/gfx_sdl1.c @@ -211,8 +211,8 @@ static bool gfx_sdl_has_focus(void) { static void gfx_sdl_start_text_input(void) { return; } static void gfx_sdl_stop_text_input(void) { return; } -static char* gfx_sdl_get_clipboard_text(void) { return NULL; } -static void gfx_sdl_set_clipboard_text(char* text) { return; } +static char* gfx_sdl_get_clipboard_text(void) { return ""; } +static void gfx_sdl_set_clipboard_text(UNUSED const char* text) { return; } static void gfx_sdl_set_cursor_visible(bool visible) { SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE); } struct GfxWindowManagerAPI gfx_sdl = { diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 0b448b3d3..c980c560b 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -304,8 +304,19 @@ static bool gfx_sdl_has_focus(void) { static void gfx_sdl_start_text_input(void) { SDL_StartTextInput(); } static void gfx_sdl_stop_text_input(void) { SDL_StopTextInput(); } -static char* gfx_sdl_get_clipboard_text(void) { return SDL_GetClipboardText(); } -static void gfx_sdl_set_clipboard_text(char* text) { SDL_SetClipboardText(text); } + +static char* gfx_sdl_get_clipboard_text(void) { + static char clipboard_buf[WAPI_CLIPBOARD_BUFSIZ]; + + char* text = SDL_GetClipboardText(); + strncpy(clipboard_buf, text, WAPI_CLIPBOARD_BUFSIZ - 1); + SDL_free(text); + + clipboard_buf[WAPI_CLIPBOARD_BUFSIZ - 1] = '\0'; + return clipboard_buf; +} + +static void gfx_sdl_set_clipboard_text(const char* text) { SDL_SetClipboardText(text); } static void gfx_sdl_set_cursor_visible(bool visible) { SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE); } struct GfxWindowManagerAPI gfx_sdl = { diff --git a/src/pc/gfx/gfx_window_manager_api.h b/src/pc/gfx/gfx_window_manager_api.h index b94ecdd52..57204a859 100644 --- a/src/pc/gfx/gfx_window_manager_api.h +++ b/src/pc/gfx/gfx_window_manager_api.h @@ -7,6 +7,8 @@ // special value for window position that signifies centered position #define WAPI_WIN_CENTERPOS 0xFFFFFFFF +#define WAPI_CLIPBOARD_BUFSIZ 1024 + typedef bool (*kb_callback_t)(int code); struct GfxWindowManagerAPI { @@ -23,7 +25,7 @@ struct GfxWindowManagerAPI { void (*start_text_input)(void); void (*stop_text_input)(void); char* (*get_clipboard_text)(void); - void (*set_clipboard_text)(char*); + void (*set_clipboard_text)(const char*); void (*set_cursor_visible)(bool); void (*delay)(unsigned int ms); int (*get_max_msaa)(void); diff --git a/src/pc/loading.c b/src/pc/loading.c index 1683ddcbf..82b518ce6 100644 --- a/src/pc/loading.c +++ b/src/pc/loading.c @@ -17,6 +17,7 @@ struct LoadingSegment gCurrLoadingSegment = { "", 0 }; struct LoadingScreen { struct DjuiBase base; struct DjuiImage* splashImage; + struct DjuiText* splashText; struct DjuiText* loadingDesc; struct DjuiProgressBar *loadingBar; }; @@ -32,6 +33,10 @@ void loading_screen_set_segment_text(const char* text) { snprintf(gCurrLoadingSegment.str, 256, text); } +void loading_screen_reset_progress_bar(void) { + sLoading->loadingBar->smoothValue = 0; +} + static void loading_screen_produce_frame_callback(void) { if (sLoading) { djui_base_render(&sLoading->base); } } @@ -49,12 +54,19 @@ static bool loading_screen_on_render(struct DjuiBase* base) { windowWidth /= scale; windowHeight /= scale; - f32 loadingDescY1 = windowHeight * 0.5f + sLoading->splashImage->base.height.value * 0.25f; - f32 loadingDescY2 = windowHeight * 0.5f + sLoading->splashImage->base.height.value * 0.55f; + f32 loadingDescY1 = windowHeight * 0.5f - sLoading->loadingDesc->base.height.value * 0.5f; + f32 loadingDescY2 = windowHeight * 0.5f + sLoading->loadingDesc->base.height.value * 0.5f; // fill the screen djui_base_set_size(base, windowWidth, windowHeight); + // splash logo + if (configExCoopTheme) { + djui_base_set_location(&sLoading->splashText->base, 0, loadingDescY1 - sLoading->splashText->base.height.value); + } else { + djui_base_set_location(&sLoading->splashImage->base, 0, loadingDescY1 - sLoading->splashImage->base.height.value); + } + { // loading text description char buffer[256] = ""; @@ -73,7 +85,7 @@ static bool loading_screen_on_render(struct DjuiBase* base) { } // loading bar - djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, loadingDescY2); + djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, loadingDescY2 + 64); djui_base_set_visible(&sLoading->loadingBar->base, gCurrLoadingSegment.percentage > 0 && strlen(gCurrLoadingSegment.str) > 0); djui_base_compute(base); @@ -95,12 +107,26 @@ static void init_loading_screen(void) { djui_base_init(NULL, base, loading_screen_on_render, loading_screen_destroy); - { - // splash image + // splash text (easter egg) + if (configExCoopTheme) { + struct DjuiText* splashDjuiText = djui_text_create(base, "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP"); + djui_base_set_location_type(&splashDjuiText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_location(&splashDjuiText->base, 0, 0); + djui_text_set_font(splashDjuiText, gDjuiFonts[1]); + djui_text_set_font_scale(splashDjuiText, gDjuiFonts[1]->defaultFontScale); + djui_text_set_alignment(splashDjuiText, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); + djui_base_set_size_type(&splashDjuiText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&splashDjuiText->base, 1.0f, gDjuiFonts[1]->defaultFontScale * 3.0f); + + load->splashText = splashDjuiText; + + // splash image + } else { struct DjuiImage* splashImage = djui_image_create(base, texture_coopdx_logo, 2048, 1024, 32); + djui_base_set_location_type(&splashImage->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_alignment(&splashImage->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); djui_base_set_location(&splashImage->base, 0, -100); - djui_base_set_alignment(&splashImage->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); - djui_base_set_size(&splashImage->base, 1024, 512); + djui_base_set_size(&splashImage->base, 512, 256); load->splashImage = splashImage; } @@ -112,11 +138,11 @@ static void init_loading_screen(void) { djui_base_set_location(&text->base, 0, 0); djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); - djui_base_set_size(&text->base, 1.0f, gDjuiFonts[0]->defaultFontScale * 4.5f); // 3 lines + djui_base_set_size(&text->base, 1.0f, gDjuiFonts[0]->defaultFontScale * 3.0f); djui_base_set_color(&text->base, 220, 220, 220, 255); djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); djui_text_set_font(text, gDjuiFonts[0]); - djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 1.5f); + djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale); load->loadingDesc = text; } @@ -127,7 +153,9 @@ static void init_loading_screen(void) { djui_base_set_location_type(&progressBar->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE); djui_base_set_location(&progressBar->base, 0, 0); djui_base_set_visible(&progressBar->base, false); - djui_base_set_size(&progressBar->base, 0.5f, 32); + progressBar->base.width.value = 0.5; + progressBar->smoothenHigh = 0.75f; + progressBar->smoothenLow = 0.25f; load->loadingBar = progressBar; } diff --git a/src/pc/loading.h b/src/pc/loading.h index 4f12040a0..11fdb0b5a 100644 --- a/src/pc/loading.h +++ b/src/pc/loading.h @@ -32,6 +32,7 @@ extern pthread_mutex_t gLoadingThreadMutex; extern bool gIsThreaded; void loading_screen_set_segment_text(const char* text); +void loading_screen_reset_progress_bar(void); void render_loading_screen(void); void loading_screen_reset(void); void render_rom_setup_screen(void); diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index 4d9de298a..75432f9cc 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -1,4 +1,5 @@ #include "smlua.h" +#include "smlua_cobject_map.h" #include "game/hardcoded.h" #include "pc/mods/mods.h" #include "pc/mods/mods_utils.h" @@ -281,8 +282,7 @@ static void smlua_load_script(struct Mod* mod, struct ModFile* file, u16 remoteI void smlua_init(void) { smlua_shutdown(); - smlua_cobject_allowlist_init(); - smlua_cpointer_allowlist_init(); + smlua_pointer_user_data_init(); gLuaState = luaL_newstate(); lua_State* L = gLuaState; @@ -364,8 +364,7 @@ void smlua_shutdown(void) { smlua_text_utils_reset_all(); smlua_audio_utils_reset_all(); audio_custom_shutdown(); - smlua_cobject_allowlist_shutdown(); - smlua_cpointer_allowlist_shutdown(); + smlua_pointer_user_data_shutdown(); smlua_clear_hooks(); smlua_model_util_clear(); smlua_level_util_reset(); diff --git a/src/pc/lua/smlua.h b/src/pc/lua/smlua.h index 937612008..3ed42aab5 100644 --- a/src/pc/lua/smlua.h +++ b/src/pc/lua/smlua.h @@ -9,7 +9,6 @@ #include "types.h" #include "smlua_cobject.h" -#include "smlua_cobject_allowlist.h" #include "smlua_cobject_autogen.h" #include "smlua_utils.h" #include "smlua_functions.h" diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index e0b64f52e..eb7ea0388 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -10,6 +10,7 @@ #include "object_fields.h" #include "pc/djui/djui_hud_utils.h" #include "pc/lua/smlua.h" +#include "pc/lua/smlua_cobject_map.h" #include "pc/lua/utils/smlua_anim_utils.h" #include "pc/lua/utils/smlua_collision_utils.h" #include "pc/lua/utils/smlua_obj_utils.h" @@ -381,38 +382,30 @@ struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyInde static int smlua__get_field(lua_State* L) { LUA_STACK_CHECK_BEGIN(); - if (!smlua_functions_valid_param_count(L, 4)) { return 0; } - enum LuaObjectType lot = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { return 0; } + CObject *cobj = lua_touserdata(L, 1); + enum LuaObjectType lot = cobj->lot; + u64 pointer = (u64)(intptr_t) cobj->pointer; + const char *key = smlua_to_string(L, 2); - u64 pointer = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - const char* key = smlua_to_string(L, 3); - if (!gSmLuaConvertSuccess) { - LOG_LUA_LINE("Tried to get a non-string field of cobject"); - return 0; + // Legacy support + if (strcmp(key, "_pointer") == 0) { + lua_pushinteger(L, pointer); + return 1; + } + if (strcmp(key, "_lot") == 0) { + lua_pushinteger(L, cobj->lot); + return 1; } - if (pointer == 0) { - LOG_LUA_LINE("_get_field on null pointer"); - return 0; - } - - if (!smlua_valid_lot(lot)) { - LOG_LUA_LINE("_get_field on invalid LOT '%u'", lot); - return 0; - } - - if (!smlua_cobject_allowlist_contains(lot, pointer)) { - LOG_LUA_LINE("_get_field received a pointer not in allow list. '%u', '%llu", lot, (u64)pointer); + if (cobj->freed) { + LOG_LUA_LINE("_get_field on freed object"); return 0; } struct LuaObjectField* data = smlua_get_object_field(lot, key); if (data == NULL) { - data = smlua_get_custom_field(L, lot, 3); + data = smlua_get_custom_field(L, lot, 2); } if (data == NULL) { LOG_LUA_LINE("_get_field on invalid key '%s', lot '%d'", key, lot); @@ -470,38 +463,20 @@ static int smlua__get_field(lua_State* L) { static int smlua__set_field(lua_State* L) { LUA_STACK_CHECK_BEGIN(); - if (!smlua_functions_valid_param_count(L, 5)) { return 0; } - enum LuaObjectType lot = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { return 0; } + CObject *cobj = lua_touserdata(L, 1); + enum LuaObjectType lot = cobj->lot; + u64 pointer = (u64)(intptr_t) cobj->pointer; + const char *key = smlua_to_string(L, 2); - u64 pointer = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - const char* key = smlua_to_string(L, 3); - if (!gSmLuaConvertSuccess) { - LOG_LUA_LINE("Tried to set a non-string field of cobject"); - return 0; - } - - if (pointer == 0) { - LOG_LUA_LINE("_set_field on null pointer"); - return 0; - } - - if (!smlua_valid_lot(lot)) { - LOG_LUA_LINE("_set_field on invalid LOT '%u'", lot); - return 0; - } - - if (!smlua_cobject_allowlist_contains(lot, pointer)) { - LOG_LUA_LINE("_set_field received a pointer not in allow list. '%u', '%llu", lot, (u64)pointer); + if (cobj->freed) { + LOG_LUA_LINE("_set_field on freed object"); return 0; } struct LuaObjectField* data = smlua_get_object_field(lot, key); if (data == NULL) { - data = smlua_get_custom_field(L, lot, 3); + data = smlua_get_custom_field(L, lot, 2); } if (data == NULL) { @@ -517,18 +492,18 @@ static int smlua__set_field(lua_State* L) { void* valuePointer = NULL; u8* p = ((u8*)(intptr_t)pointer) + data->valueOffset; switch (data->valueType) { - case LVT_BOOL:*(u8*) p = smlua_to_boolean(L, 4); break; - case LVT_U8: *(u8*) p = smlua_to_integer(L, 4); break; - case LVT_U16: *(u16*)p = smlua_to_integer(L, 4); break; - case LVT_U32: *(u32*)p = smlua_to_integer(L, 4); break; - case LVT_S8: *(s8*) p = smlua_to_integer(L, 4); break; - case LVT_S16: *(s16*)p = smlua_to_integer(L, 4); break; - case LVT_S32: *(s32*)p = smlua_to_integer(L, 4); break; - case LVT_F32: *(f32*)p = smlua_to_number(L, 4); break; - case LVT_U64: *(s64*)p = smlua_to_integer(L, 4); break; + case LVT_BOOL:*(u8*) p = smlua_to_boolean(L, 3); break; + case LVT_U8: *(u8*) p = smlua_to_integer(L, 3); break; + case LVT_U16: *(u16*)p = smlua_to_integer(L, 3); break; + case LVT_U32: *(u32*)p = smlua_to_integer(L, 3); break; + case LVT_S8: *(s8*) p = smlua_to_integer(L, 3); break; + case LVT_S16: *(s16*)p = smlua_to_integer(L, 3); break; + case LVT_S32: *(s32*)p = smlua_to_integer(L, 3); break; + case LVT_F32: *(f32*)p = smlua_to_number(L, 3); break; + case LVT_U64: *(s64*)p = smlua_to_integer(L, 3); break; case LVT_COBJECT_P: - valuePointer = smlua_to_cobject(L, 4, data->lot); + valuePointer = smlua_to_cobject(L, 3, data->lot); if (gSmLuaConvertSuccess) { *(u8**)p = valuePointer; } @@ -548,7 +523,7 @@ static int smlua__set_field(lua_State* L) { case LVT_OBJECTANIMPOINTER_P: case LVT_COLLISION_P: case LVT_TRAJECTORY_P: - valuePointer = smlua_to_cpointer(L, 4, data->valueType); + valuePointer = smlua_to_cpointer(L, 3, data->valueType); if (gSmLuaConvertSuccess) { *(u8**)p = valuePointer; } @@ -567,6 +542,43 @@ static int smlua__set_field(lua_State* L) { return 1; } +int smlua__eq(lua_State *L) { + CObject *a = lua_touserdata(L, 1); + CObject *b = lua_touserdata(L, 2); + lua_pushboolean(L, a->lot == b->lot && a->pointer == b->pointer); + return 1; +} + +int smlua__gc(lua_State *L) { + CObject *cobj = lua_touserdata(L, 1); + if (!cobj->freed) { + switch (cobj->lot) { + case LOT_SURFACE: { + smlua_pointer_user_data_delete((uintptr_t) cobj->pointer); + } + } + } + return 0; +} + +static int smlua_cpointer_get(lua_State* L) { + CPointer *cptr = lua_touserdata(L, 1); + const char *key = smlua_to_string(L, 2); + + // Legacy support + if (strcmp(key, "_pointer") == 0) { + lua_pushinteger(L, (u64)(intptr_t) cptr->pointer); + return 1; + } + if (strcmp(key, "_lot") == 0) { + lua_pushinteger(L, cptr->lvt); + return 1; + } + + return 0; +} +static int smlua_cpointer_set(UNUSED lua_State* L) { return 0; } + ////////// // bind // ////////// @@ -574,6 +586,27 @@ static int smlua__set_field(lua_State* L) { void smlua_cobject_init_globals(void) { lua_State* L = gLuaState; + // Create metatables + luaL_newmetatable(L, "CObject"); + luaL_Reg cObjectMethods[] = { + { "__index", smlua__get_field }, + { "__newindex", smlua__set_field }, + { "__eq", smlua__eq }, + { "__gc", smlua__gc }, + { NULL, NULL } + }; + luaL_setfuncs(L, cObjectMethods, 0); + lua_pop(L, 1); + luaL_newmetatable(L, "CPointer"); + luaL_Reg cPointerMethods[] = { + { "__index", smlua_cpointer_get }, + { "__newindex", smlua_cpointer_set }, + { "__eq", smlua__eq }, + { NULL, NULL } + }; + luaL_setfuncs(L, cPointerMethods, 0); + lua_pop(L, 1); + #define EXPOSE_GLOBAL_ARRAY(lot, ptr, iterator) \ { \ lua_newtable(L); \ @@ -662,8 +695,4 @@ void smlua_bind_cobject(void) { lua_State* L = gLuaState; smlua_bind_function(L, "define_custom_obj_fields", smlua_func_define_custom_obj_fields); - - smlua_bind_function(L, "_get_field", smlua__get_field); - smlua_bind_function(L, "_set_field", smlua__set_field); - } diff --git a/src/pc/lua/smlua_cobject.h b/src/pc/lua/smlua_cobject.h index f0a3381c5..8f1c8cdf0 100644 --- a/src/pc/lua/smlua_cobject.h +++ b/src/pc/lua/smlua_cobject.h @@ -65,6 +65,18 @@ struct LuaObjectTable { u16 fieldCount; }; +typedef struct { + void *pointer; + u16 lot; + bool freed; +} CObject; + +typedef struct { + void *pointer; + u16 lvt; + bool freed; +} CPointer; + bool smlua_valid_lot(u16 lot); bool smlua_valid_lvt(u16 lvt); struct LuaObjectField* smlua_get_object_field_from_ot(struct LuaObjectTable* ot, const char* key); diff --git a/src/pc/lua/smlua_cobject_allowlist.c b/src/pc/lua/smlua_cobject_allowlist.c deleted file mode 100644 index 1d712fed3..000000000 --- a/src/pc/lua/smlua_cobject_allowlist.c +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include "smlua.h" -#include "data/dynos_cmap.cpp.h" - -#define LOT_COUNT (LOT_MAX + (LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN)) -static void* sObjectAllowList[LOT_COUNT] = { NULL }; -static u64 sCachedObjectAllowed[LOT_COUNT] = { 0 }; - -static u16 smlua_lot_mapping(u16 lot) { - if (lot >= LOT_MAX) { - return LOT_MAX + (lot - LOT_AUTOGEN_MIN); - } else { - return lot; - } -} - -void smlua_cobject_allowlist_init(void) { - smlua_cobject_allowlist_shutdown(); -} - -void smlua_cobject_allowlist_shutdown(void) { - for (s32 i = 0; i < LOT_COUNT; i++) { - sCachedObjectAllowed[i] = 0; - - if (sObjectAllowList[i]) { - hmap_clear(sObjectAllowList[i]); - } - } -} - -void smlua_cobject_allowlist_add(u16 lot, u64 pointer) { - if (pointer == 0) { return; } - if (!smlua_valid_lot(lot)) { return; } - - u16 m = smlua_lot_mapping(lot); - if (sCachedObjectAllowed[m] == pointer) { return; } - sCachedObjectAllowed[m] = pointer; - - if (!sObjectAllowList[m]) { - sObjectAllowList[m] = hmap_create(); - } - - if (!hmap_get(sObjectAllowList[m], pointer)) { - hmap_put(sObjectAllowList[m], pointer, (void*)1); - } -} - -bool smlua_cobject_allowlist_contains(u16 lot, u64 pointer) { - if (pointer == 0) { return false; } - if (!smlua_valid_lot(lot)) { return false; } - - u16 m = smlua_lot_mapping(lot); - if (sCachedObjectAllowed[m] == pointer) { return true; } - - if (!sObjectAllowList[m]) { return false; } - return hmap_get(sObjectAllowList[m], pointer) != 0; -} - -///////////////////////////// - -static void* sPointerAllowList[LVT_MAX] = { 0 }; -static u64 sCachedPointerAllowed[LVT_MAX] = { 0 }; - -void smlua_cpointer_allowlist_init(void) { - smlua_cpointer_allowlist_shutdown(); -} - -void smlua_cpointer_allowlist_shutdown(void) { - for (s32 i = 0; i < LVT_MAX; i++) { - sCachedPointerAllowed[i] = 0; - - if (sPointerAllowList[i]) { - hmap_clear(sPointerAllowList[i]); - } - } -} - -void smlua_cpointer_allowlist_add(u16 lvt, u64 pointer) { - if (pointer == 0) { return; } - if (!smlua_valid_lvt(lvt)) { return; } - - if (sCachedPointerAllowed[lvt] == pointer) { return; } - sCachedPointerAllowed[lvt] = pointer; - - if (!sPointerAllowList[lvt]) { - sPointerAllowList[lvt] = hmap_create(); - } - - if (!hmap_get(sPointerAllowList[lvt], pointer)) { - hmap_put(sPointerAllowList[lvt], pointer, (void*)1); - } -} - -bool smlua_cpointer_allowlist_contains(u16 lvt, u64 pointer) { - if (pointer == 0) { return false; } - if (!smlua_valid_lvt(lvt)) { return false; } - - if (sCachedPointerAllowed[lvt] == pointer) { return true; } - - if (!sPointerAllowList[lvt]) { return false; } - return hmap_get(sPointerAllowList[lvt], pointer) != 0; -} \ No newline at end of file diff --git a/src/pc/lua/smlua_cobject_allowlist.h b/src/pc/lua/smlua_cobject_allowlist.h deleted file mode 100644 index 33b24a485..000000000 --- a/src/pc/lua/smlua_cobject_allowlist.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef SMLUA_COBJECT_ALLOWLIST_H -#define SMLUA_COBJECT_ALLOWLIST_H - -void smlua_cobject_allowlist_init(void); -void smlua_cobject_allowlist_shutdown(void); -void smlua_cobject_allowlist_add(u16 lot, u64 pointer); -bool smlua_cobject_allowlist_contains(u16 lot, u64 pointer); - -void smlua_cpointer_allowlist_init(void); -void smlua_cpointer_allowlist_shutdown(void); -void smlua_cpointer_allowlist_add(u16 lvt, u64 pointer); -bool smlua_cpointer_allowlist_contains(u16 lvt, u64 pointer); - -#endif \ No newline at end of file diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 260cab049..eaece9f8b 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -604,10 +604,11 @@ static struct LuaObjectField sCharacterFields[LUA_CHARACTER_FIELD_COUNT] = { { "type", LVT_S32, offsetof(struct Character, type), true, LOT_NONE }, }; -#define LUA_CONTROLLER_FIELD_COUNT 10 +#define LUA_CONTROLLER_FIELD_COUNT 11 static struct LuaObjectField sControllerFields[LUA_CONTROLLER_FIELD_COUNT] = { { "buttonDown", LVT_U16, offsetof(struct Controller, buttonDown), false, LOT_NONE }, { "buttonPressed", LVT_U16, offsetof(struct Controller, buttonPressed), false, LOT_NONE }, + { "buttonReleased", LVT_U16, offsetof(struct Controller, buttonReleased), false, LOT_NONE }, // { "controllerData", LVT_???, offsetof(struct Controller, controllerData), true, LOT_??? }, <--- UNIMPLEMENTED { "extStickX", LVT_S16, offsetof(struct Controller, extStickX), false, LOT_NONE }, { "extStickY", LVT_S16, offsetof(struct Controller, extStickY), false, LOT_NONE }, @@ -1249,7 +1250,7 @@ static struct LuaObjectField sNametagsSettingsFields[LUA_NAMETAGS_SETTINGS_FIELD { "showSelfTag", LVT_BOOL, offsetof(struct NametagsSettings, showSelfTag), false, LOT_NONE }, }; -#define LUA_NETWORK_PLAYER_FIELD_COUNT 31 +#define LUA_NETWORK_PLAYER_FIELD_COUNT 32 static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT] = { { "connected", LVT_BOOL, offsetof(struct NetworkPlayer, connected), true, LOT_NONE }, { "currActNum", LVT_S16, offsetof(struct NetworkPlayer, currActNum), true, LOT_NONE }, @@ -1274,6 +1275,7 @@ static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT { "modelIndex", LVT_U8, offsetof(struct NetworkPlayer, modelIndex), true, LOT_NONE }, { "name", LVT_STRING, offsetof(struct NetworkPlayer, name), true, LOT_NONE }, { "onRxSeqId", LVT_U8, offsetof(struct NetworkPlayer, onRxSeqId), true, LOT_NONE }, + { "overrideLocation", LVT_STRING, offsetof(struct NetworkPlayer, overrideLocation), true, LOT_NONE }, { "overrideModelIndex", LVT_U8, offsetof(struct NetworkPlayer, overrideModelIndex), false, LOT_NONE }, { "overridePalette", LVT_COBJECT, offsetof(struct NetworkPlayer, overridePalette), false, LOT_PLAYERPALETTE }, { "overridePaletteIndex", LVT_U8, offsetof(struct NetworkPlayer, overridePaletteIndex), false, LOT_NONE }, diff --git a/src/pc/lua/smlua_cobject_map.c b/src/pc/lua/smlua_cobject_map.c new file mode 100644 index 000000000..d0bf51287 --- /dev/null +++ b/src/pc/lua/smlua_cobject_map.c @@ -0,0 +1,35 @@ +#include +#include "smlua.h" +#include "data/dynos_cmap.cpp.h" + +static void* sPointers = NULL; + +void smlua_pointer_user_data_shutdown(void) { + hmap_clear(sPointers); +} + +void smlua_pointer_user_data_init(void) { + smlua_pointer_user_data_shutdown(); +} + +void smlua_pointer_user_data_add(uintptr_t pointer, CObject *obj) { + if (pointer == 0) { return; } + + if (!sPointers) { + sPointers = hmap_create(); + } + + if (!hmap_get(sPointers, pointer)) { + hmap_put(sPointers, pointer, obj); + } +} + +void smlua_pointer_user_data_delete(uintptr_t pointer) { + if (pointer == 0) { return; } + hmap_del(sPointers, pointer); +} + +CObject *smlua_pointer_user_data_get(uintptr_t pointer) { + if (pointer == 0) { return NULL; } + return hmap_get(sPointers, pointer); +} diff --git a/src/pc/lua/smlua_cobject_map.h b/src/pc/lua/smlua_cobject_map.h new file mode 100644 index 000000000..e5e22a37b --- /dev/null +++ b/src/pc/lua/smlua_cobject_map.h @@ -0,0 +1,10 @@ +#ifndef SMLUA_COBJECT_MAP_H +#define SMLUA_COBJECT_MAP_H + +void smlua_pointer_user_data_init(void); +void smlua_pointer_user_data_shutdown(void); +void smlua_pointer_user_data_add(uintptr_t pointer, CObject *obj); +void smlua_pointer_user_data_delete(uintptr_t pointer); +CObject *smlua_pointer_user_data_get(uintptr_t pointer); + +#endif diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 8852a5802..1b66ca230 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1,65 +1,5 @@ char gSmluaConstants[] = "" "math.randomseed(get_time())\n" -"--------------\n" -"-- CObjects --\n" -"--------------\n" -"_CObjectPool = {}\n" -"_CObject = {\n" -" __index = function (t,k)\n" -" return _get_field(t['_lot'], t['_pointer'], k, t)\n" -" end,\n" -" __newindex = function (t,k,v)\n" -" _set_field(t['_lot'], t['_pointer'], k, v, t)\n" -" end,\n" -" __tostring = function(t)\n" -" return 'CObject: ' .. t['_lot'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']'\n" -" end,\n" -" __eq = function (a, b)\n" -" return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n" -" end\n" -"}\n" -"function _NewCObject(lot, pointer)\n" -" if _CObjectPool[lot] == nil then\n" -" _CObjectPool[lot] = {}\n" -" end\n" -" if _CObjectPool[lot][pointer] == nil then\n" -" local obj = {}\n" -" rawset(obj, '_pointer', pointer)\n" -" rawset(obj, '_lot', lot)\n" -" setmetatable(obj, _CObject)\n" -" _CObjectPool[lot][pointer] = obj\n" -" return obj\n" -" end\n" -" return _CObjectPool[lot][pointer]\n" -"end\n" -"local _CPointerPool = {}\n" -"_CPointer = {\n" -" __index = function (t,k)\n" -" return nil\n" -" end,\n" -" __newindex = function (t,k,v)\n" -" end,\n" -" __tostring = function(t)\n" -" return 'CPointer: ' .. t['_lvt'] .. ', [' .. string.format('0x%08X', t['_pointer']) .. ']'\n" -" end,\n" -" __eq = function (a, b)\n" -" return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n" -" end\n" -"}\n" -"function _NewCPointer(lvt, pointer)\n" -" if _CPointerPool[lvt] == nil then\n" -" _CPointerPool[lvt] = {}\n" -" end\n" -" if _CPointerPool[lvt][pointer] == nil then\n" -" local obj = {}\n" -" rawset(obj, '_pointer', pointer)\n" -" rawset(obj, '_lvt', lvt)\n" -" setmetatable(obj, _CPointer)\n" -" _CPointerPool[lvt][pointer] = obj\n" -" return obj\n" -" end\n" -" return _CPointerPool[lvt][pointer]\n" -"end\n" "_SyncTable = {\n" " __index = function (t,k)\n" " local _table = rawget(t, '_table')\n" @@ -1479,6 +1419,7 @@ char gSmluaConstants[] = "" "INT_HIT_FROM_BELOW = (1 << 7)\n" "INT_TWIRL = (1 << 8)\n" "INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL)\n" +"INT_LUA = (1 << 31)\n" "INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)\n" "INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)\n" "INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)\n" @@ -2080,7 +2021,7 @@ char gSmluaConstants[] = "" "GRAB_POS_HEAVY_OBJ = 2\n" "GRAB_POS_BOWSER = 3\n" "MAX_KEYS = 512\n" -"MAX_KEY_VALUE_LENGTH = 256\n" +"MAX_KEY_VALUE_LENGTH = 512\n" "SYNC_DISTANCE_ONLY_DEATH = -1\n" "SYNC_DISTANCE_ONLY_EVENTS = -2\n" "SYNC_DISTANCE_INFINITE = 0\n" @@ -3290,7 +3231,8 @@ char gSmluaConstants[] = "" "HOOK_ON_ATTACK_OBJECT = 43\n" "HOOK_ON_LANGUAGE_CHANGED = 44\n" "HOOK_ON_MODS_LOADED = 45\n" -"HOOK_MAX = 46\n" +"HOOK_ON_NAMETAGS_RENDER = 46\n" +"HOOK_MAX = 47\n" "ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_MAX = 2\n" @@ -4397,10 +4339,10 @@ char gSmluaConstants[] = "" "COOP_OBJ_FLAG_LUA = (1 << 1)\n" "COOP_OBJ_FLAG_NON_SYNC = (1 << 2)\n" "COOP_OBJ_FLAG_INITIALIZED = (1 << 3)\n" -"SM64COOPDX_VERSION = 'v1.0.3'\n" +"SM64COOPDX_VERSION = 'v1.0.4'\n" "VERSION_TEXT = 'v'\n" "VERSION_NUMBER = 37\n" -"MINOR_VERSION_NUMBER = 2\n" +"MINOR_VERSION_NUMBER = 3\n" "VERSION_REGION = 'JP'\n" "VERSION_REGION = 'EU'\n" "VERSION_REGION = 'SH'\n" diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 481d26d17..b722976b1 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -38,38 +38,6 @@ bool smlua_functions_valid_param_range(lua_State* L, int min, int max) { // misc // ////////// -int smlua_func_sins(lua_State* L) { - if (!smlua_functions_valid_param_count(L, 1)) { return 0; } - - s16 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("sins: Failed to convert parameter 1"); return 0; } - - lua_pushnumber(L, sins(x)); - return 1; -} - -int smlua_func_coss(lua_State* L) { - if (!smlua_functions_valid_param_count(L, 1)) { return 0; } - - s16 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("coss: Failed to convert parameter 1"); return 0; } - - lua_pushnumber(L, coss(x)); - return 1; -} - -int smlua_func_atan2s(lua_State* L) { - if (!smlua_functions_valid_param_count(L, 2)) { return 0; } - - f32 y = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("atan2s: Failed to convert parameter 1"); return 0; } - f32 x = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("atan2s: Failed to convert parameter 2"); return 0; } - - lua_pushinteger(L, atan2s(y, x)); - return 1; -} - int smlua_func_init_mario_after_warp(lua_State* L) { if (network_player_connected_count() >= 2) { LOG_LUA_LINE("init_mario_after_warp() can only be used in singleplayer"); @@ -880,9 +848,6 @@ void smlua_bind_functions(void) { lua_State* L = gLuaState; // misc - smlua_bind_function(L, "sins", smlua_func_sins); - smlua_bind_function(L, "coss", smlua_func_coss); - smlua_bind_function(L, "atan2s", smlua_func_atan2s); smlua_bind_function(L, "init_mario_after_warp", smlua_func_init_mario_after_warp); smlua_bind_function(L, "initiate_warp", smlua_func_initiate_warp); smlua_bind_function(L, "network_init_object", smlua_func_network_init_object); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index e1f2a50aa..dc687984c 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -12295,6 +12295,21 @@ int smlua_func_djui_hud_get_font(UNUSED lua_State* L) { return 1; } +int smlua_func_djui_hud_get_fov_coeff(UNUSED 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", "djui_hud_get_fov_coeff", 0, top); + return 0; + } + + + lua_pushnumber(L, djui_hud_get_fov_coeff()); + + return 1; +} + int smlua_func_djui_hud_get_mouse_x(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -12757,6 +12772,21 @@ int smlua_func_djui_open_pause_menu(UNUSED lua_State* L) { return 1; } +int smlua_func_get_current_fov(UNUSED 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", "get_current_fov", 0, top); + return 0; + } + + + lua_pushnumber(L, get_current_fov()); + + return 1; +} + ////////////////// // djui_popup.h // ////////////////// @@ -18362,6 +18392,42 @@ int smlua_func_approach_s32(lua_State* L) { return 1; } +int smlua_func_atan2s(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", "atan2s", 2, top); + return 0; + } + + f32 y = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "atan2s"); return 0; } + f32 x = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "atan2s"); return 0; } + + lua_pushinteger(L, atan2s(y, x)); + + return 1; +} + +int smlua_func_coss(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", "coss", 1, top); + return 0; + } + + s16 sm64Angle = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "coss"); return 0; } + + lua_pushnumber(L, coss(sm64Angle)); + + return 1; +} + int smlua_func_find_vector_perpendicular_to_plane(lua_State* L) { if (L == NULL) { return 0; } @@ -18514,6 +18580,82 @@ int smlua_func_get_pos_from_transform_mtx(lua_State* L) { return 1; } +int smlua_func_max(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", "max", 2, top); + return 0; + } + + s16 a = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "max"); return 0; } + s16 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "max"); return 0; } + + lua_pushinteger(L, max(a, b)); + + return 1; +} + +int smlua_func_maxf(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", "maxf", 2, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "maxf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "maxf"); return 0; } + + lua_pushnumber(L, maxf(a, b)); + + return 1; +} + +int smlua_func_min(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", "min", 2, top); + return 0; + } + + s16 a = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "min"); return 0; } + s16 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "min"); return 0; } + + lua_pushinteger(L, min(a, b)); + + return 1; +} + +int smlua_func_minf(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", "minf", 2, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "minf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "minf"); return 0; } + + lua_pushnumber(L, minf(a, b)); + + return 1; +} + int smlua_func_mtxf_align_terrain_normal(lua_State* L) { if (L == NULL) { return 0; } @@ -19723,6 +19865,23 @@ int smlua_func_not_zero(lua_State* L) { return 1; } +int smlua_func_sins(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", "sins", 1, top); + return 0; + } + + s16 sm64Angle = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sins"); return 0; } + + lua_pushnumber(L, sins(sm64Angle)); + + return 1; +} + int smlua_func_spline_get_weights(lua_State* L) { if (L == NULL) { return 0; } @@ -19756,6 +19915,40 @@ int smlua_func_spline_get_weights(lua_State* L) { return 1; } +int smlua_func_sqr(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", "sqr", 1, top); + return 0; + } + + s16 x = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqr"); return 0; } + + lua_pushinteger(L, sqr(x)); + + return 1; +} + +int smlua_func_sqrf(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", "sqrf", 1, top); + return 0; + } + + f32 x = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqrf"); return 0; } + + lua_pushnumber(L, sqrf(x)); + + return 1; +} + int smlua_func_vec3f_add(lua_State* L) { if (L == NULL) { return 0; } @@ -20927,6 +21120,25 @@ int smlua_func_network_player_set_description(lua_State* L) { return 1; } +int smlua_func_network_player_set_override_location(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", "network_player_set_override_location", 2, top); + return 0; + } + + struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_set_override_location"); return 0; } + const char* location = smlua_to_string(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "network_player_set_override_location"); return 0; } + + network_player_set_override_location(np, location); + + return 1; +} + int smlua_func_network_player_set_override_palette_color(lua_State* L) { if (L == NULL) { return 0; } @@ -29015,6 +29227,21 @@ int smlua_func_camera_freeze(UNUSED lua_State* L) { return 1; } +int smlua_func_camera_get_checking_surfaces(UNUSED 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", "camera_get_checking_surfaces", 0, top); + return 0; + } + + + lua_pushboolean(L, camera_get_checking_surfaces()); + + return 1; +} + int smlua_func_camera_is_frozen(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -29079,6 +29306,23 @@ int smlua_func_camera_romhack_allow_dpad_usage(lua_State* L) { return 1; } +int smlua_func_camera_set_checking_surfaces(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", "camera_set_checking_surfaces", 1, top); + return 0; + } + + bool value = smlua_to_boolean(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "camera_set_checking_surfaces"); return 0; } + + camera_set_checking_surfaces(value); + + return 1; +} + int smlua_func_camera_set_romhack_override(lua_State* L) { if (L == NULL) { return 0; } @@ -29987,112 +30231,89 @@ int smlua_func_clampf(lua_State* L) { return 1; } -int smlua_func_max(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", "max", 2, top); - return 0; - } - - s32 a = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "max"); return 0; } - s32 b = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "max"); return 0; } - - lua_pushinteger(L, max(a, b)); - - return 1; -} - -int smlua_func_maxf(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", "maxf", 2, top); - return 0; - } - - f32 a = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "maxf"); return 0; } - f32 b = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "maxf"); return 0; } - - lua_pushnumber(L, maxf(a, b)); - - return 1; -} - -int smlua_func_min(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", "min", 2, top); - return 0; - } - - s32 a = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "min"); return 0; } - s32 b = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "min"); return 0; } - - lua_pushinteger(L, min(a, b)); - - return 1; -} - -int smlua_func_minf(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", "minf", 2, top); - return 0; - } - - f32 a = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "minf"); return 0; } - f32 b = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "minf"); return 0; } - - lua_pushnumber(L, minf(a, b)); - - return 1; -} - -int smlua_func_sqr(lua_State* L) { +int smlua_func_degrees_to_sm64(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", "sqr", 1, top); + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "degrees_to_sm64", 1, top); return 0; } - s32 x = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqr"); return 0; } + f32 degreesAngle = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "degrees_to_sm64"); return 0; } - lua_pushinteger(L, sqr(x)); + lua_pushinteger(L, degrees_to_sm64(degreesAngle)); return 1; } -int smlua_func_sqrf(lua_State* L) { +int smlua_func_hypotf(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", "hypotf", 2, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "hypotf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "hypotf"); return 0; } + + lua_pushnumber(L, hypotf(a, b)); + + return 1; +} + +int smlua_func_radians_to_sm64(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", "sqrf", 1, top); + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "radians_to_sm64", 1, top); return 0; } - f32 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqrf"); return 0; } + f32 radiansAngle = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "radians_to_sm64"); return 0; } - lua_pushnumber(L, sqrf(x)); + lua_pushinteger(L, radians_to_sm64(radiansAngle)); + + return 1; +} + +int smlua_func_sm64_to_degrees(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", "sm64_to_degrees", 1, top); + return 0; + } + + s16 sm64Angle = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sm64_to_degrees"); return 0; } + + lua_pushnumber(L, sm64_to_degrees(sm64Angle)); + + return 1; +} + +int smlua_func_sm64_to_radians(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", "sm64_to_radians", 1, top); + return 0; + } + + s16 sm64Angle = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sm64_to_radians"); return 0; } + + lua_pushnumber(L, sm64_to_radians(sm64Angle)); return 1; } @@ -30152,6 +30373,21 @@ int smlua_func_deref_s32_pointer(lua_State* L) { return 1; } +int smlua_func_djui_attempting_to_open_playerlist(UNUSED 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", "djui_attempting_to_open_playerlist", 0, top); + return 0; + } + + + lua_pushboolean(L, djui_attempting_to_open_playerlist()); + + return 1; +} + int smlua_func_djui_is_playerlist_open(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -30248,6 +30484,23 @@ int smlua_func_djui_set_popup_disabled_override(lua_State* L) { return 1; } +int smlua_func_get_coopnet_id(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", "get_coopnet_id", 1, top); + return 0; + } + + s8 localIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_coopnet_id"); return 0; } + + lua_pushstring(L, get_coopnet_id(localIndex)); + + return 1; +} + int smlua_func_get_current_save_file_num(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -33753,6 +34006,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_hud_get_color", smlua_func_djui_hud_get_color); smlua_bind_function(L, "djui_hud_get_filter", smlua_func_djui_hud_get_filter); smlua_bind_function(L, "djui_hud_get_font", smlua_func_djui_hud_get_font); + smlua_bind_function(L, "djui_hud_get_fov_coeff", smlua_func_djui_hud_get_fov_coeff); smlua_bind_function(L, "djui_hud_get_mouse_x", smlua_func_djui_hud_get_mouse_x); smlua_bind_function(L, "djui_hud_get_mouse_y", smlua_func_djui_hud_get_mouse_y); smlua_bind_function(L, "djui_hud_get_raw_mouse_x", smlua_func_djui_hud_get_raw_mouse_x); @@ -33777,6 +34031,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_hud_set_rotation_interpolated", smlua_func_djui_hud_set_rotation_interpolated); smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos); smlua_bind_function(L, "djui_open_pause_menu", smlua_func_djui_open_pause_menu); + smlua_bind_function(L, "get_current_fov", smlua_func_get_current_fov); // djui_popup.h smlua_bind_function(L, "djui_popup_create", smlua_func_djui_popup_create); @@ -34104,8 +34359,14 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "anim_spline_poll", smlua_func_anim_spline_poll); smlua_bind_function(L, "approach_f32", smlua_func_approach_f32); smlua_bind_function(L, "approach_s32", smlua_func_approach_s32); + smlua_bind_function(L, "atan2s", smlua_func_atan2s); + smlua_bind_function(L, "coss", smlua_func_coss); smlua_bind_function(L, "find_vector_perpendicular_to_plane", smlua_func_find_vector_perpendicular_to_plane); smlua_bind_function(L, "get_pos_from_transform_mtx", smlua_func_get_pos_from_transform_mtx); + smlua_bind_function(L, "max", smlua_func_max); + smlua_bind_function(L, "maxf", smlua_func_maxf); + smlua_bind_function(L, "min", smlua_func_min); + smlua_bind_function(L, "minf", smlua_func_minf); smlua_bind_function(L, "mtxf_align_terrain_normal", smlua_func_mtxf_align_terrain_normal); smlua_bind_function(L, "mtxf_align_terrain_triangle", smlua_func_mtxf_align_terrain_triangle); smlua_bind_function(L, "mtxf_billboard", smlua_func_mtxf_billboard); @@ -34123,7 +34384,10 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "mtxf_to_mtx", smlua_func_mtxf_to_mtx); smlua_bind_function(L, "mtxf_translate", smlua_func_mtxf_translate); smlua_bind_function(L, "not_zero", smlua_func_not_zero); + smlua_bind_function(L, "sins", smlua_func_sins); smlua_bind_function(L, "spline_get_weights", smlua_func_spline_get_weights); + smlua_bind_function(L, "sqr", smlua_func_sqr); + smlua_bind_function(L, "sqrf", smlua_func_sqrf); smlua_bind_function(L, "vec3f_add", smlua_func_vec3f_add); smlua_bind_function(L, "vec3f_combine", smlua_func_vec3f_combine); smlua_bind_function(L, "vec3f_copy", smlua_func_vec3f_copy); @@ -34171,6 +34435,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "network_player_is_override_palette_same", smlua_func_network_player_is_override_palette_same); smlua_bind_function(L, "network_player_reset_override_palette", smlua_func_network_player_reset_override_palette); smlua_bind_function(L, "network_player_set_description", smlua_func_network_player_set_description); + smlua_bind_function(L, "network_player_set_override_location", smlua_func_network_player_set_override_location); smlua_bind_function(L, "network_player_set_override_palette_color", smlua_func_network_player_set_override_palette_color); // network_utils.h @@ -34595,10 +34860,12 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "camera_config_set_x_sensitivity", smlua_func_camera_config_set_x_sensitivity); smlua_bind_function(L, "camera_config_set_y_sensitivity", smlua_func_camera_config_set_y_sensitivity); smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze); + smlua_bind_function(L, "camera_get_checking_surfaces", smlua_func_camera_get_checking_surfaces); smlua_bind_function(L, "camera_is_frozen", smlua_func_camera_is_frozen); smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides); smlua_bind_function(L, "camera_romhack_allow_centering", smlua_func_camera_romhack_allow_centering); smlua_bind_function(L, "camera_romhack_allow_dpad_usage", smlua_func_camera_romhack_allow_dpad_usage); + smlua_bind_function(L, "camera_set_checking_surfaces", smlua_func_camera_set_checking_surfaces); smlua_bind_function(L, "camera_set_romhack_override", smlua_func_camera_set_romhack_override); smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze); @@ -34657,23 +34924,24 @@ void smlua_bind_functions_autogen(void) { // smlua_math_utils.h smlua_bind_function(L, "clamp", smlua_func_clamp); smlua_bind_function(L, "clampf", smlua_func_clampf); - smlua_bind_function(L, "max", smlua_func_max); - smlua_bind_function(L, "maxf", smlua_func_maxf); - smlua_bind_function(L, "min", smlua_func_min); - smlua_bind_function(L, "minf", smlua_func_minf); - smlua_bind_function(L, "sqr", smlua_func_sqr); - smlua_bind_function(L, "sqrf", smlua_func_sqrf); + smlua_bind_function(L, "degrees_to_sm64", smlua_func_degrees_to_sm64); + smlua_bind_function(L, "hypotf", smlua_func_hypotf); + smlua_bind_function(L, "radians_to_sm64", smlua_func_radians_to_sm64); + smlua_bind_function(L, "sm64_to_degrees", smlua_func_sm64_to_degrees); + smlua_bind_function(L, "sm64_to_radians", smlua_func_sm64_to_radians); // smlua_misc_utils.h smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action); smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course); smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer); + smlua_bind_function(L, "djui_attempting_to_open_playerlist", smlua_func_djui_attempting_to_open_playerlist); smlua_bind_function(L, "djui_is_playerlist_open", smlua_func_djui_is_playerlist_open); smlua_bind_function(L, "djui_is_popup_disabled", smlua_func_djui_is_popup_disabled); smlua_bind_function(L, "djui_menu_get_font", smlua_func_djui_menu_get_font); smlua_bind_function(L, "djui_popup_create_global", smlua_func_djui_popup_create_global); smlua_bind_function(L, "djui_reset_popup_disabled_override", smlua_func_djui_reset_popup_disabled_override); smlua_bind_function(L, "djui_set_popup_disabled_override", smlua_func_djui_set_popup_disabled_override); + smlua_bind_function(L, "get_coopnet_id", smlua_func_get_coopnet_id); smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num); smlua_bind_function(L, "get_date_and_time", smlua_func_get_date_and_time); smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index 4d90aa925..b6b6887f6 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -15,72 +15,14 @@ #include "pc/network/socket/socket.h" #include "pc/chat_commands.h" #include "pc/pc_main.h" +#include "pc/djui/djui_lua_profiler.h" #include "pc/djui/djui_panel.h" +#include "pc/configfile.h" #include "../mods/mods.h" #include "game/print.h" #include "gfx_dimensions.h" -#define MAX_PROFILED_MODS 16 -#define REFRESH_RATE 15 - -static struct { - f64 start; - f64 end; - f64 sum; - f64 disp; -} sLuaProfilerCounters[MAX_PROFILED_MODS]; - -static void lua_profiler_start_counter(UNUSED struct Mod *mod) { -#ifndef WAPI_DUMMY - for (s32 i = 0; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i) { - if (gActiveMods.entries[i] == mod) { - f64 freq = SDL_GetPerformanceFrequency(); - f64 curr = SDL_GetPerformanceCounter(); - sLuaProfilerCounters[i].start = curr / freq; - return; - } - } -#endif -} - -static void lua_profiler_stop_counter(UNUSED struct Mod *mod) { -#ifndef WAPI_DUMMY - for (s32 i = 0; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i) { - if (gActiveMods.entries[i] == mod) { - f64 freq = SDL_GetPerformanceFrequency(); - f64 curr = SDL_GetPerformanceCounter(); - sLuaProfilerCounters[i].end = curr / freq; - sLuaProfilerCounters[i].sum += sLuaProfilerCounters[i].end - sLuaProfilerCounters[i].start; - return; - } - } -#endif -} - -void lua_profiler_update_counters(void) { - if (gGlobalTimer % REFRESH_RATE == 0) { - for (s32 i = 0; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i) { - sLuaProfilerCounters[i].disp = sLuaProfilerCounters[i].sum / (f64) REFRESH_RATE; - sLuaProfilerCounters[i].sum = 0; - } - } - for (s32 i = 0, y = SCREEN_HEIGHT - 60; i != MIN(MAX_PROFILED_MODS, gActiveMods.entryCount); ++i, y -= 18) { - const char *modName = gActiveMods.entries[i]->relativePath; - s32 modCounterUs = (s32) (sLuaProfilerCounters[i].disp * 1000000.0); - char text[256]; - snprintf(text, 256, " %05d", modCounterUs); - memcpy(text, modName, MIN(12, strlen(modName) - (gActiveMods.entries[i]->isDirectory ? 0 : 4))); - for (s32 j = 0; j != 12; ++j) { - char c = text[j]; - if (c >= 'a' && c <= 'z') c -= ('a' - 'A'); - if ((c < '0' || c > '9') && (c < 'A' || c > 'Z')) c = ' '; - text[j] = c; - } - print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(4), y, text); - } -} - #define MAX_HOOKED_REFERENCES 64 #define LUA_BEHAVIOR_FLAG (1 << 15) @@ -101,18 +43,13 @@ int smlua_call_hook(lua_State* L, int nargs, int nresults, int errfunc, struct M gLuaActiveMod = activeMod; gLuaLastHookMod = activeMod; - extern bool configLuaProfiler; - if (configLuaProfiler) { - lua_profiler_start_counter(activeMod); - } + lua_profiler_start_counter(activeMod); CTX_BEGIN(CTX_HOOK); int rc = smlua_pcall(L, nargs, nresults, errfunc); CTX_END(CTX_HOOK); - if (configLuaProfiler) { - lua_profiler_stop_counter(activeMod); - } + lua_profiler_stop_counter(activeMod); gLuaActiveMod = prev; return rc; @@ -690,6 +627,36 @@ void smlua_call_event_hooks_int_params_ret_int(enum LuaHookedEventType hookType, } } +void smlua_call_event_hooks_int_params_ret_string(enum LuaHookedEventType hookType, s32 param, char** returnValue) { + lua_State* L = gLuaState; + if (L == NULL) { return; } + struct LuaHookedEvent* hook = &sHookedEvents[hookType]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push params + lua_pushinteger(L, param); + + // call the callback + if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i])) { + LOG_LUA("Failed to call the callback: %u", hookType); + continue; + } + + // output the return value + if (lua_type(L, -1) == LUA_TSTRING) { + *returnValue = (char *)smlua_to_string(L, -1); + lua_settop(L, prevTop); + return; + } else { + lua_settop(L, prevTop); + } + } +} + void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex) { lua_State* L = gLuaState; if (L == NULL) { return; } @@ -1186,6 +1153,7 @@ int smlua_hook_mario_action(lua_State* L) { lua_Integer interactionType = 0; if (paramCount >= 3) { interactionType = smlua_to_integer(L, 3); + interactionType |= (1 << 31); /* INT_LUA */ if (!gSmLuaConvertSuccess) { LOG_LUA_LINE("Hook Action: tried to hook invalid interactionType: %lld, %u", interactionType, gSmLuaConvertSuccess); return 0; @@ -2212,6 +2180,81 @@ int smlua_update_mod_menu_element_name(lua_State* L) { return 1; } +int smlua_update_mod_menu_element_checkbox(lua_State* L) { + if (L == NULL) { return 0; } + if (!smlua_functions_valid_param_count(L, 2)) { return 0; } + + int index = smlua_to_integer(L, 1); + if (index >= gHookedModMenuElementsCount || !gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element"); + return 0; + } + + if (gHookedModMenuElements[index].element != MOD_MENU_ELEMENT_CHECKBOX) { + LOG_LUA_LINE("Update mod menu element: element is not a checkbox."); + return 0; + } + + bool boolValue = smlua_to_boolean(L, 2); + if (!gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element"); + return 0; + } + + gHookedModMenuElements[index].boolValue = boolValue; + return 1; +} + +int smlua_update_mod_menu_element_slider(lua_State* L) { + if (L == NULL) { return 0; } + if (!smlua_functions_valid_param_count(L, 2)) { return 0; } + + int index = smlua_to_integer(L, 1); + if (index >= gHookedModMenuElementsCount || !gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element"); + return 0; + } + + if (gHookedModMenuElements[index].element != MOD_MENU_ELEMENT_SLIDER) { + LOG_LUA_LINE("Update mod menu element: element is not a slider."); + return 0; + } + + u32 uintValue = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element"); + return 0; + } + + gHookedModMenuElements[index].uintValue = uintValue; + return 1; +} + +int smlua_update_mod_menu_element_inputbox(lua_State* L) { + if (L == NULL) { return 0; } + if (!smlua_functions_valid_param_count(L, 2)) { return 0; } + + int index = smlua_to_integer(L, 1); + if (index >= gHookedModMenuElementsCount || !gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element"); + return 0; + } + + if (gHookedModMenuElements[index].element != MOD_MENU_ELEMENT_INPUTBOX) { + LOG_LUA_LINE("Update mod menu element: element is not an inputbox."); + return 0; + } + + const char* stringValue = smlua_to_string(L, 2); + if (stringValue == NULL || strlen(stringValue) == 0 || !gSmLuaConvertSuccess) { + LOG_LUA_LINE("Update mod menu element: tried to update invalid element string"); + return 0; + } + + snprintf(gHookedModMenuElements[index].stringValue, gHookedModMenuElements[index].length, "%s", stringValue); + return 1; +} + void smlua_call_mod_menu_element_hook(struct LuaHookedModMenuElement* hooked, int index) { lua_State* L = gLuaState; if (L == NULL) { return; } @@ -2342,4 +2385,7 @@ void smlua_bind_hooks(void) { smlua_bind_function(L, "hook_mod_menu_inputbox", smlua_hook_mod_menu_inputbox); smlua_bind_function(L, "update_chat_command_description", smlua_update_chat_command_description); smlua_bind_function(L, "update_mod_menu_element_name", smlua_update_mod_menu_element_name); + smlua_bind_function(L, "update_mod_menu_element_checkbox", smlua_update_mod_menu_element_checkbox); + smlua_bind_function(L, "update_mod_menu_element_slider", smlua_update_mod_menu_element_slider); + smlua_bind_function(L, "update_mod_menu_element_inputbox", smlua_update_mod_menu_element_inputbox); } diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index 933a50a69..e36fc0651 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -57,6 +57,7 @@ enum LuaHookedEventType { HOOK_ON_ATTACK_OBJECT, HOOK_ON_LANGUAGE_CHANGED, HOOK_ON_MODS_LOADED, + HOOK_ON_NAMETAGS_RENDER, HOOK_MAX, }; @@ -107,6 +108,7 @@ static const char* LuaHookedEventTypeName[] = { "HOOK_ON_ATTACK_OBJECT", "HOOK_ON_LANGUAGE_CHANGED", "HOOK_ON_MODS_LOADED", + "HOOK_ON_NAMETAGS_RENDER", "HOOK_MAX" }; @@ -170,6 +172,7 @@ bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* retur void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue); void smlua_call_event_hooks_int_params_ret_bool(enum LuaHookedEventType hookType, s16 param, bool* returnValue); void smlua_call_event_hooks_int_params_ret_int(enum LuaHookedEventType hookType, s32 param, s32* returnValue); +void smlua_call_event_hooks_int_params_ret_string(enum LuaHookedEventType hookType, s32 param, char** returnValue); void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex); void smlua_call_event_hooks_on_play_sound(enum LuaHookedEventType hookType, s32 soundBits, f32* pos, s32* returnValue); void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue); diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index da91fd4b0..9ae8d8ecd 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -1,4 +1,5 @@ #include "smlua.h" +#include "smlua_cobject_map.h" #include "pc/mods/mods.h" #include "audio/external.h" @@ -144,126 +145,62 @@ LuaFunction smlua_to_lua_function(lua_State* L, int index) { return luaL_ref(L, LUA_REGISTRYINDEX); } -bool smlua_is_cobject(lua_State* L, int index, u16 lot) { - int top = lua_gettop(L); - bool ret = true; - - s32 indexType = lua_type(L, index); - if (indexType != LUA_TTABLE) { - ret = false; - goto result; - } - - lua_getfield(L, index, "_lot"); - if (lua_type(L, -1) != LUA_TNUMBER) { - ret = false; - goto result; - } - - enum LuaObjectType objLot = smlua_to_integer(L, -1); - if (!gSmLuaConvertSuccess) { - gSmLuaConvertSuccess = true; - ret = false; - goto result; - } - - if (lot != objLot) { - ret = false; - goto result; - } - -result: - lua_settop(L, top); - return ret; +bool smlua_is_cobject(lua_State* L, int index, UNUSED u16 lot) { + return lua_isuserdata(L, index); } void* smlua_to_cobject(lua_State* L, int index, u16 lot) { s32 indexType = lua_type(L, index); if (indexType == LUA_TNIL) { return NULL; } - if (indexType != LUA_TTABLE) { - LOG_LUA_LINE("smlua_to_cobject received improper type '%d'", lua_type(L, index)); + if (indexType != LUA_TUSERDATA) { + LOG_LUA_LINE("smlua_to_cobject received improper type '%d'", indexType); gSmLuaConvertSuccess = false; return 0; } - // get LOT - lua_getfield(L, index, "_lot"); - enum LuaObjectType objLot = smlua_to_integer(L, -1); - lua_pop(L, 1); - if (!gSmLuaConvertSuccess) { return NULL; } + CObject *cobject = luaL_checkudata(L, index, "CObject"); - if (lot != objLot) { - LOG_LUA_LINE("smlua_to_cobject received improper LOT. Expected '%d', received '%d'", lot, objLot); + if (lot != cobject->lot) { + LOG_LUA_LINE("smlua_to_cobject received improper LOT. Expected '%d', received '%d'", lot, cobject->lot); gSmLuaConvertSuccess = false; return NULL; } - // get pointer - lua_getfield(L, index, "_pointer"); - void* pointer = (void*)(intptr_t)smlua_to_integer(L, -1); - lua_pop(L, 1); - if (!gSmLuaConvertSuccess) { return NULL; } - - // check allowlist - if (!smlua_cobject_allowlist_contains(lot, (u64)(intptr_t)pointer)) { - LOG_LUA_LINE("smlua_to_cobject received a pointer not in allow list. '%u', '%llu", lot, (u64)(intptr_t)pointer); - gSmLuaConvertSuccess = false; - return NULL; - } - - if (pointer == NULL) { + if (cobject->pointer == NULL) { LOG_LUA_LINE("smlua_to_cobject received null pointer."); gSmLuaConvertSuccess = false; return NULL; } gSmLuaConvertSuccess = true; - return pointer; + return cobject->pointer; } void* smlua_to_cpointer(lua_State* L, int index, u16 lvt) { - if (lua_type(L, index) == LUA_TNIL) { - return NULL; - } - - if (lua_type(L, index) != LUA_TTABLE) { - LOG_LUA_LINE("smlua_to_cpointer received improper type '%d'", lua_type(L, index)); + s32 indexType = lua_type(L, index); + if (indexType == LUA_TNIL) { return NULL; } + if (indexType != LUA_TUSERDATA) { + LOG_LUA_LINE("smlua_to_cpointer received improper type '%d'", indexType); gSmLuaConvertSuccess = false; return 0; } - // get LVT - lua_getfield(L, index, "_lvt"); - enum LuaObjectType objLvt = smlua_to_integer(L, -1); - lua_pop(L, 1); - if (!gSmLuaConvertSuccess) { return NULL; } + CPointer *cpointer = luaL_checkudata(L, index, "CPointer"); - if (lvt != objLvt) { - LOG_LUA_LINE("smlua_to_cpointer received improper LVT. Expected '%d', received '%d'", lvt, objLvt); + if (lvt != cpointer->lvt) { + LOG_LUA_LINE("smlua_to_cpointer received improper LOT. Expected '%d', received '%d'", lvt, cpointer->lvt); gSmLuaConvertSuccess = false; return NULL; } - // get pointer - lua_getfield(L, index, "_pointer"); - void* pointer = (void*)(intptr_t)smlua_to_integer(L, -1); - lua_pop(L, 1); - if (!gSmLuaConvertSuccess) { return NULL; } - - if (!smlua_cpointer_allowlist_contains(lvt, (u64)(intptr_t)pointer)) { - LOG_LUA_LINE("smlua_to_cpointer received a pointer not in allow list. '%u', '%llu", lvt, (u64)(intptr_t)pointer); - gSmLuaConvertSuccess = false; - return NULL; - } - - if (pointer == NULL) { + if (cpointer->pointer == NULL) { LOG_LUA_LINE("smlua_to_cpointer received null pointer."); gSmLuaConvertSuccess = false; return NULL; } gSmLuaConvertSuccess = true; - return pointer; + return cpointer->pointer; } struct LSTNetworkType smlua_to_lnt(lua_State* L, int index) { @@ -418,16 +355,17 @@ void smlua_push_object(lua_State* L, u16 lot, void* p) { return; } - // add to allowlist - smlua_cobject_allowlist_add(lot, (u64)(intptr_t) p); + CObject *cobject = lua_newuserdata(L, sizeof(CObject)); + cobject->pointer = p; + cobject->lot = lot; + cobject->freed = false; + luaL_getmetatable(L, "CObject"); + lua_setmetatable(L, -2); - // get a cobject from a function - lua_getglobal(L, "_NewCObject"); // Get the function by its global name - lua_pushinteger(L, lot); - lua_pushinteger(L, (u64)(intptr_t) p); - - if (lua_pcall(L, 2, 1, 0) != LUA_OK) { - LOG_ERROR("Error calling Lua function: %s\n", lua_tostring(L, -1)); + switch (lot) { + case LOT_SURFACE: { + smlua_pointer_user_data_add((uintptr_t) p, cobject); + } } } @@ -437,15 +375,12 @@ void smlua_push_pointer(lua_State* L, u16 lvt, void* p) { return; } - smlua_cpointer_allowlist_add(lvt, (u64)(intptr_t) p); - - // get a cpointer from a function - lua_getglobal(L, "_NewCPointer"); // Get the function by its global name - lua_pushinteger(L, lvt); - lua_pushinteger(L, (u64)(intptr_t) p); - if (lua_pcall(L, 2, 1, 0) != LUA_OK) { - LOG_ERROR("Error calling Lua function: %s\n", lua_tostring(L, -1)); - } + CPointer *cpointer = lua_newuserdata(L, sizeof(CPointer)); + cpointer->pointer = p; + cpointer->lvt = lvt; + cpointer->freed = false; + luaL_getmetatable(L, "CPointer"); + lua_setmetatable(L, -2); } void smlua_push_integer_field(int index, const char* name, lua_Integer val) { @@ -500,7 +435,7 @@ void smlua_push_lnt(struct LSTNetworkType* lnt) { /////////////////////////////////////////////////////////////////////////////////////////// lua_Integer smlua_get_integer_field(int index, const char* name) { - if (lua_type(gLuaState, index) != LUA_TTABLE) { + if (lua_type(gLuaState, index) != LUA_TTABLE && lua_type(gLuaState, index) != LUA_TUSERDATA) { LOG_LUA_LINE("smlua_get_integer_field received improper type '%d'", lua_type(gLuaState, index)); gSmLuaConvertSuccess = false; return 0; @@ -512,7 +447,7 @@ lua_Integer smlua_get_integer_field(int index, const char* name) { } lua_Number smlua_get_number_field(int index, const char* name) { - if (lua_type(gLuaState, index) != LUA_TTABLE) { + if (lua_type(gLuaState, index) != LUA_TTABLE && lua_type(gLuaState, index) != LUA_TUSERDATA) { LOG_LUA_LINE("smlua_get_number_field received improper type '%d'", lua_type(gLuaState, index)); gSmLuaConvertSuccess = false; return 0; @@ -524,7 +459,7 @@ lua_Number smlua_get_number_field(int index, const char* name) { } const char* smlua_get_string_field(int index, const char* name) { - if (lua_type(gLuaState, index) != LUA_TTABLE) { + if (lua_type(gLuaState, index) != LUA_TTABLE && lua_type(gLuaState, index) != LUA_TUSERDATA) { LOG_LUA_LINE("smlua_get_string_field received improper type '%d'", lua_type(gLuaState, index)); gSmLuaConvertSuccess = false; return 0; @@ -536,7 +471,7 @@ const char* smlua_get_string_field(int index, const char* name) { } LuaFunction smlua_get_function_field(int index, const char *name) { - if (lua_type(gLuaState, index) != LUA_TTABLE) { + if (lua_type(gLuaState, index) != LUA_TTABLE && lua_type(gLuaState, index) != LUA_TUSERDATA) { LOG_LUA_LINE("smlua_get_function_field received improper type '%d'", lua_type(gLuaState, index)); gSmLuaConvertSuccess = false; return 0; @@ -774,9 +709,37 @@ void smlua_logline(void) { int level = 0; while (lua_getstack(L, level, &info)) { lua_getinfo(L, "nSl", &info); - LOG_LUA(" [%d] %s:%d -- %s [%s]", - level, info.short_src, info.currentline, + + // Get the folder and file of the crash + // in the format: "folder/file.lua" + const char* src = info.source; + int slashCount = 0; + const char* folderStart = NULL; + for (const char* p = src + strlen(src); p > src; --p) { + if (*p == '/') { + if (++slashCount == 2) { + folderStart = p + 1; + break; + } + } + } + + LOG_LUA(" [%d] '%s':%d -- %s [%s]", + level, (folderStart ? folderStart : info.short_src), info.currentline, (info.name ? info.name : ""), info.what); ++level; } } + +// If an object is freed that Lua has a CObject to, +// Lua is able to use-after-free that pointer +void smlua_free(void *ptr) { + if (ptr && gLuaState) { + CObject *obj = smlua_pointer_user_data_get((uintptr_t) ptr); + if (obj) { + obj->freed = true; + smlua_pointer_user_data_delete((uintptr_t) ptr); + } + } + free(ptr); +} diff --git a/src/pc/lua/smlua_utils.h b/src/pc/lua/smlua_utils.h index b92468552..7cb55ccf5 100644 --- a/src/pc/lua/smlua_utils.h +++ b/src/pc/lua/smlua_utils.h @@ -54,5 +54,6 @@ void smlua_logline(void); void smlua_dump_stack(void); void smlua_dump_globals(void); void smlua_dump_table(int index); +void smlua_free(void *ptr); #endif \ No newline at end of file diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index acabf05c3..4cde88afc 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -166,6 +166,15 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu static ma_engine sModAudioEngine; static struct DynamicPool *sModAudioPool; +static void smlua_audio_custom_init(void) { + sModAudioPool = dynamic_pool_init(); + + ma_result result = ma_engine_init(NULL, &sModAudioEngine); + if (result != MA_SUCCESS) { + LOG_ERROR("failed to init Miniaudio: %d", result); + } +} + static struct ModAudio* find_mod_audio(struct ModFile* file) { struct DynamicPoolNode* node = sModAudioPool->tail; while (node) { @@ -178,8 +187,8 @@ static struct ModAudio* find_mod_audio(struct ModFile* file) { } static bool audio_sanity_check(struct ModAudio* audio, bool isStream, const char* action) { - if (audio == NULL || !audio->loaded) { - LOG_LUA_LINE("Tried to %s unloaded audio %s", action, audio->isStream ? "stream" : "sample"); + if (!audio || !audio->loaded) { + LOG_LUA_LINE("Tried to %s unloaded audio %s", action, audio ? (audio->isStream ? "stream" : "sample") : "(NULL)"); return false; } if (isStream && !audio->isStream) { @@ -194,6 +203,8 @@ static bool audio_sanity_check(struct ModAudio* audio, bool isStream, const char } struct ModAudio* audio_load_internal(const char* filename, bool isStream) { + if (!sModAudioPool) { smlua_audio_custom_init(); } + // check file type bool validFileType = false; const char* fileTypes[] = { ".mp3", ".aiff", ".ogg", NULL }; @@ -568,6 +579,7 @@ void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) { } void audio_custom_update_volume(void) { + if (!sModAudioPool) { return; } struct DynamicPoolNode* node = sModAudioPool->tail; while (node) { struct DynamicPoolNode* prev = node->prev; @@ -587,32 +599,18 @@ void audio_custom_shutdown(void) { while (node) { struct DynamicPoolNode* prev = node->prev; struct ModAudio* audio = node->ptr; - if (audio->isStream) { - if (audio->loaded) { ma_sound_uninit(&audio->sound); } - dynamic_pool_free(sModAudioPool, audio); - } else { - if (audio->loaded) { - if (audio->sampleCopiesTail) { - audio_sample_destroy_copies(audio); - } - ma_sound_uninit(&audio->sound); + if (audio->loaded) { + if (!audio->isStream && audio->sampleCopiesTail) { + audio_sample_destroy_copies(audio); } - dynamic_pool_free(sModAudioPool, audio); + ma_sound_uninit(&audio->sound); } + dynamic_pool_free(sModAudioPool, audio); node = prev; } dynamic_pool_free_pool(sModAudioPool); } -void smlua_audio_custom_init(void) { - sModAudioPool = dynamic_pool_init(); - - ma_result result = ma_engine_init(NULL, &sModAudioEngine); - if (result != MA_SUCCESS) { - LOG_ERROR("failed to init Miniaudio: %d", result); - } -} - void smlua_audio_custom_deinit(void) { if (sModAudioPool) { audio_custom_shutdown(); diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index b540a35f0..048a699f7 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -55,7 +55,6 @@ void audio_custom_update_volume(void); void audio_custom_shutdown(void); -void smlua_audio_custom_init(void); void smlua_audio_custom_deinit(void); #endif diff --git a/src/pc/lua/utils/smlua_camera_utils.c b/src/pc/lua/utils/smlua_camera_utils.c index e20ae995e..68e715861 100644 --- a/src/pc/lua/utils/smlua_camera_utils.c +++ b/src/pc/lua/utils/smlua_camera_utils.c @@ -1,5 +1,6 @@ #include "smlua_camera_utils.h" #include "game/bettercamera.h" +#include "game/object_list_processor.h" static struct CameraOverride sOverrideCameraXSens = { 0 }; static struct CameraOverride sOverrideCameraYSens = { 0 }; @@ -152,3 +153,11 @@ void camera_config_set_deceleration(u32 value) { sOverrideCameraDegrade.override = true; newcam_init_settings(); } + +bool camera_get_checking_surfaces(void) { + return gCheckingSurfaceCollisionsForCamera; +} + +void camera_set_checking_surfaces(bool value) { + gCheckingSurfaceCollisionsForCamera = value; +} diff --git a/src/pc/lua/utils/smlua_camera_utils.h b/src/pc/lua/utils/smlua_camera_utils.h index 57ac352bb..982769a19 100644 --- a/src/pc/lua/utils/smlua_camera_utils.h +++ b/src/pc/lua/utils/smlua_camera_utils.h @@ -40,4 +40,7 @@ void camera_config_set_aggression(u32 value); void camera_config_set_pan_level(u32 value); void camera_config_set_deceleration(u32 value); +bool camera_get_checking_surfaces(void); +void camera_set_checking_surfaces(bool value); + #endif diff --git a/src/pc/lua/utils/smlua_math_utils.c b/src/pc/lua/utils/smlua_math_utils.c index 9e6eb617c..ccc3fc63d 100644 --- a/src/pc/lua/utils/smlua_math_utils.c +++ b/src/pc/lua/utils/smlua_math_utils.c @@ -1,28 +1,24 @@ #include "sm64.h" #include "types.h" -s32 min(s32 a, s32 b) { - return ((a) <= (b) ? (a) : (b)); +f32 sm64_to_radians(s16 sm64Angle) { + return sm64Angle * M_PI / 0x8000; } -f32 minf(f32 a, f32 b) { - return ((a) <= (b) ? (a) : (b)); +s16 radians_to_sm64(f32 radiansAngle) { + return radiansAngle * 0x8000 / M_PI; } -s32 max(s32 a, s32 b) { - return ((a) > (b) ? (a) : (b)); +f32 sm64_to_degrees(s16 sm64Angle) { + return sm64Angle * 180.0f / 0x8000; } -f32 maxf(f32 a, f32 b) { - return ((a) > (b) ? (a) : (b)); +s16 degrees_to_sm64(f32 degreesAngle) { + return degreesAngle * 0x8000 / 180.0f; } -s32 sqr(s32 x) { - return x * x; -} - -f32 sqrf(f32 x) { - return x * x; +f32 hypotf(f32 a, f32 b) { + return sqrtf(a * a + b * b); } s32 clamp(s32 a, s32 b, s32 c) { diff --git a/src/pc/lua/utils/smlua_math_utils.h b/src/pc/lua/utils/smlua_math_utils.h index 31e4cc450..7d1b40476 100644 --- a/src/pc/lua/utils/smlua_math_utils.h +++ b/src/pc/lua/utils/smlua_math_utils.h @@ -1,28 +1,13 @@ #ifndef SMLUA_MATH_UTILS_H #define SMLUA_MATH_UTILS_H -#if defined(min) -#undef min -#endif - -#if defined(max) -#undef max -#endif - -#if defined(sqr) -#undef sqr -#endif - -s32 min(s32 a, s32 b); -f32 minf(f32 a, f32 b); - -s32 max(s32 a, s32 b); -f32 maxf(f32 a, f32 b); - -s32 sqr(s32 x); -f32 sqrf(f32 x); - +f32 sm64_to_radians(s16 sm64Angle); +s16 radians_to_sm64(f32 radiansAngle); +f32 sm64_to_degrees(s16 sm64Angle); +s16 degrees_to_sm64(f32 degreesAngle); +f32 hypotf(f32 a, f32 b); s32 clamp(s32 a, s32 b, s32 c); f32 clampf(f32 a, f32 b, f32 c); -#endif +#endif // SMLUA_MATH_UTILS_H + diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 2b2521091..0af4bd1c5 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -32,6 +32,10 @@ #include "pc/discord/discord.h" #endif +#ifdef COOPNET +#include "pc/network/coopnet/coopnet.h" +#endif + static struct DateTime sDateTime; /// @@ -91,6 +95,10 @@ bool djui_is_playerlist_open(void) { return gDjuiPlayerList->base.visible; } +bool djui_attempting_to_open_playerlist(void) { + return gAttemptingToOpenPlayerlist; +} + enum DjuiFontType djui_menu_get_font(void) { return configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED; } @@ -422,6 +430,18 @@ const char* get_local_discord_id(void) { #endif } +const char* get_coopnet_id(UNUSED s8 localIndex) { +#ifdef COOPNET + if (!gNetworkSystem || gNetworkSystem != &gNetworkSystemCoopNet) { return "-1"; } + if (localIndex < 0 || localIndex >= MAX_PLAYERS) { return "-1"; } + struct NetworkPlayer* np = &gNetworkPlayers[localIndex]; + if (np == NULL || !np->connected) { return "-1"; } + return gNetworkSystem->get_id_str(np->localIndex); +#else + return "-1"; +#endif +} + /// f32 get_volume_master(void) { diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 19f3669ed..b9a11d2eb 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -50,6 +50,7 @@ bool djui_is_popup_disabled(void); void djui_set_popup_disabled_override(bool value); void djui_reset_popup_disabled_override(void); bool djui_is_playerlist_open(void); +bool djui_attempting_to_open_playerlist(void); enum DjuiFontType djui_menu_get_font(void); s8 get_dialog_box_state(void); @@ -111,6 +112,7 @@ u32 get_global_timer(void); s32 get_dialog_response(void); const char* get_local_discord_id(void); +const char* get_coopnet_id(s8 localIndex); f32 get_volume_master(void); f32 get_volume_level(void); diff --git a/src/pc/lua/utils/smlua_model_utils.c b/src/pc/lua/utils/smlua_model_utils.c index c7fbaa25b..e8ba5b644 100644 --- a/src/pc/lua/utils/smlua_model_utils.c +++ b/src/pc/lua/utils/smlua_model_utils.c @@ -53,7 +53,7 @@ #include "levels/ttm/header.h" #include "smlua_model_utils.h" -#include "pc/debuglog.h" +#include "pc/lua/smlua.h" struct ModelUtilsInfo { enum ModelExtendedId extId; @@ -463,8 +463,8 @@ struct ModelUtilsInfo sModels[E_MODEL_MAX] = { }; #define MAX_CUSTOM_MODELS 256 -struct ModelUtilsInfo sCustomModels[MAX_CUSTOM_MODELS] = { 0 }; static u16 sCustomModelsCount = 0; +struct ModelUtilsInfo sCustomModels[MAX_CUSTOM_MODELS] = { 0 }; void smlua_model_util_clear(void) { sCustomModelsCount = 0; @@ -497,7 +497,7 @@ enum ModelExtendedId smlua_model_util_get_id(const char* name) { // find geolayout const void* asset = dynos_geolayout_get(name); if (asset == NULL) { - LOG_ERROR("Failed to find model: %s - %u", name, E_MODEL_ERROR_MODEL); + LOG_LUA_LINE("Could not find model: '%s'", name); return E_MODEL_ERROR_MODEL; } @@ -517,6 +517,11 @@ enum ModelExtendedId smlua_model_util_get_id(const char* name) { } } + if (sCustomModelsCount >= MAX_CUSTOM_MODELS) { + LOG_LUA("Failed to get model: '%s' (too many custom models!)", name); + return E_MODEL_ERROR_MODEL; + } + // allocate custom model u16 customIndex = sCustomModelsCount++; struct ModelUtilsInfo* info = &sCustomModels[customIndex]; diff --git a/src/pc/lua/utils/smlua_text_utils.c b/src/pc/lua/utils/smlua_text_utils.c index f3a1a9784..ea3363be7 100644 --- a/src/pc/lua/utils/smlua_text_utils.c +++ b/src/pc/lua/utils/smlua_text_utils.c @@ -272,6 +272,7 @@ void smlua_text_utils_act_name_reset(s16 courseNum, u8 actNum) { void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName) { if (courseNum <= COURSE_RR || courseNum > COURSE_COUNT) { return; } + /* s16 courseOffset = courseNum - 1; void **courseNameTbl = get_course_name_table(); @@ -282,6 +283,11 @@ void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName) courseNameTbl[courseOffset] = smlua_text_utils_convert(courseName); sReplacedCourseName[courseOffset] = true; + */ + + struct CourseName* courseActNames = gReplacedActNameTable[courseNum]; + snprintf(courseActNames->name, 256, "%s", courseName + 3); + courseActNames->modIndex = gLuaActiveMod->index; } void smlua_text_utils_castle_secret_stars_replace(const char* name) { diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index 48d60d6d0..32b6efd70 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -204,18 +204,22 @@ void mod_clear(struct Mod* mod) { } mod->fileCount = 0; + mod->fileCapacity = 0; mod->size = 0; free(mod); } static struct ModFile* mod_allocate_file(struct Mod* mod, char* relativePath) { // actual allocation - u16 fileIndex = mod->fileCount++; - mod->files = realloc(mod->files, sizeof(struct ModFile) * mod->fileCount); - if (mod->files == NULL) { - LOG_ERROR("Failed to allocate file: '%s'", relativePath); - return NULL; + if (mod->fileCount == mod->fileCapacity) { + mod->fileCapacity = (mod->fileCapacity == 0) ? 16 : (mod->fileCapacity * 2); + mod->files = realloc(mod->files, sizeof(struct ModFile) * mod->fileCapacity); + if (mod->files == NULL) { + LOG_ERROR("Failed to allocate file: '%s'", relativePath); + return NULL; + } } + u16 fileIndex = mod->fileCount++; // clear memory struct ModFile* file = &mod->files[fileIndex]; diff --git a/src/pc/mods/mod.h b/src/pc/mods/mod.h index 7c16979d4..27ef834a8 100644 --- a/src/pc/mods/mod.h +++ b/src/pc/mods/mod.h @@ -30,6 +30,7 @@ struct Mod { struct ModFile* files; s32 index; u16 fileCount; + u16 fileCapacity; bool isDirectory; bool enabled; bool selectable; diff --git a/src/pc/mods/mod_cache.c b/src/pc/mods/mod_cache.c index 163a86ae0..fa1a662d1 100644 --- a/src/pc/mods/mod_cache.c +++ b/src/pc/mods/mod_cache.c @@ -9,30 +9,32 @@ #include "mods_utils.h" #include "pc/utils/md5.h" #include "pc/lua/smlua_hooks.h" +#include "pc/loading.h" #define MOD_CACHE_FILENAME "mod.cache" #define MOD_CACHE_VERSION 7 #define MD5_BUFFER_SIZE 1024 -struct ModCacheEntry* sModCacheHead = NULL; +static struct ModCacheEntry* sModCacheEntries = NULL; +static size_t sModCacheLength = 0; +static size_t sModLengthCapacity = 0; -static void mod_cache_remove_node(struct ModCacheEntry* node, struct ModCacheEntry* parent) { - if (node == NULL) { return; } - if (node == sModCacheHead) { sModCacheHead = node->next; } - if (parent != NULL) { parent->next = node->next; } - //LOG_INFO("Removing node: %s", node->path); +static void mod_cache_remove_node(struct ModCacheEntry* node) { if (node->path) { free(node->path); node->path = NULL; } - free(node); + if (node != &sModCacheEntries[sModCacheLength - 1]) + memcpy(node, &sModCacheEntries[sModCacheLength - 1], sizeof(struct ModCacheEntry)); + sModCacheLength--; } void mod_cache_shutdown(void) { LOG_INFO("Shutting down mod cache."); - while (sModCacheHead) { - mod_cache_remove_node(sModCacheHead, NULL); - } + sModCacheLength = 0; + sModLengthCapacity = 0; + free(sModCacheEntries); + sModCacheEntries = NULL; } void mod_cache_md5(const char* inPath, u8* outDataPath) { @@ -76,6 +78,15 @@ void mod_cache_md5(const char* inPath, u8* outDataPath) { MD5_Final(outDataPath, &ctx); } +static u64 mod_cache_fnv1a(const char* str) { + u64 hash = 0xCBF29CE484222325; + while (*str) { + hash *= 0x100000001B3; + hash ^= *str++; + } + return hash; +} + static bool mod_cache_is_valid(struct ModCacheEntry* node) { if (node == NULL || node->path == NULL || strlen(node->path) == 0) { return false; @@ -87,42 +98,37 @@ static bool mod_cache_is_valid(struct ModCacheEntry* node) { struct ModCacheEntry* mod_cache_get_from_hash(u8* dataHash) { if (dataHash == NULL) { return NULL; } - struct ModCacheEntry* node = sModCacheHead; - struct ModCacheEntry* prev = NULL; - while (node != NULL) { - struct ModCacheEntry* next = node->next; + for (size_t i = 0; i < sModCacheLength;) { + struct ModCacheEntry* node = &sModCacheEntries[i]; if (!memcmp(node->dataHash, dataHash, 16)) { if (mod_cache_is_valid(node)) { return node; } else { - mod_cache_remove_node(node, prev); - node = prev; + mod_cache_remove_node(node); + continue; } } - prev = node; - node = next; + i++; } return NULL; } struct ModCacheEntry* mod_cache_get_from_path(const char* path, bool validate) { if (path == NULL || strlen(path) == 0) { return NULL; } - struct ModCacheEntry* node = sModCacheHead; - struct ModCacheEntry* prev = NULL; - while (node != NULL) { - struct ModCacheEntry* next = node->next; - if (!strcmp(node->path, path)) { + u64 pathHash = mod_cache_fnv1a(path); + for (size_t i = 0; i < sModCacheLength;) { + struct ModCacheEntry* node = &sModCacheEntries[i]; + if (node->pathHash == pathHash && !strcmp(node->path, path)) { if (!validate) { return node; } else if (mod_cache_is_valid(node)) { return node; } else { - mod_cache_remove_node(node, prev); - node = prev; + mod_cache_remove_node(node); + continue; } } - prev = node; - node = next; + i++; } return NULL; } @@ -142,6 +148,7 @@ void mod_cache_add_internal(u8* dataHash, u64 lastLoaded, char* inPath) { return; } normalize_path((char*)path); + u64 pathHash = mod_cache_fnv1a(path); bool foundNonZero = false; for (u8 i = 0; i < 16; i++) { @@ -156,43 +163,34 @@ void mod_cache_add_internal(u8* dataHash, u64 lastLoaded, char* inPath) { return; } - struct ModCacheEntry* node = calloc(1, sizeof(struct ModCacheEntry)); - memcpy(node->dataHash, dataHash, sizeof(u8) * 16); - if (lastLoaded == 0) { lastLoaded = clock(); } - node->lastLoaded = lastLoaded; - node->path = (char*)path; - node->next = NULL; - - if (sModCacheHead == NULL) { - sModCacheHead = node; - LOG_INFO("Added head: %s", node->path); - return; + if (sModCacheEntries == NULL) { + sModLengthCapacity = 16; + sModCacheLength = 0; + sModCacheEntries = calloc(sModLengthCapacity, sizeof(struct ModCacheEntry)); + } else if (sModCacheLength == sModLengthCapacity) { + sModLengthCapacity *= 2; + sModCacheEntries = realloc(sModCacheEntries, sizeof(struct ModCacheEntry) * sModLengthCapacity); } - struct ModCacheEntry* n = sModCacheHead; - struct ModCacheEntry* prev = NULL; - while (n != NULL) { - struct ModCacheEntry* next = n->next; + struct ModCacheEntry node = {}; + memcpy(node.dataHash, dataHash, sizeof(u8) * 16); + if (lastLoaded == 0) { lastLoaded = clock(); } + node.lastLoaded = lastLoaded; + node.path = (char*)path; + node.pathHash = pathHash; - // found end of list, add it - if (next == NULL) { - LOG_INFO("Added node: %s", node->path); - if (n != node) { n->next = node; } - return; - } + for (size_t i = 0; i < sModCacheLength;) { + struct ModCacheEntry* n = &sModCacheEntries[i]; // found old hash, remove it - if (!strcmp(n->path, path)) { + if (n->pathHash == pathHash && !strcmp(n->path, path)) { LOG_INFO("Removing old node: %s", node->path); - mod_cache_remove_node(n, prev); + mod_cache_remove_node(n); } else { - prev = n; + i++; } - - n = next; } - - LOG_ERROR("Did not add node for some reason?"); + memcpy(&sModCacheEntries[sModCacheLength++], &node, sizeof(node)); } void mod_cache_add(struct Mod* mod, struct ModFile* file, bool useFilePath) { @@ -255,6 +253,8 @@ void mod_cache_update(struct Mod* mod, struct ModFile* file) { } void mod_cache_load(void) { + LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Loading Mod Cache")); + mod_cache_shutdown(); LOG_INFO("Loading mod cache"); @@ -326,19 +326,16 @@ void mod_cache_save(void) { u8 t = *gBehaviorOffset != 0; fwrite(&t, sizeof(u8), 1, fp); - struct ModCacheEntry* node = sModCacheHead; - while (node != NULL) { - struct ModCacheEntry* next = node->next; - if (node->path == NULL) { goto iterate; } + for (size_t i = 0; i < sModCacheLength; i++) { + struct ModCacheEntry* node = &sModCacheEntries[i]; + if (node->path == NULL) { continue; } u16 pathLen = strlen(node->path); - if (pathLen == 0) { goto iterate; } + if (pathLen == 0) { continue; } fwrite(node->dataHash, sizeof(u8), 16, fp); fwrite(&node->lastLoaded, sizeof(u64), 1, fp); fwrite(&pathLen, sizeof(u16), 1, fp); fwrite(node->path, sizeof(u8), pathLen + 1, fp); -iterate: - node = next; } fclose(fp); diff --git a/src/pc/mods/mod_cache.h b/src/pc/mods/mod_cache.h index f43cf8c6b..4993fe447 100644 --- a/src/pc/mods/mod_cache.h +++ b/src/pc/mods/mod_cache.h @@ -7,7 +7,7 @@ struct ModCacheEntry { u8 dataHash[16]; u64 lastLoaded; char* path; - struct ModCacheEntry* next; + u64 pathHash; }; void mod_cache_md5(const char* inPath, u8* outDataPath); diff --git a/src/pc/mods/mod_storage.h b/src/pc/mods/mod_storage.h index 3661807b4..d11de7755 100644 --- a/src/pc/mods/mod_storage.h +++ b/src/pc/mods/mod_storage.h @@ -8,7 +8,7 @@ extern "C" { #endif #define MAX_KEYS 512 -#define MAX_KEY_VALUE_LENGTH 256 +#define MAX_KEY_VALUE_LENGTH 512 #define SAVE_DIRECTORY "sav" #define SAVE_EXTENSION ".sav" diff --git a/src/pc/mods/mods.c b/src/pc/mods/mods.c index be37b7785..2485661c0 100644 --- a/src/pc/mods/mods.c +++ b/src/pc/mods/mods.c @@ -252,7 +252,10 @@ static void mods_load(struct Mods* mods, char* modsBasePath, UNUSED bool isUserM } UNUSED f32 count = (f32) mods_count_directory(modsBasePath); - LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mods In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath)); + LOADING_SCREEN_MUTEX( + loading_screen_reset_progress_bar(); + snprintf(gCurrLoadingSegment.str, 256, "Loading Mods In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath); + ); // iterate char path[SYS_MAX_PATH] = { 0 }; @@ -276,6 +279,7 @@ static void mods_load(struct Mods* mods, char* modsBasePath, UNUSED bool isUserM } void mods_refresh_local(void) { + LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Refreshing Mod Cache")); mods_local_store_enabled(); // figure out user path @@ -324,7 +328,6 @@ void mods_enable(char* relativePath) { } void mods_init(void) { - LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Caching Mods")); // load mod cache mod_cache_load(); diff --git a/src/pc/mumble/mumble.c b/src/pc/mumble/mumble.c index f1083cfad..57f9576d8 100644 --- a/src/pc/mumble/mumble.c +++ b/src/pc/mumble/mumble.c @@ -18,7 +18,7 @@ #else #include #include /* For O_* constants */ - #include + #include #endif // _WIN32 struct LinkedMem *lm = NULL; @@ -196,4 +196,4 @@ bool should_update_context() { } return true; -} \ No newline at end of file +} diff --git a/src/pc/nametags.c b/src/pc/nametags.c index ef4995818..04f478f39 100644 --- a/src/pc/nametags.c +++ b/src/pc/nametags.c @@ -8,9 +8,11 @@ #include "game/camera.h" #include "pc/lua/utils/smlua_math_utils.h" #include "pc/lua/utils/smlua_misc_utils.h" +#include "pc/lua/smlua_hooks.h" -#define NAMETAG_MAX_SCALE 0.32f -#define NAMETAG_DIST 7000.0f +#define CLAMP(_val, _min, _max) MAX(MIN((_val), _max), _min) + +#define FADE_SCALE 4.f struct StateExtras { Vec3f prevPos; @@ -80,29 +82,28 @@ void nametags_render(void) { Vec3f pos; Vec3f out; - vec3f_copy(pos, m->marioObj->header.gfx.pos); - pos[1] = m->pos[1] + 210; + vec3f_copy(pos, m->marioBodyState->headPos); + pos[1] = m->pos[1] + 180; if (djui_hud_world_pos_to_screen_pos(pos, out) && (i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON))) { - f32 scale = NAMETAG_MAX_SCALE; - f32 dist = vec3f_dist(gLakituState.pos, m->pos); - if (i != 0 && dist > 1000) { - scale = 0.5f + dist / NAMETAG_DIST; - scale = clampf(1 - scale, 0, NAMETAG_MAX_SCALE); - } + f32 scale = -400 / out[2] * djui_hud_get_fov_coeff(); char name[MAX_CONFIG_STRING]; - snprintf(name, MAX_CONFIG_STRING, "%s", np->name); - name_without_hex(name); - Color color = { - np->overridePalette.parts[CAP][0], - np->overridePalette.parts[CAP][1], - np->overridePalette.parts[CAP][2] - }; - f32 measure = djui_hud_measure_text(name) * scale * 0.5f; + char* hookedString = NULL; + smlua_call_event_hooks_int_params_ret_string(HOOK_ON_NAMETAGS_RENDER, i, &hookedString); + if (hookedString) { + snprintf(name, MAX_CONFIG_STRING, "%s", hookedString); + } else { + snprintf(name, MAX_CONFIG_STRING, "%s", np->name); + name_without_hex(name); + } + u8* color = network_get_player_text_color(m->playerIndex); - u8 alpha = i == 0 ? 255 : MIN(np->fadeOpacity << 3, 255); + f32 measure = djui_hud_measure_text(name) * scale * 0.5f; + out[1] -= 16 * scale; + + u8 alpha = (i == 0 ? 255 : MIN(np->fadeOpacity << 3, 255)) * CLAMP(FADE_SCALE - scale, 0.f, 1.f); struct StateExtras* e = &sStateExtras[i]; if (!e->inited) { @@ -110,15 +111,18 @@ void nametags_render(void) { e->prevScale = scale; e->inited = true; } - djui_hud_print_outlined_text_interpolated(name, e->prevPos[0] - measure, e->prevPos[1], e->prevScale, out[0] - measure, out[1], scale, color[0], color[1], color[2], alpha, 0.25); + djui_hud_print_outlined_text_interpolated(name, + e->prevPos[0] - measure, e->prevPos[1], e->prevScale, + out[0] - measure, out[1], scale, + color[0], color[1], color[2], alpha, 0.25); if (i != 0 && gNametagsSettings.showHealth) { djui_hud_set_color(255, 255, 255, alpha); f32 healthScale = 90 * scale; f32 prevHealthScale = 90 * e->prevScale; hud_render_power_meter_interpolated(m->health, - e->prevPos[0] - (prevHealthScale * 0.5f), e->prevPos[1] - 23, prevHealthScale, prevHealthScale, - out[0] - (healthScale * 0.5f), out[1] - 23, healthScale, healthScale + e->prevPos[0] - (prevHealthScale * 0.5f), e->prevPos[1] - 72 * scale, prevHealthScale, prevHealthScale, + out[0] - ( healthScale * 0.5f), out[1] - 72 * scale, healthScale, healthScale ); } diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 8e7cb3646..105fadc93 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -679,6 +679,9 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect gVertexColor[0] = 255; gVertexColor[1] = 255; gVertexColor[2] = 255; + gSkyboxColor[0] = 255; + gSkyboxColor[1] = 255; + gSkyboxColor[2] = 255; gFogColor[0] = 255; gFogColor[1] = 255; gFogColor[2] = 255; @@ -719,6 +722,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect cnt->stickMag = 0; cnt->buttonDown = 0; cnt->buttonPressed = 0; + cnt->buttonReleased = 0; cnt->extStickX = 0; cnt->extStickY = 0; @@ -748,6 +752,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect gDjuiInMainMenu = true; djui_panel_main_create(NULL); } + djui_lua_error_clear(); #ifdef DISCORD_SDK discord_activity_update(); diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 2ae98c00d..dd234f6ab 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -74,6 +74,16 @@ void network_player_set_description(struct NetworkPlayer *np, const char *descri np->descriptionA = a; } +void network_player_set_override_location(struct NetworkPlayer *np, const char *location) { + if (np == NULL) { return; } + + if (location != NULL) { + snprintf(np->overrideLocation, 256, "%s", location); + } else { + np->overrideLocation[0] = '\0'; + } +} + struct NetworkPlayer *network_player_from_global_index(u8 globalIndex) { for (s32 i = 0; i < MAX_PLAYERS; i++) { if (!gNetworkPlayers[i].connected) { continue; } diff --git a/src/pc/network/network_player.h b/src/pc/network/network_player.h index fa409249a..4b583535c 100644 --- a/src/pc/network/network_player.h +++ b/src/pc/network/network_player.h @@ -52,6 +52,8 @@ struct NetworkPlayer { u8 descriptionB; u8 descriptionA; + char overrideLocation[256]; + u8 overrideModelIndex; struct PlayerPalette overridePalette; @@ -75,6 +77,7 @@ void network_player_update_model(u8 localIndex); bool network_player_any_connected(void); u8 network_player_connected_count(void); void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a); +void network_player_set_override_location(struct NetworkPlayer *np, const char *location); struct NetworkPlayer* network_player_from_global_index(u8 globalIndex); struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum); diff --git a/src/pc/network/network_utils.c b/src/pc/network/network_utils.c index 5ff1102b2..aff07b6aa 100644 --- a/src/pc/network/network_utils.c +++ b/src/pc/network/network_utils.c @@ -54,7 +54,7 @@ const char* network_get_player_text_color_string(u8 localIndex) { extern s16 gMenuMode; bool network_check_singleplayer_pause(void) { - return gMenuMode != -1 && network_player_connected_count() == 1 && mods_get_all_pausable() && !gDjuiInPlayerMenu; + return gMenuMode != -1 && !gServerSettings.pauseAnywhere && network_player_connected_count() == 1 && mods_get_all_pausable() && !gDjuiInPlayerMenu; } const char* network_discord_id_from_local_index(u8 localIndex) { diff --git a/src/pc/network/packets/packet_network_players.c b/src/pc/network/packets/packet_network_players.c index 1c19ca5c7..eeb86566a 100644 --- a/src/pc/network/packets/packet_network_players.c +++ b/src/pc/network/packets/packet_network_players.c @@ -110,6 +110,8 @@ void network_receive_network_players(struct Packet *p) { packet_read(p, &playerName, sizeof(u8) * MAX_CONFIG_STRING); packet_read(p, &discordId, sizeof(u8) * 64); + if (globalIndex > MAX_PLAYERS) { continue; } + u8 localIndex = network_player_connected(npType, globalIndex, modelIndex, &palette, playerName, discordId); LOG_INFO("received network player [%d == %d] (%d)", globalIndex, npType, localIndex); if (localIndex != UNKNOWN_GLOBAL_INDEX) { diff --git a/src/pc/network/packets/packet_player.c b/src/pc/network/packets/packet_player.c index 4a04a896e..47168aa2f 100644 --- a/src/pc/network/packets/packet_player.c +++ b/src/pc/network/packets/packet_player.c @@ -1,4 +1,5 @@ #include +#include #include "../network.h" #include "object_fields.h" #include "object_constants.h" @@ -27,6 +28,7 @@ struct PacketPlayerData { f32 cStickMag; u16 cButtonDown; u16 cButtonPressed; + u16 cButtonReleased; s16 cExtStickX; s16 cExtStickY; @@ -91,15 +93,16 @@ static void read_packet_data(struct PacketPlayerData* data, struct MarioState* m memcpy(data->rawData, m->marioObj->rawData.asU32, sizeof(u32) * OBJECT_NUM_REGULAR_FIELDS); data->nodeFlags = m->marioObj->header.gfx.node.flags; - data->cRawStickX = m->controller->rawStickX; - data->cRawStickY = m->controller->rawStickY; - data->cStickX = m->controller->stickX; - data->cStickY = m->controller->stickY; - data->cStickMag = m->controller->stickMag; - data->cButtonDown = m->controller->buttonDown; - data->cButtonPressed = m->controller->buttonPressed; - data->cExtStickX = m->controller->extStickX; - data->cExtStickY = m->controller->extStickY; + data->cRawStickX = m->controller->rawStickX; + data->cRawStickY = m->controller->rawStickY; + data->cStickX = m->controller->stickX; + data->cStickY = m->controller->stickY; + data->cStickMag = m->controller->stickMag; + data->cButtonDown = m->controller->buttonDown; + data->cButtonPressed = m->controller->buttonPressed; + data->cButtonReleased = m->controller->buttonReleased; + data->cExtStickX = m->controller->extStickX; + data->cExtStickY = m->controller->extStickY; data->input = m->input; data->flags = m->flags; @@ -155,15 +158,16 @@ static void write_packet_data(struct PacketPlayerData* data, struct MarioState* memcpy(m->marioObj->rawData.asU32, data->rawData, sizeof(u32) * OBJECT_NUM_REGULAR_FIELDS); m->marioObj->header.gfx.node.flags = data->nodeFlags; - m->controller->rawStickX = data->cRawStickX; - m->controller->rawStickY = data->cRawStickY; - m->controller->stickX = data->cStickX; - m->controller->stickY = data->cStickY; - m->controller->stickMag = data->cStickMag; - m->controller->buttonDown = data->cButtonDown; - m->controller->buttonPressed = data->cButtonPressed; - m->controller->extStickX = data->cExtStickX; - m->controller->extStickY = data->cExtStickY; + m->controller->rawStickX = data->cRawStickX; + m->controller->rawStickY = data->cRawStickY; + m->controller->stickX = data->cStickX; + m->controller->stickY = data->cStickY; + m->controller->stickMag = data->cStickMag; + m->controller->buttonDown = data->cButtonDown; + m->controller->buttonPressed = data->cButtonPressed; + m->controller->buttonReleased = data->cButtonReleased; + m->controller->extStickX = data->cExtStickX; + m->controller->extStickY = data->cExtStickY; m->input = data->input; m->flags = data->flags; @@ -241,6 +245,18 @@ void network_receive_player(struct Packet* p) { struct MarioState* m = &gMarioStates[np->localIndex]; if (m == NULL || m->marioObj == NULL) { return; } + if (gNetworkType == NT_SERVER && *((u32*)(p->buffer + p->cursor + offsetof(struct PacketPlayerData, action))) == ACT_DEBUG_FREE_MOVE) { +#ifdef DEVELOPMENT + if (m->action != ACT_DEBUG_FREE_MOVE) { + construct_player_popup(np, DLANG(NOTIF, DEBUG_FLY), NULL); + } +#else + network_send_kick(np->localIndex, EKT_KICKED); + network_player_disconnected(np->localIndex); + return; +#endif + } + // prevent receiving player from other area bool levelAreaMismatch = ((gNetworkPlayerLocal == NULL) || np->currCourseNum != gNetworkPlayerLocal->currCourseNum @@ -392,19 +408,6 @@ void network_receive_player(struct Packet* p) { // Player's position is valid since it's updated and in the same area as the local player np->currPositionValid = true; -#ifndef DEVELOPMENT - if (gNetworkType == NT_SERVER) { - if (m->action == ACT_DEBUG_FREE_MOVE) { - network_send_kick(np->localIndex, EKT_CLOSE_CONNECTION); - network_player_disconnected(np->localIndex); - } - } -#else - if (m->action == ACT_DEBUG_FREE_MOVE && oldData.action != ACT_DEBUG_FREE_MOVE) { - construct_player_popup(np, DLANG(NOTIF, DEBUG_FLY), NULL); - } -#endif - if (np->currLevelNum == LEVEL_BOWSER_3 && m->action == ACT_JUMBO_STAR_CUTSCENE && gMarioStates[0].action != ACT_JUMBO_STAR_CUTSCENE) { set_mario_action((struct MarioState*) &gMarioStates[0], ACT_JUMBO_STAR_CUTSCENE, 0); } @@ -427,12 +430,14 @@ void network_update_player(void) { static f32 sLastStickY = 0; static u32 sLastButtonDown = 0; static u32 sLastButtonPressed = 0; + static u32 sLastButtonReleased = 0; f32 stickDist = sqrtf(powf(sLastStickX - m->controller->stickX, 2) + powf(sLastStickY - m->controller->stickY, 2)); bool shouldSend = (sTicksSinceSend > 2) || (sLastPlayerAction != m->action) || (sLastButtonDown != m->controller->buttonDown) || (sLastButtonPressed != m->controller->buttonPressed) + || (sLastButtonReleased != m->controller->buttonReleased) || (sLastPlayerParticles != m->particleFlags) || (stickDist > 5.0f); @@ -445,5 +450,6 @@ void network_update_player(void) { sLastStickY = m->controller->stickY; sLastButtonDown = m->controller->buttonDown; sLastButtonPressed = m->controller->buttonPressed; + sLastButtonReleased = m->controller->buttonReleased; sLastPlayerParticles = m->particleFlags; } diff --git a/src/pc/network/packets/packet_spawn_objects.c b/src/pc/network/packets/packet_spawn_objects.c index 37ee73739..f18280f0a 100644 --- a/src/pc/network/packets/packet_spawn_objects.c +++ b/src/pc/network/packets/packet_spawn_objects.c @@ -159,6 +159,8 @@ void network_receive_spawn_objects(struct Packet* p) { name = gNetworkPlayers[p->localIndex].name; } + const char *bhvName = get_behavior_name_from_id(data.behaviorId); + // Don't overwrite existing sync objects { u32 syncID = data.rawData[0x04]; // o->oSyncID @@ -167,15 +169,15 @@ void network_receive_spawn_objects(struct Packet* p) { if (so->o->behavior == get_behavior_from_id(data.behaviorId)) { LOG_ERROR("recieved duplicate sync object with id %d from %s (%s)", syncID, name, id); } else { - LOG_ERROR("recieved duplicate sync object with id %d with different behavior %s from %s (%s)", syncID, get_behavior_name_from_id(data.behaviorId), name, id); + LOG_ERROR("recieved duplicate sync object with id %d with different behavior %s from %s (%s)", syncID, bhvName, name, id); } continue; } } - LOG_INFO("rx spawn object %s from %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id); - LOG_CONSOLE("rx spawn object %s from %s\\#dcdcdc\\ (%s)", get_behavior_name_from_id(data.behaviorId), name, id); - snprintf(gLastRemoteBhv, 256, "%s %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id); + LOG_INFO("rx spawn object %s from %s (%s)", bhvName, name, id); + LOG_CONSOLE("rx spawn object %s from %s\\#dcdcdc\\ (%s)", bhvName, name, id); + snprintf(gLastRemoteBhv, 256, "%s %s (%s)", bhvName, name, id); struct Object* parentObj = NULL; if (data.parentId == (u32)-1) { diff --git a/src/pc/network/version.h b/src/pc/network/version.h index 9c49f157d..b5aaa7f4a 100644 --- a/src/pc/network/version.h +++ b/src/pc/network/version.h @@ -1,12 +1,12 @@ #ifndef VERSION_H #define VERSION_H -#define SM64COOPDX_VERSION "v1.0.3" +#define SM64COOPDX_VERSION "v1.0.4" // internal version #define VERSION_TEXT "v" #define VERSION_NUMBER 37 -#define MINOR_VERSION_NUMBER 2 +#define MINOR_VERSION_NUMBER 3 #if defined(VERSION_JP) #define VERSION_REGION "JP" diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 8aaaf3bf9..f3e0809dc 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -43,7 +44,9 @@ #include "pc/djui/djui_unicode.h" #include "pc/djui/djui_panel.h" #include "pc/djui/djui_panel_modlist.h" +#include "pc/djui/djui_ctx_display.h" #include "pc/djui/djui_fps_display.h" +#include "pc/djui/djui_lua_profiler.h" #include "pc/debuglog.h" #include "pc/utils/misc.h" @@ -182,28 +185,30 @@ void produce_interpolation_frames_and_delay(void) { // interpolate and render while ((curTime = clock_elapsed_f64()) < sFrameTargetTime) { - gfx_start_frame(); f32 delta = ((!configUncappedFramerate && configFrameLimit == FRAMERATE) ? 1.0f : MAX(MIN((curTime - sFrameTimeStart) / (sFrameTargetTime - sFrameTimeStart), 1.0f), 0.0f) ); gRenderingDelta = delta; + + gfx_start_frame(); if (!gSkipInterpolationTitleScreen) { patch_interpolations(delta); } send_display_list(gGfxSPTask); gfx_end_frame(); - - // delay - if (!configUncappedFramerate) { - f64 targetDelta = 1.0 / (f64) configFrameLimit; - f64 now = clock_elapsed_f64(); - f64 actualDelta = now - curTime; - if (actualDelta < targetDelta) { - f64 delay = ((targetDelta - actualDelta) * 1000.0); - if (delay > 0.0f) { WAPI.delay((u32) delay); } - } - } - + frames++; + + if (configUncappedFramerate) { continue; } + + // Delay if our framerate is capped. + f64 targetDelta = 1.0 / (f64) configFrameLimit; + f64 now = clock_elapsed_f64(); + f64 actualDelta = now - curTime; + if (actualDelta >= targetDelta) { continue; } + f64 delay = ((targetDelta - actualDelta) * 1000.0) - 1.0; + if (delay > 0.0f) { + WAPI.delay((u32)delay); + } } static u64 sFramesSinceFpsUpdate = 0; @@ -345,8 +350,8 @@ void* main_game_init(UNUSED void* dummy) { audio_init(); sound_init(); - smlua_audio_custom_init(); network_player_init(); + mumble_init(); gGameInited = true; } @@ -461,12 +466,10 @@ int main(int argc, char *argv[]) { network_init(NT_NONE, false); } - mumble_init(); - // main loop while (true) { debug_context_reset(); - CTX_BEGIN(CTX_FRAME); + CTX_BEGIN(CTX_TOTAL); WAPI.main_loop(produce_one_frame); #ifdef DISCORD_SDK discord_update(); @@ -476,7 +479,12 @@ int main(int argc, char *argv[]) { fflush(stdout); fflush(stderr); #endif - CTX_END(CTX_FRAME); + CTX_END(CTX_TOTAL); + +#ifdef DEVELOPMENT + djui_ctx_display_update(); +#endif + djui_lua_profiler_update(); } return 0; diff --git a/src/pc/queue.h b/src/pc/queue.h deleted file mode 100644 index a82af55c5..000000000 --- a/src/pc/queue.h +++ /dev/null @@ -1,694 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - * $FreeBSD: head/sys/sys/queue.h 251887 2013-06-18 02:57:56Z lstewart $ - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -#include - -/* - * This file defines four types of data structures: singly-linked lists, - * singly-linked tail queues, lists and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The elements - * are singly linked for minimum space and pointer manipulation overhead at - * the expense of O(n) removal for arbitrary elements. New elements can be - * added to the list after an existing element or at the head of the list. - * Elements being removed from the head of the list should use the explicit - * macro for this purpose for optimum efficiency. A singly-linked list may - * only be traversed in the forward direction. Singly-linked lists are ideal - * for applications with large datasets and few or no removals or for - * implementing a LIFO queue. - * - * A singly-linked tail queue is headed by a pair of pointers, one to the - * head of the list and the other to the tail of the list. The elements are - * singly linked for minimum space and pointer manipulation overhead at the - * expense of O(n) removal for arbitrary elements. New elements can be added - * to the list after an existing element, at the head of the list, or at the - * end of the list. Elements being removed from the head of the tail queue - * should use the explicit macro for this purpose for optimum efficiency. - * A singly-linked tail queue may only be traversed in the forward direction. - * Singly-linked tail queues are ideal for applications with large datasets - * and few or no removals or for implementing a FIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may be traversed in either direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - * - * - * SLIST LIST STAILQ TAILQ - * _HEAD + + + + - * _HEAD_INITIALIZER + + + + - * _ENTRY + + + + - * _INIT + + + + - * _EMPTY + + + + - * _FIRST + + + + - * _NEXT + + + + - * _PREV - + - + - * _LAST - - + + - * _FOREACH + + + + - * _FOREACH_FROM + + + + - * _FOREACH_SAFE + + + + - * _FOREACH_FROM_SAFE + + + + - * _FOREACH_REVERSE - - - + - * _FOREACH_REVERSE_FROM - - - + - * _FOREACH_REVERSE_SAFE - - - + - * _FOREACH_REVERSE_FROM_SAFE - - - + - * _INSERT_HEAD + + + + - * _INSERT_BEFORE - + - + - * _INSERT_AFTER + + + + - * _INSERT_TAIL - - + + - * _CONCAT - - + + - * _REMOVE_AFTER + - + - - * _REMOVE_HEAD + - + - - * _REMOVE + + + + - * _SWAP + + + + - * - */ -#ifdef QUEUE_MACRO_DEBUG -/* Store the last 2 places the queue element or head was altered */ -struct qm_trace { - unsigned long lastline; - unsigned long prevline; - const char *lastfile; - const char *prevfile; -}; - -#define TRACEBUF struct qm_trace trace; -#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } , -#define TRASHIT(x) do {(x) = (void *)-1;} while (0) -#define QMD_SAVELINK(name, link) void **name = (void *)&(link) - -#define QMD_TRACE_HEAD(head) do { \ - (head)->trace.prevline = (head)->trace.lastline; \ - (head)->trace.prevfile = (head)->trace.lastfile; \ - (head)->trace.lastline = __LINE__; \ - (head)->trace.lastfile = __FILE__; \ -} while (0) - -#define QMD_TRACE_ELEM(elem) do { \ - (elem)->trace.prevline = (elem)->trace.lastline; \ - (elem)->trace.prevfile = (elem)->trace.lastfile; \ - (elem)->trace.lastline = __LINE__; \ - (elem)->trace.lastfile = __FILE__; \ -} while (0) - -#else -#define QMD_TRACE_ELEM(elem) -#define QMD_TRACE_HEAD(head) -#define QMD_SAVELINK(name, link) -#define TRACEBUF -#define TRACEBUF_INITIALIZER -#define TRASHIT(x) -#endif /* QUEUE_MACRO_DEBUG */ - -/* - * Singly-linked List declarations. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) - -#define SLIST_FIRST(head) ((head)->slh_first) - -#define SLIST_FOREACH(var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_FROM(var, head, field) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) - -#define SLIST_INIT(head) do { \ - SLIST_FIRST((head)) = NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ -} while (0) - -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = SLIST_FIRST((head)); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define SLIST_REMOVE_AFTER(elm, field) do { \ - SLIST_NEXT(elm, field) = \ - SLIST_NEXT(SLIST_NEXT(elm, field), field); \ -} while (0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -#define SLIST_SWAP(head1, head2, type) do { \ - struct type *swap_first = SLIST_FIRST(head1); \ - SLIST_FIRST(head1) = SLIST_FIRST(head2); \ - SLIST_FIRST(head2) = swap_first; \ -} while (0) - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ - struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) - -#define STAILQ_FIRST(head) ((head)->stqh_first) - -#define STAILQ_FOREACH(var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_FROM(var, head, field) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_INIT(head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? NULL : \ - __containerof((head)->stqh_last, struct type, field.stqe_next)) - -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = STAILQ_FIRST((head)); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ - if ((STAILQ_NEXT(elm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_SWAP(head1, head2, type) do { \ - struct type *swap_first = STAILQ_FIRST(head1); \ - struct type **swap_last = (head1)->stqh_last; \ - STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_FIRST(head2) = swap_first; \ - (head2)->stqh_last = swap_last; \ - if (STAILQ_EMPTY(head1)) \ - (head1)->stqh_last = &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ - (head2)->stqh_last = &STAILQ_FIRST(head2); \ -} while (0) - - -/* - * List declarations. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ - -#if (defined(_KERNEL) && defined(INVARIANTS)) -#define QMD_LIST_CHECK_HEAD(head, field) do { \ - if (LIST_FIRST((head)) != NULL && \ - LIST_FIRST((head))->field.le_prev != \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev != head", (head)); \ -} while (0) - -#define QMD_LIST_CHECK_NEXT(elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL && \ - LIST_NEXT((elm), field)->field.le_prev != \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -#define QMD_LIST_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.le_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD(head, field) -#define QMD_LIST_CHECK_NEXT(elm, field) -#define QMD_LIST_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define LIST_EMPTY(head) ((head)->lh_first == NULL) - -#define LIST_FIRST(head) ((head)->lh_first) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_FROM(var, head, field) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_INIT(head) do { \ - LIST_FIRST((head)) = NULL; \ -} while (0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - QMD_LIST_CHECK_NEXT(listelm, field); \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - QMD_LIST_CHECK_PREV(listelm, field); \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - QMD_LIST_CHECK_HEAD((head), field); \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_PREV(elm, head, type, field) \ - ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ - __containerof((elm)->field.le_prev, struct type, field.le_next)) - -#define LIST_REMOVE(elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ - QMD_LIST_CHECK_NEXT(elm, field); \ - QMD_LIST_CHECK_PREV(elm, field); \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ -} while (0) - -#define LIST_SWAP(head1, head2, type, field) do { \ - struct type *swap_tmp = LIST_FIRST((head1)); \ - LIST_FIRST((head1)) = LIST_FIRST((head2)); \ - LIST_FIRST((head2)) = swap_tmp; \ - if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ - if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ -} while (0) - -/* - * Tail queue declarations. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ - TRACEBUF \ -} - -/* - * Tail queue functions. - */ -#if (defined(_KERNEL) && defined(INVARIANTS)) -#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev != \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev != head", (head)); \ -} while (0) - -#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ - if (*(head)->tqh_last != NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ -} while (0) - -#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ - if (TAILQ_NEXT((elm), field) != NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev != \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.tqe_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_TAILQ_CHECK_HEAD(head, field) -#define QMD_TAILQ_CHECK_TAIL(head, headname) -#define QMD_TAILQ_CHECK_NEXT(elm, field) -#define QMD_TAILQ_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head1); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) - -#define TAILQ_FIRST(head) ((head)->tqh_first) - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_FROM(var, head, field) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_INIT(head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QMD_TAILQ_CHECK_NEXT(listelm, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - QMD_TAILQ_CHECK_PREV(listelm, field); \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - QMD_TAILQ_CHECK_HEAD(head, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - QMD_TAILQ_CHECK_TAIL(head, field); \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_REMOVE(head, elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ - QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ - QMD_TAILQ_CHECK_NEXT(elm, field); \ - QMD_TAILQ_CHECK_PREV(elm, field); \ - if ((TAILQ_NEXT((elm), field)) != NULL) \ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else { \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - QMD_TRACE_HEAD(head); \ - } \ - *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_SWAP(head1, head2, type, field) do { \ - struct type *swap_first = (head1)->tqh_first; \ - struct type **swap_last = (head1)->tqh_last; \ - (head1)->tqh_first = (head2)->tqh_first; \ - (head1)->tqh_last = (head2)->tqh_last; \ - (head2)->tqh_first = swap_first; \ - (head2)->tqh_last = swap_last; \ - if ((swap_first = (head1)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head1)->tqh_first; \ - else \ - (head1)->tqh_last = &(head1)->tqh_first; \ - if ((swap_first = (head2)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head2)->tqh_first; \ - else \ - (head2)->tqh_last = &(head2)->tqh_first; \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */ diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index 416d58eda..906a1593a 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -121,18 +121,6 @@ next_get: ///////////////// -static f32 sm64_to_radians(f32 val) { - return val * M_PI / 0x8000; -} - -static f32 radians_to_sm64(f32 val) { - return val * 0x8000 / M_PI; -} - -static f32 asins(f32 val) { - return radians_to_sm64(asin(sm64_to_radians(val))); -} - f32 delta_interpolate_f32(f32 start, f32 end, f32 delta) { return start * (1.0f - delta) + end * delta; } diff --git a/tools/create_patch.sh b/tools/create_patch.sh index ea75d9cca..0fd35a2d3 100755 --- a/tools/create_patch.sh +++ b/tools/create_patch.sh @@ -10,15 +10,9 @@ then exit 1 fi -# Make sure this is a git repository -if [ ! -d .git ] -then - echo 'Error: The current directory is not a Git repository.' - exit 1 -fi - # 'git diff' is stupid and doesn't show new untracked files, so we must add them first. -git add . +# Also make sure this is a valid git repository, throw an error otherwise ( || exit 1 ) +git add . || exit 1 # Generate the patch. git diff -p --staged > "$1" # Undo the 'git add'. diff --git a/tools/n64graphics.c b/tools/n64graphics.c index f17831373..d1e7e6379 100644 --- a/tools/n64graphics.c +++ b/tools/n64graphics.c @@ -744,52 +744,85 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) if (argv[i][0] == '-') { switch (argv[i][1]) { case 'c': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'c'\n"); + return 0; + } if (!parse_format(&config->pal_format, argv[i])) { + ERROR("Error parsing 'c' format"); return 0; } break; case 'e': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'e'\n"); + return 0; + } config->bin_filename = argv[i]; config->mode = MODE_EXPORT; break; case 'f': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'f'\n"); + return 0; + } if (!parse_format(&config->format, argv[i])) { + ERROR("Error parsing format after 'f'"); return 0; } break; case 'g': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'g'\n"); + return 0; + } config->img_filename = argv[i]; break; case 'h': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'h'\n"); + return 0; + } config->height = strtoul(argv[i], NULL, 0); break; case 'i': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'i'\n"); + return 0; + } config->bin_filename = argv[i]; config->mode = MODE_IMPORT; break; case 'o': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'o'\n"); + return 0; + } config->bin_offset = strtoul(argv[i], NULL, 0); config->bin_truncate = 0; break; case 'p': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'p'\n"); + return 0; + } config->pal_filename = argv[i]; break; case 'P': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'P'\n"); + return 0; + } config->pal_offset = strtoul(argv[i], NULL, 0); config->pal_truncate = 0; break; case 's': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 's'\n"); + return 0; + } if (!parse_encoding(&config->encoding, argv[i])) { + ERROR("Error parsing 's' encoding\n"); return 0; } break; @@ -801,14 +834,19 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) exit(0); break; case 'w': - if (++i >= argc) return 0; + if (++i >= argc) { + ERROR("Not enough arguments after 'w'\n"); + return 0; + } config->width = strtoul(argv[i], NULL, 0); break; default: + ERROR("Error parsing arguments (default)\n"); return 0; break; } } else { + ERROR("Error parsing arguments (else case)\n"); return 0; } } @@ -819,11 +857,13 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) static int valid_config(const graphics_config *config) { if (!config->bin_filename || !config->img_filename) { + ERROR("Invalid bin filename or img filename\n"); return 0; } if (config->format.format == IMG_FORMAT_CI) { if (!config->pal_filename || (config->pal_format.depth != 16) || (config->pal_format.format != IMG_FORMAT_RGBA && config->pal_format.format != IMG_FORMAT_IA)) { + ERROR("Invalid format issue\n"); return 0; } } @@ -844,6 +884,12 @@ int main(int argc, char *argv[]) int valid = parse_arguments(argc, argv, &config); if (!valid || !valid_config(&config)) { + if (!valid){ + ERROR("Invalid arguments were given\n"); + } + else { + ERROR("The config is invalid\n"); + } print_usage(); exit(EXIT_FAILURE); }