-}
-
-//
-// Main Jaguar execution loop (1 frame)
-//
-void JaguarExecute(uint32 * backbuffer, bool render)
-{
- uint16 vp = TOMReadWord(0xF0003E) + 1;
- uint16 vi = TOMReadWord(0xF0004E);
-//Using WO registers is OK, since we're the ones controlling access--there's nothing wrong here! ;-)
-//Though we shouldn't be able to do it using TOMReadWord... !!! FIX !!!
-
-// uint16 vdb = TOMReadWord(0xF00046);
-//Note: This is the *definite* end of the display, though VDE *might* be less than this...
-// uint16 vbb = TOMReadWord(0xF00040);
-//It seems that they mean it when they say that VDE is the end of object processing.
-//However, we need to be able to tell the OP (or TOM) that we've reached the end of the
-//buffer and not to write any more pixels... !!! FIX !!!
-// uint16 vde = TOMReadWord(0xF00048);
-
- uint16 refreshRate = (vjs.hardwareTypeNTSC ? 60 : 50);
- uint32 m68kClockRate = (vjs.hardwareTypeNTSC ? M68K_CLOCK_RATE_NTSC : M68K_CLOCK_RATE_PAL);
-//Not sure the above is correct, since the number of lines and timings given in the JTRM
-//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!
- uint32 M68KCyclesPerScanline = m68kClockRate / (vp * refreshRate);
- uint32 RISCCyclesPerScanline = m68kClockRate / (vp * refreshRate);
-
- TOMResetBackbuffer(backbuffer);
-/*extern int effect_start;
-if (effect_start)
- WriteLog("JagExe: VP=%u, VI=%u, CPU CPS=%u, GPU CPS=%u\n", vp, vi, M68KCyclesPerScanline, RISCCyclesPerScanline);//*/
-
-//extern int start_logging;
- for(uint16 i=0; i<vp; i++)
- {
- // Increment the horizontal count (why? RNG? Besides which, this is *NOT* cycle accurate!)
- TOMWriteWord(0xF00004, (TOMReadWord(0xF00004) + 1) & 0x7FF);
-
- TOMWriteWord(0xF00006, i); // Write the VC
-
-// if (i == vi) // Time for Vertical Interrupt?
-//Not sure if this is correct...
-//Seems to be, kinda. According to the JTRM, this should only fire on odd lines in non-interlace mode...
-//Which means that it normally wouldn't go when it's zero.
- if (i == vi && i > 0 && TOMIRQEnabled(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...
- TOMSetPendingVideoInt();
- m68k_set_irq(7);
- }
-
-//if (start_logging)
-// WriteLog("About to execute M68K (%u)...\n", i);
- m68k_execute(M68KCyclesPerScanline);
-//if (start_logging)
-// WriteLog("About to execute TOM's PIT (%u)...\n", i);
- TOMExecPIT(RISCCyclesPerScanline);
-//if (start_logging)
-// WriteLog("About to execute JERRY's PIT (%u)...\n", i);
- JERRYExecPIT(RISCCyclesPerScanline);
-//if (start_logging)
-// WriteLog("About to execute JERRY's SSI (%u)...\n", i);
- JERRYI2SExec(RISCCyclesPerScanline);
- BUTCHExec(RISCCyclesPerScanline);
-//if (start_logging)
-// WriteLog("About to execute GPU (%u)...\n", i);
- GPUExec(RISCCyclesPerScanline);
-
- if (vjs.DSPEnabled)
- {
- if (vjs.usePipelinedDSP)
- DSPExecP2(RISCCyclesPerScanline); // Pipelined DSP execution (3 stage)...
- else
- DSPExec(RISCCyclesPerScanline); // Ordinary non-pipelined DSP
-// DSPExecComp(RISCCyclesPerScanline); // Comparison core
- }