Skip to content

Commit

Permalink
Korean MSX 8KB 0300 (Super Game/Super Multi Game) mapper support. #81
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Dec 22, 2024
1 parent 0abd41d commit 3f47339
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 133 deletions.
1 change: 1 addition & 0 deletions platforms/desktop-shared/Makefile.sources
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOURCES_CXX := \
$(SRC_DIR)/KoreanSMS32KB2000MemoryRule.cpp \
$(SRC_DIR)/KoreanMSX32KB2000MemoryRule.cpp \
$(SRC_DIR)/Korean2000XOR1FMemoryRule.cpp \
$(SRC_DIR)/KoreanMSX8KB0300MemoryRule.cpp \
$(SRC_DIR)/Memory.cpp \
$(SRC_DIR)/MemoryRule.cpp \
$(SRC_DIR)/MSXMemoryRule.cpp \
Expand Down
4 changes: 3 additions & 1 deletion platforms/desktop-shared/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static void main_menu(void)
if (ImGui::BeginMenu("Mapper"))
{
ImGui::PushItemWidth(220.0f);
ImGui::Combo("##emu_mapper", &config_emulator.mapper, "Auto\0ROM Only\0SEGA\0Codemasters\0Korean\0SG-1000\0MSX\0Janggun\0Korean Multi 2000 XOR F1\0Korean Multi MSX 32KB 2000\0Korean Multi MSX SMS 8000\0Korean Multi SMS 32KB 2000\0\0");
ImGui::Combo("##emu_mapper", &config_emulator.mapper, "Auto\0ROM Only\0SEGA\0Codemasters\0Korean\0SG-1000\0MSX\0Janggun\0Korean Multi 2000 XOR F1\0Korean Multi MSX 32KB 2000\0Korean Multi MSX SMS 8000\0Korean Multi SMS 32KB 2000\0Korean Multi MSX 8KB 0300\0\0");
ImGui::PopItemWidth();
ImGui::EndMenu();
}
Expand Down Expand Up @@ -1901,6 +1901,8 @@ static Cartridge::CartridgeTypes get_mapper(int index)
return Cartridge::CartridgeKoreanMSXSMS8000Mapper;
case 11:
return Cartridge::CartridgeKoreanSMS32KB2000Mapper;
case 12:
return Cartridge::CartridgeKoreanMSX8KB0300Mapper;
default:
return Cartridge::CartridgeNotSupported;
}
Expand Down
2 changes: 2 additions & 0 deletions platforms/windows/Gearsystem.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ClCompile Include="..\desktop-shared\renderer.cpp" />
<ClCompile Include="..\..\src\KoreanMSX32KB2000MemoryRule.cpp" />
<ClCompile Include="..\..\src\Korean2000XOR1FMemoryRule.cpp" />
<ClCompile Include="..\..\src\KoreanMSX8KB0300MemoryRule.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\miniz\miniz.h" />
Expand Down Expand Up @@ -144,6 +145,7 @@
<ClInclude Include="..\desktop-shared\renderer.h" />
<ClInclude Include="..\..\src\KoreanMSX32KB2000MemoryRule.h" />
<ClInclude Include="..\..\src\Korean2000XOR1FMemoryRule.h" />
<ClInclude Include="..\..\src\KoreanMSX8KB0300MemoryRule.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\desktop-shared\gui_events.def" />
Expand Down
6 changes: 6 additions & 0 deletions platforms/windows/Gearsystem.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<ClCompile Include="..\..\src\Korean2000XOR1FMemoryRule.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\KoreanMSX8KB0300MemoryRule.cpp">
<Filter>core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\audio-shared\sound_queue.h">
Expand Down Expand Up @@ -407,6 +410,9 @@
<ClInclude Include="..\..\src\Korean2000XOR1FMemoryRule.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\KoreanMSX8KB0300MemoryRule.h">
<Filter>core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\desktop-shared\Makefile.common">
Expand Down
144 changes: 75 additions & 69 deletions src/Cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,34 +128,41 @@ void Cartridge::ForceConfig(Cartridge::ForceConfiguration config)
m_iCRC = CalculateCRC32(0, m_pROM, m_iROMSize);
GatherMetadata(m_iCRC);

