Move MemoryDomain to its own file, and move the Endian enum into it, also clean up the class a bit, and refactor things as necessary

This commit is contained in:
adelikat 2013-11-04 02:11:40 +00:00
parent 9751fd5a1a
commit be547db4a1
28 changed files with 223 additions and 229 deletions

View File

@ -165,7 +165,7 @@ namespace BizHawk.Client.Common
public float mainmemory_readfloat(object lua_addr, bool bigendian)
{
int addr = LuaInt(lua_addr);
uint val = Global.Emulator.MainMemory.PeekDWord(addr, bigendian ? Endian.Big : Endian.Little);
uint val = Global.Emulator.MainMemory.PeekDWord(addr, bigendian);
byte[] bytes = BitConverter.GetBytes(val);
float _float = BitConverter.ToSingle(bytes, 0);
@ -196,7 +196,7 @@ namespace BizHawk.Client.Common
float dv = (float)(double)lua_v;
byte[] bytes = BitConverter.GetBytes(dv);
uint v = BitConverter.ToUInt32(bytes, 0);
Global.Emulator.MainMemory.PokeDWord(addr, v, bigendian ? Endian.Big : Endian.Little);
Global.Emulator.MainMemory.PokeDWord(addr, v, bigendian);
}

View File

@ -155,7 +155,7 @@ namespace BizHawk.Client.Common
public float memory_readfloat(object lua_addr, bool bigendian)
{
int addr = LuaInt(lua_addr);
uint val = Global.Emulator.MemoryDomains[_current_memory_domain].PeekDWord(addr, bigendian ? Endian.Big : Endian.Little);
uint val = Global.Emulator.MemoryDomains[_current_memory_domain].PeekDWord(addr, bigendian);
byte[] bytes = BitConverter.GetBytes(val);
float _float = BitConverter.ToSingle(bytes, 0);
@ -175,7 +175,7 @@ namespace BizHawk.Client.Common
float dv = (float)(double)lua_v;
byte[] bytes = BitConverter.GetBytes(dv);
uint v = BitConverter.ToUInt32(bytes, 0);
Global.Emulator.MemoryDomains[_current_memory_domain].PokeDWord(addr, v, bigendian ? Endian.Big : Endian.Little);
Global.Emulator.MemoryDomains[_current_memory_domain].PokeDWord(addr, v, bigendian);
}
public bool memory_usememorydomain(object lua_input)

View File

