Mercurial > audlegacy-plugins
diff src/console/Hes_Emu.cxx @ 341:986f098da058 trunk
[svn] - merge in blargg's changes
author | nenolod |
---|---|
date | Thu, 07 Dec 2006 15:20:41 -0800 |
parents | 230decbfe9be |
children | 5abb9030e8a7 |
line wrap: on
line diff
--- a/src/console/Hes_Emu.cxx Wed Dec 06 07:57:05 2006 -0800 +++ b/src/console/Hes_Emu.cxx Thu Dec 07 15:20:41 2006 -0800 @@ -1,4 +1,4 @@ -// Game_Music_Emu 0.5.1. http://www.slack.net/~ant/ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ #include "Hes_Emu.h" @@ -105,8 +105,8 @@ struct Hes_File : Gme_Info_ { - struct { - Hes_Emu::header_t h; + struct header_t { + char header [Hes_Emu::header_size]; char unused [0x20]; byte fields [0x30 * 3]; } h; @@ -115,6 +115,7 @@ blargg_err_t load_( Data_Reader& in ) { + assert( offsetof (header_t,fields) == Hes_Emu::header_size + 0x20 ); blargg_err_t err = in.read( &h, sizeof h ); if ( err ) return (err == in.eof_error ? gme_wrong_file_type : err); @@ -137,7 +138,8 @@ blargg_err_t Hes_Emu::load_( Data_Reader& in ) { - RETURN_ERR( rom.load( in, sizeof header_, &header_, unmapped ) ); + assert( offsetof (header_t,unused [4]) == header_size ); + RETURN_ERR( rom.load( in, header_size, &header_, unmapped ) ); RETURN_ERR( check_hes_header( header_.tag ) ); @@ -243,6 +245,7 @@ r.a = track; recalc_timer_load(); + last_frame_hook = 0; return 0; } @@ -282,6 +285,7 @@ { if ( unsigned (addr - apu.start_addr) <= apu.end_addr - apu.start_addr ) { + GME_APU_HOOK( this, addr - apu.start_addr, data ); // avoid going way past end when a long block xfer is writing to I/O space hes_time_t t = min( time(), end_time() + 8 ); apu.write_data( t, addr, data ); @@ -458,6 +462,17 @@ timer.fired = true; irq.timer = future_hes_time; irq_changed(); // overkill, but not worth writing custom code + #if GME_FRAME_HOOK_DEFINED + { + unsigned const threshold = period_60hz / 30; + unsigned long elapsed = present - last_frame_hook; + if ( elapsed - period_60hz + threshold / 2 < threshold ) + { + last_frame_hook = present; + GME_FRAME_HOOK( this ); + } + } + #endif return 0x0A; } @@ -467,6 +482,10 @@ //run_until( present ); //irq.vdp = future_hes_time; //irq_changed(); + #if GME_FRAME_HOOK_DEFINED + last_frame_hook = present; + GME_FRAME_HOOK( this ); + #endif return 0x08; } } @@ -498,6 +517,9 @@ // end time frame timer.last_time -= duration; vdp.next_vbl -= duration; + #if GME_FRAME_HOOK_DEFINED + last_frame_hook -= duration; + #endif cpu::end_frame( duration ); ::adjust_time( irq.timer, duration ); ::adjust_time( irq.vdp, duration );