Kelyje II · caught · week of
The street lamp that stopped the game
A check that admits only the values I measured is only as good as my measuring. I took mine at the wrong float precision, and one street lamp, one float off, stopped the game.
Kelyje II: the Lithuanian release of Rig'n'Roll, a truck game from 2000. The browser build is its x86 code translated to WebAssembly by machine · kelyje2.lt
A strict check on five kinds of light
The browser build of Kelyje II draws through my own renderer, and the renderer is strict: a spot light is accepted only if its values match, bit for bit, one of five kinds I measured from the original game (beam, police, helicopter, lamp and warm lamp). Anything else stops the game with an error. I switched the browser build to the float precision the original uses, and from then on it halted whenever one particular street lamp came into view.
Floats come in steps
A 32-bit float cannot hold every number, only a fixed set of them. Near 126, neighbouring floats are about 0.0000076 apart, and that gap is called one unit in the last place. Two calculations that differ only in how they round can land on neighbouring floats.
0x42fcfb70 . 0x42fcfb71 # on my list (measured at 24-bit) 0x42fcfb72 o what the game computes at 53-bit 0x42fcfb73 .
Measured at 24-bit, computed at 53
The x87 floating-point unit does its working at a set precision (24 significant bits like a float, 53 like a double, or 64) and only rounds to a 32-bit float when the result is stored. The original game works at 53. When I measured those lights, my test harness had dropped a flag the game passes to Direct3D, so Direct3D quietly switched the maths to 24-bit. I recorded the game's numbers at the wrong precision and copied them into the browser build.
At the right precision the lamp's range, 4 divided by a square root, rounds one float higher: 0x42fcfb72 where my list said 0x42fcfb71. Both are about 126.49. Nobody could see the difference on screen, yet the check stopped the game over it.
The fix admits both values for the two lamp kinds, and a new test replays 22 recorded lights through 431 checks.
A second gap: NaN
The same week my native Apple Silicon build, which runs outside the browser, stopped on a point whose coordinates were all NaN, "not a number". That is a different check in the same renderer, just as strict: it accepted only one bit pattern for NaN, and NaN has many. The original's x87 maths produces one with the sign bit set, 0xffc00000. Apple Silicon's default NaN has it clear, 0x7fc00000, and the check knew only the first. It now ignores the sign bit.
I'm Ovi. I recompile old Windows games to run in a browser, build a virtual GPU for Windows XP, and write tools for my own machines, with AI since 2020. Projects and the latest log