@ -725,7 +725,7 @@ namespace BizHawk.Client.Common
return theByte;
}
case Watch.WatchSize.Word:
var theWord = _settings.Domain.PeekWord(addr, _settings.BigEndian ? Endian.Big : Endian.Little);
var theWord = _settings.Domain.PeekWord(addr, _settings.BigEndian);
if (_settings.Type == Watch.DisplayType.Signed)
{
return (short)theWord;
@ -735,7 +735,7 @@ namespace BizHawk.Client.Common
return theWord;
}
case Watch.WatchSize.DWord:
var theDWord = _settings.Domain.PeekDWord(addr, _settings.BigEndian ? Endian.Big : Endian.Little);
var theDWord = _settings.Domain.PeekDWord(addr, _settings.BigEndian);
if (_settings.Type == Watch.DisplayType.Signed)
{
return (int)theDWord;
@ -808,7 +808,7 @@ namespace BizHawk.Client.Common
public MiniWordWatch(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
_previous = domain.PeekWord(Address, bigEndian ? Endian.Big : Endian.Little);
_previous = domain.PeekWord(Address, bigEndian);
}
public int Previous
@ -818,7 +818,7 @@ namespace BizHawk.Client.Common
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekWord(Address, bigendian ? Endian.Big : Endian.Little);
_previous = domain.PeekWord(Address, bigendian);
}
}
@ -830,7 +830,7 @@ namespace BizHawk.Client.Common
public MiniDWordWatch(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
_previous = domain.PeekDWord(Address, bigEndian ? Endian.Big : Endian.Little);
_previous = domain.PeekDWord(Address, bigEndian);
}
public int Previous
@ -840,7 +840,7 @@ namespace BizHawk.Client.Common
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekDWord(Address, bigendian ? Endian.Big : Endian.Little);
_previous = domain.PeekDWord(Address, bigendian);
}
}
@ -910,7 +910,7 @@ namespace BizHawk.Client.Common
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekWord(Address, bigendian ? Endian.Big : Endian.Little);
_previous = domain.PeekWord(Address, bigendian);
}
public int Previous
@ -925,7 +925,7 @@ namespace BizHawk.Client.Common
public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian)
{
ushort value = domain.PeekWord(Address, bigendian ? Endian.Big : Endian.Little);
ushort value = domain.PeekWord(Address, bigendian);
if (value != Previous)
{
_changecount++;
@ -961,7 +961,7 @@ namespace BizHawk.Client.Common
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekDWord(Address, bigendian ? Endian.Big : Endian.Little);
_previous = domain.PeekDWord(Address, bigendian);
}
public int Previous
@ -976,7 +976,7 @@ namespace BizHawk.Client.Common
public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian)
{
uint value = domain.PeekDWord(Address, bigendian ? Endian.Big : Endian.Little);
uint value = domain.PeekDWord(Address, bigendian);
if (value != Previous)
{
_changecount++;

View File

@ -176,12 +176,12 @@ namespace BizHawk.Client.Common
protected ushort GetWord()
{
return _domain.PeekWord(_address, _bigEndian ? Endian.Big : Endian.Little);
return _domain.PeekWord(_address, _bigEndian);
}
protected uint GetDWord()
{
return _domain.PeekDWord(_address, _bigEndian ? Endian.Big : Endian.Little);
return _domain.PeekDWord(_address, _bigEndian);
}
protected void PokeByte(byte val)
@ -191,12 +191,12 @@ namespace BizHawk.Client.Common
protected void PokeWord(ushort val)
{
_domain.PokeWord(_address, val, _bigEndian ? Endian.Big : Endian.Little);
_domain.PokeWord(_address, val, _bigEndian);
}
protected void PokeDWord(uint val)
{
_domain.PokeDWord(_address, val, _bigEndian ? Endian.Big : Endian.Little);
_domain.PokeDWord(_address, val, _bigEndian);
}
public void ClearChangeCount() { _changecount = 0; }

View File

@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
private readonly List<int> SecondaryHighlightedAddresses = new List<int>();
private int addressOver = -1;
private int maxRow = 0;
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => 0, (a, v) => { v = 0; });
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, MemoryDomain.Endian.Little, addr => 0, (a, v) => { v = 0; });
private string info = "";
private int row;
private int addr;
@ -376,10 +376,7 @@ namespace BizHawk.Client.EmuHawk
public void SetMemoryDomain(MemoryDomain d)
{
Domain = d;
if (d.Endian == Endian.Big)
BigEndian = true;
else
BigEndian = false;
BigEndian = d.EndianType == MemoryDomain.Endian.Big;
maxRow = Domain.Size / 2;
SetUpScrollBar();
if (0 >= vScrollBar1.Minimum && 0 <= vScrollBar1.Maximum)
@ -455,7 +452,7 @@ namespace BizHawk.Client.EmuHawk
ROM = GetRomBytes() ?? new byte[] { 0xFF };
//<zeromus> THIS IS HORRIBLE.
ROMDomain = new MemoryDomain("ROM File", ROM.Length, Endian.Little,
ROMDomain = new MemoryDomain("ROM File", ROM.Length, MemoryDomain.Endian.Little,
i => ROM[i],
(i, value) => ROM[i] = value);
@ -1705,7 +1702,6 @@ namespace BizHawk.Client.EmuHawk
}
else
{
Endian endian = BigEndian ? Endian.Big : Endian.Little;
switch (DataSize)
{
default:
@ -1719,15 +1715,15 @@ namespace BizHawk.Client.EmuHawk
case 2:
Domain.PokeWord(
address,
(ushort)(Domain.PeekWord(address, endian) + 1),
endian
(ushort)(Domain.PeekWord(address, BigEndian) + 1),
BigEndian
);
break;
case 4:
Domain.PokeDWord(
address,
Domain.PeekDWord(address, endian) + 1,
endian
Domain.PeekDWord(address, BigEndian) + 1,
BigEndian
);
break;
}
@ -1743,7 +1739,6 @@ namespace BizHawk.Client.EmuHawk
}
else
{
Endian endian = BigEndian ? Endian.Big : Endian.Little;
switch (DataSize)
{
default:
@ -1757,15 +1752,15 @@ namespace BizHawk.Client.EmuHawk
case 2:
Domain.PokeWord(
address,
(ushort)(Domain.PeekWord(address, endian) - 1),
endian
(ushort)(Domain.PeekWord(address, BigEndian) - 1),
BigEndian
);
break;
case 4:
Domain.PokeDWord(
address,
Domain.PeekDWord(address, endian) - 1,
endian
Domain.PeekDWord(address, BigEndian) - 1,
BigEndian
);
break;
}

View File

@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
public bool BlazingFast = false;
private string info = "";
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => 0, (a, v) => { v = 0; });
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, MemoryDomain.Endian.Little, addr => 0, (a, v) => { v = 0; });
private readonly Font font = new Font("Courier New", 8);
private int _rows_visible;
private int _data_size = 1;

View File

@ -180,7 +180,7 @@ namespace BizHawk.Client.EmuHawk
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString()) ??
Global.Emulator.MainMemory;
BigEndianCheckBox.Checked = domain.Endian == Endian.Big;
BigEndianCheckBox.Checked = domain.EndianType == MemoryDomain.Endian.Big;
}
#region Events

View File

@ -53,6 +53,7 @@
<Compile Include="Interfaces\ISoundProvider.cs" />
<Compile Include="Interfaces\ISyncSoundProvider.cs" />
<Compile Include="Interfaces\IVideoProvider.cs" />
<Compile Include="MemoryDomain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Common
{
CoreComm = comm;
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr => 0, (a, v) => { }));
domains.Add(new MemoryDomain("Main RAM", 1, MemoryDomain.Endian.Little, addr => 0, (a, v) => { }));
memoryDomains = domains.AsReadOnly();
}
public void ResetCounters()

View File

