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

150 lines
3.0 KiB
C#
Raw Normal View History

2015-06-18 16:44:30 +00:00
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Intellivision
{
public sealed partial class Intellivision : IEmulator
{
public IEmulatorServiceProvider ServiceProvider { get; }
2015-06-18 16:44:30 +00:00
public ControllerDefinition ControllerDefinition => ControllerDeck.Definition;
2015-06-18 16:44:30 +00:00
public IController Controller { get; set; }
2015-06-18 16:44:30 +00:00
public void FrameAdvance(bool render, bool rendersound)
{
if (Tracer.Enabled)
{
_cpu.TraceCallback = (s) => Tracer.Put(s);
}
else
{
_cpu.TraceCallback = null;
}
2016-12-06 03:00:47 +00:00
_frame++;
stic_row = -1;
// 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
2016-12-24 20:01:41 +00:00
int delay_cycles = 700;
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;
2016-12-27 21:31:33 +00:00
islag = true;
2016-11-15 15:28:09 +00:00
2016-12-24 14:14:24 +00:00
bool active_display = _stic.active_display;
// also at the start of every frame the color stack is reset
2016-12-24 20:01:41 +00:00
_stic.ColorSP = 0x0028;
2015-06-18 16:44:30 +00:00
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
_psg.generate_sound(cycles);
2016-12-24 14:14:24 +00:00
if (delay_cycles>=0 && active_display)
delay_cycles += cycles;
2016-12-24 14:14:24 +00:00
if (delay_timer> 0 && active_display)
{
delay_timer -= cycles;
if (delay_timer<=0)
{
_stic.ToggleSr2();
delay_cycles = 0;
}
}
if (delay_cycles >= 750 && active_display)
{
delay_cycles = -1;
delay_timer = 110;
_stic.ToggleSr2();
if (stic_row >= 0)
{
_stic.in_vb_2 = true;
_stic.Background(stic_row);
_stic.in_vb_2 = false;
}
stic_row++;
}
2015-06-18 16:44:30 +00:00
Connect();
}
// set up VBlank variables
_stic.in_vb_1 = true;
_stic.in_vb_2 = true;
2016-11-15 15:28:09 +00:00
if (_stic.active_display)
{
_stic.Mobs();
}
_stic.active_display = false;
_stic.Sr1 = false;
2016-12-22 02:43:33 +00:00
_cpu.PendingCycles = 3000 + _cpu.GetPendingCycles();
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
_psg.generate_sound(cycles);
Connect();
}
// vblank phase 2
_cpu.PendingCycles = 791 + _cpu.GetPendingCycles();
_stic.in_vb_1 = false;
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();
}
_stic.in_vb_2 = false;
2016-11-15 15:28:09 +00:00
2016-12-27 21:31:33 +00:00
if (islag)
lagcount++;
if (Controller.IsPressed("Power"))
HardReset();
if (Controller.IsPressed("Reset"))
SoftReset();
2015-06-18 16:44:30 +00:00
}
private int _frame;
2016-12-27 21:31:33 +00:00
public bool islag;
public int lagcount;
private int stic_row;
2015-06-18 16:44:30 +00:00
public int Frame => _frame;
public string SystemId => "INTV";
2015-06-18 16:44:30 +00:00
public bool DeterministicEmulation => true;
2015-06-18 16:44:30 +00:00
[FeatureNotImplemented]
public string BoardName => null;
2015-06-18 16:44:30 +00:00
public void ResetCounters()
2015-06-18 16:44:30 +00:00
{
_frame = 0;
2016-12-27 21:31:33 +00:00
lagcount = 0;
2015-06-18 16:44:30 +00:00
}
public CoreComm CoreComm { get; }
2015-06-18 16:44:30 +00:00
public void Dispose()
{
}
}
}