2015-01-16 01:38:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|
|
|
|
{
|
|
|
|
|
public partial class QuickNES
|
|
|
|
|
{
|
2017-04-24 18:47:40 +00:00
|
|
|
|
private unsafe void InitMemoryDomains()
|
2015-01-16 01:38:47 +00:00
|
|
|
|
{
|
|
|
|
|
List<MemoryDomain> mm = new List<MemoryDomain>();
|
|
|
|
|
for (int i = 0; ; i++)
|
|
|
|
|
{
|
|
|
|
|
IntPtr data = IntPtr.Zero;
|
|
|
|
|
int size = 0;
|
|
|
|
|
bool writable = false;
|
|
|
|
|
IntPtr name = IntPtr.Zero;
|
|
|
|
|
|
2016-02-18 01:17:49 +00:00
|
|
|
|
if (!QN.qn_get_memory_area(Context, i, ref data, ref size, ref writable, ref name))
|
2015-01-16 01:38:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (data != IntPtr.Zero && size > 0 && name != IntPtr.Zero)
|
|
|
|
|
{
|
2017-04-24 18:47:40 +00:00
|
|
|
|
mm.Add(new MemoryDomainIntPtr(Marshal.PtrToStringAnsi(name), MemoryDomain.Endian.Little, data, size, writable, 1));
|
2015-01-16 01:38:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-24 18:47:40 +00:00
|
|
|
|
|
2015-01-16 01:38:47 +00:00
|
|
|
|
// add system bus
|
2017-04-24 18:47:40 +00:00
|
|
|
|
mm.Add(new MemoryDomainDelegate(
|
2015-01-16 01:38:47 +00:00
|
|
|
|
"System Bus",
|
|
|
|
|
0x10000,
|
|
|
|
|
MemoryDomain.Endian.Unknown,
|
2015-01-18 15:25:47 +00:00
|
|
|
|
delegate(long addr)
|
2015-01-16 01:38:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (addr < 0 || addr >= 0x10000)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 01:17:49 +00:00
|
|
|
|
return QN.qn_peek_prgbus(Context, (int)addr);
|
2015-01-16 01:38:47 +00:00
|
|
|
|
},
|
2015-01-18 15:25:47 +00:00
|
|
|
|
delegate(long addr, byte val)
|
2015-01-16 01:38:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (addr < 0 || addr >= 0x10000)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-18 01:17:49 +00:00
|
|
|
|
QN.qn_poke_prgbus(Context, (int)addr, val);
|
2017-04-24 18:47:40 +00:00
|
|
|
|
}, 1));
|
2015-01-16 01:38:47 +00:00
|
|
|
|
|
2015-01-24 16:02:28 +00:00
|
|
|
|
_memoryDomains = new MemoryDomainList(mm);
|
2015-01-16 01:38:47 +00:00
|
|
|
|
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IMemoryDomains _memoryDomains;
|
|
|
|
|
}
|
|
|
|
|
}
|