C64 - expose tape data as a memory domain, because why not

This commit is contained in:
adelikat 2017-05-28 08:52:16 -05:00
parent 807edebe6d
commit 3a852707c4
5 changed files with 74 additions and 45 deletions

View File

@ -8,8 +8,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
private IMemoryDomains _memoryDomains;
private void SetupMemoryDomains(bool diskDriveEnabled)
private void SetupMemoryDomains()
{
bool diskDriveEnabled = _board.DiskDrive != null;
bool tapeDriveEnabled = _board.TapeDrive != null;
var domains = new List<MemoryDomain>
{
C64MemoryDomainFactory.Create("System Bus", 0x10000, a => _board.Cpu.Peek(a), (a, v) => _board.Cpu.Poke(a, v)),
@ -30,6 +33,15 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
C64MemoryDomainFactory.Create("1541 VIA1", 0x10, a => _board.DiskDrive.PeekVia1(a), (a, v) => _board.DiskDrive.PokeVia1(a, v))
});
}
if (tapeDriveEnabled)
{
domains.AddRange(new[]
{
C64MemoryDomainFactory.Create("Tape Data", _board.TapeDrive.TapeDataDomain.Length, a => _board.TapeDrive.TapeDataDomain[a], (a,v) => _board.TapeDrive.TapeDataDomain[a] = (byte)v)
});
}
_memoryDomains = new MemoryDomainList(domains);
((BasicServiceProvider)ServiceProvider).Register(_memoryDomains);
}

View File

@ -33,8 +33,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType);
_cyclesPerFrame = _board.Vic.CyclesPerFrame;
SetupMemoryDomains(_board.DiskDrive != null);
_memoryCallbacks = new MemoryCallbackSystem();
HardReset();
switch (SyncSettings.VicType)
@ -66,6 +66,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
// There are no multi-cart cart games, so just hardcode .First()
CoreComm.RomStatusDetails = $"{game.Name}\r\nSHA1:{roms.First().HashSHA1()}\r\nMD5:{roms.First().HashMD5()}\r\nMapper Impl \"{_board.CartPort.CartridgeType}\"";
}
SetupMemoryDomains();
}
// Currently we will require at least one rom. If multiple they MUST be all the same media type in the same format

View File

@ -27,5 +27,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
}
public abstract void SyncState(Serializer ser);
// Exposed for memory domains, should not be used for actual emulation implementation
public abstract byte[] TapeDataDomain { get; }
}
}

View File

@ -9,12 +9,18 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
public override void ExecutePhase2()
{
if (_tape != null && !ReadMotor()) _tape.ExecuteCycle();
if (_tape != null && !ReadMotor())
{
_tape.ExecuteCycle();
}
}
public override void HardReset()
{
if (_tape != null) _tape.Rewind();
if (_tape != null)
{
_tape.Rewind();
}
}
public override bool ReadDataInputBuffer()
@ -41,5 +47,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette
{
_tape = null;
}
// Exposed for memory domains, should not be used for actual emulation implementation
public override byte[] TapeDataDomain => _tape.TapeDataDomain;
}
}

View File

@ -100,5 +100,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
ser.Sync("Cycle", ref _cycle);
ser.Sync("Data", ref _data);
}
// Exposed for memory domains, should not be used for actual emulation implementation
public byte[] TapeDataDomain => _tapeData;
}
}