-Made connections between the signal pins on the CP1610 and the STIC.

--Not sure why the STIC has any connection to the SST, but the docs on the SST are virtually non-existent from what I could find.
--I took advantage of Func and Action instead of passing bool references to both devices. I think this makes sense.
-Added reset functions for both devices.

My comparison log for INTRM is still weird because it says it is true initially (Expected) and remains as such after the first instruction (A bit odd). I think this happens because the STIC is supposed to "tick" and shift SR1 to false immediately, but the STIC tick happens after the CPU tick, and the CPU tick is where the logging happens. I need to find a better place to put this logging, and I need to implement the STIC ticking for IntelliHawk. I'm not positive how to approach the latter issue as I assume a tick means one instruction execution, and my executions happen in a loop on the CPU, which has no reference to the STIC, so I'm not sure where this fits into the equation.
This commit is contained in:
brandman211 2012-08-13 08:10:15 +00:00
parent fd6201c703
commit 9100232547
4 changed files with 79 additions and 7 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, IntRM, BusRq, BusAk, MSync, Interruptible; private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, 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,6 +18,14 @@ 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;
@ -28,8 +36,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
log = new StreamWriter("log_CP1610.txt"); log = new StreamWriter("log_CP1610.txt");
} }
public CP1610() public void Reset()
{ {
BusAk = true;
Interruptible = false;
FlagS = FlagC = FlagZ = FlagO = FlagI = FlagD = false;
for (int register = 0; register <= 6; register++)
Register[register] = 0;
RegisterPC = RESET; RegisterPC = RESET;
} }

View File

@ -116,8 +116,6 @@ namespace BizHawk.Emulation.CPUs.CP1610
} }
if (FlagI && Interruptible && !IntRM) if (FlagI && Interruptible && !IntRM)
{ {
IntRM = true;
Interruptible = false;
Indirect_Set(6, 7); Indirect_Set(6, 7);
RegisterPC = INTERRUPT; RegisterPC = INTERRUPT;
} }

View File

@ -15,6 +15,38 @@ namespace BizHawk.Emulation.Consoles.Intellivision
STIC Stic; STIC Stic;
PSG Psg; PSG Psg;
private bool Sr1ToIntRM, Sr2ToBusRq, BusAkToSst;
private bool GetSr1ToIntRM()
{
return Sr1ToIntRM;
}
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()
{ {
FileStream fs = new FileStream("C:/erom.int", FileMode.Open, FileAccess.Read); FileStream fs = new FileStream("C:/erom.int", FileMode.Open, FileAccess.Read);
@ -55,12 +87,25 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Cpu = new CP1610(); Cpu = new CP1610();
Cpu.ReadMemory = ReadMemory; Cpu.ReadMemory = ReadMemory;
Cpu.WriteMemory = WriteMemory; Cpu.WriteMemory = WriteMemory;
Cpu.LogData(); Cpu.GetIntRM = GetSr1ToIntRM;
Cpu.GetBusRq = GetSr2ToBusRq;
Cpu.GetBusAk = GetBusAkToSst;
Cpu.SetBusAk = SetBusAkToSst;
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();
Psg = new PSG(); Psg = new PSG();
CoreOutputComm = new CoreOutputComm(); CoreOutputComm = new CoreOutputComm();
Cpu.LogData();
} }
public void FrameAdvance(bool render) public void FrameAdvance(bool render)

View File

@ -7,9 +7,25 @@ namespace BizHawk.Emulation.Consoles.Intellivision
{ {
public sealed class STIC public sealed class STIC
{ {
private bool Sr1, Sr2, Fgbg = false; private bool 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()
{
Sr1 = true;
Sr2 = true;
}
public ushort? ReadSTIC(ushort addr) public ushort? ReadSTIC(ushort addr)
{ {
switch (addr & 0xF000) switch (addr & 0xF000)