2015-06-18 16:44:30 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2016-11-11 21:47:55 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2016-12-03 23:44:25 +00:00
|
|
|
|
get { return ControllerDeck.Definition; }
|
2015-06-18 16:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IController Controller { get; set; }
|
|
|
|
|
|
|
|
|
|
public void FrameAdvance(bool render, bool rendersound)
|
|
|
|
|
{
|
2016-11-11 22:17:35 +00:00
|
|
|
|
if (Tracer.Enabled)
|
|
|
|
|
_cpu.TraceCallback = (s) => Tracer.Put(s);
|
|
|
|
|
else
|
|
|
|
|
_cpu.TraceCallback = null;
|
|
|
|
|
|
2016-12-10 04:00:40 +00:00
|
|
|
|
//reset the count of audio samples
|
|
|
|
|
_psg.sample_count = 0;
|
|
|
|
|
|
2016-12-06 03:00:47 +00:00
|
|
|
|
_frame++;
|
2016-11-11 21:47:55 +00:00
|
|
|
|
// read the controller state here for now
|
|
|
|
|
get_controller_state();
|
2016-12-06 02:51:12 +00:00
|
|
|
|
|
2016-12-13 21:45:30 +00:00
|
|
|
|
// 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();
|
2016-12-06 02:51:12 +00:00
|
|
|
|
_psg.generate_sound(cycles);
|
2016-12-13 21:45:30 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
2016-11-11 21:47:55 +00:00
|
|
|
|
|
|
|
|
|
_stic.Background();
|
|
|
|
|
_stic.Mobs();
|
2016-11-15 15:28:09 +00:00
|
|
|
|
|
2016-12-06 02:51:12 +00:00
|
|
|
|
_stic.Sr1 = false;
|
2016-12-22 02:43:33 +00:00
|
|
|
|
|
|
|
|
|
_cpu.PendingCycles = (3791 + _cpu.GetPendingCycles());
|
2016-12-06 02:51:12 +00:00
|
|
|
|
|
2016-11-15 15:28:09 +00:00
|
|
|
|
while (_cpu.GetPendingCycles() > 0)
|
|
|
|
|
{
|
|
|
|
|
int cycles = _cpu.Execute();
|
2016-12-10 18:48:02 +00:00
|
|
|
|
//_psg.generate_sound(cycles);
|
2016-11-15 15:28:09 +00:00
|
|
|
|
Connect();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-18 16:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-04 14:25:17 +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()
|
|
|
|
|
{
|
2016-12-04 14:25:17 +00:00
|
|
|
|
_frame = 0;
|
2015-06-18 16:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreComm CoreComm { get; private set; }
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-03 23:44:25 +00:00
|
|
|
|
}
|