comparison src/console/Gym_Emu.cxx @ 341:986f098da058 trunk

[svn] - merge in blargg's changes
author nenolod
date Thu, 07 Dec 2006 15:20:41 -0800
parents fb513e10174e
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 "Gym_Emu.h" 3 #include "Gym_Emu.h"
4 4
5 #include "blargg_endian.h" 5 #include "blargg_endian.h"
6 #include <string.h> 6 #include <string.h>
115 if ( size < 4 ) 115 if ( size < 4 )
116 return gme_wrong_file_type; 116 return gme_wrong_file_type;
117 117
118 if ( memcmp( in, "GYMX", 4 ) == 0 ) 118 if ( memcmp( in, "GYMX", 4 ) == 0 )
119 { 119 {
120 if ( size < (long) sizeof (Gym_Emu::header_t) + 1 ) 120 if ( size < Gym_Emu::header_size + 1 )
121 return gme_wrong_file_type; 121 return gme_wrong_file_type;
122 122
123 if ( memcmp( ((Gym_Emu::header_t const*) in)->packed, "\0\0\0\0", 4 ) != 0 ) 123 if ( memcmp( ((Gym_Emu::header_t const*) in)->packed, "\0\0\0\0", 4 ) != 0 )
124 return "Packed GYM file not supported"; 124 return "Packed GYM file not supported";
125 125
126 if ( data_offset ) 126 if ( data_offset )
127 *data_offset = sizeof (Gym_Emu::header_t); 127 *data_offset = Gym_Emu::header_size;
128 } 128 }
129 else if ( *in != 0 && *in != 1 ) 129 else if ( *in > 3 )
130 { 130 {
131 return gme_wrong_file_type; 131 return gme_wrong_file_type;
132 } 132 }
133 133
134 return 0; 134 return 0;
207 apu.output( (mask & 0x80) ? 0 : &blip_buf ); 207 apu.output( (mask & 0x80) ? 0 : &blip_buf );
208 } 208 }
209 209
210 blargg_err_t Gym_Emu::load_mem_( byte const* in, long size ) 210 blargg_err_t Gym_Emu::load_mem_( byte const* in, long size )
211 { 211 {
212 assert( offsetof (header_t,packed [4]) == header_size );
212 int offset = 0; 213 int offset = 0;
213 RETURN_ERR( check_header( in, size, &offset ) ); 214 RETURN_ERR( check_header( in, size, &offset ) );
214 set_voice_count( 8 ); 215 set_voice_count( 8 );
215 216
216 data = in + offset; 217 data = in + offset;