Hi, I've wrote this routine to make a sound, following the various docs about the NES APU:
the $4002 register, and the lowest 3 bits of $4003, are supposed to hold an 11 bit number (0..2047) which is inversely proportional to the frequency ( at least that's what I understood )
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:
Code:
// 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 );
byte volume, length;
word tone;
addr( 0x4000 ) = 0x10 | ( 0xF & volume );
addr( 0x4002 ) = (byte) tone;
addr( 0x4003 ) = ( length <<3 ) | ( tone >>5 );
the $4002 register, and the lowest 3 bits of $4003, are supposed to hold an 11 bit number (0..2047) which is inversely proportional to the frequency ( at least that's what I understood )
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:
Quote:
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)
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)