Open OctagonIsAnAmazingShape opened 5 months ago
It looks like upstream is welcoming PRs to fix this: https://github.com/mupen64plus/mupen64plus-core/issues/1049#issuecomment-1890265909
The Mupen64Plus core has a hardcoded 64MB limit for loading data off the cartridge, and bypassing it causes it to overflow and wrap back to 0.
The file in question (src/device/cart/cart_rom.c) has the constant
#define CART_ROM_ADDR_MASK UINT32_C(0x03ffffff);
and is used ascart_addr &= CART_ROM_ADDR_MASK;
in various DMA functions. This means reading a value above 64MB from the base address of the cartridge causes it to wrap around, obviously causing undefined behaviour.Setting the mask to
0x0fffffff
bumps the limit up to 256MB, enabling virtually all N64 ROMs to be opened. B3313 was the test ROM and it would crash when loading until I recompiled the core with this new mask.
Interestingly I was able to edit cart_rom.c and successfully compile mupen64plus.dll with the previous build of RMG (0.5.6) with the suggested fix and b3313 worked perfectly. However, doing the same edit with the updated mupen64plus core (version with v0.5.7) doesn't seem to make b3313 work at all (immediately fails on launch as opposed to previously crashing on the file selection with an unpatched mupen64plus core in 0.5.6 and earlier). Perhaps further edits need doing on the latest version of the core ?
The Mupen64Plus core has a hardcoded 64MB limit for loading data off the cartridge, and bypassing it causes it to overflow and wrap back to 0.
The file in question (src/device/cart/cart_rom.c) has the constant
#define CART_ROM_ADDR_MASK UINT32_C(0x03ffffff);
and is used ascart_addr &= CART_ROM_ADDR_MASK;
in various DMA functions. This means reading a value above 64MB from the base address of the cartridge causes it to wrap around, obviously causing undefined behaviour.Setting the mask to
0x0fffffff
bumps the limit up to 256MB, enabling virtually all N64 ROMs to be opened. B3313 was the test ROM and it would crash when loading until I recompiled the core with this new mask.