mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-01-19 01:34:10 +01:00
dmnt-cheat: make cheats default toggle configurable
This commit is contained in:
parent
4d0ab41e6e
commit
d756f2fc0d
@ -9,3 +9,6 @@ usb30_force_enabled = u8!0x0
|
|||||||
; Make the power menu's "reboot" button reboot to payload.
|
; Make the power menu's "reboot" button reboot to payload.
|
||||||
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
|
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
|
||||||
power_menu_reboot_function = str!payload
|
power_menu_reboot_function = str!payload
|
||||||
|
; Controls whether dmnt cheats should be enabled or disabled
|
||||||
|
; by default. 1 = enabled by default, 0 = disabled by default.
|
||||||
|
dmnt_cheats_enabled_by_default = u8!0x1
|
@ -26,6 +26,7 @@
|
|||||||
"sfdnsres",
|
"sfdnsres",
|
||||||
"bsdcfg",
|
"bsdcfg",
|
||||||
"set",
|
"set",
|
||||||
|
"set:sys",
|
||||||
"fsp-srv",
|
"fsp-srv",
|
||||||
"fatal:u",
|
"fatal:u",
|
||||||
"hid"
|
"hid"
|
||||||
|
@ -30,6 +30,9 @@ static DmntCheatVm *g_cheat_vm;
|
|||||||
static CheatProcessMetadata g_cheat_process_metadata = {0};
|
static CheatProcessMetadata g_cheat_process_metadata = {0};
|
||||||
static Handle g_cheat_process_debug_hnd = 0;
|
static Handle g_cheat_process_debug_hnd = 0;
|
||||||
|
|
||||||
|
/* Should we enable cheats by default? */
|
||||||
|
static bool g_enable_cheats_by_default = true;
|
||||||
|
|
||||||
/* For debug event thread management. */
|
/* For debug event thread management. */
|
||||||
static HosMutex g_debug_event_thread_lock;
|
static HosMutex g_debug_event_thread_lock;
|
||||||
static bool g_has_debug_events_thread = false;
|
static bool g_has_debug_events_thread = false;
|
||||||
@ -383,10 +386,15 @@ bool DmntCheatManager::ParseCheats(const char *s, size_t len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Master cheat can't be disabled. */
|
||||||
|
if (g_cheat_entries[0].definition.num_opcodes > 0) {
|
||||||
|
g_cheat_entries[0].enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable all entries we parsed. */
|
/* Enable all entries we parsed. */
|
||||||
for (size_t i = 0; i < DmntCheatManager::MaxCheatCount; i++) {
|
for (size_t i = 1; i < DmntCheatManager::MaxCheatCount; i++) {
|
||||||
if (g_cheat_entries[i].definition.num_opcodes > 0) {
|
if (g_cheat_entries[i].definition.num_opcodes > 0) {
|
||||||
g_cheat_entries[i].enabled = true;
|
g_cheat_entries[i].enabled = g_enable_cheats_by_default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,6 +509,10 @@ Result DmntCheatManager::ToggleCheat(u32 cheat_id) {
|
|||||||
return ResultDmntCheatUnknownChtId;
|
return ResultDmntCheatUnknownChtId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cheat_id == 0) {
|
||||||
|
return ResultDmntCheatCannotDisableMasterCheat;
|
||||||
|
}
|
||||||
|
|
||||||
entry->enabled = !entry->enabled;
|
entry->enabled = !entry->enabled;
|
||||||
|
|
||||||
/* Trigger a VM reload. */
|
/* Trigger a VM reload. */
|
||||||
@ -935,6 +947,14 @@ void DmntCheatManager::InitializeCheatManager() {
|
|||||||
/* Create cheat vm. */
|
/* Create cheat vm. */
|
||||||
g_cheat_vm = new DmntCheatVm();
|
g_cheat_vm = new DmntCheatVm();
|
||||||
|
|
||||||
|
/* Learn whether we should enable cheats by default. */
|
||||||
|
{
|
||||||
|
u8 en;
|
||||||
|
if (R_SUCCEEDED(setsysGetSettingsItemValue("atmosphere", "dmnt_cheats_enabled_by_default", &en, sizeof(en)))) {
|
||||||
|
g_enable_cheats_by_default = (en != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Spawn application detection thread, spawn cheat vm thread. */
|
/* Spawn application detection thread, spawn cheat vm thread. */
|
||||||
if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39))) {
|
if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39))) {
|
||||||
std::abort();
|
std::abort();
|
||||||
|
@ -99,6 +99,11 @@ void __appInit(void) {
|
|||||||
fatalSimple(rc);
|
fatalSimple(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = setsysInitialize();
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
fatalSimple(rc);
|
||||||
|
}
|
||||||
|
|
||||||
rc = hidInitialize();
|
rc = hidInitialize();
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
fatalSimple(rc);
|
fatalSimple(rc);
|
||||||
@ -122,6 +127,7 @@ void __appExit(void) {
|
|||||||
fsdevUnmountAll();
|
fsdevUnmountAll();
|
||||||
fsExit();
|
fsExit();
|
||||||
hidExit();
|
hidExit();
|
||||||
|
setsysExit();
|
||||||
setExit();
|
setExit();
|
||||||
lrExit();
|
lrExit();
|
||||||
nsdevExit();
|
nsdevExit();
|
||||||
|
@ -29,6 +29,7 @@ static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6
|
|||||||
static constexpr Result ResultDmntCheatUnknownChtId = MAKERESULT(Module_Dmnt, 6503);
|
static constexpr Result ResultDmntCheatUnknownChtId = MAKERESULT(Module_Dmnt, 6503);
|
||||||
static constexpr Result ResultDmntCheatOutOfCheats = MAKERESULT(Module_Dmnt, 6504);
|
static constexpr Result ResultDmntCheatOutOfCheats = MAKERESULT(Module_Dmnt, 6504);
|
||||||
static constexpr Result ResultDmntCheatInvalidCheat = MAKERESULT(Module_Dmnt, 6505);
|
static constexpr Result ResultDmntCheatInvalidCheat = MAKERESULT(Module_Dmnt, 6505);
|
||||||
|
static constexpr Result ResultDmntCheatCannotDisableMasterCheat = MAKERESULT(Module_Dmnt, 6505);
|
||||||
|
|
||||||
static constexpr Result ResultDmntCheatInvalidFreezeWidth = MAKERESULT(Module_Dmnt, 6600);
|
static constexpr Result ResultDmntCheatInvalidFreezeWidth = MAKERESULT(Module_Dmnt, 6600);
|
||||||
static constexpr Result ResultDmntCheatAddressAlreadyFrozen = MAKERESULT(Module_Dmnt, 6601);
|
static constexpr Result ResultDmntCheatAddressAlreadyFrozen = MAKERESULT(Module_Dmnt, 6601);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user