From 7551bebb888c5a1637dcd47775d7572d771284e6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 15 Mar 2019 18:29:43 -0700 Subject: [PATCH] dmnt-cheat: Fix a few bugs in vm. --- stratosphere/dmnt/source/dmnt_cheat_vm.cpp | 5 +++-- stratosphere/dmnt/source/dmnt_hid.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stratosphere/dmnt/source/dmnt_cheat_vm.cpp b/stratosphere/dmnt/source/dmnt_cheat_vm.cpp index 318d7cbde..3b0e05c3b 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_vm.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_vm.cpp @@ -147,6 +147,7 @@ void DmntCheatVm::LogOpcode(const CheatVmOpcode *opcode) { case CheatVmOpcodeType_BeginRegisterConditionalBlock: this->LogToDebugFile("Opcode: Begin Register Conditional\n"); this->LogToDebugFile("Bit Width: %x\n", opcode->begin_reg_cond.bit_width); + this->LogToDebugFile("Cond Type: %x\n", opcode->begin_reg_cond.cond_type); this->LogToDebugFile("V Reg Idx: %x\n", opcode->begin_reg_cond.val_reg_index); switch (opcode->begin_reg_cond.comp_type) { case CompareRegisterValueType_StaticValue: @@ -300,7 +301,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) { { /* 400R0000 VVVVVVVV VVVVVVVV */ /* Read additional words. */ - opcode.ldr_static.reg_index = ((first_dword >> 20) & 0xF); + opcode.ldr_static.reg_index = ((first_dword >> 16) & 0xF); opcode.ldr_static.value = (((u64)GetNextDword()) << 32ul) | ((u64)GetNextDword()); } break; @@ -461,7 +462,7 @@ void DmntCheatVm::SkipConditionalBlock() { const size_t desired_depth = this->condition_depth - 1; CheatVmOpcode skip_opcode; - while (this->DecodeNextOpcode(&skip_opcode) && this->condition_depth > desired_depth) { + while (this->condition_depth > desired_depth && this->DecodeNextOpcode(&skip_opcode)) { /* Decode instructions until we see end of the current conditional block. */ /* NOTE: This is broken in gateway's implementation. */ /* Gateway currently checks for "0x2" instead of "0x20000000" */ diff --git a/stratosphere/dmnt/source/dmnt_hid.cpp b/stratosphere/dmnt/source/dmnt_hid.cpp index 8dd34c672..1f09d0edd 100644 --- a/stratosphere/dmnt/source/dmnt_hid.cpp +++ b/stratosphere/dmnt/source/dmnt_hid.cpp @@ -26,7 +26,7 @@ Result HidManagement::GetKeysDown(u64 *keys) { std::scoped_lock lk(g_hid_keys_down_lock); hidScanInput(); - *keys = hidKeysDown(CONTROLLER_P1_AUTO); + *keys = hidKeysHeld(CONTROLLER_P1_AUTO); return 0x0; } \ No newline at end of file