2019-04-16 15:10:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using BizHawk.Common.BufferExtensions;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|
|
|
|
{
|
|
|
|
|
public partial class ChannelF : IEmulator
|
|
|
|
|
{
|
|
|
|
|
public IEmulatorServiceProvider ServiceProvider { get; }
|
|
|
|
|
|
|
|
|
|
public ControllerDefinition ControllerDefinition { get; set; }
|
|
|
|
|
|
|
|
|
|
public string SystemId => "ChannelF";
|
|
|
|
|
|
|
|
|
|
public bool DeterministicEmulation { get; set; }
|
|
|
|
|
|
|
|
|
|
private static double cpuFreq = 1.7897725;
|
|
|
|
|
private static double refreshRate = 60;
|
|
|
|
|
|
|
|
|
|
public int ClockPerFrame;
|
|
|
|
|
public int FrameClock = 0;
|
|
|
|
|
|
|
|
|
|
private void CalcClock()
|
|
|
|
|
{
|
2019-05-08 08:48:01 +00:00
|
|
|
|
var c = ((cpuFreq * 1000000) / refreshRate);
|
2019-04-16 15:10:56 +00:00
|
|
|
|
ClockPerFrame = (int) c;
|
2019-05-08 08:48:01 +00:00
|
|
|
|
|
|
|
|
|
SetupAudio();
|
2019-04-16 15:10:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool FrameAdvance(IController controller, bool render, bool renderSound)
|
|
|
|
|
{
|
2019-05-07 13:43:36 +00:00
|
|
|
|
_controller = controller;
|
|
|
|
|
_isLag = false;
|
|
|
|
|
|
2019-04-17 21:28:12 +00:00
|
|
|
|
if (_tracer.Enabled)
|
|
|
|
|
{
|
|
|
|
|
CPU.TraceCallback = s => _tracer.Put(s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CPU.TraceCallback = null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 13:43:36 +00:00
|
|
|
|
_isLag = PollInput();
|
|
|
|
|
|
2019-04-16 15:10:56 +00:00
|
|
|
|
while (FrameClock++ < ClockPerFrame)
|
|
|
|
|
{
|
|
|
|
|
CPU.ExecuteOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FrameClock = 0;
|
|
|
|
|
_frame++;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _frame;
|
|
|
|
|
private int _lagcount;
|
|
|
|
|
private bool _islag;
|
|
|
|
|
|
|
|
|
|
public void ResetCounters()
|
|
|
|
|
{
|
|
|
|
|
_frame = 0;
|
|
|
|
|
_lagcount = 0;
|
|
|
|
|
_islag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Frame => _frame;
|
|
|
|
|
|
|
|
|
|
public CoreComm CoreComm { get; }
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|