mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
format
This commit is contained in:
parent
8502cd9285
commit
f922870785
3 changed files with 13 additions and 16 deletions
|
@ -12,9 +12,8 @@ class Memory;
|
||||||
class Cheats {
|
class Cheats {
|
||||||
public:
|
public:
|
||||||
enum class CheatType {
|
enum class CheatType {
|
||||||
None,
|
None, // Cheat has been removed by the frontend or is invalid
|
||||||
ActionReplay, // CTRPF cheats
|
ActionReplay, // CTRPF cheats
|
||||||
// TODO: Other cheat devices and standards?
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cheat {
|
struct Cheat {
|
||||||
|
|
|
@ -25,8 +25,8 @@ u32 Cheats::addCheat(const Cheat& cheat) {
|
||||||
|
|
||||||
void Cheats::removeCheat(u32 id) {
|
void Cheats::removeCheat(u32 id) {
|
||||||
if (id >= cheats.size()) {
|
if (id >= cheats.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not using std::erase because we don't want to invalidate cheat IDs
|
// Not using std::erase because we don't want to invalidate cheat IDs
|
||||||
cheats[id].type = CheatType::None;
|
cheats[id].type = CheatType::None;
|
||||||
|
@ -42,14 +42,14 @@ void Cheats::removeCheat(u32 id) {
|
||||||
|
|
||||||
void Cheats::enableCheat(u32 id) {
|
void Cheats::enableCheat(u32 id) {
|
||||||
if (id < cheats.size()) {
|
if (id < cheats.size()) {
|
||||||
cheats[id].enabled = true;
|
cheats[id].enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cheats::disableCheat(u32 id) {
|
void Cheats::disableCheat(u32 id) {
|
||||||
if (id < cheats.size()) {
|
if (id < cheats.size()) {
|
||||||
cheats[id].enabled = false;
|
cheats[id].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cheats::clear() {
|
void Cheats::clear() {
|
||||||
|
@ -67,7 +67,7 @@ void Cheats::run() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CheatType::None: break;
|
case CheatType::None: break;
|
||||||
default: Helpers::panic("Unknown cheat device!");
|
default: Helpers::panic("Unknown cheat device!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,20 +135,18 @@ void HydraCore::setCheckButtonCallback(s32 (*callback)(u32 player, hydra::Button
|
||||||
|
|
||||||
u32 HydraCore::addCheat(const u8* data, u32 size) {
|
u32 HydraCore::addCheat(const u8* data, u32 size) {
|
||||||
// Every 3DS cheat is a multiple of 64 bits == 8 bytes
|
// Every 3DS cheat is a multiple of 64 bits == 8 bytes
|
||||||
if ((size % 8) != 0) {
|
if ((size % 8) != 0) {
|
||||||
return hydra::BAD_CHEAT;
|
return hydra::BAD_CHEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cheats::Cheat cheat;
|
Cheats::Cheat cheat;
|
||||||
cheat.enabled = true;
|
cheat.enabled = true;
|
||||||
cheat.type = Cheats::CheatType::ActionReplay;
|
cheat.type = Cheats::CheatType::ActionReplay;
|
||||||
|
|
||||||
for (u32 i = 0; i < size; i += 8) {
|
for (u32 i = 0; i < size; i += 8) {
|
||||||
auto read32 = [](const u8* ptr) {
|
auto read32 = [](const u8* ptr) { return (u32(ptr[3]) << 24) | (u32(ptr[2]) << 16) | (u32(ptr[1]) << 8) | u32(ptr[0]); };
|
||||||
return (u32(ptr[3]) << 24) | (u32(ptr[2]) << 16) | (u32(ptr[1]) << 8) | u32(ptr[0]);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Data is passed to us in big endian so we bswap
|
// Data is passed to us in big endian so we bswap
|
||||||
u32 firstWord = Common::swap32(read32(data + i));
|
u32 firstWord = Common::swap32(read32(data + i));
|
||||||
u32 secondWord = Common::swap32(read32(data + i + 4));
|
u32 secondWord = Common::swap32(read32(data + i + 4));
|
||||||
cheat.instructions.insert(cheat.instructions.end(), {firstWord, secondWord});
|
cheat.instructions.insert(cheat.instructions.end(), {firstWord, secondWord});
|
||||||
|
|
Loading…
Add table
Reference in a new issue