From 400b9d2e55e14feed7a6383d6a6d8cc0715c90b9 Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Mon, 3 Apr 2023 15:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E7=8E=B0core=20hook?= =?UTF-8?q?point=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/cheat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/arm11/cheat.c b/source/arm11/cheat.c index 8a872f8..e2ad054 100644 --- a/source/arm11/cheat.c +++ b/source/arm11/cheat.c @@ -250,6 +250,10 @@ static int end_of_rom( CodeLocation addr, u32 size ) #define MASK_PC8( m ) (pc[8]&m) #define MASK_PC9( m ) (pc[9]&m) +#define IRQ_HANDLER_POINTER (0x03007ffc) //see gbatek `BIOS Interrupt handling' +#define CORE_HOOKPOINT_RANGE (1<<9) +#define CORE_HOOKPOINT_NEARBY (1<<8) + static int rom_search_hookpoint( CodeLocation addr, int addrlen, CodeLocation hookpoint[MAX_HOOKPOINT] ) { CodeLocation mark[MAX_HOOKPOINT]; @@ -258,7 +262,7 @@ static int rom_search_hookpoint( CodeLocation addr, int addrlen, CodeLocation ho for( int i=0; i < addrlen; ++i ) { CodeLocation pc = addr + i; - if( *pc == 0x03007ffc && mark_idx < MAX_HOOKPOINT ) + if( *pc == IRQ_HANDLER_POINTER && mark_idx < MAX_HOOKPOINT ) mark[mark_idx++] = pc; if( MASK_PC0(0XFFFF0FFF) == 0XE3A00301 && @@ -311,18 +315,19 @@ static int rom_search_hookpoint( CodeLocation addr, int addrlen, CodeLocation ho for( int i=0; i < hookpoint_idx; ++i ) { CodeLocation p = hookpoint[i]; - if( p - addr > (1<<11) ) break; + if( p - addr > CORE_HOOKPOINT_RANGE ) break; for( int j = 0; j < mark_idx; ++j ) { CodeLocation q = mark[j]; u32 d = p