Easier APU documentation?
Moderator: Moderators
- neilbaldwin
- Posts: 481
- Joined: Tue Apr 28, 2009 4:12 am
- Contact:
- neilbaldwin
- Posts: 481
- Joined: Tue Apr 28, 2009 4:12 am
- Contact:
Just stripped it all down to this;
Which produces no sound until you put the 'sta $400f' line back in.
Code: Select all
reset:
sei
ldx #$FF
txs
lda #$00
sta PPU0
sta PPU1
jsr init_APU
mainLoop:
jmp mainLoop
nmi: rti
irq: rti
init_APU:
lda #$00
sta $4015
ldx #$00
@a: lda @apu_regs,x
sta $4000,x
inx
cpx #$18
bne @a
lda #$0F
sta $4015
lda #%00111111
sta $400c
lda #$01
sta $400e
;sta $400f
rts
@apu_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
Here's the problem; your init_apu routine is different than the one on the wiki:
I've added a note to the Wiki as to not altering the init routine in any way. Using the above was preventing the length counters from being loaded properly by the loop.
Code: Select all
init_apu:
lda #$00 ; should be $0F
sta $4015
- neilbaldwin
- Posts: 481
- Joined: Tue Apr 28, 2009 4:12 am
- Contact:
That's very odd.
I originally had the init routine from the wiki, verbatim, and I wasn't getting any noise output unless I wrote something to $400F at the time of writing the frequency register ($0E).
So then I added the lines to write $00 to $4015 before the loop and $0F after the loop, just clutching at straws really. It didn't seem to have any effect.
Now I've restored the init back to the wiki version, removed the extra write to $400f and it's now working.
*shrugs* Ghosts in the machine maybe....
I originally had the init routine from the wiki, verbatim, and I wasn't getting any noise output unless I wrote something to $400F at the time of writing the frequency register ($0E).
So then I added the lines to write $00 to $4015 before the loop and $0F after the loop, just clutching at straws really. It didn't seem to have any effect.
Now I've restored the init back to the wiki version, removed the extra write to $400f and it's now working.
*shrugs* Ghosts in the machine maybe....
- MetalSlime
- Posts: 186
- Joined: Tue Aug 19, 2008 11:01 pm
- Location: Japan
Thanks! I wrote those tutorials to help people learn how to program the APU. The tech docs are great but dense. A lot of new homebrewers were coming in and posting ROMs of their games in progress, but they were all silent. I had just figured the APU out so I wanted to help out.tokumaru wrote: From what I've read so far, the Nerdy Nights sound tutorial is pretty straightforward and tells exactly what you have to do to get things going without much trouble, along with simple register descriptions. Assuming it's accurate, I guess it's a really good intro to sound programming.
BTW, if anyone wants to host or copy/paste the Nerdy Nights sound tutorials somewhere in the nesdev wiki, you have my blessing. The more accessible they are to nes homebrewers the better.
MetalSlime runs away.