Intellivision simulate CPU halts

NOTE: This is accurate only to a good approximation. The STIC steals too many cycles to ignore (~1000) but the timing is only estimated, see: 
http://spatula-city.org/~im14u2c/intv/tech/master.html
This commit is contained in:
alyosha-tas 2016-12-13 16:45:30 -05:00 committed by GitHub
parent 16c1468903
commit eabd8dbf07
1 changed files with 24 additions and 0 deletions

View File

@ -28,6 +28,9 @@ namespace BizHawk.Emulation.Cores.Intellivision
// 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;
_cpu.AddPendingCycles(14934 - 3791 - _cpu.GetPendingCycles());
_stic.Sr1 = true;
@ -36,6 +39,27 @@ namespace BizHawk.Emulation.Cores.Intellivision
{
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();
}
Connect();
}