From 2684c683a87a852fce05405d43ff2ff25457c447 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Fri, 17 Apr 2009 11:13:59 +0000 Subject: [PATCH] cheats: - fixed search lists (and 3 byte size work correct now); - fixed search after load savestate; (will next step - add Action Replay parser) --- desmume/src/NDSSystem.cpp | 5 +++-- desmume/src/NDSSystem.h | 2 +- desmume/src/cheatSystem.cpp | 15 ++++++++++++--- desmume/src/saves.cpp | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index d9a0ec3b1..2b7b7c069 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -854,7 +854,7 @@ void NDS_FreeROM(void) MMU.bupmem.fp = NULL; } -void NDS_Reset( void) +void NDS_Reset(BOOL resetBySavestate) { unsigned int i; u32 src; @@ -1034,7 +1034,8 @@ void NDS_Reset( void) gfx3d_reset(); gpu3D->NDS_3D_Reset(); SPU_Reset(); - cheatsSearchClose(); + if (!resetBySavestate) + cheatsSearchClose(); #ifdef EXPERIMENTAL_WIFI WIFI_Init(&wifiMac); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 2cfefa3fd..0092d79b9 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -274,7 +274,7 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize, const char *cflash_disk_image_file); #endif void NDS_FreeROM(void); -void NDS_Reset(void); +void NDS_Reset(BOOL resetBySaveState = FALSE); int NDS_ImportSave(const char *filename); int NDS_WriteBMP(const char *filename); diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index 228be8765..b4be260aa 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -566,14 +566,23 @@ u32 cheatSearchNumber() BOOL cheatSearchGetList(u32 *address, u32 *curVal) { - for (u32 i = searchLastRecord; i < (4 * 1024 * 1024); i++) + u8 step = (searchSize+1); + u8 stepMem = 1; + switch (searchSize) + { + case 1: stepMem = 0x3; break; + case 2: stepMem = 0x7; break; + case 3: stepMem = 0xF; break; + } + + for (u32 i = searchLastRecord; i < (4 * 1024 * 1024); i+=step) { u32 addr = (i >> 3); u32 offs = (i % 8); - if (searchStatMem[addr] & (1<