@ -83,110 +83,5 @@ namespace BizHawk.Emulation.Common
MemoryDomain MainMemory { get; }
}
public class MemoryDomain
{
public readonly string Name;
public readonly int Size;
public readonly Endian Endian;
public readonly Func<int, byte> PeekByte;
public readonly Action<int, byte> PokeByte;
public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte)
{
Name = name;
Size = size;
Endian = endian;
PeekByte = peekByte;
PokeByte = pokeByte;
}
public MemoryDomain()
{
}
public MemoryDomain(MemoryDomain domain)
{
Name = domain.Name;
Size = domain.Size;
Endian = domain.Endian;
PeekByte = domain.PeekByte;
PokeByte = domain.PokeByte;
}
public override string ToString()
{
return Name;
}
public ushort PeekWord(int addr, Endian endian)
{
switch (endian)
{
default:
case Endian.Big:
return (ushort)((PeekByte(addr) << 8) | (PeekByte(addr + 1)));
case Endian.Little:
return (ushort)((PeekByte(addr)) | (PeekByte(addr + 1) << 8));
}
}
public uint PeekDWord(int addr, Endian endian)
{
switch (endian)
{
default:
case Endian.Big:
return (uint)((PeekByte(addr) << 24)
| (PeekByte(addr + 1) << 16)
| (PeekByte(addr + 2) << 8)
| (PeekByte(addr + 3) << 0));
case Endian.Little:
return (uint)((PeekByte(addr) << 0)
| (PeekByte(addr + 1) << 8)
| (PeekByte(addr + 2) << 16)
| (PeekByte(addr + 3) << 24));
}
}
public void PokeWord(int addr, ushort val, Endian endian)
{
switch (endian)
{
default:
case Endian.Big:
PokeByte(addr + 0, (byte)(val >> 8));
PokeByte(addr + 1, (byte)(val));
break;
case Endian.Little:
PokeByte(addr + 0, (byte)(val));
PokeByte(addr + 1, (byte)(val >> 8));
break;
}
}
public void PokeDWord(int addr, uint val, Endian endian)
{
switch (endian)
{
default:
case Endian.Big:
PokeByte(addr + 0, (byte)(val >> 24));
PokeByte(addr + 1, (byte)(val >> 16));
PokeByte(addr + 2, (byte)(val >> 8));
PokeByte(addr + 3, (byte)(val));
break;
case Endian.Little:
PokeByte(addr + 0, (byte)(val));
PokeByte(addr + 1, (byte)(val >> 8));
PokeByte(addr + 2, (byte)(val >> 16));
PokeByte(addr + 3, (byte)(val >> 24));
break;
}
}
}
public enum Endian { Big, Little, Unknown }
public enum DisplayType { NTSC, PAL, DENDY }
}

View File

@ -0,0 +1,103 @@
using System;
namespace BizHawk.Emulation.Common
{
public class MemoryDomain
{
public enum Endian { Big, Little, Unknown }
public readonly string Name;
public readonly int Size;
public readonly Endian EndianType;
public readonly Func<int, byte> PeekByte;
public readonly Action<int, byte> PokeByte;
public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte)
{
Name = name;
Size = size;
EndianType = endian;
PeekByte = peekByte;
PokeByte = pokeByte;
}
public MemoryDomain() { }
public override string ToString()
{
return Name;
}
public ushort PeekWord(int addr, bool bigEndian)
{
Endian endian = bigEndian ? Endian.Big : Endian.Little;
switch (endian)
{
default:
case Endian.Big:
return (ushort)((PeekByte(addr) << 8) | (PeekByte(addr + 1)));
case Endian.Little:
return (ushort)((PeekByte(addr)) | (PeekByte(addr + 1) << 8));
}
}
public uint PeekDWord(int addr, bool bigEndian)
{
Endian endian = bigEndian ? Endian.Big : Endian.Little;
switch (endian)
{
default:
case Endian.Big:
return (uint)((PeekByte(addr) << 24)
| (PeekByte(addr + 1) << 16)
| (PeekByte(addr + 2) << 8)
| (PeekByte(addr + 3) << 0));
case Endian.Little:
return (uint)((PeekByte(addr) << 0)
| (PeekByte(addr + 1) << 8)
| (PeekByte(addr + 2) << 16)
| (PeekByte(addr + 3) << 24));
}
}
public void PokeWord(int addr, ushort val, bool bigEndian)
{
Endian endian = bigEndian ? Endian.Big : Endian.Little;
switch (endian)
{
default:
case Endian.Big:
PokeByte(addr + 0, (byte)(val >> 8));
PokeByte(addr + 1, (byte)(val));
break;
case Endian.Little:
PokeByte(addr + 0, (byte)(val));
PokeByte(addr + 1, (byte)(val >> 8));
break;
}
}
public void PokeDWord(int addr, uint val, bool bigEndian)
{
Endian endian = bigEndian ? Endian.Big : Endian.Little;
switch (endian)
{
default:
case Endian.Big:
PokeByte(addr + 0, (byte)(val >> 24));
PokeByte(addr + 1, (byte)(val >> 16));
PokeByte(addr + 2, (byte)(val >> 8));
PokeByte(addr + 3, (byte)(val));
break;
case Endian.Little:
PokeByte(addr + 0, (byte)(val));
PokeByte(addr + 1, (byte)(val >> 8));
PokeByte(addr + 2, (byte)(val >> 16));
PokeByte(addr + 3, (byte)(val >> 24));
break;
}
}
}
}

View File

