Added some GG games
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Core.Memory
|
||||
{
|
||||
public class SmsMemoryBus : IMemory
|
||||
{
|
||||
private bool _isCodemastersMapper = false; //Codemasters used their own memory mapper
|
||||
// SMS has 8KB of internal Work RAM
|
||||
private readonly byte[] _workRam = new byte[0x2000];
|
||||
|
||||
@@ -49,6 +50,10 @@ namespace Core.Memory
|
||||
|
||||
if (address < 0x4000)
|
||||
{
|
||||
if (!_isCodemastersMapper && address < 0x0400)
|
||||
{
|
||||
return _cartridgeRom[address];
|
||||
}
|
||||
if (address < 0x0400)
|
||||
{
|
||||
return _cartridgeRom[address];
|
||||
@@ -76,6 +81,18 @@ namespace Core.Memory
|
||||
|
||||
public void Write(ushort address, byte value)
|
||||
{
|
||||
// Codemasters games bank-switch by writing directly to ROM!
|
||||
if (address == 0x0000 || address == 0x4000 || address == 0x8000)
|
||||
{
|
||||
_isCodemastersMapper = true;
|
||||
int cTotalBanks = _cartridgeRom.Length / 0x4000;
|
||||
if (cTotalBanks == 0) cTotalBanks = 1;
|
||||
|
||||
if (address == 0x0000) _romBank0 = value % cTotalBanks;
|
||||
else if (address == 0x4000) _romBank1 = value % cTotalBanks;
|
||||
else if (address == 0x8000) _romBank2 = value % cTotalBanks;
|
||||
return;
|
||||
}
|
||||
if (address < 0x8000) return; // Cannot write to physical ROM
|
||||
|
||||
if (address < 0xC000)
|
||||
@@ -266,6 +283,7 @@ namespace Core.Memory
|
||||
{
|
||||
Array.Clear(_workRam, 0, _workRam.Length);
|
||||
_mapperControl = 0;
|
||||
_isCodemastersMapper = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user