mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 13:52:21 +00:00
dmnt-cheat: make cheats default toggle configurable
This commit is contained in:
parent
4d0ab41e6e
commit
d756f2fc0d
5 changed files with 43 additions and 12 deletions
|
@ -8,4 +8,7 @@ usb30_force_enabled = u8!0x0
|
|||
[atmosphere]
|
||||
; Make the power menu's "reboot" button reboot to payload.
|
||||
; 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",
|
||||
"bsdcfg",
|
||||
"set",
|
||||
"set:sys",
|
||||
"fsp-srv",
|
||||
"fatal:u",
|
||||
"hid"
|
||||
|
|
|
@ -30,6 +30,9 @@ static DmntCheatVm *g_cheat_vm;
|
|||
static CheatProcessMetadata g_cheat_process_metadata = {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. */
|
||||
static HosMutex g_debug_event_thread_lock;
|
||||
static bool g_has_debug_events_thread = false;
|
||||
|
@ -75,7 +78,7 @@ void DmntCheatManager::WaitDebugEventsThread() {
|
|||
}
|
||||
|
||||
void DmntCheatManager::CloseActiveCheatProcess() {
|
||||
if (g_cheat_process_debug_hnd != 0) {
|
||||
if (g_cheat_process_debug_hnd != 0) {
|
||||
/* Close process resources. */
|
||||
svcCloseHandle(g_cheat_process_debug_hnd);
|
||||
g_cheat_process_debug_hnd = 0;
|
||||
|
@ -107,7 +110,7 @@ bool DmntCheatManager::HasActiveCheatProcess() {
|
|||
if (has_cheat_process) {
|
||||
has_cheat_process &= tmp == g_cheat_process_metadata.process_id;
|
||||
}
|
||||
|
||||
|
||||
if (!has_cheat_process) {
|
||||
CloseActiveCheatProcess();
|
||||
}
|
||||
|
@ -122,7 +125,7 @@ void DmntCheatManager::ContinueCheatProcess() {
|
|||
while (R_SUCCEEDED(svcGetDebugEvent((u8 *)debug_event_buf, g_cheat_process_debug_hnd))) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
|
||||
/* Continue the process. */
|
||||
if (kernelAbove300()) {
|
||||
svcContinueDebugEvent(g_cheat_process_debug_hnd, 5, nullptr, 0);
|
||||
|
@ -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. */
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (cheat_id == 0) {
|
||||
return ResultDmntCheatCannotDisableMasterCheat;
|
||||
}
|
||||
|
||||
entry->enabled = !entry->enabled;
|
||||
|
||||
/* Trigger a VM reload. */
|
||||
|
@ -935,6 +947,14 @@ void DmntCheatManager::InitializeCheatManager() {
|
|||
/* Create cheat vm. */
|
||||
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. */
|
||||
if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39))) {
|
||||
std::abort();
|
||||
|
|
|
@ -99,6 +99,11 @@ void __appInit(void) {
|
|||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = setsysInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = hidInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
|
@ -122,6 +127,7 @@ void __appExit(void) {
|
|||
fsdevUnmountAll();
|
||||
fsExit();
|
||||
hidExit();
|
||||
setsysExit();
|
||||
setExit();
|
||||
lrExit();
|
||||
nsdevExit();
|
||||
|
|
|
@ -23,12 +23,13 @@ static constexpr u32 Module_Dmnt = 13;
|
|||
static constexpr Result ResultDmntUnknown = MAKERESULT(Module_Dmnt, 1);
|
||||
static constexpr Result ResultDmntDebuggingDisabled = MAKERESULT(Module_Dmnt, 2);
|
||||
|
||||
static constexpr Result ResultDmntCheatNotAttached = MAKERESULT(Module_Dmnt, 6500);
|
||||
static constexpr Result ResultDmntCheatNullBuffer = MAKERESULT(Module_Dmnt, 6501);
|
||||
static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6502);
|
||||
static constexpr Result ResultDmntCheatUnknownChtId = MAKERESULT(Module_Dmnt, 6503);
|
||||
static constexpr Result ResultDmntCheatOutOfCheats = MAKERESULT(Module_Dmnt, 6504);
|
||||
static constexpr Result ResultDmntCheatInvalidCheat = MAKERESULT(Module_Dmnt, 6505);
|
||||
static constexpr Result ResultDmntCheatNotAttached = MAKERESULT(Module_Dmnt, 6500);
|
||||
static constexpr Result ResultDmntCheatNullBuffer = MAKERESULT(Module_Dmnt, 6501);
|
||||
static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6502);
|
||||
static constexpr Result ResultDmntCheatUnknownChtId = MAKERESULT(Module_Dmnt, 6503);
|
||||
static constexpr Result ResultDmntCheatOutOfCheats = MAKERESULT(Module_Dmnt, 6504);
|
||||
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 ResultDmntCheatAddressAlreadyFrozen = MAKERESULT(Module_Dmnt, 6601);
|
||||
|
|
Loading…
Reference in a new issue