From fa9c581d19aca402bb22edf496ea0086e7269b83 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:48:34 -0700 Subject: [PATCH] [ChannelFHawk] Expose scratchpad registers as a memory domain This more or less acts like memory for the ChannelF in practice, due to the actual console lacking RAM. Using debugger apis is very annoying for peeking at these registers and of course you can't just use RAM Watch or the Hex Editor with it locked to debugger apis --- .../ChannelF/ChannelF.MemoryDomains.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs index 62353990dd..58e071710c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs @@ -7,16 +7,27 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF { public partial class ChannelF { - internal IMemoryDomains memoryDomains; - private readonly Dictionary _byteArrayDomains = new Dictionary(); - private bool _memoryDomainsInit = false; + private IMemoryDomains _memoryDomains; + private readonly Dictionary _byteArrayDomains = [ ]; + private bool _memoryDomainsInit; private void SetupMemoryDomains() { var domains = new List { + new MemoryDomainDelegate("Scratchpad", 64, MemoryDomain.Endian.Big, + addr => + { + if (addr is < 0 or > 63) throw new ArgumentOutOfRangeException(paramName: nameof(addr), addr, message: "address out of range"); + return CPU.Regs[addr]; + }, + (addr, value) => + { + if (addr is < 0 or > 63) throw new ArgumentOutOfRangeException(paramName: nameof(addr), addr, message: "address out of range"); + CPU.Regs[addr] = value; + }, 1), new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Big, - (addr) => + addr => { if (addr is < 0 or > 0xFFFF) throw new ArgumentOutOfRangeException(paramName: nameof(addr), addr, message: "address out of range"); return ReadBus((ushort)addr); @@ -30,8 +41,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF SyncAllByteArrayDomains(); - memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); - (ServiceProvider as BasicServiceProvider)?.Register(memoryDomains); + _memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()) { MainMemory = domains[0] }; + ((BasicServiceProvider)ServiceProvider).Register(_memoryDomains); _memoryDomainsInit = true; }