annotate level2/modules/clock.asm @ 0:6641a883d6b0

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