-
Notifications
You must be signed in to change notification settings - Fork 82
/
time
124 lines (124 loc) · 2.67 KB
/
time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.PAG 'TIME FUNCTION'
;***********************************
;* *
;* TIME *
;* *
;*CONSISTS OF THREE FUNCTIONS: *
;* (1) UDTIM-- UPDATE TIME. USUALLY*
;* CALLED EVERY 60TH SECOND. *
;* (2) SETTIM-- SET TIME. .Y=MSD, *
;* .X=NEXT SIGNIFICANT,.A=LSD *
;* (3) RDTIM-- READ TIME. .Y=MSD, *
;* .X=NEXT SIGNIFICANT,.A=LSD *
;* *
;***********************************
;INTERRUPTS ARE COMING FROM TV HORIZONTAL
;WHICH IS CLOSE TO 60HZ BUT A LITTLE OVER.
;CRFAC COUNTS UP THEN SKIPS ONE UPDATE
;OF THE TIME REGISTER.
;
UDTIM LDX #0 ;PRE-LOAD FOR LATER
; INC CRFAC
; LDA CRFAC
; BNE UD10
; INC CRFAC+1
; UD10 CMP #$6F
; BNE UD20
; LDA CRFAC+1
; CMP #2
; BEQ UD50
;
;HERE WE PROCEED WITH AN INCREMENT
;OF THE TIME REGISTER.
;
UD20 INC TIME+2
BNE UD30
INC TIME+1
BNE UD30
INC TIME
;
;HERE WE CHECK FOR ROLL-OVER 23:59:59
;AND RESET THE CLOCK TO ZERO IF TRUE
;
;24:00:00 = 5184000 JIFFIES
;=79*65536+26*256+0
;=$4F*65536+$1A*256+$0+CORRECTION
;
;FINAL CORRECTION IS +1/60TH IN
;24 HOURS.
;
UD30 SEC
LDA TIME+2
SBC #$01
LDA TIME+1
SBC #$1A
LDA TIME
SBC #$4F
BCC UD60
;
;TIME HAS ROLLED--ZERO REGISTER
;
STX TIME
STX TIME+1
STX TIME+2
; BCS UD60 ;BRANCH ALWAYS
;
;COR. FACTOR ROLLED--ZERO IT
;
; UD50 STX CRFAC
; STX CRFAC+1
;
;SET STOP KEY FLAG HERE
;
UD60 LDA D2ORA ;WAIT FOR IT TO SETTLE
CMP D2ORA
BNE UD60 ;STILL BOUNCING
JMP STPTCH ;JUMP TO PATCH CHECKING FOR BOTH SHIFT KEYS
;
; THE FOLLOWING 3 BYTES WERE REPLACED WITH THE PRECEEDING JMP
;
; STA STKEY ;SAVE FOR OTHER ROUTINES
; RTS
.SKI 5
RDTIM SEI ;KEEP TIME FROM ROLLING
LDA TIME+2 ;GET LSD
LDX TIME+1 ;GET NEXT MOST SIG.
LDY TIME ;GET MSD
.SKI 5
SETTIM SEI ;KEEP TIME FROM CHANGING
STA TIME+2 ;STORE LSD
STX TIME+1 ;NEXT MOST SIGNIFICANT
STY TIME ;STORE MSD
CLI
RTS
SKIPIT = * ;GO AROUND THIS PATCH
;
;*********************************************************************
;
; PATCH TO CHECK FOR RIGHT SHIFT KEY ON STOP KEY CHECK
;
;*********************************************************************
;
*=KSP3
STPTCH
TAX ;SAVE STOP KEY ROW
SEC
ROL COLM ;LOOK AT NEXT ROW FOR THIS COLUMN
LDA ROWS
ROR COLM ;PUT IT BACK THE WAY IT WAS
AND #$40 ;CHECK RIGHT SHIFT KEY BIT
BEQ ITSSET ;BRANCH IF RIGHT SHIFT IS DOWN
;
STX STKEY ;ELSE LEAVE IT AS IT IS
RTS
;
ITSSET TXA
AND #$FD ;CLEAR THE SHIFT BIT
STA STKEY ;ITS NOT THE STOP KEY ALONE
RTS
;
KSP4 = *
*=SKIPIT
.END
; RSR 8/21/80 REMOVE CRFAC CHANGE STOP
; JM 1/21/80 FIX SO SHIT/STOP GIVE RUN FROM RIGHT