It is currently Tue Nov 13, 2018 9:26 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Learning the APU
PostPosted: Wed Oct 24, 2018 3:46 pm 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
I'm messing around with the APU, and I'm running into a problem.

I wrote / stole this little macro to play notes out of a note table:

Code:
.macro play_note note
    .local @play_note_end

    lda note_countdown
    bne @play_note_end

    lda #80
    sta note_countdown

    lda #%00000001
    sta $4015 ;enable square 1

    lda note
    tay
    lda note_table, y
    sta $4002
    iny
    lda note_table, y
    sta $4003

    @play_note_end:

.endmacro


The only problem is after the note plays it seems to play again over and over

kind of like this:
beeeeeeeeeeeeep [nothing] beep [nothing] beep

So what am I failing to understand about the APU?

Thanks

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
 Post subject: Re: Learning the APU
PostPosted: Wed Oct 24, 2018 4:09 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7714
Location: Seattle
What are you writing to $4000 and $4001?


Top
 Profile  
 
 Post subject: Re: Learning the APU
PostPosted: Wed Oct 24, 2018 5:49 pm 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
lidnariq wrote:
What are you writing to $4000 and $4001?


I wrote to $4000 earlier in the code to set the volume. I have a different macro that writes to $4001. I'm not sure what the sweep is supposed to do. Does that modify the tone or the volume. I played with that register a little and I'm not exactly sure what it does.

Thanks

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
 Post subject: Re: Learning the APU
PostPosted: Wed Oct 24, 2018 6:01 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7714
Location: Seattle
If you write the wrong value to $4000 - something with the $20s bit = "C"onstant Volume bit clear - you'll get a sound that repeatedly goes from maximum volume to minimum volume until the length counter times out.

But that's the only way the hardware would be doing anything like what you're describing. If that's not it, your problem has to be something your code is doing.



Relatedly, the "correct" value to write to $4001 is 8, unless you intend on using the hardware pitch sweeps.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: dougeff and 3 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