mupen64plus-core icon indicating copy to clipboard operation
mupen64plus-core copied to clipboard

Fix incorrect maximum ROM size

Open Rosalie241 opened this issue 11 months ago • 16 comments
trafficstars

This allows ROMs larger than 64MiB to work in mupen64plus.

Tested with the following ROMs:

You can find documentation about the console limitations here:

  • https://n64brew.dev/wiki/Memory_map
  • https://n64brew.dev/wiki/FAQ

Fixes #997 Fixes #1101

Rosalie241 avatar Dec 16 '24 01:12 Rosalie241

This is much better than the previous attempt #685

Looking at your latest modifications, there seems to be a lot more "limits" to change... I can't be of much help in that regard. Add this ROM to your tests, in my case it always soft freeze (my ParaLLEl RDP/RSP forks are too old =P) on the same part... I don't know if it works with Ares or some other emulator. The ideal would be to test it with EverDrive or something similar.

Jj0YzL5nvJ avatar Dec 16 '24 14:12 Jj0YzL5nvJ

I would also make sure to check that Paper Mario still works (and that it can save). I remember it did something where it wrote outside the cart address space, but maybe I'm remembering wrong

loganmc10 avatar Dec 16 '24 14:12 loganmc10

I would also make sure to check that Paper Mario still works (and that it can save). I remember it did something where it wrote outside the cart address space, but maybe I'm remembering wrong

Just tested, saving works fine.

GhostlyDark avatar Jan 04 '25 15:01 GhostlyDark

This is much better than the previous attempt #685

Looking at your latest modifications, there seems to be a lot more "limits" to change... I can't be of much help in that regard. Add this ROM to your tests, in my case it always soft freeze (my ParaLLEl RDP/RSP forks are too old =P) on the same part... I don't know if it works with Ares or some other emulator. The ideal would be to test it with EverDrive or something similar.

It does work with Angrylion (fine) and Parallel RDP (glitches), but only with Parallel RSP. Other RSP plugins just freeze on boot.

image

image

GhostlyDark avatar Jan 04 '25 17:01 GhostlyDark

It pass with this build: https://github.com/Rosalie241/RMG/actions/runs/12344405888

But the same build fails with the CI cores: https://github.com/mupen64plus/mupen64plus-core/actions?query=branch%3Afix-romsize

That ROM seems to be extremely sensitive to compiler optimizations...

Jj0YzL5nvJ avatar Jan 05 '25 00:01 Jj0YzL5nvJ

It pass with this build: https://github.com/Rosalie241/RMG/actions/runs/12344405888

But the same build fails with the CI cores: https://github.com/mupen64plus/mupen64plus-core/actions?query=branch%3Afix-romsize

That ROM seems to be extremely sensitive to compiler optimizations...

It plays back fully for you without issues? on Fedora it hangs eventually for me when built locally sadly, though now that you mention compiler optimizations, I've had issues with that before while working on improving FPU accuracy, which is extremely frustrating.

Rosalie241 avatar Jan 08 '25 18:01 Rosalie241

It plays back fully for you without issues?

Only on Windows and Wine with this configuration...

Jj0YzL5nvJ avatar Jan 09 '25 11:01 Jj0YzL5nvJ

It plays back fully for you without issues?

Only on Windows and Wine with this configuration...

Thank you, I can confirm it plays fully with paraLLEl RSP and angrylion-rdp-plus on Windows

image

I can also confirm it works on Linux:

image

I can also confirm saving in Paper Mario works fine still.

Rosalie241 avatar Jan 09 '25 11:01 Rosalie241

Thanks to the help of @GhostlyDark, we managed to find a solution to the unreliable behavior, it was a mistake I made.

@Jj0YzL5nvJ can you test it again with the latest changes? It works for GhostlyDark and me fine now.

Rosalie241 avatar Jan 10 '25 17:01 Rosalie241

This seems to break loading roms in init_mem_base on a linux aarch64 device with only 2 GB of ram I assume due to MB_MAX_SIZE_FULL being bumped way up

kay-lambdadelta avatar Jan 27 '25 16:01 kay-lambdadelta

This seems to break loading roms in init_mem_base on a linux aarch64 device with only 2 GB of ram I assume due to MB_MAX_SIZE_FULL being bumped way up

Interesting, I suppose I'll add a compile option called ACCURATE_ROM_RANGE so by default mupen64plus-core will still work on low end systems.

Rosalie241 avatar Jan 27 '25 16:01 Rosalie241

I know mupen64plus copies the ROM to RAM, but mapping and reserving the maximum possible ROM size to RAM seems a bit excessive even for machines with more than 8 GiB of RAM. Perhaps it would be better to reserve a cache of 128 MiB and if the ROM really is 4 GiB, copy the rest to that cache as required...

Jj0YzL5nvJ avatar Jan 27 '25 21:01 Jj0YzL5nvJ

I'll make changes once these changes have been reviewed, because I'm not sure what the best course of action is at the moment, cc @richard42

Rosalie241 avatar Jan 28 '25 16:01 Rosalie241

mapping and reserving the maximum possible ROM size to RAM seems a bit excessive even for machines with more than 8 GiB of RAM

Just because the process asks for 4 GiB of memory doesn't mean that it will suddenly consume that much RAM. Virtual memory is silly like that - modern OSes should assign physical RAM only when the virtual memory actually gets accessed.

That being said this is a concern on 32 bit platforms where you can't just reserve the entire address space worth, or possibly OSes that aren't as smart with their memory management

Chlorobite avatar Mar 07 '25 17:03 Chlorobite

mapping and reserving the maximum possible ROM size to RAM seems a bit excessive even for machines with more than 8 GiB of RAM

Just because the process asks for 4 GiB of memory doesn't mean that it will suddenly consume that much RAM. Virtual memory is silly like that - modern OSes should assign physical RAM only when the virtual memory actually gets accessed.

That being said this is a concern on 32 bit platforms where you can't just reserve the entire address space worth, or possibly OSes that aren't as smart with their memory management

it wont run without kernel overcommit enabled (default off in kernel iirc)

m4xw avatar Mar 07 '25 17:03 m4xw

I've updated the patch to use a separate rom pointer which is dynamically allocated in open_rom, this should solve the memory requirements of lower end systems, the compressed memory is also smaller now due to that.

Rosalie241 avatar Mar 23 '25 12:03 Rosalie241