Codex Helps Port ULC Audio Decoder to Nintendo 64 RSP
The author used Codex to translate a ULC reference decoder into RSPL for the Nintendo 64’s RSP, then optimized the generated assembly and pipeline scheduling. The resulting decoder handles 44.1 kHz stereo audio at near-Opus bitrates while using about 4% of CPU time and 5% of RSP time, according to the author. It has been merged into Libdragon’s preview branch.
The project demonstrates how AI-assisted code translation and optimization can support a tightly constrained low-level hardware port, although the reported performance figures come solely from the author.
— Tuesday, November 3rd 2026
Sorry for the clickbait title. I promise this post delivers: 44100 Hz stereo with near-Opus bitrates using about 4% of the N64’s CPU time.
But first, some history: The options for playing and storing audio data on the N64 were dire. The PlayStation could just stream uncompressed redbook audio straight from the CD. On the N64, cartridge space was at a premium and time on the 93 MHz CPU was limited.
Worse, access to the vector co-processor, the RSP, was guarded by Nintendo for the longest time. Nintendo's own platform library, Libultra, internally used the RSP for various graphics and sound-related tasks, but Nintendo didn't allow third-party developers to directly write code for it.
Libultra provided some functions to transparently play back compressed audio using an ADPCM scheme (adaptive differential pulse code modulation). The RSP handled decompression on the fly, just before the audio was sent to the output buffer.
This works well enough and cuts the space needed for a sample by a factor of 4. Still, a 5-minute stereo audio track at 44100 Hz will land at about 12MB – way too much for an N64 cartridge, even when you cut the sample rate in half. The whole Mario 64 ROM is just 8MB in total. The biggest N64 games were 64MB.
#ULC#Nintendo 64#Libdragon#Codex#RSPL#Opus#ADPCM#Mario 64#Conker's Bad Fur Day#Xibalba 64