Skip to content

Commit 15eb6f9

Browse files
committed
don’t randomize ram
Signed-off-by: Joseph Mattiello <[email protected]>
1 parent f8a4170 commit 15eb6f9

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

libretro.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,41 @@ bool retro_load_game(const struct retro_game_info *info)
12221222

12231223
JaguarReset();
12241224

1225+
/* JaguarReset() randomizes all of main RAM ($8–$200000), which
1226+
* destroys RAM-loaded executables (ABS/COFF files loaded at $4000).
1227+
* Cartridge ROMs are fine since they live in jagMemSpace + $800000.
1228+
* Fix: re-load the file into RAM after the reset completes. */
1229+
if (!jaguarCartInserted && !jaguar_cd_mode)
1230+
{
1231+
if (info->data && info->size > 0)
1232+
{
1233+
JaguarLoadFile((uint8_t*)info->data, info->size);
1234+
}
1235+
else if (info->path)
1236+
{
1237+
RFILE *romFile = rfopen(info->path, "rb");
1238+
if (romFile)
1239+
{
1240+
int64_t fileSize;
1241+
uint8_t *romData;
1242+
1243+
rfseek(romFile, 0, SEEK_END);
1244+
fileSize = rftell(romFile);
1245+
rfseek(romFile, 0, SEEK_SET);
1246+
1247+
romData = (uint8_t *)malloc(fileSize);
1248+
if (romData)
1249+
{
1250+
rfread(romData, 1, fileSize, romFile);
1251+
JaguarLoadFile(romData, fileSize);
1252+
free(romData);
1253+
}
1254+
rfclose(romFile);
1255+
}
1256+
}
1257+
SET32(jaguarMainRAM, 4, jaguarRunAddress);
1258+
}
1259+
12251260
/* HLE CD boot: if CD mode and no external BIOS, boot via HLE.
12261261
* Must happen after JaguarReset() since reset clears RAM/GPU state. */
12271262
if (jaguar_cd_mode && !cd_bios_loaded_externally)

0 commit comments

Comments
 (0)