继续增加调试输出

This commit is contained in:
anod 2023-01-19 00:03:51 +08:00
parent b42f0fe1aa
commit afeb36ef40

View File

@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static void log( const char *path, const void *buf, uint32_t size ) static void memo( const char *path, const void *buf, uint32_t size )
{ {
Result res; Result res;
FHandle f; FHandle f;
@ -183,39 +183,40 @@ static int32_t bin_search( acl_text_t game )
#define config_type(n) ( (n) & 0xff ) #define config_type(n) ( (n) & 0xff )
acl_error_t acl_select_game( acl_text_t game, acl_boolean_t filter, acl_count_t *n ) acl_error_t acl_select_game( acl_text_t game, acl_boolean_t filter, acl_count_t *n )
{ {
memo("sel.log", "0", 1);
CheatLib *inst = (CheatLib*)&gblcht; CheatLib *inst = (CheatLib*)&gblcht;
if( inst->serc == 0 ) return ACHTLIB_NOT_OPEN; if( inst->serc == 0 ) return ACHTLIB_NOT_OPEN;
if( strlen(game) != ACL_GBA_CODELEN ) return ACHTLIB_NOT_FOUND; if( strlen(game) != ACL_GBA_CODELEN ) return ACHTLIB_NOT_FOUND;
log("sel.log", "1", 1); memo("sel.log", "1", 1);
int32_t index = bin_search( game ); int32_t index = bin_search( game );
if( index < 0 ) return index * -1; if( index < 0 ) return index * -1;
log("sel.log", "2", 1); memo("sel.log", "2", 1);
uint32_t offset = ACL_HEADER_LEN + ACL_SERIAL_LEN(inst->serc); uint32_t offset = ACL_HEADER_LEN + ACL_SERIAL_LEN(inst->serc);
offset += ACL_INDEX_OFFSET(index); offset += ACL_INDEX_OFFSET(index);
log("sel.log", "3", 1); memo("sel.log", "3", 1);
uint32_t readed; uint32_t readed;
uint16_t groups[2]; uint16_t groups[2];
if( RES_OK != fLseek(inst->fd, offset) ) if( RES_OK != fLseek(inst->fd, offset) )
return ACHTLIB_INVALID; return ACHTLIB_INVALID;
log("sel.log", "4", 1); memo("sel.log", "4", 1);
if( RES_OK != fRead(inst->fd, groups, sizeof(groups), &readed) if( RES_OK != fRead(inst->fd, groups, sizeof(groups), &readed)
|| readed != sizeof(groups) ) || readed != sizeof(groups) )
return ACHTLIB_INVALID; return ACHTLIB_INVALID;
log("sel.log", "5", 1); memo("sel.log", "5", 1);
offset = ACL_HEADER_LEN + ACL_SERIAL_LEN(inst->serc) + ACL_INDEX_OFFSET(inst->serc+1); offset = ACL_HEADER_LEN + ACL_SERIAL_LEN(inst->serc) + ACL_INDEX_OFFSET(inst->serc+1);
offset += ACL_CONFIG_OFFSET(groups[0]); offset += ACL_CONFIG_OFFSET(groups[0]);
log("sel.log", "6", 1); memo("sel.log", "6", 1);
int32_t gcount = groups[1] - groups[0]; int32_t gcount = groups[1] - groups[0];
if( RES_OK != fLseek(inst->fd, offset) ) if( RES_OK != fLseek(inst->fd, offset) )
return ACHTLIB_INVALID; return ACHTLIB_INVALID;
log("sel.log", "7", 1); memo("sel.log", "7", 1);
CheatCfg *cfg = inst->list; CheatCfg *cfg = inst->list;
if( RES_OK != fRead(inst->fd, cfg, gcount * sizeof(CheatCfg), &readed) // 可能需要多次fread if( RES_OK != fRead(inst->fd, cfg, gcount * sizeof(CheatCfg), &readed) // 可能需要多次fread
|| readed != gcount * sizeof(CheatCfg) ) || readed != gcount * sizeof(CheatCfg) )
{ {
return ACHTLIB_INVALID; return ACHTLIB_INVALID;
} }
log("sel.log", "8", 1); memo("sel.log", "8", 1);
if( filter ) if( filter )
{ {
char reg = game[3]; char reg = game[3];
@ -234,7 +235,7 @@ log("sel.log", "8", 1);
} }
} }
} }
log("sel.log", "9", 1); memo("sel.log", "9", 1);
inst->listc = gcount; inst->listc = gcount;
inst->setid = 0; inst->setid = 0;
*n = gcount; *n = gcount;