Merge branch 'main' of https://github.com/TwilitRealm/dusk into rando-mod

This commit is contained in:
gymnast86
2026-09-01 05:11:29 -07:00
11 changed files with 102 additions and 103 deletions
+65 -63
View File
@@ -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
$<$<COMPILE_LANGUAGE:CXX>:-finline-hint-functions>)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:-flive-patching=inline-clone>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-functions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-small-functions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-functions-called-once>
$<$<COMPILE_LANGUAGE:CXX>:-fno-early-inlining>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-cp>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-cp-clone>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-sra>
$<$<COMPILE_LANGUAGE:CXX>:-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
$<$<COMPILE_LANGUAGE:CXX>:-finline-hint-functions>)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:-flive-patching=inline-clone>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-functions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-small-functions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-inline-functions-called-once>
$<$<COMPILE_LANGUAGE:CXX>:-fno-early-inlining>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-cp>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-cp-clone>
$<$<COMPILE_LANGUAGE:CXX>:-fno-ipa-sra>
$<$<COMPILE_LANGUAGE:CXX>:-fno-partial-inlining>)
endif ()
endforeach ()
endif ()
endif ()
if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(DUSK_PATCHABLE_ENTRY_FLAG $<$<COMPILE_LANGUAGE:C,CXX>:/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 $<$<COMPILE_LANGUAGE:C,CXX>:-fpatchable-function-entry=2,1>)
else ()
set(DUSK_PATCHABLE_ENTRY_FLAG $<$<COMPILE_LANGUAGE:C,CXX>:-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 $<$<COMPILE_LANGUAGE:C,CXX>:/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 $<$<COMPILE_LANGUAGE:C,CXX>:-fpatchable-function-entry=2,1>)
else ()
set(DUSK_PATCHABLE_ENTRY_FLAG $<$<COMPILE_LANGUAGE:C,CXX>:-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)
+2 -26
View File
@@ -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
+4
View File
@@ -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
+3 -2
View File
@@ -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) {
+8
View File
@@ -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;
+8 -2
View File
@@ -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;
+2 -1
View File
@@ -606,7 +606,8 @@ void dMeter2_c::moveLife() {
life_count = (dComIfGs_getMaxLife() / 5) * 4;
}
s16 new_life = dComIfGs_getLife() + dComIfGp_getItemLifeCount();
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;
} else if (new_life < 0) {
+1
View File
@@ -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,
};
+5
View File
@@ -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() {
+3 -8
View File
@@ -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);
});
}
+1 -1
View File
@@ -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) {