annotate level2/modules/clock.asm @ 244:e0921d6fd2e3

Added more comments
author boisy
date Sat, 20 Jul 2002 03:38:55 +0000
parents d603059f2b9a
children 3a6527ccdb74
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1 ********************************************************************
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
2 * Clock - OS-9 Level Two V3.00 Clock part 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
3 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
4 * $Id$
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
5 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
6 * Ed. Comments Who YY/MM/DD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
7 * ------------------------------------------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * Original version KKD 87/01/01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
9 * Fixed labels KDM 87/05/22
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
10 * Break into 2 modules KKD 88/09/29
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
11 * Fixed GIME IRQ toggle BRI 88/10/05
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12 * Changed to TSlice = 3 BRI 88/11/12
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
13 * Changed to TSlice = 2 BRI 88/11/16
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
14 * Added F$TPS, chopped size BRI 88/12/09
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
15 * 14 Added F$TPS, chopped size BRI 88/12/09
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
16 * 15 Fixed bug where F$Link to Clock2 BRI ??/??/??
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
17 * was being done without switching D.Proc to the
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
18 * system state D.SysPrc first. This bug caused
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
19 * crashes in certain situations.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
20 * 16 The only change in this edition is that BRI 90/04/15
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
21 * Simmy's F$TimAlm call has been combined into
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
22 * the standard F$Alarm call, with a few enhancements.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
23 * The best documentation for this (it would probably
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
24 * be a good start on a manual page) is the comments
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
25 * from the source code.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
26 * 17 Fixed bug where jmp [D.Crash] should instead BGP 98/10/20
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27 * jmp D.Crash
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
28
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
29
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
30 nam Clock
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
31 ttl OS-9 Level Two V3.00 Clock part 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
32
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
33 ifp1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
34 use defsfile
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
35 endc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
36
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
37 edition equ 17
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
38
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
39 *******************************************************
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
40
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
41 mod len,name,systm+objct,reent+1,Init,0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
42
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
43 *******************************************************
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
44
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
45 name fcs "Clock"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
46 fcb edition
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
47
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
48 * Svc Calls:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
49
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
50 SvcTbl fcb F$Time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
51 fdb FTime-*-2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
52 fcb F$STime
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
53 fdb FSTime-*-2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
54 fcb F$VIRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
55 fdb FVIRQ-*-2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
56 fcb F$Alarm
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
57 fdb FAlarm-*-2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
58 fcb F$TPS *** new BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
59 fdb FTPS-*-2 *** new BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
60 * fcb $26
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
61 * fdb FUnk-*-2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
62 fcb $80
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
63
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
64 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
65 * IRQ Handler:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
66 * Note NO STACK HERE!
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
67
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
68 IRQChek lda >IRQEnR get GIME irq status
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
69 ora <D.IRQS save it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
70 bita #$08 was it VBORD irq?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
71 bne L0035 ..yes, increment time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
72 sta <D.IRQS
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
73 ldd <D.GPoll set D.SvcIRQ to GIME polling
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
74 bra L0043 ..and jmp D.XIRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
75
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
76 * WAS VBORD IRQ so increment Time Vars:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
77 L0035 anda #^$08 drop vbord irq
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
78 sta <D.IRQS
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
79 dec <D.Tick ticks-1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
80 bne L0041 ..skip if not yet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
81 lda #TkPerSec reset ticks to start of second
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
82 sta <D.Tick (also F$Alarm check flag!!)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
83 L0041 ldd <D.VIRQ set alternate IRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
84 L0043 std <D.SvcIrq for system state
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
85 jmp [D.XIRQ] and finish irq handling.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
86
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
87 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
88 * NEW GIME irq register reset:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
89
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
90 GPoll jsr [>D.Poll] do regular polling
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
91 bcc GPoll
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
92 GFix lda #$FE get enabled bits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
93 anda <D.IRQS
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
94 sta <D.IRQS
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
95 lda <D.IRQER
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
96 tfr a,b copy it for GIME IRQ re-trigger
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
97 anda #^$01 select GIME IRQ input(s) to toggle
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
98 sta >IrqEnR disable selected GIME input(s)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
99 stb >IrqEnR trigger GIME again
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
100 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
102
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
103 *------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
104 * VIRQ Handler:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
105
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
106 VIRQChek clr ,-s clear found flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
107 lda <D.IRQS check for other irqs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
108 bita #$37 any others?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
109 beq L006D ..no
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
110 inc ,s yes, set flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
111 L006D ldy <D.CLTb point to virqtable
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
112 bra L008A ..begin search
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
113
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
114 * Main Loop:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
115
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
116 L0072 ldd ,x get virq counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
117 subd #$0001 decrement
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
118 bne L0088 ..skip if not ready
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
119 inc ,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 lda $04,x check kill flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
121 bne L0082 ..nope
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
122 lbsr L01D9 ..yep, delete entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
123 L0082 ora #$01 set software irq bit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
124 sta $04,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
125 ldd $02,x reset counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
126 L0088 std ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
127 L008A ldx ,y++ last entry?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
128 bne L0072 ..no
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
129 lda ,s+ else any found?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
130 beq L0092 ..no
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
131 bsr GPoll
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
132 bra L0094
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
133 L0092 bsr GFix
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
134 L0094 jsr [>D.AltIRQ] poll keyboard
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
135 lda #TkPerSec
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
136 cmpa <D.Tick new second starting?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
137 bne L011D ..not yet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
138 ldd #3 gettime vector
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
139 lbsr L0125
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
140 lda <$002D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141 cmpa #$10
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
142 bhi L011D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
143 beq L00E5
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
144 ldx #$1016
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
145 ldb ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
146 beq L011D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
147 leay -$07,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
148 bsr L00CE
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
149 bne L011D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
150 lda <$002D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
151 cmpa #$0F
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
152 bcs L00C5
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
153 tstb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 bpl L00C5
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
155 clr ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
156 L00C5 ldx >$1017
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
157 beq L011D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 jsr ,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
159 bra L011D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
160 L00CE ldb #$04
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
161 pshs x,b
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
162 ldx #$0028
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
163 L00D5 lda b,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
164 bmi L00DF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
165 dec ,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
166 cmpa b,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
167 bne L00E3
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
168 L00DF decb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
169 bpl L00D5
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
170 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
171 L00E3 puls pc,x,b
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
172 L00E5 ldx <$0048
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
173 leax <$21,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
174 L00EA lda ,-x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175 beq L0119
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
176 ldb #$C3
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
177 tfr d,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
178 lda $06,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
179 beq L0119
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
180 bsr L00CE
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
181 bne L0119
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
182 pshs b
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
183 ldd $06,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
184 exg d,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
185 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186 exg d,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
187 pshs x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
188 ldx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
189 sty <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
190 os9 F$Send
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
191 stx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
192 puls x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
193 tst ,s+
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
194 bpl L0119
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
195 clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
196 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
197 std $06,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
198 L0119 cmpx <$0048
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
199 bhi L00EA
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
200 L011D jmp [D.Clock] continue w/multitasking
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
201
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
202 *--------------------------------- new!
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
203 * F$STime
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
204
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
205 FSTime ldx #D.Time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
206 bsr Copy6
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
207 ldd #06 do setime in clock2:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
208
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
209 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
210 * CALL CLOCK2: D=offset
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
211 L0125 ldx <D.Clock2 else update time vars
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
212 jmp d,x do it and rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
213
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
214 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
215 * F$Time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
216 * Note that time is already here
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
217 * from once/second clock polling!
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
218
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219 FTime ldx #D.Time point to time packet Moved ****
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
220 L012C ldy <D.Proc user process
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
221 lda <D.SysTsk from sys map
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
222 ldb P$Task,y to user map
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
223 ldu R$X,u destination=user(X)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
224 bra L015B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
225
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
226 Copy6 ldy <D.Proc calling process *** changed BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
227 lda P$Task,y from user map *** changed BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
228 ldb <D.SysTsk
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229 ldu R$X,u packet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
230 exg x,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
231 L015B ldy #6 number bytes
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
232 os9 F$Move get them
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
233 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
234
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
235
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
236
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
237 *--------------------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
238 * F$Alarm
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
239 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
240 * Note: The time packet is standard F$Time format, except seconds are always
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
241 * set to zero and $80 through $FF are wild cards that will match any
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
242 * time constant. Use of wild cards to replace one or more time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
243 * constants in a time packet results in a repetitive alarm. The BELL
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
244 * alarm sounds once per second up to and including the 15th second in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
245 * the alarm minute. Signal alarms are sent on the 16th second of the
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
246 * alarm minute to avoid misses when using a real-time Clock2, which may
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
247 * be out of sync with the internal VBORD (60 Hz) tick count.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
248 * EG1: X=>$5A0216000000 sets an alarm at midnight on Feb. 22, 1990.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
249 * EG2: X=>$5AFFFF0D0000 sets an alarm at 1:00 PM every day in 1990.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
250 * EG3: X=>$FFFFFFFFFF00 sets an alarm at every minute.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
251 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
252 * INPUT: A = alarm type or process ID
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
253 * B = action or signal code (depending on A)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
254 * X = pointer to caller's time packet (if alarm set or return)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
255 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
256 * OUTPUT: Alarm set, cleared, or returned, as follows:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
257 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
258 * - if A=0:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
259 * - if B=0, clear alarm
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
260 * - if B=1, set "BELL" alarm
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
261 * - D = alarm info
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
262 * - X = pointer to caller's 6 byte time packet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
263 * - if B=2, return alarm info
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
264 * - D = alarm info
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
265 * - X = pointer to caller's 6 byte time packet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
266 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
267 * - if A<>0:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
268 * - A = process ID to be signalled
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
269 * - B = signal code to be sent
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
270 * - X = pointer to caller's 6 byte time packet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
271 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
272 * ERROR OUTPUT: CC = Carry set
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
273 * B = error code
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
274
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
275 FAlarm ldx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
276 leax >$00C3,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
277 ldd $01,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
278 beq L0167
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
279 tsta
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
280 bne L017C
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
281 cmpb #$01
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
282 beq L0179
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
283 cmpb #$02
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
284 beq L0170
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
285 comb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
286 ldb #$BB
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
287 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
288 L0167 tst $06,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
289 bne L0188
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
290 ldx #$100F
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
291 bra L0188
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
292 L0170 ldx #$100F
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
293 ldd $06,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
294 std $01,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
295 bra L012C
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
296 L0179 ldx #$100F
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
297 L017C pshs x,b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
298 clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
299 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
300 std $06,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
301 bsr Copy6
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
302 puls x,b,a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
303 clr $05,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
304 L0188 std $06,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
305 clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
306 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
307
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
308 *--------------------------------- *** new ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
309 * get ticks per second:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
310
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
311 FTPS ldd #TkPerSec number of ticks per second
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
312 std R$D,u save it to caller's reg stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
313 clrb no error...
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
314 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
315
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
316 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
317 FVIRQ pshs cc save irq status
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
318 orcc #IntMasks stop irq/firqs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
319 ldy <D.CLTb point to virq table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
320 ldx <D.Init and Init module
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
321 ldb PollCnt,x get max devices
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
322 ldx R$X,u get X parameter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
323 beq L01C3 ..remove entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
324 tst ,y first entry empty?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
325 beq L01B9 ..yes
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
326 subb #$02 else point to last
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
327 lslb entry in table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
328 leay b,y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
329 tst ,y empty?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
330 bne L01D3 ..no, error
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
331 L01B3 tst ,--y found spot?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
332 beq L01B3 ..no, back up
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
333 leay $02,y yes, reset ptr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
334 L01B9 ldx R$Y,u get packet ptr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
335 stx ,y set entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
336 ldd R$D,u get first count *** changed BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
337 std ,x set it *** changed BRI ***
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
338 bra L01CF return okay.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
339 L01C3 ldx R$Y,u get entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
340 L01C5 tst ,y return if
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
341 beq L01CF no entries
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
342 cmpx ,y++ else search for
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
343 bne L01C5 this entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
344 bsr L01D9 then remove it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
345 L01CF puls cc restore intrpt status
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
346 clrb ok
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
347 rts .
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
348 L01D3 puls cc retrieve CC reg
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
349 comb set error bit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
350 ldb #E$Poll 'Polling Table Full'
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
351 rts .
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
352
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
353 *--------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
354 * delete virq entry:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
355
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
356 L01D9 pshs y,x save regs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
357 L01DB ldx ,y++ move entries
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
358 stx -$04,y up in table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
359 bne L01DB until last one (0000)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
360 puls y,x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
361 leay -$02,y reset table ptr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
362 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
363
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
364
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
365 *---------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
366 * Clock Init:
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
367
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
368 Init clrb necessary???
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
369 pshs cc save intpt status
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
370 ldd #(TkPerSec*256)+02
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
371 sta <D.Tick
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
372 stb <D.TSlice two ticks/time slice
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
373 stb <D.Slice and first slice
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
374 orcc #IntMasks stop interrupts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
375 leax >IRQChek,pcr set IRQ handler
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
376 stx <D.IRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
377 leax >VIRQChek,pcr set VIRQ handler
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
378 stx <D.VIRQ
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
379 leax >GPoll,pcr set GIME irq reset
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
380 stx <D.GPoll
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
381 * install system calls
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
382 leay >SvcTbl,pcr insert syscalls
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
383 os9 F$SSvc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
384 clra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
385 ldx #PIA0Base point to PIA0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
386 sta $01,x dir register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
387 sta ,x side A are inputs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
388 sta $03,x dir register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
389 coma
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
390 sta $02,x side B outputs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
391 ldd #$343C reset D
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
392 sta $01,x control reg
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
393 stb $03,x set up irq from VBORD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
394 lda $02,x dummy reset
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
395 lda #$08
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
396 ora <D.IRQER get GIME IRQ reg/enable VBord irqs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
397 sta <D.IRQER save shadow reg
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
398 sta >IRQEnR set VBorder irqs
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
399
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
400 ldx <D.Proc save user proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
401 pshs x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
402 ldx <D.SysPrc make sys for link
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
403 stx <D.Proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
404
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
405 leax <Clock2,pcr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
406 lda #Systm+Objct
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
407 os9 F$Link
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
408
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
409 * And here, we restore the original D.Proc value
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
410 puls x
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
411 stx <D.Proc restore user proc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
412
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
413 bcs err
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
414 sty <D.Clock2 save exec vector
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
415 jsr ,y do init of clock (ignore errs)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
416 puls pc,cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
417
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
418 err ldb #5 "no clock2" err
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
419 jmp D.Crash tell user the booterr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
420
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
421 Clock2 fcs "Clock2"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
422
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
423 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
424 len equ *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
425 end
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
426