annotate level1/modules/clock.asm @ 1945:89bba8b61def

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