summaryrefslogtreecommitdiffstats
path: root/src/core/memory/dmnt_cheat_vm.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-07-17 23:11:52 +0200
committerGitHub <noreply@github.com>2020-07-17 23:11:52 +0200
commit5d95e62443f8174e65678dcb714222a736b21614 (patch)
tree617ef4384902e760e3a20b5738dcdd4d1556657a /src/core/memory/dmnt_cheat_vm.cpp
parentMerge pull request #4309 from Morph1984/fix-romfs-bug (diff)
parentclang-format (diff)
downloadyuzu-5d95e62443f8174e65678dcb714222a736b21614.tar
yuzu-5d95e62443f8174e65678dcb714222a736b21614.tar.gz
yuzu-5d95e62443f8174e65678dcb714222a736b21614.tar.bz2
yuzu-5d95e62443f8174e65678dcb714222a736b21614.tar.lz
yuzu-5d95e62443f8174e65678dcb714222a736b21614.tar.xz
yuzu-5d95e62443f8174e65678dcb714222a736b21614.tar.zst
yuzu-5d95e62443f8174e65678dcb714222a736b21614.zip
Diffstat (limited to 'src/core/memory/dmnt_cheat_vm.cpp')
-rw-r--r--src/core/memory/dmnt_cheat_vm.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp
index fb9f36bfd..2e7da23fe 100644
--- a/src/core/memory/dmnt_cheat_vm.cpp
+++ b/src/core/memory/dmnt_cheat_vm.cpp
@@ -190,6 +190,15 @@ void DmntCheatVm::LogOpcode(const CheatVmOpcode& opcode) {
callbacks->CommandLog(
fmt::format("Act[{:02X}]: {:d}", i, save_restore_regmask->should_operate[i]));
}
+ } else if (auto rw_static_reg = std::get_if<ReadWriteStaticRegisterOpcode>(&opcode.opcode)) {
+ callbacks->CommandLog("Opcode: Read/Write Static Register");
+ if (rw_static_reg->static_idx < NumReadableStaticRegisters) {
+ callbacks->CommandLog("Op Type: ReadStaticRegister");
+ } else {
+ callbacks->CommandLog("Op Type: WriteStaticRegister");
+ }
+ callbacks->CommandLog(fmt::format("Reg Idx {:X}", rw_static_reg->idx));
+ callbacks->CommandLog(fmt::format("Stc Idx {:X}", rw_static_reg->static_idx));
} else if (auto debug_log = std::get_if<DebugLogOpcode>(&opcode.opcode)) {
callbacks->CommandLog("Opcode: Debug Log");
callbacks->CommandLog(fmt::format("Bit Width: {:X}", debug_log->bit_width));
@@ -544,6 +553,16 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
}
opcode.opcode = save_restore_regmask;
} break;
+ case CheatVmOpcodeType::ReadWriteStaticRegister: {
+ ReadWriteStaticRegisterOpcode rw_static_reg{};
+ // C3000XXx
+ // C3 = opcode 0xC3.
+ // XX = static register index.
+ // x = register index.
+ rw_static_reg.static_idx = ((first_dword >> 4) & 0xFF);
+ rw_static_reg.idx = (first_dword & 0xF);
+ opcode.opcode = rw_static_reg;
+ } break;
case CheatVmOpcodeType::DebugLog: {
DebugLogOpcode debug_log{};
// FFFTIX##
@@ -667,6 +686,7 @@ void DmntCheatVm::ResetState() {
registers.fill(0);
saved_values.fill(0);
loop_tops.fill(0);
+ static_registers.fill(0);
instruction_ptr = 0;
condition_depth = 0;
decode_success = true;
@@ -1153,6 +1173,15 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
}
}
}
+ } else if (auto rw_static_reg =
+ std::get_if<ReadWriteStaticRegisterOpcode>(&cur_opcode.opcode)) {
+ if (rw_static_reg->static_idx < NumReadableStaticRegisters) {
+ // Load a register with a static register.
+ registers[rw_static_reg->idx] = static_registers[rw_static_reg->static_idx];
+ } else {
+ // Store a register to a static register.
+ static_registers[rw_static_reg->static_idx] = registers[rw_static_reg->idx];
+ }
} else if (auto debug_log = std::get_if<DebugLogOpcode>(&cur_opcode.opcode)) {
// Read value from memory.
u64 log_value = 0;