GB3x: update saveram and memory domains

This commit is contained in:
alyosha-tas 2019-09-15 16:19:48 -04:00
parent 0bd3553c27
commit d5c9f32095
2 changed files with 85 additions and 12 deletions

View File

@ -20,6 +20,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
addr => L.RAM[addr], addr => L.RAM[addr],
(addr, value) => L.RAM[addr] = value, (addr, value) => L.RAM[addr] = value,
1), 1),
new MemoryDomainDelegate(
"Main RAM C",
C.RAM.Length,
MemoryDomain.Endian.Little,
addr => C.RAM[addr],
(addr, value) => C.RAM[addr] = value,
1),
new MemoryDomainDelegate( new MemoryDomainDelegate(
"Main RAM R", "Main RAM R",
R.RAM.Length, R.RAM.Length,
@ -34,6 +41,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
addr => L.ZP_RAM[addr], addr => L.ZP_RAM[addr],
(addr, value) => L.ZP_RAM[addr] = value, (addr, value) => L.ZP_RAM[addr] = value,
1), 1),
new MemoryDomainDelegate(
"Zero Page RAM C",
C.ZP_RAM.Length,
MemoryDomain.Endian.Little,
addr => C.ZP_RAM[addr],
(addr, value) => C.ZP_RAM[addr] = value,
1),
new MemoryDomainDelegate( new MemoryDomainDelegate(
"Zero Page RAM R", "Zero Page RAM R",
R.ZP_RAM.Length, R.ZP_RAM.Length,
@ -48,6 +62,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
addr => PeekSystemBusL(addr), addr => PeekSystemBusL(addr),
(addr, value) => PokeSystemBusL(addr, value), (addr, value) => PokeSystemBusL(addr, value),
1), 1),
new MemoryDomainDelegate(
"System Bus C",
0X10000,
MemoryDomain.Endian.Little,
addr => PeekSystemBusC(addr),
(addr, value) => PokeSystemBusC(addr, value),
1),
new MemoryDomainDelegate( new MemoryDomainDelegate(
"System Bus R", "System Bus R",
0X10000, 0X10000,
@ -62,6 +83,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
addr => L._rom[addr], addr => L._rom[addr],
(addr, value) => L._rom[addr] = value, (addr, value) => L._rom[addr] = value,
1), 1),
new MemoryDomainDelegate(
"ROM C",
C._rom.Length,
MemoryDomain.Endian.Little,
addr => C._rom[addr],
(addr, value) => C._rom[addr] = value,
1),
new MemoryDomainDelegate( new MemoryDomainDelegate(
"ROM R", "ROM R",
R._rom.Length, R._rom.Length,
@ -76,6 +104,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
addr => L.VRAM[addr], addr => L.VRAM[addr],
(addr, value) => L.VRAM[addr] = value, (addr, value) => L.VRAM[addr] = value,
1), 1),
new MemoryDomainDelegate(
"VRAM C",
C.VRAM.Length,
MemoryDomain.Endian.Little,
addr => C.VRAM[addr],
(addr, value) => C.VRAM[addr] = value,
1),
new MemoryDomainDelegate( new MemoryDomainDelegate(
"VRAM R", "VRAM R",
R.VRAM.Length, R.VRAM.Length,
@ -91,6 +126,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
domains.Add(CartRamL); domains.Add(CartRamL);
} }
if (C.cart_RAM != null)
{
var CartRamC = new MemoryDomainByteArray("Cart RAM C", MemoryDomain.Endian.Little, C.cart_RAM, true, 1);
domains.Add(CartRamC);
}
if (R.cart_RAM != null) if (R.cart_RAM != null)
{ {
var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.cart_RAM, true, 1); var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.cart_RAM, true, 1);
@ -107,6 +148,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
return L.PeekMemory(addr2); return L.PeekMemory(addr2);
} }
private byte PeekSystemBusC(long addr)
{
ushort addr2 = (ushort)(addr & 0xFFFF);
return C.PeekMemory(addr2);
}
private byte PeekSystemBusR(long addr) private byte PeekSystemBusR(long addr)
{ {
ushort addr2 = (ushort)(addr & 0xFFFF); ushort addr2 = (ushort)(addr & 0xFFFF);
@ -119,6 +166,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
L.WriteMemory(addr2, value); L.WriteMemory(addr2, value);
} }
private void PokeSystemBusC(long addr, byte value)
{
ushort addr2 = (ushort)(addr & 0xFFFF);
C.WriteMemory(addr2, value);
}
private void PokeSystemBusR(long addr, byte value) private void PokeSystemBusR(long addr, byte value)
{ {
ushort addr2 = (ushort)(addr & 0xFFFF); ushort addr2 = (ushort)(addr & 0xFFFF);

View File

@ -7,10 +7,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
{ {
public byte[] CloneSaveRam() public byte[] CloneSaveRam()
{ {
if ((L.cart_RAM != null) || (R.cart_RAM != null)) if ((L.cart_RAM != null) || (C.cart_RAM != null) || (R.cart_RAM != null))
{ {
int Len1 = 0; int Len1 = 0;
int Len2 = 0; int Len2 = 0;
int Len3 = 0;
int index = 0; int index = 0;
if (L.cart_RAM != null) if (L.cart_RAM != null)
@ -18,12 +19,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
Len1 = L.cart_RAM.Length; Len1 = L.cart_RAM.Length;
} }
if (R.cart_RAM != null) if (C.cart_RAM != null)
{ {
Len2 = R.cart_RAM.Length; Len2 = C.cart_RAM.Length;
} }
byte[] temp = new byte[Len1 + Len2]; if (R.cart_RAM != null)
{
Len3 = R.cart_RAM.Length;
}
byte[] temp = new byte[Len1 + Len2 + Len3];
if (L.cart_RAM != null) if (L.cart_RAM != null)
{ {
@ -34,6 +40,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
} }
} }
if (C.cart_RAM != null)
{
for (int i = 0; i < C.cart_RAM.Length; i++)
{
temp[index] = C.cart_RAM[i];
index++;
}
}
if (R.cart_RAM != null) if (R.cart_RAM != null)
{ {
for (int i = 0; i < L.cart_RAM.Length; i++) for (int i = 0; i < L.cart_RAM.Length; i++)
@ -53,18 +68,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
public void StoreSaveRam(byte[] data) public void StoreSaveRam(byte[] data)
{ {
if ((L.cart_RAM != null) && (R.cart_RAM == null)) int temp = 0;
if (L.cart_RAM != null)
{ {
Buffer.BlockCopy(data, 0, L.cart_RAM, 0, L.cart_RAM.Length); Buffer.BlockCopy(data, temp, L.cart_RAM, 0, L.cart_RAM.Length);
temp += L.cart_RAM.Length;
} }
else if ((R.cart_RAM != null) && (L.cart_RAM == null))
if (C.cart_RAM != null)
{ {
Buffer.BlockCopy(data, 0, R.cart_RAM, 0, R.cart_RAM.Length); Buffer.BlockCopy(data, temp, C.cart_RAM, 0, C.cart_RAM.Length);
temp += C.cart_RAM.Length;
} }
else if ((R.cart_RAM != null) && (L.cart_RAM != null))
if (R.cart_RAM != null)
{ {
Buffer.BlockCopy(data, 0, L.cart_RAM, 0, L.cart_RAM.Length); Buffer.BlockCopy(data, temp, R.cart_RAM, 0, R.cart_RAM.Length);
Buffer.BlockCopy(data, L.cart_RAM.Length, R.cart_RAM, 0, R.cart_RAM.Length);
} }
Console.WriteLine("loading SRAM here"); Console.WriteLine("loading SRAM here");
@ -74,7 +94,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
{ {
get get
{ {
return (L.has_bat || R.has_bat) & Link3xSyncSettings.Use_SRAM; return (L.has_bat || C.has_bat || R.has_bat) & Link3xSyncSettings.Use_SRAM;
} }
} }
} }