From 9efb7effbea3ec09d8ef1d1fa94bf3cd9ecda44e Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Mon, 20 Mar 2023 12:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0dump=20rom=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/arm11/atp.h | 6 +++++- source/arm11/filebrowser.c | 8 ++++++++ source/arm11/open_agb_firm.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/arm11/atp.h b/include/arm11/atp.h index b48c430..c4e57aa 100644 --- a/include/arm11/atp.h +++ b/include/arm11/atp.h @@ -40,9 +40,13 @@ typedef void * atp_callerdata_t; // page option #define ATP_PAGE_NOOPTION 0 +#define ATP_PAGE_DOSELECT 1 // SAME AS SELECT #define ATP_PAGE_UPDATE 2 // UPDATE THE CURSOR ROW #define ATP_PAGE_REFRESH 3 // UPDATE THE WHOLE PAGE -#define ATP_PAGE_DOSELECT 4 // SAME AS SELECT +#define ATP_PAGE_PREVITEM 5 +#define ATP_PAGE_NEXTITEM 6 +#define ATP_PAGE_PREVPAGE 7 +#define ATP_PAGE_NEXTPAGE 8 typedef struct { atp_text_t text; diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index a17121c..b292318 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -624,6 +624,14 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a atp_tips( NULL, "指引:按START" ); return WAIT_ON_ACT( res ); } +#ifndef NDEBUG + else if( y ) + { + extern u8 dump_patched_rom; + dump_patched_rom = 1; + } +#endif + return ATP_PAGE_NOOPTION; } diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index a65d184..0b33212 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -134,6 +134,32 @@ static OafConfig g_oafConfig = static KHandle g_frameReadyEvent = 0; static u16 detect_cheatKey = 0; +#ifndef NDEBUG +u8 dump_patched_rom = 0; +Result dump_rom( u32 size ) +{ + FHandle file; + Result res; + if( (res=fOpen(&file, "dump.gba", FA_OPEN_ALWAYS|FA_WRITE)) != RES_OK ) + return res; + + u8 *p = ROM_LOC; + while( size > 0 ) + { + u32 len; + res = fWrite( file, p, 512, &len ); + if( res != RES_OK ) + return res; + + size -= len; + p += len; + } + fClose( file ); + + return RES_OK; +} +#endif + // -------------------------- // code for oaf config page // -------------------------- @@ -411,6 +437,13 @@ static Result loadGbaRom(const char *const path, u32 *const romSizeOut) } *romSizeOut = fixRomPadding(fileSize); + +#ifndef NDEBUG + if( dump_patched_rom ) + { + dump_rom( fileSize ); + } +#endif } else {