src/musashi/m68kcpu.c

changeset 147
ad888290cdff
parent 118
feee84e0b3bf
     1.1 diff -r fb6a37a266da -r ad888290cdff src/musashi/m68kcpu.c
     1.2 --- a/src/musashi/m68kcpu.c	Wed Apr 16 02:07:24 2014 -0600
     1.3 +++ b/src/musashi/m68kcpu.c	Wed Apr 16 02:20:43 2014 -0600
     1.4 @@ -66,6 +66,9 @@
     1.5  jmp_buf m68ki_address_error_trap;
     1.6  #endif /* M68K_EMULATE_ADDRESS_ERROR */
     1.7  
     1.8 +jmp_buf m68ki_bus_error_jmp_buf;
     1.9 +jmp_buf m68ki_bus_error_return_jmp_buf;
    1.10 +
    1.11  /* Used by shift & rotate instructions */
    1.12  uint8 m68ki_shift_8_table[65] =
    1.13  {
    1.14 @@ -638,9 +641,12 @@
    1.15  		/* Return point if we had an address error */
    1.16  		m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */
    1.17  
    1.18 +		m68ki_check_bus_error_trap();
    1.19 +
    1.20  		/* Main loop.  Keep going until we run out of clock cycles */
    1.21  		do
    1.22  		{
    1.23 +			int i;
    1.24  			/* Set tracing accodring to T1. (T0 is done inside instruction) */
    1.25  			m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */
    1.26  
    1.27 @@ -653,20 +659,16 @@
    1.28  			/* Record previous program counter */
    1.29  			REG_PPC = REG_PC;
    1.30  
    1.31 +			for (i = 15; i >= 0; i--){
    1.32 +				REG_DA_SAVE[i] = REG_DA[i];
    1.33 +			}
    1.34  			/* Read an instruction and call its handler */
    1.35  			REG_IR = m68ki_read_imm_16();
    1.36 -			if (!BUS_ERROR_OCCURRED){
    1.37 -				m68ki_instruction_jump_table[REG_IR]();
    1.38 -			}
    1.39 +			m68ki_instruction_jump_table[REG_IR]();
    1.40  			USE_CYCLES(CYC_INSTRUCTION[REG_IR]);
    1.41 -
    1.42  			/* Trace m68k_exception, if necessary */
    1.43  			m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */
    1.44 -
    1.45 -			if (BUS_ERROR_OCCURRED){
    1.46 -				m68ki_jump_bus_error_vector();
    1.47 -				BUS_ERROR_OCCURRED = 0;
    1.48 -			}
    1.49 +	
    1.50  		} while(GET_CYCLES() > 0);
    1.51  
    1.52  		/* set previous PC to current PC for the next entry into the loop */