@ -158,16 +158,16 @@ namespace BizHawk.Emulation.Computers.Commodore64
{
// chips must be initialized before this code runs!
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("System Bus", 0x10000, Endian.Little, board.cpu.Peek, board.cpu.Poke));
domains.Add(new MemoryDomain("RAM", 0x10000, Endian.Little, board.ram.Peek, board.ram.Poke));
domains.Add(new MemoryDomain("CIA0", 0x10, Endian.Little, board.cia0.Peek, board.cia0.Poke));
domains.Add(new MemoryDomain("CIA1", 0x10, Endian.Little, board.cia1.Peek, board.cia1.Poke));
domains.Add(new MemoryDomain("VIC", 0x40, Endian.Little, board.vic.Peek, board.vic.Poke));
domains.Add(new MemoryDomain("SID", 0x20, Endian.Little, board.sid.Peek, board.sid.Poke));
//domains.Add(new MemoryDomain("1541 Bus", 0x10000, Endian.Little, new Func<int, byte>(disk.Peek), new Action<int, byte>(disk.Poke)));
//domains.Add(new MemoryDomain("1541 VIA0", 0x10, Endian.Little, new Func<int, byte>(disk.PeekVia0), new Action<int, byte>(disk.PokeVia0)));
//domains.Add(new MemoryDomain("1541 VIA1", 0x10, Endian.Little, new Func<int, byte>(disk.PeekVia1), new Action<int, byte>(disk.PokeVia1)));
//domains.Add(new MemoryDomain("1541 RAM", 0x1000, Endian.Little, new Func<int, byte>(disk.PeekRam), new Action<int, byte>(disk.PokeRam)));
domains.Add(new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, board.cpu.Peek, board.cpu.Poke));
domains.Add(new MemoryDomain("RAM", 0x10000, MemoryDomain.Endian.Little, board.ram.Peek, board.ram.Poke));
domains.Add(new MemoryDomain("CIA0", 0x10, MemoryDomain.Endian.Little, board.cia0.Peek, board.cia0.Poke));
domains.Add(new MemoryDomain("CIA1", 0x10, MemoryDomain.Endian.Little, board.cia1.Peek, board.cia1.Poke));
domains.Add(new MemoryDomain("VIC", 0x40, MemoryDomain.Endian.Little, board.vic.Peek, board.vic.Poke));
domains.Add(new MemoryDomain("SID", 0x20, MemoryDomain.Endian.Little, board.sid.Peek, board.sid.Poke));
//domains.Add(new MemoryDomain("1541 Bus", 0x10000, MemoryDomain.Endian.Little, new Func<int, byte>(disk.Peek), new Action<int, byte>(disk.Poke)));
//domains.Add(new MemoryDomain("1541 VIA0", 0x10, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekVia0), new Action<int, byte>(disk.PokeVia0)));
//domains.Add(new MemoryDomain("1541 VIA1", 0x10, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekVia1), new Action<int, byte>(disk.PokeVia1)));
//domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekRam), new Action<int, byte>(disk.PokeRam)));
memoryDomains = domains.AsReadOnly();
}
}

View File

