For education purposes only · no game files included · bring your own THUG
Guide 02

Graphics and sound fixes

How the Xbox-era renderer and audio got onto SDL2, OpenGL and a 5-channel float mixer, and how the music and voice streams of the PC release were made to play.

GoalSame picture and sound as the PC release, from the original data files, on a Mac.

The renderer and the base audio landed in the first commit (962139d), so there's no "before" to diff; those steps show the key code as excerpts. Music and streams came later, with real diffs.

1Render into a backbuffer, present it scaled

The game draws into an off-screen framebuffer at the render resolution; presenting draws that texture as one quad into the window. Everything else (resolution, letterboxing, motion blur) hangs off this.

excerptWn32/Code/Plat/Gfx/p_nx.cpp

2Decode console-flavoured textures

Xbox textures are swizzled (Morton order) and fonts are 8-bit palettized. They're unswizzled and expanded to RGBA before glTexImage2D.

excerptWn32/Code/Plat/Gfx/nx/chars.cpp

PS2 alpha goes 0–128, because 128 means "fully opaque" on the GS. Twenty years later we're still multiplying by two.

3One mixer for everything

A single SDL audio callback at 48 kHz, 5 float channels: music and voice streams first, sound effects on top. Locks around it keep the game thread from swapping streams mid-buffer.

excerptWn32/Code/Plat/Audio/Mixer.cpp
excerptWn32/Code/Plat/Gel/SoundFX/p_sfx.cpp
The pause menu's now-playing box: proof the soundtrack is running (Flamethrower, "I Want It All").
The pause menu's now-playing box: proof the soundtrack is running (Flamethrower, "I Want It All").

4Turn the soundtrack on

The retail scripts only queue the soundtrack when running from CD or with TestMusicFromHost. CD mode drags debug behaviour along, so a one-line script patch flips the other switch.

new fileScripts/patches/scripts/game/skater/skater_sfx.q · 28ef9a3

5Find the tracks: hex names and a .wad

The PC release names music files after the checksum of the track name, in hex (a9a6af00.bik), and packs the voice streams into pcm.wad, indexed by pcm.dat.

diffWn32/Code/Plat/Gel/Music/p_music.cpp · 28ef9a3

6Decode Bink audio, resample, spread over 5 channels

A built-in Bink audio decoder (binkaudio.cpp) feeds a streamer that resamples to 48 kHz (with pitch, because the game bends voice pitch) and places stereo on the 5 mixer channels the way sound effects do.

diffWn32/Code/Plat/Gel/Music/p_music.cpp · 28ef9a3

(void)fPitch; is a stub's way of saying "I heard you, I just don't care". Now it cares.