}
//New timer based code stuffola...
-void ScanlineCallback(void);
+void HalflineCallback(void);
void RenderCallback(void);
void JaguarReset(void)
{
// New timer base code stuffola...
InitializeEventList();
// SetCallbackTime(ScanlineCallback, 63.5555);
- SetCallbackTime(ScanlineCallback, 31.77775);
-// SetCallbackTime(RenderCallback, 33303.082); // # Scanlines * scanline time
-// SetCallbackTime(RenderCallback, 16651.541); // # Scanlines * scanline time
+// SetCallbackTime(ScanlineCallback, 31.77775);
+ SetCallbackTime(HalflineCallback, (vjs.hardwareTypeNTSC ? 31.777777777 : 32.0));
}
void JaguarDone(void)
JaguarDasm(0x802000, 6000);
WriteLog("\n");//*/
#endif
-/* WriteLog("\n\nM68000 disassembly at $802000...\n");
- JaguarDasm(0x802000, 10000);
+/* WriteLog("\n\nM68000 disassembly at $4000...\n");
+ JaguarDasm(0x4000, 10000);
WriteLog("\n");//*/
}
//seem to indicate the refresh rate is *half* the above...
// uint16 refreshRate = (vjs.hardwareTypeNTSC ? 30 : 25);
// Should these be hardwired or read from VP? Yes, from VP!
+ // Err, actually, they should be hardwired, and hardwired to a set # of
+ // lines as well...
uint32 M68KCyclesPerScanline = m68kClockRate / (vp * refreshRate);
uint32 RISCCyclesPerScanline = m68kClockRate / (vp * refreshRate);
//if (start_logging)
// WriteLog("About to execute OP (%u)...\n", i);
- TOMExecScanline(i, render);
+ TOMExecHalfline(i, render);
}
}
while (!frameDone);
}
-void ScanlineCallback(void)
+#define USE_CORRECT_PAL_TIMINGS
+// A lot of confusion comes from here...
+// The thing to keep in mind is that the VC is advanced every HALF line, regardless
+// of whether the display is interlaced or not. The only difference with an
+// interlaced display is that the high bit of VC will be set when the lower
+// field is being rendered.
+//
+// Normally, TVs will render a full frame in 1/30s (NTSC) or 1/25s (PAL) by
+// rendering two fields that are slighty vertically offset from each other.
+// Each field is created in 1/60s (NTSC) or 1/50s (PAL), and every other line
+// is rendered in this mode so that each field, when overlaid on each other,
+// will yield the final picture at the full resolution for the full frame.
+//
+// We execute a half frame in each timeslice (1/60s NTSC, 1/50s PAL).
+// Since the number of lines in a FULL frame is 525 for NTSC, 625 for PAL,
+// it will be half this number for a half frame. BUT, since we're counting
+// HALF lines, we double this number and we're back at 525 for NTSC, 625 for PAL.
+//
+// Scanline times are 63.5555... µs in NTSC and 64 µs in PAL
+// Half line times are, naturally, half of this. :-P
+void HalflineCallback(void)
{
+//OK, this is hardwired to run in NTSC, and for who knows how long.
+//Need to fix this so that it does a half-line in the correct amount of time
+//and number of lines, depending on which mode we're in. [FIXED]
uint16 vc = TOMReadWord(0xF00006, JAGUAR);
uint16 vp = TOMReadWord(0xF0003E, JAGUAR) + 1;
uint16 vi = TOMReadWord(0xF0004E, JAGUAR);
// uint16 vbb = TOMReadWord(0xF00040, JAGUAR);
vc++;
+#ifdef USE_CORRECT_PAL_TIMINGS
+ // Each # of lines is for a full frame == 1/30s (NTSC), 1/25s (PAL).
+ // So we cut the number of half-lines in a frame in half. :-P
+ uint16 numHalfLines = ((vjs.hardwareTypeNTSC ? 525 : 625) * 2) / 2;
+
+ if (vc >= numHalfLines)
+#else
if (vc >= vp)
+#endif
vc = 0;
//WriteLog("SLC: Currently on line %u (VP=%u)...\n", vc, vp);
m68k_set_irq(2);
}
- TOMExecScanline(vc, true);
+ TOMExecHalfline(vc, true);
//Change this to VBB???
//Doesn't seem to matter (at least for Flip Out & I-War)
frameDone = true;
}//*/
-// SetCallbackTime(ScanlineCallback, 63.5555);
- SetCallbackTime(ScanlineCallback, 31.77775);
+#ifdef USE_CORRECT_PAL_TIMINGS
+ SetCallbackTime(HalflineCallback, (vjs.hardwareTypeNTSC ? 31.777777777 : 32.0));
+#else
+// SetCallbackTime(HalflineCallback, 63.5555);
+ SetCallbackTime(HalflineCallback, 31.77775);
+#endif
}
// This isn't currently used, but maybe it should be...