[ChannelFHawk] ICodeDataLogger
This commit is contained in:
parent
4c69ce4e27
commit
e0264ed102
|
@ -7,7 +7,9 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public readonly struct CpuLink(ChannelF channelF) : IF3850Link
|
||||
{
|
||||
public byte ReadMemory(ushort address)
|
||||
=> channelF.ReadBus(address);
|
||||
=> channelF._cdl == null
|
||||
? channelF.ReadBus(address)
|
||||
: channelF.ReadMemory_CDL(address);
|
||||
|
||||
public void WriteMemory(ushort address, byte value)
|
||||
=> channelF.WriteBus(address, value);
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
||||
{
|
||||
public partial class ChannelF : ICodeDataLogger
|
||||
{
|
||||
private ICodeDataLog _cdl;
|
||||
|
||||
public void SetCDL(ICodeDataLog cdl)
|
||||
{
|
||||
_cdl = cdl;
|
||||
}
|
||||
|
||||
public void NewCDL(ICodeDataLog cdl)
|
||||
{
|
||||
void AddIfExists(string name)
|
||||
{
|
||||
var found = _memoryDomains[name];
|
||||
if (found is not null) cdl[name] = new byte[found.Size];
|
||||
}
|
||||
|
||||
cdl["System Bus"] = new byte[_memoryDomains["System Bus"]!.Size];
|
||||
|
||||
AddIfExists("BIOS1");
|
||||
AddIfExists("BIOS2");
|
||||
AddIfExists("ROM");
|
||||
|
||||
cdl.SubType = "ChannelF";
|
||||
cdl.SubVer = 0;
|
||||
}
|
||||
|
||||
[FeatureNotImplemented]
|
||||
public void DisassembleCDL(Stream s, ICodeDataLog cdl)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public enum CDLType
|
||||
{
|
||||
None,
|
||||
BIOS1,
|
||||
BIOS2,
|
||||
CARTROM
|
||||
}
|
||||
|
||||
public struct CDLResult
|
||||
{
|
||||
public CDLType Type;
|
||||
public int Address;
|
||||
}
|
||||
|
||||
private byte ReadMemory_CDL(ushort addr)
|
||||
{
|
||||
var mapping = ReadCDL(addr);
|
||||
var res = mapping.Type;
|
||||
var address = mapping.Address;
|
||||
|
||||
byte data = ReadBus(addr);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case CDLType.None:
|
||||
default:
|
||||
// shouldn't get here
|
||||
break;
|
||||
|
||||
case CDLType.BIOS1:
|
||||
_cdl["BIOS1"][address] = data;
|
||||
break;
|
||||
|
||||
case CDLType.BIOS2:
|
||||
_cdl["BIOS2"][address] = data;
|
||||
break;
|
||||
|
||||
case CDLType.CARTROM:
|
||||
_cdl["ROM"][address] = data;
|
||||
break;
|
||||
}
|
||||
|
||||
// update the system bus as well
|
||||
// because why not
|
||||
_cdl["System Bus"][addr] = data;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,30 @@
|
|||
}
|
||||
}
|
||||
|
||||
public CDLResult ReadCDL(ushort addr)
|
||||
{
|
||||
var result = new CDLResult();
|
||||
int divisor = addr / 0x400;
|
||||
result.Address = addr % 0x400;
|
||||
|
||||
switch (divisor)
|
||||
{
|
||||
case 0:
|
||||
result.Type = CDLType.BIOS1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
result.Type = CDLType.BIOS2;
|
||||
break;
|
||||
|
||||
default:
|
||||
result.Type = CDLType.CARTROM;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates writing a byte of data to the address space (in its default configuration, there is no writeable RAM in the
|
||||
/// Channel F addressable through the address space)
|
||||
|
|
Loading…
Reference in New Issue