It is currently Thu Dec 13, 2018 9:08 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Sequencing the APU (ASM)
PostPosted: Mon Dec 03, 2018 2:01 am 
Offline

Joined: Mon Dec 03, 2018 1:56 am
Posts: 4
Hey everyone!
Right now i am working on a project where i manually code music and sounds for the NES via assembly only.
Currently, my issue seems to be an inability to trigger a sequence of more than one note.
I know that once the counter reaches 0 on the note length, the flag for the note length at register $4015 will set to 0.
My code looks like this:

.inesprg 1
.ineschr 0
.inesmap 1
.inesmir 0

.bank 1
.org $FFFA
.dw 0 ;vbank
.dw Main
.dw 0

.bank 0
.org $C000

Main:

;period/frequ and also set length
One:
JSR D3

ldx $4015
cpx #%00000000
beq Two

Infiniteloop
jmp Infiniteloop

Two:
JSR D4

jmp Infiniteloop

D3:
;D3, eighth note
lda #%00000001
sta $4015
lda #%10011111
sta $4000
lda #%11111001
sta $4002
lda #%01001010
sta $4003

RTS

D4:
lda #%00000001
sta $4015
lda #%10011111
sta $4000
lda #%01111100
sta $4002
lda #%01001001
sta $4003

RTS

In my head, the code should.
1. From main, jump to my subroutine D3, where I
a. enable PU1 by writing 1 to the first bit of register $4015
b. write the duty cycle/volume/period/length data to registers $4000, $4002, and $4003
c. return to main
2. Load the value stored at $4015 to the x register
3. test the value against a correct zero-d out $4015, meaning that the timer on PU1 had counted to zero
4. Jump to D4, where i would do the same process as in step one.

On paper, i feel like my code checks out, but clearly i am missing something here, so if anyone could help me (again) that would be extremely cool.
Thanks!


Top
 Profile  
 
PostPosted: Mon Dec 03, 2018 3:38 am 
Offline
User avatar

Joined: Tue Jan 24, 2017 1:23 am
Posts: 12
Quote:
ldx $4015
cpx #%00000000
beq Two

Infiniteloop
jmp Infiniteloop


The test goes to Infiniteloop if $4015 is nonzero (note still playing)
Try this:

test:
ldx $4015
cpx #%00000000
beq Two
jmp test

Infiniteloop
jmp Infiniteloop


Top
 Profile  
 
PostPosted: Tue Dec 04, 2018 2:05 am 
Offline

Joined: Mon Dec 03, 2018 1:56 am
Posts: 4
nin-kuuku wrote:
Quote:
ldx $4015
cpx #%00000000
beq Two

Infiniteloop
jmp Infiniteloop


The test goes to Infiniteloop if $4015 is nonzero (note still playing)
Try this:

test:
ldx $4015
cpx #%00000000
beq Two
jmp test

Infiniteloop
jmp Infiniteloop


This works! thank you so much!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group