]> Shamusworld >> Repos - virtualjaguar/commitdiff
Made JaguarExecuteNew play nice with the GUI code
authorShamus Hammons <jlhamm@acm.org>
Sat, 13 Aug 2005 03:31:39 +0000 (03:31 +0000)
committerShamus Hammons <jlhamm@acm.org>
Sat, 13 Aug 2005 03:31:39 +0000 (03:31 +0000)
src/jaguar.cpp

index d2817df12e65bd301980ee76bbd4bece70037121..494dacf1f0b3eb059502f8d74fbd37d77f29c5c4 100644 (file)
@@ -1276,6 +1276,8 @@ uint8 * GetRamPtr(void)
 // New Jaguar execution stack
 //
 
+#if 0
+
 void JaguarExecuteNew(void)
 {
        extern bool finished, showGUI;
@@ -1361,6 +1363,98 @@ joystick_exec();
        SetCallbackTime(ScanlineCallback, 31.77775);
 }
 
+#else
+
+bool frameDone;
+void JaguarExecuteNew(void)
+{
+//     extern bool finished, showGUI;
+//     extern bool debounceRunKey;
+       // Pass a message to the "joystick" code to debounce the ESC key...
+//     debounceRunKey = true;
+//     finished = false;
+/*     InitializeEventList();
+       TOMResetBackbuffer(backbuffer);
+//     SetCallbackTime(ScanlineCallback, 63.5555);
+       SetCallbackTime(ScanlineCallback, 31.77775);
+//     SetCallbackTime(RenderCallback, 33303.082);     // # Scanlines * scanline time
+//     SetCallbackTime(RenderCallback, 16651.541);     // # Scanlines * scanline time//*/
+//     uint8 * keystate = SDL_GetKeyState(NULL);
+       frameDone = false;
+
+       do
+       {
+               double timeToNextEvent = GetTimeToNextEvent();
+//WriteLog("JEN: Time to next event (%u) is %f usec (%u RISC cycles)...\n", nextEvent, timeToNextEvent, USEC_TO_RISC_CYCLES(timeToNextEvent));
+
+               m68k_execute(USEC_TO_M68K_CYCLES(timeToNextEvent));
+               gpu_exec(USEC_TO_RISC_CYCLES(timeToNextEvent));
+
+               if (vjs.DSPEnabled)
+               {
+                       if (vjs.usePipelinedDSP)
+                               DSPExecP2(USEC_TO_RISC_CYCLES(timeToNextEvent));        // Pipelined DSP execution (3 stage)...
+                       else
+                               DSPExec(USEC_TO_RISC_CYCLES(timeToNextEvent));          // Ordinary non-pipelined DSP
+               }
+
+               HandleNextEvent();
+
+//             if (keystate[SDLK_ESCAPE])
+//                     break;
+
+//         SDL_PumpEvents();   // Needed to keep the keystate current...
+       }
+       while (!frameDone);
+}
+
+void ScanlineCallback(void)
+{
+       uint16 vc = TOMReadWord(0xF00006);
+       uint16 vp = TOMReadWord(0xF0003E) + 1;
+       uint16 vi = TOMReadWord(0xF0004E);
+//     uint16 vbb = TOMReadWord(0xF00040);
+       vc++;
+
+       if (vc >= vp)
+               vc = 0;
+
+//WriteLog("SLC: Currently on line %u (VP=%u)...\n", vc, vp);
+       TOMWriteWord(0xF00006, vc);
+
+//This is a crappy kludge, but maybe it'll work for now...
+//Maybe it's not so bad, since the IRQ happens on a scanline boundary...
+       if (vc == vi && vc > 0 && tom_irq_enabled(IRQ_VBLANK))  // Time for Vertical Interrupt?
+       {
+               // We don't have to worry about autovectors & whatnot because the Jaguar
+               // tells you through its HW registers who sent the interrupt...
+               tom_set_pending_video_int();
+               m68k_set_irq(7);
+       }
+
+       TOMExecScanline(vc, true);
+
+//Change this to VBB???
+//Doesn't seem to matter (at least for Flip Out & I-War)
+       if (vc == 0)
+//     if (vc == vbb)
+       {
+               joystick_exec();
+               RenderBackbuffer();
+               TOMResetBackbuffer(backbuffer);
+               frameDone = true;
+       }//*/
+
+//     if (vc == 0)
+//             TOMResetBackbuffer(backbuffer);
+
+//     SetCallbackTime(ScanlineCallback, 63.5555);
+       SetCallbackTime(ScanlineCallback, 31.77775);
+}
+
+#endif
+
+// This isn't currently used, but maybe it should be...
 void RenderCallback(void)
 {
        RenderBackbuffer();