Mercurial > audlegacy-plugins
comparison src/console/Spc_Emu.cxx @ 341:986f098da058 trunk
[svn] - merge in blargg's changes
author | nenolod |
---|---|
date | Thu, 07 Dec 2006 15:20:41 -0800 |
parents | eb5d48fcf8ea |
children | c31e94fefd2a |
comparison
equal
deleted
inserted
replaced
340:9e5a7158fa80 | 341:986f098da058 |
---|---|
1 // Game_Music_Emu 0.5.1. http://www.slack.net/~ant/ | 1 // Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ |
2 | 2 |
3 #include "Spc_Emu.h" | 3 #include "Spc_Emu.h" |
4 | 4 |
5 #include "blargg_endian.h" | 5 #include "blargg_endian.h" |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
216 blargg_err_t load_( Data_Reader& in ) | 216 blargg_err_t load_( Data_Reader& in ) |
217 { | 217 { |
218 long file_size = in.remain(); | 218 long file_size = in.remain(); |
219 if ( file_size < Snes_Spc::spc_file_size ) | 219 if ( file_size < Snes_Spc::spc_file_size ) |
220 return gme_wrong_file_type; | 220 return gme_wrong_file_type; |
221 RETURN_ERR( in.read( &header, sizeof header ) ); | 221 RETURN_ERR( in.read( &header, Spc_Emu::header_size ) ); |
222 RETURN_ERR( check_spc_header( header.tag ) ); | 222 RETURN_ERR( check_spc_header( header.tag ) ); |
223 long const xid6_offset = 0x10200; | 223 long const xid6_offset = 0x10200; |
224 long xid6_size = file_size - xid6_offset; | 224 long xid6_size = file_size - xid6_offset; |
225 if ( xid6_size > 0 ) | 225 if ( xid6_size > 0 ) |
226 { | 226 { |
227 RETURN_ERR( xid6.resize( xid6_size ) ); | 227 RETURN_ERR( xid6.resize( xid6_size ) ); |
228 RETURN_ERR( in.skip( xid6_offset - sizeof header ) ); | 228 RETURN_ERR( in.skip( xid6_offset - Spc_Emu::header_size ) ); |
229 RETURN_ERR( in.read( xid6.begin(), xid6.size() ) ); | 229 RETURN_ERR( in.read( xid6.begin(), xid6.size() ) ); |
230 } | 230 } |
231 return 0; | 231 return 0; |
232 } | 232 } |
233 | 233 |
262 apu.mute_voices( m ); | 262 apu.mute_voices( m ); |
263 } | 263 } |
264 | 264 |
265 blargg_err_t Spc_Emu::load_mem_( byte const* in, long size ) | 265 blargg_err_t Spc_Emu::load_mem_( byte const* in, long size ) |
266 { | 266 { |
267 assert( offsetof (header_t,unused2 [46]) == header_size ); | |
267 file_data = in; | 268 file_data = in; |
268 file_size = size; | 269 file_size = size; |
269 set_voice_count( Snes_Spc::voice_count ); | 270 set_voice_count( Snes_Spc::voice_count ); |
270 if ( size < Snes_Spc::spc_file_size ) | 271 if ( size < Snes_Spc::spc_file_size ) |
271 return gme_wrong_file_type; | 272 return gme_wrong_file_type; |
289 { | 290 { |
290 if ( sample_rate() != native_sample_rate ) | 291 if ( sample_rate() != native_sample_rate ) |
291 { | 292 { |
292 count = long (count * resampler.ratio()) & ~1; | 293 count = long (count * resampler.ratio()) & ~1; |
293 count -= resampler.skip_input( count ); | 294 count -= resampler.skip_input( count ); |
294 } | 295 } |
295 | |
296 if ( count > 0 ) | 296 if ( count > 0 ) |
297 RETURN_ERR( apu.skip( count ) ); | 297 RETURN_ERR( apu.skip( count ) ); |
298 | 298 |
299 // eliminate pop due to resampler | 299 // eliminate pop due to resampler |
300 const int resampler_latency = 64; | 300 const int resampler_latency = 64; |