I got bored so I started on this
the left in right might be switched, I don't know which ring goes to which.
Code:
the left in right might be switched, I don't know which ring goes to which.
Code:
Start:
;;insert code to start the interrupt here
di
exx
ld bc,MusicStartLeft
ld de,MuxicStartRight
call NextNoteLeft
call NextNoteRight
exx
ei
StartMain:
Main:
ld hl, (righttimer)
dec hl
ld (righttimer),hl
ld a,h
or l
call z, FlipRight
ld hl, (lefttimer)
dec hl
ld (lefttimer),hl
ld a,h
or l
call z, FlipLeft
jp Main
Interrupt:
ex af, af'
exx
ld hl,(NoteLengthLeft)
dec hl
ld (NoteLengthLeft),hl
ld a,h
or l
call z, NextNoteLeft
ld hl,(NoteLengthRight)
dec hl
ld (NoteLengthRight),hl
ld a,h
or l
call z, NextNoteRight
ex af,af'
exx
reti
NextNoteLeft:
ld l,(bc)
inc bc
ld h,(bc)
ld (NoteLengthLeft),hl
inc bc
ld l,(bc)
inc bc
ld h,(bc)
ld (lefttimermax),hl
inc bc
ret
NextNoteRight:
ld l,(de)
inc de
ld h,(de)
ld (NoteLengthRight),hl
inc de
ld l,(de)
inc de
ld h,de
ld (righttimermax),hl
inc de
ret
InterruptEnd:
FlipLeft:
ld a,e
ld hl,(lefttimermax)
ld (lefttimer),hl
xor %00000001
ld e,a
out (0),a
ret
FlipRight:
ld a,e
ld hl,(righttimermax)
ld (righttimer),hl
xor %00000010
ld e,a
out (0),a
ret
.dw MusicAddressRight
.dw MusicAddressLeft
.dw NoteLengthRight
.dw NoteLengthLeft
.dw righttimer
.dw lefttimer
.dw righttimermax
.dw lefttimermax
;; .dw length
;; .dw pitch