<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src/sh4</tt></b></td></tr>
<tr><td><tt><a href="#file1">sh4.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+16</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-17</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">9ffc8295b414 -> d644413208a3</td></tr>
</table>
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
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
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4.c</b></big> <small id="info" style="color: #888888;" >9ffc8295b414 -> d644413208a3</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4.c
+++ lxdream/src/sh4/sh4.c
@@ -246,10 +246,6 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     sh4r.slice_cycle = 0;
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
-        sh4_sleep_run_slice(nanosecs);
-    }
-
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     /* Setup for sudden vm exits */
     switch( setjmp(sh4_exit_jmp_buf) ) {
     case CORE_EXIT_BREAKPOINT:
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -267,25 +263,28 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         dreamcast_reset();
         break;
     case CORE_EXIT_SLEEP:
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        sh4_sleep_run_slice(nanosecs);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         break;  
     case CORE_EXIT_FLUSH_ICACHE:
         xlat_flush_cache();
         break;
     }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    sh4_running = TRUE;
-    
-    /* Execute the core's real slice */
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
+        sh4_sleep_run_slice(nanosecs);
+    } else {
+        sh4_running = TRUE;
+
+        /* Execute the core's real slice */
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #ifdef SH4_TRANSLATOR
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    if( sh4_use_translator ) {
-        sh4_translate_run_slice(nanosecs);
-    } else {
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        if( sh4_use_translator ) {
+            sh4_translate_run_slice(nanosecs);
+        } else {
+            sh4_emulate_run_slice(nanosecs);
+        }
+#else
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         sh4_emulate_run_slice(nanosecs);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#endif
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-#else
-    sh4_emulate_run_slice(nanosecs);
-#endif
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     
     /* And finish off the peripherals afterwards */
 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -621,8 +620,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  */
 uint32_t sh4_sleep_run_slice( uint32_t nanosecs )
 {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    int sleep_state = sh4r.sh4_state;
-    assert( sleep_state != SH4_STATE_RUNNING );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    assert( sh4r.sh4_state != SH4_STATE_RUNNING );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     while( sh4r.event_pending < nanosecs ) {
         sh4r.slice_cycle = sh4r.event_pending;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -634,7 +632,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             return sh4r.slice_cycle;
         }
     }
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    sh4r.slice_cycle = nanosecs;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    if( sh4r.slice_cycle < nanosecs )
+        sh4r.slice_cycle = nanosecs;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     return sh4r.slice_cycle;
 }
 
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>