Commented Code Snippets
Page 1 of 1
Commented Code Snippets
Hi, once again, I figured I should post a thread to contain useful bits of code in making a Mesen HD Audio patch.
For now, an MSU-1-like approach to playing music.
For now, an MSU-1-like approach to playing music.
- Code:
NEA_BGM_Play:
cmp #$Firsttrack_number
bcc errorfound
cmp #$Lasttrack_plus1
bcs errorfound
sta $4104 ;store track number as album number because it flows better.
pha
lda #$01
sta $4101 ;stop music.
sta $4105 ;don't need a track number, so track 1 in each album is the song.
pla
;checking for noloops
cmp #$XX ; Game over
beq noloop
cmp #$XX ; Ending
beq noloop
lda #$01
bne yesloop
noloop:
lda #$00
yesloop:
sta $4100 ;set loop
lda #$00
sta $4101 ;start song play
lda $4100 ;checking error bit
cmp #$03 ;is bit 2 (error) set
bcc errorfound ; error is 4+up, values might be 4-7 depending.
Mute Code Goes Here!!
errorfound: ;if there's an error, this should avoid muting.
rts
Last edited by Cubear on Sat 9 Dec 2023 - 18:47; edited 2 times in total
Re: Commented Code Snippets
This requires a bit of a strange setup for the NEA audio but it makes the code flow nicely so it's worth it to me.
the track number is sent as the album number. the track number is always sent as 1.
like so:
this code also has some filtering at the start, for not activating this code while SFX are passing through the hook. from my small amount of experience, NES games often use the same code to run SFX as Music, so it's probably essential to filter them out.
the track number is sent as the album number. the track number is always sent as 1.
like so:
- Code:
<bgm>81,1,gameover.ogg
this code also has some filtering at the start, for not activating this code while SFX are passing through the hook. from my small amount of experience, NES games often use the same code to run SFX as Music, so it's probably essential to filter them out.
Similar topics
» Code help
» right code for music?
» Brake pots with asm (new code)
» New, simplified LoZ3 MSU-1 code
» MSU1 Code Library
» right code for music?
» Brake pots with asm (new code)
» New, simplified LoZ3 MSU-1 code
» MSU1 Code Library
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum