rough draft gbhawk CDL
This commit is contained in:
parent
7a72bf72e6
commit
a8db56d8b2
|
@ -720,6 +720,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Consoles\Nintendo\GBA\VBARegisterHelper.cs" />
|
||||
<Compile Include="Consoles\Nintendo\GBHawk\Audio.cs" />
|
||||
<Compile Include="Consoles\Nintendo\GBHawk\GBHawk.ICodeDataLog.cs" />
|
||||
<Compile Include="Consoles\Nintendo\GBHawk\Mappers\Mapper_WisdomTree.cs" />
|
||||
<Compile Include="Consoles\Nintendo\GBHawk\Mappers\Mapper_RockMan8.cs" />
|
||||
<Compile Include="Consoles\Nintendo\GBHawk\Mappers\Mapper_Sachen_MMC2.cs" />
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
public const ushort RLC = 14;
|
||||
public const ushort RL = 15;
|
||||
public const ushort RRC = 16;
|
||||
public const ushort RR = 17;
|
||||
public const ushort RR = 17;
|
||||
public const ushort CPL = 18;
|
||||
public const ushort DA = 19;
|
||||
public const ushort SCF = 20;
|
||||
|
@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
public const ushort SWAP = 29;
|
||||
public const ushort BIT = 30;
|
||||
public const ushort RES = 31;
|
||||
public const ushort SET = 32;
|
||||
public const ushort SET = 32;
|
||||
public const ushort EI = 33;
|
||||
public const ushort DI = 34;
|
||||
public const ushort HALT = 35;
|
||||
|
@ -108,6 +108,18 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
this.WriteMemory = WriteMemory;
|
||||
}
|
||||
|
||||
//a little CDL related stuff
|
||||
public delegate void DoCDLCallbackType(ushort addr, LR35902.eCDLog_Flags flags);
|
||||
|
||||
public DoCDLCallbackType CDLCallback;
|
||||
|
||||
public enum eCDLog_Flags
|
||||
{
|
||||
eCDLog_Flags_ExecFirst = 1,
|
||||
eCDLog_Flags_ExecOperand = 2,
|
||||
eCDLog_Flags_Data = 4,
|
||||
};
|
||||
|
||||
// Execute instructions
|
||||
public void ExecuteOne(ref byte interrupt_src, byte interrupt_enable)
|
||||
{
|
||||
|
@ -117,7 +129,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
// do nothing
|
||||
break;
|
||||
case OP:
|
||||
// Read the opcode of the next instruction
|
||||
// Read the opcode of the next instruction
|
||||
if (EI_pending > 0 && !CB_prefix)
|
||||
{
|
||||
EI_pending--;
|
||||
|
@ -148,6 +160,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
{
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null && !CB_prefix) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
FetchInstruction(ReadMemory(RegPC++));
|
||||
}
|
||||
instr_pntr = 0;
|
||||
|
@ -333,6 +346,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
{
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null && !CB_prefix) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
|
||||
RegPC++;
|
||||
FetchInstruction(ReadMemory(RegPC));
|
||||
|
@ -348,10 +362,11 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
OP };
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null && !CB_prefix) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
|
||||
if (Halt_bug_3)
|
||||
{
|
||||
|
@ -416,6 +431,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
stopped = false;
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null && !CB_prefix) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
FetchInstruction(ReadMemory(RegPC++));
|
||||
instr_pntr = 0;
|
||||
|
||||
|
@ -445,6 +461,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
stopped = false;
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null && !CB_prefix) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
FetchInstruction(ReadMemory(RegPC++));
|
||||
instr_pntr = 0;
|
||||
|
||||
|
@ -472,6 +489,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
case OP_G:
|
||||
if (OnExecFetch != null) OnExecFetch(RegPC);
|
||||
if (TraceCallback != null) TraceCallback(State());
|
||||
if (CDLCallback != null) CDLCallback(RegPC, eCDLog_Flags.eCDLog_Flags_ExecFirst);
|
||||
|
||||
FetchInstruction(ReadMemory(RegPC)); // note no increment
|
||||
|
||||
|
|
|
@ -7,7 +7,13 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
{
|
||||
public void Read_Func(ushort dest, ushort src_l, ushort src_h)
|
||||
{
|
||||
Regs[dest] = ReadMemory((ushort)(Regs[src_l] | (Regs[src_h]) << 8));
|
||||
ushort addr = (ushort)(Regs[src_l] | (Regs[src_h]) << 8);
|
||||
if (CDLCallback != null)
|
||||
{
|
||||
if (src_l == PCl) CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_ExecOperand);
|
||||
else CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_Data);
|
||||
}
|
||||
Regs[dest] = ReadMemory(addr);
|
||||
}
|
||||
|
||||
// speical read for POP AF that always clears the lower 4 bits of F
|
||||
|
@ -18,7 +24,9 @@ namespace BizHawk.Emulation.Common.Components.LR35902
|
|||
|
||||
public void Write_Func(ushort dest_l, ushort dest_h, ushort src)
|
||||
{
|
||||
WriteMemory((ushort)(Regs[dest_l] | (Regs[dest_h]) << 8), (byte)Regs[src]);
|
||||
ushort addr = (ushort)(Regs[dest_l] | (Regs[dest_h]) << 8);
|
||||
if (CDLCallback != null) CDLCallback(addr, eCDLog_Flags.eCDLog_Flags_Data);
|
||||
WriteMemory(addr, (byte)Regs[src]);
|
||||
}
|
||||
|
||||
public void TR_Func(ushort dest, ushort src)
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components.LR35902;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||
{
|
||||
public partial class GBHawk : ICodeDataLogger
|
||||
{
|
||||
private ICodeDataLog _cdl;
|
||||
|
||||
public void SetCDL(ICodeDataLog cdl)
|
||||
{
|
||||
_cdl = cdl;
|
||||
if (cdl == null)
|
||||
this.cpu.CDLCallback = null;
|
||||
else this.cpu.CDLCallback = DoCDL;
|
||||
}
|
||||
|
||||
public void NewCDL(ICodeDataLog cdl)
|
||||
{
|
||||
cdl["ROM"] = new byte[MemoryDomains["ROM"].Size];
|
||||
cdl["HRAM"] = new byte[MemoryDomains["Zero Page RAM"].Size];
|
||||
|
||||
cdl["WRAM"] = new byte[MemoryDomains["Main RAM"].Size];
|
||||
|
||||
if (MemoryDomains.Has("Cart RAM"))
|
||||
{
|
||||
cdl["CartRAM"] = new byte[MemoryDomains["Cart RAM"].Size];
|
||||
}
|
||||
|
||||
cdl.SubType = "GB";
|
||||
cdl.SubVer = 0;
|
||||
}
|
||||
|
||||
[FeatureNotImplemented]
|
||||
void ICodeDataLogger.DisassembleCDL(Stream s, ICodeDataLog cdl)
|
||||
{
|
||||
}
|
||||
|
||||
public void DoCDL2(LR35902.eCDLog_Flags flags, string type, int cdladdr)
|
||||
{
|
||||
if (type == null) return;
|
||||
_cdl[type][cdladdr] |= (byte)flags;
|
||||
}
|
||||
|
||||
public void DoCDL(ushort addr, LR35902.eCDLog_Flags flags)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
addr_access = addr;
|
||||
|
||||
if (ppu.DMA_start)
|
||||
{
|
||||
// some of gekkio's tests require these to be accessible during DMA
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
if (ppu.DMA_addr < 0x80)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return; mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ((addr >= 0xE000) && (addr < 0xF000))
|
||||
{
|
||||
DoCDL2(flags, "WRAM", addr - 0xE000);
|
||||
}
|
||||
else if ((addr >= 0xF000) && (addr < 0xFE00))
|
||||
{
|
||||
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000));
|
||||
}
|
||||
else if ((addr >= 0xFE00) && (addr < 0xFEA0) && ppu.DMA_OAM_access)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ((addr >= 0xFF00) && (addr < 0xFF80)) // The game GOAL! Requires Hardware Regs to be accessible
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ((addr >= 0xFF80))
|
||||
{
|
||||
DoCDL2(flags, "HRAM", addr - 0xFF80);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (addr < 0x900)
|
||||
{
|
||||
if (addr < 0x100)
|
||||
{
|
||||
// return Either BIOS ROM or Game ROM
|
||||
if ((GB_bios_register & 0x1) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (addr >= 0x200)
|
||||
{
|
||||
// return Either BIOS ROM or Game ROM
|
||||
if (((GB_bios_register & 0x1) == 0) && is_GBC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//return mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (addr < 0x8000)
|
||||
{
|
||||
//return mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xA000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xC000)
|
||||
{
|
||||
//return mapper.ReadMemory(addr);
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xD000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xE000)
|
||||
{
|
||||
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xD000));
|
||||
}
|
||||
else if (addr < 0xF000)
|
||||
{
|
||||
DoCDL2(flags, "WRAM", addr - 0xE000);
|
||||
}
|
||||
else if (addr < 0xFE00)
|
||||
{
|
||||
DoCDL2(flags, "WRAM", (RAM_Bank * 0x1000) + (addr - 0xF000));
|
||||
}
|
||||
else if (addr < 0xFEA0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xFF00)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xFF80)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (addr < 0xFFFF)
|
||||
{
|
||||
DoCDL2(flags, "HRAM", addr - 0xFF80);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
else
|
||||
{
|
||||
return Core._rom[addr];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (addr < 0x8000)
|
||||
{
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
else if (addr < 0xFEA0)
|
||||
{
|
||||
if (ppu.OAM_access_read) { return OAM[addr - 0xFE00]; }
|
||||
else { return 0xFF; }
|
||||
else { return 0xFF; }
|
||||
}
|
||||
else if (addr < 0xFF00)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue