From cfa050cc8f9eea3008253e490d7ea5217974dbd9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 27 May 2019 18:10:49 -0700 Subject: [PATCH] dmnt: explicitly reserve double-extended width opcodes --- stratosphere/dmnt/source/dmnt_cheat_vm.cpp | 4 ++++ stratosphere/dmnt/source/dmnt_cheat_vm.hpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/stratosphere/dmnt/source/dmnt_cheat_vm.cpp b/stratosphere/dmnt/source/dmnt_cheat_vm.cpp index bb3ccae99..1aa5126e7 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_vm.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_vm.cpp @@ -260,6 +260,9 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) { if (opcode.opcode >= CheatVmOpcodeType_ExtendedWidth) { opcode.opcode = (CheatVmOpcodeType)((((u32)opcode.opcode) << 4) | ((first_dword >> 24) & 0xF)); } + if (opcode.opcode >= CheatVmOpcodeType_DoubleExtendedWidth) { + opcode.opcode = (CheatVmOpcodeType)((((u32)opcode.opcode) << 4) | ((first_dword >> 20) & 0xF)); + } /* detect condition start. */ switch (opcode.opcode) { @@ -501,6 +504,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) { } break; case CheatVmOpcodeType_ExtendedWidth: + case CheatVmOpcodeType_DoubleExtendedWidth: default: /* Unrecognized instruction cannot be decoded. */ valid = false; diff --git a/stratosphere/dmnt/source/dmnt_cheat_vm.hpp b/stratosphere/dmnt/source/dmnt_cheat_vm.hpp index 134e5478f..210f949d8 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_vm.hpp +++ b/stratosphere/dmnt/source/dmnt_cheat_vm.hpp @@ -45,6 +45,10 @@ enum CheatVmOpcodeType : u32 { CheatVmOpcodeType_BeginRegisterConditionalBlock = 0xC0, CheatVmOpcodeType_SaveRestoreRegister = 0xC1, CheatVmOpcodeType_SaveRestoreRegisterMask = 0xC2, + + /* This is a meta entry, and not a real opcode. */ + /* This is to facilitate multi-nybble instruction decoding. */ + CheatVmOpcodeType_DoubleExtendedWidth = 0xF0, }; enum MemoryAccessType : u32 {