11 March 2016 - Forum Rules

Main Menu

Zelda 1 Bank 7

Started by gzip, January 17, 2022, 08:48:37 PM

Previous topic - Next topic


I was toying around with the idea of moving sounds around and ran across a note somewhere that DPCM sounds have to reside in the fixed bank. That got me thinking of how little space is available in bank 7 of The Legend of Zelda and that there must be a way to free up some space by modifying the sounds. That led me to the following notes in Trax's disassembly:

Related to Sound Effects that use the DMC (Sword, Link Hurt...)

1BEE: 00 4C 80 1D 20 28 4C Table for Sample Address (7 bytes)
1BF5: 75 C0 40 0A B0 90 D0 Table for Sample Length (7 bytes)
1BFC: 0F 0F 0D 0F 0E 0F 0E Table for Sample Frequency Index (7 bytes)

Looks simple enough so I did a little sleuthing and found the following calculations:

Address is calculated by: $C000 + x * $40 (+$10000 for ROM location)
Sample Length is calculated by: $10 * x + 1

That allowed me to flesh out the following table:

Sound Name   | Address Range | Length
Flying Sword | 1C000-1C750   | 751
Boss Hurt    | 1D300-1DF00   | C01
Dungeon Door | 1E000-1E400   | 401
Link Hurt    | 1C740-1C7E0   | A1
Boss Sound 1 | 1C800-1D300   | B01
Boss Sound 2 | 1CA00-1D300   | 901
Boss Sound 3 | 1D300-1DFFF   | D01

Now the first thing to note is that 1C7E1-1C7FF is actually unused even though there's data there. I verified that the sounds remain unaffected by blanking out that space. That's $1F (31 bytes) of unused space for free!

Now imho the boss sounds are not really that critical of a feature. At the very least we don't need three different sounds. Boss Sound 3 is the largest and also the strangest so why not reclaim that space for better use? One catch, if you look carefully Boss Hurt is using the same sound, just a smaller portion at a slightly different frequency. No matter, let's just point both of them to one of the other sounds and then modify the frequency of them all so they all still sound a little different.

Here's the modified table with the data for Boss Sound 3 no longer referenced:

1BEE: 00 20 80 1D 20 28 20
1BF5: 75 90 40 0A B0 90 B0
1BFC: 0F 0D 0D 0F 0C 0F 0E

Boom, that frees up $D01 bytes of data in the fixed bank for better use! (That's 3,329 bytes from 1D300-1DFFF.) :thumbsup: