One of my frustrations with saturn emulation is that most cores don’t work too well on handheld devices (eg anbernic). YabaSanshiro with the SH2 dynamic recompiler does work mostly fullspeed, but it has some compatibility issues.
I looked into the code a bit to see what it might take to use the dynamic recompiler with beetle-saturn (or maybe Kronos) which has better compatibility.
Here is a list of what I see that would need to be fixed or updated:
-
The dynarec from yabause does not emulate the cache. This is necessary for compatibility with certain games. Fixing this would require the dynamic recompiler to (optionally) generate code for each memory access to check for cache hit or miss.
-
x86-64 is incomplete, and ARM-64 is missing entirely. The original Yabause does work on x86-64 in 64-bit mode, but the dynarec only generates 32-bit code. This is a problem because it requires some hacks to make sure that the process is mapped in the lower 4GB of RAM. uoYabause does have a full x86-64 dynarec based on Titan Project, but this is missing a lot of the optimizations from the original dynarec.
One path to fix this would be to finish the 64-bit support on x86-64 and then port to 64-bit ARM. (32-bit ARM is already done.) Another possibility would be to keep the original instruction decoder and then use lightrec like beetle-psx. That would require creating a proper intermediate representation, which might be a good idea anyway even if not using lightning.
-
Debug output. When debugging output is enabled, it shows the decompiled SH2 code, but not the recompiled output (x86, ARM). This isn’t strictly necessary to add, but I’d want to do it before going further.
-
Threaded compilation to fix the recompilation stuttering problem. The yabause code is not multithreaded at all and everything stops while recompilation is happening. Need to run the recompiler in a separate thread like in beetle-psx. This requires adding thread locks, mutexes, etc.
-
Need to add the VDP1 slowdown hack for certain games.
-
Maybe also want the additional cycle timing checks like beetle-psx does.
-
Yabause dynarec uses a 4K page size for instruction cache invalidation. This code seems to have been inherited from Mupen64plus. This isn’t ideal, but I’m not certain that it actually breaks compatibility with any games. However, the cache mode hacks in mednafen being necessary does suggest that some games are sensitive to the instruction cache behavior, so this needs to be looked into further.
-
User interface needs some improvement to work well on Rocknix etc.
This will probably take more time than I have right now, so I’m wondering if anyone else would be interested in working on this. It’s mostly clear what needs to be done, but it would take a lot of time for testing and debugging. Maybe we could sponsor a series of bounties for each of these tasks. Would anyone be interested in that?