From 506796a3351273c004179e071393a52655faea6b Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 15 Apr 2022 19:04:02 +0200 Subject: [PATCH] Add 5106, 5146, 5186 codes for indirect reads from a register code --- data/database/chtdb.txt | 22 +++++++++++++++------- src/core/cheats.cpp | 12 ++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/data/database/chtdb.txt b/data/database/chtdb.txt index ef89a5225..f4bc1782d 100644 --- a/data/database/chtdb.txt +++ b/data/database/chtdb.txt @@ -267,10 +267,6 @@ ; It will then poke all following codes for rest of cheat ; 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 ; **************** ; 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 ; with the 8-bit contents of Register XX. ; 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. ; u8Poke RegXX, (TTTTTTTT) ;* 510200XX 000000ZZ - 8-Bit Indirect Register Write, poke ZZ to the 32-Bit ; address stored in Register XX. ; 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. ; u8Poke RegXX, RegYY + ZZ ;* 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. ; u8Poke (RegXX), RegYY + ZZ ;* 510500XX 000000ZZ - 8-Bit Direct Register Write, poke ZZ to Register XX. ; 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: ; ================== @@ -340,6 +340,10 @@ ; u16Poke (RegXX), RegYY + ZZZZ ;* 514500XX 0000ZZZZ - 16-Bit Direct Register Write, poke ZZZZ to Register XX. ; 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: ; ================== @@ -363,6 +367,10 @@ ;* 518500XX ZZZZZZZZ - 32-Bit Direct Register Write, poke ZZZZZZZZ to Register XX. ; u32Poke RegXX, ZZZZZZZZ. Note: This is useful to write ; 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: ; ============================ diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index 4eb988a27..104891dee 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -1492,6 +1492,10 @@ void CheatCode::Apply() const case 0x05: // Write the u8 poke value to cht_register[cht_reg_no1] cht_register[cht_reg_no1] = Truncate8(poke_value & 0xFFu); 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(cht_register[cht_reg_no2] + poke_value); + break; case 0x40: // Write the u16 from cht_register[cht_reg_no1] to address DoMemoryWrite(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] cht_register[cht_reg_no1] = Truncate16(poke_value & 0xFFFFu); 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(cht_register[cht_reg_no2] + poke_value); + break; case 0x80: // Write the u32 from cht_register[cht_reg_no1] to address DoMemoryWrite(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] cht_register[cht_reg_no1] = poke_value; 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(cht_register[cht_reg_no2] + poke_value); + break; case 0xC0: // Reg3 = Reg2 + Reg1 cht_register[cht_reg_no3] = cht_register[cht_reg_no2] + cht_register[cht_reg_no1];