I have been compiling information for NES sound drivers, mainly their frequency registers, for contribution over at VGMPF. Sometimes, I can find the frequency register data in the game's ROM, but other times, I can't find it. My question is, are the frequency registers somehow compressed in the ROM or are they coded differently? For example, frequency 357 would be 35 07 instead of 57 03. I'm kind of new to this and don't know much about NES programming in general.
I was also looking at Nick Eastridge's sound engine used in his earlier games (Paperboy, Mad Max, etc.) and found that some notes have two different frequencies. Not just for the triangle channel, but for the square channels as well. I wonder what's up with that. Thanks for your time.
Frequency Registers Help
Moderator: Moderators
- Doommaster1994
- Posts: 162
- Joined: Mon Jun 21, 2010 10:23 pm
- Location: Seattle, WA
- Contact:
- rainwarrior
- Posts: 8763
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Frequency Registers Help
The value sent to the frequency register is the result of arbitrary calculations.
Usually we're trying to approximate a twelfth-root-of-two scale, and since the NES can't really calculate that on the fly, part of the calculation usually uses a lookup table.
Here are some common ways to do things:
1. Use a 12 note table, and bit shifting to select an octave (dividing by two raises the pitch by an octave)?
2. Use a table with one entry for every note?
3. Allow detune, vibrato, slide, or other pitch effects to modify the pitch looked up from the table?
The lookup table will typically be 16 bit (2 byte) values. The might sometimes be stored in pairs of bytes (big or little endian is arbitrary; the CPU only sees 8 bits at a time so the order is up to the programmer), or more likely there will be two tables, one for MSB and one for LSB, because this tends to look up more efficiently on the NES.
Usually we're trying to approximate a twelfth-root-of-two scale, and since the NES can't really calculate that on the fly, part of the calculation usually uses a lookup table.
Here are some common ways to do things:
1. Use a 12 note table, and bit shifting to select an octave (dividing by two raises the pitch by an octave)?
2. Use a table with one entry for every note?
3. Allow detune, vibrato, slide, or other pitch effects to modify the pitch looked up from the table?
The lookup table will typically be 16 bit (2 byte) values. The might sometimes be stored in pairs of bytes (big or little endian is arbitrary; the CPU only sees 8 bits at a time so the order is up to the programmer), or more likely there will be two tables, one for MSB and one for LSB, because this tends to look up more efficiently on the NES.
- Doommaster1994
- Posts: 162
- Joined: Mon Jun 21, 2010 10:23 pm
- Location: Seattle, WA
- Contact:
Re: Frequency Registers Help
I'm not sure what you mean by 'tables'. Again, I don't know much about the NES and 6502 though I've been trying to learn.
I also notice some games list some (but not all) of the frequency registers.
I also notice some games list some (but not all) of the frequency registers.
- rainwarrior
- Posts: 8763
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Frequency Registers Help
A table, in this context, is just a list of values. An array.
- Doommaster1994
- Posts: 162
- Joined: Mon Jun 21, 2010 10:23 pm
- Location: Seattle, WA
- Contact:
Re: Frequency Registers Help
Oh okay.
I looked at some of these games, and I don't see anything that resembles the frequencies, but I think they should be in there or else, I wouldn't know how the music plays.
I looked at some of these games, and I don't see anything that resembles the frequencies, but I think they should be in there or else, I wouldn't know how the music plays.
- rainwarrior
- Posts: 8763
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Frequency Registers Help
Create a trace log, and put a breakpoint on the writes to the pitch register. When you find it, work backwards through the assembly trace to find where the value came from. Ultimately you'll find the tables used.
- Doommaster1994
- Posts: 162
- Joined: Mon Jun 21, 2010 10:23 pm
- Location: Seattle, WA
- Contact:
Re: Frequency Registers Help
I'm not sure how to do that. I know how to open the trace logger, and I think setting the breakpoints can be done in the debugger, but I'm not too familiar with that stuff.
- rainwarrior
- Posts: 8763
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Frequency Registers Help
Well, start by reading this, I suppose: http://www.fceux.com/web/help/fceux.html?Debugger.html