From 4a632ff5dc1f7d0f2a1e5e0c0598ab44f1dd20d1 Mon Sep 17 00:00:00 2001 From: SuperDude88 <82904174+SuperDude88@users.noreply.github.com> Date: Mon, 31 Aug 2026 18:24:30 -0400 Subject: [PATCH 1/8] Instant Death Fixes - Fix some overflows with instant death mode --- src/d/actor/d_a_alink_damage.inc | 5 +++-- src/d/d_meter2.cpp | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/d/actor/d_a_alink_damage.inc b/src/d/actor/d_a_alink_damage.inc index a57e71bcee..34701229c3 100644 --- a/src/d/actor/d_a_alink_damage.inc +++ b/src/d/actor/d_a_alink_damage.inc @@ -157,10 +157,11 @@ f32 daAlink_c::damageMagnification(BOOL i_checkZoraMag, int param_1) { } #if TARGET_PC - base_mag *= dusk::getSettings().game.damageMultiplier; if (dusk::getSettings().game.instantDeath) { - base_mag = 9999.0f; + return 9999.0f; // don't need to multiply this further, 9999 is plenty } + + base_mag *= dusk::getSettings().game.damageMultiplier; #endif if (checkWolf() && !checkCargoCarry() && param_1 == 0) { diff --git a/src/d/d_meter2.cpp b/src/d/d_meter2.cpp index 8d396e0185..302daa4b0f 100644 --- a/src/d/d_meter2.cpp +++ b/src/d/d_meter2.cpp @@ -606,7 +606,12 @@ void dMeter2_c::moveLife() { life_count = (dComIfGs_getMaxLife() / 5) * 4; } +#if TARGET_PC + int new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount(); // prevent an overflow with really large damage values +#else s16 new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount(); +#endif + if (new_life > life_count) { new_life = life_count; } else if (new_life < 0) { From 48171f0f0adfc4d7efb6d815f28a5a4259b40a00 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 31 Aug 2026 18:02:40 -0600 Subject: [PATCH 2/8] Only use inlining flags w/ mod support Also enables mod support by default. It was already enabled in the CMakePresets.json, so this just moves it to the CMakeLists itself. --- CMakeLists.txt | 128 +++++++++++++++++++++++----------------------- CMakePresets.json | 28 +--------- 2 files changed, 67 insertions(+), 89 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f826a1d86b..83118beb1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) option(DUSK_PACKAGE_INSTALL "Install Dusklight with a Linux-native file structure" OFF) option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) -option(DUSK_ENABLE_CODE_MODS "Enable code mods" OFF) +option(DUSK_ENABLE_CODE_MODS "Enable code mods" ON) set(DUSK_HAS_FUNCHOOK OFF) if (DUSK_ENABLE_CODE_MODS AND (NOT APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")) @@ -424,73 +424,75 @@ endif () # Hook reliability: prevent auto-inlining, guarantee patchable function entries, # and disable identical-code folding for game functions. -set(DUSK_GAME_ABI_INLINE_OPTIONS) -if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS - $<$:-finline-hint-functions>) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS - $<$:-flive-patching=inline-clone> - $<$:-fno-inline-functions> - $<$:-fno-inline-small-functions> - $<$:-fno-inline-functions-called-once> - $<$:-fno-early-inlining> - $<$:-fno-ipa-cp> - $<$:-fno-ipa-cp-clone> - $<$:-fno-ipa-sra> - $<$:-fno-partial-inlining>) - endif () -endif () - -if (DUSK_GAME_ABI_INLINE_OPTIONS) - target_compile_options(dusklight PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) - - foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) - target_compile_options(${jsystem_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) - endforeach() - foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx - aurora_os aurora_pad aurora_si aurora_vi) - if (TARGET ${_sdk_lib}) - get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) - if (NOT _sdk_lib_imported) - target_compile_options(${_sdk_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) - endif () +if (DUSK_ENABLE_CODE_MODS) + set(DUSK_GAME_ABI_INLINE_OPTIONS) + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS + $<$:-finline-hint-functions>) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS + $<$:-flive-patching=inline-clone> + $<$:-fno-inline-functions> + $<$:-fno-inline-small-functions> + $<$:-fno-inline-functions-called-once> + $<$:-fno-early-inlining> + $<$:-fno-ipa-cp> + $<$:-fno-ipa-cp-clone> + $<$:-fno-ipa-sra> + $<$:-fno-partial-inlining>) endif () - endforeach () -endif () + endif () -if (MSVC) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:/hotpatch>) - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") - target_link_options(dusklight PRIVATE /FUNCTIONPADMIN:16 /OPT:NOICF) - else () - target_link_options(dusklight PRIVATE /FUNCTIONPADMIN /OPT:NOICF) - endif () -elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(AppleClang|Clang|GNU)$") - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=2,1>) - else () - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=10,4>) - endif () -endif () + if (DUSK_GAME_ABI_INLINE_OPTIONS) + target_compile_options(dusklight PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) -if (DEFINED DUSK_PATCHABLE_ENTRY_FLAG) - target_compile_options(dusklight PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) - foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) - target_compile_options(${jsystem_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) - endforeach() - foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx - aurora_os aurora_pad aurora_si aurora_vi) - if (TARGET ${_sdk_lib}) - get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) - if (NOT _sdk_lib_imported) - target_compile_options(${_sdk_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) + target_compile_options(${jsystem_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) + endforeach() + foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_sdk_lib}) + get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) + if (NOT _sdk_lib_imported) + target_compile_options(${_sdk_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) + endif () endif () + endforeach () + endif () + + if (MSVC) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:/hotpatch>) endif () - endforeach () + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") + target_link_options(dusklight PRIVATE /FUNCTIONPADMIN:16 /OPT:NOICF) + else () + target_link_options(dusklight PRIVATE /FUNCTIONPADMIN /OPT:NOICF) + endif () + elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(AppleClang|Clang|GNU)$") + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=2,1>) + else () + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=10,4>) + endif () + endif () + + if (DEFINED DUSK_PATCHABLE_ENTRY_FLAG) + target_compile_options(dusklight PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) + target_compile_options(${jsystem_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + endforeach() + foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_sdk_lib}) + get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) + if (NOT _sdk_lib_imported) + target_compile_options(${_sdk_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + endif () + endif () + endforeach () + endif () endif () if (WIN32) diff --git a/CMakePresets.json b/CMakePresets.json index 45a6522625..849e4161cd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -60,11 +60,7 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - } + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -151,10 +147,6 @@ "CMAKE_C_COMPILER": "cl", "CMAKE_CXX_COMPILER": "cl", "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -254,11 +246,7 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - } + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -323,10 +311,6 @@ "type": "BOOL", "value": false }, - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -372,10 +356,6 @@ "type": "BOOL", "value": false }, - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -406,10 +386,6 @@ "type": "BOOL", "value": false }, - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true From 57f0185a3c443ab5d645df7da93b0f1b635bcddb Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 1 Sep 2026 02:09:38 +0200 Subject: [PATCH 3/8] Suppress new XF memory write stub logs (#2362) --- src/dusk/logging.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dusk/logging.cpp b/src/dusk/logging.cpp index 7a6b1036bc..1f3a0451b4 100644 --- a/src/dusk/logging.cpp +++ b/src/dusk/logging.cpp @@ -14,6 +14,7 @@ constexpr std::string_view kStubFragments[] = { "Unimplemented: BP register"sv, "Unhandled BP register"sv, "Unhandled XF register"sv, + "Unhandled XF memory write"sv, "but selective updates are not implemented"sv, }; From 01e3c4616f2900d05c3b09cfc6889c8d61c77078 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 1 Sep 2026 02:10:07 +0200 Subject: [PATCH 4/8] global.h MSVC warning fix (#2359) --- include/global.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/global.h b/include/global.h index c16020936e..c559435fa5 100644 --- a/include/global.h +++ b/include/global.h @@ -83,11 +83,15 @@ extern void __dcbf(void*, int); extern void __dcbz(void*, int); extern void __sync(); extern int __abs(int); +#if defined(_MSVC_LANG) && !defined(__clang__) +#define __memcpy memcpy +#else #if defined(__has_builtin) && __has_builtin(__builtin_memcpy) #define __memcpy __builtin_memcpy #else #define __memcpy memcpy #endif +#endif #ifdef __cplusplus } #endif From 2e19ffbf50e159f65777af78a3faeebb1557d4a9 Mon Sep 17 00:00:00 2001 From: SuperDude88 <82904174+SuperDude88@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:15:15 -0400 Subject: [PATCH 5/8] Shorten int Change --- src/d/d_meter2.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/d/d_meter2.cpp b/src/d/d_meter2.cpp index 302daa4b0f..a90124ebb6 100644 --- a/src/d/d_meter2.cpp +++ b/src/d/d_meter2.cpp @@ -606,11 +606,7 @@ void dMeter2_c::moveLife() { life_count = (dComIfGs_getMaxLife() / 5) * 4; } -#if TARGET_PC - int new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount(); // prevent an overflow with really large damage values -#else - s16 new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount(); -#endif + DUSK_IF_ELSE(int, s16) new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount(); // prevent an overflow with really large damage values if (new_life > life_count) { new_life = life_count; From 2570c8f072b9dc6ba7f50dc2ec9cdb4f0ccc58e6 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Tue, 1 Sep 2026 01:09:42 -0700 Subject: [PATCH 6/8] fix gamemode onSaveLoaded handling with hideTvSettingsScreen setting --- src/d/d_bright_check.cpp | 8 ++++++++ src/d/d_file_select.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/d/d_bright_check.cpp b/src/d/d_bright_check.cpp index 7ec4f09b10..b9ea46e58e 100644 --- a/src/d/d_bright_check.cpp +++ b/src/d/d_bright_check.cpp @@ -191,6 +191,14 @@ void dBrightCheck_c::modeMove() { mDoAud_seStart(Z2SE_ENTER_GAME, NULL, 0, 0); #ifdef TARGET_PC toggleAutoSave(true); + + if (!dusk::getSettings().game.hideTvSettingsScreen) { + const dusk::gamemode::GameMode* gameMode = + dusk::gamemode::getGameModeManager().getCurrentGameMode(); + if (gameMode) { + gameMode->invokeOnSaveLoadedFunction(); + } + } #endif mCompleteCheck = true; mMode = MODE_WAIT_e; diff --git a/src/d/d_file_select.cpp b/src/d/d_file_select.cpp index 4b23d3ded9..3f64b8b239 100644 --- a/src/d/d_file_select.cpp +++ b/src/d/d_file_select.cpp @@ -1789,10 +1789,16 @@ void dFile_select_c::nameInput2() { #if TARGET_PC dusk::mods::svc::save_slot_new(mSelectNum); const dusk::gamemode::GameMode* gameMode = - dusk::gamemode::getGameModeManager().getCurrentGameMode(); + dusk::gamemode::getGameModeManager().getCurrentGameMode(); if (gameMode) { gameMode->invokeOnNewSaveFunction(); - gameMode->invokeOnSaveLoadedFunction(); + } + + // only do OnSaveLoaded callback here if hiding the brightness check screen + if (dusk::getSettings().game.hideTvSettingsScreen) { + if (gameMode) { + gameMode->invokeOnSaveLoadedFunction(); + } } #endif mDataSelProc = DATASELPROC_NEXT_MODE_WAIT; From 6c966876b9f41578614e6a531c3f2315518f7f83 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Tue, 1 Sep 2026 02:46:53 -0700 Subject: [PATCH 7/8] fix speedrun timer resetting --- src/dusk/ui/menu_bar.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/dusk/ui/menu_bar.cpp b/src/dusk/ui/menu_bar.cpp index d2bf8f8d9d..4884dbf3a9 100644 --- a/src/dusk/ui/menu_bar.cpp +++ b/src/dusk/ui/menu_bar.cpp @@ -160,17 +160,12 @@ void MenuBar::build_tabs() { }); if (dusk::speedrun::isActive()) { - mTabBar->add_tab("Reset Timer", [this] { + mTabBar->add_tab("Reset Run", [this] { mTabBar->set_active_tab(-1); mDoAud_seStartMenu(kSoundClick); dusk::speedrun::g_speedrunInfo.reset(); - if (getSettings().game.liveSplitEnabled) { - dusk::speedrun::reset(); - } - auto* playScene = fpcM_SearchByName(fpcNm_PLAY_SCENE_e); - if (playScene != nullptr) { - fopScnM_ChangeReq((scene_class*)playScene, fpcNm_NAME_SCENE_e, 0x7FFF, 0); - } + dusk::speedrun::reset(); + JUTGamePad::C3ButtonReset::sResetSwitchPushing = true; hide(false); }); } From a746b23944ecca700df3ccc3d3523e936be2c74b Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Tue, 1 Sep 2026 03:11:04 -0700 Subject: [PATCH 8/8] make sure tools are disabled for speedrun mode and reset run info when mode is deactivated --- src/dusk/speedrun.cpp | 5 +++++ src/dusk/ui/settings.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dusk/speedrun.cpp b/src/dusk/speedrun.cpp index 8527f9510a..166ef70839 100644 --- a/src/dusk/speedrun.cpp +++ b/src/dusk/speedrun.cpp @@ -19,6 +19,8 @@ static void onSpeedrunModeDeactive() { if (getSettings().game.liveSplitEnabled) { speedrun::disconnectLiveSplit(); } + g_speedrunInfo.reset(); + reset(); } void registerSpeedrunGameMode() { @@ -82,6 +84,9 @@ void resetForSpeedrunMode() { getSettings().backend.enableAdvancedSettings.setSpeedrunValue(false); getSettings().game.recordingMode.setSpeedrunValue(false); getSettings().game.debugFlyCam.setSpeedrunValue(false); + + getSettings().game.enableMoveLinkCombo.setSpeedrunValue(false); + getSettings().game.enableTeleportCombo.setSpeedrunValue(false); } static void clearSpeedrunOverrides() { diff --git a/src/dusk/ui/settings.cpp b/src/dusk/ui/settings.cpp index 5622110dc9..a546f1c76a 100644 --- a/src/dusk/ui/settings.cpp +++ b/src/dusk/ui/settings.cpp @@ -1239,7 +1239,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) { { .key = "Speedrun Mode", .helpText = - "Enables speedrunning options while restricting certain gameplay modifiers.", + "Enables Speedrun game mode option in the Dusklight launch menu.", .onChange = [this](bool enabled) { if (enabled) {