-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:
parent
9100232547
commit
26b1d06b7a
|
@ -8,7 +8,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
private const ushort RESET = 0x1000;
|
||||
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 RegisterSP { get { return Register[6]; } set { Register[6] = 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, 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 StreamWriter log;
|
||||
|
@ -46,6 +38,31 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
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()
|
||||
{
|
||||
if (!logging)
|
||||
|
|
|
@ -49,23 +49,12 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
if (mem == 0x6)
|
||||
RegisterSP--;
|
||||
if (!FlagD)
|
||||
{
|
||||
value = ReadMemory(Register[mem]);
|
||||
if (mem != 0x6)
|
||||
{
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
PendingCycles -= 11; TotalExecutedCycles += 11;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Double Byte Data.
|
||||
value = (ushort)(ReadMemory(Register[mem]++) & 0xFF);
|
||||
value |= (ushort)(ReadMemory(Register[mem]) << 8);
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
}
|
||||
// Auto-increment the memory register if it does so on write.
|
||||
if (mem >= 0x4 && mem != 0x6)
|
||||
|
@ -73,23 +62,23 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
return value;
|
||||
}
|
||||
|
||||
public void Indirect_Get_Cycles(byte mem)
|
||||
public int Indirect_Get_Cycles(byte mem)
|
||||
{
|
||||
if (!FlagD)
|
||||
{
|
||||
if (mem != 0x6)
|
||||
{
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
return 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
PendingCycles -= 11; TotalExecutedCycles += 11;
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Double Byte Data.
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,10 +90,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Register[mem]++;
|
||||
}
|
||||
|
||||
public void Execute(int cycles)
|
||||
{
|
||||
PendingCycles += cycles;
|
||||
while (PendingCycles > 0)
|
||||
public void Execute()
|
||||
{
|
||||
if (logging)
|
||||
{
|
||||
|
@ -121,7 +107,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
}
|
||||
byte dest, src, mem;
|
||||
ushort dest_value, src_value, mem_read, addr, addr_read, offset;
|
||||
int decle2, decle3, result = 0, ones, carry, status_word, lower, sign, cond, ext;
|
||||
int cycles = 0, decle2, decle3, result = 0, ones, carry, status_word, lower, sign, cond, ext;
|
||||
bool branch = false;
|
||||
bool prev_FlagD = FlagD;
|
||||
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
||||
|
@ -131,17 +117,17 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
throw new ArgumentException(UNEXPECTED_HLT);
|
||||
case 0x001: // SDBD
|
||||
FlagD = true;
|
||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||
cycles = 4;
|
||||
Interruptible = false;
|
||||
break;
|
||||
case 0x002: // EIS
|
||||
FlagI = true;
|
||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||
cycles = 4;
|
||||
Interruptible = false;
|
||||
break;
|
||||
case 0x003: // DIS
|
||||
FlagI = false;
|
||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||
cycles = 4;
|
||||
Interruptible = false;
|
||||
break;
|
||||
case 0x004: // J, JE, JD, JSR, JSRE, JSRD
|
||||
|
@ -169,19 +155,19 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
throw new ArgumentException();
|
||||
}
|
||||
RegisterPC = (ushort)addr;
|
||||
PendingCycles -= 12; TotalExecutedCycles += 12;
|
||||
cycles = 12;
|
||||
Interruptible = true;
|
||||
break;
|
||||
case 0x005: // TCI
|
||||
throw new ArgumentException(UNEXPECTED_TCI);
|
||||
case 0x006: // CLRC
|
||||
FlagC = false;
|
||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||
cycles = 4;
|
||||
Interruptible = false;
|
||||
break;
|
||||
case 0x007: // SETC
|
||||
FlagC = true;
|
||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||
cycles = 4;
|
||||
Interruptible = false;
|
||||
break;
|
||||
// INCR
|
||||
|
@ -199,7 +185,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// DECR
|
||||
|
@ -216,7 +202,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// COMR
|
||||
|
@ -234,7 +220,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// NEGR
|
||||
|
@ -257,7 +243,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// ADCR
|
||||
|
@ -280,7 +266,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// GSWD
|
||||
|
@ -293,13 +279,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
status_word = ((FlagS ? 1 : 0) << 3) | ((FlagZ ? 1 : 0) << 2) | ((FlagO ? 1 : 0) << 1) |
|
||||
(FlagC ? 1 : 0);
|
||||
Register[dest] = (ushort)((status_word << 12) | (status_word << 4));
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// NOP
|
||||
case 0x034:
|
||||
case 0x035:
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// SIN
|
||||
|
@ -322,7 +308,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
FlagO = ((src_value & 0x40) != 0) ? true : false;
|
||||
FlagZ = ((src_value & 0x20) != 0) ? true : false;
|
||||
FlagS = ((src_value & 0x10) != 0) ? true : false;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// SWAP
|
||||
|
@ -341,13 +327,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
{
|
||||
// Single swap.
|
||||
result = (lower << 8) | ((dest_value >> 8) & 0xFF);
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Double swap.
|
||||
result = (lower << 8) | lower;
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS_7(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -367,15 +353,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
dest = (byte)(opcode & 0x3);
|
||||
result = Register[dest] << 1;
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single shift.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double shift.
|
||||
result <<= 1;
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -397,17 +381,15 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
result = (dest_value << 1) | (FlagC ? 1 : 0);
|
||||
FlagC = ((dest_value & 0x8000) != 0);
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single rotate.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double rotate.
|
||||
result <<= 1;
|
||||
result |= (FlagO ? 1 : 0);
|
||||
FlagO = ((dest_value & 0x4000) != 0);
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -429,16 +411,14 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
result = dest_value << 1;
|
||||
FlagC = ((dest_value & 0x8000) != 0);
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single shift.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double shift.
|
||||
result <<= 1;
|
||||
FlagO = ((dest_value & 0x4000) != 0);
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -458,15 +438,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
dest = (byte)(opcode & 0x3);
|
||||
result = Register[dest] >> 1;
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single shift.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double shift.
|
||||
result >>= 1;
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS_7(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -488,16 +466,14 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
sign = dest_value & 0x8000;
|
||||
result = (dest_value >> 1) | sign;
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single shift.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double shift.
|
||||
result >>= 1;
|
||||
result |= sign;
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS_7(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -519,17 +495,15 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
result = (dest_value >> 1) | ((FlagC ? 1 : 0) << 15);
|
||||
FlagC = ((dest_value & 0x1) != 0);
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single rotate.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double rotate.
|
||||
result >>= 1;
|
||||
result |= (FlagO ? 1 : 0) << 15;
|
||||
FlagO = ((dest_value & 0x2) != 0);
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS_7(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -552,17 +526,15 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
result = (dest_value >> 1) | sign;
|
||||
FlagC = ((dest_value & 0x1) != 0);
|
||||
if (((opcode >> 3) & 0x1) == 0)
|
||||
{
|
||||
// Single shift.
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
else
|
||||
{
|
||||
// Double shift.
|
||||
result >>= 1;
|
||||
result |= sign;
|
||||
FlagO = ((dest_value & 0x2) != 0);
|
||||
PendingCycles -= 8; TotalExecutedCycles += 8;
|
||||
cycles = 8;
|
||||
}
|
||||
Calc_FlagS_7(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -641,13 +613,9 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
if (dest == 0x6 || dest == 0x7)
|
||||
{
|
||||
PendingCycles -= 7; TotalExecutedCycles += 7;
|
||||
}
|
||||
cycles = 7;
|
||||
else
|
||||
{
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
}
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// ADDR
|
||||
|
@ -727,7 +695,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// SUBR
|
||||
|
@ -807,7 +775,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// CMPR
|
||||
|
@ -885,7 +853,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagO_Add(dest_value, -src_value);
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// ANDR
|
||||
|
@ -960,7 +928,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// XORR
|
||||
|
@ -1034,7 +1002,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 6; TotalExecutedCycles += 6;
|
||||
cycles = 6;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// Branch Forward, no External Condition
|
||||
|
@ -1187,12 +1155,10 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
if (((opcode >> 5) & 0x1) != 0)
|
||||
offset = (ushort)(-offset - 1);
|
||||
RegisterPC += offset;
|
||||
PendingCycles -= 9; TotalExecutedCycles += 9;
|
||||
cycles = 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
PendingCycles -= 7; TotalExecutedCycles += 7;
|
||||
}
|
||||
cycles = 7;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// MVO
|
||||
|
@ -1207,7 +1173,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
src = (byte)(opcode & 0x7);
|
||||
addr = ReadMemory(RegisterPC++);
|
||||
WriteMemory(addr, Register[src]);
|
||||
PendingCycles -= 11; TotalExecutedCycles += 11;
|
||||
cycles = 11;
|
||||
Interruptible = false;
|
||||
break;
|
||||
// MVO@
|
||||
|
@ -1270,7 +1236,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
src = (byte)(opcode & 0x7);
|
||||
Indirect_Set(mem, src);
|
||||
PendingCycles -= 9; TotalExecutedCycles += 9;
|
||||
cycles = 9;
|
||||
Interruptible = false;
|
||||
break;
|
||||
// MVI
|
||||
|
@ -1286,7 +1252,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
dest = (byte)(opcode & 0x7);
|
||||
addr = ReadMemory(RegisterPC++);
|
||||
Register[dest] = ReadMemory(addr);
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// MVI@
|
||||
|
@ -1349,7 +1315,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
Register[dest] = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
Interruptible = true;
|
||||
break;
|
||||
// ADD
|
||||
|
@ -1373,7 +1339,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// ADD@
|
||||
|
@ -1436,7 +1402,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
mem_read = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
dest_value = Register[dest];
|
||||
result = dest_value + mem_read;
|
||||
Calc_FlagC(result);
|
||||
|
@ -1468,7 +1434,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagZ(result);
|
||||
result &= 0xFFFF;
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// SUB@
|
||||
|
@ -1532,7 +1498,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
mem_read = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
dest_value = Register[dest];
|
||||
result = dest_value - mem_read;
|
||||
Calc_FlagC(result);
|
||||
|
@ -1561,7 +1527,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagO_Add(dest_value, -addr_read);
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// CMP@
|
||||
|
@ -1625,7 +1591,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
mem_read = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
dest_value = Register[dest];
|
||||
result = dest_value - mem_read;
|
||||
Calc_FlagC(result);
|
||||
|
@ -1652,7 +1618,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// AND@
|
||||
|
@ -1715,7 +1681,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
mem_read = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
result = Register[dest] & mem_read;
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -1740,7 +1706,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
Register[dest] = (ushort)result;
|
||||
PendingCycles -= 10; TotalExecutedCycles += 10;
|
||||
cycles = 10;
|
||||
Interruptible = true;
|
||||
break;
|
||||
// XOR@
|
||||
|
@ -1804,7 +1770,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
mem = (byte)((opcode >> 3) & 0x7);
|
||||
dest = (byte)(opcode & 0x7);
|
||||
mem_read = Indirect_Get(mem);
|
||||
Indirect_Get_Cycles(mem);
|
||||
cycles = Indirect_Get_Cycles(mem);
|
||||
result = Register[dest] ^ mem_read;
|
||||
Calc_FlagS(result);
|
||||
Calc_FlagZ(result);
|
||||
|
@ -1814,8 +1780,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
}
|
||||
if (FlagD == prev_FlagD)
|
||||
FlagD = false;
|
||||
LogData();
|
||||
}
|
||||
PendingCycles -= cycles; TotalExecutedCycles += cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,36 +15,11 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
|||
STIC Stic;
|
||||
PSG Psg;
|
||||
|
||||
private bool Sr1ToIntRM, Sr2ToBusRq, BusAkToSst;
|
||||
|
||||
private bool GetSr1ToIntRM()
|
||||
public void Connect()
|
||||
{
|
||||
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;
|
||||
Cpu.SetIntRM(Stic.GetSr1());
|
||||
Cpu.SetBusRq(Stic.GetSr2());
|
||||
Stic.SetSst(Cpu.GetBusAk());
|
||||
}
|
||||
|
||||
public void LoadExecutiveRom()
|
||||
|
@ -87,22 +62,15 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
|||
Cpu = new CP1610();
|
||||
Cpu.ReadMemory = ReadMemory;
|
||||
Cpu.WriteMemory = WriteMemory;
|
||||
Cpu.GetIntRM = GetSr1ToIntRM;
|
||||
Cpu.GetBusRq = GetSr2ToBusRq;
|
||||
Cpu.GetBusAk = GetBusAkToSst;
|
||||
Cpu.SetBusAk = SetBusAkToSst;
|
||||
Cpu.Reset();
|
||||
|
||||
Stic = new STIC();
|
||||
Stic.GetSr1 = GetSr1ToIntRM;
|
||||
Stic.GetSr2 = GetSr2ToBusRq;
|
||||
Stic.GetSst = GetBusAkToSst;
|
||||
Stic.SetSr1 = SetSr1ToIntRM;
|
||||
Stic.SetSr2 = SetSr2ToBusRq;
|
||||
Stic.Reset();
|
||||
|
||||
Psg = new PSG();
|
||||
|
||||
Connect();
|
||||
|
||||
CoreOutputComm = new CoreOutputComm();
|
||||
|
||||
Cpu.LogData();
|
||||
|
@ -110,7 +78,14 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
|||
|
||||
public void FrameAdvance(bool render)
|
||||
{
|
||||
Cpu.Execute(999);
|
||||
Cpu.AddPendingCycles(999);
|
||||
while (Cpu.GetPendingCycles() > 0)
|
||||
{
|
||||
Cpu.Execute();
|
||||
Stic.Execute();
|
||||
Connect();
|
||||
Cpu.LogData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,25 +7,30 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
|||
{
|
||||
public sealed class STIC
|
||||
{
|
||||
private bool Fgbg = false;
|
||||
private bool Sr1, Sr2, Sst, Fgbg = false;
|
||||
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 bool GetSr1()
|
||||
{
|
||||
return Sr1;
|
||||
}
|
||||
|
||||
public bool GetSr2()
|
||||
{
|
||||
return Sr2;
|
||||
}
|
||||
|
||||
public void SetSst(bool value)
|
||||
{
|
||||
Sst = value;
|
||||
}
|
||||
|
||||
public ushort? ReadSTIC(ushort addr)
|
||||
{
|
||||
switch (addr & 0xF000)
|
||||
|
@ -120,5 +125,10 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
Sr1 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue