2016-02-28 17:01:12 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class SMS : IEmulator
|
|
|
|
|
{
|
2017-05-08 16:42:22 +00:00
|
|
|
|
public IEmulatorServiceProvider ServiceProvider { get; }
|
2016-02-28 17:01:12 +00:00
|
|
|
|
|
|
|
|
|
public ControllerDefinition ControllerDefinition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (IsGameGear)
|
|
|
|
|
{
|
|
|
|
|
return GGController;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SmsController;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 01:09:11 +00:00
|
|
|
|
public void FrameAdvance(IController controller, bool render, bool rendersound)
|
2016-02-28 17:01:12 +00:00
|
|
|
|
{
|
2017-05-02 01:09:11 +00:00
|
|
|
|
_controller = controller;
|
2016-02-28 17:01:12 +00:00
|
|
|
|
_lagged = true;
|
2017-05-08 16:42:22 +00:00
|
|
|
|
_frame++;
|
2016-02-28 17:01:12 +00:00
|
|
|
|
PSG.BeginFrame(Cpu.TotalExecutedCycles);
|
|
|
|
|
Cpu.Debug = Tracer.Enabled;
|
|
|
|
|
if (!IsGameGear)
|
|
|
|
|
{
|
|
|
|
|
PSG.StereoPanning = Settings.ForceStereoSeparation ? ForceStereoByte : (byte)0xFF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first
|
|
|
|
|
{
|
2017-05-08 16:42:22 +00:00
|
|
|
|
Cpu.Logger = s => Tracer.Put(s);
|
2016-02-28 17:01:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsGameGear == false)
|
|
|
|
|
{
|
2017-05-02 01:09:11 +00:00
|
|
|
|
Cpu.NonMaskableInterrupt = controller.IsPressed("Pause");
|
2016-02-28 17:01:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsGame3D && Settings.Fix3D)
|
|
|
|
|
{
|
|
|
|
|
Vdp.ExecFrame((Frame & 1) == 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Vdp.ExecFrame(render);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PSG.EndFrame(Cpu.TotalExecutedCycles);
|
|
|
|
|
if (_lagged)
|
|
|
|
|
{
|
|
|
|
|
_lagCount++;
|
|
|
|
|
_isLag = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_isLag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 16:42:22 +00:00
|
|
|
|
public int Frame => _frame;
|
2016-02-28 17:01:12 +00:00
|
|
|
|
|
2017-05-08 16:42:22 +00:00
|
|
|
|
public string SystemId => "SMS";
|
|
|
|
|
|
|
|
|
|
public bool DeterministicEmulation => true;
|
2016-02-28 17:01:12 +00:00
|
|
|
|
|
|
|
|
|
public void ResetCounters()
|
|
|
|
|
{
|
2017-05-08 16:42:22 +00:00
|
|
|
|
_frame = 0;
|
2016-02-28 17:01:12 +00:00
|
|
|
|
_lagCount = 0;
|
|
|
|
|
_isLag = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 16:42:22 +00:00
|
|
|
|
public CoreComm CoreComm { get; }
|
2016-02-28 17:01:12 +00:00
|
|
|
|
|
2017-05-08 16:42:22 +00:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
2016-02-28 17:01:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|