Fixed 2SF and USF to read emulator setup tags from nested library files for playback

CQTexperiment
Chris Moeller 2014-02-26 16:37:56 -08:00
parent 2c2f5b18c9
commit 5f88c6d882
3 changed files with 15 additions and 13 deletions

View File

@ -63,6 +63,7 @@ typedef struct psf_load_state
psf_info_callback info_target;
void * info_context;
int info_want_nested_tags;
char lib_name_temp[32];
} psf_load_state;
@ -70,7 +71,7 @@ typedef struct psf_load_state
static int psf_load_internal( psf_load_state * state, const char * file_name );
int psf_load( const char * uri, const psf_file_callbacks * file_callbacks, uint8_t allowed_version,
psf_load_callback load_target, void * load_context, psf_info_callback info_target, void * info_context )
psf_load_callback load_target, void * load_context, psf_info_callback info_target, void * info_context, int info_want_nested_tags )
{
int rval;
@ -88,6 +89,7 @@ int psf_load( const char * uri, const psf_file_callbacks * file_callbacks, uint8
state.load_context = load_context;
state.info_target = info_target;
state.info_context = info_context;
state.info_want_nested_tags = info_want_nested_tags;
state.base_path = strdup( uri );
if ( !state.base_path ) return -1;
@ -426,7 +428,7 @@ static int psf_load_internal( psf_load_state * state, const char * file_name )
free( tag_buffer );
tag_buffer = NULL;
if ( tags && state->info_target && state->depth == 1 )
if ( tags && state->info_target && ( state->depth == 1 || state->info_want_nested_tags ) )
{
tag = tags;
while ( tag->next ) tag = tag->next;

View File

@ -62,7 +62,7 @@ typedef int (* psf_info_callback)(void * context, const char * name, const char
* Returns negative on error, PSF version on success.
*/
int psf_load( const char * uri, const psf_file_callbacks * file_callbacks, uint8_t allowed_version,
psf_load_callback load_target, void * load_context, psf_info_callback info_target, void * info_context );
psf_load_callback load_target, void * load_context, psf_info_callback info_target, void * info_context, int info_want_nested_tags );
#ifdef __cplusplus
}

View File

@ -946,7 +946,7 @@ static int usf_info(void * context, const char * name, const char * value)
state.first = true;
state.refresh = 0;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 1, psf1_loader, &state, psf1_info, &state ) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 1, psf1_loader, &state, psf1_info, &state, 0 ) <= 0 )
return NO;
if ( state.refresh )
@ -962,7 +962,7 @@ static int usf_info(void * context, const char * name, const char * value)
state.refresh = 0;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 2, psf2fs_load_callback, emulatorExtra, psf1_info, &state ) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 2, psf2fs_load_callback, emulatorExtra, psf1_info, &state, 0 ) <= 0 )
return NO;
emulatorCore = ( uint8_t * ) malloc( psx_get_state_size( 2 ) );
@ -981,7 +981,7 @@ static int usf_info(void * context, const char * name, const char * value)
struct sdsf_loader_state state;
memset( &state, 0, sizeof(state) );
if ( psf_load( [currentUrl UTF8String], &source_callbacks, type, sdsf_loader, &state, 0, 0) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, type, sdsf_loader, &state, 0, 0, 0 ) <= 0 )
return NO;
emulatorCore = ( uint8_t * ) malloc( sega_get_state_size( type - 0x10 ) );
@ -1016,7 +1016,7 @@ static int usf_info(void * context, const char * name, const char * value)
emulatorCore = ( uint8_t * ) state.emu_state;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x21, usf_loader, &state, usf_info, &state ) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x21, usf_loader, &state, usf_info, &state, 1 ) <= 0 )
return NO;
usf_set_compare( state.emu_state, state.enablecompare );
@ -1034,7 +1034,7 @@ static int usf_info(void * context, const char * name, const char * value)
struct gsf_loader_state state;
memset( &state, 0, sizeof(state) );
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x22, gsf_loader, &state, 0, 0 ) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x22, gsf_loader, &state, 0, 0, 0 ) <= 0 )
return NO;
if ( state.data_size > UINT_MAX )
@ -1066,7 +1066,7 @@ static int usf_info(void * context, const char * name, const char * value)
memset( &state, 0, sizeof(state) );
state.initial_frames = -1;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x24, twosf_loader, &state, twosf_info, &state) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x24, twosf_loader, &state, twosf_info, &state, 1 ) <= 0 )
{
if (state.rom) free(state.rom);
if (state.state) free(state.state);
@ -1123,7 +1123,7 @@ static int usf_info(void * context, const char * name, const char * value)
{
struct ncsf_loader_state * state = new struct ncsf_loader_state;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x25, ncsf_loader, state, 0, 0) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x25, ncsf_loader, state, 0, 0, 0 ) <= 0 )
{
delete state;
return NO;
@ -1155,7 +1155,7 @@ static int usf_info(void * context, const char * name, const char * value)
emulatorExtra = state;
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x41, qsf_loader, state, 0, 0) <= 0 )
if ( psf_load( [currentUrl UTF8String], &source_callbacks, 0x41, qsf_loader, state, 0, 0, 0 ) <= 0 )
return NO;
emulatorCore = ( uint8_t * ) malloc( qsound_get_state_size() );
@ -1217,7 +1217,7 @@ static int usf_info(void * context, const char * name, const char * value)
[[psf_file_container instance] add_hint:currentUrl source:currentSource];
type = psf_load( [currentUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info );
type = psf_load( [currentUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info, 0 );
if (type <= 0)
return NO;
@ -1643,7 +1643,7 @@ static int usf_info(void * context, const char * name, const char * value)
NSString * decodedUrl = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if ( psf_load( [decodedUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info ) <= 0)
if ( psf_load( [decodedUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info, 0 ) <= 0)
return NO;
return info.info;