Deduplicate `MemoryDomainDelegateSysBusNES`

This commit is contained in:
YoshiRulz 2023-01-08 07:54:20 +10:00
parent 0bd2a1d89b
commit 16ee704332
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 4 additions and 77 deletions

View File

@ -397,74 +397,9 @@ namespace BizHawk.Emulation.Common
=> _monitor.Exit();
}
public class MemoryDomainDelegateSysBusNES : MemoryDomain
public class MemoryDomainDelegateSysBusNES : MemoryDomainDelegate
{
private Action<long, byte> _poke;
// TODO: use an array of Ranges
private Action<Range<long>, byte[]> _bulkPeekByte { get; set; }
private Action<Range<long>, bool, ushort[]> _bulkPeekUshort { get; set; }
private Action<Range<long>, bool, uint[]> _bulkPeekUint { get; set; }
public Func<long, byte> Peek { get; set; }
public Action<long, byte> Poke
{
get => _poke;
set
{
_poke = value;
Writable = value != null;
}
}
private Action<int, byte, int, int> sendcheattocore { get; set; }
public override byte PeekByte(long addr)
{
return Peek(addr);
}
public override void PokeByte(long addr, byte val)
{
_poke?.Invoke(addr, val);
}
public override void BulkPeekByte(Range<long> addresses, byte[] values)
{
if (_bulkPeekByte != null)
{
_bulkPeekByte.Invoke(addresses, values);
}
else
{
base.BulkPeekByte(addresses, values);
}
}
public override void BulkPeekUshort(Range<long> addresses, bool bigEndian, ushort[] values)
{
if (_bulkPeekUshort != null)
{
_bulkPeekUshort.Invoke(addresses, bigEndian, values);
}
else
{
base.BulkPeekUshort(addresses, bigEndian, values);
}
}
public override void BulkPeekUint(Range<long> addresses, bool bigEndian, uint[] values)
{
if (_bulkPeekUint != null)
{
_bulkPeekUint.Invoke(addresses, bigEndian, values);
}
else
{
base.BulkPeekUint(addresses, bigEndian, values);
}
}
private readonly Action<int, byte, int, int> sendcheattocore;
public override void SendCheatToCore(int addr, byte value, int compare, int comparetype)
{
@ -486,15 +421,7 @@ namespace BizHawk.Emulation.Common
Action<long, byte> poke,
int wordSize,
Action<int, byte, int, int> nescheatpoke = null)
{
Name = name;
EndianType = endian;
Size = size;
Peek = peek;
_poke = poke;
Writable = poke != null;
WordSize = wordSize;
sendcheattocore = nescheatpoke;
}
: base(name, size, endian, peek, poke, wordSize)
=> sendcheattocore = nescheatpoke;
}
}