Hardware Reference
In-Depth Information
dec
rep_cnt
beq
done
; if not finished playing, reestablish
ldx
#score
; pointers and loop count
ldy
#duration
;
movb
#notes,ip
;
movw
0,x,delay
; get the first note delay count
ldd
TCNT
; play the first note
addd
delay
;
std
TC5
bra
forever
done swi
; ********************************************************************************
; The OC5 interrupt service routine simply starts a new OC5 operation.
; ********************************************************************************
oc5_isr
ldd
TC5
addd
delay
std
TC5
rti
; ********************************************************************************
; The following subroutine creates a time delay which is equal to [Y] times
; 10 ms. The timer prescaler is 1:8.
; ********************************************************************************
delayby10ms
bset
TIOS,OC0
; enable OC0
ldd
TCNT
again1
addd
#30000
; start an output-compare operation
std
TC0
; with 10-ms time delay
brclr
TFLG1,C0F,*
ldd
TC0
dbne
y,again1
bclr
TIOS,OC0
; disable OC0
rts
; ********************************************************************************
; This table determines the frequency of each note.
; ********************************************************************************
score dc.w D4,B3,G3,B3,D4,G4,B4,A4,G4,B3,C4S
dc.w D4,ZZ,D4,ZZ,D4,B4,A4,G4,F4S,E4,F4S,G4,ZZ,G4,D4,B3,G3
dc.w D4,B3,G3,B3,D4,G4,B4,A4,G4,B3,C4S,D4,ZZ,D4,ZZ,D4
dc.w B4,A4,G4,F4S,E4,F4S,G4,ZZ,G4,D4,B3,G3,B4,ZZ,B4
dc.w B4,C5,D5,ZZ,D5,C5,B4,A4,B4,C5,ZZ,C5,ZZ,C5,B4,A4,G4
dc.w F4S,E4,F4S,G4,B3,C4S,D4,ZZ,D4,G4,ZZ,G4,ZZ,G4,F4S
dc.w E4,ZZ,E4,ZZ,E4,A4,C5,B4,A4,G4,ZZ,G4,F4S,D4,ZZ,D4
dc.w G4,A4,B4,C5,D5,G4,A4,B4,C5,A4,G4
; ********************************************************************************
; Each of the following entries multiplied by 10 ms gives the duration of a note.
; ********************************************************************************
duration
dc.w
30,10,40,40,40,80,30,10,40,40,40
dc.w
80, 3,20,3,20,60,20,40,80,20,20,40,3,40,40,40,40
dc.w
30,10,40,40,40,80,30,10,40,40,40,80,3,20,3,20
dc.w
60,20,40,80,20,20,40,3,40,40,40,40,20,3,20
Search WWH ::




Custom Search