gbhawk CDL - fiddle with it a bit, ignore writes to rom

This commit is contained in:
zeromus 2018-11-15 05:00:48 -05:00
parent 9955b43c0a
commit 026527380d
21 changed files with 54 additions and 48 deletions

View File

@ -109,15 +109,16 @@ namespace BizHawk.Emulation.Common.Components.LR35902
} }
//a little CDL related stuff //a little CDL related stuff
public delegate void DoCDLCallbackType(ushort addr, LR35902.eCDLog_Flags flags); public delegate void DoCDLCallbackType(ushort addr, LR35902.eCDLogMemFlags flags);
public DoCDLCallbackType CDLCallback; public DoCDLCallbackType CDLCallback;
public enum eCDLog_Flags public enum eCDLogMemFlags
{ {
eCDLog_Flags_ExecFirst = 1, FetchFirst = 1,
eCDLog_Flags_ExecOperand = 2, FetchOperand = 2,
eCDLog_Flags_Data = 4, Data = 4,
Write = 8
}; };
// Execute instructions // Execute instructions
@ -160,7 +161,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
{ {
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null && !CB_prefix) TraceCallback(State()); if (TraceCallback != null && !CB_prefix) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
FetchInstruction(ReadMemory(RegPC++)); FetchInstruction(ReadMemory(RegPC++));
} }
instr_pntr = 0; instr_pntr = 0;
@ -346,7 +347,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
{ {
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null && !CB_prefix) TraceCallback(State()); if (TraceCallback != null && !CB_prefix) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
RegPC++; RegPC++;
FetchInstruction(ReadMemory(RegPC)); FetchInstruction(ReadMemory(RegPC));
@ -366,7 +367,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
{ {
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null && !CB_prefix) TraceCallback(State()); if (TraceCallback != null && !CB_prefix) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
if (Halt_bug_3) if (Halt_bug_3)
{ {
@ -431,7 +432,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
stopped = false; stopped = false;
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null && !CB_prefix) TraceCallback(State()); if (TraceCallback != null && !CB_prefix) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
FetchInstruction(ReadMemory(RegPC++)); FetchInstruction(ReadMemory(RegPC++));
instr_pntr = 0; instr_pntr = 0;
@ -461,7 +462,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
stopped = false; stopped = false;
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null && !CB_prefix) TraceCallback(State()); if (TraceCallback != null && !CB_prefix) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
FetchInstruction(ReadMemory(RegPC++)); FetchInstruction(ReadMemory(RegPC++));
instr_pntr = 0; instr_pntr = 0;
@ -489,7 +490,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
case OP_G: case OP_G:
if (OnExecFetch != null) OnExecFetch(RegPC); if (OnExecFetch != null) OnExecFetch(RegPC);
if (TraceCallback != null) TraceCallback(State()); if (TraceCallback != null) TraceCallback(State());
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst); if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst);
FetchInstruction(ReadMemory(RegPC)); // note no increment FetchInstruction(ReadMemory(RegPC)); // note no increment

View File

