]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
STOP update
authorToni Wilen <twilen@winuae.net>
Thu, 12 May 2022 18:57:54 +0000 (21:57 +0300)
committerToni Wilen <twilen@winuae.net>
Thu, 12 May 2022 18:57:54 +0000 (21:57 +0300)
gencpu.cpp
newcpu.cpp

index 7fcf8a0d9c8e88932ad1e72e7d00524e1fa23056..78e9fde8a26779feae24b57ba9b1782b4a11e345 100644 (file)
@@ -6669,9 +6669,6 @@ static void gen_opcode (unsigned int opcode)
                // 68000/68010: Traced STOP runs 4 cycles faster.
                // 68020 68030 68040: STOP works normally
                // 68060: Immediate privilege violation exception
-               if ((cpu_level == 0 || cpu_level == 1) && using_ce) {
-                       out("%s(regs.t1 ? 4 : 8);\n", do_cycles);
-               }
                if (cpu_level >= 5) {
                        out("if (!(sr & 0x2000)) {\n");
                        out("Exception(8);\n");
@@ -6681,6 +6678,9 @@ static void gen_opcode (unsigned int opcode)
                out("regs.sr = sr;\n");
                makefromsr();
                out("m68k_setstopped();\n");
+               if ((cpu_level == 0 || cpu_level == 1) && (using_ce || using_prefetch)) {
+                       out("%s(4);\n", do_cycles);
+               }
                sync_m68k_pc();
                // STOP does not prefetch anything
                did_prefetch = -1;
index 2dcdb4ab7c21a11f3db8713697f0efae66237018..89acfc0caed6a1b1563370b704f5bc0815209419 100644 (file)
@@ -4484,17 +4484,19 @@ static int do_specialties (int cycles)
                Exception (3);
        }
 
-       if ((regs.spcflags & SPCFLAG_STOP) && regs.s == 0 && currprefs.cpu_model <= 68010) {
-               // 68000/68010 undocumented special case:
-               // if STOP clears S-bit and T was not set:
-               // cause privilege violation exception, PC pointing to following instruction.
-               // If T was set before STOP: STOP works as documented.
-               m68k_unset_stop();
-               Exception(8);
-       }
-
        bool first = true;
        while (regs.spcflags & SPCFLAG_STOP) {
+
+               if (regs.s == 0 && currprefs.cpu_model <= 68010) {
+                       // 68000/68010 undocumented special case:
+                       // if STOP clears S-bit and T was not set:
+                       // cause privilege violation exception, PC pointing to following instruction.
+                       // If T was set before STOP: STOP works as documented.
+                       m68k_unset_stop();
+                       Exception(8);
+                       break;
+               }
+
        isstopped:
                check_uae_int_request();
                {
@@ -4515,11 +4517,12 @@ static int do_specialties (int cycles)
 
                if (m68k_interrupt_delay) {
                        unset_special(SPCFLAG_INT);
-                       if (first) {
-                               ipl_fetch();
-                       }
                        if (time_for_interrupt()) {
-                               x_do_cycles(4 * cpucycleunit);
+                               if (!first) {
+                                       // extra loop because even after higher ipl detection,
+                                       // stop needs to do one more loop before it exits.
+                                       x_do_cycles(4 * cpucycleunit);
+                               }
                                do_interrupt(regs.ipl);
                                break;
                        }
@@ -4544,23 +4547,16 @@ static int do_specialties (int cycles)
                        }
                }
 
-               if (!first) {
-                       if (currprefs.cpu_compatible) {
-                               x_do_cycles(2 * cpucycleunit);
-                               ipl_fetch();
-                               x_do_cycles(2 * cpucycleunit);
-                       } else {
-                               x_do_cycles(4 * cpucycleunit);
-                               ipl_fetch();
-                       }
-               }
                first = false;
+               ipl_fetch();
+               x_do_cycles(4 * cpucycleunit);
 
                if (regs.spcflags & SPCFLAG_COPPER)
                        do_copper();
 
                if (regs.spcflags & SPCFLAG_MODE_CHANGE) {
                        m68k_resumestopped();
+                       fill_prefetch();
                        return 1;
                }
 
@@ -7634,18 +7630,14 @@ void m68k_setstopped (void)
        if ((regs.spcflags & SPCFLAG_DOTRACE) == 0) {
                m68k_set_stop();
        } else {
-               m68k_resumestopped ();
+               m68k_resumestopped();
        }
 }
 
-void m68k_resumestopped (void)
+void m68k_resumestopped(void)
 {
        if (!regs.stopped)
                return;
-       if (currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000) {
-               x_do_cycles (6 * cpucycleunit);
-       }
-       fill_prefetch ();
        m68k_unset_stop();
 }