-Fixed logging.
--It now just builds a strings and writes on finalization. -Fixed up format strings. -As RegisterPC already increments upon reading the third decle, I now just store PC as the return address for jumping instead of PC + 1.
This commit is contained in:
parent
60c5a1ce58
commit
9f2bcf3318
|
@ -17,22 +17,15 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
public Action<ushort, ushort> WriteMemory;
|
public Action<ushort, ushort> WriteMemory;
|
||||||
|
|
||||||
private bool logging = true;
|
private bool logging = true;
|
||||||
private TextWriter log;
|
private string log = "";
|
||||||
|
|
||||||
public CP1610()
|
|
||||||
{
|
|
||||||
if (logging)
|
|
||||||
log = File.CreateText("log.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
~CP1610()
|
~CP1610()
|
||||||
{
|
{
|
||||||
Close();
|
using (StreamWriter write = new StreamWriter("log.txt"))
|
||||||
}
|
{
|
||||||
|
if (logging)
|
||||||
public void Close()
|
write.Write(log);
|
||||||
{
|
}
|
||||||
log.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogData()
|
public void LogData()
|
||||||
|
@ -40,17 +33,16 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
if (!logging)
|
if (!logging)
|
||||||
return;
|
return;
|
||||||
for (int register = 0; register <= 5; register++)
|
for (int register = 0; register <= 5; register++)
|
||||||
log.WriteLine("R" + register + " = {0:X4}", Register[register]);
|
log += string.Format("R{0:d} = {1:X4}\n", register, Register[register]);
|
||||||
log.WriteLine("SP = {0:X4}", RegisterSP);
|
log += string.Format("SP = {0:X4}\n", RegisterSP);
|
||||||
log.WriteLine("PC = {0:X4}", RegisterPC);
|
log += string.Format("PC = {0:X4}\n", RegisterPC);
|
||||||
log.WriteLine("S = {0:X4}", FlagS);
|
log += string.Format("S = {0:X4}\n", FlagS);
|
||||||
log.WriteLine("C = {0:X4}", FlagC);
|
log += string.Format("C = {0:X4}\n", FlagC);
|
||||||
log.WriteLine("Z = {0:X4}", FlagZ);
|
log += string.Format("Z = {0:X4}\n", FlagZ);
|
||||||
log.WriteLine("O = {0:X4}", FlagO);
|
log += string.Format("O = {0:X4}\n", FlagO);
|
||||||
log.WriteLine("I = {0:X4}", FlagI);
|
log += string.Format("I = {0:X4}\n", FlagI);
|
||||||
log.WriteLine("D = {0:X4}", FlagD);
|
log += string.Format("D = {0:X4}\n", FlagD);
|
||||||
log.WriteLine("------");
|
log += "------\n";
|
||||||
log.WriteLine();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -792,7 +792,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
src = (byte)(opcode & 0x7);
|
src = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "MVO R" + src + ", " + string.Format("${0:X4}", addr);
|
return string.Format("MVO R{0:d}, ${1:X4}", src, addr);
|
||||||
case 0x248:
|
case 0x248:
|
||||||
case 0x249:
|
case 0x249:
|
||||||
case 0x24A:
|
case 0x24A:
|
||||||
|
@ -863,7 +863,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
dest = (byte)(opcode & 0x7);
|
dest = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "MVI R" + dest + ", " + string.Format("${0:X4}", addr);
|
return string.Format("MVI R{0:d}, ${1:X4}", dest, addr);
|
||||||
case 0x288:
|
case 0x288:
|
||||||
case 0x289:
|
case 0x289:
|
||||||
case 0x28A:
|
case 0x28A:
|
||||||
|
@ -934,7 +934,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
dest = (byte)(opcode & 0x7);
|
dest = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "ADD R" + dest + ", " + string.Format("${0:X4}", addr);
|
return string.Format("ADD R{0:d}, ${1:X4}", dest, addr);
|
||||||
case 0x2C8:
|
case 0x2C8:
|
||||||
case 0x2C9:
|
case 0x2C9:
|
||||||
case 0x2CA:
|
case 0x2CA:
|
||||||
|
@ -1005,7 +1005,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
mem = (byte)(opcode & 0x7);
|
mem = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "SUB R" + mem + ", " + string.Format("${0:X4}", addr);
|
return string.Format("SUB R{0:d}, ${1:X4}", mem, addr);
|
||||||
case 0x308:
|
case 0x308:
|
||||||
case 0x309:
|
case 0x309:
|
||||||
case 0x30A:
|
case 0x30A:
|
||||||
|
@ -1076,7 +1076,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
mem = (byte)(opcode & 0x7);
|
mem = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "CMP R" + mem + ", " + string.Format("${0:X4}", addr);
|
return string.Format("CMP R{0:d}, ${1:X4}", mem, addr);
|
||||||
case 0x348:
|
case 0x348:
|
||||||
case 0x349:
|
case 0x349:
|
||||||
case 0x34A:
|
case 0x34A:
|
||||||
|
@ -1147,7 +1147,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
mem = (byte)(opcode & 0x7);
|
mem = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "AND R" + mem + ", " + string.Format("${0:X4}", addr);
|
return string.Format("AND R{0:d}, ${1:X4}", mem, addr);
|
||||||
case 0x388:
|
case 0x388:
|
||||||
case 0x389:
|
case 0x389:
|
||||||
case 0x38A:
|
case 0x38A:
|
||||||
|
@ -1218,7 +1218,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
mem = (byte)(opcode & 0x7);
|
mem = (byte)(opcode & 0x7);
|
||||||
addr = ReadMemory((ushort)(pc + 1));
|
addr = ReadMemory((ushort)(pc + 1));
|
||||||
addrToAdvance = 2;
|
addrToAdvance = 2;
|
||||||
return "XOR R" + mem + ", " + string.Format("${0:X4}", addr);
|
return string.Format("XOR R{0:d}, ${1:X4}", mem, addr);
|
||||||
case 0x3C8:
|
case 0x3C8:
|
||||||
case 0x3C9:
|
case 0x3C9:
|
||||||
case 0x3CA:
|
case 0x3CA:
|
||||||
|
|
|
@ -43,8 +43,8 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
while (PendingCycles > 0)
|
while (PendingCycles > 0)
|
||||||
{
|
{
|
||||||
int addrToAdvance;
|
int addrToAdvance;
|
||||||
if (!logging)
|
if (logging)
|
||||||
log.WriteLine(Disassemble(RegisterPC, out addrToAdvance));
|
log += Disassemble(RegisterPC, out addrToAdvance) + "\n";
|
||||||
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
||||||
switch (opcode)
|
switch (opcode)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
addr = (ushort)(((decle2 << 8) & 0xFC00) | (decle3 & 0x3FF));
|
addr = (ushort)(((decle2 << 8) & 0xFC00) | (decle3 & 0x3FF));
|
||||||
if (dest != 0x7)
|
if (dest != 0x7)
|
||||||
// Store the return address.
|
// Store the return address.
|
||||||
Register[dest] = (ushort)((RegisterPC + 1) & 0xFFFF);
|
Register[dest] = (ushort)(RegisterPC & 0xFFFF);
|
||||||
// ff indicates how to affect the Interrupt (I) flag in the CP1610
|
// ff indicates how to affect the Interrupt (I) flag in the CP1610
|
||||||
switch (decle2 & 0x3)
|
switch (decle2 & 0x3)
|
||||||
{
|
{
|
||||||
|
@ -1496,8 +1496,8 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
case 0x3FF:
|
case 0x3FF:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
LogData();
|
||||||
}
|
}
|
||||||
LogData();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,21 +48,14 @@ namespace BizHawk.Emulation.Consoles.Intellivision
|
||||||
Cpu.ReadMemory = ReadMemory;
|
Cpu.ReadMemory = ReadMemory;
|
||||||
Cpu.WriteMemory = WriteMemory;
|
Cpu.WriteMemory = WriteMemory;
|
||||||
Cpu.RegisterPC = 0x1000;
|
Cpu.RegisterPC = 0x1000;
|
||||||
|
Cpu.LogData();
|
||||||
|
|
||||||
CoreOutputComm = new CoreOutputComm();
|
CoreOutputComm = new CoreOutputComm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FrameAdvance(bool render)
|
public void FrameAdvance(bool render)
|
||||||
{
|
{
|
||||||
try
|
Cpu.Execute(999); // execute some cycles. this will do nothing useful until a memory mapper is created.
|
||||||
{
|
|
||||||
Cpu.Execute(999); // execute some cycles. this will do nothing useful until a memory mapper is created.
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Cpu.Close();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue