It is currently Wed Nov 22, 2017 9:48 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Frequency Registers Help
PostPosted: Thu Feb 12, 2015 12:29 am 
Offline
User avatar

Joined: Mon Jun 21, 2010 10:23 pm
Posts: 162
Location: Seattle, WA
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:19 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:24 am 
Offline
User avatar

Joined: Mon Jun 21, 2010 10:23 pm
Posts: 162
Location: Seattle, WA
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:31 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
A table, in this context, is just a list of values. An array.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:35 am 
Offline
User avatar

Joined: Mon Jun 21, 2010 10:23 pm
Posts: 162
Location: Seattle, WA
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:44 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:47 am 
Offline
User avatar

Joined: Mon Jun 21, 2010 10:23 pm
Posts: 162
Location: Seattle, WA
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.


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 1:59 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
Well, start by reading this, I suppose: http://www.fceux.com/web/help/fceux.html?Debugger.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: tepples and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group