This is my code (it uses the Konami VRC6 chip, aka Mapper 24, so you might not be familiar with this but similar logic should work with the built in sound channels. Since my asm file is pretty big I'm only leaving in the parts that deal with the music itself.
Code: Select all
song_illuminator: db $9f,$9f,$9f,$9f,$9f,$9f db $af,$af,$9f,$9f,$9f,$9f db $9f,$9f,$cf,$cf handleMusic: pha txa pha tya pha lda #%01001001 ;Volume 9, Duty Mode 04 ldx musicloop jsr ChibiSoundVRC6 pla tay pla tax pla rts ChibiSoundVRC6: STA VRC6_PULSE1_CTRL LDA musicloop,x STA VRC6_PULSE1_FREQ_LO LDA #%10000000 STA VRC6_PULSE1_FREQ_HI inx cpx #$10 ; See Note 1 beq loopMusic ; See Note 1 RTS ; See Note 1 loopMusic: ; See Note 1 ldx #$00 ; See Note 1 rts ; Note 1: Only the first note plays if these lines of code are here. Otherwise the whole song does play but much too fast.