# HG changeset patch # User Nathan Keynes # Date 1305023474 -36000 # Node ID d644413208a3457e02b75233fa4ed87f8db4247a # Parent 9ffc8295b4142979fb2abc7c9b10f10892f29b31 Fix SLEEP issue on timeslice border - Don't update slice_cycle if we're already past it in sh4_sleep_run_slice - Make sure we don't re-enter the main run_slice if we're sleeping --- a/src/sh4/sh4.c Fri Apr 08 08:11:20 2011 +1000 +++ b/src/sh4/sh4.c Tue May 10 20:31:14 2011 +1000 @@ -246,10 +246,6 @@ { sh4r.slice_cycle = 0; - if( sh4r.sh4_state != SH4_STATE_RUNNING ) { - sh4_sleep_run_slice(nanosecs); - } - /* Setup for sudden vm exits */ switch( setjmp(sh4_exit_jmp_buf) ) { case CORE_EXIT_BREAKPOINT: @@ -267,25 +263,28 @@ dreamcast_reset(); break; case CORE_EXIT_SLEEP: - sh4_sleep_run_slice(nanosecs); break; case CORE_EXIT_FLUSH_ICACHE: xlat_flush_cache(); break; } - sh4_running = TRUE; - - /* Execute the core's real slice */ + if( sh4r.sh4_state != SH4_STATE_RUNNING ) { + sh4_sleep_run_slice(nanosecs); + } else { + sh4_running = TRUE; + + /* Execute the core's real slice */ #ifdef SH4_TRANSLATOR - if( sh4_use_translator ) { - sh4_translate_run_slice(nanosecs); - } else { + if( sh4_use_translator ) { + sh4_translate_run_slice(nanosecs); + } else { + sh4_emulate_run_slice(nanosecs); + } +#else sh4_emulate_run_slice(nanosecs); +#endif } -#else - sh4_emulate_run_slice(nanosecs); -#endif /* And finish off the peripherals afterwards */ @@ -621,8 +620,7 @@ */ uint32_t sh4_sleep_run_slice( uint32_t nanosecs ) { - int sleep_state = sh4r.sh4_state; - assert( sleep_state != SH4_STATE_RUNNING ); + assert( sh4r.sh4_state != SH4_STATE_RUNNING ); while( sh4r.event_pending < nanosecs ) { sh4r.slice_cycle = sh4r.event_pending; @@ -634,7 +632,8 @@ return sh4r.slice_cycle; } } - sh4r.slice_cycle = nanosecs; + if( sh4r.slice_cycle < nanosecs ) + sh4r.slice_cycle = nanosecs; return sh4r.slice_cycle; }