Closed exelotl closed 6 months ago
Hey there, just adding this to not forget about what the issue is. The issue is with the STM instructions. In particular, the divmod code (likely handwritten asm) for the armv4 uses a "push {sp, lr}" instruction, which in gpsp is incorrectly emulated. The new SP value is written to memory, as opposed to the old value. According to GBATEK and other emus, there's a few corner cases for this instruction which we do not handle. Thanks for the report. This is a high quality report and helps a lot :)
Allright! I fixed this issue on the interpreter (in my fork) and seems to properly run the attached demo. I will rewrite some of the dynarec code to bring the fix to all platforms. Thanks again for the report! It seems many homebrew run into this due to some library code that devkitpro's toolchain ships.
Added a few fixes. Doesnt fix the issue a 100% yet (only ARM mode for now), and the dynarec doesn't correctly emulate the CPU behavriou, but it behaves like mGBA does, so it should work. Lemme know if it still fails in some other funny way :) I will keep this open until I fix the other instructions and some other funny corner cases. Thanks!
Not all LDM/STM instructions have been fixed, however I wrote a few tests to track this (at https://github.com/davidgfnet/test-rom-suite/). I'm gonna close this since the reported issue is indeed fixed, and perhaps file an issue to ensure we fix other corner cases. Thanks for the report! Fixed a few other homebrews
Whenever a 64-bit integer division occurs (signed or unsigned), my game hangs.
I guess the underlying cause isn't specific to division, since division is done in software on the GBA. Maybe there's some instruction within the 64-bit division routine in libgcc that's not emulated properly?
Here's an example:
Here's the project (build files included, can be recompiled with devkitARM): gpsp_bug.zip