Added some GG games

This commit is contained in:
2026-05-26 23:22:04 +01:00
parent 4a0424a664
commit 2f332ff224
5 changed files with 24 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ namespace Core.Memory
{ {
public class SmsMemoryBus : IMemory public class SmsMemoryBus : IMemory
{ {
private bool _isCodemastersMapper = false; //Codemasters used their own memory mapper
// SMS has 8KB of internal Work RAM // SMS has 8KB of internal Work RAM
private readonly byte[] _workRam = new byte[0x2000]; private readonly byte[] _workRam = new byte[0x2000];
@@ -49,6 +50,10 @@ namespace Core.Memory
if (address < 0x4000) if (address < 0x4000)
{ {
if (!_isCodemastersMapper && address < 0x0400)
{
return _cartridgeRom[address];
}
if (address < 0x0400) if (address < 0x0400)
{ {
return _cartridgeRom[address]; return _cartridgeRom[address];
@@ -76,6 +81,18 @@ namespace Core.Memory
public void Write(ushort address, byte value) 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 < 0x8000) return; // Cannot write to physical ROM
if (address < 0xC000) if (address < 0xC000)
@@ -266,6 +283,7 @@ namespace Core.Memory
{ {
Array.Clear(_workRam, 0, _workRam.Length); Array.Clear(_workRam, 0, _workRam.Length);
_mapperControl = 0; _mapperControl = 0;
_isCodemastersMapper = false;
} }
} }
} }

View File

@@ -27,6 +27,7 @@
<ItemGroup> <ItemGroup>
<None Remove="ROMS\After Burner %28UE%29 [!].sms" /> <None Remove="ROMS\After Burner %28UE%29 [!].sms" />
<None Remove="ROMS\Aladdin %28USA, Europe, Brazil%29.gg" />
<None Remove="ROMS\Alex Kidd in High Tech World %28UE%29 [!].sms" /> <None Remove="ROMS\Alex Kidd in High Tech World %28UE%29 [!].sms" />
<None Remove="ROMS\Alex Kidd in Miracle World %28UE%29 [!].sms" /> <None Remove="ROMS\Alex Kidd in Miracle World %28UE%29 [!].sms" />
<None Remove="ROMS\Back to the Future 2 %28UE%29 [!].sms" /> <None Remove="ROMS\Back to the Future 2 %28UE%29 [!].sms" />
@@ -94,6 +95,8 @@
<None Remove="ROMS\Sonic 1 GG.gg" /> <None Remove="ROMS\Sonic 1 GG.gg" />
<None Remove="ROMS\Sonic 2.sms" /> <None Remove="ROMS\Sonic 2.sms" />
<None Remove="ROMS\Sonic Chaos %28UE%29 [!].sms" /> <None Remove="ROMS\Sonic Chaos %28UE%29 [!].sms" />
<None Remove="ROMS\Sonic The Hedgehog - Triple Trouble %28USA, Europe, Brazil%29.gg" />
<None Remove="ROMS\Sonic The Hedgehog 2 %28World%29.gg" />
<None Remove="ROMS\Sonic.sms" /> <None Remove="ROMS\Sonic.sms" />
<None Remove="ROMS\Space Harrier %28USA%29.sms" /> <None Remove="ROMS\Space Harrier %28USA%29.sms" />
<None Remove="ROMS\Speedball %28UE%29 %28Virgin%29 [!].sms" /> <None Remove="ROMS\Speedball %28UE%29 %28Virgin%29 [!].sms" />
@@ -126,6 +129,7 @@
<EmbeddedResource Include="ROMS\After Burner (UE) [!].sms"> <EmbeddedResource Include="ROMS\After Burner (UE) [!].sms">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="ROMS\Aladdin (USA, Europe, Brazil).gg" />
<EmbeddedResource Include="ROMS\Alex Kidd in High Tech World (UE) [!].sms"> <EmbeddedResource Include="ROMS\Alex Kidd in High Tech World (UE) [!].sms">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
@@ -309,6 +313,8 @@
<EmbeddedResource Include="ROMS\Sonic Chaos (UE) [!].sms"> <EmbeddedResource Include="ROMS\Sonic Chaos (UE) [!].sms">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="ROMS\Sonic The Hedgehog - Triple Trouble (USA, Europe, Brazil).gg" />
<EmbeddedResource Include="ROMS\Sonic The Hedgehog 2 (World).gg" />
<EmbeddedResource Include="ROMS\Sonic.sms"> <EmbeddedResource Include="ROMS\Sonic.sms">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>

Binary file not shown.

Binary file not shown.