annotate level1/modules/clock.asm @ 2657:90d13dbd887a

Fixed error in source
author Boisy Pitre <boisy.pitre@nuance.com>
date Sat, 19 May 2012 16:24:08 -0500
parents 2ebf5e737ceb
children 8399491c0821
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 *
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
4 * $Id$
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
5 *
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
6 * Edt/Rev YYYY/MM/DD Modified by
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
7 * Comment
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * ------------------------------------------------------------------
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
9 * ????/??/??
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
10 * NitrOS-9 2.00 distribution.
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
11 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
12 * 9r4 2003/01/01 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
13 * Back-ported to OS-9 Level Two.
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1213
diff changeset
14 *
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
15 * 9r5 2003/08/18 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
16 * Separated clock into Clock and Clock2 for modularity.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
17 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
18 * 9r6 2003/09/04 Boisy G. Pitre
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
19 * Combined Level One and Level Two sources
1735
11f38ece79ef More changes by Phill for Dragon
boisy
parents: 1731
diff changeset
20 *
1742
ea3988b5403c Incremented rev to indicate PHS's changes
boisy
parents: 1736
diff changeset
21 * 9r7 2004/11/27 Phill Harvey-Smith
1735
11f38ece79ef More changes by Phill for Dragon
boisy
parents: 1731
diff changeset
22 * 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
23 * 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
24 *
1744
80cdc57fbaae PIAs initialized with new value
boisy
parents: 1742
diff changeset
25 * 9r7 2005/01/17 Boisy G. Pitre
80cdc57fbaae PIAs initialized with new value
boisy
parents: 1742
diff changeset
26 * Fixed incorrect value for PIA initialization. Robert indicated
80cdc57fbaae PIAs initialized with new value
boisy
parents: 1742
diff changeset
27 * that it should be $3434, not $3435.
80cdc57fbaae PIAs initialized with new value
boisy
parents: 1742
diff changeset
28 *
1794
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
29 * 9r7 2005/04/08 Phill Harvey-Smith
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
30 * Made the above level dependent as having PIAs inited with $3434
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
31 * 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
32 * IRQ is later enabled from the GIME, however the CoCo 1,2 and Dragon
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
33 * do not posses a GIME so anything dependent on the clock tick will
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
34 * hang. So changed to conditionaly compile based on level :-
277b53362535 Additions by Phill
boisy
parents: 1744
diff changeset
35 *
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
36 * 9r8 2005/12/04 Boisy G. Pitre
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
37 * 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
38 * due to improper initialization of certain system globals.
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
39
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
40 nam Clock
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
41 ttl NitrOS-9 System Clock
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
42
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
43 ifp1
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
44 use defsfile
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
45 endc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
46
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
47 tylg set Systm+Objct
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
48 atrv set ReEnt+rev
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
49 rev set 8
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
50 edition set 9
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
51
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
52
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
53 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
54 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
55 * Start of module
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
56 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
57 mod len,name,tylg,atrv,init,0
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
58
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
59 name fcs "Clock"
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
60 fcb edition
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
61
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
62
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
63 TkPerTS equ TkPerSec/10 ticks per time slice
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
64
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
65 *
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
66 * Table to set up Service Calls
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
67 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
68 NewSvc fcb F$Time
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
69 fdb FTime-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
70 fcb F$VIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
71 fdb FVIRQ-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
72 fcb F$STime
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
73 fdb FSTime-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
74 fcb $80 end of service call installation table
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
75
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
76
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
77 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
78 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
79 * Handle F$STime system call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
80 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
81 * First, copy time packet from user address space to system time
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
82 * variables, then fall through to code to update RTC.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
83 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
84 FSTime equ *
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
85 ldx R$X,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
86 ldd ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
87 std <D.Year
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
88 ldd 2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
89 std <D.Day
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
90 ldd 4,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
91 std <D.Min
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
92 lda #TkPerSec reset to start of second
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
93 sta <D.Tick
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
94 ldx <D.Clock2 get entry point to Clock2
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
95 clra clear carry
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
96 jmp $06,x and call SetTime entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
97
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
98 *--------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
99 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
100 * Clock Initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
101 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
102 * 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
103 * call. F$STime is usually called by SysGo (with a dummy argument)
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
104 * in order to initialize the clock. F$STime is re-vectored to the
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
105 * service code above to handle future F$STime calls.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
106 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
107 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
108
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
109 Clock2 fcs "Clock2"
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
110
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
111 init
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
112 pshs dp,cc save DP and CC
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
113 clra
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
114 tfr a,dp set DP to zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
115 leax <Clock2,pcr
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
116 lda #Sbrtn+Objct
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
117 os9 F$Link
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
118 bcc LinkOk
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
119 jmp >$FFFE level 1: jump to reset vector
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
120
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
121 LinkOk
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
122 puls cc,dp ; Restore saved dp and cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
123 sty <D.Clock2 save entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
124 InitCont
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
125 * Do not need to explicitly read RTC during initialization
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
126 ldd #59*256+$01 last second and last tick
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
127 std <D.Sec will prompt RTC read at next time slice
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
128 ldb #TkPerSec
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
129 stb <D.TSec set ticks per second
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
130 ldb #TkPerTS get ticks per time slice
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
131 stb <D.TSlice set ticks per time slice
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
132 stb <D.Slice set first time slice
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
133 IFNE atari
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
134 * Atari gets its clock source from the NMI
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
135 leax SvcIRQ,pcr set NMI handler
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
136 stx <D.NMI
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
137 ELSE
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
138 leax SvcIRQ,pcr set IRQ handler
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
139 stx <D.IRQ
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
140 ENDC
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
141
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
142 leay NewSvc,pcr insert syscalls
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
143 os9 F$SSvc
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
144
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
145 * Call Clock2 init routine
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
146 ldy <D.Clock2 get entry point to Clock2
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
147 jsr ,y call init entry point of Clock2
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
148
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
149 * Initialize clock hardware
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
150 IFNE atari
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
151 * Atari - Tell ANTIC to assert NMI on Vertical Blank
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
152 lda #$40
2656
2ebf5e737ceb Updated to address Atari port problems
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2631
diff changeset
153 sta NMIEN enable VBlank NMI
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
154 rts
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
155 ELSE
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
156 ldx #PIA0Base point to PIA0
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
157 clra no error for return...
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
158 pshs cc save IRQ enable status (and Carry clear)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
159 orcc #IntMasks stop interrupts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
160
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
161 sta 1,x enable DDRA
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
162 sta ,x set port A all inputs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
163 sta 3,x enable DDRB
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
164 coma
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
165 sta 2,x set port B all outputs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
166
1735
11f38ece79ef More changes by Phill for Dragon
boisy
parents: 1731
diff changeset
167 ; ldd #$343C [A]=PIA0 CRA contents, [B]=PIA0 CRB contents
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
168
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
169 ldd #$3435 IRQ needs to be left enabled for Level1, as no GIME generated IRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
170
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
171 sta 1,x CA2 (MUX0) out low, port A, disable HBORD high-to-low IRQs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
172 stb 3,x CB2 (MUX1) out low, port B, disable VBORD low-to-high IRQs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
173
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
174 lda 2,x clear possible pending PIA0 VBORD IRQ
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
175 puls cc,pc recover IRQ enable status and return
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
176 ENDC
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
177
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
178 *
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
179 * Clock IRQ Entry Point
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
180 *
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
181 * For CoCo 1/2, called once every 16.667 milliseconds
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
182 SvcIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
183 clra
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
184 tfr a,dp set direct page to zero
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
185 IFNE atari
2656
2ebf5e737ceb Updated to address Atari port problems
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2631
diff changeset
186 sta NMIRES clear NMI interrupt
2657
90d13dbd887a Fixed error in source
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2656
diff changeset
187 ELSE
90d13dbd887a Fixed error in source
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2656
diff changeset
188 tst PIA0Base+3 get hw byte
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
189 bmi L0032 branch if sync flag on
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
190 jmp [>D.SvcIRQ] else service other possible IRQ
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
191 L0032 tst PIA0Base+2 clear interrupt
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
192 ENDC
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
193 dec <D.Tick decrement tick counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
194 bne L007F go around if not zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
195 ldb <D.Sec get minutes/seconds
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
196 * Seconds increment
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
197 incb increment seconds
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
198 cmpb #60 full minute?
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
199 bcs L0079 nope...
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
200 *
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
201 * Call GetTime entry point in Clock2
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
202 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
203 ldx <D.Clock2 get entry point to Clock2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
204 jsr $03,x call GetTime entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
205 fcb $8C skip next 2 bytes
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
206 L0079 stb <D.Sec update sec
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
207 L007B lda <D.TSec get ticks per second value
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
208 sta <D.Tick and repopulate tick decrement counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
209 L007F clra clear A
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
210 pshs a and save it on the stack
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
211 ldy <D.CLTb get pointer to VIRQ Polling Entries
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
212 bra L009E go to the processing portion of the loop
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
213 L0087 ldd Vi.Cnt,x get count down counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
214 subd #$0001 subtract tick count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
215 bne L009C branch if not at terminal count ($0000)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
216 lda #$01
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
217 sta ,s set flag on stack to 1
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
218 lda Vi.Stat,x get status byte
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
219 beq DelEntry branch if zero (one shot, so delete)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
220 L0096 ora #Vi.IFlag set interrupted flag
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
221 sta Vi.Stat,x save in packet
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
222 ldd Vi.Rst,x get reset count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
223 L009C std Vi.Cnt,x save tick count back
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
224 L009E ldx ,y++ get two bytes at Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
225 bne L0087 if not zero, branch
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
226 lda ,s+ else get byte off stack
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
227 beq GoAltIRQ branch if zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
228 ldx <D.Proc else get pointer to current process descriptor
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
229 beq L00AE branch if none
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
230 tst P$State,x test process state
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
231 bpl UsrPoll branch if system state not set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
232 L00AE jsr [>D.Poll] poll ISRs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
233 bcc L00AE keep polling until carry set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
234 GoAltIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
235 jmp [>D.AltIRQ] jump into an alternate IRQ if available
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
236 DelEntry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
237 bsr DelVIRQ delete the VIRQ entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
238 bra L0096
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
239
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
240 UsrPoll leay >up@,pcr point to routine to execute
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
241 jmp [>D.URtoSs] User to System
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
242 up@ jsr [>D.Poll] call polling routine
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
243 bcc up@ keep polling until carry set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
244 ldx <D.Proc get current process descriptor
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
245 ldb P$State,x and its state
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
246 andb #^SysState turn off sysstate bit
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
247 stb P$State,x save new state
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
248 ldd <P$SWI2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
249 std <D.SWI2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
250 ldd <D.UsrIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
251 std <D.SvcIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
252 bra GoAltIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
253
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
254 DelVIRQ pshs y,x save off Y,X
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
255 dl@ ldx ,y++ get next entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
256 stx -$04,y move up
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
257 bne dl@ continue until all are moved
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
258 puls y,x restore
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
259 leay -2,y move back 2 from Y (points to last entry)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
260 rts return
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
261
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
262 * Install or Remove VIRQ Entry
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
263 FVIRQ pshs cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
264 orcc #IntMasks mask all interrupts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
265 ldy <D.CLTb get pointer to VIRQ polling table
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
266 ldx <D.Init get pointer to init module
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
267 ldb PollCnt,x get poll count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
268 ldx R$X,u get pointer to caller's X
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
269 beq L0118 branch if removing
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
270 tst ,y entry available?
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
271 beq L010C
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
272 subb #$02
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
273 lslb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
274 leay b,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
275 tst ,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
276 bne PTblFul polling table full
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
277 L0106 tst ,--y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
278 beq L0106
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
279 leay $02,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
280 L010C ldx R$Y,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
281 stx ,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
282 ldy R$D,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
283 sty ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
284 bra L0124
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
285 L0118 leax R$Y,u X = caller's Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
286 L011A tst ,y end of VIRQ table
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
287 beq L0124 branch if so
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
288 cmpx ,y++ else compare to current VIRQ entry and inc Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
289 bne L011A continue searching if not matched
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
290 bsr DelVIRQ else delete entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
291 L0124 puls cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
292 clrb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
293 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
294 PTblFul puls cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
295 comb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
296 ldb #E$Poll
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
297 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
298
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
299
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
300
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
301 * F$Time system call code
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
302 FTime ldx R$X,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
303 ldd <D.Year
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
304 std ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
305 ldd <D.Day
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
306 std 2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
307 ldd <D.Min
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
308 std 4,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
309 clrb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
310 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
311
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
312 emod
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
313 len equ *
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
314 end