gpgx memory domains
This commit is contained in:
parent
b2210f3dfe
commit
3e389a93b0
|
@ -53,8 +53,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||||
}
|
}
|
||||||
AttachedCore = this;
|
AttachedCore = this;
|
||||||
|
|
||||||
MemoryDomains = MemoryDomainList.GetDummyList();
|
|
||||||
|
|
||||||
LoadCallback = new LibGPGX.load_archive_cb(load_archive);
|
LoadCallback = new LibGPGX.load_archive_cb(load_archive);
|
||||||
|
|
||||||
this.romfile = romfile;
|
this.romfile = romfile;
|
||||||
|
@ -111,6 +109,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||||
|
|
||||||
// pull the default video size from the core
|
// pull the default video size from the core
|
||||||
update_video();
|
update_video();
|
||||||
|
|
||||||
|
SetMemoryDomains();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -472,6 +472,38 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||||
|
|
||||||
public MemoryDomainList MemoryDomains { get; private set; }
|
public MemoryDomainList MemoryDomains { get; private set; }
|
||||||
|
|
||||||
|
unsafe void SetMemoryDomains()
|
||||||
|
{
|
||||||
|
var mm = new List<MemoryDomain>();
|
||||||
|
for (int i = LibGPGX.MIN_MEM_DOMAIN; i <= LibGPGX.MAX_MEM_DOMAIN; i++)
|
||||||
|
{
|
||||||
|
IntPtr area = IntPtr.Zero;
|
||||||
|
int size = 0;
|
||||||
|
IntPtr pname = LibGPGX.gpgx_get_memdom(i, ref area, ref size);
|
||||||
|
if (area == IntPtr.Zero || pname == IntPtr.Zero || size == 0)
|
||||||
|
continue;
|
||||||
|
string name = Marshal.PtrToStringAnsi(pname);
|
||||||
|
byte *p = (byte*) area;
|
||||||
|
|
||||||
|
mm.Add(new MemoryDomain(name, size, MemoryDomain.Endian.Unknown,
|
||||||
|
delegate(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0 || addr >= size)
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
return p[addr];
|
||||||
|
},
|
||||||
|
delegate(int addr, byte val)
|
||||||
|
{
|
||||||
|
if (addr < 0 || addr >= size)
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
p[addr] = val;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryDomains = new MemoryDomainList(mm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
|
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
|
||||||
{
|
{
|
||||||
return new List<KeyValuePair<string, int>>();
|
return new List<KeyValuePair<string, int>>();
|
||||||
|
|
|
@ -44,6 +44,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||||
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void gpgx_clear_sram();
|
public static extern void gpgx_clear_sram();
|
||||||
|
|
||||||
|
public const int MIN_MEM_DOMAIN = 0;
|
||||||
|
public const int MAX_MEM_DOMAIN = 9;
|
||||||
|
|
||||||
|
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
// apparently, if you use built in string marshalling, the interop will assume that
|
||||||
|
// the unmanaged char pointer was allocated in hglobal and try to free it that way
|
||||||
|
public static extern IntPtr gpgx_get_memdom(int which, ref IntPtr area, ref int size);
|
||||||
|
|
||||||
// call this before reading sram returned by gpgx_get_sram()
|
// call this before reading sram returned by gpgx_get_sram()
|
||||||
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void gpgx_sram_prepread();
|
public static extern void gpgx_sram_prepread();
|
||||||
|
|
|
@ -177,7 +177,6 @@ GPGX_EX void gpgx_advance(void)
|
||||||
nsamples = audio_update(soundbuffer);
|
nsamples = audio_update(soundbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GPGX_EX void gpgx_clear_sram(void)
|
GPGX_EX void gpgx_clear_sram(void)
|
||||||
{
|
{
|
||||||
// clear sram
|
// clear sram
|
||||||
|
@ -225,28 +224,110 @@ GPGX_EX void gpgx_sram_commitwrite(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPGX_EX const char* gpgx_get_memdom(int which, void **area, int *size)
|
||||||
|
{
|
||||||
|
if (!area || !size)
|
||||||
|
return NULL;
|
||||||
|
switch (which)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*area = work_ram;
|
||||||
|
*size = 0x10000;
|
||||||
|
return "68K RAM";
|
||||||
|
case 1:
|
||||||
|
*area = zram;
|
||||||
|
*size = 0x2000;
|
||||||
|
return "Z80 RAM";
|
||||||
|
case 2:
|
||||||
|
if (!cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = ext.md_cart.rom;
|
||||||
|
*size = ext.md_cart.romsize;
|
||||||
|
return "MD CART";
|
||||||
|
}
|
||||||
|
else if (scd.cartridge.id)
|
||||||
|
{
|
||||||
|
*area = scd.cartridge.area;
|
||||||
|
*size = scd.cartridge.mask + 1;
|
||||||
|
return "EBRAM";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 3:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.bootrom;
|
||||||
|
*size = 0x20000;
|
||||||
|
return "CD BOOT ROM";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 4:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.prg_ram;
|
||||||
|
*size = 0x80000;
|
||||||
|
return "CD PRG RAM";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 5:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.word_ram[0];
|
||||||
|
*size = 0x20000;
|
||||||
|
return "CD WORD RAM[0] (1M)";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 6:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.word_ram[1];
|
||||||
|
*size = 0x20000;
|
||||||
|
return "CD WORD RAM[1] (1M)";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 7:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.word_ram_2M;
|
||||||
|
*size = 0x40000;
|
||||||
|
return "CD WORD RAM (2M)";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 8:
|
||||||
|
if (cdd.loaded)
|
||||||
|
{
|
||||||
|
*area = scd.bram;
|
||||||
|
*size = 0x2000;
|
||||||
|
return "CD BRAM";
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
case 9:
|
||||||
|
*area = boot_rom;
|
||||||
|
*size = 0x800;
|
||||||
|
return "BOOT ROM";
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GPGX_EX void gpgx_get_sram(void **area, int *size)
|
GPGX_EX void gpgx_get_sram(void **area, int *size)
|
||||||
{
|
{
|
||||||
|
if (!area || !size)
|
||||||
|
return;
|
||||||
|
|
||||||
if (sram.on)
|
if (sram.on)
|
||||||
{
|
{
|
||||||
if (area)
|
*area = sram.sram;
|
||||||
*area = sram.sram;
|
*size = 0x10000;
|
||||||
if (size)
|
|
||||||
*size = 0x10000;
|
|
||||||
}
|
}
|
||||||
else if (scd.cartridge.id)
|
else if (scd.cartridge.id)
|
||||||
{
|
{
|
||||||
if (area)
|
*area = scd.cartridge.area;
|
||||||
*area = scd.cartridge.area;
|
*size = scd.cartridge.mask + 1 + 0x2000;
|
||||||
if (size)
|
|
||||||
*size = scd.cartridge.mask + 1 + 0x2000;
|
|
||||||
}
|
}
|
||||||
else if (cdd.loaded)
|
else if (cdd.loaded)
|
||||||
{
|
{
|
||||||
if (area)
|
*area = scd.bram;
|
||||||
*area = scd.bram;
|
*size = 0x2000;
|
||||||
if (size)
|
|
||||||
*size = 0x2000;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue