--- uae/src/newcpu.c 2018/04/24 17:03:49 1.1.1.16 +++ uae/src/newcpu.c 2018/04/24 17:07:17 1.1.1.18 @@ -22,6 +22,7 @@ #include "compiler.h" #include "gui.h" #include "savestate.h" +#include "blitter.h" /* Opcode of faulting instruction */ uae_u16 last_op_for_exception_3; @@ -750,7 +751,7 @@ kludge_me_do: unset_special (SPCFLAG_TRACE | SPCFLAG_DOTRACE); } -static void Interrupt(int nr) +static void Interrupt (int nr) { assert(nr < 8 && nr >= 0); lastint_regs = regs; @@ -1150,14 +1151,14 @@ unsigned long REGPARAM2 op_illg (uae_u32 ersatz_perform (arg); fill_prefetch_0 (); return 4; - } else if ((pc & 0xF80000) == 0xF00000) { + } else if ((pc & 0xFFFF0000) == RTAREA_BASE) { /* User-mode STOP replacement */ m68k_setstopped (1); return 4; } } - if ((opcode & 0xF000) == 0xA000 && (pc & 0xF80000) == 0xF00000) { + if ((opcode & 0xF000) == 0xA000 && (pc & 0xFFFF0000) == RTAREA_BASE) { /* Calltrap. */ m68k_incpc(2); call_calltrap (opcode & 0xFFF); @@ -1170,7 +1171,7 @@ unsigned long REGPARAM2 op_illg (uae_u32 return 4; } if ((opcode & 0xF000) == 0xA000) { - if ((pc & 0xF80000) == 0xF00000) { + if ((pc & 0xFFFF0000) == RTAREA_BASE) { /* Calltrap. */ call_calltrap (opcode & 0xFFF); } @@ -1236,7 +1237,6 @@ static void do_trace (void) } } - static int do_specialties (void) { if (regs.spcflags & SPCFLAG_COPPER) @@ -1244,7 +1244,10 @@ static int do_specialties (void) /*n_spcinsns++;*/ while (regs.spcflags & SPCFLAG_BLTNASTY) { - do_cycles (4 * CYCLE_UNIT); + int c = blitnasty(); + if (!c) + break; + do_cycles (c * CYCLE_UNIT); if (regs.spcflags & SPCFLAG_COPPER) do_copper (); } @@ -1302,7 +1305,7 @@ static void m68k_run_1 (void) uae_u32 opcode = get_iword_prefetch (0); #ifdef DEBUG_PREFETCH if (get_ilong (0) != do_get_mem_long (®s.prefetch)) { - fprintf (stderr, "Prefetch differs from memory.\n"); + write_log ("Prefetch differs from memory.\n"); debugging = 1; return; } @@ -1327,7 +1330,7 @@ static void m68k_run_1 (void) #endif #ifdef DEBUG_PREFETCH if (memcmp (saved_bytes, oldpcp, 20) != 0) { - fprintf (stderr, "Self-modifying code detected.\n"); + write_log ("Self-modifying code detected.\n"); set_special (SPCFLAG_BRK); debugging = 1; } @@ -1409,12 +1412,20 @@ void m68k_go (int may_quit) if (quit_program == 1) break; quit_program = 0; + if (savestate_state == STATE_RESTORE) { + restore_state (savestate_filename); +#if 0 + activate_debugger (); +#endif + } m68k_reset (); reset_all_systems (); customreset (); /* We may have been restoring state, but we're done now. */ savestate_restore_finish (); handle_active_events (); + if (regs.spcflags) + do_specialties (); } if (debugging) @@ -1581,14 +1592,19 @@ uae_u8 *restore_cpu (uae_u8 *src) for (i = 0; i < 15; i++) regs.regs[i] = restore_u32 (); regs.pc = restore_u32 (); + /* We don't actually use this - we deliberately set prefetch_pc to a + zero so that prefetch isn't used for the first insn after a state + restore. */ regs.prefetch = restore_u32 (); + regs.prefetch_pc = regs.pc + 128; regs.usp = restore_u32 (); regs.isp = restore_u32 (); regs.sr = restore_u16 (); l = restore_u32(); - if (l & CPUMODE_HALT) + if (l & CPUMODE_HALT) { regs.stopped = 1; - else + set_special (SPCFLAG_STOP); + } else regs.stopped = 0; if (model >= 68010) { regs.dfc = restore_u32 ();