修正获取rom的识别码失败的问题

This commit is contained in:
anod 2023-01-18 13:44:09 +08:00
parent 9c889be093
commit 527ad26d20

View File

@ -260,6 +260,7 @@ atp_error_t select_region( atp_callerdata_t data, atp_counter_t index, atp_itemc
extern atp_error_t oaf_config_page();
#define DIRBUFFSIZE 512
#define WAIT_ON_ACT( act ) ( ATP_POWER_OFF == (act) ) ? ATP_POWER_OFF : ATP_PAGE_REFRESH
#define WAIT_ON_ERRPAGE( page ) WAIT_ON_ACT( atp_show(1, (page), NULL) )
@ -277,18 +278,36 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
else if( x )
{
DirList const *dList = (DirList*)data;
const char *file = &dList->ptrs[index][1];
char *path = (char*)(data+1);
const char *file = &dList->ptrs[index][1];
int pathlen = strlen(path);
int filelen = strlen(file);
if( pathlen + filelen > DIRBUFFSIZE - 1)
{
return WAIT_ON_ERRPAGE( display_toolong );
}
else if( ENT_TYPE_DIR == dList->ptrs[index][0] )
{
return WAIT_ON_ERRPAGE( display_empty );
}
path[pathlen] = '/';
safeStrcpy( path+pathlen+1, file, DIRBUFFSIZE - filelen );
#define RECOVER_PATH path[pathlen] = '\0'
// 确定game serial
char serial[5];
if( RES_OK != rom_get_serial(file, serial) )
if( RES_OK != rom_get_serial(path, serial) )
{
RECOVER_PATH;
return WAIT_ON_ERRPAGE( display_noserial );
}
serial[4] = '\0';
else RECOVER_PATH;
acl_count_t len;
if( RES_OK != acl_open_lib( file ) )
if( RES_OK != acl_open_lib( "gba.acl" ) )
{
return WAIT_ON_ERRPAGE( display_openlib );
}
@ -312,12 +331,11 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
res = atp_select("选择一个金手指配置", len, select_region, NULL, type, 0, 0, &item );
acl_close_lib();
return ATP_PAGE_REFRESH;
return WAIT_ON_ACT( res );
}
return ATP_PAGE_NOOPTION;
}
#define DIRBUFFSIZE 512
#define PATH_SAME 0
#define PATH_PUSH 1
#define PATH_POP 2
@ -367,7 +385,8 @@ Result browseFiles(const char *const basePath, char selected[512])
GFX_waitForVBlank0();
hidScanInput();
atp_tips( NULL, "指引按START" );
error = atp_select( curDir, count, display_folder, serve_on_key, (atp_callerdata_t)dList, selecting, 0, &value );
void *cust[] = {dList, curDir};
error = atp_select( curDir, count, display_folder, serve_on_key, (atp_callerdata_t)cust, selecting, 0, &value );
}
else error = atp_show( 1, display_empty, NULL );