mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +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]
|
[atmosphere]
|
||||||
; 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;
|
||||||
|
@ -75,7 +78,7 @@ void DmntCheatManager::WaitDebugEventsThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DmntCheatManager::CloseActiveCheatProcess() {
|
void DmntCheatManager::CloseActiveCheatProcess() {
|
||||||
if (g_cheat_process_debug_hnd != 0) {
|
if (g_cheat_process_debug_hnd != 0) {
|
||||||
/* Close process resources. */
|
/* Close process resources. */
|
||||||
svcCloseHandle(g_cheat_process_debug_hnd);
|
svcCloseHandle(g_cheat_process_debug_hnd);
|
||||||
g_cheat_process_debug_hnd = 0;
|
g_cheat_process_debug_hnd = 0;
|
||||||
|
@ -107,7 +110,7 @@ bool DmntCheatManager::HasActiveCheatProcess() {
|
||||||
if (has_cheat_process) {
|
if (has_cheat_process) {
|
||||||
has_cheat_process &= tmp == g_cheat_process_metadata.process_id;
|
has_cheat_process &= tmp == g_cheat_process_metadata.process_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_cheat_process) {
|
if (!has_cheat_process) {
|
||||||
CloseActiveCheatProcess();
|
CloseActiveCheatProcess();
|
||||||
}
|
}
|
||||||
|
@ -122,7 +125,7 @@ void DmntCheatManager::ContinueCheatProcess() {
|
||||||
while (R_SUCCEEDED(svcGetDebugEvent((u8 *)debug_event_buf, g_cheat_process_debug_hnd))) {
|
while (R_SUCCEEDED(svcGetDebugEvent((u8 *)debug_event_buf, g_cheat_process_debug_hnd))) {
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Continue the process. */
|
/* Continue the process. */
|
||||||
if (kernelAbove300()) {
|
if (kernelAbove300()) {
|
||||||
svcContinueDebugEvent(g_cheat_process_debug_hnd, 5, nullptr, 0);
|
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. */
|
/* 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();
|
||||||
|
|
|
@ -23,12 +23,13 @@ static constexpr u32 Module_Dmnt = 13;
|
||||||
static constexpr Result ResultDmntUnknown = MAKERESULT(Module_Dmnt, 1);
|
static constexpr Result ResultDmntUnknown = MAKERESULT(Module_Dmnt, 1);
|
||||||
static constexpr Result ResultDmntDebuggingDisabled = MAKERESULT(Module_Dmnt, 2);
|
static constexpr Result ResultDmntDebuggingDisabled = MAKERESULT(Module_Dmnt, 2);
|
||||||
|
|
||||||
static constexpr Result ResultDmntCheatNotAttached = MAKERESULT(Module_Dmnt, 6500);
|
static constexpr Result ResultDmntCheatNotAttached = MAKERESULT(Module_Dmnt, 6500);
|
||||||
static constexpr Result ResultDmntCheatNullBuffer = MAKERESULT(Module_Dmnt, 6501);
|
static constexpr Result ResultDmntCheatNullBuffer = MAKERESULT(Module_Dmnt, 6501);
|
||||||
static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6502);
|
static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6502);
|
||||||
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…
Reference in a new issue