Cheats: Added register cheat types 5107 & 5147 (#3352)

This is new cheat type uses the general purpose cheat registers in a relative easy method to allow arrays of arrays cheats to be quickly created and will also cut down massively on cheats. For instance this method allows the following 15 cheats for Vandal Hearts II which would otherwise need 18886 separate cheats to replicate:

#Technique Slot Modifier\[MASTER] Select Slot Number for following cheats to act on (1 - 1349)
518500F1 001CF3C3
514500F2 0000000F
514500F3 0000????
514500F4 0000D0D0
OptionRange = 1:1349
#Technique Slot Modifier\Select Weapon
510700F1 000000??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 1 Learned
510700F1 00020001
#Technique Slot Modifier\Select Technique 1
510700F1 000300??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 2 Learned
510700F1 00040001
#Technique Slot Modifier\Select Technique 2
510700F1 000500??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 3 Learned
510700F1 00060001
#Technique Slot Modifier\Select Technique 3
510700F1 000700??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 4 Learned
510700F1 00080001
#Technique Slot Modifier\Select Technique 4
510700F1 000900??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 5 Learned
510700F1 000A0001
#Technique Slot Modifier\Select Technique 5
510700F1 000B00??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\Technique 6 Learned
510700F1 000C0001
#Technique Slot Modifier\Select Technique 6
510700F1 000D00??
OptionRange = 0x00:0xFF
#Technique Slot Modifier\100% (Max) Technique Learned
510700F1 000E0064
This commit is contained in:
PugsyMAME 2025-01-11 02:37:03 +00:00 committed by GitHub
parent ea4e756512
commit a26cac18e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

View File

@ -2803,6 +2803,7 @@ void Cheats::GamesharkCheatCode::Apply() const
const u8 cht_reg_no2 = Truncate8((inst.address & 0xFF00u) >> 8); const u8 cht_reg_no2 = Truncate8((inst.address & 0xFF00u) >> 8);
const u8 cht_reg_no3 = Truncate8(inst.value32 & 0xFFu); const u8 cht_reg_no3 = Truncate8(inst.value32 & 0xFFu);
const u8 sub_type = Truncate8((inst.address & 0xFF0000u) >> 16); const u8 sub_type = Truncate8((inst.address & 0xFF0000u) >> 16);
const u16 cht_offset = Truncate16((inst.value32 & 0xFFFF0000u) >> 16);
switch (sub_type) switch (sub_type)
{ {
@ -2831,6 +2832,20 @@ void Cheats::GamesharkCheatCode::Apply() const
// cht_register[cht_reg_no1] // cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u8>(cht_register[cht_reg_no2] + poke_value); cht_register[cht_reg_no1] = DoMemoryRead<u8>(cht_register[cht_reg_no2] + poke_value);
break; break;
case 0x07: // Write the u8 poke_value to a specific index of a single array in a series of consecutive arrays
//This cheat type requires a separate cheat to set up 4 consecutive cht_arrays before this will work
//cht_register[cht_reg_no1] = the base address of the first element of the first array
//cht_register[cht_reg_no1+1] = the array size (basically the address diff between the start of each array)
//cht_register[cht_reg_no1+2] = the index of which array in the series to poke (this must be greater than 0)
//cht_register[cht_reg_no1+3] must == 0xD0D0 to ensure it only pokes when the above cht_regs have been set
// (safety valve)
//cht_offset = the index of the individual array to change (so must be 0 to cht_register[cht_reg_no1+1])
if (cht_register[cht_reg_no1 + 3] == 0xD0D0 && cht_register[cht_reg_no1 + 2] > 0
&& cht_register[cht_reg_no1 + 1] >= cht_offset)
DoMemoryWrite<u8>((cht_register[cht_reg_no1] - cht_register[cht_reg_no1 + 1]) +
(cht_register[cht_reg_no1 + 1] * cht_register[cht_reg_no1 + 2]) + cht_offset,
Truncate8(poke_value & 0xFFu));
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));
@ -2858,6 +2873,20 @@ void Cheats::GamesharkCheatCode::Apply() const
// cht_register[cht_reg_no1] // cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u16>(cht_register[cht_reg_no2] + poke_value); cht_register[cht_reg_no1] = DoMemoryRead<u16>(cht_register[cht_reg_no2] + poke_value);
break; break;
case 0x47: // Write the u16 poke_value to a specific index of a single array in a series of consecutive arrays
//This cheat type requires a separate cheat to set up 4 consecutive cht_arrays before this will work
//cht_register[cht_reg_no1] = the base address of the first element of the first array
//cht_register[cht_reg_no1+1] = the array size (basically the address diff between the start of each array)
//cht_register[cht_reg_no1+2] = the index of which array in the series to poke (this must be greater than 0)
//cht_register[cht_reg_no1+3] must == 0xD0D0 to ensure it only pokes when the above cht_regs have been set
// (safety valve)
//cht_offset = the index of the individual array to change (so must be 0 to cht_register[cht_reg_no1+1])
if (cht_register[cht_reg_no1 + 3] == 0xD0D0 && cht_register[cht_reg_no1 + 2] > 0
&& cht_register[cht_reg_no1 + 1] >= cht_offset)
DoMemoryWrite<u16>((cht_register[cht_reg_no1] - cht_register[cht_reg_no1 + 1]) +
(cht_register[cht_reg_no1 + 1] * cht_register[cht_reg_no1 + 2]) + cht_offset,
Truncate16(poke_value & 0xFFFFu));
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]);
@ -2883,6 +2912,7 @@ void Cheats::GamesharkCheatCode::Apply() const
// cht_register[cht_reg_no1] // cht_register[cht_reg_no1]
cht_register[cht_reg_no1] = DoMemoryRead<u32>(cht_register[cht_reg_no2] + poke_value); cht_register[cht_reg_no1] = DoMemoryRead<u32>(cht_register[cht_reg_no2] + poke_value);
break; break;
//Do not use 0x87 as it's not possible to duplicate 0x07, 0x47 for a 32 bit write as not enough characters
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];