public void FrameAdvance(bool render, bool renderSound) { Frame++; isLag = true; PSG.BeginFrame(Cpu.TotalExecutedCycles); VDP.ExecuteFrame(); PSG.EndFrame(Cpu.TotalExecutedCycles); if (isLag) { LagCount++; } }
public void FrameAdvance(bool render, bool renderSound) { Cpu.Debug = Tracer.Enabled; Frame++; _isLag = true; PSG.BeginFrame(Cpu.TotalExecutedCycles); if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first { Cpu.Logger = (s) => Tracer.Put(s); } VDP.ExecuteFrame(); PSG.EndFrame(Cpu.TotalExecutedCycles); if (_isLag) { _lagCount++; } }
public void FrameAdvance(bool render, bool rendersound) { lagged = true; Frame++; PSG.BeginFrame(SoundCPU.TotalExecutedCycles); YM2612.BeginFrame(SoundCPU.TotalExecutedCycles); // Do start-of-frame events VDP.HIntLineCounter = VDP.Registers[10]; //VDP.VdpStatusWord &= unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalBlanking; } for (VDP.ScanLine = 0; VDP.ScanLine < 262; VDP.ScanLine++) { //Log.Error("VDP","FRAME {0}, SCANLINE {1}", Frame, VDP.ScanLine); if (VDP.ScanLine < VDP.FrameHeight) { VDP.RenderLine(); } Exec68k(365); RunZ80(171); // H-Int now? VDP.HIntLineCounter--; if (VDP.HIntLineCounter < 0 && VDP.ScanLine < 224) // FIXME { VDP.HIntLineCounter = VDP.Registers[10]; VDP.VdpStatusWord |= GenVDP.StatusHorizBlanking; if (VDP.HInterruptsEnabled) { Set68kIrq(4); //Console.WriteLine("Fire hint!"); } } Exec68k(488 - 365); RunZ80(228 - 171); if (VDP.ScanLine == 224) { VDP.VdpStatusWord |= GenVDP.StatusVerticalInterruptPending; VDP.VdpStatusWord |= GenVDP.StatusVerticalBlanking; Exec68k(16); // this is stupidly wrong. // End-frame stuff if (VDP.VInterruptEnabled) { Set68kIrq(6); } SoundCPU.Interrupt = true; //The INT output is asserted every frame for exactly one scanline, and it can't be disabled. A very short Z80 interrupt routine would be triggered multiple times if it finishes within 228 Z80 clock cycles. I think (but cannot recall the specifics) that some games have delay loops in the interrupt handler for this very reason. } } PSG.EndFrame(SoundCPU.TotalExecutedCycles); YM2612.EndFrame(SoundCPU.TotalExecutedCycles); if (lagged) { _lagcount++; islag = true; } else { islag = false; } }