chapter8/CH8PRG10.SRC:

40          *=$600
50 ;METRONOME ROUTINE...USES $0000 TO PASS THE METRONOME RATE
60 ;
70 AUDF1    =  $D200 ; AUDIO FREQUENCY REGISTER
80 AUDC1    =  $D201 ; AUDIO CONTROL REGISTER
90 FREQ     =  $08 ; AUDF1 VALUE
0100 VOLUME =  $AF ; AUDC1 VALUE
0110 OFF    =  $A0  ; TURN OFF VOLUME
0120 SETVBV =  $E45C ; SET TIMER VALUE ROUTINE
0130 XITVBV =  $E462
0140 CDTMV2 =  $021A ; TIMER 2
0150 CDTMA2 =  $0228 ; TIMER 2 VECTOR
0160 ZTIMER =  $0000 ; ZPAGE VBLANK TIMER VALUE
0170 ;
0180 START  LDA #10
0190        STA ZTIMER
0200 ; SET THE TIMER VECTOR
0220 ;
0230 INIT   LDA #CNTINT&255
0240        STA CDTMA2
0250        LDA #CNTINT/256
0260        STA CDTMA2+1
0270 ;
0280 ; SET THE TIMER VALUE AFTER THE VECTOR
0290 ;
0300        LDY ZTIMER ; SET TIMER TWO TO COUNT
0310        JSR SETIME
0320        RTS
0340 ; METRONOME COUNT DOWN VECTORS TO HERE
0380 ; SET UP AUDIO CHANNEL FOR MET CLICK
0400 CNTINT LDA #VOLUME
0410        STA AUDC1
0420        LDA #FREQ
0430        STA AUDF1
0435        LDY #$FF ; DELAY
0440 DELAY  DEY
0442        BNE DELAY
0450        STY AUDC1
0460        JMP INIT
0480 ;
0490 ; SUBROUTINE TO SET TIMER
0500 ;
0520 SETIME LDX #0 ; NO TIME >256 VBLANKS
0530        LDA #2 ; SET TIMER 2
0540        JSR SETVBV ; SYSTEM ROUTINE TO SET TIMER
0550        RTS
0560        *=$2E2
0570        .WORD  START
0580        .END

Back to previous page