Break a bunch of memory domain stuff with pointless refactoring
This commit is contained in:
parent
71e32bc3d9
commit
111648cf98
|
@ -229,7 +229,7 @@ namespace BizHawk.Client.Common
|
|||
var d = (string.IsNullOrEmpty(domain)) ? Domain : DomainList[VerifyMemoryDomain(domain)];
|
||||
if (addr < d.Size)
|
||||
{
|
||||
var val = d.PeekDWord(addr, bigendian);
|
||||
var val = d.PeekUint(addr, bigendian);
|
||||
var bytes = BitConverter.GetBytes(val);
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ namespace BizHawk.Client.Common
|
|||
var dv = (float)value;
|
||||
var bytes = BitConverter.GetBytes(dv);
|
||||
var v = BitConverter.ToUInt32(bytes, 0);
|
||||
d.PokeDWord(addr, v, bigendian);
|
||||
d.PokeUint(addr, v, bigendian);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -888,11 +888,11 @@ namespace BizHawk.Client.Common
|
|||
return theByte;
|
||||
|
||||
case WatchSize.Word:
|
||||
var theWord = _settings.Domain.PeekWord(addr % Domain.Size, _settings.BigEndian);
|
||||
var theWord = _settings.Domain.PeekUshort(addr % Domain.Size, _settings.BigEndian);
|
||||
return theWord;
|
||||
|
||||
case WatchSize.DWord:
|
||||
var theDWord = _settings.Domain.PeekDWord(addr % Domain.Size, _settings.BigEndian);
|
||||
var theDWord = _settings.Domain.PeekUint(addr % Domain.Size, _settings.BigEndian);
|
||||
return theDWord;
|
||||
}
|
||||
}
|
||||
|
@ -958,7 +958,7 @@ namespace BizHawk.Client.Common
|
|||
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
_previous = domain.PeekWord(Address % domain.Size, bigEndian);
|
||||
_previous = domain.PeekUshort(Address % domain.Size, bigEndian);
|
||||
}
|
||||
|
||||
public long Previous
|
||||
|
@ -968,7 +968,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
_previous = domain.PeekWord(Address, bigendian);
|
||||
_previous = domain.PeekUshort(Address, bigendian);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -980,7 +980,7 @@ namespace BizHawk.Client.Common
|
|||
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
_previous = domain.PeekDWord(Address % domain.Size, bigEndian);
|
||||
_previous = domain.PeekUint(Address % domain.Size, bigEndian);
|
||||
}
|
||||
|
||||
public long Previous
|
||||
|
@ -990,7 +990,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
_previous = domain.PeekDWord(Address, bigendian);
|
||||
_previous = domain.PeekUint(Address, bigendian);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,7 +1071,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
_previous = _prevFrame = domain.PeekWord(Address % domain.Size, bigendian);
|
||||
_previous = _prevFrame = domain.PeekUshort(Address % domain.Size, bigendian);
|
||||
}
|
||||
|
||||
public long Previous
|
||||
|
@ -1086,7 +1086,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Update(PreviousType type, MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
var value = domain.PeekWord(Address % domain.Size, bigendian);
|
||||
var value = domain.PeekUshort(Address % domain.Size, bigendian);
|
||||
if (value != Previous)
|
||||
{
|
||||
_changecount++;
|
||||
|
@ -1131,7 +1131,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
_previous = _prevFrame = domain.PeekDWord(Address % domain.Size, bigendian);
|
||||
_previous = _prevFrame = domain.PeekUint(Address % domain.Size, bigendian);
|
||||
}
|
||||
|
||||
public long Previous
|
||||
|
@ -1146,7 +1146,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Update(PreviousType type, MemoryDomain domain, bool bigendian)
|
||||
{
|
||||
var value = domain.PeekDWord(Address % domain.Size, bigendian);
|
||||
var value = domain.PeekUint(Address % domain.Size, bigendian);
|
||||
if (value != Previous)
|
||||
{
|
||||
_changecount++;
|
||||
|
@ -1180,7 +1180,7 @@ namespace BizHawk.Client.Common
|
|||
public Settings(IMemoryDomains memoryDomains)
|
||||
{
|
||||
BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
|
||||
Size = (WatchSize)memoryDomains.MainMemory.ByteSize;
|
||||
Size = (WatchSize)memoryDomains.MainMemory.WordSize;
|
||||
Type = DisplayType.Unsigned;
|
||||
Mode = memoryDomains.MainMemory.Size > (1024 * 1024) ?
|
||||
SearchMode.Fast :
|
||||
|
|
|
@ -373,11 +373,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (_domain.Size == 0)
|
||||
{
|
||||
return _domain.PeekWord(_address, _bigEndian);
|
||||
return _domain.PeekUshort(_address, _bigEndian);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _domain.PeekWord(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
return _domain.PeekUshort(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,11 +393,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (_domain.Size == 0)
|
||||
{
|
||||
return _domain.PeekDWord(_address, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
return _domain.PeekUint(_address, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
}
|
||||
else
|
||||
{
|
||||
return _domain.PeekDWord(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
return _domain.PeekUint(_address % _domain.Size, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,15 +412,15 @@ namespace BizHawk.Client.Common
|
|||
protected void PokeWord(ushort val)
|
||||
{
|
||||
if (_domain.Size == 0)
|
||||
_domain.PokeWord(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
else _domain.PokeWord(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
_domain.PokeUshort(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
else _domain.PokeUshort(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
}
|
||||
|
||||
protected void PokeDWord(uint val)
|
||||
{
|
||||
if (_domain.Size == 0)
|
||||
_domain.PokeDWord(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
else _domain.PokeDWord(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
_domain.PokeUint(_address, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
else _domain.PokeUint(_address % _domain.Size, val, _bigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain
|
||||
}
|
||||
|
||||
#endregion Protected
|
||||
|
|
|
@ -873,10 +873,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
val = _currentDomain.PeekByte(addr);
|
||||
break;
|
||||
case 2:
|
||||
val = _currentDomain.PeekWord(addr, _bigEndian);
|
||||
val = _currentDomain.PeekUshort(addr, _bigEndian);
|
||||
break;
|
||||
case 4:
|
||||
val = (int)_currentDomain.PeekDWord(addr, _bigEndian);
|
||||
val = (int)_currentDomain.PeekUint(addr, _bigEndian);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
// int to long TODO: 32 bit domains have more digits than the hex editor can account for and the address covers up the 0 column
|
||||
public partial class HexEditor : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private class NullMemoryDomain : MemoryDomain
|
||||
{
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
}
|
||||
|
||||
public NullMemoryDomain()
|
||||
{
|
||||
EndianType = Endian.Unknown;
|
||||
Name = "Null";
|
||||
Size = 1024;
|
||||
Writable = true;
|
||||
WordSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RequiredService]
|
||||
private IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
|
@ -47,8 +69,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private long _maxRow;
|
||||
|
||||
private MemoryDomain _domain = new MemoryDomain(
|
||||
"NULL", 1024, MemoryDomain.Endian.Little, addr => 0, delegate(long a, byte v) { v = 0; });
|
||||
private MemoryDomain _domain = new NullMemoryDomain();
|
||||
|
||||
private long _row;
|
||||
private long _addr;
|
||||
|
@ -429,7 +450,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void HexEditor_Load(object sender, EventArgs e)
|
||||
{
|
||||
DataSize = _domain.ByteSize;
|
||||
DataSize = _domain.WordSize;
|
||||
SetDataSize(DataSize);
|
||||
|
||||
if (RecentTables.AutoLoad)
|
||||
|
@ -555,9 +576,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
case 1:
|
||||
return _domain.PeekByte(address);
|
||||
case 2:
|
||||
return _domain.PeekWord(address, BigEndian);
|
||||
return _domain.PeekUshort(address, BigEndian);
|
||||
case 4:
|
||||
return (int)_domain.PeekDWord(address, BigEndian);
|
||||
return (int)_domain.PeekUint(address, BigEndian);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1096,15 +1117,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
(byte)(_domain.PeekByte(address) + 1));
|
||||
break;
|
||||
case 2:
|
||||
_domain.PokeWord(
|
||||
_domain.PokeUshort(
|
||||
address,
|
||||
(ushort)(_domain.PeekWord(address, BigEndian) + 1),
|
||||
(ushort)(_domain.PeekUshort(address, BigEndian) + 1),
|
||||
BigEndian);
|
||||
break;
|
||||
case 4:
|
||||
_domain.PokeDWord(
|
||||
_domain.PokeUint(
|
||||
address,
|
||||
_domain.PeekDWord(address, BigEndian) + 1,
|
||||
_domain.PeekUint(address, BigEndian) + 1,
|
||||
BigEndian);
|
||||
break;
|
||||
}
|
||||
|
@ -1129,15 +1150,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
(byte)(_domain.PeekByte(address) - 1));
|
||||
break;
|
||||
case 2:
|
||||
_domain.PokeWord(
|
||||
_domain.PokeUshort(
|
||||
address,
|
||||
(ushort)(_domain.PeekWord(address, BigEndian) - 1),
|
||||
(ushort)(_domain.PeekUshort(address, BigEndian) - 1),
|
||||
BigEndian);
|
||||
break;
|
||||
case 4:
|
||||
_domain.PokeDWord(
|
||||
_domain.PokeUint(
|
||||
address,
|
||||
_domain.PeekDWord(address, BigEndian) - 1,
|
||||
_domain.PeekUint(address, BigEndian) - 1,
|
||||
BigEndian);
|
||||
break;
|
||||
}
|
||||
|
@ -2293,8 +2314,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
ushort hi = _domain.PeekWord(((addr+(i<<3)+(j<<1) )^0x0),bigend);
|
||||
ushort lo = _domain.PeekWord(((addr+(i<<3)+(j<<1) + 32)^0x0),bigend);
|
||||
ushort hi = _domain.PeekUshort(((addr+(i<<3)+(j<<1) )^0x0),bigend);
|
||||
ushort lo = _domain.PeekUshort(((addr+(i<<3)+(j<<1) + 32)^0x0),bigend);
|
||||
matVals[i,j] = (int)(((hi << 16) | lo)) / 65536.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
default:
|
||||
case Mode.New:
|
||||
switch (MemoryDomains.First().ByteSize)
|
||||
switch (MemoryDomains.First().WordSize)
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
|
|
|
@ -5,37 +5,23 @@ using System.Collections.ObjectModel;
|
|||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public class MemoryDomain
|
||||
public abstract class MemoryDomain
|
||||
{
|
||||
public enum Endian { Big, Little, Unknown }
|
||||
|
||||
public MemoryDomain(string name, long size, Endian endian, Func<long, byte> peekByte, Action<long, byte> pokeByte, int byteSize = 1)
|
||||
{
|
||||
Name = name;
|
||||
Size = size;
|
||||
ByteSize = byteSize;
|
||||
EndianType = endian;
|
||||
PeekByte = peekByte;
|
||||
PokeByte = pokeByte;
|
||||
}
|
||||
public string Name { get; protected set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
public long Size { get; protected set; }
|
||||
|
||||
public long Size { get; private set; }
|
||||
public int WordSize { get; protected set; }
|
||||
|
||||
public int ByteSize { get; private set; }
|
||||
public Endian EndianType { get; protected set; }
|
||||
|
||||
public Endian EndianType { get; private set; }
|
||||
public bool Writable { get; protected set; }
|
||||
|
||||
public Func<long, byte> PeekByte { get; private set; }
|
||||
public abstract byte PeekByte(long addr);
|
||||
|
||||
public Action<long, byte> PokeByte { get; private set; }
|
||||
|
||||
public void SetPeekPokeDelegates(Func<long, byte> peeker, Action<long, byte> poker)
|
||||
{
|
||||
PeekByte = peeker;
|
||||
PokeByte = poker;
|
||||
}
|
||||
public abstract void PokeByte(long addr, byte val);
|
||||
|
||||
/// <summary>
|
||||
/// creates a memorydomain that references a managed byte array
|
||||
|
@ -45,59 +31,10 @@ namespace BizHawk.Emulation.Common
|
|||
/// <param name="data"></param>
|
||||
/// <param name="writable">if false, writes will be ignored</param>
|
||||
/// <returns></returns>
|
||||
public static MemoryDomain FromByteArray(string name, Endian endian, byte[] data, bool writable = true, int byteSize = 1)
|
||||
[Obsolete]
|
||||
public static MemoryDomain FromByteArray(string name, Endian endian, byte[] data, bool writable = true, int wordSize = 1)
|
||||
{
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
return new MemoryDomain
|
||||
(
|
||||
name,
|
||||
data.Length,
|
||||
endian,
|
||||
delegate(long addr)
|
||||
{
|
||||
return data[addr];
|
||||
},
|
||||
writable ?
|
||||
delegate(long addr, byte val)
|
||||
{
|
||||
data[addr] = val;
|
||||
}
|
||||
: (Action<long, byte>)null,
|
||||
byteSize
|
||||
);
|
||||
}
|
||||
|
||||
public void SetDelegatesForIntPtr(long size, Endian endian, IntPtr data, bool writable = true, int byteSize = 1)
|
||||
{
|
||||
Func<long, byte> peeker;
|
||||
Action<long, byte> poker;
|
||||
CreateDelegatesForIntPtr(size, endian, data, out peeker, out poker, writable, byteSize);
|
||||
PeekByte = peeker;
|
||||
PokeByte = poker;
|
||||
}
|
||||
|
||||
public unsafe static void CreateDelegatesForIntPtr(long size, Endian endian, IntPtr data, out Func<long, byte> peeker, out Action<long, byte> poker, bool writable = true, int byteSize = 1)
|
||||
{
|
||||
byte* p = (byte*)data;
|
||||
uint l = (uint)size;
|
||||
|
||||
peeker = delegate(long addr)
|
||||
{
|
||||
if ((uint)addr >= l)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
return p[addr];
|
||||
};
|
||||
|
||||
poker =
|
||||
writable ?
|
||||
delegate(long addr, byte val)
|
||||
{
|
||||
if ((uint)addr >= l)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
p[addr] = val;
|
||||
}
|
||||
: (Action<long, byte>)null;
|
||||
return new MemoryDomainByteArray(name, endian, data, writable, wordSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -106,16 +43,10 @@ namespace BizHawk.Emulation.Common
|
|||
/// <param name="data">must remain valid as long as the MemoryDomain exists!</param>
|
||||
/// <param name="writable">if false, writes will be ignored</param>
|
||||
/// <returns></returns>
|
||||
public unsafe static MemoryDomain FromIntPtr(string name, long size, Endian endian, IntPtr data, bool writable = true, int byteSize = 1)
|
||||
[Obsolete]
|
||||
public unsafe static MemoryDomain FromIntPtr(string name, long size, Endian endian, IntPtr data, bool writable = true, int wordSize = 1)
|
||||
{
|
||||
if (data == IntPtr.Zero)
|
||||
throw new ArgumentNullException("data");
|
||||
if ((ulong)size >= 0x80000000)
|
||||
throw new ArgumentOutOfRangeException("size");
|
||||
|
||||
var md = new MemoryDomain(name,size,endian, null, null, byteSize);
|
||||
md.SetDelegatesForIntPtr(size, endian, data, writable, byteSize);
|
||||
return md;
|
||||
return new MemoryDomainIntPtr(name, endian, data, size, writable, wordSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -124,35 +55,10 @@ namespace BizHawk.Emulation.Common
|
|||
/// <param name="data">must remain valid as long as the MemoryDomain exists!</param>
|
||||
/// <param name="writable">if false, writes will be ignored</param>
|
||||
/// <returns></returns>
|
||||
public unsafe static MemoryDomain FromIntPtrSwap16(string name, long size, Endian endian, IntPtr data, bool writable = true, int byteSize = 1)
|
||||
[Obsolete]
|
||||
public unsafe static MemoryDomain FromIntPtrSwap16(string name, long size, Endian endian, IntPtr data, bool writable = true)
|
||||
{
|
||||
if (data == IntPtr.Zero)
|
||||
throw new ArgumentNullException("data");
|
||||
if ((ulong)size >= 0x80000000)
|
||||
throw new ArgumentOutOfRangeException("size");
|
||||
byte* p = (byte*)data;
|
||||
uint l = (uint)size;
|
||||
return new MemoryDomain
|
||||
(
|
||||
name,
|
||||
size,
|
||||
endian,
|
||||
delegate(long addr)
|
||||
{
|
||||
if ((uint)addr >= l)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
return p[addr ^ 1];
|
||||
},
|
||||
writable ?
|
||||
delegate(long addr, byte val)
|
||||
{
|
||||
if ((uint)addr >= l)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
p[addr ^ 1] = val;
|
||||
}
|
||||
: (Action<long, byte>)null,
|
||||
byteSize
|
||||
);
|
||||
return new MemoryDomainIntPtrSwap16(name, endian, data, size, writable);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -160,7 +66,7 @@ namespace BizHawk.Emulation.Common
|
|||
return Name;
|
||||
}
|
||||
|
||||
public ushort PeekWord(long addr, bool bigEndian)
|
||||
public virtual ushort PeekUshort(long addr, bool bigEndian)
|
||||
{
|
||||
Endian endian = bigEndian ? Endian.Big : Endian.Little;
|
||||
switch (endian)
|
||||
|
@ -173,7 +79,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
|
||||
public uint PeekDWord(long addr, bool bigEndian)
|
||||
public virtual uint PeekUint(long addr, bool bigEndian)
|
||||
{
|
||||
Endian endian = bigEndian ? Endian.Big : Endian.Little;
|
||||
switch (endian)
|
||||
|
@ -192,7 +98,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
|
||||
public void PokeWord(long addr, ushort val, bool bigEndian)
|
||||
public virtual void PokeUshort(long addr, ushort val, bool bigEndian)
|
||||
{
|
||||
Endian endian = bigEndian ? Endian.Big : Endian.Little;
|
||||
switch (endian)
|
||||
|
@ -209,7 +115,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
|
||||
public void PokeDWord(long addr, uint val, bool bigEndian)
|
||||
public virtual void PokeUint(long addr, uint val, bool bigEndian)
|
||||
{
|
||||
Endian endian = bigEndian ? Endian.Big : Endian.Little;
|
||||
switch (endian)
|
||||
|
@ -230,84 +136,4 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MemoryDomainList : ReadOnlyCollection<MemoryDomain>, IMemoryDomains
|
||||
{
|
||||
private MemoryDomain _mainMemory;
|
||||
private MemoryDomain _systemBus;
|
||||
|
||||
public bool Has(string name)
|
||||
{
|
||||
return this.FirstOrDefault((md) => md.Name == name) != null;
|
||||
}
|
||||
|
||||
public MemoryDomainList(IList<MemoryDomain> domains)
|
||||
: base(domains)
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryDomain this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomain MainMemory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_mainMemory != null)
|
||||
{
|
||||
return _mainMemory;
|
||||
}
|
||||
|
||||
return this.First();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_mainMemory = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSystemBus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.Any(x => x.Name == "System Bus");
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomain SystemBus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return _systemBus;
|
||||
}
|
||||
|
||||
var bus = this.FirstOrDefault(x => x.Name == "System Bus");
|
||||
|
||||
if (bus != null)
|
||||
{
|
||||
return bus;
|
||||
}
|
||||
|
||||
return MainMemory;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_systemBus = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public class MemoryDomainDelegate : MemoryDomain
|
||||
{
|
||||
private Func<long, byte> _peek;
|
||||
private Action<long, byte> _poke;
|
||||
|
||||
public Func<long, byte> Peek { get { return _peek; } set { _peek = value; } }
|
||||
public Action<long, byte> Poke { get { return _poke; } set { _poke = value; Writable = value != null; } }
|
||||
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
return _peek(addr);
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
if (_poke != null)
|
||||
_poke(addr, val);
|
||||
}
|
||||
|
||||
public MemoryDomainDelegate(string name, long size, Endian endian, Func<long, byte> peek, Action<long, byte> poke, int wordSize)
|
||||
{
|
||||
Name = name;
|
||||
EndianType = endian;
|
||||
Size = size;
|
||||
_peek = peek;
|
||||
_poke = poke;
|
||||
Writable = poke != null;
|
||||
}
|
||||
}
|
||||
|
||||
public class MemoryDomainByteArray : MemoryDomain
|
||||
{
|
||||
private byte[] _data;
|
||||
|
||||
public byte[] Data { get { return _data; } set { _data = value; Size = _data.LongLength; } }
|
||||
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
return Data[addr];
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
if (Writable)
|
||||
Data[addr] = val;
|
||||
}
|
||||
|
||||
public MemoryDomainByteArray(string name, Endian endian, byte[] data, bool writable, int wordSize)
|
||||
{
|
||||
Name = name;
|
||||
EndianType = endian;
|
||||
Data = data;
|
||||
Writable = writable;
|
||||
WordSize = wordSize;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe class MemoryDomainIntPtr : MemoryDomain
|
||||
{
|
||||
public IntPtr Data { get; set; }
|
||||
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
if ((ulong)addr >= (ulong)Size)
|
||||
return ((byte*)Data)[addr];
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
if (Writable)
|
||||
{
|
||||
if ((ulong)addr >= (ulong)Size)
|
||||
((byte*)Data)[addr] = val;
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomainIntPtr(string name, Endian endian, IntPtr data, long size, bool writable, int wordSize)
|
||||
{
|
||||
Name = name;
|
||||
EndianType = endian;
|
||||
Data = data;
|
||||
Size = size;
|
||||
Writable = writable;
|
||||
WordSize = wordSize;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe class MemoryDomainIntPtrSwap16 : MemoryDomain
|
||||
{
|
||||
public IntPtr Data { get; set; }
|
||||
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
if ((ulong)addr >= (ulong)Size)
|
||||
return ((byte*)Data)[addr ^ 1];
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
if (Writable)
|
||||
{
|
||||
if ((ulong)addr >= (ulong)Size)
|
||||
((byte*)Data)[addr ^ 1] = val;
|
||||
else
|
||||
throw new ArgumentOutOfRangeException("addr");
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomainIntPtrSwap16(string name, Endian endian, IntPtr data, long size, bool writable)
|
||||
{
|
||||
Name = name;
|
||||
EndianType = endian;
|
||||
Data = data;
|
||||
Size = size;
|
||||
Writable = writable;
|
||||
WordSize = 2;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public class MemoryDomainList : ReadOnlyCollection<MemoryDomain>, IMemoryDomains
|
||||
{
|
||||
private MemoryDomain _mainMemory;
|
||||
private MemoryDomain _systemBus;
|
||||
|
||||
public bool Has(string name)
|
||||
{
|
||||
return this.FirstOrDefault((md) => md.Name == name) != null;
|
||||
}
|
||||
|
||||
public MemoryDomainList(IList<MemoryDomain> domains)
|
||||
: base(domains)
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryDomain this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomain MainMemory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_mainMemory != null)
|
||||
{
|
||||
return _mainMemory;
|
||||
}
|
||||
|
||||
return this.First();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_mainMemory = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSystemBus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.Any(x => x.Name == "System Bus");
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryDomain SystemBus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return _systemBus;
|
||||
}
|
||||
|
||||
var bus = this.FirstOrDefault(x => x.Name == "System Bus");
|
||||
|
||||
if (bus != null)
|
||||
{
|
||||
return bus;
|
||||
}
|
||||
|
||||
return MainMemory;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_systemBus = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -96,6 +96,8 @@
|
|||
<Compile Include="Base Implementations\InputCallbackSystem.cs" />
|
||||
<Compile Include="Base Implementations\MemoryCallbackSystem.cs" />
|
||||
<Compile Include="Base Implementations\MemoryDomain.cs" />
|
||||
<Compile Include="Base Implementations\MemoryDomainImpls.cs" />
|
||||
<Compile Include="Base Implementations\MemoryDomainList.cs" />
|
||||
<Compile Include="Base Implementations\NullController.cs" />
|
||||
<Compile Include="Base Implementations\NullEmulator.cs" />
|
||||
<Compile Include="Base Implementations\NullSound.cs" />
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
|
||||
public static bool CanPoke(this MemoryDomain d)
|
||||
{
|
||||
if (d.PokeByte == null)
|
||||
if (!d.Writable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280
|
|||
},
|
||||
delegate(ushort addr)
|
||||
{
|
||||
return md.PeekWord(addr + i, false);
|
||||
return md.PeekUshort(addr + i, false);
|
||||
}
|
||||
);
|
||||
w.WriteLine("0x{0:x8}: {1}", i, dis);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
MemoryDomain.FromByteArray("Main RAM", MemoryDomain.Endian.Little, _ram)
|
||||
};
|
||||
|
||||
var systemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
var systemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
if (addr < 0 || addr >= 65536)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
Cpu.WriteMemory((ushort)addr, value);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
domains.Add(systemBusDomain);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
|||
{
|
||||
var domains = new List<MemoryDomain>();
|
||||
|
||||
var mainRamDomain = new MemoryDomain("Main Ram", 0xC000, MemoryDomain.Endian.Little,
|
||||
var mainRamDomain = new MemoryDomainDelegate("Main Ram", 0xC000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 0xC000)
|
||||
|
@ -23,11 +23,11 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
|||
if (addr < 0 || addr >= 0xC000)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
_machine.Memory.Write((int)addr, value);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
domains.Add(mainRamDomain);
|
||||
|
||||
var systemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
var systemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
|||
if (addr < 0 || addr >= 65536)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
_machine.Memory.Write((int)addr, value);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
domains.Add(systemBusDomain);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|||
{
|
||||
public static MemoryDomain Create(string name, int size, Func<int, int> peekByte, Action<int, int> pokeByte)
|
||||
{
|
||||
return new MemoryDomain(name, size, MemoryDomain.Endian.Little, addr => unchecked((byte)peekByte((int)addr)), (addr, val) => pokeByte(unchecked((int)addr), val));
|
||||
return new MemoryDomainDelegate(name, size, MemoryDomain.Endian.Little, addr => unchecked((byte)peekByte((int)addr)), (addr, val) => pokeByte(unchecked((int)addr), val), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,50 +11,45 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
{
|
||||
var domains = new List<MemoryDomain>
|
||||
{
|
||||
new MemoryDomain(
|
||||
new MemoryDomainByteArray(
|
||||
"Main RAM",
|
||||
128,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => Ram[addr],
|
||||
(addr, value) => Ram[addr] = value),
|
||||
new MemoryDomain(
|
||||
Ram, true, 1),
|
||||
new MemoryDomainDelegate(
|
||||
"TIA",
|
||||
16,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => _tia.ReadMemory((ushort)addr, true),
|
||||
(addr, value) => this._tia.WriteMemory((ushort)addr, value)),
|
||||
new MemoryDomain(
|
||||
(addr, value) => this._tia.WriteMemory((ushort)addr, value), 1),
|
||||
new MemoryDomainDelegate(
|
||||
"PIA",
|
||||
1024,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => M6532.ReadMemory((ushort)addr, true),
|
||||
(addr, value) => M6532.WriteMemory((ushort)addr, value)),
|
||||
new MemoryDomain(
|
||||
(addr, value) => M6532.WriteMemory((ushort)addr, value), 1),
|
||||
new MemoryDomainDelegate(
|
||||
"System Bus",
|
||||
65536,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => _mapper.PeekMemory((ushort) addr),
|
||||
(addr, value) => _mapper.PokeMemory((ushort) addr, value))
|
||||
(addr, value) => _mapper.PokeMemory((ushort) addr, value), 1)
|
||||
};
|
||||
|
||||
if (_mapper is mDPC) // TODO: also mDPCPlus
|
||||
{
|
||||
domains.Add(new MemoryDomain(
|
||||
domains.Add(new MemoryDomainByteArray(
|
||||
"DPC",
|
||||
2048,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => (_mapper as mDPC).DspData[addr],
|
||||
(addr, value) => (_mapper as mDPC).DspData[addr] = value));
|
||||
MemoryDomain.Endian.Little,(_mapper as mDPC).DspData, true, 1));
|
||||
}
|
||||
|
||||
if (_mapper.HasCartRam)
|
||||
{
|
||||
domains.Add(new MemoryDomain(
|
||||
domains.Add(new MemoryDomainDelegate(
|
||||
"Cart Ram",
|
||||
_mapper.CartRam.Len,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => _mapper.CartRam[(int)addr],
|
||||
(addr, value) => _mapper.CartRam[(int)addr] = value));
|
||||
(addr, value) => _mapper.CartRam[(int)addr] = value, 1));
|
||||
}
|
||||
|
||||
MemoryDomains = new MemoryDomainList(domains);
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
_MemoryDomains = new List<MemoryDomain>();
|
||||
if (theMachine is Machine7800)
|
||||
{
|
||||
_MemoryDomains.Add(new MemoryDomain(
|
||||
_MemoryDomains.Add(new MemoryDomainDelegate(
|
||||
"RAM", 0x1000, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
|
@ -51,40 +51,22 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
{
|
||||
((Machine7800)theMachine).RAM2[(ushort)addr] = val;
|
||||
}
|
||||
}));
|
||||
}, 1));
|
||||
|
||||
_MemoryDomains.Add(new MemoryDomain(
|
||||
"BIOS ROM", bios.Length, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
return bios[addr];
|
||||
},
|
||||
null
|
||||
));
|
||||
_MemoryDomains.Add(new MemoryDomainByteArray(
|
||||
"BIOS ROM", MemoryDomain.Endian.Unknown,
|
||||
bios, false, 1));
|
||||
|
||||
if (hsc7800 != null)
|
||||
{
|
||||
_MemoryDomains.Add(new MemoryDomain(
|
||||
"HSC ROM", hsbios.Length, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
return hsbios[addr];
|
||||
},
|
||||
null));
|
||||
_MemoryDomains.Add(new MemoryDomainByteArray(
|
||||
"HSC ROM", MemoryDomain.Endian.Unknown, hsbios, false, 1));
|
||||
|
||||
_MemoryDomains.Add(new MemoryDomain(
|
||||
"HSC RAM", hsram.Length, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
return hsram[addr];
|
||||
},
|
||||
delegate(long addr, byte val)
|
||||
{
|
||||
hsram[addr] = val;
|
||||
}));
|
||||
_MemoryDomains.Add(new MemoryDomainByteArray(
|
||||
"HSC RAM", MemoryDomain.Endian.Unknown, hsram, true, 1));
|
||||
}
|
||||
|
||||
_MemoryDomains.Add(new MemoryDomain(
|
||||
_MemoryDomains.Add(new MemoryDomainDelegate(
|
||||
"System Bus", 65536, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
|
@ -97,7 +79,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
if (addr < 0 || addr >= 0x10000)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
theMachine.Mem[(ushort)addr] = val;
|
||||
}));
|
||||
}, 1));
|
||||
}
|
||||
else // todo 2600?
|
||||
{
|
||||
|
|
|
@ -12,13 +12,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
private void SetupMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>(3);
|
||||
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, MemoryDomain.Endian.Little,
|
||||
addr => Ram[addr],
|
||||
(addr, value) => Ram[addr] = value);
|
||||
var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => VDP.VRAM[addr],
|
||||
(addr, value) => VDP.VRAM[addr] = value);
|
||||
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
var MainMemoryDomain = new MemoryDomainByteArray("Main RAM", MemoryDomain.Endian.Little, Ram, true, 1);
|
||||
var VRamDomain = new MemoryDomainByteArray("Video RAM", MemoryDomain.Endian.Little, VDP.VRAM, true, 1);
|
||||
var SystemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -36,7 +32,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
}
|
||||
|
||||
Cpu.WriteMemory((ushort)addr, value);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
domains.Add(MainMemoryDomain);
|
||||
domains.Add(VRamDomain);
|
||||
|
|
|
@ -181,17 +181,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
var s = new LibmGBA.MemoryAreas();
|
||||
LibmGBA.BizGetMemoryAreas(core, s);
|
||||
|
||||
var LE = MemoryDomain.Endian.Little;
|
||||
MemoryDomains["IWRAM"].SetDelegatesForIntPtr(MemoryDomains["IWRAM"].Size, LE, s.wram, true, 4);
|
||||
MemoryDomains["EWRAM"].SetDelegatesForIntPtr(MemoryDomains["EWRAM"].Size, LE, s.wram, true, 4);
|
||||
MemoryDomains["BIOS"].SetDelegatesForIntPtr(MemoryDomains["BIOS"].Size, LE, s.bios, false, 4);
|
||||
MemoryDomains["PALRAM"].SetDelegatesForIntPtr(MemoryDomains["PALRAM"].Size, LE, s.palram, false, 4);
|
||||
MemoryDomains["VRAM"].SetDelegatesForIntPtr(MemoryDomains["VRAM"].Size, LE, s.vram, true, 4);
|
||||
MemoryDomains["OAM"].SetDelegatesForIntPtr(MemoryDomains["OAM"].Size, LE, s.oam, false, 4);
|
||||
MemoryDomains["ROM"].SetDelegatesForIntPtr(MemoryDomains["ROM"].Size, LE, s.rom, false, 4);
|
||||
_iwram.Data = s.iwram;
|
||||
_ewram.Data = s.wram;
|
||||
_bios.Data = s.bios;
|
||||
_palram.Data = s.palram;
|
||||
_vram.Data = s.vram;
|
||||
_oam.Data = s.oam;
|
||||
_rom.Data = s.rom;
|
||||
|
||||
// special combined ram memory domain
|
||||
MemoryDomains["Combined WRAM"].SetPeekPokeDelegates(
|
||||
|
||||
_cwram.Peek =
|
||||
delegate(long addr)
|
||||
{
|
||||
LibmGBA.BizGetMemoryAreas(core, s);
|
||||
|
@ -201,7 +201,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
return PeekWRAM(s.iwram, addr & 32767);
|
||||
else
|
||||
return PeekWRAM(s.wram, addr);
|
||||
},
|
||||
};
|
||||
_cwram.Poke =
|
||||
delegate(long addr, byte val)
|
||||
{
|
||||
if (addr < 0 || addr >= (256 + 32) * 1024)
|
||||
|
@ -210,8 +211,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
PokeWRAM(s.iwram, addr & 32767, val);
|
||||
else
|
||||
PokeWRAM(s.wram, addr, val);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
_gpumem = new GBAGPUMemoryAreas
|
||||
{
|
||||
|
@ -220,22 +220,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
palram = s.palram,
|
||||
vram = s.vram
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private MemoryDomainIntPtr _iwram;
|
||||
private MemoryDomainIntPtr _ewram;
|
||||
private MemoryDomainIntPtr _bios;
|
||||
private MemoryDomainIntPtr _palram;
|
||||
private MemoryDomainIntPtr _vram;
|
||||
private MemoryDomainIntPtr _oam;
|
||||
private MemoryDomainIntPtr _rom;
|
||||
private MemoryDomainDelegate _cwram;
|
||||
|
||||
private void CreateMemoryDomains(int romsize)
|
||||
{
|
||||
var LE = MemoryDomain.Endian.Little;
|
||||
|
||||
var mm = new List<MemoryDomain>();
|
||||
mm.Add(new MemoryDomain("IWRAM", 32 * 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("EWRAM", 256 * 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("BIOS", 16 * 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("PALRAM", 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("VRAM", 96 * 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("OAM", 1024, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("ROM", romsize, LE, null, null, 4));
|
||||
mm.Add(new MemoryDomain("Combined WRAM", (256 + 32) * 1024, LE, null, null, 4));
|
||||
mm.Add(_iwram = new MemoryDomainIntPtr("IWRAM", LE, IntPtr.Zero, 32 * 1024, true, 4));
|
||||
mm.Add(_ewram = new MemoryDomainIntPtr("EWRAM", LE, IntPtr.Zero, 256 * 1024, true, 4));
|
||||
mm.Add(_bios = new MemoryDomainIntPtr("BIOS", LE, IntPtr.Zero, 16 * 1024, false, 4));
|
||||
mm.Add(_palram = new MemoryDomainIntPtr("PALRAM", LE, IntPtr.Zero, 1024, true, 4));
|
||||
mm.Add(_vram = new MemoryDomainIntPtr("VRAM", LE, IntPtr.Zero, 96 * 1024, true, 4));
|
||||
mm.Add(_oam = new MemoryDomainIntPtr("OAM", LE, IntPtr.Zero, 1024, true, 4));
|
||||
mm.Add(_rom = new MemoryDomainIntPtr("ROM", LE, IntPtr.Zero, romsize, false, 4));
|
||||
mm.Add(_cwram = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, LE, null, null, 4));
|
||||
|
||||
MemoryDomains = new MemoryDomainList(mm);
|
||||
WireMemoryDomainPointers();
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
AddMemoryDomain(LibMeteor.MemoryArea.rom, 32 * 1024 * 1024, "ROM");
|
||||
// special domain for system bus
|
||||
{
|
||||
MemoryDomain sb = new MemoryDomain("System Bus", 1 << 28, MemoryDomain.Endian.Little,
|
||||
MemoryDomain sb = new MemoryDomainDelegate("System Bus", 1 << 28, MemoryDomain.Endian.Little,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= 0x10000000)
|
||||
|
@ -48,14 +48,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
if (addr < 0 || addr >= 0x10000000)
|
||||
throw new IndexOutOfRangeException();
|
||||
LibMeteor.libmeteor_writebus((uint)addr, val);
|
||||
});
|
||||
}, 4);
|
||||
_domainList.Add(sb);
|
||||
}
|
||||
// special combined ram memory domain
|
||||
{
|
||||
var ew = _domainList[1];
|
||||
var iw = _domainList[0];
|
||||
MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little,
|
||||
MemoryDomain cr = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= (256 + 32) * 1024)
|
||||
|
@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
iw.PokeByte(addr & 32767, val);
|
||||
else
|
||||
ew.PokeByte(addr, val);
|
||||
});
|
||||
}, 4);
|
||||
_domainList.Add(cr);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
mm.Add(MemoryDomain.FromIntPtr("OAM", 1024, l, s.oam, true, 4));
|
||||
mm.Add(MemoryDomain.FromIntPtr("ROM", 32 * 1024 * 1024, l, s.rom, true, 4));
|
||||
|
||||
mm.Add(new MemoryDomain("System Bus", 0x10000000, l,
|
||||
mm.Add(new MemoryDomainDelegate("System Bus", 0x10000000, l,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= 0x10000000)
|
||||
|
@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
var ew = mm[1];
|
||||
var iw = mm[0];
|
||||
MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little,
|
||||
MemoryDomain cr = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= (256 + 32) * 1024)
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
// also add a special memory domain for the system bus, where calls get sent directly to the core each time
|
||||
|
||||
_memoryDomains.Add(new MemoryDomain("System Bus", 65536, MemoryDomain.Endian.Little,
|
||||
_memoryDomains.Add(new MemoryDomainDelegate("System Bus", 65536, MemoryDomain.Endian.Little,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
if (addr < 0 || addr >= 65536)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
LibGambatte.gambatte_cpuwrite(GambatteState, (ushort)addr, val);
|
||||
}));
|
||||
}, 1));
|
||||
|
||||
MemoryDomains = new MemoryDomainList(_memoryDomains);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
|
|
|
@ -16,16 +16,43 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
foreach (var md in L.MemoryDomains)
|
||||
{
|
||||
mm.Add(new MemoryDomain("L " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
|
||||
mm.Add(new WrappedMemoryDomain("L " + md.Name, md));
|
||||
}
|
||||
|
||||
foreach (var md in R.MemoryDomains)
|
||||
{
|
||||
mm.Add(new MemoryDomain("R " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
|
||||
mm.Add(new WrappedMemoryDomain("R " + md.Name, md));
|
||||
}
|
||||
|
||||
_memoryDomains = new MemoryDomainList(mm);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
||||
}
|
||||
|
||||
// todo: clean this up
|
||||
private class WrappedMemoryDomain : MemoryDomain
|
||||
{
|
||||
private readonly MemoryDomain _m;
|
||||
|
||||
public WrappedMemoryDomain(string name, MemoryDomain m)
|
||||
{
|
||||
_m = m;
|
||||
|
||||
Name = name;
|
||||
Size = m.Size;
|
||||
WordSize = m.WordSize;
|
||||
EndianType = m.EndianType;
|
||||
Writable = m.Writable;
|
||||
}
|
||||
|
||||
public override byte PeekByte(long addr)
|
||||
{
|
||||
return _m.PeekByte(addr);
|
||||
}
|
||||
|
||||
public override void PokeByte(long addr, byte val)
|
||||
{
|
||||
_m.PokeByte(addr, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
public string Disassemble(MemoryDomain m, uint addr, out int length)
|
||||
{
|
||||
length = 4; // TODO: is this right?
|
||||
var instruction = m.PeekDWord(addr, true);
|
||||
var instruction = m.PeekUint(addr, true);
|
||||
|
||||
//TODO - reserve buffer here for disassembling into. allocating repeatedly will be slower
|
||||
var result = api.m64p_decode_op(instruction, addr);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
};
|
||||
}
|
||||
|
||||
var md = new MemoryDomain(name, size, endian, peekByte, pokeByte, 4);
|
||||
var md = new MemoryDomainDelegate(name, size, endian, peekByte, pokeByte, 4);
|
||||
|
||||
_memoryDomains.Add(md);
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
api.m64p_write_memory_8((uint)addr, val);
|
||||
};
|
||||
|
||||
_memoryDomains.Add(new MemoryDomain
|
||||
_memoryDomains.Add(new MemoryDomainDelegate
|
||||
(
|
||||
name: "System Bus",
|
||||
size: uint.MaxValue,
|
||||
endian: MemoryDomain.Endian.Big,
|
||||
peekByte: peekByte,
|
||||
pokeByte: pokeByte
|
||||
"System Bus",
|
||||
uint.MaxValue,
|
||||
MemoryDomain.Endian.Big,
|
||||
peekByte,
|
||||
pokeByte, 4
|
||||
));
|
||||
|
||||
MemoryDomains = new MemoryDomainList(_memoryDomains);
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
public MemoryDomain GetDiskPeeker()
|
||||
{
|
||||
return new MemoryDomain("FDS Side", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null);
|
||||
return new MemoryDomainDelegate("FDS Side", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null, 1);
|
||||
}
|
||||
|
||||
void SetIRQ()
|
||||
|
|
|
@ -13,16 +13,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
private void SetupMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>();
|
||||
var RAM = new MemoryDomain("RAM", 0x800, MemoryDomain.Endian.Little,
|
||||
addr => ram[addr], (addr, value) => ram[addr] = value);
|
||||
var SystemBus = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
addr => PeekMemory((ushort)addr), (addr, value) => ApplySystemBusPoke((int)addr, value));
|
||||
var PPUBus = new MemoryDomain("PPU Bus", 0x4000, MemoryDomain.Endian.Little,
|
||||
addr => ppu.ppubus_peek((int)addr), (addr, value) => ppu.ppubus_write((int)addr, value));
|
||||
var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, MemoryDomain.Endian.Little,
|
||||
addr => CIRAM[addr], (addr, value) => CIRAM[addr] = value);
|
||||
var OAMdoman = new MemoryDomain("OAM", 64 * 4, MemoryDomain.Endian.Unknown,
|
||||
addr => ppu.OAM[addr], (addr, value) => ppu.OAM[addr] = value);
|
||||
var RAM = new MemoryDomainByteArray("RAM", MemoryDomain.Endian.Little, ram, true, 1);
|
||||
var SystemBus = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
addr => PeekMemory((ushort)addr), (addr, value) => ApplySystemBusPoke((int)addr, value), 1);
|
||||
var PPUBus = new MemoryDomainDelegate("PPU Bus", 0x4000, MemoryDomain.Endian.Little,
|
||||
addr => ppu.ppubus_peek((int)addr), (addr, value) => ppu.ppubus_write((int)addr, value), 1);
|
||||
var CIRAMdomain = new MemoryDomainByteArray("CIRAM (nametables)", MemoryDomain.Endian.Little, CIRAM, true, 1);
|
||||
var OAMdoman = new MemoryDomainByteArray("OAM", MemoryDomain.Endian.Unknown, ppu.OAM, true, 1);
|
||||
|
||||
domains.Add(RAM);
|
||||
domains.Add(SystemBus);
|
||||
|
@ -32,36 +29,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
if (!(Board is FDS) && Board.SaveRam != null)
|
||||
{
|
||||
var BatteryRam = new MemoryDomain("Battery RAM", Board.SaveRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => Board.SaveRam[addr], (addr, value) => Board.SaveRam[addr] = value);
|
||||
var BatteryRam = new MemoryDomainByteArray("Battery RAM", MemoryDomain.Endian.Little, Board.SaveRam, true, 1);
|
||||
domains.Add(BatteryRam);
|
||||
}
|
||||
|
||||
if (Board.ROM != null)
|
||||
{
|
||||
var PRGROM = new MemoryDomain("PRG ROM", cart.prg_size * 1024, MemoryDomain.Endian.Little,
|
||||
addr => Board.ROM[addr], (addr, value) => Board.ROM[addr] = value);
|
||||
var PRGROM = new MemoryDomainByteArray("PRG ROM", MemoryDomain.Endian.Little, Board.ROM, true, 1);
|
||||
domains.Add(PRGROM);
|
||||
}
|
||||
|
||||
if (Board.VROM != null)
|
||||
{
|
||||
var CHRROM = new MemoryDomain("CHR VROM", cart.chr_size * 1024, MemoryDomain.Endian.Little,
|
||||
addr => Board.VROM[addr], (addr, value) => Board.VROM[addr] = value);
|
||||
var CHRROM = new MemoryDomainByteArray("CHR VROM", MemoryDomain.Endian.Little, Board.VROM, true, 1);
|
||||
domains.Add(CHRROM);
|
||||
}
|
||||
|
||||
if (Board.VRAM != null)
|
||||
{
|
||||
var VRAM = new MemoryDomain("VRAM", Board.VRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => Board.VRAM[addr], (addr, value) => Board.VRAM[addr] = value);
|
||||
var VRAM = new MemoryDomainByteArray("VRAM", MemoryDomain.Endian.Little, Board.VRAM, true, 1);
|
||||
domains.Add(VRAM);
|
||||
}
|
||||
|
||||
if (Board.WRAM != null)
|
||||
{
|
||||
var WRAM = new MemoryDomain("WRAM", Board.WRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => Board.WRAM[addr], (addr, value) => Board.WRAM[addr] = value);
|
||||
var WRAM = new MemoryDomainByteArray("WRAM", MemoryDomain.Endian.Little, Board.WRAM, true, 1);
|
||||
domains.Add(WRAM);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
}
|
||||
}
|
||||
// add system bus
|
||||
mm.Add(new MemoryDomain
|
||||
mm.Add(new MemoryDomainDelegate
|
||||
(
|
||||
"System Bus",
|
||||
0x10000,
|
||||
|
@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
}
|
||||
|
||||
QN.qn_poke_prgbus(Context, (int)addr, val);
|
||||
}
|
||||
}, 1
|
||||
));
|
||||
|
||||
_memoryDomains = new MemoryDomainList(mm);
|
||||
|
|
|
@ -1076,7 +1076,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
byte* blockptr = api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.WRAM);
|
||||
|
||||
var md = new MemoryDomain("System Bus", 0x1000000, MemoryDomain.Endian.Little,
|
||||
var md = new MemoryDomainDelegate("System Bus", 0x1000000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
var a = FakeBusMap((int)addr);
|
||||
|
@ -1090,7 +1090,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
var a = FakeBusMap((int)addr);
|
||||
if (a.HasValue)
|
||||
blockptr[a.Value] = val;
|
||||
}, byteSize: 2);
|
||||
}, wordSize: 2);
|
||||
_memoryDomains.Add(md);
|
||||
}
|
||||
|
||||
|
@ -1116,17 +1116,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
//maybe a better way to visualize it is with an empty bus and adjacent banks
|
||||
//so, we just throw away everything above its size of 544 bytes
|
||||
if (size != 544) throw new InvalidOperationException("oam size isnt 544 bytes.. wtf?");
|
||||
md = new MemoryDomain(name, size, endian,
|
||||
md = new MemoryDomainDelegate(name, size, endian,
|
||||
(addr) => (addr < 544) ? blockptr[addr] : (byte)0x00,
|
||||
(addr, value) => { if (addr < 544) blockptr[addr] = value; },
|
||||
byteSize);
|
||||
}
|
||||
else if(pow2)
|
||||
md = new MemoryDomain(name, size, endian,
|
||||
md = new MemoryDomainDelegate(name, size, endian,
|
||||
(addr) => blockptr[addr & mask],
|
||||
(addr, value) => blockptr[addr & mask] = value, byteSize);
|
||||
else
|
||||
md = new MemoryDomain(name, size, endian,
|
||||
md = new MemoryDomainDelegate(name, size, endian,
|
||||
(addr) => blockptr[addr % size],
|
||||
(addr, value) => blockptr[addr % size] = value, byteSize);
|
||||
|
||||
|
@ -1137,9 +1137,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
void SetupMemoryDomains(byte[] romData, byte[] sgbRomData)
|
||||
{
|
||||
// remember, MainMemory must always be the same as MemoryDomains[0], else GIANT DRAGONS
|
||||
//<zeromus> - this is stupid.
|
||||
|
||||
//lets just do this entirely differently for SGB
|
||||
if (IsSGB)
|
||||
{
|
||||
|
@ -1147,13 +1144,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
//You wouldnt expect a DMG game to access excess wram, but what if it tried to? maybe an oversight in bsnes?
|
||||
MakeMemoryDomain("SGB WRAM", LibsnesApi.SNES_MEMORY.SGB_WRAM, MemoryDomain.Endian.Little);
|
||||
|
||||
|
||||
var romDomain = new MemoryDomain("SGB CARTROM", romData.Length, MemoryDomain.Endian.Little,
|
||||
(addr) => romData[addr],
|
||||
(addr, value) => romData[addr] = value);
|
||||
var romDomain = new MemoryDomainByteArray("SGB CARTROM", MemoryDomain.Endian.Little, romData, true, 1);
|
||||
_memoryDomains.Add(romDomain);
|
||||
|
||||
|
||||
//the last 1 byte of this is special.. its an interrupt enable register, instead of ram. weird. maybe its actually ram and just getting specially used?
|
||||
MakeMemoryDomain("SGB HRAM", LibsnesApi.SNES_MEMORY.SGB_HRAM, MemoryDomain.Endian.Little);
|
||||
|
||||
|
@ -1161,9 +1154,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
MainMemory = MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, MemoryDomain.Endian.Little);
|
||||
|
||||
var sgbromDomain = new MemoryDomain("SGB.SFC ROM", sgbRomData.Length, MemoryDomain.Endian.Little,
|
||||
(addr) => sgbRomData[addr],
|
||||
(addr, value) => sgbRomData[addr] = value);
|
||||
var sgbromDomain = new MemoryDomainByteArray("SGB.SFC ROM", MemoryDomain.Endian.Little, sgbRomData, true, 1);
|
||||
_memoryDomains.Add(sgbromDomain);
|
||||
}
|
||||
else
|
||||
|
@ -1180,9 +1171,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
if (!DeterministicEmulation)
|
||||
{
|
||||
_memoryDomains.Add(new MemoryDomain("System Bus", 0x1000000, MemoryDomain.Endian.Little,
|
||||
_memoryDomains.Add(new MemoryDomainDelegate("System Bus", 0x1000000, MemoryDomain.Endian.Little,
|
||||
(addr) => api.QUERY_peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr),
|
||||
(addr, val) => api.QUERY_poke(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr, val), byteSize: 2));
|
||||
(addr, val) => api.QUERY_poke(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr, val), wordSize: 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -513,13 +513,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
var domains = new List<MemoryDomain>(10);
|
||||
int mainmemorymask = Ram.Length - 1;
|
||||
var MainMemoryDomain = new MemoryDomain("Main Memory", Ram.Length, MemoryDomain.Endian.Little,
|
||||
addr => Ram[addr],
|
||||
(addr, value) => Ram[addr] = value,
|
||||
byteSize: 2);
|
||||
var MainMemoryDomain = new MemoryDomainByteArray("Main Memory", MemoryDomain.Endian.Little, Ram, true, 1);
|
||||
domains.Add(MainMemoryDomain);
|
||||
|
||||
var SystemBusDomain = new MemoryDomain("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little,
|
||||
var SystemBusDomain = new MemoryDomainDelegate("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 0x200000)
|
||||
|
@ -532,10 +529,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
throw new ArgumentOutOfRangeException();
|
||||
Cpu.WriteMemory21((int)addr, value);
|
||||
},
|
||||
byteSize: 2);
|
||||
wordSize: 2);
|
||||
domains.Add(SystemBusDomain);
|
||||
|
||||
var CpuBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
var CpuBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 0x10000)
|
||||
|
@ -548,63 +545,41 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
throw new ArgumentOutOfRangeException();
|
||||
Cpu.WriteMemory((ushort)addr, value);
|
||||
},
|
||||
byteSize: 2);
|
||||
wordSize: 2);
|
||||
domains.Add(CpuBusDomain);
|
||||
|
||||
var RomDomain = new MemoryDomain("ROM", RomLength, MemoryDomain.Endian.Little,
|
||||
addr => RomData[addr],
|
||||
(addr, value) => RomData[addr] = value,
|
||||
byteSize: 2);
|
||||
var RomDomain = new MemoryDomainByteArray("ROM", MemoryDomain.Endian.Little, RomData, true, 1);
|
||||
domains.Add(RomDomain);
|
||||
|
||||
if (BRAM != null)
|
||||
{
|
||||
var BRAMMemoryDomain = new MemoryDomain("Battery RAM", Ram.Length, MemoryDomain.Endian.Little,
|
||||
addr => BRAM[addr],
|
||||
(addr, value) => BRAM[addr] = value,
|
||||
byteSize: 2);
|
||||
var BRAMMemoryDomain = new MemoryDomainByteArray("Battery RAM", MemoryDomain.Endian.Little, BRAM, true, 1);
|
||||
domains.Add(BRAMMemoryDomain);
|
||||
}
|
||||
|
||||
if (TurboCD)
|
||||
{
|
||||
var CDRamMemoryDomain = new MemoryDomain("TurboCD RAM", CDRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => CDRam[addr],
|
||||
(addr, value) => CDRam[addr] = value,
|
||||
byteSize: 2);
|
||||
var CDRamMemoryDomain = new MemoryDomainByteArray("TurboCD RAM", MemoryDomain.Endian.Little, CDRam, true, 1);
|
||||
domains.Add(CDRamMemoryDomain);
|
||||
|
||||
var AdpcmMemoryDomain = new MemoryDomain("ADPCM RAM", ADPCM.RAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => ADPCM.RAM[addr],
|
||||
(addr, value) => ADPCM.RAM[addr] = value,
|
||||
byteSize: 2);
|
||||
var AdpcmMemoryDomain = new MemoryDomainByteArray("ADPCM RAM", MemoryDomain.Endian.Little, ADPCM.RAM, true, 1);
|
||||
domains.Add(AdpcmMemoryDomain);
|
||||
|
||||
if (SuperRam != null)
|
||||
{
|
||||
var SuperRamMemoryDomain = new MemoryDomain("Super System Card RAM", SuperRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => SuperRam[addr],
|
||||
(addr, value) => SuperRam[addr] = value,
|
||||
byteSize: 2);
|
||||
var SuperRamMemoryDomain = new MemoryDomainByteArray("Super System Card RAM", MemoryDomain.Endian.Little, SuperRam, true, 1);
|
||||
domains.Add(SuperRamMemoryDomain);
|
||||
}
|
||||
}
|
||||
|
||||
if (ArcadeCard)
|
||||
{
|
||||
var ArcadeRamMemoryDomain = new MemoryDomain("Arcade Card RAM", ArcadeRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => ArcadeRam[addr],
|
||||
(addr, value) => ArcadeRam[addr] = value,
|
||||
byteSize: 2);
|
||||
domains.Add(ArcadeRamMemoryDomain);
|
||||
var ArcadeRamMemoryDomain = new MemoryDomainByteArray("Arcade Card RAM", MemoryDomain.Endian.Little, ArcadeRam, true, 1);
|
||||
}
|
||||
|
||||
if (PopulousRAM != null)
|
||||
{
|
||||
var PopulusRAMDomain = new MemoryDomain("Cart Battery RAM", PopulousRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => PopulousRAM[addr],
|
||||
(addr, value) => PopulousRAM[addr] = value,
|
||||
byteSize: 2);
|
||||
var PopulusRAMDomain = new MemoryDomainByteArray("Cart Battery RAM", MemoryDomain.Endian.Little, PopulousRAM, true, 1);
|
||||
domains.Add(PopulusRAMDomain);
|
||||
}
|
||||
|
||||
|
|
|
@ -458,6 +458,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
|
|||
|
||||
void SetupMemoryDomains()
|
||||
{
|
||||
/*
|
||||
var domains = new List<MemoryDomain>(3);
|
||||
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, MemoryDomain.Endian.Big,
|
||||
addr => Ram[addr & 0xFFFF],
|
||||
|
@ -485,6 +486,8 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
|
|||
domains.Add(SystemBusDomain);
|
||||
memoryDomains = new MemoryDomainList(domains);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(memoryDomains);
|
||||
*/
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
|
|
@ -12,18 +12,12 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
void SetupMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>(3);
|
||||
var MainMemoryDomain = new MemoryDomain("Main RAM", SystemRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => SystemRam[addr],
|
||||
(addr, value) => SystemRam[addr] = value);
|
||||
var VRamDomain = new MemoryDomain("Video RAM", Vdp.VRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => Vdp.VRAM[addr],
|
||||
(addr, value) => Vdp.VRAM[addr] = value);
|
||||
var MainMemoryDomain = new MemoryDomainByteArray("Main RAM", MemoryDomain.Endian.Little, SystemRam, true, 1);
|
||||
var VRamDomain = new MemoryDomainByteArray("Video RAM", MemoryDomain.Endian.Little, Vdp.VRAM, true, 1);
|
||||
|
||||
var ROMDomain = new MemoryDomain("ROM", RomData.Length, MemoryDomain.Endian.Little,
|
||||
addr => RomData[addr],
|
||||
(addr, value) => RomData[addr] = value);
|
||||
var ROMDomain = new MemoryDomainByteArray("ROM", MemoryDomain.Endian.Little, RomData, true, 1);
|
||||
|
||||
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
var SystemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
|
||||
(addr) =>
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -41,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
}
|
||||
|
||||
Cpu.WriteMemory((ushort)addr, value);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
domains.Add(MainMemoryDomain);
|
||||
domains.Add(VRamDomain);
|
||||
|
@ -50,17 +44,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
|
||||
if (SaveRAM != null)
|
||||
{
|
||||
var SaveRamDomain = new MemoryDomain("Save RAM", SaveRAM.Length, MemoryDomain.Endian.Little,
|
||||
var SaveRamDomain = new MemoryDomainDelegate("Save RAM", SaveRAM.Length, MemoryDomain.Endian.Little,
|
||||
addr => SaveRAM[addr],
|
||||
(addr, value) => { SaveRAM[addr] = value; SaveRamModified = true; });
|
||||
(addr, value) => { SaveRAM[addr] = value; SaveRamModified = true; }, 1);
|
||||
domains.Add(SaveRamDomain);
|
||||
}
|
||||
|
||||
if (ExtRam != null)
|
||||
{
|
||||
var ExtRamDomain = new MemoryDomain("Cart (Volatile) RAM", ExtRam.Length, MemoryDomain.Endian.Little,
|
||||
addr => ExtRam[addr],
|
||||
(addr, value) => { ExtRam[addr] = value; });
|
||||
var ExtRamDomain = new MemoryDomainByteArray("Cart (Volatile) RAM", MemoryDomain.Endian.Little, ExtRam, true, 1);
|
||||
domains.Add(ExtRamDomain);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
public string Disassemble(MemoryDomain m, uint addr, out int length)
|
||||
{
|
||||
_disassemblerInstance.ReadWord = (a) => (short)m.PeekWord(a, m.EndianType == MemoryDomain.Endian.Big);
|
||||
_disassemblerInstance.ReadWord = (a) => (short)m.PeekUshort(a, m.EndianType == MemoryDomain.Endian.Big);
|
||||
_disassemblerInstance.ReadByte = (a) => (sbyte)m.PeekByte(a);
|
||||
_disassemblerInstance.ReadLong = (a) => (int)m.PeekDWord(a, m.EndianType == MemoryDomain.Endian.Big);
|
||||
_disassemblerInstance.ReadLong = (a) => (int)m.PeekUint(a, m.EndianType == MemoryDomain.Endian.Big);
|
||||
var info = _disassemblerInstance.Disassemble((int)addr);
|
||||
|
||||
length = info.Length;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
{
|
||||
// vram pokes need to go through hook which invalidates cached tiles
|
||||
byte* p = (byte*)area;
|
||||
mm.Add(new MemoryDomain(name, size, MemoryDomain.Endian.Unknown,
|
||||
mm.Add(new MemoryDomainDelegate(name, size, MemoryDomain.Endian.Unknown,
|
||||
delegate(long addr)
|
||||
{
|
||||
if (addr < 0 || addr >= 65536)
|
||||
|
@ -38,17 +38,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
throw new ArgumentOutOfRangeException();
|
||||
Core.gpgx_poke_vram(((int)addr) ^ 1, val);
|
||||
},
|
||||
byteSize: 2));
|
||||
wordSize: 2));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var byteSize = name.Contains("Z80") ? 1 : 2;
|
||||
// TODO: are the Z80 domains really Swap16 in the core? Check this
|
||||
mm.Add(MemoryDomain.FromIntPtrSwap16(name, size,
|
||||
MemoryDomain.Endian.Big, area, name != "MD CART" && name != "CD BOOT ROM", byteSize));
|
||||
MemoryDomain.Endian.Big, area, name != "MD CART" && name != "CD BOOT ROM"));
|
||||
}
|
||||
}
|
||||
var m68Bus = new MemoryDomain("M68K BUS", 0x1000000, MemoryDomain.Endian.Big,
|
||||
var m68Bus = new MemoryDomainDelegate("M68K BUS", 0x1000000, MemoryDomain.Endian.Big,
|
||||
delegate (long addr)
|
||||
{
|
||||
var a = (uint)addr;
|
||||
|
@ -66,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
mm.Add(m68Bus);
|
||||
|
||||
var s68Bus = new MemoryDomain("S68K BUS", 0x1000000, MemoryDomain.Endian.Big,
|
||||
var s68Bus = new MemoryDomainDelegate("S68K BUS", 0x1000000, MemoryDomain.Endian.Big,
|
||||
delegate (long addr)
|
||||
{
|
||||
var a = (uint)addr;
|
||||
|
|
Loading…
Reference in New Issue