@ -26,12 +26,12 @@ namespace BizHawk
CoreComm = comm;
var domains = new List<MemoryDomain>(1)
{
new MemoryDomain("Main RAM", 128, Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value),
new MemoryDomain("TIA", 16, Endian.Little, addr => tia.ReadMemory((ushort) addr, true),
new MemoryDomain("Main RAM", 128, MemoryDomain.Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value),
new MemoryDomain("TIA", 16, MemoryDomain.Endian.Little, addr => tia.ReadMemory((ushort) addr, true),
(addr, value) => tia.WriteMemory((ushort) addr, value)),
new MemoryDomain("PIA", 1024, Endian.Little, addr => m6532.ReadMemory((ushort) addr, true),
new MemoryDomain("PIA", 1024, MemoryDomain.Endian.Little, addr => m6532.ReadMemory((ushort) addr, true),
(addr, value) => m6532.WriteMemory((ushort) addr, value)),
new MemoryDomain("System Bus", 8192, Endian.Little, addr => mapper.PeekMemory((ushort) addr), (addr, value) => { })
new MemoryDomain("System Bus", 8192, MemoryDomain.Endian.Little, addr => mapper.PeekMemory((ushort) addr), (addr, value) => { })
};
memoryDomains = domains.AsReadOnly();
CoreComm.CpuTraceAvailable = true;

View File

@ -250,7 +250,7 @@ namespace BizHawk.Emulation
if (theMachine is Machine7800)
{
_MemoryDomains.Add(new MemoryDomain(
"RAM1", 0x800, Endian.Unknown,
"RAM1", 0x800, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return ((Machine7800)theMachine).RAM1[(ushort)addr];
@ -260,7 +260,7 @@ namespace BizHawk.Emulation
((Machine7800)theMachine).RAM1[(ushort)addr] = val;
}));
_MemoryDomains.Add(new MemoryDomain(
"RAM2", 0x800, Endian.Unknown,
"RAM2", 0x800, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return ((Machine7800)theMachine).RAM2[(ushort)addr];
@ -270,7 +270,7 @@ namespace BizHawk.Emulation
((Machine7800)theMachine).RAM2[(ushort)addr] = val;
}));
_MemoryDomains.Add(new MemoryDomain(
"BIOS ROM", bios.Length, Endian.Unknown,
"BIOS ROM", bios.Length, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return bios[addr];
@ -281,7 +281,7 @@ namespace BizHawk.Emulation
if (hsc7800 != null)
{
_MemoryDomains.Add(new MemoryDomain(
"HSC ROM", hsbios.Length, Endian.Unknown,
"HSC ROM", hsbios.Length, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return hsbios[addr];
@ -290,7 +290,7 @@ namespace BizHawk.Emulation
{
}));
_MemoryDomains.Add(new MemoryDomain(
"HSC RAM", hsram.Length, Endian.Unknown,
"HSC RAM", hsram.Length, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return hsram[addr];
@ -301,7 +301,7 @@ namespace BizHawk.Emulation
}));
}
_MemoryDomains.Add(new MemoryDomain(
"System Bus", 65536, Endian.Unknown,
"System Bus", 65536, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
return theMachine.Mem[(ushort)addr];

View File

@ -618,7 +618,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
private void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>();
var MainMemoryDomain = new MemoryDomain("Main RAM", ram.Length, Endian.Little,
var MainMemoryDomain = new MemoryDomain("Main RAM", ram.Length, MemoryDomain.Endian.Little,
addr => ram[addr & RamSizeMask],
(addr, value) => ram[addr & RamSizeMask] = value);
domains.Add(MainMemoryDomain);

View File

@ -53,13 +53,13 @@ namespace BizHawk.Emulation.Consoles.Coleco
void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>(3);
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, Endian.Little,
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, MemoryDomain.Endian.Little,
addr => Ram[addr & RamSizeMask],
(addr, value) => Ram[addr & RamSizeMask] = value);
var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, Endian.Little,
var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, MemoryDomain.Endian.Little,
addr => VDP.VRAM[addr & 0x3FFF],
(addr, value) => VDP.VRAM[addr & 0x3FFF] = value);
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, Endian.Little,
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
addr => Cpu.ReadMemory((ushort)addr),
(addr, value) => Cpu.WriteMemory((ushort)addr, value));

View File

@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
if (data == IntPtr.Zero)
throw new Exception("libmeteor_getmemoryarea() returned NULL??");
MemoryDomain md = new MemoryDomain(name, size, Endian.Little,
MemoryDomain md = new MemoryDomain(name, size, MemoryDomain.Endian.Little,
delegate(int addr)
{
unsafe
@ -258,7 +258,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
AddMemoryDomain(LibMeteor.MemoryArea.rom, 32 * 1024 * 1024, "ROM");
// special domain for system bus
{
MemoryDomain sb = new MemoryDomain("BUS", 1 << 28, Endian.Little,
MemoryDomain sb = new MemoryDomain("BUS", 1 << 28, MemoryDomain.Endian.Little,
delegate(int addr)
{
return LibMeteor.libmeteor_peekbus((uint)addr);
@ -273,7 +273,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
{
var ew = _MemoryDomains[1];
var iw = _MemoryDomains[0];
MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, Endian.Little,
MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little,
delegate(int addr)
{
if (addr >= 256 * 1024)

View File

@ -608,7 +608,7 @@ namespace BizHawk.Emulation.Consoles.GB
MemoryRefreshers.Add(refresher);
MemoryDomains.Add(new MemoryDomain(name, length, Endian.Little, refresher.Peek, refresher.Poke));
MemoryDomains.Add(new MemoryDomain(name, length, MemoryDomain.Endian.Little, refresher.Peek, refresher.Poke));
}
void InitMemoryDomains()
@ -625,7 +625,7 @@ namespace BizHawk.Emulation.Consoles.GB
// 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, Endian.Little,
MemoryDomains.Add(new MemoryDomain("System Bus", 65536, MemoryDomain.Endian.Little,
delegate(int addr)
{
return LibGambatte.gambatte_cpuread(GambatteState, (ushort)addr);

View File

@ -315,9 +315,9 @@ namespace BizHawk.Emulation.Consoles.GB
var mm = new List<MemoryDomain>();
foreach (var md in L.MemoryDomains)
mm.Add(new MemoryDomain("L " + md.Name, md.Size, md.Endian, md.PeekByte, md.PokeByte));
mm.Add(new MemoryDomain("L " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
foreach (var md in R.MemoryDomains)
mm.Add(new MemoryDomain("R " + md.Name, md.Size, md.Endian, md.PeekByte, md.PokeByte));
mm.Add(new MemoryDomain("R " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
MemoryDomains = mm.AsReadOnly();
}

View File

@ -257,7 +257,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
#region memorydomains
MemoryDomain MakeMemoryDomain(string name, mupen64plusApi.N64_MEMORY id, Endian endian)
private MemoryDomain MakeMemoryDomain(string name, mupen64plusApi.N64_MEMORY id, MemoryDomain.Endian endian)
{
int size = api.get_memory_size(id);
@ -292,18 +292,18 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
void InitMemoryDomains()
{
MemoryDomains = new List<MemoryDomain>();
MakeMemoryDomain("RDRAM", mupen64plusApi.N64_MEMORY.RDRAM, Endian.Little);
MakeMemoryDomain("PI Register", mupen64plusApi.N64_MEMORY.PI_REG, Endian.Little);
MakeMemoryDomain("SI Register", mupen64plusApi.N64_MEMORY.SI_REG, Endian.Little);
MakeMemoryDomain("VI Register", mupen64plusApi.N64_MEMORY.VI_REG, Endian.Little);
MakeMemoryDomain("RI Register", mupen64plusApi.N64_MEMORY.RI_REG, Endian.Little);
MakeMemoryDomain("AI Register", mupen64plusApi.N64_MEMORY.AI_REG, Endian.Little);
MakeMemoryDomain("RDRAM", mupen64plusApi.N64_MEMORY.RDRAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("PI Register", mupen64plusApi.N64_MEMORY.PI_REG, MemoryDomain.Endian.Little);
MakeMemoryDomain("SI Register", mupen64plusApi.N64_MEMORY.SI_REG, MemoryDomain.Endian.Little);
MakeMemoryDomain("VI Register", mupen64plusApi.N64_MEMORY.VI_REG, MemoryDomain.Endian.Little);
MakeMemoryDomain("RI Register", mupen64plusApi.N64_MEMORY.RI_REG, MemoryDomain.Endian.Little);
MakeMemoryDomain("AI Register", mupen64plusApi.N64_MEMORY.AI_REG, MemoryDomain.Endian.Little);
MakeMemoryDomain("EEPROM", mupen64plusApi.N64_MEMORY.EEPROM, Endian.Little);
MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, Endian.Little);
MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, Endian.Little);
MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, Endian.Little);
MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, Endian.Little);
MakeMemoryDomain("EEPROM", mupen64plusApi.N64_MEMORY.EEPROM, MemoryDomain.Endian.Little);
MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, MemoryDomain.Endian.Little);
MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, MemoryDomain.Endian.Little);
MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, MemoryDomain.Endian.Little);
MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, MemoryDomain.Endian.Little);
}
public IList<MemoryDomain> MemoryDomains { get; private set; }

View File

@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public MemoryDomain GetExRAM()
{
return new MemoryDomain("ExRAM", EXRAM.Length, Endian.Little, (addr) => EXRAM[addr], (addr, val) => EXRAM[addr] = val);
return new MemoryDomain("ExRAM", EXRAM.Length, MemoryDomain.Endian.Little, (addr) => EXRAM[addr], (addr, val) => EXRAM[addr] = val);
}
public override void SyncState(Serializer ser)

View File

@ -221,7 +221,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public MemoryDomain GetDiskPeeker()
{
return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, Endian.Little, diskdrive.PeekData, null);
return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null);
}
void SetIRQ()

View File

@ -469,15 +469,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
private void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>();
var RAM = new MemoryDomain("RAM", 0x800, Endian.Little,
var RAM = new MemoryDomain("RAM", 0x800, MemoryDomain.Endian.Little,
addr => ram[addr & 0x07FF], (addr, value) => ram[addr & 0x07FF] = value);
var SystemBus = new MemoryDomain("System Bus", 0x10000, Endian.Little,
var SystemBus = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
addr => ReadMemory((ushort)addr), (addr, value) => ApplySystemBusPoke(addr, value)); //WriteMemory((ushort)addr, value));
var PPUBus = new MemoryDomain("PPU Bus", 0x4000, Endian.Little,
var PPUBus = new MemoryDomain("PPU Bus", 0x4000, MemoryDomain.Endian.Little,
addr => ppu.ppubus_peek(addr), (addr, value) => ppu.ppubus_write(addr, value));
var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, Endian.Little,
var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, MemoryDomain.Endian.Little,
addr => CIRAM[addr & 0x07FF], (addr, value) => CIRAM[addr & 0x07FF] = value);
var OAMdoman = new MemoryDomain("OAM", 64 * 4, Endian.Unknown,
var OAMdoman = new MemoryDomain("OAM", 64 * 4, MemoryDomain.Endian.Unknown,
addr => ppu.OAM[addr & (64 * 4 - 1)], (addr, value) => ppu.OAM[addr & (64 * 4 - 1)] = value);
domains.Add(RAM);
@ -488,32 +488,32 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if (!(board is FDS) && board.SaveRam != null)
{
var BatteryRam = new MemoryDomain("Battery RAM", board.SaveRam.Length, Endian.Little,
var BatteryRam = new MemoryDomain("Battery RAM", board.SaveRam.Length, MemoryDomain.Endian.Little,
addr => board.SaveRam[addr], (addr, value) => board.SaveRam[addr] = value);
domains.Add(BatteryRam);
}
var PRGROM = new MemoryDomain("PRG ROM", cart.prg_size * 1024, Endian.Little,
var PRGROM = new MemoryDomain("PRG ROM", cart.prg_size * 1024, MemoryDomain.Endian.Little,
addr => board.ROM[addr], (addr, value) => board.ROM[addr] = value);
domains.Add(PRGROM);
if (board.VROM != null)
{
var CHRROM = new MemoryDomain("CHR VROM", cart.chr_size * 1024, Endian.Little,
var CHRROM = new MemoryDomain("CHR VROM", cart.chr_size * 1024, MemoryDomain.Endian.Little,
addr => board.VROM[addr], (addr, value) => board.VROM[addr] = value);
domains.Add(CHRROM);
}
if (board.VRAM != null)
{
var VRAM = new MemoryDomain("VRAM", board.VRAM.Length, Endian.Little,
var VRAM = new MemoryDomain("VRAM", board.VRAM.Length, MemoryDomain.Endian.Little,
addr => board.VRAM[addr], (addr, value) => board.VRAM[addr] = value);
domains.Add(VRAM);
}
if (board.WRAM != null)
{
var WRAM = new MemoryDomain("WRAM", board.WRAM.Length, Endian.Little,
var WRAM = new MemoryDomain("WRAM", board.WRAM.Length, MemoryDomain.Endian.Little,
addr => board.WRAM[addr], (addr, value) => board.WRAM[addr] = value);
domains.Add(WRAM);
}

View File

@ -835,7 +835,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public CoreComm CoreComm { get; private set; }
// ----- Client Debugging API stuff -----
unsafe MemoryDomain MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, Endian endian)
unsafe MemoryDomain MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, MemoryDomain.Endian endian)
{
int size = api.snes_get_memory_size(id);
int mask = size - 1;
@ -880,44 +880,44 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
{
//NOTE: CGB has 32K of wram, and DMG has 8KB of wram. Not sure how to control this right now.. bsnes might not have any ready way of doign that? I couldnt spot it.
//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, Endian.Little);
MakeMemoryDomain("SGB WRAM", LibsnesApi.SNES_MEMORY.SGB_WRAM, MemoryDomain.Endian.Little);
var romDomain = new MemoryDomain("SGB CARTROM", romData.Length, Endian.Little,
var romDomain = new MemoryDomain("SGB CARTROM", romData.Length, MemoryDomain.Endian.Little,
(addr) => romData[addr],
(addr, value) => romData[addr] = value);
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, Endian.Little);
MakeMemoryDomain("SGB HRAM", LibsnesApi.SNES_MEMORY.SGB_HRAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("SGB CARTRAM", LibsnesApi.SNES_MEMORY.SGB_CARTRAM, Endian.Little);
MakeMemoryDomain("SGB CARTRAM", LibsnesApi.SNES_MEMORY.SGB_CARTRAM, MemoryDomain.Endian.Little);
MainMemory = MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, Endian.Little);
MainMemory = MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, MemoryDomain.Endian.Little);
var sgbromDomain = new MemoryDomain("SGB.SFC ROM", sgbRomData.Length, Endian.Little,
var sgbromDomain = new MemoryDomain("SGB.SFC ROM", sgbRomData.Length, MemoryDomain.Endian.Little,
(addr) => sgbRomData[addr],
(addr, value) => sgbRomData[addr] = value);
MemoryDomains.Add(sgbromDomain);
}
else
{
MainMemory = MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, Endian.Little);
MainMemory = MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, MemoryDomain.Endian.Little);
var romDomain = new MemoryDomain("CARTROM", romData.Length, Endian.Little,
var romDomain = new MemoryDomain("CARTROM", romData.Length, MemoryDomain.Endian.Little,
(addr) => romData[addr],
(addr, value) => romData[addr] = value);
MemoryDomains.Add(romDomain);
MakeMemoryDomain("CARTRAM", LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM, Endian.Little);
MakeMemoryDomain("VRAM", LibsnesApi.SNES_MEMORY.VRAM, Endian.Little);
MakeMemoryDomain("OAM", LibsnesApi.SNES_MEMORY.OAM, Endian.Little);
MakeMemoryDomain("CGRAM", LibsnesApi.SNES_MEMORY.CGRAM, Endian.Little);
MakeMemoryDomain("APURAM", LibsnesApi.SNES_MEMORY.APURAM, Endian.Little);
MakeMemoryDomain("CARTRAM", LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("VRAM", LibsnesApi.SNES_MEMORY.VRAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("OAM", LibsnesApi.SNES_MEMORY.OAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("CGRAM", LibsnesApi.SNES_MEMORY.CGRAM, MemoryDomain.Endian.Little);
MakeMemoryDomain("APURAM", LibsnesApi.SNES_MEMORY.APURAM, MemoryDomain.Endian.Little);
if (!DeterministicEmulation)
MemoryDomains.Add(new MemoryDomain("BUS", 0x1000000, Endian.Little,
MemoryDomains.Add(new MemoryDomain("BUS", 0x1000000, MemoryDomain.Endian.Little,
(addr) => api.peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr),
(addr, val) => api.poke(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr, val)));

View File

@ -545,19 +545,19 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>(10);
var MainMemoryDomain = new MemoryDomain("Main Memory", Ram.Length, Endian.Little,
var MainMemoryDomain = new MemoryDomain("Main Memory", Ram.Length, MemoryDomain.Endian.Little,
addr => Ram[addr & 0x1FFF],
(addr, value) => Ram[addr & 0x1FFF] = value);
domains.Add(MainMemoryDomain);
var SystemBusDomain = new MemoryDomain("System Bus", 0x200000, Endian.Little,
var SystemBusDomain = new MemoryDomain("System Bus", 0x200000, MemoryDomain.Endian.Little,
addr => Cpu.ReadMemory21(addr),
(addr, value) => Cpu.WriteMemory21(addr, value));
domains.Add(SystemBusDomain);
if (BRAM != null)
{
var BRAMMemoryDomain = new MemoryDomain("Battery RAM", Ram.Length, Endian.Little,
var BRAMMemoryDomain = new MemoryDomain("Battery RAM", Ram.Length, MemoryDomain.Endian.Little,
addr => BRAM[addr & 0x7FF],
(addr, value) => BRAM[addr & 0x7FF] = value);
domains.Add(BRAMMemoryDomain);
@ -565,19 +565,19 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (TurboCD)
{
var CDRamMemoryDomain = new MemoryDomain("TurboCD RAM", CDRam.Length, Endian.Little,
var CDRamMemoryDomain = new MemoryDomain("TurboCD RAM", CDRam.Length, MemoryDomain.Endian.Little,
addr => CDRam[addr & 0xFFFF],
(addr, value) => CDRam[addr & 0xFFFF] = value);
domains.Add(CDRamMemoryDomain);
var AdpcmMemoryDomain = new MemoryDomain("ADPCM RAM", ADPCM.RAM.Length, Endian.Little,
var AdpcmMemoryDomain = new MemoryDomain("ADPCM RAM", ADPCM.RAM.Length, MemoryDomain.Endian.Little,
addr => ADPCM.RAM[addr & 0xFFFF],
(addr, value) => ADPCM.RAM[addr & 0xFFFF] = value);
domains.Add(AdpcmMemoryDomain);
if (SuperRam != null)
{
var SuperRamMemoryDomain = new MemoryDomain("Super System Card RAM", SuperRam.Length, Endian.Little,
var SuperRamMemoryDomain = new MemoryDomain("Super System Card RAM", SuperRam.Length, MemoryDomain.Endian.Little,
addr => SuperRam[addr & 0x3FFFF],
(addr, value) => SuperRam[addr & 0x3FFFF] = value);
domains.Add(SuperRamMemoryDomain);
@ -586,7 +586,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (ArcadeCard)
{
var ArcadeRamMemoryDomain = new MemoryDomain("Arcade Card RAM", ArcadeRam.Length, Endian.Little,
var ArcadeRamMemoryDomain = new MemoryDomain("Arcade Card RAM", ArcadeRam.Length, MemoryDomain.Endian.Little,
addr => ArcadeRam[addr & 0x1FFFFF],
(addr, value) => ArcadeRam[addr & 0x1FFFFF] = value);
domains.Add(ArcadeRamMemoryDomain);

View File

@ -419,22 +419,22 @@ namespace BizHawk.Emulation.Consoles.Sega
void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>(3);
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, Endian.Big,
var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, MemoryDomain.Endian.Big,
addr => Ram[addr & 0xFFFF],
(addr, value) => Ram[addr & 0xFFFF] = value);
var Z80Domain = new MemoryDomain("Z80 RAM", Z80Ram.Length, Endian.Little,
var Z80Domain = new MemoryDomain("Z80 RAM", Z80Ram.Length, MemoryDomain.Endian.Little,
addr => Z80Ram[addr & 0x1FFF],
(addr, value) => { Z80Ram[addr & 0x1FFF] = value; });
var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, Endian.Big,
var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, MemoryDomain.Endian.Big,
addr => VDP.VRAM[addr & 0xFFFF],
(addr, value) => VDP.VRAM[addr & 0xFFFF] = value);
var RomDomain = new MemoryDomain("Rom Data", RomData.Length, Endian.Big,
var RomDomain = new MemoryDomain("Rom Data", RomData.Length, MemoryDomain.Endian.Big,
addr => RomData[addr], //adelikat: For speed considerations, I didn't mask this, every tool that uses memory domains is smart enough not to overflow, if I'm wrong let me know!
(addr, value) => RomData[addr & (RomData.Length - 1)] = value);
var SystemBusDomain = new MemoryDomain("System Bus", 0x1000000, Endian.Big,
var SystemBusDomain = new MemoryDomain("System Bus", 0x1000000, MemoryDomain.Endian.Big,
addr => (byte)ReadByte(addr),
(addr, value) => Write8((uint)addr, (uint)value));

View File

@ -398,16 +398,16 @@ namespace BizHawk.Emulation.Consoles.Sega
void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>(3);
var MainMemoryDomain = new MemoryDomain("Main RAM", SystemRam.Length, Endian.Little,
var MainMemoryDomain = new MemoryDomain("Main RAM", SystemRam.Length, MemoryDomain.Endian.Little,
addr => SystemRam[addr & RamSizeMask],
(addr, value) => SystemRam[addr & RamSizeMask] = value);
var VRamDomain = new MemoryDomain("Video RAM", Vdp.VRAM.Length, Endian.Little,
var VRamDomain = new MemoryDomain("Video RAM", Vdp.VRAM.Length, MemoryDomain.Endian.Little,
addr => Vdp.VRAM[addr & 0x3FFF],
(addr, value) => Vdp.VRAM[addr & 0x3FFF] = value);
var SaveRamDomain = new MemoryDomain("Save RAM", SaveRAM.Length, Endian.Little,
var SaveRamDomain = new MemoryDomain("Save RAM", SaveRAM.Length, MemoryDomain.Endian.Little,
addr => SaveRAM[addr % SaveRAM.Length],
(addr, value) => { SaveRAM[addr % SaveRAM.Length] = value; SaveRamModified = true; });
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, Endian.Little,
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little,
addr => Cpu.ReadMemory((ushort)addr),
(addr, value) => Cpu.WriteMemory((ushort)addr, value));

View File

@ -442,7 +442,7 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
ret.Add(new MemoryDomain(
nmd.name,
nmd.length,
Endian.Little,
MemoryDomain.Endian.Little,
delegate(int addr)
{
if (addr < 0 || addr >= l)