From 8834685ee5e6fbab79d7336a91c59b1cab522bdd Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Tue, 7 Mar 2023 16:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3include=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/cheat.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/arm11/cheat.c b/source/arm11/cheat.c index 3eff065..a52b49c 100644 --- a/source/arm11/cheat.c +++ b/source/arm11/cheat.c @@ -10,6 +10,8 @@ typedef instruction_t* CodeLocation; #define CodeAtLocation(p) (*(p)) #define MAKE_ENT(hole,key) (((key)<<16) | (hole)) +#define ENT_KEY(id) ((id)>>16) +#define ENT_HOLE(id) ((id)&0xffff) #define ROM_LOC ((CodeLocation)0x20000000u) #define GBA_KEYCODE(k) (0x3ff & (~(k))) @@ -44,8 +46,8 @@ cheat_error_t init_current_cheat( u32 id, u16 len ) cheat_error_t put_current_cheat( acl_entryid_t entid ) { if( setting.chtId == 0 ) return CCHT_NOT_INIT; - u16 index = entid & 0xffff; - u16 option = entid >> 16; + u16 index = ENT_HOLE(entid); + u16 option = ENT_KEY(entid); if( index == 0 ) return CCHT_INVALID; if( index <= setting.entLen ) @@ -80,12 +82,12 @@ cheat_error_t include_current_cheat( acl_entryid_t id ) { if( setting.chtId == 0 ) return CCHT_NOT_INIT; - int index = id & 0xffff; + int index = ENT_HOLE(id); if( index == 0 ) return CCHT_OK; else if( index < setting.entLen ) { acl_index_t val = setting.entArr[index-1]; - if( val != 0 ) return CCHT_OK; + if( val == ENT_KEY(id) ) return CCHT_OK; else return CCHT_INVALID; } else return CCHT_INVALID; @@ -238,10 +240,10 @@ static int rom_search_hookpoint( CodeLocation addr, int addrlen, CodeLocation ho hookpoint[hookpoint_idx++] = pc; else - if( MASK_PC0(0xffff0000) == 0xe92d0000 && - MASK_PC1(0xffff0fff) == 0xe3a00301 && - MASK_PC2(0xfff00fff) == 0xe5b00200 && - MASK_PC3(0xffff0000) != 0xe59f0000 ) + if( MASK_PC0(0XFFFF0000) == 0XE92D0000 && + MASK_PC1(0XFFFF0FFF) == 0XE3A00301 && + MASK_PC2(0XFFF00FFF) == 0XE5B00200 && + MASK_PC3(0XFFFF0000) != 0XE59F0000 ) hookpoint[hookpoint_idx++] = pc; else