添加dump rom的功能

This commit is contained in:
anod 2023-03-20 12:20:11 +08:00
parent 44aca8e6be
commit 9efb7effbe
3 changed files with 46 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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
{