]> Shamusworld >> Repos - thunder/blobdiff - src/thunder.cpp
Fixed IRQ/DAA problems. Emulator is now in a stable state. Woo hoo!
[thunder] / src / thunder.cpp
index 5fdd7a88fd114daf1cee260c3d98a5da61b43d49..17ea566f26774da6ad315789ed1df2f5584a855e 100755 (executable)
@@ -310,6 +310,7 @@ uint8 RdMem(uint16 addr)
 //
 void WrMem(uint16 addr, uint8 b)
 {
+       extern bool disasm;
        extern bool charbase;                                                           // Needed for screen. Extern it in it??
   //extern uint16 sr, ur, xr, yr;            // Needed for tracelog
   //extern uint16 pcr;
@@ -362,6 +363,10 @@ void WrMem(uint16 addr, uint8 b)
 //             cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;//wil wok???
                // IRQ Ack (may also be frame go...
 //             cpu1.cpuFlags &= ~V6809_ASSERT_LINE_IRQ;
+#if 1
+       if (disasm)
+               WriteLog("WriteMem: CPU #1 Acknowledging IRQ...\n", b);
+#endif
                ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
        }
 }
@@ -401,6 +406,7 @@ uint8 RdMemB(uint16 addr)
 //
 void WrMemB(uint16 addr, uint8 b)
 {
+       extern bool disasm;
        extern bool charbase;
   //extern uint16 sr, ur, xr, yr;            // Needed for tracelog
   //extern uint16 pcr;
@@ -452,6 +458,10 @@ void WrMemB(uint16 addr, uint8 b)
        {
                // IRQ Ack (may also be frame go...)
 //             cpu2.cpuFlags &= ~V6809_ASSERT_LINE_IRQ;
+#if 1
+       if (disasm)
+               WriteLog("WriteMem: CPU #2 Acknowledging IRQ...\n", b);
+#endif
                ClearLineOfCurrentV6809(V6809_ASSERT_LINE_IRQ);
        }
 }
@@ -1494,7 +1504,7 @@ WriteLog("About to enter main loop...\n");
                                }
                                if (keys[SDLK_d])                               // (D) start disassembly
                                        disasm = true;
-#if 1
+#if 0
        if (keys[SDLK_k])
                gram1[0x5606] = 0x00;
        if (keys[SDLK_l])
@@ -1510,22 +1520,9 @@ WriteLog("About to enter main loop...\n");
 #endif
 
 
-//                             if (enable_cpu)
-                               if (true)
+                               if (enable_cpu)
+//                             if (true)
                                {
-#if 0
-//                                     if (irqGoA)
-                                               cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-
-                                       Execute6809(&cpu1, 25000);
-                                       cpu1.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)
-
-//                                     if (irqGoB)
-                                               cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
-
-                                       Execute6809(&cpu2, 25000);
-                                       cpu2.clock -= 25000;                            // Remove 25K ticks from clock (in case it overflowed)//*/
-#else
                                        // We can do this here because we're not executing the cores yet.
                                        cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
                                        cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
@@ -1533,15 +1530,19 @@ WriteLog("About to enter main loop...\n");
 // 1.538 MHz = 25633.333... cycles per frame (1/60 s)
 // 25600 cycles/frame
 // Setting interleave to 25 and below causes the V6809 core to hang...
+// 32 gets to the title screen before hanging...
 // 40 works, until it doesn't... :-P
+// 640 * 40
+// 800 * 32
+// Interesting, putting IRQs at 30 Hz makes it run at the correct speed. Still hangs in the demo, though.
                                        for(uint32 i=0; i<640; i++)
+//                                     for(uint32 i=0; i<1280; i++)
                                        {
                                                // Gay, but what are ya gonna do?
                                                // There's better ways, such as keeping track of when slave writes to master, etc...
                                                Execute6809(&cpu1, 40);
                                                Execute6809(&cpu2, 40);
                                        }
-#endif
                                } // END: enable_cpu
 
 //        if (refresh_++ == 1)                // 30 Hz...
@@ -1553,11 +1554,13 @@ WriteLog("About to enter main loop...\n");
 //          refresh_ = (refresh2 ? 1 : 0);    // 60/30 Hz...
 //        }
 
+#if 1
 //temp, for testing...
 BlitChar(screen, chr_rom, gram1);
-
+#endif
                                // Speed throttling happens here...
                                while (SDL_GetTicks() - oldTicks < 16)  // Actually, it's 16.66... Need to account for that somehow
+//                             while (SDL_GetTicks() - oldTicks < 32)  // Actually, it's 16.66... Need to account for that somehow
                                        SDL_Delay(1);                           // Release our timeslice...
 
                                oldTicks = SDL_GetTicks();