-Separated the logging from the save state function.
-Made it so that the log only opens when logging is true and that the file closes upon destruction. --Still, BizHawk says that it can't open the file again when I load a game again. This is because the emulator class gets recreated without deleting the original one every time you load a game. ---adelikat convinced me not to care about this. -Fixed the initial state of the GB CPU: --It was setting AF to 0x01, not A. This is effectively setting F to 0x01, which gets overwritten later anyway. --Two BIOS flags were used in different places; merging them gets the PC to start in the right place. -By fixing the initial state, most of the log now matches up. --The only differences are the VBA has some repeated records (Where all of the registers, including PC, are the same as the previous record) whereas BizHawk doesn't. --This very well might be an issue with how I'm logging it --Alternatively, it could be some kind of lagging mechanism. --I'm not sure which version is even correct...VBA is far from accruate. --All in all, considering that the vast majority of the diff comes out as the same, I think I fixed the biggest CPU related bug. Will investigate more later.
This commit is contained in:
parent
db1bfcfdfc
commit
b29c9835ff
|
@ -1188,7 +1188,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
case 0x28: // SRA B
|
||||
RegAF.Low = 0;
|
||||
if ((RegBC.High & 1) != 0) RegAF.Low |= 0x10;
|
||||
RegBC.High = (byte) ((RegBC.High >> 1) | (RegBC.High & 0x80));
|
||||
RegBC.High = (byte)((RegBC.High >> 1) | (RegBC.High & 0x80));
|
||||
if (RegBC.High == 0) RegAF.Low |= 0x80;
|
||||
break;
|
||||
case 0x29: // SRA C
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
|
||||
public Func<ushort, byte> ReadMemory;
|
||||
public Action<ushort, byte> WriteMemory;
|
||||
private bool logging = false;
|
||||
private bool logging = true;
|
||||
private TextWriter log = File.CreateText("log.txt");
|
||||
|
||||
public void UnregisterMemoryMapper()
|
||||
|
@ -150,7 +150,14 @@ namespace BizHawk.Emulation.CPUs.Z80GB
|
|||
{
|
||||
if (!logging)
|
||||
return;
|
||||
SaveStateText(log);
|
||||
log.WriteLine("AF {0:X4}", RegAF.Word);
|
||||
log.WriteLine("BC {0:X4}", RegBC.Word);
|
||||
log.WriteLine("DE {0:X4}", RegDE.Word);
|
||||
log.WriteLine("HL {0:X4}", RegHL.Word);
|
||||
log.WriteLine("SP {0:X4}", RegSP.Word);
|
||||
log.WriteLine("PC {0:X4}", RegPC.Word);
|
||||
log.WriteLine("------");
|
||||
log.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -277,8 +277,6 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
HardReset();
|
||||
}
|
||||
|
||||
public bool BootFromBios = true;
|
||||
|
||||
public void HardReset()
|
||||
{
|
||||
Cpu = new CPUs.Z80GB.Z80();
|
||||
|
@ -296,13 +294,13 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
{
|
||||
case ESystemType.GB:
|
||||
case ESystemType.SGB:
|
||||
Cpu.RegisterAF = 0x01;
|
||||
Cpu.RegisterA = 0x01;
|
||||
break;
|
||||
case ESystemType.GBP:
|
||||
Cpu.RegisterAF = 0xFF;
|
||||
Cpu.RegisterA = 0xFF;
|
||||
break;
|
||||
case ESystemType.GBC:
|
||||
Cpu.RegisterAF = 0x11;
|
||||
Cpu.RegisterA = 0x11;
|
||||
break;
|
||||
case ESystemType.GBA:
|
||||
throw new NotImplementedException(); //decide what to do
|
||||
|
@ -315,8 +313,8 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
Cpu.RegisterDE = 0x00D8;
|
||||
Cpu.RegisterHL = 0x014D;
|
||||
Cpu.RegisterSP = 0xFFFE;
|
||||
if (BootFromBios) Cpu.RegisterPC = 0x0000;
|
||||
else Cpu.RegisterPC = 0x0100;
|
||||
if (skipBIOS) Cpu.RegisterPC = 0x0100;
|
||||
else Cpu.RegisterPC = 0x0000;
|
||||
|
||||
WRam = new byte[32 * 1024]; //GB has 4KB of WRam; GBC has 32KB of WRam
|
||||
SRam = new byte[8 * 1024]; //different carts may have different amounts of this
|
||||
|
|
Loading…
Reference in New Issue