Preprocess cheats to get rid of hacks that try to modify the cheat engine, add support for C2 cheat opcode

This commit is contained in:
Gericom
2026-03-14 12:27:35 +01:00
parent 8c8f36f5c6
commit d0f25a51d9
5 changed files with 142 additions and 3 deletions

View File

@@ -27,6 +27,7 @@
#include "DSMode.h"
#include "Arm7IoRegisterClearer.h"
#include "PatchListFactory.h"
#include "CheatPreprocessor.h"
#include "NdsLoader.h"
#define AP_LIST_PATH "/_pico/aplist.bin"
@@ -523,6 +524,7 @@ void NdsLoader::ApplyArm7Patches()
{
sendToArm9(IPC_COMMAND_ARM9_APPLY_ARM7_PATCHES);
sendToArm9(_cheats ? _cheats->length : 0);
PreprocessCheats();
void* patchSpaceStart = (void*)receiveFromArm9();
void* cheatsPtr = (void*)receiveFromArm9();
if (cheatsPtr != nullptr && _cheats != nullptr)
@@ -569,6 +571,20 @@ void NdsLoader::ApplyArm7Patches()
}
}
void NdsLoader::PreprocessCheats()
{
if (_cheats != nullptr)
{
CheatPreprocessor cheatPreprocessor;
auto cheat = &_cheats->firstCheat;
for (u32 i = 0; i < _cheats->numberOfCheats; i++)
{
cheatPreprocessor.PreprocessCheat(cheat);
cheat = (pload_cheat_t*)((u8*)cheat + cheat->length);
}
}
}
void NdsLoader::SetupSharedMemory(u32 cardId, u32 agbMem, u32 resetParam, u32 romOffset, u32 bootType)
{
memcpy(TWL_SHARED_MEMORY->ntrSharedMem.cardRomHeader, &_romHeader, sizeof(nds_header_ntr_t) - 0x10);