-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x86/FPU: Always preserve sign in neg.s (Fix GT4 text) #10464
Conversation
Something to keep in mind: This PR changes the default clamping mode for GT4 and has a possibility to break users's save data. There should be a notice for that somewhere (and in general when changing modes specifically with this game). Apologies if this is not the proper place for this. |
if it breaks saves, then folks are gonna have to make a savestate on an older version when this merges or something, then load that and save on the new version. We can't not fix bug because a games behaviour will change, that's making everything suffer for 1 game for a temporary problem. |
Silent did mention that. Unless the save routine specifically negates infinities or NaNs, this change won't break anything. The clamping mode is unchanged. Just the broken behaviour for For what it's worth, my own save seemed fine. But it's definitely something we should test before merging. |
Thank you so very much for this fix! IIRC, this issue has been present for at least 10 years, if not closer to 15, and has long been one of the most common and annoying in the whole game. Finally having working split times and having that silly Fantastic work! Thanks again! Apologies for PR bumping. |
Description of Changes
Finally had the chance to look into this. The "Full Throttle" text getting stuck on screen seems to be due to the following block of instructions (NTSC-U, Version 1.01):
Forcing full EE FPU clamping for this block fixes the text. But that's a janky solution, because it would mean finding the offsets for every release/revision. Instead, I noticed that we're using floating-point min/max, which means that negative NaNs get punted to positive FLT_MAX.
Notice the block starts with
neg.s
. With float clamping,+nan
becomes+FLT_MAX
, instead of actually changing the sign. So the result of the next multiplication would also have its sign inverted. This is what appears to cause the "Full Throttle" text to get stuck on the screen.So, instead of using a higher clamp mode, we can just use integer clamping for
neg.s
. I can't think of why you'd actually want the sign of an input to not change, this behaviour seems very wrong, but it is a global change affecting the default clamping level, so there is some risk. But I'm hoping it should be fine.Rationale behind Changes
Fixes "Full Throttle" text in Gran Turismo 4 without making license tests crash, which happens with full/double FPU.
Fixes split time display.
Also fixes the text in Gran Bikeismo (Tourist Trophy), which isn't surprising, since it's the same engine.
Suggested Testing Steps
Test games known to be sensitive to floating point accuracy.
Make sure GT4 text is fixed, and license tests aren't broken.
To check for save data getting broken: