Classic Computer Magazine Archive PROGRAM LISTING: 89-02a/CLOCK.M65


0100 ;CLOCK.M65
0110 ;BY J. LITTLE
0120 ;(c)1988, ANTIC PUBLISHING
0130 ;
0140 ;USES RTCLOK FOR REAL-TIME CLOCK
0150 ;IN VBI. USES ADDRESS 20 TO KEEP
0160 ;COUNT OF JIFFIES AND USES 18 & 19
0170 ;FOR STORAGE OF COUNT OF MINUTES
0180 ;& SECONDS INSTEAD OF THEIR USUAL
0190 ;FUNCTIONS. USES LOCATION $CF TO
0200 ;KEEP COUNT OF HOURS. COUNTS
0210 ;JIFFIES IN $D0 AND $D1.
0220 ;
0230 ;Because this clock is intended
0240 ;for long-term applications,
0250 ;all calculations were made using
0260 ;the maximum number of decimal
0270 ;places, for the highest accuracy.
0280 ;Working from RTCLOK'S calculated
0290 ;error of .12776% (59.92334 HZ
0300 ;instead of 60 HZ), the jiffy
0310 ;counter is incremented every
0320 ;13.05 seconds (783 jiffies), for
0330 ;a calculated accuracy of
0340 ;approximately .00004%, or about
0350 ;1/4 second per week.
0360 ;
0370 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0380 ;
0390     *=  $0680
0400 ;
0410 ;SET UP VBI
0420     PLA 
0430     LDX # >START
0440     LDY # <START
0450     LDA #7
0460     JSR $E45C
0470     RTS 
0480 ;
0490 ;FIRST PART OF CODE MAKES UP
0500 ;FOR LOST TIME
0510 ;
0520 START
0530     INC $D0
0540     BNE AA
0550 ;
0560     INC $D1
0570 AA
0580     LDA $D0     ;WHEN $D0=15
0590     CMP #15     ;AND $D1=3,
0600     BCC RESUME  ;ELAPSED TIME
0610 ;
0620     LDA $D1     ;=13.05 SEC
0630     CMP #3
0640     BCC RESUME
0650 ;
0660     LDA #0      ;CLEAR COUNTERS
0670     STA $D0
0680     STA $D1
0690     LDA 20      ;IF # OF JIFFIES
0700     CMP #60     ;=60,INCREASE
0710     BCC BB      ;TO 1 INSTEAD
0720 ;
0730     LDA #1      ;OF 0 AND INC
0740     STA 20      ;SECOND COUNT.
0750     BNE CC
0760 ;
0770 BB
0780     INC 20
0790 ;
0800 ;REST OF CODE COUNTS JIFFIES,
0810 ;SECONDS, MINUTES, AND HOURS.
0820 ;
0830 RESUME
0840     LDA 20      ;COUNT JIFFIES
0850     CMP #60     ;FOR 1 SECOND
0860     BCC END
0870 ;
0880     LDA #0      ;ZERO JIFFIE
0890     STA 20      ;COUNTER THEN
0900 CC
0910     INC 19      ;UPDATE SECONDS
0920     LDA 19
0930     CMP #60
0940     BCC END     ;FOR 1 MINUTE
0950 ;
0960     LDA #0
0970     STA 19
0980     INC 18
0990     LDA 18      ;COUNT MINUTES
1000     CMP #60     ;FOR 1 HOUR
1010     BCC END
1020 ;
1030     LDA #0
1040     STA 18
1050     INC $CF     ;STORE HOUR
1060     LDA $CF     ;COUNT IN $CF
1070     CMP #24
1080     BCC END
1090 ;
1100     LDA #0
1110     STA $CF
1120 END
1130     JMP $E462


Back to previous page