Skip to content

The game thread's FPU precision is not the one the start-up code sets ​

What to know ​

Watcom's start-up code runs fninit (control word 0x037f: 64-bit precision). POD runs its game in a second thread made with CreateThread, and a new thread starts with the Windows default 0x027f: 53-bit precision, round to nearest (measured: the step log stores fnstcw at every step). A port tested under the emulator with the start-up word can agree on thousands of cases and still differ where 53-bit and 64-bit rounding differ.

Read the control word in the running game, in the thread that runs the code being ported. At 53-bit precision, x87 fadd, fmul and fild round exactly as IEEE f64 does. The port can then use f64 in the original's order of operations.

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.