Code: Select all
// don't take it literally, it's part of a longer code.
byte volume, length;
word tone;
addr( 0x4000 ) = 0x10 | ( 0xF & volume );
addr( 0x4002 ) = (byte) tone;
addr( 0x4003 ) = ( length <<3 ) | ( tone >>5 );
So, tell me if I'm wrong, but the higher the value, the lower the frequency, thus the pitch of the sound.
I made a program that increments this value and expected to hear a sound whose pitch would get constantly lower. But it doesn't, it goes lower but at certain points it jumps to a higher pitch, and then continues going lower.
Is the code correct? can you spot an error?
Thanks!
PS: I quote from Everynes - Nocash NES Specs:
4002h - APU Frequency Channel 1 (Rectangle)
0-7 Lower 8 bits of wavelength (upper 3 bits in Register 3 (4003h))
...
4003h - APU Length Channel 1 (Rectangle)
2-0 Upper 3 bits of wavelength (unused on noise channel)
7-3 Length counter load register (5bit value, see below)