Merge pull request #2823 from CookiePLMonster/read-reg-cheat-code

Add 5106, 5146, 5186 codes for indirect reads from a register code
This commit is contained in:
Connor McLaughlin 2022-04-17 18:16:40 +10:00 committed by GitHub
commit d105ea52e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View file

@ -267,10 +267,6 @@
; It will then poke all following codes for rest of cheat ; It will then poke all following codes for rest of cheat
; 00000000 FFFF or until it reaches the 00000000 FFFF line. ; 00000000 FFFF or until it reaches the 00000000 FFFF line.
; ;
;* 52XXXXXX YYYYYYYY - Register Master Code, if ($XXXXXX) contains 0xYYYYYYYY poke
; 00000000 FFFF all following codes for rest of the cheat or until it reaches
; the 00000000 FFFF line.
;
; Other Code Types ; Other Code Types
; **************** ; ****************
; These are only needed on hardware when you can't enable & disable codes after ; These are only needed on hardware when you can't enable & disable codes after
@ -304,21 +300,25 @@
;* 510000XX TTTTTTTT - 8-Bit Address Write from Register, Poke address TTTTTTTT ;* 510000XX TTTTTTTT - 8-Bit Address Write from Register, Poke address TTTTTTTT
; with the 8-bit contents of Register XX. ; with the 8-bit contents of Register XX.
; u8Poke TTTTTTTT, RegXX ; u8Poke TTTTTTTT, RegXX
;* 510100XX TTTTTTTT - 8-Bit Address Read to Register, Peek the 8bit contents of ;* 510100XX TTTTTTTT - 8-Bit Address Read to Register, Peek the 8-bit contents of
; address TTTTTTTT and store it in Register XX. ; address TTTTTTTT and store it in Register XX.
; u8Poke RegXX, (TTTTTTTT) ; u8Poke RegXX, (TTTTTTTT)
;* 510200XX 000000ZZ - 8-Bit Indirect Register Write, poke ZZ to the 32-Bit ;* 510200XX 000000ZZ - 8-Bit Indirect Register Write, poke ZZ to the 32-Bit
; address stored in Register XX. ; address stored in Register XX.
; u8Poke (RegXX), ZZ ; u8Poke (RegXX), ZZ
;* 5103YYXX 000000ZZ - 8-Bit Register Addition, add ZZ and the 8 bit contents ;* 5103YYXX 000000ZZ - 8-Bit Register Addition, add ZZ and the 8-bit contents
; of Register YY together and write it to Register XX. ; of Register YY together and write it to Register XX.
; u8Poke RegXX, RegYY + ZZ ; u8Poke RegXX, RegYY + ZZ
;* 5104YYXX 000000ZZ - 8-Bit Indirect Register Write with addition, add ZZ and ;* 5104YYXX 000000ZZ - 8-Bit Indirect Register Write with addition, add ZZ and
; the 8 bit contents of Register YY together and write it ; the 8-bit contents of Register YY together and write it
; to the 32-Bit address stored in Register XX. ; to the 32-Bit address stored in Register XX.
; u8Poke (RegXX), RegYY + ZZ ; u8Poke (RegXX), RegYY + ZZ
;* 510500XX 000000ZZ - 8-Bit Direct Register Write, poke ZZ to Register XX. ;* 510500XX 000000ZZ - 8-Bit Direct Register Write, poke ZZ to Register XX.
; u8Poke RegXX, ZZ ; u8Poke RegXX, ZZ
;* 5106YYXX ZZZZZZZZ - 8-Bit Indirect Register Read, Peek the 8-bit contents
; of (32-Bit address in Register YY + ZZZZZZZZ) and write it
; to Register XX.
; u8Poke RegXX, (RegYY + ZZZZZZZZ)
; ;
; 16 BIT operations: ; 16 BIT operations:
; ================== ; ==================
@ -340,6 +340,10 @@
; u16Poke (RegXX), RegYY + ZZZZ ; u16Poke (RegXX), RegYY + ZZZZ
;* 514500XX 0000ZZZZ - 16-Bit Direct Register Write, poke ZZZZ to Register XX. ;* 514500XX 0000ZZZZ - 16-Bit Direct Register Write, poke ZZZZ to Register XX.
; u16Poke RegXX, ZZZZ ; u16Poke RegXX, ZZZZ
;* 5146YYXX ZZZZZZZZ - 16-Bit Indirect Register Read, Peek the 16-bit contents
; of (32-Bit address in Register YY + ZZZZZZZZ) and write it
; to Register XX.
; u16Poke RegXX, (RegYY + ZZZZZZZZ)
; ;
; 32 BIT operations: ; 32 BIT operations:
; ================== ; ==================
@ -363,6 +367,10 @@
;* 518500XX ZZZZZZZZ - 32-Bit Direct Register Write, poke ZZZZZZZZ to Register XX. ;* 518500XX ZZZZZZZZ - 32-Bit Direct Register Write, poke ZZZZZZZZ to Register XX.
; u32Poke RegXX, ZZZZZZZZ. Note: This is useful to write ; u32Poke RegXX, ZZZZZZZZ. Note: This is useful to write
; the actual address to a register. ; the actual address to a register.
;* 5186YYXX ZZZZZZZZ - 32-Bit Indirect Register Read, Peek the 32-bit contents
; of (32-Bit address in Register YY + ZZZZZZZZ) and write it
; to Register XX.
; u32Poke RegXX, (RegYY + ZZZZZZZZ)
; ;
; Generic Register Operations: ; Generic Register Operations:
; ============================ ; ============================

