blargg_err_t track_info_( track_info_t* out, int ) const { get_vgm_length( h, out ); if ( gd3.size() ) parse_gd3( gd3.begin(), gd3.end(), out ); return 0; }
blargg_err_t load_( Data_Reader& in ) { int file_size = in.remain(); if ( file_size <= h.size ) return blargg_err_file_type; RETURN_ERR( in.read( &h, h.size ) ); if ( !h.valid_tag() ) return blargg_err_file_type; int gd3_offset = get_le32( h.gd3_offset ) - 0x2C; int remain = file_size - h.size - gd3_offset; byte gd3_h [gd3_header_size]; if ( gd3_offset > 0 && remain >= gd3_header_size ) { RETURN_ERR( in.skip( gd3_offset ) ); RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) ); int gd3_size = check_gd3_header( gd3_h, remain ); if ( gd3_size ) { RETURN_ERR( gd3.resize( gd3_size ) ); RETURN_ERR( in.read( gd3.begin(), gd3.size() ) ); } } return blargg_ok; }
blargg_err_t load_( Data_Reader& in ) { long file_size = in.remain(); if ( file_size <= Vgm_Emu::header_size ) return gme_wrong_file_type; RETURN_ERR( in.read( &h, Vgm_Emu::header_size ) ); RETURN_ERR( check_vgm_header( h ) ); long gd3_offset = get_le32( h.gd3_offset ) - 0x2C; long remain = file_size - Vgm_Emu::header_size - gd3_offset; byte gd3_h [gd3_header_size]; if ( gd3_offset > 0 && remain >= gd3_header_size ) { RETURN_ERR( in.skip( gd3_offset ) ); RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) ); long gd3_size = check_gd3_header( gd3_h, remain ); if ( gd3_size ) { RETURN_ERR( gd3.resize( gd3_size ) ); RETURN_ERR( in.read( gd3.begin(), gd3.size() ) ); } } return 0; }
blargg_err_t load_( Data_Reader& in ) { int file_size = in.remain(); if ( file_size <= h.size_min ) return blargg_err_file_type; RETURN_ERR( in.read( &h, h.size_min ) ); if ( !h.valid_tag() ) return blargg_err_file_type; if ( h.size() > h.size_min ) RETURN_ERR( in.read( &h.rf5c68_rate, h.size() - h.size_min ) ); h.cleanup(); int data_offset = get_le32( h.data_offset ) + offsetof( Vgm_Core::header_t, data_offset ); int data_size = file_size - offsetof( Vgm_Core::header_t, data_offset ) - data_offset; int gd3_offset = get_le32( h.gd3_offset ); if ( gd3_offset > 0 ) gd3_offset += offsetof( Vgm_Core::header_t, gd3_offset ); int amount_to_skip = gd3_offset - h.size(); if ( gd3_offset > 0 && gd3_offset > data_offset ) { data_size = gd3_offset - data_offset; amount_to_skip = 0; RETURN_ERR( data.resize( data_size ) ); RETURN_ERR( in.skip( data_offset - h.size() ) ); RETURN_ERR( in.read( data.begin(), data_size ) ); } int remain = file_size - gd3_offset; byte gd3_h [gd3_header_size]; if ( gd3_offset > 0 && remain >= gd3_header_size ) { RETURN_ERR( in.skip( amount_to_skip ) ); RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) ); int gd3_size = check_gd3_header( gd3_h, remain ); if ( gd3_size ) { RETURN_ERR( gd3.resize( gd3_size ) ); RETURN_ERR( in.read( gd3.begin(), gd3.size() ) ); } if ( data_offset > gd3_offset ) { RETURN_ERR( data.resize( data_size ) ); RETURN_ERR( in.skip( data_offset - gd3_offset - sizeof gd3_h - gd3.size() ) ); RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) ); } } return (blargg_err_t)blargg_ok; }
blargg_err_t load_( Data_Reader& in ) { long file_size = in.remain(); if ( file_size < Snes_Spc::spc_min_file_size ) return gme_wrong_file_type; RETURN_ERR( in.read( &header, Spc_Emu::header_size ) ); RETURN_ERR( check_spc_header( header.tag ) ); long const xid6_offset = 0x10200; long xid6_size = file_size - xid6_offset; if ( xid6_size > 0 ) { RETURN_ERR( xid6.resize( xid6_size ) ); RETURN_ERR( in.skip( xid6_offset - Spc_Emu::header_size ) ); RETURN_ERR( in.read( xid6.begin(), xid6.size() ) ); } return 0; }
// Read multiple strings and separate into individual strings static blargg_err_t read_strs( Data_Reader& in, int size, blargg_vector<char>& chars, blargg_vector<const char*>& strs ) { RETURN_ERR( chars.resize( size + 1 ) ); chars [size] = 0; // in case last string doesn't have terminator RETURN_ERR( in.read( &chars [0], size ) ); RETURN_ERR( strs.resize( 128 ) ); int count = 0; for ( int i = 0; i < size; i++ ) { if ( (int) strs.size() <= count ) RETURN_ERR( strs.resize( count * 2 ) ); strs [count++] = &chars [i]; while ( i < size && chars [i] ) i++; } return strs.resize( count ); }
blargg_err_t load_( Data_Reader& in ) { int file_size = in.remain(); if ( file_size < Sfm_Emu::sfm_min_file_size ) return blargg_err_file_type; RETURN_ERR( data.resize( file_size ) ); RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) ); RETURN_ERR( check_sfm_header( data.begin() ) ); int metadata_size = get_le32( data.begin() + 4 ); byte temp = data[ 8 + metadata_size ]; data[ 8 + metadata_size ] = '\0'; metadata.parseDocument( (const char *)data.begin() + 8 ); data[ 8 + metadata_size ] = temp; return blargg_ok; }
blargg_err_t hash_( Hash_Function& out ) const { hash_vgm_file( h, data.begin(), data.end() - data.begin(), out ); return (blargg_err_t)blargg_ok; }
blargg_err_t track_info_( track_info_t* out, int ) const { get_spc_info( header, xid6.begin(), xid6.size(), out ); return 0; }
blargg_err_t hash_( Hash_Function& out ) const { hash_sfm_file( data.begin(), data.end() - data.begin(), out ); return blargg_ok; }