Hello Everyone! I'm back with another NES sound related question.
Having scrapped getting sound from the NES via a .nsf file, I have been trying to hard-code some little ditties into the chip in assembly.
My current process is this: I am making separate sub-routines for each note/note length and then calling them in an order, to form a sort of song.
Right now, my code for the note D, with a fade out looks like this:
D3:
;pitch D3
lda #%11111001
sta $4002
lda #%10000010
sta $4003
;volume & pulse width
;fade out
;F-D-B-9-7-5-3-2-1-0
lda #%00111111
sta $4000
sta $4000
sta $4000
sta $4000
sta $4000
sta $4000
lda #%00111101
sta $4000
lda #%00111011
sta $4000
lda #%00111001
sta $4000
lda #%00110111
sta $4000
lda #%00110101
sta $4000
lda #%00110011
sta $4000
lda #%00110010
sta $4000
lda #%00110001
sta $4000
RTS
and to an extent, this works! the NES generating a D3 pitch. HOWEVER: the fade is not working as expected. What I expect to happen is for the note to hold at maximum volume for a moment, before going down in volume. what happens in actuality, is that the APU only seems to be reading (from what i can hear) the last write to $4000, meaning that i have a steady tone at volume 1, rather than a tone that decreases in volume. If anyone can help me troubleshoot this, that would be very helpful.
Note: I understand that the length can be changed via the highest 5 bits written to $4003, but I still would like to experiment with this method and get it to work.