View file

@ -1492,6 +1492,10 @@ void CheatCode::Apply() const
case 0x05: // Write the u8 poke value to cht_register[cht_reg_no1] case 0x05: // Write the u8 poke value to cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = Truncate8(poke_value & 0xFFu); cht_register[cht_reg_no1] = Truncate8(poke_value & 0xFFu);
break; break;
case 0x06: // Read the u8 value from the address (cht_register[cht_reg_no2] + poke_value) to
// cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u8>(cht_register[cht_reg_no2] + poke_value);
break;
case 0x40: // Write the u16 from cht_register[cht_reg_no1] to address case 0x40: // Write the u16 from cht_register[cht_reg_no1] to address
DoMemoryWrite<u16>(inst.value32, Truncate16(cht_register[cht_reg_no1] & 0xFFFFu)); DoMemoryWrite<u16>(inst.value32, Truncate16(cht_register[cht_reg_no1] & 0xFFFFu));
@ -1515,6 +1519,10 @@ void CheatCode::Apply() const
case 0x45: // Write the u16 poke value to cht_register[cht_reg_no1] case 0x45: // Write the u16 poke value to cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = Truncate16(poke_value & 0xFFFFu); cht_register[cht_reg_no1] = Truncate16(poke_value & 0xFFFFu);
break; break;
case 0x46: // Read the u16 value from the address (cht_register[cht_reg_no2] + poke_value) to
// cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u16>(cht_register[cht_reg_no2] + poke_value);
break;
case 0x80: // Write the u32 from cht_register[cht_reg_no1] to address case 0x80: // Write the u32 from cht_register[cht_reg_no1] to address
DoMemoryWrite<u32>(inst.value32, cht_register[cht_reg_no1]); DoMemoryWrite<u32>(inst.value32, cht_register[cht_reg_no1]);
@ -1536,6 +1544,10 @@ void CheatCode::Apply() const
case 0x85: // Write the u32 poke value to cht_register[cht_reg_no1] case 0x85: // Write the u32 poke value to cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = poke_value; cht_register[cht_reg_no1] = poke_value;
break; break;
case 0x86: // Read the u32 value from the address (cht_register[cht_reg_no2] + poke_value) to
// cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u32>(cht_register[cht_reg_no2] + poke_value);
break;
case 0xC0: // Reg3 = Reg2 + Reg1 case 0xC0: // Reg3 = Reg2 + Reg1
cht_register[cht_reg_no3] = cht_register[cht_reg_no2] + cht_register[cht_reg_no1]; cht_register[cht_reg_no3] = cht_register[cht_reg_no2] + cht_register[cht_reg_no1];