@ -10,8 +10,8 @@ namespace BizHawk.Emulation.Common.Components.LR35902
ushort addr = (ushort)(Regs[src_l] | (Regs[src_h]) << 8); ushort addr = (ushort)(Regs[src_l] | (Regs[src_h]) << 8);
if (CDLCallback != null) if (CDLCallback != null)
{ {
if (src_l == PCl) CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_ExecOperand); if (src_l == PCl) CDLCallback(addr, eCDLogMemFlags.FetchOperand);
else CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_Data); else CDLCallback(addr, eCDLogMemFlags.Data);
} }
Regs[dest] = ReadMemory(addr); Regs[dest] = ReadMemory(addr);
} }
@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
public void Write_Func(ushort dest_l, ushort dest_h, ushort src) public void Write_Func(ushort dest_l, ushort dest_h, ushort src)
{ {
ushort addr = (ushort)(Regs[dest_l] | (Regs[dest_h]) << 8); ushort addr = (ushort)(Regs[dest_l] | (Regs[dest_h]) << 8);
if (CDLCallback != null) CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_Data); if (CDLCallback != null) CDLCallback(addr, eCDLogMemFlags.Write | eCDLogMemFlags.Data);
WriteMemory(addr, (byte)Regs[src]); WriteMemory(addr, (byte)Regs[src]);
} }

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
_cdl = cdl; _cdl = cdl;
if (cdl == null) if (cdl == null)
this.cpu.CDLCallback = null; this.cpu.CDLCallback = null;
else this.cpu.CDLCallback = DoCDL; else this.cpu.CDLCallback = CDLCpuCallback;
} }
public void NewCDL(ICodeDataLog cdl) public void NewCDL(ICodeDataLog cdl)
@ -40,16 +40,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
} }
public void DoCDL2(LR35902.eCDLog_Flags flags, string type, int cdladdr) public void SetCDL(LR35902.eCDLogMemFlags flags, string type, int cdladdr)
{ {
if (type == null) return; if (type == null) return;
byte val = (byte)flags;
_cdl[type][cdladdr] |= (byte)flags; _cdl[type][cdladdr] |= (byte)flags;
} }
public void DoCDL(ushort addr, LR35902.eCDLog_Flags flags) void CDLCpuCallback(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
MemoryCallbacks.CallReads(addr, "System Bus"); if (addr < 0x8000)
addr_access = addr; {
//don't record writes to the ROM, it's just noisy
//NOTE: in principle a mapper could mount a useful resource here, but I doubt it)
if ((flags & LR35902.eCDLogMemFlags.Write) != 0) return;
}
if (ppu.DMA_start) if (ppu.DMA_start)
{ {
@ -68,11 +73,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if ((addr >= 0xE000) && (addr < 0xF000)) else if ((addr >= 0xE000) && (addr < 0xF000))
{ {
DoCDL2(flags, "WRAM", addr - 0xE000); SetCDL(flags, "WRAM", addr - 0xE000);
} }
else if ((addr >= 0xF000) && (addr < 0xFE00)) else if ((addr >= 0xF000) && (addr < 0xFE00))
{ {
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000)); SetCDL(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000));
} }
else if ((addr >= 0xFE00) && (addr < 0xFEA0) && ppu.DMA_OAM_access) else if ((addr >= 0xFE00) && (addr < 0xFEA0) && ppu.DMA_OAM_access)
{ {
@ -84,7 +89,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if ((addr >= 0xFF80)) else if ((addr >= 0xFF80))
{ {
DoCDL2(flags, "HRAM", addr - 0xFF80); SetCDL(flags, "HRAM", addr - 0xFF80);
} }
} }
@ -143,15 +148,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if (addr < 0xE000) else if (addr < 0xE000)
{ {
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xD000)); SetCDL(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xD000));
} }
else if (addr < 0xF000) else if (addr < 0xF000)
{ {
DoCDL2(flags, "WRAM", addr - 0xE000); SetCDL(flags, "WRAM", addr - 0xE000);
} }
else if (addr < 0xFE00) else if (addr < 0xFE00)
{ {
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000)); SetCDL(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000));
} }
else if (addr < 0xFEA0) else if (addr < 0xFEA0)
{ {
@ -167,7 +172,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if (addr < 0xFFFF) else if (addr < 0xFFFF)
{ {
DoCDL2(flags, "HRAM", addr - 0xFF80); SetCDL(flags, "HRAM", addr - 0xFF80);
} }
else else
{ {

View File

@ -47,18 +47,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
} }
public virtual void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public virtual void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
} }
protected void SetCDLROM(LR35902.eCDLog_Flags flags, int cdladdr) protected void SetCDLROM(LR35902.eCDLogMemFlags flags, int cdladdr)
{ {
Core.DoCDL2(flags, "ROM", cdladdr); Core.SetCDL(flags, "ROM", cdladdr);
} }
protected void SetCDLRAM(LR35902.eCDLog_Flags flags, int cdladdr) protected void SetCDLRAM(LR35902.eCDLogMemFlags flags, int cdladdr)
{ {
Core.DoCDL2(flags, "CartRAM", cdladdr); Core.SetCDL(flags, "CartRAM", cdladdr);
} }
} }
} }

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -77,7 +77,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -89,7 +89,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -83,7 +83,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -71,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x4000) if (addr < 0x4000)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {

View File

@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
public override void MapCDL(ushort addr, LR35902.eCDLog_Flags flags) public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags)
{ {
if (addr < 0x8000) if (addr < 0x8000)
{ {