;------------------------------- ; little music player ; 20020905 gpz: some fixes, works much better now ;------------------------------- STUBPOLL=$ce00+3 *=$c000-2 .word $c000 ;------------------------------- ; jumptable jmp start jmp stop ;------------------------------- ; patched from host init: jmp $1000 play: jmp $1003 ;------------------------------- ; some variables border: .byte $00 rastertime: .byte $00 ;------------------------------- ; stop playing and switch to dummy irq stop: sei ; volume=0 lda #$00 sta rastertime sta $d418 lda border sta $d020 lda #$35 sta $01 lda #irqoff sta $ffff sta $0315 ; acknowledge irq inc $d019 lda $dc0d sta $dc0d cli jmp mlp ;------------------------------- ; init tune and start playing start: sei lda #$35 sta $01 lda #irq sta $ffff sta $0315 lda #$7f sta $dc0d lda #$01 sta $d01a lda #$1b sta $d011 lda #$fc sta $d012 ; init tune lda #$00 tax tay jsr init lda #$f0 @ww: cmp $d012 bne @ww ; acknowledge irq inc $d019 cli ;------------------------------- ; poll debug-stub to be able to do further transfers mlp: @l: lda $d011 and #$80 bne @l lda #$28+4+3 @lp: cmp $d012 bne @lp jsr STUBPOLL jmp mlp ;------------------------------- irq: sei sta irqa stx irqx sty irqy lda #$fc @lp: cmp $d012 beq @lp inc $d020 jsr play inc $d020 ldx border lda $d012 cmp rastertime bcc @skp sta rastertime @skp: @lpw: lda $d011 and #$80 beq @l lda $d012 cmp rastertime bcc @lpw @l: cmp $d012 beq @l stx $d020 ; acknowledge irq inc $d019 irqa=*+1 lda #$00 irqx=*+1 ldx #$00 irqy=*+1 ldy #$00 rti ;------------------------------- ; dummy irq irqoff: sei pha ; acknowledge irq lda $dc0d sta $dc0d inc $d019 pla rti