if (config.region == CartridgePAL)
switch (config.region)
{
Log("Forcing Region: PAL");
m_bPAL = true;
}
else if (config.region == CartridgeNTSC)
{
Log("Forcing Region: NTSC");
m_bPAL = false;
case CartridgePAL:
Log("Forcing Region: PAL");
m_bPAL = true;
break;
case CartridgeNTSC:
Log("Forcing Region: NTSC");
m_bPAL = false;
break;
default:
Log("Not forcing Region: Auto");
break;
}

if (config.system == CartridgeSMS)
switch (config.system)
{
Log("Forcing System: Master System");
m_bGameGear = false;
m_bSG1000 = false;
}
else if (config.system == CartridgeGG)
{
Log("Forcing System: Game Gear");
m_bGameGear = true;
m_bSG1000 = false;
}
else if (config.system == CartridgeSG1000)
{
Log("Forcing System: SG-1000");
m_bGameGear = false;
m_bSG1000 = true;
case CartridgeSMS:
Log("Forcing System: Master System");
m_bGameGear = false;
m_bSG1000 = false;
break;
case CartridgeGG:
Log("Forcing System: Game Gear");
m_bGameGear = true;
m_bSG1000 = false;
break;
case CartridgeSG1000:
Log("Forcing System: SG-1000");
m_bGameGear = false;
m_bSG1000 = true;
break;
default:
Log("Not forcing System: Auto");
break;
}

switch (config.type)
Expand Down Expand Up @@ -196,6 +203,10 @@ void Cartridge::ForceConfig(Cartridge::ForceConfiguration config)
m_Type = config.type;
Log("Forcing Mapper: Korean 2000 XOR 1F");
break;
case Cartridge::CartridgeKoreanMSX8KB0300Mapper:
m_Type = config.type;
Log("Forcing Mapper: Korean MSX 8KB 0300");
break;
case Cartridge::CartridgeMSXMapper:
m_Type = config.type;
Log("Forcing Mapper: MSX");
Expand All @@ -205,6 +216,7 @@ void Cartridge::ForceConfig(Cartridge::ForceConfiguration config)
Log("Forcing Mapper: Janggun");
break;
default:
Log("Not forcing Mapper: Auto");
break;
}

Expand All @@ -231,6 +243,7 @@ void Cartridge::ForceConfig(Cartridge::ForceConfiguration config)
Log("Forcing Zone: GG International");
break;
default:
Log("Not forcing Zone: Auto");
break;
}
}
Expand Down Expand Up @@ -504,44 +517,32 @@ bool Cartridge::GatherMetadata(u32 crc)
switch (zone)
{
case 3:
{
m_Zone = CartridgeJapanSMS;
Log("Cartridge zone is SMS Japan");
break;
}
case 4:
{
m_Zone = CartridgeExportSMS;
Log("Cartridge zone is SMS Export");
break;
}
case 5:
{
m_Zone = CartridgeJapanGG;
m_bGameGear = true;
Log("Cartridge zone is GG Japan");
break;
}
case 6:
{
m_Zone = CartridgeExportGG;
m_bGameGear = true;
Log("Cartridge zone is GG Export");
break;
}
case 7:
{
m_Zone = CartridgeInternationalGG;
m_bGameGear = true;
Log("Cartridge zone is GG International");
break;
}
default:
{
m_Zone = CartridgeUnknownZone;
Log("Unknown cartridge zone");
break;
}
}

m_iROMBankCount16k = std::max(Pow2Ceil(m_iROMSize / 0x4000), 1u);
Expand Down Expand Up @@ -592,6 +593,9 @@ bool Cartridge::GatherMetadata(u32 crc)
case Cartridge::CartridgeKorean2000XOR1FMapper:
Log("Korean 2000 XOR 1F mapper found");
break;
case Cartridge::CartridgeKoreanMSX8KB0300Mapper:
Log("Korean MSX 8KB 0300 mapper found");
break;
case Cartridge::CartridgeMSXMapper:
Log("MSX mapper found");
break;
Expand Down Expand Up @@ -634,40 +638,42 @@ void Cartridge::GetInfoFromDB(u32 crc)

Log("ROM found in database: %s. CRC: %X", kGameDatabase[i].title, crc);

