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

146 lines
3.1 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++;
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;
2016-12-24 20:01:41 +00:00
//also at the start of every frame the color stack is reset
_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;
}
}
2016-12-24 14:14:24 +00:00
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
2016-12-26 15:51:45 +00:00
_cpu.PendingCycles = (3000 + _cpu.GetPendingCycles());
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
_psg.generate_sound(cycles);
Connect();
}
// vblank phase 2
2016-12-26 15:51:45 +00:00
_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++;
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;
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;
2016-12-27 21:31:33 +00:00
lagcount = 0;
2015-06-18 16:44:30 +00:00
}
public CoreComm CoreComm { get; private set; }
public void Dispose()
{
}
}
}