diff --git a/source/arm11/acl.c b/source/arm11/acl.c index f48dc17..a85a0a2 100644 --- a/source/arm11/acl.c +++ b/source/arm11/acl.c @@ -123,12 +123,11 @@ static int32_t bin_search( acl_text_t game ) } int size = ACL_SERIAL_LEN(gblcht.serc); - const char *serials = (char*)malloc( size ); + char *serials = (char*)malloc( size ); if( serials == NULL ){ return -ACHTLIB_NOMEM; } - // TODO uint32_t readed; if( RES_OK != fRead(gblcht.fd, serials, size, &readed) || readed != size ) @@ -140,10 +139,10 @@ static int32_t bin_search( acl_text_t game ) int start = 0, end = gblcht.serc - 1; size = ACL_SERIAL_LEN(1); int found = -1; - while( start < end ) + while( start <= end ) { 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 ) { found = mid; @@ -298,14 +297,14 @@ static acl_error_t load_data() 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; if( total == 0 ) return ACHTLIB_SUCCESS; uint8_t *d = (uint8_t*)malloc( total ); 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; uint32_t readed; @@ -322,7 +321,7 @@ static acl_error_t load_data() #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; 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 ); if( r == ACHTLIB_SUCCESS ) { + found = 1; inst->setid = id; break; } @@ -375,7 +375,7 @@ acl_error_t acl_select_entry( acl_entryid_t id, acl_elemlen_t *count) { if( cache[j].entid == id ) { - memcpy( &gblset.entry, &cache[i], sizeof(CheatEntry) ); + memcpy( &gblset.entry, &cache[j], sizeof(CheatEntry) ); found = 1; break; }