|
This is from NES101.html by Michael Martin:
... Then there's $4017.
$4017 is a sound initialization register. Only bits 6 and 7 of $4017 are important, when you write to it. Bit 6 controls Sound IRQs: if bit 6 is set, no sound IRQs will occur. If it's clear (which is the default), interrupts to a sound routine will occur at the end of every audio frame. Audio and video frames have slightly different lengths, apparently; bit 7 lets you get some control about how different they are. Writing a 1 into bit 7, then never touching $4017 after that makes envelopes decay about 20% more slowly. Writing a 1 into bit 7 every NMI will produce similar decay rates to cleared 7 (probably the 'normal' decay rate) but timed effects like slides and fades won't happen until later in the frame - this will allow you to do more advanced sound computation without glitching the sound.
If an IRQ goes off, you must acknowledge it, either by writing $4017 or reading $4015. If you don't, another IRQ will be generated after one instruction. This is rarely what you want.
We don't care about any of that, but we'd rather not have any IRQs. We'll write a $40 into $4017 as well.
init'sound: ; initialize sound hardware lda #$01 sta $4015 lda #$00 sta $4001 lda #$40 sta $4017 rts ...
I haven't seen that in any other docs, but I could of just as easily plain missed it.
|