修正include的逻辑

This commit is contained in:
anod 2023-03-07 16:28:26 +08:00
parent b6261d3e81
commit 8834685ee5

View File

@ -10,6 +10,8 @@ typedef instruction_t* CodeLocation;
#define CodeAtLocation(p) (*(p)) #define CodeAtLocation(p) (*(p))
#define MAKE_ENT(hole,key) (((key)<<16) | (hole)) #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 ROM_LOC ((CodeLocation)0x20000000u)
#define GBA_KEYCODE(k) (0x3ff & (~(k))) #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 ) cheat_error_t put_current_cheat( acl_entryid_t entid )
{ {
if( setting.chtId == 0 ) return CCHT_NOT_INIT; if( setting.chtId == 0 ) return CCHT_NOT_INIT;
u16 index = entid & 0xffff; u16 index = ENT_HOLE(entid);
u16 option = entid >> 16; u16 option = ENT_KEY(entid);
if( index == 0 ) return CCHT_INVALID; if( index == 0 ) return CCHT_INVALID;
if( index <= setting.entLen ) 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; if( setting.chtId == 0 ) return CCHT_NOT_INIT;
int index = id & 0xffff; int index = ENT_HOLE(id);
if( index == 0 ) return CCHT_OK; if( index == 0 ) return CCHT_OK;
else if( index < setting.entLen ) else if( index < setting.entLen )
{ {
acl_index_t val = setting.entArr[index-1]; 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;
} }
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; hookpoint[hookpoint_idx++] = pc;
else else
if( MASK_PC0(0xffff0000) == 0xe92d0000 && if( MASK_PC0(0XFFFF0000) == 0XE92D0000 &&
MASK_PC1(0xffff0fff) == 0xe3a00301 && MASK_PC1(0XFFFF0FFF) == 0XE3A00301 &&
MASK_PC2(0xfff00fff) == 0xe5b00200 && MASK_PC2(0XFFF00FFF) == 0XE5B00200 &&
MASK_PC3(0xffff0000) != 0xe59f0000 ) MASK_PC3(0XFFFF0000) != 0XE59F0000 )
hookpoint[hookpoint_idx++] = pc; hookpoint[hookpoint_idx++] = pc;
else else