]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
68020 cpu speed adjustments, non-prefetch speed adjustment support.
authorToni Wilen <twilen@winuae.net>
Sat, 2 May 2020 18:07:31 +0000 (21:07 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 2 May 2020 18:07:31 +0000 (21:07 +0300)
gencpu.cpp
newcpu.cpp

index 66acbd660587e713bf3351632bef51b07cd1ba97..e2aaa4cf454bd8ede97c9eb135a2f4bc4f482cf6 100644 (file)
@@ -478,8 +478,10 @@ static void check_ipl_always(void)
 
 static void addcycles_020(int cycles)
 {
-       if (using_prefetch_020 || using_ce020) {
+       if (using_ce020) {
                out("%s(%d);\n", do_cycles, cycles);
+       } else if (using_prefetch_020) {
+               out("count_cycles += %d;\n", cycles);
        }
 }
 
@@ -598,8 +600,12 @@ static void returncycles(int cycles)
                int total = count_readl + count_readw + count_writel + count_writew - count_readp;
                if (!total)
                        total++;
-               out("return (%d * CYCLE_UNIT / 2 + count_cycles) | (((%d * 4 * CYCLE_UNIT / 2 + count_cycles) * 3) << 16);\n",
-                       cycles, total);
+               if (using_mmu || using_prefetch_020) {
+                       out("return (%d * 4 * CYCLE_UNIT / 2 + count_cycles) * 4;\n", total);
+               } else {
+                       out("return (%d * CYCLE_UNIT / 2 + count_cycles) | (((%d * 4 * CYCLE_UNIT / 2 + count_cycles) * 4) << 16);\n",
+                               cycles, total);
+               }
        } else if (using_simple_cycles) {
                out("return %d * CYCLE_UNIT / 2 + count_cycles;\n", cycles);
        } else {
@@ -728,6 +734,7 @@ static void addcycles000(int cycles)
        count_cycles += cycles;
        insn_n_cycles += cycles;
 }
+#if 0
 static void addcycles000_2(int cycles)
 {
        if (using_ce) {
@@ -736,7 +743,7 @@ static void addcycles000_2(int cycles)
        count_cycles += cycles;
        insn_n_cycles += cycles;
 }
-
+#endif
 static void addcycles000_3(void)
 {
        if (using_ce) {
@@ -1120,6 +1127,7 @@ static void fill_prefetch_1_empty(int o)
        }
 }
 
+#if 0
 static void fill_prefetch_full_2 (void)
 {
        if (using_prefetch) {
@@ -1138,6 +1146,7 @@ static void fill_prefetch_full_2 (void)
                insn_n_cycles += 4;
        }
 }
+#endif
 
 // don't check trace bits
 static void fill_prefetch_full_ntx(int beopcode)
@@ -1529,6 +1538,7 @@ static void fill_prefetch_next_after(int copy, const char *format, ...)
        }
 }
 
+#if 0
 static void fill_prefetch_next_skipopcode(void)
 {
        if (using_prefetch) {
@@ -1543,7 +1553,7 @@ static void fill_prefetch_next_skipopcode(void)
                insn_n_cycles += 4;
        }
 }
-
+#endif
 
 static void fill_prefetch_next_empty(void)
 {
@@ -9300,7 +9310,7 @@ static void generate_cpu (int id, int mode)
                }
        }
  
-       do_always_dynamic_cycles = !using_simple_cycles && !using_prefetch && !using_prefetch_020 && using_always_dynamic_cycles;
+       do_always_dynamic_cycles = !using_simple_cycles && !using_prefetch && using_always_dynamic_cycles;
 
        if (!using_indirect)
                using_indirect = using_ce || using_ce020 || using_prefetch_020 || id >= 50;
index 8d31f6eeef155cdec99af6eb2f8939451f3518b5..7052c3d13c2da29090e1d9608094972c7b2b5b8d 100644 (file)
@@ -1979,24 +1979,28 @@ static unsigned long cycles_mult;
 static void update_68k_cycles (void)
 {
        cycles_mult = 0;
-       if (currprefs.m68k_speed >= 0 && !currprefs.cpu_cycle_exact && !currprefs.cpu_compatible) {
-               if (currprefs.m68k_speed_throttle < 0) {
-                       cycles_mult = (unsigned long)(CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle));
-               } else if (currprefs.m68k_speed_throttle > 0) {
-                       cycles_mult = (unsigned long)(CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle));
-               }
-       }
-       if (currprefs.m68k_speed == 0) {
+
+       if (currprefs.m68k_speed == 0) { // aproximate
+               cycles_mult = CYCLES_DIV;
                if (currprefs.cpu_model >= 68040) {
-                       if (!cycles_mult)
-                               cycles_mult = CYCLES_DIV / 8;
-                       else
-                               cycles_mult /= 8;
+                       cycles_mult = CYCLES_DIV / 12;
                } else if (currprefs.cpu_model >= 68020) {
-                       if (!cycles_mult)
-                               cycles_mult = CYCLES_DIV / 4;
-                       else
-                               cycles_mult /= 4;
+                       cycles_mult = CYCLES_DIV / 6;
+               }
+               if (!currprefs.cpu_cycle_exact) {
+                       if (currprefs.m68k_speed_throttle < 0) {
+                               cycles_mult = (cycles_mult * 1000) / (1000 + currprefs.m68k_speed_throttle);
+                       } else if (currprefs.m68k_speed_throttle > 0) {
+                               cycles_mult = (cycles_mult * 1000) / (1000 + currprefs.m68k_speed_throttle);
+                       }
+               }
+       } else {
+               if (currprefs.m68k_speed >= 0 && !currprefs.cpu_cycle_exact && !currprefs.cpu_compatible) {
+                       if (currprefs.m68k_speed_throttle < 0) {
+                               cycles_mult = (unsigned long)(CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle));
+                       } else if (currprefs.m68k_speed_throttle > 0) {
+                               cycles_mult = (unsigned long)(CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle));
+                       }
                }
        }
 
@@ -2011,8 +2015,9 @@ static void update_68k_cycles (void)
                } else {
                        cpucycleunit = CYCLE_UNIT * currprefs.cpu_clock_multiplier;
                }
-               if (currprefs.cpu_model >= 68040)
+               if (currprefs.cpu_model >= 68040) {
                        cpucycleunit /= 2;
+               }
        } else if (currprefs.cpu_frequency) {
                cpucycleunit = CYCLE_UNIT * baseclock / currprefs.cpu_frequency;
        } else if (currprefs.cpu_memory_cycle_exact && currprefs.cpu_clock_multiplier == 0) {
@@ -5346,7 +5351,7 @@ static void m68k_run_mmu060 (void)
                                mmu060_state = 1;
 
                                count_instr (regs.opcode);
-                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode) >> 16;
+                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode);
 
                                cpu_cycles = adjust_cycles (cpu_cycles);
                                regs.instruction_cnt++;
@@ -5396,7 +5401,7 @@ static void m68k_run_mmu040 (void)
                                mmu_opcode = -1;
                                mmu_opcode = regs.opcode = x_prefetch (0);
                                count_instr (regs.opcode);
-                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode) >> 16;
+                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode);
                                cpu_cycles = adjust_cycles (cpu_cycles);
                                regs.instruction_cnt++;
 
@@ -5489,7 +5494,7 @@ insretry:
                                                count_instr (regs.opcode);
                                                do_cycles (cpu_cycles);
 
-                                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode) >> 16;
+                                               cpu_cycles = (*cpufunctbl[regs.opcode])(regs.opcode);
 
                                        } else {