Merge pull request #131 from wheremyfoodat/cheats

More AR stuff
This commit is contained in:
wheremyfoodat 2023-07-21 15:39:57 +03:00 committed by GitHub
commit 5dfc17ed18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 17 deletions

View file

@ -13,7 +13,7 @@ class Cheats {
public: public:
enum class CheatType { enum class CheatType {
ActionReplay, // CTRPF cheats ActionReplay, // CTRPF cheats
Gateway, // TODO: Other cheat devices and standards?
}; };
struct Cheat { struct Cheat {

View file

@ -96,12 +96,37 @@ void ActionReplay::runInstruction(const Cheat& cheat, u32 instruction) {
break; break;
} }
// Less Than (YYYYYYYY < [XXXXXXX + offset]) // clang-format off
case 0x4: { #define MAKE_IF_INSTRUCTION(opcode, comparator) \
case opcode: { \
const u32 baseAddr = Helpers::getBits<0, 28>(instruction); \
const u32 imm = cheat[pc++]; \
const u32 value = read32(baseAddr + *activeOffset); \
\
pushConditionBlock(imm comparator value); \
break; \
}
// Greater Than (YYYYYYYY > [XXXXXXX + offset]) (Unsigned)
MAKE_IF_INSTRUCTION(3, >)
// Less Than (YYYYYYYY < [XXXXXXX + offset]) (Unsigned)
MAKE_IF_INSTRUCTION(4, <)
// Equal to (YYYYYYYY == [XXXXXXX + offset])
MAKE_IF_INSTRUCTION(5, ==)
// Not Equal (YYYYYYYY != [XXXXXXX + offset])
MAKE_IF_INSTRUCTION(6, !=)
#undef MAKE_IF_INSTRUCTION
// clang-format on
// BXXXXXXX 00000000 - offset = *(XXXXXXX + offset)
case 0xB: {
const u32 baseAddr = Helpers::getBits<0, 28>(instruction); const u32 baseAddr = Helpers::getBits<0, 28>(instruction);
const u32 imm = cheat[pc++]; *activeOffset = read32(baseAddr + *activeOffset);
const u32 value = read32(baseAddr + *activeOffset);
Helpers::panic("TODO: How do ActionReplay conditional blocks work?"); pc++; // Eat up dummy word
break; break;
} }

View file

@ -17,12 +17,7 @@ void Cheats::run() {
break; break;
} }
case CheatType::Gateway: { default: Helpers::panic("Unknown cheat device!");
Helpers::panic("Gateway cheats not supported yet! Only Action Replay is supported!");
break;
}
default: Helpers::panic("Unknown cheat type");
} }
} }
} }