Home Artists Posts Import Register

Content

Hi Everyone,

I'd like to do another technical report about a recent bugfix: the fix for Rugrats that I checked in yesterday.

The story begins with this Rugrats game, exactly: "Nickelodeon Rugrats - Search for Reptar", US version and a bug report about bad music in a cutscene at the very start:

Music in the PSX can be played back either directly from CD or it can be loaded into the Sound Processing Unit(SPU) and it's dedicated RAM and played back from there.

If the music is played back from CD, there are two formats available for the PSX:

The most known is the uncompressed format named "Compact Disc Digital Audio"(CD-DA) or often called "red book". It contains typical music tracks with uncompressed stereo audio.

The second supported format is ADPCM compressed audio from the CD-XA standard(XA for eXtended Architecture). XA audio can save space and usually doesn't suffer from a big loss in quality, so it's more often used on the PSX than CD-DA.

XA comes in different forms of compression:

As you can see, the sample rate is either 37800Hz or 18900 Hz and it can be stored in either mono or stereo, leading to a compression ratio of 1/4 to 1/16. (Table contains interleaved values for 2X speed)

The music in this cutscene is also played back from CD as CD XA audio at a rate of 1/8.

What does 1/8 mean? The documentation offers several configurations:

For example you can save 8 audio tracks with the length of 5 minutes on the disc space of only 5 minutes. A file selector inside the CD controller will pick the file that is requested and the data coming from other files is just ignored.

It works in such a way, that one sector(1 second of playback has 75 sectors) of the CD is read, decoded and stored and the next 7 sectors don't contain data for this track. The buffer containing audio will slowly deplete and by the time it's consumed, 8 sectors have passed by and new data is available.

At least that's the usual case. For Rugrats, only for this cutscene, we have one of these cases that fit under "etc." 

Rugrats will, play back XA audio with one file with 8 times the same audio track. That means that every sector read contains data to be played back and that is just too much. The audio buffer in the CD controller runs full and it's hard to guess what random things happen in that case.

Why have the developers even done that? They store 8 times the same data, so could instead just used uncompressed data, right?

Well, sometimes maximum ressource efficiency is not the biggest concern. The game is below 600MByte in size, which means they have not been running against a limit, so needing only one way of CD audio playback in the games code can be some advantage, especially in the early days of CD consoles where everything was very low level.

What does it mean for our bug now? The simplest assumption is what likely really happens in the hardware: if the CD audio buffer has not run dry, there is no need to fetch another sector, so let's just ignore every sector as long as no new CD XA data is required.

And indeed this fixes the Rugrats cutscene and, as has been found out in the Discord channel after some hours, it also fixes the audio in the Vagrant Story  credits, which makes it very likely that it's the correct solution.

The fix is already available in the unstable build if you want to try it.

Until next post, have a good time!

Comments

Anonymous

Thanks for explaining! That's awesome!

Anonymous

I get more out of this than Netflix. Keep it up!