annotate level1/modules/clock2.asm @ 1417:b7b173926ea1

Changes and fixes by Robert Gault
author boisy
date Sun, 30 Nov 2003 22:25:56 +0000
parents 7fdef42e19a0
children 31cba223dc92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
1 ********************************************************************
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
2 * Clock2 - Real-Time Clock Subroutines
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
3 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
4 * $Id$
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
5 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
6 * Edt/Rev YYYY/MM/DD Modified by
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
7 * Comment
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
8 * ------------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
9 * 1 2003/08/18 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
10 * Stripped from clock.asm in order to modularize clocks.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
11
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
12 nam Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
13 ttl Real-Time Clock Subroutines
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
14
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
15 ifp1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
16 use defsfile
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
17 endc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
18
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
19 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
20 * Setup for specific RTC chip
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
21 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
22 IFNE RTCDriveWire
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
23 RTC.Base equ $0000
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
24 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
25
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
26 IFNE RTCElim
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
27 RTC.Sped equ $20 32.768 KHz, rate=0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
28 RTC.Strt equ $06 binary, 24 Hour, DST disabled
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
29 RTC.Stop equ $86 bit 7 set stops clock to allow setting time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
30 RTC.Base equ $FF72 I don't know base for this chip.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
31 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
32
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
33 IFNE RTCDsto2+RTCDsto4
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
34 RTC.Base equ $FF50 Base address of clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
35 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
36
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
37 IFNE RTCBB+RTCTc3
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
38 IFNE RTCBB
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
39 RTC.Base equ $FF5C In SCS* Decode
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
40 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
41 RTC.Base equ $FF7C Fully decoded RTC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
42 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
43 RTC.Zero equ -4 Send zero bit by writing this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
44 RTC.One equ -3 Send one bit by writing this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
45 RTC.Read equ 0 Read data from this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
46 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
47
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
48 IFNE RTCSmart
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
49 RTC.Base equ $4004 We map the clock into this addr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
50 RTC.Zero equ -4 Send zero bit by writing this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
51 RTC.One equ -3 Send one bit by writing this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
52 RTC.Read equ 0 Read data from this offset
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
53 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
54
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
55 IFNE RTCHarrs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
56 RTC.Base equ $FF60 Base address for clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
57 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
58
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
59 IFNE RTCSoft
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
60 RTC.Base equ 0 Have to have one defined.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
61 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
62
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
63 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
64 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
65 * Start of module
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
66 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
67 mod len,name,Systm+Objct,ReEnt+0,JmpTable,RTC.Base
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
68
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
69 name fcs "Clock2"
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
70 fcb 1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
71
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
72 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
73 SlotSlct fcb MPI.Slot-1 Slot constant for MPI select code
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
74 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
75
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
76 * Jump table for RTC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
77 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
78 * Entry points:
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
79 * - Init
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
80 * - SetTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
81 * - GetTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
82 JmpTable
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
83 lbra Init
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
84 bra GetTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
85 nop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
86 lbra SetTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
87
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
88 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
89 * GetTime Subroutine
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
90 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
91 * This subroutine is called by the main clock module.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
92 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
93
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
94 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
95 * Eliminator time update (lacks MPI slot select ability)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
96 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
97 GetTime equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
98 IFNE RTCElim
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
99 ldx M$Mem,pcr get RTC base address from fake memory requirement
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
100 ldb #$0A UIP status register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
101 stb ,x generate address strobe
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
102 lda 1,x get UIP status
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
103 bpl NoUIP Update In Progress, go shift next RTC read
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
104 lda #TkPerSec/2 set up next RTC read attempt in 1/2 second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
105 sta <D.Tick save tick
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
106 bra UpdTExit and return
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
107
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
108 NoUIP decb year register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
109 stb ,x generate address strobe
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
110 lda 1,x get year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
111 sta <D.Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
112 decb month register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
113 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
114 lda 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
115 sta <D.Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
116 decb day of month register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
117 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
118 lda 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
119 sta <D.Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
120 ldb #4 hour register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
121 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
122 lda 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
123 sta <D.Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
124 ldb #2 minute register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
125 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
126 lda 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
127 sta <D.Min
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
128 clrb second register address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
129 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
130 lda 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
131 SaveSec sta <D.Sec
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
132 UpdTExit rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
133 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
134
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
135 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
136 * Disto 2-in-1 RTC time update
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
137 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
138 IFNE RTCDsto2
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
139 pshs a,cc Save old interrupt status and mask IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
140 bsr RTCPre
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
141
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
142 bsr GetVal Get Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
143 bsr GetVal Get Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
144 bsr GetVal Get Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
145 decb ldb #5
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
146 stb 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
147 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
148 lda ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
149 anda #3
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
150 bsr GetVal1 Get Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
151 bsr GetVal Get Minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
152 bsr GetVal Get Second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
153
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
154 RTCPost clr >$FFD9 2 MHz (Really should check $A0 first)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
155 puls cc,b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
156
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
157 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
158 stb >MPI.Slct Restore saved "currently" selected MPak slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
159 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
160
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
161 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
162 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
163
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
164 RTCPre orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
165
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
166 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
167 ldb >MPI.Slct Save currently selected MPak slot on stack
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
168 stb 3,s
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
169 andb #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
170 orb >SlotSlct,pcr Get slot to select
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
171 stb >MPI.Slct Select MPak slot for clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
172 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
173
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
174 ldy #D.Time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
175 ldx M$Mem,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
176 clr 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
177 ldb #12
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
178 clr >$FFD8 1 MHz
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
179 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
180
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
181 GetVal stb 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
182 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
183 lda ,x read tens digit from clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
184 anda #$0f
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
185 GetVal1 pshs b save b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
186 ldb #10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
187 mul multiply by 10 to get value
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
188 stb ,y save 10s value
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
189 puls b set up clock for ones digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
190 stb 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
191 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
192 lda ,x read ones digit from clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
193 anda #$0f
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
194 adda ,y add ones + tens
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
195 sta ,y+ store clock value into time packet
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
196 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
197
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
198 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
199
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
200 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
201 * Disto 4-in-1 RTC time update
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
202 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
203 IFNE RTCDsto4
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
204 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
205 pshs cc Save old interrupt status and mask IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
206 orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
207 ldb >MPI.Slct Save currently selected MPak slot on stack
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
208 pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
209 andb #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
210 orb >SlotSlct,pcr Select MPak slot for clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
211 stb >MPI.Slct
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
212 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
213
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
214 ldx M$Mem,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
215 ldy #D.Time Start with seconds
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
216
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
217 ldb #11
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
218 bsr GetVal Get Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
219 bsr GetVal Get Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
220 bsr GetVal Get Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
221 lda #3 Mask tens digit of hour to remove AM/PM bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
222 bsr GetVal1 Get Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
223 bsr GetVal Get Minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
224 bsr GetVal Get Second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
225
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
226 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
227 puls b Restore saved "currently" selected MPak slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
228 stb >MPI.Slct
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
229 puls cc,pc Restore previous IRQ status
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
230 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
231 rts No MPI, don't need to mess with slot, CC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
232 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
233
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
234 GetVal lda #$0f Mask to apply to tens digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
235 GetVal1 stb 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
236 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
237 anda ,x read ones digit from clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
238 pshs b save b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
239 ldb #10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
240 mul multiply by 10 to get value
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
241 stb ,y Add to ones digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
242 puls b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
243 stb 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
244 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
245 lda ,x read tens digit from clock and mask it
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
246 anda #$0f
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
247 adda ,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
248 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
249 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
250
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
251 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
252
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
253
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
254 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
255 * Update time from DriveWire
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
256 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
257 IFNE RTCDriveWire
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
258
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
259 lbra DoDW
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
260
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
261 use bbwrite.asm
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
262
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
263 DoDW pshs y,x,cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
264 lda #'# Time packet
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
265 orcc #IntMasks Disable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
266 lbsr SerWrite
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
267 bsr SerRead Read year byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
268 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
269 sta <D.Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
270 bsr SerRead Read month byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
271 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
272 sta <D.Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
273 bsr SerRead Read day byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
274 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
275 sta <D.Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
276 bsr SerRead Read hour byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
277 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
278 sta <D.Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
279 bsr SerRead Read minute byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
280 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
281 sta <D.Min
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
282 bsr SerRead Read second byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
283 bcs UpdLeave
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
284 sta <D.Sec
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
285 bsr SerRead Read day of week (0-6) byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
286 UpdLeave puls cc,x,y,pc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
287
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
288 use bbread.asm
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
289
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
290 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
291
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
292 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
293 * Update time from B&B RTC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
294 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
295 IFNE RTCBB+RTCTc3
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
296 pshs u,y,cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
297 leay ReadBCD,pcr Read bytes of clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
298
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
299 TfrTime orcc #IntMasks turn off interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
300 ldu M$Mem,pcr Get base address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
301
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
302 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
303 ldb >MPI.Slct Select slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
304 pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
305 andb #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
306 orb SlotSlct,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
307 stb >MPI.Slct
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
308 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
309
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
310 lbsr SendMsg Initialize clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
311 ldx #D.Sec
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
312 ldb #8 Tfr 8 bytes
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
313
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
314 tfrloop jsr ,y Tfr 1 byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
315
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
316 bitb #$03
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
317 beq skipstuf Skip over day-of-week, etc.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
318 leax -1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
319 skipstuf decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
320 bne tfrloop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
321
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
322 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
323 puls b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
324 stb >MPI.Slct restore MPAK slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
325 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
326
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
327 puls u,y,cc,pc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
328
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
329 ClkMsg fcb $C5,$3A,$A3,$5C,$C5,$3A,$A3,$5C
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
330 * Enable clock with message $C53AA35CC53AA35C
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
331 SendMsg lda RTC.Read,u Send Initialization message to clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
332 leax <ClkMsg,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
333 ldb #8
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
334 msgloop lda ,x+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
335 bsr SendByte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
336 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
337 bne msgloop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
338 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
339
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
340 SendBCD pshs b Send byte to clock, first converting to BCD
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
341 bitb #$03
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
342 bne BCDskip Send zero for day-of-week, etc.
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
343 lda #0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
344 bra SndBCDGo
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
345 BCDskip lda ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
346 SndBCDGo tfr a,b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
347 bra binenter
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
348 binloop adda #6
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
349 binenter subb #10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
350 bhs binloop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
351 puls b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
352 SendByte coma Send one byte to clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
353 rora
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
354 bcc sendone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
355 sendzero tst RTC.Zero,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
356 lsra
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
357 bcc sendone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
358 bne sendzero
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
359 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
360 sendone tst RTC.One,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
361 lsra
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
362 bcc sendone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
363 bne sendzero
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
364 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
365
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
366
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
367 ReadBCD pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
368 ldb #$80 High bit will rotate out after we read 8 bits
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
369 readbit lda RTC.Read,u Read a bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
370 lsra
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
371 rorb Shift it into B
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
372 bcc readbit Stop when marker bit appears
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
373 tfr b,a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
374 bra BCDEnter Convert BCD number to Binary
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
375 BCDLoop subb #6 by subtracting 6 for each $10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
376 BCDEnter suba #$10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
377 bhs BCDLoop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
378 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
379 puls b,pc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
380
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
381 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
382
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
383
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
384 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
385 * Update time from Smartwatch RTC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
386 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
387 IFNE RTCSmart
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
388 pshs cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
389 orcc #IntMasks Disable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
390 lda >MPI.Slct Get MPI slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
391 ldb <$90 Get GIME shadow of $FF90
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
392 pshs b,a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
393 anda #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
394 ora >SlotSlct,pcr Get new slot to select
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
395 anda #$03 *** TEST ***
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
396 sta >MPI.Slct And select it
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
397 andb #$FC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
398 stb >$FF90 ROM mapping = 16k internal, 16k external
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
399 ldb >$FFA2 Read GIME for $4000-$5fff
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
400 pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
401 lda #$3E
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
402 sta >$FFA2 Put block $3E at $4000-$5fff
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
403 clr >$FFDE Map RAM/ROM, to map in external ROM
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
404 lbsr SendMsg Initialize clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
405 ldx #D.Sec Start with seconds
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
406 lda #$08
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
407 sta ,-s Set up loop counter = 8
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
408 L021E ldb #$08
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
409 L0220 lda >RTC.Read+RTC.Base Read one bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
410 lsra
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
411 ror ,x Put bit into time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
412 decb End of bit loop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
413 bne L0220
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
414 lda ,s Check loop counter
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
415 cmpa #$08
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
416 beq L023D Fill "seconds" twice (ignore 1st value)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
417 cmpa #$04
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
418 bne L0239
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
419 ldb ,x Save 4th value read at $34 (day of week?)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
420 stb $0A,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
421 bra L023D And overwrite "day" with day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
422 L0239 leax -$01,x Go to next time to read
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
423 bsr BCD2Dec Convert 1,x from BCD to decimal
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
424 L023D dec ,s
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
425 bne L021E End of loop for reading time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
426 leas $01,s Done with loop counter
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
427 clr >$FFDF Map all RAM
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
428 puls b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
429 stb >$FFA2 Put back original memory block
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
430 puls b,a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
431 sta >MPI.Slct
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
432 stb >$FF90 Restore original ROM mapping
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
433 puls cc,pc Re-enable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
434
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
435 * Convert BCD to a normal number
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
436
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
437 BCD2Dec lda $01,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
438 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
439 B2DLoop cmpa #$10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
440 bcs B2DDone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
441 suba #$10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
442 addb #$0A
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
443 bra B2DLoop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
444 B2DDone pshs a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
445 addb ,s+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
446 stb $01,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
447 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
448
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
449 ClkMsg fcb $C5,$3A,$A3,$5C,$C5,$3A,$A3,$5C
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
450
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
451 * Send above "string" to smartwatch, one bit at a time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
452
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
453 SendMsg leax <ClkMsg,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
454 lda >RTC.Read+RTC.Base Tell clock we're going to start???
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
455 lda #$08
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
456 sta ,-s Store counter = 8
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
457 L006B ldb #$08 Start of outer loop, 8 bytes to send
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
458 lda ,x+ Get byte to send
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
459 L006F lsra Start of inner loop, 8 bits to send
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
460 bcs L0077
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
461 tst >RTC.Zero+RTC.Base Send a "zero" bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
462 bra L007A
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
463 L0077 tst >RTC.One+RTC.Base Send a "one" bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
464 L007A decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
465 bne L006F End of inner loop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
466 dec ,s End of outer loop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
467 bne L006B
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
468 puls pc,a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
469
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
470 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
471
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
472 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
473 * Update time from Harris RTC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
474 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
475 IFNE RTCHarrs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
476 pshs cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
477 orcc #IntMasks Disable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
478
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
479 ldu M$Mem,pcr Get base address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
480 ldy #D.Time Pointer to time in system map
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
481
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
482 lda #%00001100 Init command register (Normal,Int. Disabled,
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
483 sta $11,u Run,24-hour mode, 32kHz)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
484
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
485 lda ,u Read base address to set-up clock regs for read
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
486 lda 6,u Get year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
487 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
488 lda 4,u Get month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
489 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
490 lda 5,u Get day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
491 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
492 lda 1,u Get hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
493 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
494 lda 2,u Get minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
495 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
496 lda 3,u Get second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
497 sta ,y+
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
498
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
499 puls cc,pc Re-enable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
500 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
501 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
502 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
503 * Software time update
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
504 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
505 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
506
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
507 IFNE RTCSoft
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
508 lda <D.Min grab current minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
509 inca minute+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
510 cmpa #60 End of hour?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
511 blo UpdMin no, Set start of minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
512 ldd <D.Day get day, hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
513 incb hour+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
514 cmpb #24 End of Day?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
515 blo UpdHour ..no
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
516 inca day+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
517 leax months-1,pcr point to months table with offset-1: Jan = +1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
518 ldb <D.Month this month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
519 cmpa b,x end of month?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
520 bls UpdDay ..no, update the day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
521 cmpb #2 yes, is it Feb?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
522 bne NoLeap ..no, ok
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
523 ldb <D.Year else get year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
524 andb #$03 check for leap year: good until 2099
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
525 cmpd #$1D00 29th on leap year?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
526 beq UpdDay ..yes, skip it
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
527 NoLeap ldd <D.Year else month+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
528 incb month+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
529 cmpb #13 end of year?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
530 blo UpdMonth ..no
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
531 inca year+1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
532 ldb #$01 set month to jan
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
533 UpdMonth std <D.Year save year, month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
534 lda #$01 day=1st
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
535 UpdDay clrb hour=midnite
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
536 UpdHour std <D.Day save day,hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
537 clra minute=00
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
538 UpdMin clrb seconds=00
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
539 std <D.Min save min,secs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
540 UpdTExit rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
541 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
542
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
543 months fcb 31,28,31,30,31,30,31,31,30,31,30,31 Days in each month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
544
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
545
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
546 SetTime equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
547 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
548 * Set Eliminator RTC from D.Time
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
549 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
550 IFNE RTCElim
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
551 pshs cc save interrupt status
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
552 orcc #IntMasks disable IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
553 ldx M$Mem,pcr get RTC base address from fake memory requirement
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
554 ldy #D.Time point [Y] to time variables in DP
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
555 ldd #$0B*256+RTC.Stop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
556 bsr UpdatCk0 stop clock before setting it
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
557 ldb #RTC.Sped
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
558 bsr UpdatCk0 set crystal speed, output rate
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
559 bsr UpdatClk go set year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
560 bsr UpdatClk go set month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
561 bsr UpdatClk go set day of month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
562 bsr UpdatCk0 go set day of week (value doesn't matter)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
563 bsr UpdatCk0 go set hours alarm (value doesn't matter)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
564 bsr UpdatClk go set hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
565 bsr UpdatCk0 go set minutes alarm (value doesn't matter)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
566 bsr UpdatClk go set minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
567 bsr UpdatCk0 go set seconds alarm (value doesn't matter)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
568 bsr UpdatClk go set second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
569 ldd #$0B*256+RTC.Strt
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
570 bsr UpdatCk0 go start clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
571 puls cc Recover IRQ status
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
572 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
573 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
574
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
575 UpdatClk ldb ,y+ get data from D.Time variables in DP
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
576 UpdatCk0 std ,x generate address strobe, save data
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
577 deca set [A] to next register down
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
578 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
579
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
580 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
581 * OS-9 Level Two code only (for now)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
582 NewSvc fcb F$NVRAM Eliminator adds one new service call
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
583 fdb F.NVRAM-*-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
584 fcb $80 end of service call installation table
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
585
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
586 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
587 * read/write RTC Non Volatile RAM (NVRAM)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
588 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
589 * INPUT: [U] = pointer to caller's register stack
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
590 * R$A = access mode (1 = read, 2 = write, other = error)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
591 * R$B = byte count (1 through 50 here, but in other implementations
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
592 * may be 1 through 256 where 0 implies 256)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
593 * R$X = address of buffer in user map
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
594 * R$Y = start address in NVRAM
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
595 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
596 * OUTPUT: RTC NVRAM read/written
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
597 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
598 * ERROR OUTPUT: [CC] = Carry set
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
599 * [B] = error code
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
600 F.NVRAM tfr u,y copy caller's register stack pointer
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
601 ldd #$0100 ask for one page
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
602 os9 F$SRqMem
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
603 bcs NVR.Exit go report error...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
604 pshs y,u save caller's stack and data buffer pointers
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
605 ldx R$Y,y get NVRAM start address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
606 cmpx #50 too high?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
607 bhs Arg.Err yes, go return error...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
608 ldb R$B,y get NVRAM byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
609 beq Arg.Err
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
610 abx check end address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
611 cmpx #50 too high?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
612 bhi Arg.Err yes, go return error...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
613 lda R$A,y get direction flag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
614 cmpa #WRITE. put caller's data into NVRAM?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
615 bne ChkRead no, go check if read...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
616 clra [D]=byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
617 pshs d save it...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
618 ldx <D.Proc get caller's process descriptor address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
619 lda P$Task,x caller is source task
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
620 ldb <D.SysTsk system is destination task
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
621 ldx R$X,y get caller's source pointer
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
622 puls y recover byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
623 os9 F$Move go MOVE data
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
624 bcs NVR.Err
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
625 ldy ,s get caller's register stack pointer from stack
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
626 lda R$Y+1,y get NVRAM start address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
627 adda #$0E add offset to first RTC NVRAM address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
628 ldb R$B,y get byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
629 ldx M$Mem,pcr get clock base address from fake memory requirement
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
630 pshs cc,b save IRQ enable status and byte counter
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
631 orcc #IntMasks disable IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
632 WrNVR.Lp ldb ,u+ get caller's data
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
633 std ,x generate RTC address strobe and save data to NVRAM
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
634 inca next NVRAM address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
635 dec 1,s done yet?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
636 bne WrNVR.Lp no, go save another byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
637 puls cc,b recover IRQ enable status and clean up stack
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
638 NVR.RtM puls y,u recover register stack & data buffer pointers
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
639 ldd #$0100 return one page
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
640 os9 F$SRtMem
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
641 NVR.Exit rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
642
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
643 Arg.Err ldb #E$IllArg Illegal Argument error
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
644 bra NVR.Err
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
645
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
646 ChkRead cmpa #READ. return NVRAM data to caller?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
647 bne Arg.Err illegal access mode, go return error...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
648 lda R$Y+1,y get NVRAM start address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
649 adda #$0E add offset to first RTC NVRAM address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
650 ldx M$Mem,pcr get clock base address from fake memory requirement
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
651 pshs cc,b save IRQ enable status and byte counter
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
652 orcc #IntMasks disable IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
653 RdNVR.Lp sta ,x generate RTC address strobe
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
654 ldb 1,x get NVRAM data
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
655 stb ,u+ save it to buffer
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
656 inca next NVRAM address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
657 dec 1,s done yet?
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
658 bne RdNVR.Lp no, go get another byte
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
659 puls cc,a recover IRQ enable status, clean up stack ([A]=0)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
660 ldb R$B,y [D]=byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
661 pshs d save it...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
662 ldx <D.Proc get caller's process descriptor address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
663 ldb P$Task,x caller is source task
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
664 lda <D.SysTsk system is destination task
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
665 ldu R$X,y get caller's source pointer
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
666 puls y recover byte count
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
667 ldx 2,s get data buffer (source) pointer
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
668 os9 F$Move go MOVE data
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
669 bcc NVR.RtM
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
670 NVR.Err puls y,u recover caller's stack and data pointers
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
671 pshs b save error code
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
672 ldd #$0100 return one page
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
673 os9 F$SRtMem
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
674 comb set Carry for error
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
675 puls b,pc recover error code, return...
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
676
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
677 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
678 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
679
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
680 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
681 * Set Disto 2-in-1 RTC from Time variables
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
682 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
683 IFNE RTCDsto2
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
684 pshs a,cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
685 lbsr RTCPre Initialize
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
686
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
687 bsr SetVal Set Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
688 bsr SetVal Set Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
689 bsr SetVal Set Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
690 ldd #$0805 $08 in A, $05 in B
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
691 bsr SetVal1 Set Hour (OR value in A ($08) with hour)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
692 bsr SetVal Set Minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
693 bsr SetVal Set Second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
694
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
695 lbra RTCPost Clean up + return
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
696
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
697 SetVal clra
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
698 SetVal1 stb 2,x Set Clock address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
699 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
700 pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
701 ldb ,y+ Get current value
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
702 DvLoop subb #10 Get Tens digit in A, ones digit in B
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
703 bcs DvDone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
704 inca
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
705 bra DvLoop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
706 DvDone addb #10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
707 sta ,x Store tens digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
708 tfr b,a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
709 puls b Get back original clock address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
710 stb 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
711 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
712 sta ,x Store ones digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
713 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
714 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
715
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
716 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
717 * Set Disto 4-in-1 RTC from Time variables
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
718 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
719 IFNE RTCDsto4
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
720 pshs cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
721 orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
722
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
723 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
724 ldb >MPI.Slct Save currently selected MPak slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
725 pshs b
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
726 andb #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
727 orb >SlotSlct,pcr Get slot to select
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
728 stb >MPI.Slct Select MPak slot for clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
729 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
730
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
731 ldy #D.Time+6
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
732 ldx M$Mem,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
733 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
734 bsr SetVal Set Second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
735 bsr SetVal Set Minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
736 bsr SetVal Set Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
737 bsr SetVal Set Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
738 bsr SetVal Set Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
739 bsr SetVal Set Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
740
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
741 IFNE MPIFlag
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
742 puls b Restore old MPAK slot
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
743 stb >MPI.Slct
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
744 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
745
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
746 puls cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
747 clrb No error
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
748 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
749
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
750 SetVal clr ,-s Create variable for tens digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
751 lda ,-y Get current value
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
752 DvLoop suba #10 Get Tens digit on stack, ones digit in A
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
753 bcs DvDone
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
754 inc ,s
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
755 bra DvLoop
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
756 DvDone adda #10
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
757 stb 1,x Set Clock address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
758 incb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
759 sta ,x Store ones digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
760 stb 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
761 incb
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
762 puls a
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
763 sta ,x Store tens digit
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
764 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
765 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
766
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
767 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
768 * Set B&B RTC from Time variables
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
769 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
770 IFNE RTCBB+RTCTc3
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
771 pshs u,y,cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
772 leay SendBCD,pcr Send bytes of clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
773 lbra TfrTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
774 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
775
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
776 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
777 * Set Harris 1770 RTC from Time variables
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
778 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
779 IFNE RTCHarrs
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
780 pshs cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
781 orcc #IntMasks Disable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
782
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
783 ldu M$Mem,pcr Get base address
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
784 ldy #D.Time Pointer to time in system map
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
785
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
786 lda #%00000100 Init command register (Normal,Int. Disabled,
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
787 sta $11,u STOP clock,24-hour mode, 32kHz)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
788
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
789 lda ,y+ Get year
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
790 sta 6,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
791 lda ,y+ Get month
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
792 sta 4,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
793 lda ,y+ Get day
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
794 sta 5,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
795 lda ,y+ Get hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
796 sta 1,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
797 lda ,y+ Get minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
798 sta 2,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
799 lda ,y Get second
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
800 sta 3,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
801
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
802 lda #%00001100 Init command register (Normal,Int. Disabled,
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
803 sta $11,u START clock,24-hour mode, 32kHz)
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
804
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
805 puls cc,pc Re-enable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
806 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
807
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
808
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
809 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
810 * RTC-specific initializations here
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
811 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
812 Init equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
813 IFNE RTCDsto4
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
814 * Disto 4-N-1 RTC specific initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
815 ldx M$Mem,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
816 ldd #$010F Set mode for RTC chip
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
817 stb 1,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
818 sta ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
819 ldd #$0504
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
820 sta ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
821 stb ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
822 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
823
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
824 IFNE RTCElim
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
825 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
826 * Eliminator will install specific system calls
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
827 leay NewSvc,pcr insert syscalls
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
828 os9 F$SSvc
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
829 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
830 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
831
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
832 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
833
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
834 emod
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
835 len equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents:
diff changeset
836 end