Dec 12, 2022

The CV3j Audio Engine and the Woes of Bank Switching

With nearly 8.10% of CV3j's code to at least log (mapping it will much more gradually), I took a peek at the code pertaining to the audio. That's a huge swath of pure data, so any missing elements should be easy to spot. I used the music debugger (A+B+Start) and an $E249 breakpoint, I played every song, every sound effect, and every DCM that I'm aware of. I don't think I missed any parts of a song, other than "Pressure", which usually got cut short because I wasted no time running up to Dracula and forgot I was trying to log all data.

There are 125 tracks. All the sound effects and noise percussion are located in ROM bank #0C, while background music is spread across banks #04 and #05. The code for the audio engine itself is located in bank #0C. ...And banks #04 and #05. At first I naively thought each page may have had different parts of the engine, but when I noticed a significant amount of bank #0C was not logged, I searched the other two banks for that same data and found them already logged. It seems like a large chunk of the game's code is dedicated to game's audio engine, most of which isn't actually used by sound effects. However, after manually logging the bytes of each copy of the audio engine, it was roughly 5% of the game: #7AD (1,965) bytes long, duplicated on across three pages.

All the audio envelopes are also stored in bank #0C. Of the 128 volume envelopes, 119 were defined, and of those, 60 were never utilized. Of the 20 pitch envelopes, 5 were never utilized. That comes out to roughly 350 bytes of ROM wasted just for the envelopes alone.  Most of these envelopes are negligible and there's no real way of knowing for which channels each envelope was intended, but it may be fun for someone to play around with.

At one point, audio channel 9 was delegated to the DCM channel, but it appears to have been removed, possibly to save space in WRAM. Now instead of writing the track address for channel 9, which is always 4 bytes after the previous address, it just reads (in)directly from the DCM data itself. Thus, there's another 60 90 bytes of ROM available to be recycled.

No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.