if (kGameDatabase[i].mapper == GS_DB_CODEMASTERS_MAPPER)
m_Type = Cartridge::CartridgeCodemastersMapper;
else if (kGameDatabase[i].mapper == GS_DB_SG1000_MAPPER)
{
m_bSG1000 = true;
m_Type = Cartridge::CartridgeSG1000Mapper;
}
else if (kGameDatabase[i].mapper == GS_DB_KOREAN_MAPPER)
{
m_Type = Cartridge::CartridgeKoreanMapper;
}
else if (kGameDatabase[i].mapper == GS_DB_KOREAN_MSX_SMS_8000_MAPPER)
{
m_Type = Cartridge::CartridgeKoreanMSXSMS8000Mapper;
}
else if (kGameDatabase[i].mapper == GS_DB_KOREAN_SMS_32KB_2000_MAPPER)
{
m_Type = Cartridge::CartridgeKoreanSMS32KB2000Mapper;
}
else if (kGameDatabase[i].mapper == GS_DB_KOREAN_MSX_32KB_2000_MAPPER)
{
m_Type = Cartridge::CartridgeKoreanMSX32KB2000Mapper;
}
else if (kGameDatabase[i].mapper == GS_DB_KOREAN_2000_XOR_1F_MAPPER)
{
m_Type = Cartridge::CartridgeKorean2000XOR1FMapper;
}
else if (kGameDatabase[i].mapper == GS_DB_MSX_MAPPER)
{
m_Type = Cartridge::CartridgeMSXMapper;
}
else if (kGameDatabase[i].mapper == GS_DB_JANGGUN_MAPPER)
switch (kGameDatabase[i].mapper)
{
m_Type = Cartridge::CartridgeJanggunMapper;
case GS_DB_CODEMASTERS_MAPPER:
m_Type = Cartridge::CartridgeCodemastersMapper;
break;
case GS_DB_SG1000_MAPPER:
m_bSG1000 = true;
m_Type = Cartridge::CartridgeSG1000Mapper;
break;
case GS_DB_KOREAN_MAPPER:
m_Type = Cartridge::CartridgeKoreanMapper;
break;
case GS_DB_KOREAN_MSX_SMS_8000_MAPPER:
m_Type = Cartridge::CartridgeKoreanMSXSMS8000Mapper;
break;
case GS_DB_KOREAN_SMS_32KB_2000_MAPPER:
m_Type = Cartridge::CartridgeKoreanSMS32KB2000Mapper;
break;
case GS_DB_KOREAN_MSX_32KB_2000_MAPPER:
m_Type = Cartridge::CartridgeKoreanMSX32KB2000Mapper;
break;
case GS_DB_KOREAN_2000_XOR_1F_MAPPER:
m_Type = Cartridge::CartridgeKorean2000XOR1FMapper;
break;
case GS_DB_KOREAN_MSX_8KB_0300_MAPPER:
m_Type = Cartridge::CartridgeKoreanMSX8KB0300Mapper;
break;
case GS_DB_MSX_MAPPER:
m_Type = Cartridge::CartridgeMSXMapper;
break;
case GS_DB_JANGGUN_MAPPER:
m_Type = Cartridge::CartridgeJanggunMapper;
break;
default:
m_Type = Cartridge::CartridgeNotSupported;
break;
}

