implement code type 0xC4

This commit is contained in:
tomvita 2025-01-06 18:09:28 +08:00
parent 0ea8d67f06
commit c2cef36702
2 changed files with 31 additions and 3 deletions

View File

@ -158,6 +158,11 @@ namespace ams::dmnt::cheat::impl {
this->LogToDebugFile("Opcode: Begin Keypress Conditional\n"); this->LogToDebugFile("Opcode: Begin Keypress Conditional\n");
this->LogToDebugFile("Key Mask: %x\n", opcode->begin_keypress_cond.key_mask); this->LogToDebugFile("Key Mask: %x\n", opcode->begin_keypress_cond.key_mask);
break; break;
case CheatVmOpcodeType_BeginExtendedKeypressConditionalBlock:
this->LogToDebugFile("Opcode: Begin Extended Keypress Conditional\n");
this->LogToDebugFile("Key Mask: %x\n", opcode->begin_ext_keypress_cond.key_mask);
this->LogToDebugFile("Auto Repeat: %d\n", opcode->begin_ext_keypress_cond.auto_repeat);
break;
case CheatVmOpcodeType_PerformArithmeticRegister: case CheatVmOpcodeType_PerformArithmeticRegister:
this->LogToDebugFile("Opcode: Perform Register Arithmetic\n"); this->LogToDebugFile("Opcode: Perform Register Arithmetic\n");
this->LogToDebugFile("Bit Width: %x\n", opcode->perform_math_reg.bit_width); this->LogToDebugFile("Bit Width: %x\n", opcode->perform_math_reg.bit_width);
@ -365,6 +370,7 @@ namespace ams::dmnt::cheat::impl {
switch (opcode.opcode) { switch (opcode.opcode) {
case CheatVmOpcodeType_BeginConditionalBlock: case CheatVmOpcodeType_BeginConditionalBlock:
case CheatVmOpcodeType_BeginKeypressConditionalBlock: case CheatVmOpcodeType_BeginKeypressConditionalBlock:
case CheatVmOpcodeType_BeginExtendedKeypressConditionalBlock:
case CheatVmOpcodeType_BeginRegisterConditionalBlock: case CheatVmOpcodeType_BeginRegisterConditionalBlock:
opcode.begin_conditional_block = true; opcode.begin_conditional_block = true;
break; break;
@ -468,6 +474,14 @@ namespace ams::dmnt::cheat::impl {
opcode.begin_keypress_cond.key_mask = first_dword & 0x0FFFFFFF; opcode.begin_keypress_cond.key_mask = first_dword & 0x0FFFFFFF;
} }
break; break;
case CheatVmOpcodeType_BeginExtendedKeypressConditionalBlock:
{
/* C4r000kk kkkkkkkk */
/* Read additional words. */
opcode.begin_ext_keypress_cond.key_mask = (((u64)first_dword & 0xFF) << 32ul) | ((u64)GetNextDword());
opcode.begin_ext_keypress_cond.auto_repeat = ((first_dword >> 20) & 0xF) != 0;
}
break;
case CheatVmOpcodeType_PerformArithmeticRegister: case CheatVmOpcodeType_PerformArithmeticRegister:
{ {
/* 9TCRSIs0 (VVVVVVVV (VVVVVVVV)) */ /* 9TCRSIs0 (VVVVVVVV (VVVVVVVV)) */
@ -999,12 +1013,19 @@ namespace ams::dmnt::cheat::impl {
break; break;
case CheatVmOpcodeType_BeginKeypressConditionalBlock: case CheatVmOpcodeType_BeginKeypressConditionalBlock:
/* Check for keypress. */ /* Check for keypress. */
if (cur_opcode.begin_keypress_cond.key_mask > 0x8000000) { if ((cur_opcode.begin_keypress_cond.key_mask & kHeld) != cur_opcode.begin_keypress_cond.key_mask) {
if ((cur_opcode.begin_keypress_cond.key_mask & 0x7FFFFFF & kHeld) != (cur_opcode.begin_keypress_cond.key_mask & 0x7FFFFFF) || (cur_opcode.begin_keypress_cond.key_mask & 0x7FFFFFF & keyold) == (cur_opcode.begin_keypress_cond.key_mask & 0x7FFFFFF)) { /* Keys not pressed. Skip conditional block. */
this->SkipConditionalBlock(true);
}
break;
case CheatVmOpcodeType_BeginExtendedKeypressConditionalBlock:
/* Check for keypress. */
if (!cur_opcode.begin_ext_keypress_cond.auto_repeat) {
if ((cur_opcode.begin_ext_keypress_cond.key_mask & kHeld) != (cur_opcode.begin_ext_keypress_cond.key_mask) || (cur_opcode.begin_ext_keypress_cond.key_mask & keyold) == (cur_opcode.begin_ext_keypress_cond.key_mask)) {
/* Keys not pressed. Skip conditional block. */ /* Keys not pressed. Skip conditional block. */
this->SkipConditionalBlock(true); this->SkipConditionalBlock(true);
} }
} else if ((cur_opcode.begin_keypress_cond.key_mask & kHeld) != cur_opcode.begin_keypress_cond.key_mask) { } else if ((cur_opcode.begin_ext_keypress_cond.key_mask & kHeld) != cur_opcode.begin_ext_keypress_cond.key_mask) {
/* Keys not pressed. Skip conditional block. */ /* Keys not pressed. Skip conditional block. */
this->SkipConditionalBlock(true); this->SkipConditionalBlock(true);
} }

View File

@ -43,6 +43,7 @@ namespace ams::dmnt::cheat::impl {
CheatVmOpcodeType_SaveRestoreRegister = 0xC1, CheatVmOpcodeType_SaveRestoreRegister = 0xC1,
CheatVmOpcodeType_SaveRestoreRegisterMask = 0xC2, CheatVmOpcodeType_SaveRestoreRegisterMask = 0xC2,
CheatVmOpcodeType_ReadWriteStaticRegister = 0xC3, CheatVmOpcodeType_ReadWriteStaticRegister = 0xC3,
CheatVmOpcodeType_BeginExtendedKeypressConditionalBlock = 0xC4,
/* This is a meta entry, and not a real opcode. */ /* This is a meta entry, and not a real opcode. */
/* This is to facilitate multi-nybble instruction decoding. */ /* This is to facilitate multi-nybble instruction decoding. */
@ -192,6 +193,11 @@ namespace ams::dmnt::cheat::impl {
u32 key_mask; u32 key_mask;
}; };
struct BeginExtendedKeypressConditionalOpcode {
u64 key_mask;
bool auto_repeat;
};
struct PerformArithmeticRegisterOpcode { struct PerformArithmeticRegisterOpcode {
u32 bit_width; u32 bit_width;
RegisterArithmeticType math_type; RegisterArithmeticType math_type;
@ -266,6 +272,7 @@ namespace ams::dmnt::cheat::impl {
StoreStaticToAddressOpcode str_static; StoreStaticToAddressOpcode str_static;
PerformArithmeticStaticOpcode perform_math_static; PerformArithmeticStaticOpcode perform_math_static;
BeginKeypressConditionalOpcode begin_keypress_cond; BeginKeypressConditionalOpcode begin_keypress_cond;
BeginExtendedKeypressConditionalOpcode begin_ext_keypress_cond;
PerformArithmeticRegisterOpcode perform_math_reg; PerformArithmeticRegisterOpcode perform_math_reg;
StoreRegisterToAddressOpcode str_register; StoreRegisterToAddressOpcode str_register;
BeginRegisterConditionalOpcode begin_reg_cond; BeginRegisterConditionalOpcode begin_reg_cond;