-Logging now uses a static StreamWriter instead of building the string and writing on destruction.
-Applied to the old Gameboy core. Why not? It at least fixes that annoying bug from before if we ever care to use it again. -Both logs are now written to different files.
This commit is contained in:
parent
9f2bcf3318
commit
743480e26f
|
@ -16,16 +16,13 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
public Func<ushort, ushort> ReadMemory;
|
public Func<ushort, ushort> ReadMemory;
|
||||||
public Action<ushort, ushort> WriteMemory;
|
public Action<ushort, ushort> WriteMemory;
|
||||||
|
|
||||||
private bool logging = true;
|
private static bool logging = true;
|
||||||
private string log = "";
|
private static StreamWriter log;
|
||||||
|
|
||||||
~CP1610()
|
static CP1610()
|
||||||
{
|
|
||||||
using (StreamWriter write = new StreamWriter("log.txt"))
|
|
||||||
{
|
{
|
||||||
if (logging)
|
if (logging)
|
||||||
write.Write(log);
|
log = new StreamWriter("log_CP1610.txt");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogData()
|
public void LogData()
|
||||||
|
@ -33,16 +30,18 @@ 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 += string.Format("R{0:d} = {1:X4}\n", register, Register[register]);
|
log.WriteLine("R{0:d} = {1:X4}", register, Register[register]);
|
||||||
log += string.Format("SP = {0:X4}\n", RegisterSP);
|
log.WriteLine("SP = {0:X4}", RegisterSP);
|
||||||
log += string.Format("PC = {0:X4}\n", RegisterPC);
|
log.WriteLine("PC = {0:X4}", RegisterPC);
|
||||||
log += string.Format("S = {0:X4}\n", FlagS);
|
log.WriteLine("S = {0:X4}", FlagS);
|
||||||
log += string.Format("C = {0:X4}\n", FlagC);
|
log.WriteLine("C = {0:X4}", FlagC);
|
||||||
log += string.Format("Z = {0:X4}\n", FlagZ);
|
log.WriteLine("Z = {0:X4}", FlagZ);
|
||||||
log += string.Format("O = {0:X4}\n", FlagO);
|
log.WriteLine("O = {0:X4}", FlagO);
|
||||||
log += string.Format("I = {0:X4}\n", FlagI);
|
log.WriteLine("I = {0:X4}", FlagI);
|
||||||
log += string.Format("D = {0:X4}\n", FlagD);
|
log.WriteLine("D = {0:X4}", FlagD);
|
||||||
log += "------\n";
|
log.WriteLine("------");
|
||||||
|
log.WriteLine();
|
||||||
|
log.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,10 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
||||||
{
|
{
|
||||||
int addrToAdvance;
|
int addrToAdvance;
|
||||||
if (logging)
|
if (logging)
|
||||||
log += Disassemble(RegisterPC, out addrToAdvance) + "\n";
|
{
|
||||||
|
log.WriteLine(Disassemble(RegisterPC, out addrToAdvance));
|
||||||
|
log.Flush();
|
||||||
|
}
|
||||||
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
||||||
switch (opcode)
|
switch (opcode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,6 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
||||||
|
|
||||||
public void ExecuteInstruction()
|
public void ExecuteInstruction()
|
||||||
{
|
{
|
||||||
LogCPU();
|
|
||||||
byte TB; byte TB2; sbyte TSB; ushort TUS; int TI1; int TI2; int TIR;
|
byte TB; byte TB2; sbyte TSB; ushort TUS; int TI1; int TI2; int TIR;
|
||||||
while (RegPC.Word == 0x031A)
|
while (RegPC.Word == 0x031A)
|
||||||
break;
|
break;
|
||||||
|
@ -2243,6 +2242,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
||||||
break;
|
break;
|
||||||
default: throw new Exception("unhandled opcode");
|
default: throw new Exception("unhandled opcode");
|
||||||
}
|
}
|
||||||
|
LogData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIrq()
|
void CheckIrq()
|
||||||
|
|
|
@ -9,15 +9,19 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
||||||
{
|
{
|
||||||
public sealed partial class Z80
|
public sealed partial class Z80
|
||||||
{
|
{
|
||||||
private bool logging = false;
|
private static bool logging = false;
|
||||||
private TextWriter log;
|
private static StreamWriter log;
|
||||||
|
|
||||||
|
static Z80()
|
||||||
|
{
|
||||||
|
if (logging)
|
||||||
|
log = new StreamWriter("log_Z80.txt");
|
||||||
|
}
|
||||||
|
|
||||||
public Z80()
|
public Z80()
|
||||||
{
|
{
|
||||||
InitializeTables();
|
InitializeTables();
|
||||||
Reset();
|
Reset();
|
||||||
if (logging)
|
|
||||||
log = File.CreateText("log.txt");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
|
@ -149,7 +153,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
||||||
PendingCycles = reader.ReadInt32();
|
PendingCycles = reader.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogCPU()
|
public void LogData()
|
||||||
{
|
{
|
||||||
if (!logging)
|
if (!logging)
|
||||||
return;
|
return;
|
||||||
|
@ -161,6 +165,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
||||||
log.WriteLine("PC {0:X4}", RegPC.Word);
|
log.WriteLine("PC {0:X4}", RegPC.Word);
|
||||||
log.WriteLine("------");
|
log.WriteLine("------");
|
||||||
log.WriteLine();
|
log.WriteLine();
|
||||||
|
log.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -285,6 +285,7 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
||||||
Cpu.ReadMemory = ReadMemoryBios;
|
Cpu.ReadMemory = ReadMemoryBios;
|
||||||
Cpu.WriteMemory = WriteMemory;
|
Cpu.WriteMemory = WriteMemory;
|
||||||
Cpu.Reset();
|
Cpu.Reset();
|
||||||
|
Cpu.LogData();
|
||||||
|
|
||||||
//setup initial cpu registers. based on no evidence:
|
//setup initial cpu registers. based on no evidence:
|
||||||
//registers which may be used to identify system type are judged to be important; and
|
//registers which may be used to identify system type are judged to be important; and
|
||||||
|
|
Loading…
Reference in New Issue