Search
lxdream.org :: lxdream/src/sh4/sh4core.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4core.c
changeset 265:5daf59b7f31b
prev260:c82e26ec0cac
next273:48eb3304a41e
author nkeynes
date Wed Jan 10 08:38:02 2007 +0000 (17 years ago)
permissions -rw-r--r--
last change Fix last tile not actually being rendered
file annotate diff log raw
1.1 --- a/src/sh4/sh4core.c Wed Jan 03 09:00:17 2007 +0000
1.2 +++ b/src/sh4/sh4core.c Wed Jan 10 08:38:02 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4core.c,v 1.36 2007-01-03 09:00:17 nkeynes Exp $
1.6 + * $Id: sh4core.c,v 1.37 2007-01-06 04:06:36 nkeynes Exp $
1.7 *
1.8 * SH4 emulation core, and parent module for all the SH4 peripheral
1.9 * modules.
1.10 @@ -58,6 +58,7 @@
1.11 void sh4_stop( void );
1.12 void sh4_save_state( FILE *f );
1.13 int sh4_load_state( FILE *f );
1.14 +static void sh4_accept_interrupt( void );
1.15
1.16 struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,
1.17 NULL, sh4_run_slice, sh4_stop,
1.18 @@ -138,24 +139,43 @@
1.19
1.20 uint32_t sh4_run_slice( uint32_t nanosecs )
1.21 {
1.22 - int target = sh4r.icount + nanosecs / sh4_cpu_period;
1.23 - int start = sh4r.icount;
1.24 int i;
1.25 + sh4r.slice_cycle = 0;
1.26
1.27 if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
1.28 - if( sh4r.int_pending != 0 )
1.29 - sh4r.sh4_state = SH4_STATE_RUNNING;;
1.30 + if( sh4r.event_pending < nanosecs ) {
1.31 + sh4r.sh4_state = SH4_STATE_RUNNING;
1.32 + sh4r.slice_cycle = sh4r.event_pending;
1.33 + }
1.34 }
1.35
1.36 if( sh4_breakpoint_count == 0 ) {
1.37 - for( sh4r.slice_cycle = 0; sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
1.38 + for( ; sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
1.39 + if( SH4_EVENT_PENDING() ) {
1.40 + if( sh4r.event_types & PENDING_EVENT ) {
1.41 + event_execute();
1.42 + }
1.43 + /* Eventq execute may (quite likely) deliver an immediate IRQ */
1.44 + if( sh4r.event_types & PENDING_IRQ ) {
1.45 + sh4_accept_interrupt();
1.46 + }
1.47 + }
1.48 if( !sh4_execute_instruction() ) {
1.49 break;
1.50 }
1.51 }
1.52 } else {
1.53 -
1.54 - for( sh4r.slice_cycle = 0; sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
1.55 + for( ;sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
1.56 + if( SH4_EVENT_PENDING() ) {
1.57 + if( sh4r.event_types & PENDING_EVENT ) {
1.58 + event_execute();
1.59 + }
1.60 + /* Eventq execute may (quite likely) deliver an immediate IRQ */
1.61 + if( sh4r.event_types & PENDING_IRQ ) {
1.62 + sh4_accept_interrupt();
1.63 + }
1.64 + }
1.65 +
1.66 if( !sh4_execute_instruction() )
1.67 break;
1.68 #ifdef ENABLE_DEBUG_MODE
1.69 @@ -444,9 +464,6 @@
1.70 #define FPULf *((float *)&sh4r.fpul)
1.71 #define FPULi (sh4r.fpul)
1.72
1.73 - if( SH4_INT_PENDING() )
1.74 - sh4_accept_interrupt();
1.75 -
1.76 pc = sh4r.pc;
1.77 if( pc > 0xFFFFFF00 ) {
1.78 /* SYSCALL Magic */
.