mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-08 06:44:12 +08:00
修复acl.c里面的bug,已调试完成
This commit is contained in:
parent
22194bdb64
commit
582e58dc85
@ -123,12 +123,11 @@ static int32_t bin_search( acl_text_t game )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int size = ACL_SERIAL_LEN(gblcht.serc);
|
int size = ACL_SERIAL_LEN(gblcht.serc);
|
||||||
const char *serials = (char*)malloc( size );
|
char *serials = (char*)malloc( size );
|
||||||
if( serials == NULL ){
|
if( serials == NULL ){
|
||||||
return -ACHTLIB_NOMEM;
|
return -ACHTLIB_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
uint32_t readed;
|
uint32_t readed;
|
||||||
if( RES_OK != fRead(gblcht.fd, serials, size, &readed)
|
if( RES_OK != fRead(gblcht.fd, serials, size, &readed)
|
||||||
|| readed != size )
|
|| readed != size )
|
||||||
@ -140,10 +139,10 @@ static int32_t bin_search( acl_text_t game )
|
|||||||
int start = 0, end = gblcht.serc - 1;
|
int start = 0, end = gblcht.serc - 1;
|
||||||
size = ACL_SERIAL_LEN(1);
|
size = ACL_SERIAL_LEN(1);
|
||||||
int found = -1;
|
int found = -1;
|
||||||
while( start < end )
|
while( start <= end )
|
||||||
{
|
{
|
||||||
int mid = (start+end) >> 1;
|
int mid = (start+end) >> 1;
|
||||||
int res = strncmp( game, &serials[ACL_SERIAL_LEN(mid)], size );
|
int res = strncmp( game, serials+ACL_SERIAL_LEN(mid), size );
|
||||||
if( res == 0 )
|
if( res == 0 )
|
||||||
{
|
{
|
||||||
found = mid;
|
found = mid;
|
||||||
@ -298,14 +297,14 @@ static acl_error_t load_data()
|
|||||||
gblset.entdata = NULL;
|
gblset.entdata = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int elemlen = gblset.entry.entid > 0xffff ? sizdof(uint32_t) : sizeof(uint16_t);
|
int elemlen = gblset.entry.entid > 0xffff ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||||
int total = gblset.entry.datasz * elemlen;
|
int total = gblset.entry.datasz * elemlen;
|
||||||
if( total == 0 ) return ACHTLIB_SUCCESS;
|
if( total == 0 ) return ACHTLIB_SUCCESS;
|
||||||
|
|
||||||
uint8_t *d = (uint8_t*)malloc( total );
|
uint8_t *d = (uint8_t*)malloc( total );
|
||||||
if( d == NULL ) return ACHTLIB_NOMEM;
|
if( d == NULL ) return ACHTLIB_NOMEM;
|
||||||
|
|
||||||
if( RES_OK != fLseek(gblcht.fd, gblset.entry.offset))
|
if( RES_OK != fLseek(gblcht.fd, gblset.seek + gblset.entry.offset))
|
||||||
return ACHTLIB_INVALID;
|
return ACHTLIB_INVALID;
|
||||||
|
|
||||||
uint32_t readed;
|
uint32_t readed;
|
||||||
@ -322,7 +321,7 @@ static acl_error_t load_data()
|
|||||||
|
|
||||||
#define config_offset(n) ( (n & ~0xff) >> 3 )
|
#define config_offset(n) ( (n & ~0xff) >> 3 )
|
||||||
|
|
||||||
acl_error_t acl_select_cheat_set( acl_cheatid_t id )
|
acl_error_t acl_select_cheat_set( acl_chtid_t id )
|
||||||
{
|
{
|
||||||
CheatLib *inst = &gblcht;
|
CheatLib *inst = &gblcht;
|
||||||
if( inst->serc == 0 ) return ACHTLIB_NOT_OPEN;
|
if( inst->serc == 0 ) return ACHTLIB_NOT_OPEN;
|
||||||
@ -339,6 +338,7 @@ acl_error_t acl_select_cheat_set( acl_cheatid_t id )
|
|||||||
acl_error_t r = init_cheatset( offset );
|
acl_error_t r = init_cheatset( offset );
|
||||||
if( r == ACHTLIB_SUCCESS )
|
if( r == ACHTLIB_SUCCESS )
|
||||||
{
|
{
|
||||||
|
found = 1;
|
||||||
inst->setid = id;
|
inst->setid = id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ acl_error_t acl_select_entry( acl_entryid_t id, acl_elemlen_t *count)
|
|||||||
{
|
{
|
||||||
if( cache[j].entid == id )
|
if( cache[j].entid == id )
|
||||||
{
|
{
|
||||||
memcpy( &gblset.entry, &cache[i], sizeof(CheatEntry) );
|
memcpy( &gblset.entry, &cache[j], sizeof(CheatEntry) );
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user