GBHawk: Fix HuC3 SRAM

This commit is contained in:
alyosha-tas 2020-06-04 18:34:39 -04:00
parent 39636f6ef1
commit 92bbf768af
2 changed files with 29 additions and 27 deletions

View File

@ -353,7 +353,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
case 0x22: mapper = new MapperMBC7(); mppr = "MBC7"; has_bat = true; break; case 0x22: mapper = new MapperMBC7(); mppr = "MBC7"; has_bat = true; break;
case 0xFC: mapper = new MapperCamera(); mppr = "CAM"; has_bat = true; break; case 0xFC: mapper = new MapperCamera(); mppr = "CAM"; has_bat = true; break;
case 0xFD: mapper = new MapperTAMA5(); mppr = "TAMA5"; has_bat = true; break; case 0xFD: mapper = new MapperTAMA5(); mppr = "TAMA5"; has_bat = true; break;
case 0xFE: mapper = new MapperHuC3(); mppr = "HuC3"; break; case 0xFE: mapper = new MapperHuC3(); mppr = "HuC3"; has_bat = true; break;
case 0xFF: mapper = new MapperHuC1(); mppr = "HuC1"; break; case 0xFF: mapper = new MapperHuC1(); mppr = "HuC1"; break;
// Bootleg mappers // Bootleg mappers

View File

@ -1,6 +1,7 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Cores.Components.LR35902; using BizHawk.Emulation.Cores.Components.LR35902;
using System;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
@ -58,38 +59,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public override byte ReadMemoryHigh(ushort addr) public override byte ReadMemoryHigh(ushort addr)
{ {
if ((addr >= 0xA000) && (addr < 0xC000)) if ((control >= 0xB) && (control < 0xE))
{ {
if ((control >= 0xB) && (control < 0xE)) if (control == 0xD)
{ {
if (control == 0xD) return 1;
{
return 1;
}
return chip_read;
} }
return chip_read;
}
if (RAM_enable) if (Core.cart_RAM != null)
{
if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length)
{ {
if (Core.cart_RAM != null) return Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000];
{
if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length)
{
return Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000];
}
else
{
return 0xFF;
}
}
else
{
return 0xFF;
}
} }
else else
{ {
// what to return if RAM not enabled and controller not selected?
return 0xFF; return 0xFF;
} }
} }
@ -170,8 +156,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else else
{ {
if (RAM_enable && ((control < 0xB) || (control > 0xE))) if ((control < 0xB) || (control > 0xE))
{ {
if (!RAM_enable)
{
return;
}
if (Core.cart_RAM != null) if (Core.cart_RAM != null)
{ {
if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length) if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length)
@ -179,6 +170,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000] = value; Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000] = value;
} }
} }
return;
} }
if (control == 0xB) if (control == 0xB)
@ -243,6 +236,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
// maybe IR // maybe IR
} }
// Still write to RAM if another command executed
if (Core.cart_RAM != null)
{
if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length)
{
Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000] = value;
}
}
} }
} }