if (kGameDatabase[i].features & GS_DB_FEATURE_SMS_MODE)
Expand Down
1 change: 1 addition & 0 deletions src/Cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Cartridge
CartridgeKoreanSMS32KB2000Mapper,
CartridgeKoreanMSX32KB2000Mapper,
CartridgeKorean2000XOR1FMapper,
CartridgeKoreanMSX8KB0300Mapper,
CartridgeMSXMapper,
CartridgeJanggunMapper,
CartridgeNotSupported
Expand Down
10 changes: 9 additions & 1 deletion src/GearsystemCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "KoreanSMS32KB2000MemoryRule.h"
#include "KoreanMSX32KB2000MemoryRule.h"
#include "Korean2000XOR1FMemoryRule.h"
#include "KoreanMSX8KB0300MemoryRule.h"
#include "MSXMemoryRule.h"
#include "JanggunMemoryRule.h"
#include "SG1000MemoryRule.h"
Expand All @@ -57,6 +58,7 @@ GearsystemCore::GearsystemCore()
InitPointer(m_pKoreanSMS32KB2000MemoryRule);
InitPointer(m_pKoreanMSX32KB2000MemoryRule);
InitPointer(m_pKorean2000XOR1FMemoryRule);
InitPointer(m_pKoreanMSX8KB0300MemoryRule);
InitPointer(m_pMSXMemoryRule);
InitPointer(m_pJanggunMemoryRule);
InitPointer(m_pSmsIOPorts);
Expand All @@ -80,9 +82,10 @@ GearsystemCore::~GearsystemCore()
SafeDelete(m_pKoreanMSXSMS8000MemoryRule);
SafeDelete(m_pKoreanSMS32KB2000MemoryRule);
SafeDelete(m_pKoreanMSX32KB2000MemoryRule);
SafeDelete(m_pKorean2000XOR1FMemoryRule);
SafeDelete(m_pKoreanMSX8KB0300MemoryRule);
SafeDelete(m_pMSXMemoryRule);
SafeDelete(m_pJanggunMemoryRule);
SafeDelete(m_pKorean2000XOR1FMemoryRule);
SafeDelete(m_pCartridge);
SafeDelete(m_pInput);
SafeDelete(m_pVideo);
Expand Down Expand Up @@ -861,6 +864,7 @@ void GearsystemCore::InitMemoryRules()
m_pKoreanSMS32KB2000MemoryRule = new KoreanSMS32KB2000MemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pKoreanMSX32KB2000MemoryRule = new KoreanMSX32KB2000MemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pKorean2000XOR1FMemoryRule = new Korean2000XOR1FMemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pKoreanMSX8KB0300MemoryRule = new KoreanMSX8KB0300MemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pMSXMemoryRule = new MSXMemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pJanggunMemoryRule = new JanggunMemoryRule(m_pMemory, m_pCartridge, m_pInput);
m_pBootromMemoryRule = new BootromMemoryRule(m_pMemory, m_pCartridge, m_pInput);
Expand Down Expand Up @@ -904,6 +908,9 @@ bool GearsystemCore::AddMemoryRules()
case Cartridge::CartridgeKorean2000XOR1FMapper:
m_pMemory->SetCurrentRule(m_pKorean2000XOR1FMemoryRule);
break;
case Cartridge::CartridgeKoreanMSX8KB0300Mapper:
m_pMemory->SetCurrentRule(m_pKoreanMSX8KB0300MemoryRule);
break;
case Cartridge::CartridgeMSXMapper:
m_pMemory->SetCurrentRule(m_pMSXMemoryRule);
break;
Expand Down Expand Up @@ -947,6 +954,7 @@ void GearsystemCore::Reset()
m_pKoreanSMS32KB2000MemoryRule->Reset();
m_pKoreanMSX32KB2000MemoryRule->Reset();
m_pKorean2000XOR1FMemoryRule->Reset();
m_pKoreanMSX8KB0300MemoryRule->Reset();
m_pMSXMemoryRule->Reset();
m_pJanggunMemoryRule->Reset();
m_pBootromMemoryRule->Reset();
Expand Down
3 changes: 2 additions & 1 deletion src/GearsystemCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "definitions.h"
#include "Cartridge.h"
#include "Korean2000XOR1FMemoryRule.h"

class Memory;
class Processor;
Expand All @@ -38,6 +37,7 @@ class KoreanMSXSMS8000MemoryRule;
class KoreanSMS32KB2000MemoryRule;
class KoreanMSX32KB2000MemoryRule;
class Korean2000XOR1FMemoryRule;
class KoreanMSX8KB0300MemoryRule;
class MSXMemoryRule;
class JanggunMemoryRule;
class MemoryRule;
Expand Down Expand Up @@ -116,6 +116,7 @@ class GearsystemCore
KoreanSMS32KB2000MemoryRule* m_pKoreanSMS32KB2000MemoryRule;
KoreanMSX32KB2000MemoryRule* m_pKoreanMSX32KB2000MemoryRule;
Korean2000XOR1FMemoryRule* m_pKorean2000XOR1FMemoryRule;
KoreanMSX8KB0300MemoryRule* m_pKoreanMSX8KB0300MemoryRule;
MSXMemoryRule* m_pMSXMemoryRule;
JanggunMemoryRule* m_pJanggunMemoryRule;
SmsIOPorts* m_pSmsIOPorts;
Expand Down
Loading

0 comments on commit 3f47339

Please sign in to comment.