BizHawk/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs

108 lines
2.2 KiB
C#
Raw Normal View History

2015-06-18 16:44:30 +00:00
using BizHawk.Emulation.Common;
using System;
2015-06-18 16:44:30 +00:00
namespace BizHawk.Emulation.Cores.Intellivision
{
public sealed partial class Intellivision : IEmulator
{
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public ControllerDefinition ControllerDefinition
{
get { return ControllerDeck.Definition; }
2015-06-18 16:44:30 +00:00
}
public IController Controller { get; set; }
public void FrameAdvance(bool render, bool rendersound)
{
if (Tracer.Enabled)
_cpu.TraceCallback = (s) => Tracer.Put(s);
else
_cpu.TraceCallback = null;
//reset the count of audio samples
_psg.sample_count = 0;
2016-12-06 03:00:47 +00:00
_frame++;
// read the controller state here for now
get_controller_state();
// this timer tracks cycles stolen by the STIC during the visible part of the frame, quite a large number of them actually
int delay_cycles = 0;
int delay_timer = -1;
2016-12-22 02:43:33 +00:00
_cpu.PendingCycles = (14934 - 3791 + _cpu.GetPendingCycles());
2016-11-15 15:28:09 +00:00
_stic.Sr1 = true;
2015-06-18 16:44:30 +00:00
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
_psg.generate_sound(cycles);
if (delay_cycles>=0)
delay_cycles += cycles;
if (delay_timer>0)
{
delay_timer -= cycles;
if (delay_timer<=0)
{
_stic.ToggleSr2();
delay_cycles = 0;
}
}
if (delay_cycles>=800)
{
delay_cycles = -1;
delay_timer = 110;
_stic.ToggleSr2();
}
2015-06-18 16:44:30 +00:00
Connect();
}
_stic.Background();
_stic.Mobs();
2016-11-15 15:28:09 +00:00
_stic.Sr1 = false;
2016-12-22 02:43:33 +00:00
_cpu.PendingCycles = (3791 + _cpu.GetPendingCycles());
2016-11-15 15:28:09 +00:00
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
//_psg.generate_sound(cycles);
2016-11-15 15:28:09 +00:00
Connect();
}
2015-06-18 16:44:30 +00:00
}
private int _frame;
public int Frame { get { return _frame; } }
2015-06-18 16:44:30 +00:00
public string SystemId
{
get { return "INTV"; }
}
public bool DeterministicEmulation { get { return true; } }
[FeatureNotImplemented]
public string BoardName { get { return null; } }
public void ResetCounters()
{
_frame = 0;
2015-06-18 16:44:30 +00:00
}
public CoreComm CoreComm { get; private set; }
public void Dispose()
{
}
}
}