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

Changes and fixes by Robert Gault
author boisy
date Sun, 30 Nov 2003 22:25:56 +0000
parents 7fdef42e19a0
children 67a173d497d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1 ********************************************************************
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
2 * Clock - OS-9 System Clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
3 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
4 * CoCo 3 notes:
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
5 * Includes support for several different RTC chips, GIME Toggle
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
6 * IRQ fix, numerous minor changes.
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
7 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * $Id$
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
9 *
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
10 * Edt/Rev YYYY/MM/DD Modified by
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
11 * Comment
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12 * ------------------------------------------------------------------
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
13 * ????/??/??
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
14 * NitrOS-9 2.00 distribution.
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
15 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
16 * 9r4 2003/01/01 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
17 * Back-ported to OS-9 Level Two.
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
18 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
19 * 9r5 2003/08/18 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
20 * Separated clock into Clock and Clock2 for modularity.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
21 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
22 * 9r6 2003/09/04 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
23 * Combined Level One and Level Two sources
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
24
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
25 nam Clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
26 ttl OS-9 System Clock
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
28 IFP1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
29 use defsfile
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
30 ENDC
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
31
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
32 Edtn equ 9
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
33 rev equ 6
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
34
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
35
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
36 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
37 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
38 * Start of module
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
39 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
40 mod len,name,Systm+Objct,ReEnt+rev,Init,0
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
41
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
42 name fcs "Clock"
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
43 fcb Edtn
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
44
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
45 IFEQ Level-1
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
46
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
47 *TkPerTS equ 2 ticks per time slice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
48 TkPerTS equ TkPerSec/10 ticks per time slice
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
49
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
50 NewSvc fcb F$Time
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
51 fdb FTime-*-2
87
39ea0a63ce31 F$VIRQ in place of Unknown label
boisy
parents: 62
diff changeset
52 fcb F$VIRQ
39ea0a63ce31 F$VIRQ in place of Unknown label
boisy
parents: 62
diff changeset
53 fdb FVIRQ-*-2
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
54 fcb F$STime
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
55 fdb FSTime-*-2
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
56 fcb $80
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
57
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
58 FSTime ldx R$X,u
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
59 ldd ,x
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
60 std <D.Year
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
61 ldd 2,x
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
62 std <D.Day
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
63 ldd 4,x
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
64 std <D.Min
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
65 andcc #^Carry
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
66
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
67 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
68 * Call SetTime entry point in Clock2
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
69 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
70 ldx <D.Clock2 get entry point to Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
71 jsr $06,x else call GetTime entry point
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
72
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
73 rts
1000
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
74
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
75 *
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
76 * Clock IRQ Entry Point
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
77 *
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
78 ClockIRQ clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
79 tfr a,dp set direct page to zero
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
80 lda PIA0Base+3 get hw byte
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
81 bmi L0032 branch if sync flag on
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
82 jmp [>D.SvcIRQ]
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
83 L0032 lda PIA0Base+2 clear interrupt?
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
84 dec <D.Tick decrement tick counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
85 bne L007F go around if not zero
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
86 ldb <D.Sec get minutes/seconds
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
87 * Seconds increment
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
88 incb increment seconds
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
89 cmpb #60 full minute?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
90 bcs L0079 nope...
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
91
1000
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
92 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
93 * Call GetTime entry point in Clock2
1000
da4002e207e3 Added DriveWire support to clock module
boisy
parents: 506
diff changeset
94 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
95 ldx <D.Clock2 get entry point to Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
96 jsr $03,x call GetTime entry point
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
97 fcb $8C skip next 2 bytes
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
98
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
99 L0079 stb <D.Sec update sec
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
100 L007B lda <D.TSec
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101 sta <D.Tick
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
102 L007F clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
103 pshs a
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
104 ldy <D.CLTb
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
105 bra L009E
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
106 L0087 ldd ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
107 subd #$0001
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
108 bne L009C
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
109 lda #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
110 sta ,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
111 lda $04,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
112 beq L00B8
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
113 L0096 ora #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
114 sta $04,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
115 ldd $02,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
116 L009C std ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
117 L009E ldx ,y++
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
118 bne L0087
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
119 lda ,s+
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 beq L00B4
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
121 ldx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
122 beq L00AE
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
123 tst P$State,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
124 bpl L00BC branch if sysstate not set
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
125 L00AE jsr [>D.Poll]
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
126 bcc L00AE
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
127 L00B4 jmp [>D.AltIRQ]
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
128 L00B8 bsr L00DD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
129 bra L0096
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
130 L00BC leay >L00C4,pcr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
131 jmp [>D.URtoSs]
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
132 L00C4 jsr [>D.Poll]
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
133 bcc L00C4
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
134 ldx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
135 ldb P$State,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
136 andb #^SysState turn off sysstate bit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
137 stb P$State,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
138 ldd <P$SWI2,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
139 std <D.SWI2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
140 ldd <D.UsrIRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141 std <D.SvcIRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
142 bra L00B4
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
143 L00DD pshs y,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
144 L00DF ldx ,y++
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
145 stx -$04,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
146 bne L00DF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
147 puls y,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
148 leay -2,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
149 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
150
87
39ea0a63ce31 F$VIRQ in place of Unknown label
boisy
parents: 62
diff changeset
151 FVIRQ pshs cc
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
152 orcc #FIRQMask+IRQMask
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
153 ldy <D.CLTb
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 ldx <D.Init
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
155 ldb PollCnt,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
156 ldx R$X,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
157 beq L0118
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 tst ,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
159 beq L010C
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
160 subb #$02
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
161 lslb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
162 leay b,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
163 tst ,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
164 bne L0128
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
165 L0106 tst ,--y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
166 beq L0106
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
167 leay $02,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
168 L010C ldx R$Y,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
169 stx ,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
170 ldy R$D,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
171 sty ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
172 bra L0124
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
173 L0118 leax R$Y,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
174 L011A tst ,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175 beq L0124
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
176 cmpx ,y++
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
177 bne L011A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
178 bsr L00DD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
179 L0124 puls cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
180 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
181 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
182 L0128 puls cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
183 comb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
184 ldb #E$Poll
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
185 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
187 Init pshs dp,cc
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
188 clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
189 tfr a,dp
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
190
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
191 leax <Clock2,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
192 lda #Systm+Objct
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
193 os9 F$Link
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
194 bcc LinkOk
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
195 jmp >$FFFE reset
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
196 LinkOk sty <D.Clock2 save entry point
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
197 * Call Clock2 init routine
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
198 jsr ,y call init entry point of Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
199
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
200
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
201 lda #TkPerSec
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
202
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
203 sta <D.TSec
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
204 sta <D.Tick
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
205
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
206 * Don't need to explicitly read RTC during initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
207 ldd #59*256+TkPerTS last second and time slice in minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
208 std <D.Sec Will prompt RTC read at next time slice
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
209
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
210 stb <D.TSlice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
211 stb <D.Slice
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
212 orcc #FIRQMask+IRQMask mask ints
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
213 leax >ClockIRQ,pcr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
214 stx <D.IRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
215 * install system calls
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
216 leay >NewSvc,pcr
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
217 os9 F$SSvc
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
218 ldx #PIA0Base
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219 clra
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
220 sta 1,x change PIA0Base side A to DDR
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
221 sta ,x clear PIA0Base side A
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
222 sta 3,x change PIA0Base side B to DDR
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
223 coma complement A side A
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
224 sta 2,x write all 1's to PIA0Base side B
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
225 lda #$34
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
226 sta 1,x PIA0Base side A to I/O reg
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
227 lda #$3F
1213
4e235f213651 Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents: 1000
diff changeset
228 sta 3,x PIA0Base side B to I/O reg
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229 lda 2,x
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
230
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
231 puls pc,dp,cc
506
4f81e616d397 clock.asm now has B&B and TC^3 clock code
boisy
parents: 201
diff changeset
232
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
233
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
234 * F$Time system call code
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
235 FTime ldx R$X,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
236 ldd <D.Year
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
237 std ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
238 ldd <D.Day
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
239 std 2,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
240 ldd <D.Min
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
241 std 4,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
242 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
243 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
244
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
245
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
246
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
247
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
248 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
249
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
250
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
251
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
252
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
253 * OS-9 Level Two Clock
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
254
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
255 TkPerTS equ 2 ticks per time slice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
256 GI.Toggl equ %00000001 GIME CART* IRQ enable bit, for CC3
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
257
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
258 * TC9 needs to reset more interrupt sources
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
259 *GI.Toggl equ %00000111 GIME SERINT*, KEYINT*, CART* IRQ enable bits
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
260
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
261
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
262 * Table to set up Service Calls:
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
263 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
264 NewSvc fcb F$Time
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
265 fdb F.Time-*-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
266 fcb F$VIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
267 fdb F.VIRQ-*-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
268 fcb F$Alarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
269 fdb F.ALARM-*-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
270 fcb F$STime
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
271 fdb F.STime-*-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
272 fcb $80 end of service call installation table
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
273
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
274 *---------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
275 * IRQ Handling starts here.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
276 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
277 * Caveat: There may not be a stack at this point, so avoid using one.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
278 * Stack is set up by the kernel between here and SvcVIRQ.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
279 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
280 SvcIRQ lda >IRQEnR Get GIME IRQ Status and save it.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
281 ora <D.IRQS
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
282 sta <D.IRQS
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
283 bita #$08 Check for clock interrupt
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
284 beq NoClock
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
285 anda #^$08 Drop clock interrupt
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
286 sta <D.IRQS
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
287 ldx <D.VIRQ Set VIRQ routine to be executed
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
288 clr <D.QIRQ ---x IS clock IRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
289 bra ContIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
290
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
291 NoClock leax DoPoll,pcr If not clock IRQ, just poll IRQ source
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
292 IFNE H6309
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
293 oim #$FF,<D.QIRQ ---x set flag to NOT clock IRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
294 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
295 lda #$FF
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
296 sta <D.QIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
297 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
298 ContIRQ stx <D.SvcIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
299 jmp [D.XIRQ] Chain through Kernel to continue IRQ handling
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
300
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
301 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
302 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
303 * IRQ handling re-enters here on VSYNC IRQ.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
304 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
305 * - Count down VIRQ timers, mark ones that are done
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
306 * - Call DoPoll/DoToggle to service VIRQs and IRQs and reset GIME
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
307 * - Call Keyboard scan
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
308 * - Update time variables
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
309 * - At end of minute, check alarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
310 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
311 SvcVIRQ clra Flag if we find any VIRQs to service
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
312 pshs a
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
313 ldy <D.CLTb Get address of VIRQ table
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
314 bra virqent
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
315
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
316 virqloop equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
317 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
318 ldd 2,y Get Level 3 extended map type
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
319 orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
320 sta >$0643
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
321 stb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
322 std >$FFA1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
323 andcc #^IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
324 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
325
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
326 ldd Vi.Cnt,x Decrement tick count
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
327 IFNE H6309
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
328 decd --- subd #1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
329 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
330 subd #$0001
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
331 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
332 bne notzero Is this one done?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
333 lda Vi.Stat,x Should we reset?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
334 bmi doreset
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
335 lbsr DelVIRQ No, delete this entry
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
336 doreset ora #$01 Mark this VIRQ as triggered.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
337 sta Vi.Stat,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
338 lda #$80 Add VIRQ as interrupt source
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
339 sta ,s
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
340 ldd Vi.Rst,x Reset from Reset count.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
341 notzero std Vi.Cnt,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
342 virqent ldx ,y++
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
343 bne virqloop
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
344
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
345 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
346 puls d
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
347 orcc #Carry
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
348 stb >$0643
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
349 stb >$FFA1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
350 incb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
351 stb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
352 stb >$FFA1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
353 andcc #^IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
354 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
355 puls a Get VIRQ status flag: high bit set if VIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
356 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
357
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
358 ora <D.IRQS Check to see if other hardware IRQ pending.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
359 bita #%10110111 Any V/IRQ interrupts pending?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
360 beq toggle
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
361 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
362 lbsr DoPoll Yes, go service them.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
363 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
364 bsr DoPoll Yes, go service them.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
365 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
366 bra KbdCheck
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
367 toggle equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
368 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
369 lbsr DoToggle No, toggle GIME anyway
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
370 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
371 bsr DoToggle No, toggle GIME anyway
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
372 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
373
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
374 KbdCheck equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
375 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
376 lda >$0643 grab current map type
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
377 ldb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
378 pshs d save it
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
379 orcc #IntMasks IRQs off
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
380 lda >$0660 SCF local memory ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
381 sta >$0643 into DAT image ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
382 sta >$FFA1 and into RAM ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
383 inca
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
384 sta >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
385 sta >$FFA2 map in SCF, CC3IO, WindInt, etc.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
386 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
387
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
388 jsr [>D.AltIRQ] go update mouse, gfx cursor, keyboard, etc.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
389
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
390 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
391 puls d restore original map type ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
392 orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
393 sta >$0643 into system DAT image ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
394 stb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
395 std >$FFA1 and into RAM ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
396 andcc #$AF
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
397 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
398
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
399 dec <D.Tick End of second?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
400 bne VIRQend No, skip time update and alarm check
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
401 lda #TkPerSec Reset tick count
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
402 sta <D.Tick
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
403
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
404 * ATD: Modified to call real time clocks on every minute ONLY.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
405 inc <D.Sec go up one second
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
406 lda <D.Sec grab current second
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
407 cmpa #60 End of minute?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
408 blo VIRQend No, skip time update and alarm check
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
409 clr <D.Sec Reset second count to zero
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
410
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
411 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
412 * Call GetTime entry point in Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
413 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
414 ldx <D.Clock2 get entry point to Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
415 jsr $03,x call GetTime entry point
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
416
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
417 NoGet ldd >WGlobal+G.AlPID
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
418 ble VIRQend Quit if no Alarm set
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
419 ldd >WGlobal+G.AlPckt+3 Does Hour/Minute agree?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
420 cmpd <D.Hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
421 bne VIRQend
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
422 ldd >WGlobal+G.AlPckt+1 Does Month/Day agree?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
423 cmpd <D.Month
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
424 bne VIRQend
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
425 ldb >WGlobal+G.AlPckt+0 Does Year agree?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
426 cmpb <D.Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
427 bne VIRQend
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
428 ldd >WGlobal+G.AlPID
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
429 cmpd #1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
430 beq checkbel
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
431 os9 F$Send
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
432 bra endalarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
433 checkbel ldb <D.Sec Sound bell for 15 seconds
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
434 andb #$F0
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
435 beq dobell
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
436 endalarm ldd #$FFFF
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
437 std >WGlobal+G.AlPID
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
438 bra VIRQend
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
439 dobell ldx >WGlobal+G.BelVec
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
440 beq VIRQend
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
441 jsr ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
442 VIRQend jmp [>D.Clock] Jump to kernel's timeslice routine
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
443
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
444 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
445 * Interrupt polling and GIME reset code
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
446 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
447
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
448 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
449 * Call [D.Poll] until all interrupts have been handled
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
450 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
451 Dopoll
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
452 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
453 lda >$0643 Level 3: get map type
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
454 ldb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
455 pshs d save for later
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
456 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
457 Dopoll.i
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
458 jsr [>D.Poll] Call poll routine
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
459 bcc DoPoll.i Until error (error -> no interrupt found)
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
460
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
461 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
462 puls d
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
463 orcc #IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
464 sta >$0643
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
465 stb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
466 std >$FFA1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
467 andcc #^IntMasks
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
468 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
469
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
470 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
471 * Reset GIME to avoid missed IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
472 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
473 DoToggle lda #^GI.Toggl Mask off CART* bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
474 anda <D.IRQS
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
475 sta <D.IRQS
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
476 lda <D.IRQER Get current enable register status
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
477 tfr a,b
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
478 anda #^GI.Toggl Mask off CART* bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
479 orb #GI.Toggl --- ensure that 60Hz IRQ's are always enabled
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
480 sta >IRQEnR Disable CART
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
481 stb >IRQEnR Enable CART
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
482 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
483 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
484
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
485
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
486 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
487 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
488 * Handle F$VIRQ system call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
489 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
490 F.VIRQ pshs cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
491 orcc #IntMasks Disable interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
492 ldy <D.CLTb Address of VIRQ table
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
493 ldx <D.Init Address of INIT
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
494 ldb PollCnt,x Number of polling table entries from INIT
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
495 ldx R$X,u Zero means delete entry
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
496 beq RemVIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
497 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
498 bra FindVIRQ ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
499
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
500 v.loop leay 4,y ---x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
501 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
502 FindVIRQ ldx ,y++ Is VIRQ entry null?
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
503 beq AddVIRQ If yes, add entry here
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
504 decb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
505 bne FindVIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
506 puls cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
507 comb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
508 ldb #E$Poll
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
509 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
510
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
511 AddVIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
512 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
513 ldx R$Y,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
514 stx ,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
515 lda >$0643
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
516 ldb >$0645
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
517 std 2,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
518 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
519 leay -2,y point to first null VIRQ entry
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
520 ldx R$Y,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
521 stx ,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
522 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
523 ldy R$D,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
524 sty ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
525 bra virqexit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
526
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
527 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
528 v.chk leay 4,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
529 RemVIRQ ldx ,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
530 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
531 RemVIRQ ldx ,y++
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
532 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
533 beq virqexit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
534 cmpx R$Y,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
535 bne RemVIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
536 bsr DelVIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
537 virqexit puls cc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
538 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
539 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
540
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
541 DelVIRQ pshs x,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
542 DelVLup
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
543 IFGT Level-2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
544 ldq ,y++ move entries up in table
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
545 leay 2,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
546 stq -8,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
547 bne DelVLup
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
548 puls x,y,pc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
549 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
550 ldx ,y++ move entries up in table
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
551 stx -4,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
552 bne DelVLup
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
553 puls x,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
554 leay -2,y
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
555 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
556 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
557
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
558 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
559 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
560 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
561 * Handle F$Alarm call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
562 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
563 F.Alarm ldx #WGlobal+G.AlPckt
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
564 ldd R$D,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
565 bne DoAlarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
566 std G.AlPID-G.AlPckt,x Erase F$Alarm PID, Signal.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
567 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
568
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
569 DoAlarm tsta If PID != 0, set alarm for this process
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
570 bne SetAlarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
571 cmpd #1 1 -> Set system-wide alarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
572 bne GetAlarm
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
573 SetAlarm std G.AlPID-G.AlPckt,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
574 ldy <D.Proc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
575 lda P$Task,y Move from process task
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
576 ldb <D.SysTsk To system task
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
577 ldx R$X,u From address given in X
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
578 ldu #WGlobal+G.AlPckt
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
579 ldy #5 Move 5 bytes
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
580 bra FMove
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
581
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
582 GetAlarm cmpd #2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
583 bne AlarmErr
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
584 ldd G.AlPID-G.AlPckt,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
585 std R$D,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
586 bra RetTime
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
587 AlarmErr comb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
588 ldb #E$IllArg
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
589 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
590 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
591
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
592 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
593 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
594 * Handle F$Time System call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
595 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
596 F.Time equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
597 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
598 ldx #D.Time Address of system time packet
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
599 RetTime ldy <D.Proc Get pointer to current proc descriptor
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
600 ldb P$Task,y Process Task number
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
601 lda <D.SysTsk From System Task
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
602 ldu R$X,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
603 STime.Mv ldy #6 Move 6 bytes
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
604 FMove os9 F$Move
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
605 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
606 ldx R$X,u get pointer to caller's space
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
607 ldd <D.Year get year and month
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
608 std ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
609 ldd <D.Day get day and hour
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
610 std 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
611 ldd <D.Min get minute and second
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
612 std 4,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
613 clrb
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
614 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
615 rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
616
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
617 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
618 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
619 * Handle F$STime system call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
620 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
621 * First, copy time packet from user address space to system time
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
622 * variables, then fall through to code to update RTC.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
623 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
624 F.STime equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
625 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
626 ldx <D.Proc Caller's process descriptor
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
627 lda P$Task,x Source is in user map
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
628 ldx R$X,u Address of caller's time packet
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
629 ldu #D.Time Destination address
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
630 ldb <D.SysTsk Destination is in system map
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
631 bsr STime.Mv Get time packet (ignore errors)
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
632 ELSE
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
633 ldx R$X,u
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
634 ldd ,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
635 std <D.Year
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
636 ldd 2,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
637 std <D.Day
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
638 ldd 4,x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
639 std <D.Min
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
640 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
641 lda #TkPerSec Reset to start of second
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
642 sta <D.Tick
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
643
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
644 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
645 * Call SetTime entry point in Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
646 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
647 ldx <D.Clock2 get entry point to Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
648 jsr $06,x else call GetTime entry point
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
649
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
650 NoSet rts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
651
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
652 *--------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
653 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
654 * Clock Initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
655 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
656 * This vector is called by the kernel to service the first F$STime
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
657 * call. F$STime is usually called by CC3Go (with a dummy argument)
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
658 * in order to initialize the clock. F$STime is re-vectored to the
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
659 * service code above to handle future F$STime calls.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
660 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
661 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
662 Init ldx <D.Proc save user proc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
663 pshs x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
664 ldx <D.SysPrc make sys for link
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
665 stx <D.Proc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
666
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
667 leax <Clock2,pcr
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
668 lda #Systm+Objct
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
669 os9 F$Link
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
670
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
671 * And here, we restore the original D.Proc value
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
672 puls x
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
673 stx <D.Proc restore user proc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
674
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
675 bcc LinkOk
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
676 lda #E$MNF
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
677 jmp <D.Crash
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
678 LinkOk sty <D.Clock2 save entry point
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
679 InitCont ldx #PIA0Base point to PIA0
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
680 clra no error for return...
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
681 pshs cc save IRQ enable status (and Carry clear)
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
682 orcc #IntMasks stop interrupts
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
683
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
684 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
685 * Note: this code can go away once we have a rel_50hz
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
686 IFEQ TkPerSec-50
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
687 ldb <D.VIDMD get video mode register copy
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
688 orb #$08 set 50 Hz VSYNC bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
689 stb <D.VIDMD save video mode register copy
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
690 stb >$FF98 set 50 Hz VSYNC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
691 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
692 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
693
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
694 sta 1,x enable DDRA
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
695 sta ,x set port A all inputs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
696 sta 3,x enable DDRB
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
697 coma
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
698 sta 2,x set port B all outputs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
699 ldd #$343C [A]=PIA0 CRA contents, [B]=PIA0 CRB contents
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
700 sta 1,x CA2 (MUX0) out low, port A, disable HBORD high-to-low IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
701 stb 3,x CB2 (MUX1) out low, port B, disable VBORD low-to-high IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
702 lda ,x clear possible pending PIA0 HBORD IRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
703 lda 2,x clear possible pending PIA0 VBORD IRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
704
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
705 * Don't need to explicitly read RTC during initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
706 ldd #59*256+TkPerTS last second and time slice in minute
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
707 std <D.Sec Will prompt RTC read at next time slice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
708
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
709 stb <D.TSlice set ticks per time slice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
710 stb <D.Slice set first time slice
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
711 leax SvcIRQ,pcr set IRQ handler
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
712 stx <D.IRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
713 leax SvcVIRQ,pcr set VIRQ handler
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
714 stx <D.VIRQ
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
715 leay NewSvc,pcr insert syscalls
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
716 os9 F$SSvc
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
717 IFGT Level-1
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
718 * H6309 optimization opportunity here using oim
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
719 lda <D.IRQER get shadow GIME IRQ enable register
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
720 ora #$08 set VBORD bit
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
721 sta <D.IRQER save shadow register
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
722 sta >IRQEnR enable GIME VBORD IRQs
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
723 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
724
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
725 * Call Clock2 init routine
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
726 ldy <D.Clock2 get entry point to Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
727 jsr ,y call init entry point of Clock2
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
728 InitRts puls cc,pc recover IRQ enable status and return
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
729
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
730 ENDC
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
731
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
732
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
733 Clock2 fcs "Clock2"
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
734
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
735 emod
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
736 len equ *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
737 end