PSI-Rockin / DobieStation

A dog-themed PS2 emulator
GNU General Public License v3.0
524 stars 55 forks source link

Games that abuse floating-point inaccuracies #245

Open PSI-Rockin opened 4 years ago

PSI-Rockin commented 4 years ago

While many games perhaps have missing polygons or minor SPS due to rounding and clamping issues, this list is reserved for games that outright break when floating-point math is inaccurate.

This list is incomplete and needs more examples.

weirdbeardgame commented 4 years ago

I'll post the classic games Katamari Damacy, If the floating points in this game are known to get quite massive having a variety of effects A. the game will turn into or explode into a mess of massive SPS causing the game world to be unviewable or B. the objects will not be attached to the ball or in the incorrect positions

gran turismo 4 with out proper accuracy cars will randomly be in space

tadanokojin commented 4 years ago

https://github.com/PCSX2/pcsx2/issues/2990

is worth a mention I think

weirdbeardgame commented 4 years ago

Klonoa 2 without proper rounding the Green sphere elevators will be in the wrong positions and the wrong size

PSI-Rockin commented 4 years ago

To clarify on the Powerdrome problem. Note that MAX_FLT and MIN_FLT respectively are from x86's perspective - the PS2 can support floats up to MAX_FLT 2 and MIN_FLT 2.

The VU1 pseudocode is something like this:

upper_bound = MAX_FLT
lower_bound = MIN_FLT
loop:
    ... process vertex ...
    upper_bound = max(upper_bound, vertex)
    lower_bound = min(lower_bound, vertex)
    goto loop if not all vertices are processed
diff = 0.5 * (upper_bound - lower_bound) + lower_bound

diff gets used in vertex culling code. Because on all emulators, it ends up equaling 0.5 * MIN_FLT, the culling code is triggered and the vertices are discarded unnecessarily.

This is impossible to emulate correctly without using softfloats, which will unnecessarily slow down emulation. The best course of action is to patch the code at the following addresses:

[$3820] 8020005e:7f7fffff muli.w vf1, vf0, I            loi 0x7f7fffff
[$3828] 81c000a2:ff7fffff addi.xyz vf2, vf0, I          loi 0xff7fffff

The LOIs may be changed to MAX_FLT / 2 and MIN_FLT / 2 respectively to work on emulators. The micro's CRC is 0x7FEF354E.

refractionpcsx2 commented 4 years ago

Powerdrome VU data is stored in the following EE memory addresses on the PAL release at least 0x0037A688 = ff7fffff 0x0037A680 = 7f7fffff

ps1freak26 commented 2 years ago

Destruction Derby Arenas has corrupt textures from floating point inaccuracies.