Mercurial > audlegacy-plugins
comparison src/console/Nsfe_Emu.cxx @ 341:986f098da058 trunk
[svn] - merge in blargg's changes
author | nenolod |
---|---|
date | Thu, 07 Dec 2006 15:20:41 -0800 |
parents | 31c9d8f37474 |
children | 5abb9030e8a7 |
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 "Nsfe_Emu.h" | 3 #include "Nsfe_Emu.h" |
4 | 4 |
5 #include "blargg_endian.h" | 5 #include "blargg_endian.h" |
6 #include <string.h> | 6 #include <string.h> |
86 byte chip_flags; | 86 byte chip_flags; |
87 byte track_count; | 87 byte track_count; |
88 byte first_track; | 88 byte first_track; |
89 byte unused [6]; | 89 byte unused [6]; |
90 }; | 90 }; |
91 BOOST_STATIC_ASSERT( sizeof (nsfe_info_t) == 16 ); | |
92 | 91 |
93 blargg_err_t Nsfe_Info::load( Data_Reader& in, Nsf_Emu* nsf_emu ) | 92 blargg_err_t Nsfe_Info::load( Data_Reader& in, Nsf_Emu* nsf_emu ) |
94 { | 93 { |
94 int const nsfe_info_size = 16; | |
95 assert( offsetof (nsfe_info_t,unused [6]) == nsfe_info_size ); | |
96 | |
95 // check header | 97 // check header |
96 byte signature [4]; | 98 byte signature [4]; |
97 blargg_err_t err = in.read( signature, sizeof signature ); | 99 blargg_err_t err = in.read( signature, sizeof signature ); |
98 if ( err ) | 100 if ( err ) |
99 return (err == in.eof_error ? gme_wrong_file_type : err); | 101 return (err == in.eof_error ? gme_wrong_file_type : err); |
144 | 146 |
145 nsfe_info_t finfo; | 147 nsfe_info_t finfo; |
146 finfo.track_count = 1; | 148 finfo.track_count = 1; |
147 finfo.first_track = 0; | 149 finfo.first_track = 0; |
148 | 150 |
149 RETURN_ERR( in.read( &finfo, min( size, (blargg_long) sizeof finfo ) ) ); | 151 RETURN_ERR( in.read( &finfo, min( size, (blargg_long) nsfe_info_size ) ) ); |
150 if ( size > (int) sizeof finfo ) | 152 if ( size > nsfe_info_size ) |
151 RETURN_ERR( in.skip( size - sizeof finfo ) ); | 153 RETURN_ERR( in.skip( size - nsfe_info_size ) ); |
152 phase = 1; | 154 phase = 1; |
153 info.speed_flags = finfo.speed_flags; | 155 info.speed_flags = finfo.speed_flags; |
154 info.chip_flags = finfo.chip_flags; | 156 info.chip_flags = finfo.chip_flags; |
155 info.track_count = finfo.track_count; | 157 info.track_count = finfo.track_count; |
156 this->actual_track_count_ = finfo.track_count; | 158 this->actual_track_count_ = finfo.track_count; |
201 break; | 203 break; |
202 | 204 |
203 case BLARGG_4CHAR('A','T','A','D'): { | 205 case BLARGG_4CHAR('A','T','A','D'): { |
204 check( phase == 1 ); | 206 check( phase == 1 ); |
205 phase = 2; | 207 phase = 2; |
206 disable_playlist( false ); | |
207 if ( !nsf_emu ) | 208 if ( !nsf_emu ) |
208 { | 209 { |
209 in.skip( size ); | 210 RETURN_ERR( in.skip( size ) ); |
210 } | 211 } |
211 else | 212 else |
212 { | 213 { |
213 Subset_Reader sub( &in, size ); // limit emu to nsf data | 214 Subset_Reader sub( &in, size ); // limit emu to nsf data |
214 Remaining_Reader rem( &header, sizeof header, &sub ); | 215 Remaining_Reader rem( &header, Nsf_Emu::header_size, &sub ); |
215 RETURN_ERR( nsf_emu->load( rem ) ); | 216 RETURN_ERR( nsf_emu->load( rem ) ); |
216 check( rem.remain() == 0 ); | 217 check( rem.remain() == 0 ); |
217 } | 218 } |
218 disable_playlist( false ); // TODO: fix this crappy hack (unload() disables playlist) | |
219 break; | 219 break; |
220 } | 220 } |
221 | 221 |
222 case BLARGG_4CHAR('D','N','E','N'): | 222 case BLARGG_4CHAR('D','N','E','N'): |
223 check( phase == 2 ); | 223 check( phase == 2 ); |
281 Nsfe_File() { set_type( gme_nsfe_type ); } | 281 Nsfe_File() { set_type( gme_nsfe_type ); } |
282 | 282 |
283 blargg_err_t load_( Data_Reader& in ) | 283 blargg_err_t load_( Data_Reader& in ) |
284 { | 284 { |
285 RETURN_ERR( info.load( in, 0 ) ); | 285 RETURN_ERR( info.load( in, 0 ) ); |
286 info.disable_playlist( false ); | |
286 set_track_count( info.info.track_count ); | 287 set_track_count( info.info.track_count ); |
287 return 0; | 288 return 0; |
288 } | 289 } |
289 | 290 |
290 blargg_err_t track_info_( track_info_t* out, int track ) const | 291 blargg_err_t track_info_( track_info_t* out, int track ) const |