-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 Action<ushort, ushort> WriteMemory;
|
||||
|
||||
private bool logging = true;
|
||||
private string log = "";
|
||||
private static bool logging = true;
|
||||
private static StreamWriter log;
|
||||
|
||||
~CP1610()
|
||||
static CP1610()
|
||||
{
|
||||
using (StreamWriter write = new StreamWriter("log.txt"))
|
||||
{
|
||||
if (logging)
|
||||
write.Write(log);
|
||||
}
|
||||
if (logging)
|
||||
log = new StreamWriter("log_CP1610.txt");
|
||||
}
|
||||
|
||||
public void LogData()
|
||||
|
@ -33,16 +30,18 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
if (!logging)
|
||||
return;
|
||||
for (int register = 0; register <= 5; register++)
|
||||
log += string.Format("R{0:d} = {1:X4}\n", register, Register[register]);
|
||||
log += string.Format("SP = {0:X4}\n", RegisterSP);
|
||||
log += string.Format("PC = {0:X4}\n", RegisterPC);
|
||||
log += string.Format("S = {0:X4}\n", FlagS);
|
||||
log += string.Format("C = {0:X4}\n", FlagC);
|
||||
log += string.Format("Z = {0:X4}\n", FlagZ);
|
||||
log += string.Format("O = {0:X4}\n", FlagO);
|
||||
log += string.Format("I = {0:X4}\n", FlagI);
|
||||
log += string.Format("D = {0:X4}\n", FlagD);
|
||||
log += "------\n";
|
||||
log.WriteLine("R{0:d} = {1:X4}", register, Register[register]);
|
||||
log.WriteLine("SP = {0:X4}", RegisterSP);
|
||||
log.WriteLine("PC = {0:X4}", RegisterPC);
|
||||
log.WriteLine("S = {0:X4}", FlagS);
|
||||
log.WriteLine("C = {0:X4}", FlagC);
|
||||
log.WriteLine("Z = {0:X4}", FlagZ);
|
||||
log.WriteLine("O = {0:X4}", FlagO);
|
||||
log.WriteLine("I = {0:X4}", FlagI);
|
||||
log.WriteLine("D = {0:X4}", FlagD);
|
||||
log.WriteLine("------");
|
||||
log.WriteLine();
|
||||
log.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ namespace BizHawk.Emulation.CPUs.CP1610
|
|||
{
|
||||
int addrToAdvance;
|
||||
if (logging)
|
||||
log += Disassemble(RegisterPC, out addrToAdvance) + "\n";
|
||||
{
|
||||
log.WriteLine(Disassemble(RegisterPC, out addrToAdvance));
|
||||
log.Flush();
|
||||
}
|
||||
int opcode = ReadMemory(RegisterPC++) & 0x3FF;
|
||||
switch (opcode)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
|
||||
public void ExecuteInstruction()
|
||||
{
|
||||
LogCPU();
|
||||
byte TB; byte TB2; sbyte TSB; ushort TUS; int TI1; int TI2; int TIR;
|
||||
while (RegPC.Word == 0x031A)
|
||||
break;
|
||||
|
@ -2243,6 +2242,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
break;
|
||||
default: throw new Exception("unhandled opcode");
|
||||
}
|
||||
LogData();
|
||||
}
|
||||
|
||||
void CheckIrq()
|
||||
|
|
|
@ -9,15 +9,19 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
{
|
||||
public sealed partial class Z80
|
||||
{
|
||||
private bool logging = false;
|
||||
private TextWriter log;
|
||||
private static bool logging = false;
|
||||
private static StreamWriter log;
|
||||
|
||||
static Z80()
|
||||
{
|
||||
if (logging)
|
||||
log = new StreamWriter("log_Z80.txt");
|
||||
}
|
||||
|
||||
public Z80()
|
||||
{
|
||||
InitializeTables();
|
||||
Reset();
|
||||
if (logging)
|
||||
log = File.CreateText("log.txt");
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
@ -149,7 +153,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
PendingCycles = reader.ReadInt32();
|
||||
}
|
||||
|
||||
private void LogCPU()
|
||||
public void LogData()
|
||||
{
|
||||
if (!logging)
|
||||
return;
|
||||
|
@ -161,6 +165,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
log.WriteLine("PC {0:X4}", RegPC.Word);
|
||||
log.WriteLine("------");
|
||||
log.WriteLine();
|
||||
log.Flush();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -285,6 +285,7 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
Cpu.ReadMemory = ReadMemoryBios;
|
||||
Cpu.WriteMemory = WriteMemory;
|
||||
Cpu.Reset();
|
||||
Cpu.LogData();
|
||||
|
||||
//setup initial cpu registers. based on no evidence:
|
||||
//registers which may be used to identify system type are judged to be important; and
|
||||
|
|
Loading…
Reference in New Issue