mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 11:11:30 +12:00
Merge branch 'master' into ir
This commit is contained in:
commit
3b067a0eed
3 changed files with 37 additions and 17 deletions
|
@ -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 {
|
||||||
|
|
|
@ -29,14 +29,14 @@ void ActionReplay::runCheat(const Cheat& cheat) {
|
||||||
}
|
}
|
||||||
// Fetch instruction
|
// Fetch instruction
|
||||||
const u32 instruction = cheat[pc++];
|
const u32 instruction = cheat[pc++];
|
||||||
|
|
||||||
// Instructions D0000000 00000000 and D2000000 00000000 are unconditional
|
// Instructions D0000000 00000000 and D2000000 00000000 are unconditional
|
||||||
bool isUnconditional = cheat[pc] == 0 && (instruction == 0xD0000000 || instruction == 0xD2000000);
|
bool isUnconditional = cheat[pc] == 0 && (instruction == 0xD0000000 || instruction == 0xD2000000);
|
||||||
if (ifStackIndex > 0 && !isUnconditional && !ifStack[ifStackIndex - 1]) {
|
if (ifStackIndex > 0 && !isUnconditional && !ifStack[ifStackIndex - 1]) {
|
||||||
pc++; // Eat up dummy word
|
pc++; // Eat up dummy word
|
||||||
continue; // Skip conditional instructions where the condition is false
|
continue; // Skip conditional instructions where the condition is false
|
||||||
}
|
}
|
||||||
|
|
||||||
runInstruction(cheat, instruction);
|
runInstruction(cheat, instruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +210,7 @@ void ActionReplay::executeDType(const Cheat& cheat, u32 instruction) {
|
||||||
case 0xD2000000: {
|
case 0xD2000000: {
|
||||||
const u32 subopcode = cheat[pc++];
|
const u32 subopcode = cheat[pc++];
|
||||||
switch (subopcode) {
|
switch (subopcode) {
|
||||||
// Ends all loop/execute blocks
|
// Ends all loop/execute blocks
|
||||||
case 0:
|
case 0:
|
||||||
loopStackIndex = 0;
|
loopStackIndex = 0;
|
||||||
ifStackIndex = 0;
|
ifStackIndex = 0;
|
||||||
|
|
|
@ -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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue