Intellivision - add System Ram and Executive Rom memory domains
This commit is contained in:
parent
c739755e9b
commit
35c4df9256
|
@ -36,10 +36,60 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
addr => GraphicsRom[addr],
|
||||
(addr, value) => GraphicsRom[addr] = value,
|
||||
1),
|
||||
new MemoryDomainDelegate(
|
||||
"System Ram",
|
||||
SystemRam.Length * 2,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => ReadByteFromShortArray(addr, SystemRam),
|
||||
(addr, value) => WriteByteToShortArray(addr, value, SystemRam),
|
||||
1
|
||||
),
|
||||
new MemoryDomainDelegate(
|
||||
"Executive Rom",
|
||||
SystemRam.Length * 2,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => ReadByteFromShortArray(addr, ExecutiveRom),
|
||||
(addr, value) => WriteByteToShortArray(addr, value, ExecutiveRom),
|
||||
1
|
||||
)
|
||||
};
|
||||
|
||||
MemoryDomains = new MemoryDomainList(domains);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
}
|
||||
|
||||
// TODO: move these to a common library and maybe add an endian parameter
|
||||
// Little endian
|
||||
private byte ReadByteFromShortArray(long addr, ushort[] array)
|
||||
{
|
||||
if (addr % 2 == 0)
|
||||
{
|
||||
long index = addr / 2;
|
||||
return (byte)(array[index] >> 8);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
long index = (addr - 1) / 2;
|
||||
return (byte)(array[index] & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteByteToShortArray(long addr, byte value, ushort[] array)
|
||||
{
|
||||
if (addr % 2 == 0)
|
||||
{
|
||||
long index = (addr - 1) / 2;
|
||||
ushort val = (ushort)((value << 8) + (array[index] & 0xFF));
|
||||
array[index] = val;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
long index = addr / 2;
|
||||
ushort val = (ushort)((((array[index] >> 8) & 0xFF) << 8) + value);
|
||||
array[index] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue