Skip to content

Commit

Permalink
Add Dreamcast 32MB RAM Mod (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
cepawiel authored Sep 22, 2023
1 parent 2445739 commit a7dbbbe
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/cfg/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Option<int> GDBPort("Debug.GDBPort", debugger::DEFAULT_PORT);
Option<bool> GDBWaitForConnection("Debug.GDBWaitForConnection");
Option<bool> UseReios("UseReios");
Option<bool> FastGDRomLoad("FastGDRomLoad", false);
Option<bool> RamMod32MB("Dreamcast.RamMod32MB", false);

Option<bool> OpenGlChecks("OpenGlChecks", false, "validate");

Expand Down
1 change: 1 addition & 0 deletions core/cfg/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ extern Option<int> GDBPort;
extern Option<bool> GDBWaitForConnection;
extern Option<bool> UseReios;
extern Option<bool> FastGDRomLoad;
extern Option<bool> RamMod32MB;

extern Option<bool> OpenGlChecks;

Expand Down
2 changes: 1 addition & 1 deletion core/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void setPlatform(int platform)
switch (platform)
{
case DC_PLATFORM_DREAMCAST:
settings.platform.ram_size = 16_MB;
settings.platform.ram_size = config::RamMod32MB ? 32_MB : 16_MB;
settings.platform.vram_size = 8_MB;
settings.platform.aram_size = 2_MB;
settings.platform.bios_size = 2_MB;
Expand Down
5 changes: 5 additions & 0 deletions core/rend/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,11 @@ static void gui_display_settings()
OptionCheckbox("Serial Console", config::SerialConsole,
"Dump the Dreamcast serial console to stdout");
#endif
{
DisabledScope scope(game_started);
OptionCheckbox("Dreamcast 32MB RAM Mod", config::RamMod32MB,
"Enables 32MB RAM Mod for Dreamcast. May affect compatibility");
}
OptionCheckbox("Dump Textures", config::DumpTextures,
"Dump all textures into data/texdump/<game id>");

Expand Down
14 changes: 13 additions & 1 deletion core/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class SerializeBase
V39,
V40,
V41,
Current = V41,
V42,
Current = V42,

Next = Current + 1,
};
Expand Down Expand Up @@ -101,6 +102,15 @@ class Deserializer : public SerializeBase
throw Exception("Unsupported version");
if (_version > Current)
throw Exception("Version too recent");

if(_version >= V42 && settings.platform.isConsole())
{
u32 ramSize;
deserialize(ramSize);
if (ramSize != settings.platform.ram_size) {
throw Exception("Selected RAM Size doesn't match Save State");
}
}
}

template<typename T>
Expand Down Expand Up @@ -162,6 +172,8 @@ class Serializer : public SerializeBase
{
Version v = Current;
serialize(v);
if (settings.platform.isConsole())
serialize(settings.platform.ram_size);
}

template<typename T>
Expand Down
14 changes: 14 additions & 0 deletions shell/libretro/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"disabled",
#endif
},
{
CORE_OPTION_NAME "_dc_32mb_mod",
"Dreamcast 32MB RAM Mod",
NULL,
"Enables 32MB RAM Mod for Dreamcast. May affect compatibility",
NULL,
"hacks",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled",
},
{
CORE_OPTION_NAME "_sh4clock",
"SH4 CPU under/overclock",
Expand Down
1 change: 1 addition & 0 deletions shell/libretro/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Option<bool> UseReios(CORE_OPTION_NAME "_hle_bios");

Option<bool> OpenGlChecks("", false);
Option<bool> FastGDRomLoad(CORE_OPTION_NAME "_gdrom_fast_loading", false);
Option<bool> RamMod32MB(CORE_OPTION_NAME "_dc_32mb_mod", false);

//Option<std::vector<std::string>, false> ContentPath("");
//Option<bool, false> HideLegacyNaomiRoms("", true);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/serialize_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST_F(SerializeTest, SizeTest)
std::vector<char> data(30000000);
Serializer ser(data.data(), data.size());
dc_serialize(ser);
ASSERT_EQ(28191378u, ser.size());
ASSERT_EQ(28191382u, ser.size());
}


Expand Down

0 comments on commit a7dbbbe

Please sign in to comment.