-Simplified the CPU / STIC connection.

-Made FrameAdvance handle the pending cycle loop. During each iteration, it runs one instruction and ticks the STIC accordingly.
This commit is contained in:
brandman211 2012-08-14 03:58:11 +00:00
parent 9100232547
commit 26b1d06b7a
4 changed files with 1753 additions and 1786 deletions

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
private const ushort RESET = 0x1000; private const ushort RESET = 0x1000;
private const ushort INTERRUPT = 0x1004; private const ushort INTERRUPT = 0x1004;
private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, MSync, Interruptible; private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, MSync, Interruptible;
private ushort[] Register = new ushort[8]; private ushort[] Register = new ushort[8];
private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } } private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } }
private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } } private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } }
@ -18,14 +18,6 @@ namespace BizHawk.Emulation.CPUs.CP1610
public Func<ushort, ushort> ReadMemory; public Func<ushort, ushort> ReadMemory;
public Func<ushort, ushort, bool> WriteMemory; public Func<ushort, ushort, bool> WriteMemory;
public Func<bool> GetIntRM;
public Func<bool> GetBusRq;
public Func<bool> GetBusAk;
public Action<bool> SetBusAk;
private bool IntRM { get { return GetIntRM(); } }
private bool BusRq { get { return GetBusRq(); } }
private bool BusAk { get { return GetBusAk(); } set { SetBusAk(value); } }
private static bool logging = true; private static bool logging = true;
private static StreamWriter log; private static StreamWriter log;
@ -46,6 +38,31 @@ namespace BizHawk.Emulation.CPUs.CP1610
RegisterPC = RESET; RegisterPC = RESET;
} }
public bool GetBusAk()
{
return BusAk;
}
public void SetIntRM(bool value)
{
IntRM = value;
}
public int GetPendingCycles()
{
return PendingCycles;
}
public void SetBusRq(bool value)
{
BusRq = value;
}
public void AddPendingCycles(int cycles)
{
PendingCycles += cycles;
}
public void LogData() public void LogData()
{ {
if (!logging) if (!logging)

File diff suppressed because it is too large Load Diff

View File

@ -15,36 +15,11 @@ namespace BizHawk.Emulation.Consoles.Intellivision
STIC Stic; STIC Stic;
PSG Psg; PSG Psg;
private bool Sr1ToIntRM, Sr2ToBusRq, BusAkToSst; public void Connect()
private bool GetSr1ToIntRM()
{ {
return Sr1ToIntRM; Cpu.SetIntRM(Stic.GetSr1());
} Cpu.SetBusRq(Stic.GetSr2());
Stic.SetSst(Cpu.GetBusAk());
private bool GetSr2ToBusRq()
{
return Sr2ToBusRq;
}
private bool GetBusAkToSst()
{
return BusAkToSst;
}
private void SetSr1ToIntRM(bool value)
{
Sr1ToIntRM = value;
}
private void SetSr2ToBusRq(bool value)
{
Sr2ToBusRq = value;
}
private void SetBusAkToSst(bool value)
{
BusAkToSst = value;
} }
public void LoadExecutiveRom() public void LoadExecutiveRom()
@ -87,22 +62,15 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Cpu = new CP1610(); Cpu = new CP1610();
Cpu.ReadMemory = ReadMemory; Cpu.ReadMemory = ReadMemory;
Cpu.WriteMemory = WriteMemory; Cpu.WriteMemory = WriteMemory;
Cpu.GetIntRM = GetSr1ToIntRM;
Cpu.GetBusRq = GetSr2ToBusRq;
Cpu.GetBusAk = GetBusAkToSst;
Cpu.SetBusAk = SetBusAkToSst;
Cpu.Reset(); Cpu.Reset();
Stic = new STIC(); Stic = new STIC();
Stic.GetSr1 = GetSr1ToIntRM;
Stic.GetSr2 = GetSr2ToBusRq;
Stic.GetSst = GetBusAkToSst;
Stic.SetSr1 = SetSr1ToIntRM;
Stic.SetSr2 = SetSr2ToBusRq;
Stic.Reset(); Stic.Reset();
Psg = new PSG(); Psg = new PSG();
Connect();
CoreOutputComm = new CoreOutputComm(); CoreOutputComm = new CoreOutputComm();
Cpu.LogData(); Cpu.LogData();
@ -110,7 +78,14 @@ namespace BizHawk.Emulation.Consoles.Intellivision
public void FrameAdvance(bool render) public void FrameAdvance(bool render)
{ {
Cpu.Execute(999); Cpu.AddPendingCycles(999);
while (Cpu.GetPendingCycles() > 0)
{
Cpu.Execute();
Stic.Execute();
Connect();
Cpu.LogData();
}
} }

View File

@ -7,18 +7,8 @@ namespace BizHawk.Emulation.Consoles.Intellivision
{ {
public sealed class STIC public sealed class STIC
{ {
private bool Fgbg = false; private bool Sr1, Sr2, Sst, Fgbg = false;
private ushort[] Register = new ushort[64]; private ushort[] Register = new ushort[64];
public Func<bool> GetSr1;
public Func<bool> GetSr2;
public Func<bool> GetSst;
public Action<bool> SetSr1;
public Action<bool> SetSr2;
private bool Sr1 { set { SetSr1(value); } }
private bool Sr2 { set { SetSr2(value); } }
private bool Sst { get { return GetSst(); } }
public void Reset() public void Reset()
{ {
@ -26,6 +16,21 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Sr2 = true; Sr2 = true;
} }
public bool GetSr1()
{
return Sr1;
}
public bool GetSr2()
{
return Sr2;
}
public void SetSst(bool value)
{
Sst = value;
}
public ushort? ReadSTIC(ushort addr) public ushort? ReadSTIC(ushort addr)
{ {
switch (addr & 0xF000) switch (addr & 0xF000)
@ -120,5 +125,10 @@ namespace BizHawk.Emulation.Consoles.Intellivision
} }
return false; return false;
} }
public void Execute()
{
Sr1 = false;
}
} }
} }