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.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.8 * SH4 emulation core, and parent module for all the SH4 peripheral
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.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.20 uint32_t sh4_run_slice( uint32_t nanosecs )
1.22 - int target = sh4r.icount + nanosecs / sh4_cpu_period;
1.23 - int start = sh4r.icount;
1.25 + sh4r.slice_cycle = 0;
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.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.43 + /* Eventq execute may (quite likely) deliver an immediate IRQ */
1.44 + if( sh4r.event_types & PENDING_IRQ ) {
1.45 + sh4_accept_interrupt();
1.48 if( !sh4_execute_instruction() ) {
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.60 + /* Eventq execute may (quite likely) deliver an immediate IRQ */
1.61 + if( sh4r.event_types & PENDING_IRQ ) {
1.62 + sh4_accept_interrupt();
1.66 if( !sh4_execute_instruction() )
1.68 #ifdef ENABLE_DEBUG_MODE
1.70 #define FPULf *((float *)&sh4r.fpul)
1.71 #define FPULi (sh4r.fpul)
1.73 - if( SH4_INT_PENDING() )
1.74 - sh4_accept_interrupt();
1.77 if( pc > 0xFFFFFF00 ) {