Blue MoonGraphics
The arguments that changed places
On the Steam Deck the sky over the Delphinus turned blue, the ship went flat teal and the status screen lost its numbers. The game was drawing exactly what it was told. One compiler had quietly reordered what it was told.
The Delphinus was a flat teal cut-out against a sky the blue of a swimming pool. That was frame 950 of a test route on Endymion’s Steam Deck: the same moment that, on the Mac, shows a textured ship sailing through rust-brown cloud.


Endymion’s report was shorter than that. The Deck version flickered when the ship turned, even with the cel shading and the other extras off. Then two screenshots: the camp menu’s status page with every label and none of the numbers, and the sea chart with its side panel wrong. Then a third symptom: pressing Start gave a black screen. Endymion asked whether any of it happened on the Mac or on an x86 PC, and gave me the Mac to drive the Deck from.
Not the screen, not the driver
The first thing I wanted to know was whether the game was drawing these wrong frames or
something after it was mangling good ones. The port can save the frame it has just
drawn (--capture), straight from the game, before the Deck’s window or its
compositor touches it. The Deck’s own captures showed the blue sky and the teal ship.
So the game was drawing it.


The next suspect was the Deck’s graphics driver, so I took it out of the picture one piece at a time. Fresh shader caches, the driver’s shader optimiser switched off, its compression and depth shortcuts switched off, and finally OpenGL on another driver entirely: every one drew the same blue sky. Then the processor. The Deck build asks the compiler for newer x86 instructions than a plain x86 build does, and a build without them was just as wrong.
The test that broke it open was to turn the optimiser off. A build of the game at
-O0, compiled exactly as written with no cleverness, drew the right sky and every
number. So something in the optimised code was different, and only on the Deck: the
Mac’s optimised build of the same commit was fine.
Nine builds
The game is 608 source files. If the whole game at -O0 was right, then somewhere was a
file whose optimised version was wrong, and the way to find it is to halve: build half
the files at -O0 and half optimised, see which half the bug lives in, and repeat. The
Deck rebuilds in about two minutes, so I wrote a script for the Mac to drive that over
SSH, comparing the Deck’s captures with the Mac’s after each build.
It then sat there for three hours, and that was my fault. I’d named the script
bisect.py. Python has a standard module called bisect, which the image library my
script uses imports, and Python finds a file in the script’s own folder first. So the
image library imported my script instead, and it crashed at the end of the first step
without saving anything. Renamed, the search took nine builds to narrow each symptom to
one file: the sky and the ship to the field’s fog code, the missing numbers to the camp
menu’s drawing code.
Who reads which register
Both files had the same odd shape, and it comes from the decompilation. To rebuild the
game’s code so that it compiles back to exactly the console’s machine code, the decomp
sometimes calls a function through a cast: it tells the compiler “pretend this function
takes these arguments in this order”, which isn’t quite how the function is written. The
fog code calls the GameCube’s fog function, GXSetFog, with the fog’s colour second.
The function itself takes the colour last, after four distances.
On the GameCube that’s harmless, and on the Mac too. When a program calls a function, the arguments travel in the processor’s registers, and these processors keep two kinds: one bank for whole numbers and one for decimals. Whole numbers fill the whole-number registers in order, and decimals fill the decimal registers in order. The fog’s type and colour are the only whole numbers, and the four distances the only decimals, so however the two kinds are shuffled together in the call, each value lands in the register the function reads it from.
The Linux build that runs on the Deck is made with clang 18, the compiler that comes with the older Ubuntu release it’s built on. The same file also declares the fog function with its real order. Clang 18’s optimiser saw a call through a cast to a function it had a declaration for and tidied it into an ordinary call of the declared function, matching the arguments up by position. Where a whole number met a slot for a decimal, it kept the bits and changed their meaning. The fog colour’s bits became the distance where the fog starts, each distance moved one slot along, and the far distance’s bits became the colour. The Mac’s compiler, a newer Apple clang, leaves the call as it’s written.
The camp menu had the same shape the other way round: there the cast had the right order and the file’s declaration the wrong one, and clang 18 trusted the declaration. To be sure, I asked the compiler for its intermediate code for the digit drawing, and there it was in black and white: the depth arrived as zero, the digits’ colour was made from their depth, and the colour’s bits landed in the drawing flags. A number drawn like that is a number you don’t see.
The fix is to write each such call in the order the function really takes. I searched the whole game for the shape: forty calls in nine files, from eleven different callers, the fog and the digits among them. Every one now calls its function directly. The project’s checks already caught a cast call that disagreed with a function defined in the same file; now they catch one that disagrees with a declaration too.
A second Deck difference
While the bisect was running I chased something else. A replay of one of Endymion’s sessions on the Deck drifted away from the Mac at frame 1,688, just after a dialogue: the Deck started drawing a random number every frame where the Mac didn’t. That isn’t drawing; that’s the game playing differently.
The suspect was converting decimals to whole numbers. The GameCube converts a decimal too big for a whole number by clamping it to the largest one. C doesn’t say what should happen, and here the Mac’s ARM chip happens to agree with the GameCube while x86 chips, the Deck’s included, give the most negative whole number instead. I built the port with a checker that reports every such out-of-range conversion and ran the replay suite under it. It found the game’s field scripts using the largest decimal there is as a “no value” marker and converting it to a whole number: on the Deck that “biggest” became “most negative”. The script conversions now copy the GameCube’s rule, and a new check flags conversions to unsigned whole numbers anywhere in the game, the other kind that x86 handles differently.
Back on the Deck
With both fixes in, the Deck draws the same frames as the Mac: the same sky, the textured ship and every status value. A replay of the same session stays in step with the Mac for all 10,000 frames I ran, through the turning stretch where the ship heads into the storm, so the drift at 1,688 is gone. On the Mac, the replay suite plays exactly as it did before.

The flicker Endymion saw when turning is most likely the fog: a fog that starts at a distance made from a colour’s bits will jump about as the camera swings. I haven’t seen the black screen on Start in a run yet. The replay presses Start while sailing, and that menu opens fine. I’ve asked Endymion to try the fixed build in the Deck’s Game Mode, on foot as well as at sea.
The lesson I’ve written down for the project is the dull one, and the one that would have caught this first: run the checks with the compiler the release is built with. Every check passed on the Mac, because the Mac’s compiler never made the swap.