dmnt-cheat: Add opcode to store register to memory

This commit is contained in:
Michael Scire
2019-03-05 01:20:18 -08:00
parent 88a6ef4cd7
commit 8c86074da2
2 changed files with 127 additions and 27 deletions

View File

@@ -28,12 +28,13 @@ enum CheatVmOpcodeType : u32 {
CheatVmOpcodeType_ControlLoop = 3,
CheatVmOpcodeType_LoadRegisterStatic = 4,
CheatVmOpcodeType_LoadRegisterMemory = 5,
CheatVmOpcodeType_StoreToRegisterAddress = 6,
CheatVmOpcodeType_StoreStaticToAddress = 6,
CheatVmOpcodeType_PerformArithmeticStatic = 7,
CheatVmOpcodeType_BeginKeypressConditionalBlock = 8,
/* These are not implemented by Gateway's VM. */
CheatVmOpcodeType_PerformArithmeticRegister = 9,
CheatVmOpcodeType_StoreRegisterToAddress = 10,
/* This is a meta entry, and not a real opcode. */
/* This is to facilitate multi-nybble instruction decoding in the future. */
@@ -70,6 +71,12 @@ enum RegisterArithmeticType : u32 {
RegisterArithmeticType_None = 9,
};
enum StoreRegisterOffsetType : u32 {
StoreRegisterOffsetType_None = 0,
StoreRegisterOffsetType_Reg = 1,
StoreRegisterOffsetType_Imm = 2,
};
union VmInt {
u8 bit8;
u16 bit16;
@@ -114,7 +121,7 @@ struct LoadRegisterMemoryOpcode {
u64 rel_address;
};
struct StoreToRegisterAddressOpcode {
struct StoreStaticToAddressOpcode {
u32 bit_width;
u32 reg_index;
bool increment_reg;
@@ -144,6 +151,17 @@ struct PerformArithmeticRegisterOpcode {
VmInt value;
};
struct StoreRegisterToAddressOpcode {
u32 bit_width;
u32 str_reg_index;
u32 addr_reg_index;
bool increment_reg;
StoreRegisterOffsetType ofs_type;
u32 ofs_reg_index;
u64 rel_address;
};
struct CheatVmOpcode {
CheatVmOpcodeType opcode;
union {
@@ -153,10 +171,11 @@ struct CheatVmOpcode {
ControlLoopOpcode ctrl_loop;
LoadRegisterStaticOpcode ldr_static;
LoadRegisterMemoryOpcode ldr_memory;
StoreToRegisterAddressOpcode str_regaddr;
StoreStaticToAddressOpcode str_static;
PerformArithmeticStaticOpcode perform_math_static;
BeginKeypressConditionalOpcode begin_keypress_cond;
PerformArithmeticRegisterOpcode perform_math_reg;
StoreRegisterToAddressOpcode str_register;
};
};