melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
2.98k stars 493 forks source link

Test on emulator passes, but fails on hardware #2039

Open Kuratius opened 1 month ago

Kuratius commented 1 month ago

image SqrtBench.zip

Expectation would be that the test either passes or fails on both, but the correct percentage is different.

Jaklyy commented 1 month ago

From a quick glance it sounds likely that the square root hardware on the ds takes shortcuts in the calculation That's very interesting

Kuratius commented 1 month ago

I did a bit more testing, I think the framecounter is off by 1. If I put a while(1); at the end of the first while loop, it freezes on frame 1 on the emulator and frame 2 on the nds. This affects the correct percentage because I use the framecounter to keep track of the number of iterations when calculating how many were correct.

Jaklyy commented 1 month ago

what exactly are you running the rom via on hardware? since the frame counter appears to be incremented via interrupt it could be possible its running the interrupt handler an extra time before/during the first frame due to a bug with the bootloader. because i can't actually reproduce that behavior when using a recent-ish build of twilightmenu++ on my 3ds

Jaklyy commented 1 month ago

...however i can reproduce it when installed directly to nand that's very interesting

Kuratius commented 1 month ago

My build of twilightmenu is probably 2-3 years old, but I'm starting the rom from unlaunch so I dont think it matters.