annotate level1/modules/clock.asm @ 2725:c2112f93923a lwtools-port

o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari o Added NMI code (as a conditional) to clock
author Boisy Pitre <boisy.pitre@nuance.com>
date Tue, 31 Jul 2012 11:54:02 -0500
parents 8399491c0821
children d9760f344c96
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
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
52 IFNE atari
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
53 USENMI EQU 0
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
54 ENDC
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
55
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
56 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
57 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
58 * Start of module
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
59 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
60 mod len,name,tylg,atrv,init,0
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
61
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
62 name fcs "Clock"
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
63 fcb edition
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
64
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
65
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
66 TkPerTS equ TkPerSec/10 ticks per time slice
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
67
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
68 *
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
69 * Table to set up Service Calls
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
70 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
71 NewSvc fcb F$Time
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
72 fdb FTime-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
73 fcb F$VIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
74 fdb FVIRQ-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
75 fcb F$STime
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
76 fdb FSTime-*-2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
77 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
78
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
79
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
80 *------------------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
81 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
82 * Handle F$STime system call
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
83 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
84 * First, copy time packet from user address space to system time
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
85 * variables, then fall through to code to update RTC.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
86 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
87 FSTime equ *
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
88 ldx R$X,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
89 ldd ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
90 std <D.Year
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
91 ldd 2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
92 std <D.Day
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
93 ldd 4,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
94 std <D.Min
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
95 lda #TkPerSec reset to start of second
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
96 sta <D.Tick
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
97 ldx <D.Clock2 get entry point to Clock2
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
98 clra clear carry
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
99 jmp $06,x and call SetTime entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
100
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
101 *--------------------------------------------------
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
102 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
103 * Clock Initialization
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
104 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
105 * 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
106 * call. F$STime is usually called by SysGo (with a dummy argument)
1313
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
107 * in order to initialize the clock. F$STime is re-vectored to the
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
108 * service code above to handle future F$STime calls.
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
109 *
7fdef42e19a0 New clock/clock2 combo
boisy
parents: 1287
diff changeset
110 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
111
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
112 Clock2 fcs "Clock2"
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
113
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
114 init
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
115 pshs dp,cc save DP and CC
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
116 clra
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
117 tfr a,dp set DP to zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
118 leax <Clock2,pcr
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
119 lda #Sbrtn+Objct
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
120 os9 F$Link
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
121 bcc LinkOk
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
122 jmp >$FFFE level 1: jump to reset vector
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
123
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
124 LinkOk
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
125 puls cc,dp ; Restore saved dp and cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
126 sty <D.Clock2 save entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
127 InitCont
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
128 * 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
129 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
130 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
131 ldb #TkPerSec
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
132 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
133 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
134 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
135 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
136 IFNE atari
2714
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
137 leax SvcIRQ,pcr set IRQ handler
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
138 IFNE USENMI
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
139 stx <D.NMI
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
140 ELSE
2714
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
141 stx <D.IRQ
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
142 ENDC
2631
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
143 ELSE
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
144 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
145 stx <D.IRQ
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
146 ENDC
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
147
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
148 leay NewSvc,pcr insert syscalls
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
149 os9 F$SSvc
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
150
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
151 * Call Clock2 init routine
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
152 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
153 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
154
442795681807 o Fixed Atari SIO DWRead to timeout longer
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2624
diff changeset
155 * Initialize clock hardware
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
156 IFNE atari
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
157 IFNE USENMI
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
158 lda #$40
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
159 sta NMIEN enable VBlank NMI
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
160 rts
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
161 ELSE
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
162 lda #IRQST.TIMER1
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
163 pshs cc
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
164 orcc #IntMasks
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
165 ora <D.IRQENShdw
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
166 sta <D.IRQENShdw
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
167 sta IRQEN
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
168 lda #%00101001
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
169 sta AUDCTL
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
170 clr AUDC1
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
171 lda #$FF
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
172 sta AUDF1
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
173 sta STIMER
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
174 puls cc,pc
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
175 ENDC
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
176 ELSE
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
177 ldx #PIA0Base point to PIA0
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
178 clra no error for return...
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
179 pshs cc save IRQ enable status (and Carry clear)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
180 orcc #IntMasks stop interrupts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
181
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
182 sta 1,x enable DDRA
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
183 sta ,x set port A all inputs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
184 sta 3,x enable DDRB
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
185 coma
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
186 sta 2,x set port B all outputs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
187
1735
11f38ece79ef More changes by Phill for Dragon
boisy
parents: 1731
diff changeset
188 ; ldd #$343C [A]=PIA0 CRA contents, [B]=PIA0 CRB contents
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
189
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
190 ldd #$3435 IRQ needs to be left enabled for Level1, as no GIME generated IRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
191
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
192 sta 1,x CA2 (MUX0) out low, port A, disable HBORD high-to-low IRQs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
193 stb 3,x CB2 (MUX1) out low, port B, disable VBORD low-to-high IRQs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
194
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
195 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
196 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
197 ENDC
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
198
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
199 *
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
200 * Clock IRQ Entry Point
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
201 *
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
202 * For CoCo 1/2, called once every 16.667 milliseconds
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
203 SvcIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
204 clra
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
205 tfr a,dp set direct page to zero
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
206 IFNE atari
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
207 IFNE USENMI
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
208 sta NMIRES clear NMI interrupt
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
209 ELSE
2714
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
210 lda IRQST get hw byte
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
211 bita #IRQST.TIMER1
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
212 beq L0032 branch if interrupt occurred
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
213 jmp [>D.SvcIRQ] else service other possible IRQ
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
214 L0032
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
215 lda #$FF
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
216 sta AUDF1
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
217 lda <D.IRQENShdw
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
218 tfr a,b A = clear interrupt, B = set interrupt
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
219 anda #^IRQST.TIMER1
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
220 orb #IRQST.TIMER1
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
221 sta IRQEN
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
222 stb IRQEN
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
223 stb <D.IRQENShdw
8399491c0821 Reworked sources so that serial polling for the atari works.
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2657
diff changeset
224 sta STIMER
2725
c2112f93923a o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2714
diff changeset
225 ENDC
2657
90d13dbd887a Fixed error in source
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2656
diff changeset
226 ELSE
90d13dbd887a Fixed error in source
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2656
diff changeset
227 tst PIA0Base+3 get hw byte
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
228 bmi L0032 branch if sync flag on
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
229 jmp [>D.SvcIRQ] else service other possible IRQ
1945
89bba8b61def Level 1 slow time update bug fixed
boisy
parents: 1927
diff changeset
230 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
231 ENDC
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
232 dec <D.Tick decrement tick counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
233 bne L007F go around if not zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
234 ldb <D.Sec get minutes/seconds
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
235 * Seconds increment
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
236 incb increment seconds
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
237 cmpb #60 full minute?
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
238 bcs L0079 nope...
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
239 *
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
240 * Call GetTime entry point in Clock2
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
241 *
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
242 ldx <D.Clock2 get entry point to Clock2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
243 jsr $03,x call GetTime entry point
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
244 fcb $8C skip next 2 bytes
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
245 L0079 stb <D.Sec update sec
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
246 L007B lda <D.TSec get ticks per second value
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
247 sta <D.Tick and repopulate tick decrement counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
248 L007F clra clear A
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
249 pshs a and save it on the stack
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
250 ldy <D.CLTb get pointer to VIRQ Polling Entries
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
251 bra L009E go to the processing portion of the loop
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
252 L0087 ldd Vi.Cnt,x get count down counter
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
253 subd #$0001 subtract tick count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
254 bne L009C branch if not at terminal count ($0000)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
255 lda #$01
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
256 sta ,s set flag on stack to 1
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
257 lda Vi.Stat,x get status byte
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
258 beq DelEntry branch if zero (one shot, so delete)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
259 L0096 ora #Vi.IFlag set interrupted flag
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
260 sta Vi.Stat,x save in packet
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
261 ldd Vi.Rst,x get reset count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
262 L009C std Vi.Cnt,x save tick count back
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
263 L009E ldx ,y++ get two bytes at Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
264 bne L0087 if not zero, branch
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
265 lda ,s+ else get byte off stack
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
266 beq GoAltIRQ branch if zero
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
267 ldx <D.Proc else get pointer to current process descriptor
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
268 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
269 tst P$State,x test process state
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
270 bpl UsrPoll branch if system state not set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
271 L00AE jsr [>D.Poll] poll ISRs
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
272 bcc L00AE keep polling until carry set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
273 GoAltIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
274 jmp [>D.AltIRQ] jump into an alternate IRQ if available
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
275 DelEntry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
276 bsr DelVIRQ delete the VIRQ entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
277 bra L0096
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
278
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
279 UsrPoll leay >up@,pcr point to routine to execute
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
280 jmp [>D.URtoSs] User to System
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
281 up@ jsr [>D.Poll] call polling routine
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
282 bcc up@ keep polling until carry set
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
283 ldx <D.Proc get current process descriptor
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
284 ldb P$State,x and its state
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
285 andb #^SysState turn off sysstate bit
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
286 stb P$State,x save new state
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
287 ldd <P$SWI2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
288 std <D.SWI2
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
289 ldd <D.UsrIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
290 std <D.SvcIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
291 bra GoAltIRQ
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
292
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
293 DelVIRQ pshs y,x save off Y,X
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
294 dl@ ldx ,y++ get next entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
295 stx -$04,y move up
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
296 bne dl@ continue until all are moved
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
297 puls y,x restore
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
298 leay -2,y move back 2 from Y (points to last entry)
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
299 rts return
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 * Install or Remove VIRQ Entry
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
302 FVIRQ pshs cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
303 orcc #IntMasks mask all interrupts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
304 ldy <D.CLTb get pointer to VIRQ polling table
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
305 ldx <D.Init get pointer to init module
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
306 ldb PollCnt,x get poll count
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
307 ldx R$X,u get pointer to caller's X
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
308 beq L0118 branch if removing
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
309 tst ,y entry available?
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
310 beq L010C
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
311 subb #$02
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
312 lslb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
313 leay b,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
314 tst ,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
315 bne PTblFul polling table full
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
316 L0106 tst ,--y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
317 beq L0106
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
318 leay $02,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
319 L010C ldx R$Y,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
320 stx ,y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
321 ldy R$D,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
322 sty ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
323 bra L0124
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
324 L0118 leax R$Y,u X = caller's Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
325 L011A tst ,y end of VIRQ table
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
326 beq L0124 branch if so
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
327 cmpx ,y++ else compare to current VIRQ entry and inc Y
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
328 bne L011A continue searching if not matched
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
329 bsr DelVIRQ else delete entry
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
330 L0124 puls cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
331 clrb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
332 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
333 PTblFul puls cc
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
334 comb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
335 ldb #E$Poll
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
336 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
337
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
338
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
339
1726
043d330e2f0e Recomposed source lines to share more common code between Level 1
boisy
parents: 1658
diff changeset
340 * F$Time system call code
1927
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
341 FTime ldx R$X,u
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
342 ldd <D.Year
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
343 std ,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
344 ldd <D.Day
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
345 std 2,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
346 ldd <D.Min
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
347 std 4,x
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
348 clrb
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
349 rts
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
350
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
351 emod
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
352 len equ *
8234be91628d Source reformatting
boisy
parents: 1794
diff changeset
353 end