The code at http://wiki.nesdev.com/w/index.php/APU_ ... ialization had this:
There was an ominous warning saying "Do not alter this code in any way". However, I checked everything and I could find no reason at all to initialize $4015 first or to count up (requiring a CPY instruction) instead of down.
So I disregarded the warning and changed it to this:
Is there any reason why my change might be wrong, or should we let it stand?
Code:
init_apu:
lda #$0F
sta $4015
ldy #0
@loop: lda @regs,y
sta $4000,y
iny
cpy #$18
bne @loop
rts
@regs:
.byte $30,$08,$00,$00
.byte $30,$08,$00,$00
.byte $80,$00,$00,$00
.byte $30,$00,$00,$00
.byte $00,$00,$00,$00
.byte $00,$0F,$00,$40
lda #$0F
sta $4015
ldy #0
@loop: lda @regs,y
sta $4000,y
iny
cpy #$18
bne @loop
rts
@regs:
.byte $30,$08,$00,$00
.byte $30,$08,$00,$00
.byte $80,$00,$00,$00
.byte $30,$00,$00,$00
.byte $00,$00,$00,$00
.byte $00,$0F,$00,$40
There was an ominous warning saying "Do not alter this code in any way". However, I checked everything and I could find no reason at all to initialize $4015 first or to count up (requiring a CPY instruction) instead of down.
So I disregarded the warning and changed it to this:
Code:
init_apu:
ldy #$17
@loop: lda @regs,y
sta $4000,y
dey
bpl @loop
rts
@regs:
.byte $30,$08,$00,$00
.byte $30,$08,$00,$00
.byte $80,$00,$00,$00
.byte $30,$00,$00,$00
.byte $00,$00,$00,$00
.byte $00,$0F,$00,$40
ldy #$17
@loop: lda @regs,y
sta $4000,y
dey
bpl @loop
rts
@regs:
.byte $30,$08,$00,$00
.byte $30,$08,$00,$00
.byte $80,$00,$00,$00
.byte $30,$00,$00,$00
.byte $00,$00,$00,$00
.byte $00,$0F,$00,$40
Is there any reason why my change might be wrong, or should we let it stand?