1 |
21 |
robfinch |
3 error(s), 894 warning(s) unlisted in pass 1
|
2 |
4 |
robfinch |
; ============================================================================
|
3 |
|
|
; __
|
4 |
13 |
robfinch |
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
5 |
4 |
robfinch |
; \ __ / All rights reserved.
|
6 |
|
|
; \/_// robfinch@opencores.org
|
7 |
|
|
; ||
|
8 |
|
|
;
|
9 |
|
|
;
|
10 |
13 |
robfinch |
; BSD 3-Clause License
|
11 |
|
|
; Redistribution and use in source and binary forms, with or without
|
12 |
|
|
; modification, are permitted provided that the following conditions are met:
|
13 |
|
|
;
|
14 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
15 |
|
|
; list of conditions and the following disclaimer.
|
16 |
|
|
;
|
17 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
18 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
19 |
|
|
; and/or other materials provided with the distribution.
|
20 |
|
|
;
|
21 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
22 |
|
|
; contributors may be used to endorse or promote products derived from
|
23 |
|
|
; this software without specific prior written permission.
|
24 |
|
|
;
|
25 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
26 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
27 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
28 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
29 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
30 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
31 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
32 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
33 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
34 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
4 |
robfinch |
;
|
36 |
|
|
; ============================================================================
|
37 |
|
|
;
|
38 |
15 |
robfinch |
; ============================================================================
|
39 |
|
|
; __
|
40 |
|
|
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
41 |
|
|
; \ __ / All rights reserved.
|
42 |
|
|
; \/_// robfinch@opencores.org
|
43 |
|
|
; ||
|
44 |
|
|
;
|
45 |
|
|
;
|
46 |
|
|
; BSD 3-Clause License
|
47 |
|
|
; Redistribution and use in source and binary forms, with or without
|
48 |
|
|
; modification, are permitted provided that the following conditions are met:
|
49 |
|
|
;
|
50 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
51 |
|
|
; list of conditions and the following disclaimer.
|
52 |
|
|
;
|
53 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
54 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
55 |
|
|
; and/or other materials provided with the distribution.
|
56 |
|
|
;
|
57 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
58 |
|
|
; contributors may be used to endorse or promote products derived from
|
59 |
|
|
; this software without specific prior written permission.
|
60 |
|
|
;
|
61 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
62 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
63 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
64 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
65 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
66 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
67 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
68 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
69 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
70 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
71 |
|
|
;
|
72 |
|
|
; ============================================================================
|
73 |
|
|
;
|
74 |
21 |
robfinch |
; ASCII control characters.
|
75 |
|
|
SOH equ 1
|
76 |
|
|
EOT equ 4
|
77 |
|
|
ACK equ 6
|
78 |
|
|
BS equ 8
|
79 |
|
|
NAK equ 21
|
80 |
|
|
ETB equ $17
|
81 |
|
|
CAN equ 24
|
82 |
|
|
DEL equ 127
|
83 |
|
|
|
84 |
4 |
robfinch |
CR EQU $0D ;ASCII equates
|
85 |
|
|
LF EQU $0A
|
86 |
|
|
TAB EQU $09
|
87 |
|
|
CTRLC EQU $03
|
88 |
|
|
CTRLH EQU $08
|
89 |
|
|
CTRLI EQU $09
|
90 |
|
|
CTRLJ EQU $0A
|
91 |
|
|
CTRLK EQU $0B
|
92 |
|
|
CTRLM EQU $0D
|
93 |
|
|
CTRLS EQU $13
|
94 |
13 |
robfinch |
CTRLT EQU $14
|
95 |
4 |
robfinch |
CTRLX EQU $18
|
96 |
16 |
robfinch |
CTRLZ EQU $1A
|
97 |
4 |
robfinch |
XON EQU $11
|
98 |
|
|
XOFF EQU $13
|
99 |
|
|
|
100 |
|
|
FIRST_CORE EQU 1
|
101 |
|
|
MAX_TASKNO EQU 63
|
102 |
|
|
DRAM_BASE EQU $10000000
|
103 |
|
|
|
104 |
15 |
robfinch |
; ROM monitor functions
|
105 |
|
|
;
|
106 |
|
|
MF_Monitor EQU 0
|
107 |
|
|
MF_INCH EQU 1
|
108 |
|
|
MF_OUTCH EQU 2
|
109 |
|
|
MF_CRLF EQU 3
|
110 |
|
|
MF_DisplayString EQU 4
|
111 |
|
|
MF_DisplayByteAsHex EQU 5
|
112 |
|
|
MF_DisplayWordAsHex EQU 6
|
113 |
|
|
MF_ShowSprites EQU 7
|
114 |
|
|
MF_Srand EQU 8
|
115 |
|
|
MF_Random EQU 9
|
116 |
|
|
MF_OSCALL EQU 10
|
117 |
16 |
robfinch |
MF_GetRange EQU 11 ; gets a pair of numbers last>first
|
118 |
|
|
MF_GetNumber EQU 12
|
119 |
21 |
robfinch |
MF_SerialPutchar EQU 13
|
120 |
15 |
robfinch |
|
121 |
|
|
mon_numwka EQU $910
|
122 |
|
|
mon_r1 EQU $920
|
123 |
|
|
mon_r2 EQU $924
|
124 |
|
|
; ============================================================================
|
125 |
|
|
; __
|
126 |
|
|
; \\__/ o\ (C) S2022 Robert Finch, Waterloo
|
127 |
|
|
; \ __ / All rights reserved.
|
128 |
|
|
; \/_// robfinch@opencores.org
|
129 |
|
|
; ||
|
130 |
|
|
;
|
131 |
|
|
;
|
132 |
|
|
; BSD 3-Clause License
|
133 |
|
|
; Redistribution and use in source and binary forms, with or without
|
134 |
|
|
; modification, are permitted provided that the following conditions are met:
|
135 |
|
|
;
|
136 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
137 |
|
|
; list of conditions and the following disclaimer.
|
138 |
|
|
;
|
139 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
140 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
141 |
|
|
; and/or other materials provided with the distribution.
|
142 |
|
|
;
|
143 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
144 |
|
|
; contributors may be used to endorse or promote products derived from
|
145 |
|
|
; this software without specific prior written permission.
|
146 |
|
|
;
|
147 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
148 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
149 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
150 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
151 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
152 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
153 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
154 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
155 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
156 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
157 |
|
|
;
|
158 |
|
|
; ============================================================================
|
159 |
|
|
|
160 |
|
|
COREID EQU $FFFFFFFE0
|
161 |
|
|
MSCOUNT EQU $FFFFFFFE4
|
162 |
|
|
LEDS EQU $FFFE60001
|
163 |
|
|
VIA EQU $FFFE60000
|
164 |
|
|
VIA_PA EQU 1
|
165 |
|
|
VIA_DDRA EQU 3
|
166 |
|
|
VIA_ACR EQU 11
|
167 |
|
|
VIA_IFR EQU 13
|
168 |
|
|
VIA_IER EQU 14
|
169 |
|
|
VIA_T3LL EQU 18
|
170 |
|
|
VIA_T3LH EQU 19
|
171 |
|
|
VIA_T3CMPL EQU 20
|
172 |
|
|
VIA_T3CMPH EQU 21
|
173 |
|
|
TEXTSCR EQU $FFFE00000
|
174 |
|
|
TEXTREG EQU $FFFE07F00
|
175 |
|
|
TEXT_COLS EQU 0
|
176 |
|
|
TEXT_ROWS EQU 1
|
177 |
|
|
TEXT_CURPOS EQU 34
|
178 |
|
|
COLS EQU 64
|
179 |
|
|
ROWS EQU 32
|
180 |
|
|
ACIA EQU $FFFE30100
|
181 |
|
|
ACIA_TX EQU 0
|
182 |
|
|
ACIA_RX EQU 0
|
183 |
|
|
ACIA_STAT EQU 1
|
184 |
|
|
ACIA_CMD EQU 2
|
185 |
|
|
ACIA_CTRL EQU 3
|
186 |
21 |
robfinch |
ACIA_IRQS EQU 4
|
187 |
15 |
robfinch |
ACIA_CTRL2 EQU 11
|
188 |
|
|
RTC EQU $FFFE30500 ; I2C
|
189 |
|
|
RTCBuf EQU $7FC0
|
190 |
|
|
PRNG EQU $FFFE30600
|
191 |
|
|
KEYBD EQU $FFFE30400
|
192 |
|
|
KEYBDCLR EQU $FFFE30402
|
193 |
|
|
PIC EQU $FFFE3F000
|
194 |
|
|
SPRITE_CTRL EQU $FFFE10000
|
195 |
|
|
SPRITE_EN EQU $3C0
|
196 |
|
|
|
197 |
|
|
OUTSEMA EQU $EF0000
|
198 |
|
|
SEMAABS EQU $1000
|
199 |
|
|
OSSEMA EQU $EF0010
|
200 |
|
|
|
201 |
16 |
robfinch |
OPC_SWI EQU $03F
|
202 |
4 |
robfinch |
ScreenLocation EQU $10
|
203 |
|
|
ColorCodeLocation EQU $14
|
204 |
|
|
ScreenLocation2 EQU $18
|
205 |
|
|
BlkcpySrc EQU $1C
|
206 |
|
|
BlkcpyDst EQU $20
|
207 |
|
|
Strptr EQU $24
|
208 |
|
|
PICptr EQU $28
|
209 |
|
|
; Forth Area
|
210 |
|
|
; 0x30-0x60
|
211 |
|
|
|
212 |
|
|
; Task control blocks, room for 256 tasks
|
213 |
|
|
TCB_NxtRdy EQU $00 ; next task on ready / timeout list
|
214 |
|
|
TCB_PrvRdy EQU $04 ; previous task on ready / timeout list
|
215 |
|
|
TCB_NxtTCB EQU $08
|
216 |
|
|
TCB_Timeout EQU $0C
|
217 |
|
|
TCB_Priority EQU $10
|
218 |
|
|
TCB_MSGPTR_D1 EQU $14
|
219 |
|
|
TCB_MSGPTR_D2 EQU $18
|
220 |
|
|
TCB_hJCB EQU $1C
|
221 |
|
|
TCB_Status EQU $1E
|
222 |
|
|
TCB_CursorRow EQU $20
|
223 |
|
|
TCB_CursorCol EQU $21
|
224 |
|
|
TCB_hWaitMbx EQU $22 ; handle of mailbox task is waiting at
|
225 |
|
|
TCB_mbq_next EQU $24 ; mailbox queue next
|
226 |
|
|
TCB_mbq_prev EQU $28 ; mailbox queue previous
|
227 |
|
|
TCB_iof_next EQU $2C
|
228 |
|
|
TCB_iof_prev EQU $30
|
229 |
|
|
TCB_SPSave EQU $34 ; TCB_SPSave area
|
230 |
|
|
TCB_mmu_map EQU $38
|
231 |
|
|
|
232 |
|
|
KeybdHead EQU $FFFFFC800
|
233 |
|
|
KeybdTail EQU $FFFFFC900
|
234 |
|
|
KeybdEcho EQU $FFFFFCA00
|
235 |
|
|
KeybdBad EQU $FFFFFCB00
|
236 |
|
|
KeybdAck EQU $FFFFFCC00
|
237 |
|
|
KeybdLocks EQU $FFFFFCD00
|
238 |
|
|
KeybdBuffer EQU $FFFFFC000 ; buffer is 16 chars
|
239 |
|
|
|
240 |
|
|
BIOS_SCREENS EQU $17000000 ; $17000000 to $171FFFFF
|
241 |
|
|
|
242 |
|
|
; EhBASIC vars:
|
243 |
|
|
;
|
244 |
15 |
robfinch |
NmiBase EQU $FFC013
|
245 |
|
|
IrqBase EQU $FFC014
|
246 |
4 |
robfinch |
|
247 |
|
|
IOFocusNdx EQU $100
|
248 |
|
|
|
249 |
13 |
robfinch |
; These variables in global OS storage area
|
250 |
|
|
|
251 |
15 |
robfinch |
IOFocusList EQU $FFC000 ; to $FF000F
|
252 |
|
|
IOFocusID EQU $FFC010
|
253 |
|
|
IrqSource EQU $FFC011
|
254 |
|
|
IRQFlag EQU $FFC012
|
255 |
|
|
RunningID EQU $FFC013
|
256 |
21 |
robfinch |
milliseconds EQU $FFC014
|
257 |
|
|
|
258 |
|
|
; One copy of serial buffer management
|
259 |
|
|
; 1 serial buffer for system.
|
260 |
|
|
SerHeadRcv EQU $FFC015
|
261 |
|
|
SerTailRcv EQU $FFC016
|
262 |
|
|
SerHeadXmit EQU $FFC017
|
263 |
|
|
SerTailXmit EQU $FFC018
|
264 |
|
|
SerRcvXon EQU $FFC019
|
265 |
|
|
SerRcvXoff EQU $FFC01A
|
266 |
|
|
SerRcvBuf EQU $FFB000 ; 4kB serial recieve buffer
|
267 |
|
|
|
268 |
16 |
robfinch |
; Top of boot stack is at $FFC0FF
|
269 |
13 |
robfinch |
|
270 |
4 |
robfinch |
; These variables use direct page access
|
271 |
|
|
CursorRow EQU $110
|
272 |
|
|
CursorCol EQU $111
|
273 |
|
|
CharColor EQU $112
|
274 |
|
|
ScreenColor EQU $113
|
275 |
|
|
CursorFlash EQU $114
|
276 |
|
|
KeyState1 EQU $120
|
277 |
|
|
KeyState2 EQU $121
|
278 |
|
|
KeyLED EQU $122
|
279 |
|
|
KeybdID EQU $124
|
280 |
13 |
robfinch |
KeybdBlock EQU $126
|
281 |
|
|
kbdHeadRcv EQU $127
|
282 |
|
|
kbdTailRcv EQU $128
|
283 |
|
|
kbdFifo EQU $40 ; in local RAM
|
284 |
|
|
kbdFifoAlias EQU $C00040 ; to $C0007F ; alias for $40 to $7F
|
285 |
|
|
SerhZero EQU $130
|
286 |
|
|
SertZero EQU $132
|
287 |
4 |
robfinch |
|
288 |
21 |
robfinch |
|
289 |
14 |
robfinch |
farflag EQU $15F
|
290 |
13 |
robfinch |
asmbuf EQU $160 ; to $17F
|
291 |
|
|
|
292 |
4 |
robfinch |
QNdx0 EQU $780
|
293 |
|
|
QNdx1 EQU QNdx0+2
|
294 |
|
|
QNdx2 EQU QNdx1+2
|
295 |
|
|
QNdx3 EQU QNdx2+2
|
296 |
|
|
QNdx4 EQU QNdx3+2
|
297 |
|
|
FreeTCB EQU QNdx4+2
|
298 |
|
|
TimeoutList EQU FreeTCB+2
|
299 |
|
|
FreeMbx EQU RunningTCB + 2
|
300 |
|
|
nMailbox EQU FreeMbx + 2
|
301 |
|
|
FreeMsg EQU nMailbox + 2
|
302 |
|
|
nMsgBlk EQU FreeMsg + 2
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
CharOutVec EQU $800
|
306 |
|
|
CharInVec EQU $804
|
307 |
13 |
robfinch |
CmdPromptJI EQU $808
|
308 |
14 |
robfinch |
MonErrVec EQU $80C
|
309 |
15 |
robfinch |
BreakpointFlag EQU $810
|
310 |
21 |
robfinch |
NumSetBreakpoints EQU $811 ; to 812
|
311 |
15 |
robfinch |
Breakpoints EQU $820 ; to $82F
|
312 |
|
|
BreakpointBytes EQU $830 ; to $83F
|
313 |
|
|
mon_vectb EQU $880
|
314 |
4 |
robfinch |
|
315 |
|
|
; Register save area for monitor
|
316 |
|
|
mon_DSAVE EQU $900
|
317 |
|
|
mon_XSAVE EQU $902
|
318 |
|
|
mon_YSAVE EQU $904
|
319 |
|
|
mon_USAVE EQU $906
|
320 |
|
|
mon_SSAVE EQU $908
|
321 |
|
|
mon_PCSAVE EQU $90A
|
322 |
|
|
mon_DPRSAVE EQU $90E
|
323 |
|
|
mon_CCRSAVE EQU $90F
|
324 |
|
|
|
325 |
|
|
mon_numwka EQU $910
|
326 |
|
|
mon_r1 EQU $920
|
327 |
13 |
robfinch |
mon_r2 EQU $924
|
328 |
15 |
robfinch |
jmpvec EQU $928
|
329 |
16 |
robfinch |
mon_init EQU $92C
|
330 |
|
|
mon_retflag EQU $930
|
331 |
4 |
robfinch |
|
332 |
|
|
; The ORG directive must set an address a multiple of 4 in order for the Verilog
|
333 |
|
|
; output to work correctly.
|
334 |
|
|
|
335 |
|
|
org $FFD0AC
|
336 |
|
|
00FFD0AC 012 nop
|
337 |
|
|
00FFD0AD 012 nop
|
338 |
|
|
00FFD0AE 012 nop
|
339 |
|
|
XBLANK
|
340 |
|
|
00FFD0AF 0C6020 ldb #' '
|
341 |
21 |
robfinch |
00FFD0B1 017002115 lbsr OUTCH
|
342 |
4 |
robfinch |
00FFD0B4 039 rts
|
343 |
|
|
|
344 |
|
|
org $FFD0D0
|
345 |
|
|
00FFD0D0 012 nop
|
346 |
|
|
00FFD0D1 012 nop
|
347 |
|
|
CRLF
|
348 |
|
|
CRLF1:
|
349 |
|
|
00FFD0D2 0C600D ldb #CR
|
350 |
21 |
robfinch |
00FFD0D4 0170020F2 lbsr OUTCH
|
351 |
4 |
robfinch |
00FFD0D7 0C600A ldb #LF
|
352 |
21 |
robfinch |
00FFD0D9 0170020ED lbsr OUTCH
|
353 |
4 |
robfinch |
00FFD0DC 039 rts
|
354 |
|
|
|
355 |
|
|
org $FFD0F0
|
356 |
|
|
00FFD0F0 012 nop
|
357 |
|
|
00FFD0F1 020FDF bra CRLF1
|
358 |
|
|
|
359 |
|
|
org $FFD1DC
|
360 |
|
|
ONEKEY
|
361 |
|
|
00FFD1DC 06E90F000804 jmp [CharInVec]
|
362 |
|
|
|
363 |
|
|
org $FFD2C0
|
364 |
|
|
00FFD2C0 012 nop
|
365 |
|
|
LETTER
|
366 |
21 |
robfinch |
00FFD2C1 017001F05 lbsr OUTCH
|
367 |
4 |
robfinch |
00FFD2C4 039 rts
|
368 |
|
|
|
369 |
|
|
org $FFD2CC
|
370 |
|
|
00FFD2CC 012 nop
|
371 |
|
|
00FFD2CD 012 nop
|
372 |
|
|
HEX2
|
373 |
21 |
robfinch |
00FFD2CE 017001169 lbsr DispByteAsHex
|
374 |
4 |
robfinch |
00FFD2D1 039 rts
|
375 |
|
|
HEX4
|
376 |
21 |
robfinch |
00FFD2D2 01700115C lbsr DispWordAsHex
|
377 |
4 |
robfinch |
00FFD2D5 039 rts
|
378 |
|
|
|
379 |
|
|
org $FFD300
|
380 |
|
|
ClearScreenJmp
|
381 |
21 |
robfinch |
00FFD300 016000F39 lbra ClearScreen
|
382 |
4 |
robfinch |
org $FFD308
|
383 |
|
|
HomeCursorJmp
|
384 |
21 |
robfinch |
00FFD308 016000FA8 lbra HomeCursor
|
385 |
4 |
robfinch |
|
386 |
13 |
robfinch |
org $FFD400
|
387 |
4 |
robfinch |
|
388 |
|
|
; Local RAM test routine
|
389 |
|
|
; Checkerboard testing.
|
390 |
|
|
; There is 70kB of local RAM
|
391 |
|
|
; Does not use any RAM including no stack
|
392 |
|
|
|
393 |
|
|
ramtest:
|
394 |
13 |
robfinch |
00FFD400 18E000000 ldy #0
|
395 |
|
|
00FFD403 086001 lda #1
|
396 |
|
|
00FFD405 0150B7FFFE60001 sta LEDS
|
397 |
|
|
00FFD40A 0CCAAA555 ldd #$AAA555
|
398 |
4 |
robfinch |
ramtest1:
|
399 |
13 |
robfinch |
00FFD40D 0EDA01 std ,y++
|
400 |
|
|
00FFD40F 18C008000 cmpy #$8000
|
401 |
|
|
00FFD412 025FF9 blo ramtest1
|
402 |
4 |
robfinch |
; now readback values and compare
|
403 |
13 |
robfinch |
00FFD414 18E000000 ldy #0
|
404 |
4 |
robfinch |
ramtest3:
|
405 |
13 |
robfinch |
00FFD417 0ECA01 ldd ,y++
|
406 |
|
|
00FFD419 183AAA555 cmpd #$AAA555
|
407 |
|
|
00FFD41C 02600E bne ramerr
|
408 |
|
|
00FFD41E 18C008000 cmpy #$8000
|
409 |
|
|
00FFD421 025FF4 blo ramtest3
|
410 |
|
|
00FFD423 086002 lda #2
|
411 |
|
|
00FFD425 0150B7FFFE60001 sta LEDS
|
412 |
|
|
00FFD42A 06EC04 jmp ,u
|
413 |
4 |
robfinch |
ramerr:
|
414 |
13 |
robfinch |
00FFD42C 086080 lda #$80
|
415 |
|
|
00FFD42E 0150B7FFFE60001 sta LEDS
|
416 |
16 |
robfinch |
00FFD433 0150F6FFFFFFFE0 ldb COREID
|
417 |
|
|
00FFD438 0C1020 cmpb #$20
|
418 |
|
|
00FFD43A 027009 beq ramerr1
|
419 |
|
|
00FFD43C 08EE00000 ldx #TEXTSCR
|
420 |
|
|
00FFD43F 03A abx
|
421 |
|
|
00FFD440 086046 lda #'F'
|
422 |
|
|
00FFD442 0A7804 sta ,x
|
423 |
|
|
00FFD444 013 sync
|
424 |
|
|
ramerr1:
|
425 |
|
|
00FFD445 06EC04 jmp ,u
|
426 |
4 |
robfinch |
|
427 |
15 |
robfinch |
|
428 |
13 |
robfinch |
org $FFE000
|
429 |
21 |
robfinch |
00FFE000 FFF35C FDB Monitor
|
430 |
13 |
robfinch |
00FFE002 FFE022 FDB DumRts ; NEXTCMD
|
431 |
21 |
robfinch |
00FFE004 FFF191 FDB INCH
|
432 |
|
|
00FFE006 FFF1AF FDB INCHE
|
433 |
|
|
00FFE008 FFF1B3 FDB INCHEK
|
434 |
|
|
00FFE00A FFF1C9 FDB OUTCH
|
435 |
|
|
00FFE00C FFE41E FDB PDATA
|
436 |
|
|
00FFE00E FFE411 FDB PCRLF
|
437 |
|
|
00FFE010 FFE40D FDB PSTRNG
|
438 |
13 |
robfinch |
00FFE012 FFE022 FDB DumRts ; LRA
|
439 |
|
|
00FFE014 FFE022 FDB DumRts
|
440 |
|
|
00FFE016 FFE022 FDB DumRts
|
441 |
|
|
00FFE018 FFE022 FDB DumRts
|
442 |
|
|
00FFE01A FFE022 FDB DumRts ; VINIZ
|
443 |
21 |
robfinch |
00FFE01C FFE31C FDB DisplayChar ; VOUTCH
|
444 |
13 |
robfinch |
00FFE01E FFE022 FDB DumRts ; ACINIZ
|
445 |
|
|
00FFE020 FFE022 FDB DumRts ; AOUTCH
|
446 |
4 |
robfinch |
|
447 |
|
|
DumRts:
|
448 |
13 |
robfinch |
00FFE022 039 rts
|
449 |
4 |
robfinch |
|
450 |
|
|
;------------------------------------------------------------------------------
|
451 |
|
|
;------------------------------------------------------------------------------
|
452 |
|
|
|
453 |
|
|
start:
|
454 |
13 |
robfinch |
00FFE023 086FFF lda #$FFF ; all cores can do this
|
455 |
|
|
00FFE025 0150B7FFFE60003 sta VIA+VIA_DDRA
|
456 |
|
|
00FFE02A 086055 lda #$55 ; see if we can at least set LEDs
|
457 |
|
|
00FFE02C 0150B7FFFE60001 sta LEDS
|
458 |
|
|
00FFE031 086001 lda #1 ; prime OS semaphore
|
459 |
|
|
00FFE033 0B7EF1010 sta OSSEMA+$1000
|
460 |
15 |
robfinch |
00FFE036 0B7EF1000 sta OUTSEMA+$1000
|
461 |
16 |
robfinch |
00FFE039 0CEFFE03C ldu #st6 ; U = return address
|
462 |
|
|
; jmp ramtest ; JMP dont JSR
|
463 |
4 |
robfinch |
st6:
|
464 |
16 |
robfinch |
00FFE03C 1CE006FFF lds #$6FFF ; boot up stack area
|
465 |
|
|
00FFE03F 0150B6FFFFFFFE0 lda COREID
|
466 |
|
|
00FFE044 081001 cmpa #FIRST_CORE
|
467 |
4 |
robfinch |
; beq st8
|
468 |
|
|
; sync ; halt cores other than 2
|
469 |
|
|
st8:
|
470 |
|
|
; bne skip_init
|
471 |
|
|
; bsr romToRam
|
472 |
|
|
; ldd #st7 & $FFFF
|
473 |
|
|
; tfr d,x
|
474 |
|
|
; jmp ,x ; jump to the BIOS now in local RAM
|
475 |
|
|
st7:
|
476 |
21 |
robfinch |
00FFE046 08D170 bsr Delay3s ; give some time for devices to reset
|
477 |
16 |
robfinch |
00FFE048 07F000810 clr BreakpointFlag
|
478 |
|
|
00FFE04B 07F000811 clr NumSetBreakpoints
|
479 |
|
|
00FFE04E 0860AA lda #$AA
|
480 |
|
|
00FFE050 0150B7FFFE60001 sta LEDS
|
481 |
|
|
00FFE055 0150B6FFFFFFFE0 lda COREID
|
482 |
|
|
00FFE05A 081020 cmpa #$20
|
483 |
|
|
00FFE05C 027002 beq st11
|
484 |
|
|
00FFE05E 086001 lda #FIRST_CORE
|
485 |
|
|
st11:
|
486 |
|
|
00FFE060 0B7FFC010 sta IOFocusID ; core #2 has focus
|
487 |
|
|
00FFE063 0B7FFC013 sta RunningID
|
488 |
14 |
robfinch |
; Clear IO focus list
|
489 |
16 |
robfinch |
00FFE066 08E000000 ldx #0
|
490 |
14 |
robfinch |
st9:
|
491 |
16 |
robfinch |
00FFE069 06F80A000FFC000 clr IOFocusList,x
|
492 |
|
|
00FFE06E 030001 inx
|
493 |
|
|
00FFE070 08C000010 cmpx #16
|
494 |
|
|
00FFE073 025FF4 blo st9
|
495 |
|
|
00FFE075 086018 lda #24
|
496 |
|
|
00FFE077 0B7FFC001 sta IOFocusList+FIRST_CORE
|
497 |
14 |
robfinch |
|
498 |
16 |
robfinch |
00FFE07A 0860CE lda #$0CE
|
499 |
|
|
00FFE07C 097113 sta ScreenColor
|
500 |
|
|
00FFE07E 097112 sta CharColor
|
501 |
21 |
robfinch |
00FFE080 08D1BA bsr ClearScreen
|
502 |
|
|
00FFE082 0CCFFE31C ldd #DisplayChar
|
503 |
16 |
robfinch |
00FFE085 0FD000800 std CharOutVec
|
504 |
21 |
robfinch |
00FFE088 0CCFFEC73 ldd #SerialPeekCharDirect
|
505 |
16 |
robfinch |
00FFE08B 0FD000804 std CharInVec
|
506 |
15 |
robfinch |
; swi
|
507 |
|
|
; fcb MF_OSCALL
|
508 |
|
|
; fcb 24 ; request IO focus
|
509 |
16 |
robfinch |
00FFE08E 0150F6FFFFFFFE0 ldb COREID
|
510 |
|
|
00FFE093 0C1001 cmpb #FIRST_CORE
|
511 |
|
|
00FFE095 027011 beq init
|
512 |
|
|
00FFE097 0C1020 cmpb #$20 ; CmodA709 core?
|
513 |
21 |
robfinch |
00FFE099 027060 beq init2
|
514 |
|
|
00FFE09B 020070 bra skip_init
|
515 |
|
|
00FFE09D 0200B7 bra multi_sieve
|
516 |
4 |
robfinch |
st3:
|
517 |
16 |
robfinch |
00FFE09F 0860FF lda #$FF
|
518 |
|
|
00FFE0A1 0150B7FFFE60001 sta LEDS
|
519 |
|
|
00FFE0A6 020FF7 bra st3
|
520 |
4 |
robfinch |
|
521 |
|
|
; initialize interrupt controller
|
522 |
|
|
; first, zero out all the vectors
|
523 |
|
|
init:
|
524 |
21 |
robfinch |
00FFE0A8 017000479 lbsr rtc_read ; get clock values
|
525 |
16 |
robfinch |
00FFE0AB 08E000127 ldx #kbdHeadRcv
|
526 |
|
|
00FFE0AE 0C6020 ldb #32 ; number of bytes to zero out
|
527 |
13 |
robfinch |
init1:
|
528 |
16 |
robfinch |
00FFE0B0 06F800 clr ,x+
|
529 |
|
|
00FFE0B2 05A decb
|
530 |
|
|
00FFE0B3 026FFB bne init1
|
531 |
21 |
robfinch |
00FFE0B5 08E000080 ldx #128 ; register to start at
|
532 |
4 |
robfinch |
st1:
|
533 |
21 |
robfinch |
00FFE0B8 06F809E3F000 clr PIC,x ; cause code
|
534 |
|
|
00FFE0BC 0A7809E3F001 sta PIC+1,x
|
535 |
|
|
00FFE0C0 0E7809E3F002 stb PIC+2,x
|
536 |
|
|
00FFE0C4 030004 leax 4,x
|
537 |
|
|
00FFE0C6 08C000100 cmpx #256 ; max reg
|
538 |
|
|
00FFE0C9 025FED blo st1
|
539 |
|
|
00FFE0CB 0860C1 lda #$C1 ; make irq edge sensitive (bit 7), enable interupt (bit 6), irq (bit 0)
|
540 |
|
|
00FFE0CD 0150B7FFFE3F0FD sta PIC+$FD
|
541 |
|
|
00FFE0D2 086041 lda #$41 ; level sensitive, enabled, irq
|
542 |
|
|
00FFE0D4 0150B7FFFE3F0D1 sta PIC+$D1 ; serial irq is #20
|
543 |
|
|
00FFE0D9 086040 lda #COLS
|
544 |
|
|
00FFE0DB 0150B7FFFE07F00 sta TEXTREG+TEXT_COLS
|
545 |
|
|
00FFE0E0 086020 lda #ROWS
|
546 |
|
|
00FFE0E2 0150B7FFFE07F01 sta TEXTREG+TEXT_ROWS
|
547 |
|
|
00FFE0E7 08D153 bsr ClearScreen
|
548 |
|
|
00FFE0E9 08D1C8 bsr HomeCursor
|
549 |
|
|
00FFE0EB 08E000000 ldx #0
|
550 |
|
|
00FFE0EE 0CC000000 ldd #0
|
551 |
|
|
00FFE0F1 0170010DF lbsr ShowSprites
|
552 |
|
|
00FFE0F4 0170008C9 lbsr KeybdInit
|
553 |
|
|
00FFE0F7 0DC124 ldd KeybdID
|
554 |
|
|
00FFE0F9 08D336 bsr DispWordAsHex
|
555 |
16 |
robfinch |
init2:
|
556 |
21 |
robfinch |
00FFE0FB 01700036A lbsr TimerInit
|
557 |
|
|
00FFE0FE 017000AEE lbsr InitSerial
|
558 |
|
|
00FFE101 08E000080 ldx #128
|
559 |
|
|
00FFE104 086001 lda #1 ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
|
560 |
|
|
00FFE106 0C6001 ldb #FIRST_CORE ; serving core id
|
561 |
4 |
robfinch |
; lda #4 ; make the timer interrupt edge sensitive
|
562 |
|
|
; sta PIC+4 ; reg #4 is the edge sensitivity setting
|
563 |
|
|
; sta PIC ; reg #0 is interrupt enable
|
564 |
21 |
robfinch |
00FFE108 0C6001 ldb #1
|
565 |
|
|
00FFE10A 0F7EF1000 stb OUTSEMA+SEMAABS ; set semaphore to 1 available slot
|
566 |
4 |
robfinch |
skip_init:
|
567 |
21 |
robfinch |
00FFE10D 01C0EF andcc #$EF ; unmask irq
|
568 |
|
|
00FFE10F 086005 lda #5
|
569 |
|
|
00FFE111 0150B7FFFE60001 sta LEDS
|
570 |
|
|
00FFE116 0CCFFE11F ldd #msgStartup
|
571 |
|
|
00FFE119 08D2C2 bsr DisplayString
|
572 |
16 |
robfinch |
st10:
|
573 |
21 |
robfinch |
00FFE11B 03F swi
|
574 |
|
|
00FFE11C 000 fcb MF_Monitor
|
575 |
|
|
00FFE11D 020FFC bra st10
|
576 |
4 |
robfinch |
|
577 |
|
|
msgStartup
|
578 |
21 |
robfinch |
00FFE11F 072066036038030039020 fcb "rf6809 12-bit System Starting.",CR,LF,0
|
579 |
|
|
00FFE126 03103202D062069074020
|
580 |
|
|
00FFE12D 05307907307406506D020
|
581 |
|
|
00FFE134 05307406107207406906E
|
582 |
|
|
00FFE13B 06702E00D00A000
|
583 |
4 |
robfinch |
|
584 |
|
|
;------------------------------------------------------------------------------
|
585 |
|
|
; The checkpoint register must be cleared within 1 second or a NMI interrupt
|
586 |
|
|
; will occur. checkpoint should be called with a JSR so that the global ROM
|
587 |
|
|
; routine is called.
|
588 |
|
|
;
|
589 |
|
|
; Modifies:
|
590 |
|
|
; none
|
591 |
|
|
;------------------------------------------------------------------------------
|
592 |
|
|
|
593 |
|
|
checkpoint:
|
594 |
21 |
robfinch |
00FFE140 01507FFFFFFFFE1 clr $FFFFFFFE1 ; writing any value will do
|
595 |
|
|
00FFE145 039 rts
|
596 |
4 |
robfinch |
|
597 |
|
|
;------------------------------------------------------------------------------
|
598 |
|
|
; Copy the system ROM to local RAM
|
599 |
|
|
; Running the code from local RAM is probably an order of magnitude faster
|
600 |
|
|
; then running from the global ROM. It also reduces the network traffic to
|
601 |
|
|
; run from local RAM.
|
602 |
|
|
;
|
603 |
|
|
; Modifies:
|
604 |
|
|
; d,x,y
|
605 |
|
|
;------------------------------------------------------------------------------
|
606 |
|
|
|
607 |
|
|
romToRam:
|
608 |
21 |
robfinch |
00FFE146 08EFFC000 ldx #$FFC000
|
609 |
|
|
00FFE149 18E00C000 ldy #$00C000
|
610 |
4 |
robfinch |
romToRam1:
|
611 |
21 |
robfinch |
00FFE14C 0EC801 ldd ,x++
|
612 |
|
|
00FFE14E 0EDA01 std ,y++
|
613 |
|
|
00FFE150 08C000000 cmpx #0
|
614 |
|
|
00FFE153 026FF7 bne romToRam1
|
615 |
|
|
00FFE155 039 rts
|
616 |
4 |
robfinch |
|
617 |
|
|
;------------------------------------------------------------------------------
|
618 |
|
|
; Multi-core sieve program.
|
619 |
|
|
;------------------------------------------------------------------------------
|
620 |
|
|
|
621 |
|
|
; First fill screen chars with 'P' indicating prime positions
|
622 |
|
|
; Each core is responsible for the Nth position where N is the
|
623 |
|
|
; core number minus two.
|
624 |
|
|
;
|
625 |
|
|
multi_sieve:
|
626 |
21 |
robfinch |
00FFE156 086050 lda #'P' ; indicate prime
|
627 |
|
|
00FFE158 0150F6FFFFFFFE0 ldb COREID ; find out which core we are
|
628 |
|
|
00FFE15D 0C0001 subb #FIRST_CORE
|
629 |
|
|
00FFE15F 08E000000 ldx #0 ; start at first char of screen
|
630 |
|
|
00FFE162 03A abx
|
631 |
4 |
robfinch |
multi_sieve3:
|
632 |
21 |
robfinch |
00FFE163 0A7809E00000 sta TEXTSCR,x ; store 'P'
|
633 |
|
|
00FFE167 030008 leax 8,x ; advance to next position
|
634 |
|
|
00FFE169 08C000FFF cmpx #4095
|
635 |
|
|
00FFE16C 025FF5 blo multi_sieve3
|
636 |
|
|
00FFE16E 0BDFFE140 jsr checkpoint
|
637 |
4 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
638 |
21 |
robfinch |
00FFE171 0CB002 addb #2 ; start sieve at 2 (core id)
|
639 |
|
|
00FFE173 08604E lda #'N' ; flag position value of 'N' for non-prime
|
640 |
4 |
robfinch |
multi_sieve2:
|
641 |
21 |
robfinch |
00FFE175 08E000000 ldx #0
|
642 |
|
|
00FFE178 03A abx ; skip the first position - might be prime
|
643 |
4 |
robfinch |
multi_sieve1:
|
644 |
21 |
robfinch |
00FFE179 03A abx ; increment
|
645 |
|
|
00FFE17A 0A7809E00000 sta TEXTSCR,x
|
646 |
|
|
00FFE17E 08C000FFF cmpx #4095
|
647 |
|
|
00FFE181 025FF6 blo multi_sieve1
|
648 |
|
|
00FFE183 0BDFFE140 jsr checkpoint
|
649 |
4 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
650 |
21 |
robfinch |
00FFE186 0CB008 addb #8 ; number of cores working on it
|
651 |
|
|
00FFE188 0C1FF0 cmpb #4080
|
652 |
|
|
00FFE18A 025FE9 blo multi_sieve2
|
653 |
4 |
robfinch |
multi_sieve4: ; hang machine
|
654 |
21 |
robfinch |
00FFE18C 013 sync
|
655 |
|
|
00FFE18D 0160011CC lbra Monitor
|
656 |
4 |
robfinch |
|
657 |
13 |
robfinch |
;------------------------------------------------------------------------------
|
658 |
|
|
; Single core sieve.
|
659 |
|
|
;------------------------------------------------------------------------------
|
660 |
|
|
|
661 |
4 |
robfinch |
sieve:
|
662 |
21 |
robfinch |
00FFE190 086050 lda #'P' ; indicate prime
|
663 |
|
|
00FFE192 08E000000 ldx #0 ; start at first char of screen
|
664 |
4 |
robfinch |
sieve3:
|
665 |
21 |
robfinch |
00FFE195 0A7809E00000 sta TEXTSCR,x ; store 'P'
|
666 |
|
|
00FFE199 030001 inx ; advance to next position
|
667 |
|
|
00FFE19B 08C000FFF cmpx #4095
|
668 |
|
|
00FFE19E 025FF5 blo sieve3
|
669 |
|
|
00FFE1A0 0C6002 ldb #2 ; start sieve at 2
|
670 |
|
|
00FFE1A2 08604E lda #'N' ; flag position value of 'N' for non-prime
|
671 |
4 |
robfinch |
sieve2:
|
672 |
21 |
robfinch |
00FFE1A4 08E000000 ldx #0
|
673 |
|
|
00FFE1A7 03A abx ; skip the first position - might be prime
|
674 |
4 |
robfinch |
sieve1:
|
675 |
21 |
robfinch |
00FFE1A8 03A abx ; increment
|
676 |
|
|
00FFE1A9 0A7809E00000 sta TEXTSCR,x
|
677 |
|
|
00FFE1AD 08C000FFF cmpx #4095
|
678 |
|
|
00FFE1B0 025FC7 blo multi_sieve1
|
679 |
|
|
00FFE1B2 05C incb ; number of cores working on it
|
680 |
|
|
00FFE1B3 0C1FF0 cmpb #4080
|
681 |
|
|
00FFE1B5 025FED blo sieve2
|
682 |
4 |
robfinch |
sieve4: ; hang machine
|
683 |
21 |
robfinch |
00FFE1B7 039 rts
|
684 |
4 |
robfinch |
|
685 |
|
|
;------------------------------------------------------------------------------
|
686 |
|
|
; Three second delay for user convenience and to allow some devices time to
|
687 |
|
|
; reset.
|
688 |
|
|
;------------------------------------------------------------------------------
|
689 |
|
|
|
690 |
|
|
Delay3s:
|
691 |
21 |
robfinch |
00FFE1B8 0CC895440 ldd #9000000
|
692 |
4 |
robfinch |
dly3s1:
|
693 |
21 |
robfinch |
00FFE1BB 0C10FF cmpb #$FF
|
694 |
|
|
00FFE1BD 026000 bne dly3s2
|
695 |
4 |
robfinch |
dly3s2:
|
696 |
21 |
robfinch |
00FFE1BF 0150B7FFFE60001 sta LEDS
|
697 |
|
|
00FFE1C4 083000001 subd #1
|
698 |
|
|
00FFE1C7 026FF2 bne dly3s1
|
699 |
|
|
00FFE1C9 039 rts
|
700 |
4 |
robfinch |
|
701 |
|
|
;------------------------------------------------------------------------------
|
702 |
|
|
;------------------------------------------------------------------------------
|
703 |
|
|
ShiftLeft5:
|
704 |
21 |
robfinch |
00FFE1CA 058 aslb
|
705 |
|
|
00FFE1CB 049 rola
|
706 |
|
|
00FFE1CC 058 aslb
|
707 |
|
|
00FFE1CD 049 rola
|
708 |
|
|
00FFE1CE 058 aslb
|
709 |
|
|
00FFE1CF 049 rola
|
710 |
|
|
00FFE1D0 058 aslb
|
711 |
|
|
00FFE1D1 049 rola
|
712 |
|
|
00FFE1D2 058 aslb
|
713 |
|
|
00FFE1D3 049 rola
|
714 |
|
|
00FFE1D4 039 rts
|
715 |
4 |
robfinch |
|
716 |
|
|
;------------------------------------------------------------------------------
|
717 |
13 |
robfinch |
; Parameters:
|
718 |
|
|
; b = core id of core to copy
|
719 |
4 |
robfinch |
;------------------------------------------------------------------------------
|
720 |
|
|
;
|
721 |
|
|
CopyVirtualScreenToScreen:
|
722 |
21 |
robfinch |
00FFE1D5 034076 pshs d,x,y,u
|
723 |
13 |
robfinch |
; Compute virtual screen location for core passed in accb.
|
724 |
21 |
robfinch |
00FFE1D7 01F098 tfr b,a
|
725 |
16 |
robfinch |
00FFE1D9 048 asla
|
726 |
21 |
robfinch |
00FFE1DA 048 asla
|
727 |
|
|
00FFE1DB 048 asla
|
728 |
|
|
00FFE1DC 048 asla
|
729 |
|
|
00FFE1DD 08AC00 ora #$C00
|
730 |
|
|
00FFE1DF 05F clrb
|
731 |
|
|
00FFE1E0 01F001 tfr d,x
|
732 |
|
|
00FFE1E2 034006 pshs d
|
733 |
|
|
00FFE1E4 18EE00000 ldy #TEXTSCR
|
734 |
|
|
00FFE1E7 0CE000400 ldu #COLS*ROWS/2
|
735 |
4 |
robfinch |
cv2s1:
|
736 |
21 |
robfinch |
00FFE1EA 0EC801 ldd ,x++
|
737 |
|
|
00FFE1EC 0EDA01 std ,y++
|
738 |
|
|
00FFE1EE 0335FF leau -1,u
|
739 |
|
|
00FFE1F0 283000000 cmpu #0
|
740 |
|
|
00FFE1F3 026FF5 bne cv2s1
|
741 |
4 |
robfinch |
; reset the cursor position in the text controller
|
742 |
21 |
robfinch |
00FFE1F5 035010 puls x
|
743 |
|
|
00FFE1F7 0E6808110 ldb CursorRow,x
|
744 |
|
|
00FFE1FA 086040 lda #COLS
|
745 |
|
|
00FFE1FC 03D mul
|
746 |
|
|
00FFE1FD 01F002 tfr d,y
|
747 |
|
|
00FFE1FF 0E6808111 ldb CursorCol,x
|
748 |
|
|
00FFE202 01F021 tfr y,x
|
749 |
|
|
00FFE204 03A abx
|
750 |
|
|
00FFE205 0150BFFFFE07F22 stx TEXTREG+TEXT_CURPOS
|
751 |
|
|
00FFE20A 0350F6 puls d,x,y,u,pc
|
752 |
4 |
robfinch |
|
753 |
|
|
;------------------------------------------------------------------------------
|
754 |
|
|
;------------------------------------------------------------------------------
|
755 |
|
|
;
|
756 |
|
|
CopyScreenToVirtualScreen:
|
757 |
21 |
robfinch |
00FFE20C 034076 pshs d,x,y,u
|
758 |
|
|
00FFE20E 08D08D bsr GetScreenLocation
|
759 |
|
|
00FFE210 01F002 tfr d,y
|
760 |
|
|
00FFE212 08EE00000 ldx #TEXTSCR
|
761 |
|
|
00FFE215 0CE000400 ldu #COLS*ROWS/2
|
762 |
4 |
robfinch |
cs2v1:
|
763 |
21 |
robfinch |
00FFE218 0EC801 ldd ,x++
|
764 |
|
|
00FFE21A 0EDA01 std ,y++
|
765 |
|
|
00FFE21C 0335FF leau -1,u
|
766 |
|
|
00FFE21E 283000000 cmpu #0
|
767 |
|
|
00FFE221 026FF5 bne cs2v1
|
768 |
|
|
00FFE223 0350F6 puls d,x,y,u,pc
|
769 |
4 |
robfinch |
|
770 |
|
|
;------------------------------------------------------------------------------
|
771 |
|
|
;------------------------------------------------------------------------------
|
772 |
21 |
robfinch |
00FFE225 054045058054053043052 fcb "TEXTSCR "
|
773 |
|
|
00FFE22C 020
|
774 |
|
|
00FFE22D FFE237 fcw TextOpen
|
775 |
|
|
00FFE22F FFE238 fcw TextClose
|
776 |
|
|
00FFE231 FFE239 fcw TextRead
|
777 |
|
|
00FFE233 FFE23A fcw TextWrite
|
778 |
|
|
00FFE235 FFE23B fcw TextSeek
|
779 |
4 |
robfinch |
|
780 |
|
|
TextOpen:
|
781 |
21 |
robfinch |
00FFE237 039 rts
|
782 |
4 |
robfinch |
TextClose:
|
783 |
21 |
robfinch |
00FFE238 039 rts
|
784 |
4 |
robfinch |
TextRead:
|
785 |
21 |
robfinch |
00FFE239 039 rts
|
786 |
4 |
robfinch |
TextWrite:
|
787 |
21 |
robfinch |
00FFE23A 039 rts
|
788 |
4 |
robfinch |
TextSeek:
|
789 |
21 |
robfinch |
00FFE23B 039 rts
|
790 |
4 |
robfinch |
|
791 |
|
|
;------------------------------------------------------------------------------
|
792 |
|
|
; Clear the screen and the screen color memory
|
793 |
|
|
; We clear the screen to give a visual indication that the system
|
794 |
|
|
; is working at all.
|
795 |
|
|
;
|
796 |
|
|
; Modifies:
|
797 |
|
|
; none
|
798 |
|
|
;------------------------------------------------------------------------------
|
799 |
|
|
|
800 |
|
|
ClearScreen:
|
801 |
21 |
robfinch |
00FFE23C 034076 pshs d,x,y,u
|
802 |
|
|
00FFE23E 08E000800 ldx #COLS*ROWS
|
803 |
|
|
00FFE241 01F013 tfr x,u
|
804 |
|
|
00FFE243 08D058 bsr GetScreenLocation
|
805 |
|
|
00FFE245 01F002 tfr d,y
|
806 |
|
|
00FFE247 0C6020 ldb #' ' ; space char
|
807 |
4 |
robfinch |
cs1:
|
808 |
21 |
robfinch |
00FFE249 0E7A00 stb ,y+ ; set text to space
|
809 |
|
|
00FFE24B 0301FF leax -1,x ; decrement x
|
810 |
|
|
00FFE24D 026FFA bne cs1
|
811 |
|
|
00FFE24F 0150F6FFFFFFFE0 ldb COREID ; update colors only if we have focus
|
812 |
|
|
00FFE254 0F1FFC010 cmpb IOFocusID
|
813 |
|
|
00FFE257 02000D bra cs3
|
814 |
|
|
00FFE259 18EE02000 ldy #TEXTSCR+$2000
|
815 |
4 |
robfinch |
; lda CharColor
|
816 |
21 |
robfinch |
00FFE25C 0860CE lda #$0CE
|
817 |
|
|
00FFE25E 01F031 tfr u,x ; get back count
|
818 |
4 |
robfinch |
cs2:
|
819 |
21 |
robfinch |
00FFE260 0A7A00 sta ,y+
|
820 |
|
|
00FFE262 0301FF dex ; decrement x
|
821 |
|
|
00FFE264 026FFA bne cs2
|
822 |
4 |
robfinch |
cs3:
|
823 |
21 |
robfinch |
00FFE266 0350F6 puls d,x,y,u,pc
|
824 |
4 |
robfinch |
|
825 |
|
|
;------------------------------------------------------------------------------
|
826 |
|
|
; Scroll text on the screen upwards
|
827 |
|
|
;
|
828 |
|
|
; Modifies:
|
829 |
|
|
; none
|
830 |
|
|
;------------------------------------------------------------------------------
|
831 |
|
|
|
832 |
|
|
ScrollUp:
|
833 |
21 |
robfinch |
00FFE268 034076 pshs d,x,y,u
|
834 |
|
|
00FFE26A 18E0003FF ldy #(COLS*ROWS-1)/2 ; y = num chars/2 to move
|
835 |
|
|
00FFE26D 08D02E bsr GetScreenLocation
|
836 |
|
|
00FFE26F 01F001 tfr d,x
|
837 |
|
|
00FFE271 01F003 tfr d,u
|
838 |
|
|
00FFE273 030040 leax COLS,x ; x = index to source row
|
839 |
4 |
robfinch |
scrup1:
|
840 |
21 |
robfinch |
00FFE275 0EC801 ldd ,x++ ; move 2 characters
|
841 |
|
|
00FFE277 0EDC01 std ,u++
|
842 |
|
|
00FFE279 0313FF dey
|
843 |
|
|
00FFE27B 026FF8 bne scrup1
|
844 |
|
|
00FFE27D 08601F lda #ROWS-1
|
845 |
|
|
00FFE27F 08D002 bsr BlankLine
|
846 |
|
|
00FFE281 0350F6 puls d,x,y,u,pc
|
847 |
4 |
robfinch |
|
848 |
|
|
;------------------------------------------------------------------------------
|
849 |
|
|
; Blank out a line on the display
|
850 |
|
|
;
|
851 |
|
|
; Modifies:
|
852 |
|
|
; none
|
853 |
|
|
; Parameters:
|
854 |
|
|
; acca = line number to blank
|
855 |
|
|
;------------------------------------------------------------------------------
|
856 |
|
|
|
857 |
|
|
BlankLine:
|
858 |
21 |
robfinch |
00FFE283 034016 pshs d,x
|
859 |
|
|
00FFE285 034002 pshs a
|
860 |
|
|
00FFE287 08D014 bsr GetScreenLocation
|
861 |
|
|
00FFE289 01F001 tfr d,x
|
862 |
|
|
00FFE28B 035002 puls a
|
863 |
|
|
00FFE28D 0C6040 ldb #COLS ; b = # chars to blank out from video controller
|
864 |
|
|
00FFE28F 03D mul ; d = screen index (row# * #cols)
|
865 |
|
|
00FFE290 03080B leax d,x
|
866 |
|
|
00FFE292 086020 lda #' '
|
867 |
|
|
00FFE294 0C6040 ldb #COLS ; b = # chars to blank out from video controller
|
868 |
4 |
robfinch |
blnkln1:
|
869 |
21 |
robfinch |
00FFE296 0A7800 sta ,x+
|
870 |
|
|
00FFE298 05A decb
|
871 |
|
|
00FFE299 026FFB bne blnkln1
|
872 |
|
|
00FFE29B 035096 puls d,x,pc
|
873 |
4 |
robfinch |
|
874 |
|
|
;------------------------------------------------------------------------------
|
875 |
|
|
; Get the location of the screen memory. The location
|
876 |
|
|
; depends on whether or not the task has the output focus.
|
877 |
|
|
;
|
878 |
|
|
; Modifies:
|
879 |
|
|
; d
|
880 |
|
|
; Retuns:
|
881 |
|
|
; d = screen location
|
882 |
|
|
;------------------------------------------------------------------------------
|
883 |
|
|
|
884 |
|
|
GetScreenLocation:
|
885 |
21 |
robfinch |
00FFE29D 0150B6FFFFFFFE0 lda COREID ; which core are we?
|
886 |
|
|
00FFE2A2 0B1FFC010 cmpa IOFocusID ; do we have the IO focus
|
887 |
|
|
00FFE2A5 026008 bne gsl1 ; no, go pick virtual screen address
|
888 |
|
|
00FFE2A7 081020 cmpa #$20 ; CmodA709?
|
889 |
|
|
00FFE2A9 027004 beq gsl1
|
890 |
|
|
00FFE2AB 0CCE00000 ldd #TEXTSCR ; yes, we update the real screen
|
891 |
|
|
00FFE2AE 039 rts
|
892 |
4 |
robfinch |
gsl1:
|
893 |
21 |
robfinch |
00FFE2AF 0CC007800 ldd #$7800
|
894 |
|
|
00FFE2B2 039 rts
|
895 |
4 |
robfinch |
|
896 |
|
|
;------------------------------------------------------------------------------
|
897 |
|
|
; HomeCursor
|
898 |
|
|
; Set the cursor location to the top left of the screen.
|
899 |
|
|
;
|
900 |
|
|
; Modifies:
|
901 |
|
|
; none
|
902 |
|
|
;------------------------------------------------------------------------------
|
903 |
|
|
|
904 |
|
|
HomeCursor:
|
905 |
21 |
robfinch |
00FFE2B3 034016 pshs d,x
|
906 |
|
|
00FFE2B5 00F110 clr CursorRow
|
907 |
|
|
00FFE2B7 00F111 clr CursorCol
|
908 |
|
|
00FFE2B9 0150F6FFFFFFFE0 ldb COREID
|
909 |
|
|
00FFE2BE 0F1FFC010 cmpb IOFocusID
|
910 |
|
|
00FFE2C1 02600A bne hc1
|
911 |
|
|
00FFE2C3 0C1020 cmpb #$20
|
912 |
|
|
00FFE2C5 027006 beq hc1
|
913 |
|
|
00FFE2C7 04F clra
|
914 |
|
|
00FFE2C8 0150B7FFFE07F22 sta TEXTREG+TEXT_CURPOS
|
915 |
4 |
robfinch |
hc1:
|
916 |
21 |
robfinch |
00FFE2CD 035096 puls d,x,pc
|
917 |
4 |
robfinch |
|
918 |
|
|
;------------------------------------------------------------------------------
|
919 |
|
|
; Update the cursor position in the text controller based on the
|
920 |
|
|
; CursorRow,CursorCol.
|
921 |
|
|
;
|
922 |
|
|
; Modifies:
|
923 |
|
|
; none
|
924 |
|
|
;------------------------------------------------------------------------------
|
925 |
|
|
;
|
926 |
|
|
UpdateCursorPos:
|
927 |
21 |
robfinch |
00FFE2CF 034016 pshs d,x
|
928 |
|
|
00FFE2D1 0150F6FFFFFFFE0 ldb COREID ; update cursor position in text controller
|
929 |
|
|
00FFE2D6 0F1FFC010 cmpb IOFocusID ; only for the task with the output focus
|
930 |
|
|
00FFE2D9 026018 bne ucp1
|
931 |
|
|
00FFE2DB 0C1020 cmpb #$20 ; and not for CmodA709
|
932 |
|
|
00FFE2DD 027014 beq ucp1
|
933 |
|
|
00FFE2DF 096110 lda CursorRow
|
934 |
|
|
00FFE2E1 08403F anda #$3F ; limit of 63 rows
|
935 |
|
|
00FFE2E3 0150F6FFFE07F00 ldb TEXTREG+TEXT_COLS
|
936 |
|
|
00FFE2E8 03D mul
|
937 |
|
|
00FFE2E9 01F001 tfr d,x
|
938 |
|
|
00FFE2EB 0D6111 ldb CursorCol
|
939 |
|
|
00FFE2ED 03A abx
|
940 |
|
|
00FFE2EE 0150BFFFFE07F22 stx TEXTREG+TEXT_CURPOS
|
941 |
4 |
robfinch |
ucp1:
|
942 |
21 |
robfinch |
00FFE2F3 035096 puls d,x,pc
|
943 |
4 |
robfinch |
|
944 |
|
|
;------------------------------------------------------------------------------
|
945 |
|
|
; Calculate screen memory location from CursorRow,CursorCol.
|
946 |
|
|
; Also refreshes the cursor location.
|
947 |
|
|
;
|
948 |
|
|
; Modifies:
|
949 |
|
|
; d
|
950 |
|
|
; Returns:
|
951 |
|
|
; d = screen location
|
952 |
|
|
;------------------------------------------------------------------------------
|
953 |
|
|
;
|
954 |
|
|
CalcScreenLoc:
|
955 |
21 |
robfinch |
00FFE2F5 034010 pshs x
|
956 |
|
|
00FFE2F7 096110 lda CursorRow
|
957 |
|
|
00FFE2F9 0C6040 ldb #COLS
|
958 |
|
|
00FFE2FB 03D mul
|
959 |
|
|
00FFE2FC 01F001 tfr d,x
|
960 |
|
|
00FFE2FE 0D6111 ldb CursorCol
|
961 |
|
|
00FFE300 03A abx
|
962 |
|
|
00FFE301 0150F6FFFFFFFE0 ldb COREID ; update cursor position in text controller
|
963 |
|
|
00FFE306 0F1FFC010 cmpb IOFocusID ; only for the task with the output focus
|
964 |
|
|
00FFE309 026009 bne csl1
|
965 |
|
|
00FFE30B 0C1020 cmpb #$20
|
966 |
|
|
00FFE30D 027005 beq csl1
|
967 |
|
|
00FFE30F 0150BFFFFE07F22 stx TEXTREG+TEXT_CURPOS
|
968 |
4 |
robfinch |
csl1:
|
969 |
21 |
robfinch |
00FFE314 08DF87 bsr GetScreenLocation
|
970 |
|
|
00FFE316 03080B leax d,x
|
971 |
|
|
00FFE318 01F010 tfr x,d
|
972 |
|
|
00FFE31A 035090 puls x,pc
|
973 |
4 |
robfinch |
|
974 |
|
|
;------------------------------------------------------------------------------
|
975 |
|
|
; Display a character on the screen.
|
976 |
|
|
; If the task doesn't have the I/O focus then the character is written to
|
977 |
|
|
; the virtual screen.
|
978 |
|
|
;
|
979 |
|
|
; Modifies:
|
980 |
|
|
; none
|
981 |
|
|
; Parameters:
|
982 |
|
|
; accb = char to display
|
983 |
|
|
;------------------------------------------------------------------------------
|
984 |
|
|
;
|
985 |
|
|
DisplayChar:
|
986 |
21 |
robfinch |
00FFE31C 01700097B lbsr SerialPutChar
|
987 |
|
|
ScreenDisplayChar:
|
988 |
|
|
00FFE31F 034016 pshs d,x
|
989 |
|
|
00FFE321 0C100D cmpb #CR ; carriage return ?
|
990 |
|
|
00FFE323 026007 bne dccr
|
991 |
|
|
00FFE325 00F111 clr CursorCol ; just set cursor column to zero on a CR
|
992 |
|
|
00FFE327 08DFA6 bsr UpdateCursorPos
|
993 |
4 |
robfinch |
dcx14:
|
994 |
21 |
robfinch |
00FFE329 01600008C lbra dcx4
|
995 |
4 |
robfinch |
dccr:
|
996 |
21 |
robfinch |
00FFE32C 0C1091 cmpb #$91 ; cursor right ?
|
997 |
|
|
00FFE32E 02600D bne dcx6
|
998 |
|
|
00FFE330 096111 lda CursorCol
|
999 |
|
|
00FFE332 081040 cmpa #COLS
|
1000 |
|
|
00FFE334 024003 bhs dcx7
|
1001 |
|
|
00FFE336 04C inca
|
1002 |
|
|
00FFE337 097111 sta CursorCol
|
1003 |
4 |
robfinch |
dcx7:
|
1004 |
21 |
robfinch |
00FFE339 08DF94 bsr UpdateCursorPos
|
1005 |
|
|
00FFE33B 035096 puls d,x,pc
|
1006 |
4 |
robfinch |
dcx6:
|
1007 |
21 |
robfinch |
00FFE33D 0C1090 cmpb #$90 ; cursor up ?
|
1008 |
|
|
00FFE33F 026009 bne dcx8
|
1009 |
|
|
00FFE341 096110 lda CursorRow
|
1010 |
|
|
00FFE343 027FF4 beq dcx7
|
1011 |
|
|
00FFE345 04A deca
|
1012 |
|
|
00FFE346 097110 sta CursorRow
|
1013 |
|
|
00FFE348 020FEF bra dcx7
|
1014 |
4 |
robfinch |
dcx8:
|
1015 |
21 |
robfinch |
00FFE34A 0C1093 cmpb #$93 ; cursor left ?
|
1016 |
|
|
00FFE34C 026009 bne dcx9
|
1017 |
|
|
00FFE34E 096111 lda CursorCol
|
1018 |
|
|
00FFE350 027FE7 beq dcx7
|
1019 |
|
|
00FFE352 04A deca
|
1020 |
|
|
00FFE353 097111 sta CursorCol
|
1021 |
|
|
00FFE355 020FE2 bra dcx7
|
1022 |
4 |
robfinch |
dcx9:
|
1023 |
21 |
robfinch |
00FFE357 0C1092 cmpb #$92 ; cursor down ?
|
1024 |
|
|
00FFE359 02600B bne dcx10
|
1025 |
|
|
00FFE35B 096110 lda CursorRow
|
1026 |
|
|
00FFE35D 081020 cmpa #ROWS
|
1027 |
|
|
00FFE35F 027FD8 beq dcx7
|
1028 |
|
|
00FFE361 04C inca
|
1029 |
|
|
00FFE362 097110 sta CursorRow
|
1030 |
|
|
00FFE364 020FD3 bra dcx7
|
1031 |
4 |
robfinch |
dcx10:
|
1032 |
21 |
robfinch |
00FFE366 0C1094 cmpb #$94 ; cursor home ?
|
1033 |
|
|
00FFE368 02600C bne dcx11
|
1034 |
|
|
00FFE36A 096111 lda CursorCol
|
1035 |
|
|
00FFE36C 027004 beq dcx12
|
1036 |
|
|
00FFE36E 00F111 clr CursorCol
|
1037 |
|
|
00FFE370 020FC7 bra dcx7
|
1038 |
4 |
robfinch |
dcx12:
|
1039 |
21 |
robfinch |
00FFE372 00F110 clr CursorRow
|
1040 |
|
|
00FFE374 020FC3 bra dcx7
|
1041 |
4 |
robfinch |
dcx11:
|
1042 |
21 |
robfinch |
00FFE376 0C1099 cmpb #$99 ; delete ?
|
1043 |
|
|
00FFE378 026008 bne dcx13
|
1044 |
|
|
00FFE37A 08DF79 bsr CalcScreenLoc
|
1045 |
|
|
00FFE37C 01F001 tfr d,x
|
1046 |
|
|
00FFE37E 096111 lda CursorCol ; acc = cursor column
|
1047 |
|
|
00FFE380 020011 bra dcx5
|
1048 |
4 |
robfinch |
dcx13
|
1049 |
21 |
robfinch |
00FFE382 0C1008 cmpb #CTRLH ; backspace ?
|
1050 |
|
|
00FFE384 02601E bne dcx3
|
1051 |
|
|
00FFE386 096111 lda CursorCol
|
1052 |
|
|
00FFE388 02702E beq dcx4
|
1053 |
|
|
00FFE38A 04A deca
|
1054 |
|
|
00FFE38B 097111 sta CursorCol
|
1055 |
|
|
00FFE38D 08DF66 bsr CalcScreenLoc
|
1056 |
|
|
00FFE38F 01F001 tfr d,x
|
1057 |
|
|
00FFE391 096111 lda CursorCol
|
1058 |
4 |
robfinch |
dcx5:
|
1059 |
21 |
robfinch |
00FFE393 0E6001 ldb 1,x
|
1060 |
|
|
00FFE395 0E7801 stb ,x++
|
1061 |
|
|
00FFE397 04C inca
|
1062 |
|
|
00FFE398 081040 cmpa #COLS
|
1063 |
|
|
00FFE39A 025FF7 blo dcx5
|
1064 |
|
|
00FFE39C 0C6020 ldb #' '
|
1065 |
|
|
00FFE39E 0301FF dex
|
1066 |
|
|
00FFE3A0 0E7804 stb ,x
|
1067 |
|
|
00FFE3A2 020014 bra dcx4
|
1068 |
4 |
robfinch |
dcx3:
|
1069 |
21 |
robfinch |
00FFE3A4 0C100A cmpb #LF ; linefeed ?
|
1070 |
|
|
00FFE3A6 02700E beq dclf
|
1071 |
|
|
00FFE3A8 034004 pshs b
|
1072 |
|
|
00FFE3AA 08DF49 bsr CalcScreenLoc
|
1073 |
|
|
00FFE3AC 01F001 tfr d,x
|
1074 |
|
|
00FFE3AE 035004 puls b
|
1075 |
|
|
00FFE3B0 0E7804 stb ,x
|
1076 |
4 |
robfinch |
; ToDo character color
|
1077 |
|
|
; lda CharColor
|
1078 |
|
|
; sta $2000,x
|
1079 |
21 |
robfinch |
00FFE3B2 08D006 bsr IncCursorPos
|
1080 |
|
|
00FFE3B4 020002 bra dcx4
|
1081 |
4 |
robfinch |
dclf:
|
1082 |
21 |
robfinch |
00FFE3B6 08D011 bsr IncCursorRow
|
1083 |
4 |
robfinch |
dcx4:
|
1084 |
21 |
robfinch |
00FFE3B8 035096 puls d,x,pc
|
1085 |
4 |
robfinch |
|
1086 |
|
|
;------------------------------------------------------------------------------
|
1087 |
|
|
; Increment the cursor position, scroll the screen if needed.
|
1088 |
|
|
;
|
1089 |
|
|
; Modifies:
|
1090 |
|
|
; none
|
1091 |
|
|
;------------------------------------------------------------------------------
|
1092 |
|
|
|
1093 |
|
|
IncCursorPos:
|
1094 |
21 |
robfinch |
00FFE3BA 034016 pshs d,x
|
1095 |
|
|
00FFE3BC 096111 lda CursorCol
|
1096 |
|
|
00FFE3BE 04C inca
|
1097 |
|
|
00FFE3BF 097111 sta CursorCol
|
1098 |
|
|
00FFE3C1 081040 cmpa #COLS
|
1099 |
|
|
00FFE3C3 025014 blo icc1
|
1100 |
|
|
00FFE3C5 00F111 clr CursorCol ; column = 0
|
1101 |
|
|
00FFE3C7 020002 bra icr1
|
1102 |
4 |
robfinch |
IncCursorRow:
|
1103 |
21 |
robfinch |
00FFE3C9 034016 pshs d,x
|
1104 |
4 |
robfinch |
icr1:
|
1105 |
21 |
robfinch |
00FFE3CB 096110 lda CursorRow
|
1106 |
|
|
00FFE3CD 04C inca
|
1107 |
|
|
00FFE3CE 097110 sta CursorRow
|
1108 |
|
|
00FFE3D0 081020 cmpa #ROWS
|
1109 |
|
|
00FFE3D2 025005 blo icc1
|
1110 |
|
|
00FFE3D4 04A deca ; backup the cursor row, we are scrolling up
|
1111 |
|
|
00FFE3D5 097110 sta CursorRow
|
1112 |
|
|
00FFE3D7 08DE8F bsr ScrollUp
|
1113 |
4 |
robfinch |
icc1:
|
1114 |
21 |
robfinch |
00FFE3D9 08DEF4 bsr UpdateCursorPos
|
1115 |
4 |
robfinch |
icc2:
|
1116 |
21 |
robfinch |
00FFE3DB 035096 puls d,x,pc
|
1117 |
4 |
robfinch |
|
1118 |
|
|
;------------------------------------------------------------------------------
|
1119 |
|
|
; Display a string on the screen.
|
1120 |
|
|
;
|
1121 |
|
|
; Modifies:
|
1122 |
|
|
; none
|
1123 |
|
|
; Parameters:
|
1124 |
|
|
; d = pointer to string
|
1125 |
|
|
;------------------------------------------------------------------------------
|
1126 |
|
|
;
|
1127 |
|
|
DisplayString:
|
1128 |
21 |
robfinch |
00FFE3DD 034016 pshs d,x
|
1129 |
|
|
00FFE3DF 01F001 tfr d,x
|
1130 |
|
|
00FFE3E1 0150B6FFFFFFFE0 lda COREID
|
1131 |
|
|
00FFE3E6 081020 cmpa #$20
|
1132 |
|
|
00FFE3E8 027005 beq dspj1B
|
1133 |
13 |
robfinch |
dspj2: ; lock semaphore for access
|
1134 |
21 |
robfinch |
00FFE3EA 0B6EF0001 lda OUTSEMA+1
|
1135 |
|
|
00FFE3ED 027FFB beq dspj2
|
1136 |
4 |
robfinch |
dspj1B:
|
1137 |
21 |
robfinch |
00FFE3EF 0E6800 ldb ,x+ ; move string char into acc
|
1138 |
|
|
00FFE3F1 027005 beq dsretB ; is it end of string ?
|
1139 |
|
|
00FFE3F3 017000DD3 lbsr OUTCH ; display character
|
1140 |
|
|
00FFE3F6 020FF7 bra dspj1B
|
1141 |
4 |
robfinch |
dsretB:
|
1142 |
21 |
robfinch |
00FFE3F8 07FEF0001 clr OUTSEMA+1 ; unlock semaphore
|
1143 |
|
|
00FFE3FB 035096 puls d,x,pc
|
1144 |
4 |
robfinch |
|
1145 |
|
|
DisplayStringCRLF:
|
1146 |
21 |
robfinch |
00FFE3FD 034006 pshs d
|
1147 |
|
|
00FFE3FF 08DFDC bsr DisplayString
|
1148 |
|
|
00FFE401 0C600D ldb #CR
|
1149 |
|
|
00FFE403 017000DC3 lbsr OUTCH
|
1150 |
|
|
00FFE406 0C600A ldb #LF
|
1151 |
|
|
00FFE408 017000DBE lbsr OUTCH
|
1152 |
|
|
00FFE40B 035086 puls d,pc
|
1153 |
4 |
robfinch |
|
1154 |
|
|
;
|
1155 |
|
|
; PRINT CR, LF, STRING
|
1156 |
|
|
;
|
1157 |
|
|
PSTRNG
|
1158 |
21 |
robfinch |
00FFE40D 08D002 BSR PCRLF
|
1159 |
|
|
00FFE40F 02000D BRA PDATA
|
1160 |
4 |
robfinch |
PCRLF
|
1161 |
21 |
robfinch |
00FFE411 034010 PSHS X
|
1162 |
|
|
00FFE413 08EFFE425 LDX #CRLFST
|
1163 |
|
|
00FFE416 08D006 BSR PDATA
|
1164 |
|
|
00FFE418 035010 PULS X
|
1165 |
|
|
00FFE41A 039 RTS
|
1166 |
4 |
robfinch |
|
1167 |
|
|
PRINT
|
1168 |
21 |
robfinch |
00FFE41B 0BDFFF1C9 JSR OUTCH
|
1169 |
4 |
robfinch |
PDATA
|
1170 |
21 |
robfinch |
00FFE41E 0E6800 LDB ,X+
|
1171 |
|
|
00FFE420 0C1004 CMPB #$04
|
1172 |
|
|
00FFE422 026FF7 BNE PRINT
|
1173 |
|
|
00FFE424 039 RTS
|
1174 |
4 |
robfinch |
|
1175 |
|
|
CRLFST
|
1176 |
21 |
robfinch |
00FFE425 00D00A004 fcb CR,LF,4
|
1177 |
4 |
robfinch |
|
1178 |
|
|
DispDWordAsHex:
|
1179 |
21 |
robfinch |
00FFE428 08D007 bsr DispWordAsHex
|
1180 |
|
|
00FFE42A 01E001 exg d,x
|
1181 |
|
|
00FFE42C 08D003 bsr DispWordAsHex
|
1182 |
|
|
00FFE42E 01E001 exg d,x
|
1183 |
|
|
00FFE430 039 rts
|
1184 |
4 |
robfinch |
|
1185 |
|
|
DispWordAsHex:
|
1186 |
21 |
robfinch |
00FFE431 01E089 exg a,b
|
1187 |
|
|
00FFE433 08D005 bsr DispByteAsHex
|
1188 |
|
|
00FFE435 01E089 exg a,b
|
1189 |
|
|
00FFE437 08D001 bsr DispByteAsHex
|
1190 |
|
|
00FFE439 039 rts
|
1191 |
4 |
robfinch |
|
1192 |
|
|
DispByteAsHex:
|
1193 |
21 |
robfinch |
00FFE43A 034004 pshs b
|
1194 |
16 |
robfinch |
00FFE43C 054 lsrb
|
1195 |
|
|
00FFE43D 054 lsrb
|
1196 |
|
|
00FFE43E 054 lsrb
|
1197 |
|
|
00FFE43F 054 lsrb
|
1198 |
|
|
00FFE440 054 lsrb
|
1199 |
21 |
robfinch |
00FFE441 054 lsrb
|
1200 |
|
|
00FFE442 054 lsrb
|
1201 |
|
|
00FFE443 054 lsrb
|
1202 |
|
|
00FFE444 08D00C bsr DispNyb
|
1203 |
|
|
00FFE446 035004 puls b
|
1204 |
|
|
00FFE448 034004 pshs b
|
1205 |
16 |
robfinch |
00FFE44A 054 lsrb
|
1206 |
21 |
robfinch |
00FFE44B 054 lsrb
|
1207 |
|
|
00FFE44C 054 lsrb
|
1208 |
|
|
00FFE44D 054 lsrb
|
1209 |
|
|
00FFE44E 08D002 bsr DispNyb
|
1210 |
|
|
00FFE450 035004 puls b
|
1211 |
4 |
robfinch |
|
1212 |
|
|
DispNyb
|
1213 |
21 |
robfinch |
00FFE452 034004 pshs b
|
1214 |
|
|
00FFE454 0C400F andb #$0F
|
1215 |
|
|
00FFE456 0C100A cmpb #10
|
1216 |
|
|
00FFE458 025007 blo DispNyb1
|
1217 |
|
|
00FFE45A 0CB037 addb #'A'-10
|
1218 |
|
|
00FFE45C 017000D6A lbsr OUTCH
|
1219 |
|
|
00FFE45F 035084 puls b,pc
|
1220 |
4 |
robfinch |
DispNyb1
|
1221 |
21 |
robfinch |
00FFE461 0CB030 addb #'0'
|
1222 |
|
|
00FFE463 017000D63 lbsr OUTCH
|
1223 |
|
|
00FFE466 035084 puls b,pc
|
1224 |
4 |
robfinch |
|
1225 |
|
|
;==============================================================================
|
1226 |
13 |
robfinch |
; Timer
|
1227 |
|
|
;==============================================================================
|
1228 |
|
|
|
1229 |
|
|
; ============================================================================
|
1230 |
|
|
; __
|
1231 |
|
|
; \\__/ o\ (C) 2022 Robert Finch, Waterloo
|
1232 |
|
|
; \ __ / All rights reserved.
|
1233 |
|
|
; \/_// robfinch@opencores.org
|
1234 |
|
|
; ||
|
1235 |
|
|
;
|
1236 |
|
|
;
|
1237 |
|
|
; Timer routines for a WDC6522 compatible circuit.
|
1238 |
|
|
;
|
1239 |
|
|
; This source file is free software: you can redistribute it and/or modify
|
1240 |
|
|
; it under the terms of the GNU Lesser General Public License as published
|
1241 |
|
|
; by the Free Software Foundation, either version 3 of the License, or
|
1242 |
|
|
; (at your option) any later version.
|
1243 |
|
|
;
|
1244 |
|
|
; This source file is distributed in the hope that it will be useful,
|
1245 |
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1246 |
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
1247 |
|
|
; GNU General Public License for more details.
|
1248 |
|
|
;
|
1249 |
|
|
; You should have received a copy of the GNU General Public License
|
1250 |
|
|
; along with this program. If not, see .
|
1251 |
|
|
;
|
1252 |
|
|
; ============================================================================
|
1253 |
|
|
;
|
1254 |
|
|
TimerInit:
|
1255 |
21 |
robfinch |
00FFE468 0CC061A80 ldd #$61A80 ; compare to 400000 (100 Hz assuming 40MHz clock)
|
1256 |
|
|
00FFE46B 0150F7FFFE60014 stb VIA+VIA_T3CMPL
|
1257 |
|
|
00FFE470 0150B7FFFE60015 sta VIA+VIA_T3CMPH
|
1258 |
|
|
00FFE475 01507FFFFE60012 clr VIA+VIA_T3LL
|
1259 |
|
|
00FFE47A 01507FFFFE60013 clr VIA+VIA_T3LH
|
1260 |
|
|
00FFE47F 0150B6FFFE6000B lda VIA+VIA_ACR ; set continuous mode for timer
|
1261 |
|
|
00FFE484 08A100 ora #$100
|
1262 |
|
|
00FFE486 0150B7FFFE6000B sta VIA+VIA_ACR
|
1263 |
|
|
00FFE48B 086880 lda #$880 ; enable timer #3 interrupts
|
1264 |
|
|
00FFE48D 0150B7FFFE6000E sta VIA+VIA_IER
|
1265 |
|
|
00FFE492 039 rts
|
1266 |
13 |
robfinch |
|
1267 |
|
|
TimerIRQ:
|
1268 |
|
|
; Reset the edge sense circuit in the PIC
|
1269 |
21 |
robfinch |
00FFE493 08601F lda #31 ; Timer is IRQ #31
|
1270 |
16 |
robfinch |
00FFE495 0150B7FFFE3F010 sta PIC+16 ; register 16 is edge sense reset reg
|
1271 |
21 |
robfinch |
00FFE49A 0150B6FFFE3F0FF lda PIC+$FF ; Timer active interrupt flag
|
1272 |
|
|
00FFE49F 027041 beq notTimerIRQ
|
1273 |
|
|
00FFE4A1 01507FFFFE3F0FF clr PIC+$FF ; clear the flag
|
1274 |
|
|
00FFE4A6 08601F lda #31 ; Timer is IRQ #31
|
1275 |
|
|
00FFE4A8 0B7FFC011 sta IrqSource ; stuff a byte indicating the IRQ source for PEEK()
|
1276 |
|
|
00FFE4AB 01507FFFFE60012 clr VIA+VIA_T3LL ; should clear the interrupt
|
1277 |
|
|
00FFE4B0 01507FFFFE60013 clr VIA+VIA_T3LH
|
1278 |
|
|
00FFE4B5 08601F lda #31 ; Timer is IRQ #31
|
1279 |
|
|
00FFE4B7 0150B7FFFE3F010 sta PIC+16 ; register 16 is edge sense reset reg
|
1280 |
|
|
00FFE4BC 01507FFFFE3F0FF clr PIC+$FF ; clear the flag
|
1281 |
|
|
00FFE4C1 07CE0003F inc $E0003F ; update timer IRQ screen flag
|
1282 |
|
|
00FFE4C4 0FCFFC016 ldd milliseconds+2
|
1283 |
|
|
00FFE4C7 0C300000A addd #10
|
1284 |
|
|
00FFE4CA 0FDFFC016 std milliseconds+2
|
1285 |
|
|
00FFE4CD 0FCFFC014 ldd milliseconds
|
1286 |
|
|
00FFE4D0 0C9000 adcb #0
|
1287 |
|
|
00FFE4D2 0F7FFC015 stb milliseconds+1
|
1288 |
|
|
00FFE4D5 089000 adca #0
|
1289 |
|
|
00FFE4D7 0B7FFC014 sta milliseconds
|
1290 |
|
|
|
1291 |
|
|
; Update XModem timer, we just always do it rather than testing if XModem
|
1292 |
|
|
; is active. The increment is set to give approximately 3s before the MSB
|
1293 |
|
|
; gets set.
|
1294 |
|
|
00FFE4DA 0F6FFC020 ldb xm_timer
|
1295 |
|
|
00FFE4DD 0CB004 addb #4
|
1296 |
|
|
00FFE4DF 0F7FFC020 stb xm_timer
|
1297 |
13 |
robfinch |
notTimerIRQ:
|
1298 |
21 |
robfinch |
00FFE4E2 039 rts
|
1299 |
13 |
robfinch |
|
1300 |
|
|
; ============================================================================
|
1301 |
|
|
; __
|
1302 |
|
|
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
1303 |
|
|
; \ __ / All rights reserved.
|
1304 |
|
|
; \/_// robfinch@opencores.org
|
1305 |
|
|
; ||
|
1306 |
|
|
;
|
1307 |
|
|
;
|
1308 |
|
|
; BSD 3-Clause License
|
1309 |
|
|
; Redistribution and use in source and binary forms, with or without
|
1310 |
|
|
; modification, are permitted provided that the following conditions are met:
|
1311 |
|
|
;
|
1312 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
1313 |
|
|
; list of conditions and the following disclaimer.
|
1314 |
|
|
;
|
1315 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
1316 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
1317 |
|
|
; and/or other materials provided with the distribution.
|
1318 |
|
|
;
|
1319 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
1320 |
|
|
; contributors may be used to endorse or promote products derived from
|
1321 |
|
|
; this software without specific prior written permission.
|
1322 |
|
|
;
|
1323 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
1324 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
1325 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
1326 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
1327 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
1328 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
1329 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
1330 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
1331 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
1332 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1333 |
|
|
;
|
1334 |
|
|
; ============================================================================
|
1335 |
|
|
;
|
1336 |
|
|
;===============================================================================
|
1337 |
|
|
; Generic I2C routines
|
1338 |
|
|
;
|
1339 |
|
|
; It is assumed there may be more than one I2C controller in the system, so
|
1340 |
|
|
; the address of the controller is passed in the X register.
|
1341 |
|
|
;===============================================================================
|
1342 |
|
|
|
1343 |
|
|
I2C_PREL EQU $0
|
1344 |
|
|
I2C_PREH EQU $1
|
1345 |
|
|
I2C_CTRL EQU $2
|
1346 |
|
|
I2C_RXR EQU $3
|
1347 |
|
|
I2C_TXR EQU $3
|
1348 |
|
|
I2C_CMD EQU $4
|
1349 |
|
|
I2C_STAT EQU $4
|
1350 |
|
|
|
1351 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1352 |
|
|
; i2c initialization, sets the clock prescaler
|
1353 |
|
|
;
|
1354 |
|
|
; Parameters:
|
1355 |
|
|
; x = I2C controller address
|
1356 |
|
|
; Returns: none
|
1357 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1358 |
|
|
|
1359 |
15 |
robfinch |
i2c_init:
|
1360 |
21 |
robfinch |
00FFE4E3 034004 pshs b
|
1361 |
|
|
00FFE4E5 0C6004 ldb #4 ; setup prescale for 400kHz clock
|
1362 |
|
|
00FFE4E7 0E7804 stb I2C_PREL,x
|
1363 |
|
|
00FFE4E9 06F001 clr I2C_PREH,x
|
1364 |
|
|
00FFE4EB 035084 puls b,pc
|
1365 |
13 |
robfinch |
|
1366 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1367 |
|
|
; Wait for I2C transfer to complete
|
1368 |
|
|
;
|
1369 |
|
|
; Parameters
|
1370 |
|
|
; x - I2C controller base address
|
1371 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1372 |
|
|
|
1373 |
|
|
i2c_wait_tip:
|
1374 |
21 |
robfinch |
00FFE4ED 034004 pshs b
|
1375 |
13 |
robfinch |
i2cw1:
|
1376 |
21 |
robfinch |
00FFE4EF 0E6004 ldb I2C_STAT,x ; would use lvb, but lb is okay since its the I/O area
|
1377 |
|
|
00FFE4F1 0C5001 bitb #1 ; wait for tip to clear
|
1378 |
|
|
00FFE4F3 026FFA bne i2cw1
|
1379 |
|
|
00FFE4F5 035084 puls b,pc
|
1380 |
13 |
robfinch |
|
1381 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1382 |
|
|
; Write command to i2c
|
1383 |
|
|
;
|
1384 |
|
|
; Parameters
|
1385 |
|
|
; accb - data to transmit
|
1386 |
|
|
; acca - command value
|
1387 |
|
|
; x - I2C controller base address
|
1388 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1389 |
|
|
|
1390 |
|
|
i2c_wr_cmd:
|
1391 |
21 |
robfinch |
00FFE4F7 0E7003 stb I2C_TXR,x
|
1392 |
|
|
00FFE4F9 0A7004 sta I2C_CMD,x
|
1393 |
|
|
00FFE4FB 08DFF0 bsr i2c_wait_tip
|
1394 |
|
|
00FFE4FD 0E6004 ldb I2C_STAT,x
|
1395 |
|
|
00FFE4FF 039 rts
|
1396 |
13 |
robfinch |
|
1397 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1398 |
|
|
; Parameters
|
1399 |
|
|
; x - I2C controller base address
|
1400 |
|
|
; accb - data to send
|
1401 |
|
|
; Returns: none
|
1402 |
|
|
; Stack space: 2 words
|
1403 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1404 |
|
|
|
1405 |
15 |
robfinch |
i2c_xmit1:
|
1406 |
21 |
robfinch |
00FFE500 034006 pshs d ; save data value
|
1407 |
|
|
00FFE502 034006 pshs d ; and save it again
|
1408 |
|
|
00FFE504 0C6001 ldb #1
|
1409 |
|
|
00FFE506 0E7002 stb I2C_CTRL,x ; enable the core
|
1410 |
|
|
00FFE508 0C6076 ldb #$76 ; set slave address = %0111011
|
1411 |
|
|
00FFE50A 086090 lda #$90 ; set STA, WR
|
1412 |
|
|
00FFE50C 08DFE9 bsr i2c_wr_cmd
|
1413 |
|
|
00FFE50E 08D00A bsr i2c_wait_rx_nack
|
1414 |
|
|
00FFE510 035006 puls d ; get back data value
|
1415 |
|
|
00FFE512 086050 lda #$50 ; set STO, WR
|
1416 |
|
|
00FFE514 08DFE1 bsr i2c_wr_cmd
|
1417 |
|
|
00FFE516 08D002 bsr i2c_wait_rx_nack
|
1418 |
|
|
00FFE518 035086 puls d,pc
|
1419 |
13 |
robfinch |
|
1420 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1421 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1422 |
|
|
|
1423 |
|
|
i2c_wait_rx_nack:
|
1424 |
21 |
robfinch |
00FFE51A 034004 pshs b ; save off accb
|
1425 |
13 |
robfinch |
i2cwr1:
|
1426 |
21 |
robfinch |
00FFE51C 0E6004 ldb I2C_STAT,x ; wait for RXack = 0
|
1427 |
|
|
00FFE51E 0C5080 bitb #$80 ; test for nack
|
1428 |
|
|
00FFE520 026FFA bne i2cwr1
|
1429 |
|
|
00FFE522 035084 puls b,pc
|
1430 |
13 |
robfinch |
|
1431 |
|
|
; ============================================================================
|
1432 |
|
|
; __
|
1433 |
|
|
; \\__/ o\ (C) 2022 Robert Finch, Waterloo
|
1434 |
|
|
; \ __ / All rights reserved.
|
1435 |
|
|
; \/_// robfinch@opencores.org
|
1436 |
|
|
; ||
|
1437 |
|
|
;
|
1438 |
|
|
;
|
1439 |
|
|
; BSD 3-Clause License
|
1440 |
|
|
; Redistribution and use in source and binary forms, with or without
|
1441 |
|
|
; modification, are permitted provided that the following conditions are met:
|
1442 |
|
|
;
|
1443 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
1444 |
|
|
; list of conditions and the following disclaimer.
|
1445 |
|
|
;
|
1446 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
1447 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
1448 |
|
|
; and/or other materials provided with the distribution.
|
1449 |
|
|
;
|
1450 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
1451 |
|
|
; contributors may be used to endorse or promote products derived from
|
1452 |
|
|
; this software without specific prior written permission.
|
1453 |
|
|
;
|
1454 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
1455 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
1456 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
1457 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
1458 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
1459 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
1460 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
1461 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
1462 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
1463 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1464 |
|
|
;
|
1465 |
|
|
; ============================================================================
|
1466 |
|
|
|
1467 |
|
|
;===============================================================================
|
1468 |
|
|
; Realtime clock routines
|
1469 |
|
|
;===============================================================================
|
1470 |
|
|
|
1471 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1472 |
|
|
; Read the real-time-clock chip.
|
1473 |
|
|
;
|
1474 |
|
|
; The entire contents of the clock registers and sram are read into a buffer
|
1475 |
|
|
; in one-shot rather than reading the registers individually.
|
1476 |
|
|
;
|
1477 |
|
|
; Parameters: none
|
1478 |
|
|
; Returns: d = 0 on success, otherwise non-zero
|
1479 |
|
|
; Modifies: d and RTCBuf
|
1480 |
|
|
; Stack space: 6 words
|
1481 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1482 |
|
|
|
1483 |
|
|
rtc_read:
|
1484 |
21 |
robfinch |
00FFE524 08EE30500 ldx #RTC
|
1485 |
|
|
00FFE527 18E007FC0 ldy #RTCBuf
|
1486 |
|
|
00FFE52A 0C6080 ldb #$80
|
1487 |
|
|
00FFE52C 0E7002 stb I2C_CTRL,x ; enable I2C
|
1488 |
|
|
00FFE52E 0CC0900DE ldd #$900DE ; read address, write op, STA + wr bit
|
1489 |
|
|
00FFE531 08DFC4 bsr i2c_wr_cmd
|
1490 |
|
|
00FFE533 0C5080 bitb #$80
|
1491 |
|
|
00FFE535 02603C bne rtc_rxerr
|
1492 |
|
|
00FFE537 0CC010000 ldd #$10000 ; address zero, wr bit
|
1493 |
|
|
00FFE53A 08DFBB bsr i2c_wr_cmd
|
1494 |
|
|
00FFE53C 0C5080 bitb #$80
|
1495 |
|
|
00FFE53E 026033 bne rtc_rxerr
|
1496 |
|
|
00FFE540 0CC0900DF ldd #$900DF ; read address, read op, STA + wr bit
|
1497 |
|
|
00FFE543 08DFB2 bsr i2c_wr_cmd
|
1498 |
|
|
00FFE545 0C5080 bitb #$80
|
1499 |
|
|
00FFE547 02602A bne rtc_rxerr
|
1500 |
13 |
robfinch |
|
1501 |
21 |
robfinch |
00FFE549 05F clrb
|
1502 |
13 |
robfinch |
rtcr0001:
|
1503 |
21 |
robfinch |
00FFE54A 086020 lda #$20
|
1504 |
|
|
00FFE54C 0A7004 sta I2C_CMD,x ; rd bit
|
1505 |
|
|
00FFE54E 08DF9D bsr i2c_wait_tip
|
1506 |
|
|
00FFE550 08DFC8 bsr i2c_wait_rx_nack
|
1507 |
|
|
00FFE552 0A6004 lda I2C_STAT,x
|
1508 |
|
|
00FFE554 085080 bita #$80
|
1509 |
|
|
00FFE556 02601B bne rtc_rxerr
|
1510 |
|
|
00FFE558 0A6003 lda I2C_RXR,x
|
1511 |
|
|
00FFE55A 0A7A07 sta b,y
|
1512 |
|
|
00FFE55C 05C incb
|
1513 |
|
|
00FFE55D 0C105F cmpb #$5F
|
1514 |
|
|
00FFE55F 025FE9 blo rtcr0001
|
1515 |
|
|
00FFE561 086068 lda #$68
|
1516 |
|
|
00FFE563 0A7004 sta I2C_CMD,x ; STO, rd bit + nack
|
1517 |
|
|
00FFE565 08DF86 bsr i2c_wait_tip
|
1518 |
|
|
00FFE567 0A6004 lda I2C_STAT,x
|
1519 |
|
|
00FFE569 085080 bita #$80
|
1520 |
|
|
00FFE56B 026006 bne rtc_rxerr
|
1521 |
|
|
00FFE56D 0A6003 lda I2C_RXR,x
|
1522 |
|
|
00FFE56F 0A7A07 sta b,y
|
1523 |
|
|
00FFE571 04F05F clrd ; return 0
|
1524 |
13 |
robfinch |
rtc_rxerr:
|
1525 |
21 |
robfinch |
00FFE573 06F002 clr I2C_CTRL,x ; disable I2C and return status
|
1526 |
|
|
00FFE575 04F clra
|
1527 |
|
|
00FFE576 039 rts
|
1528 |
13 |
robfinch |
|
1529 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1530 |
|
|
; Write the real-time-clock chip.
|
1531 |
|
|
;
|
1532 |
|
|
; The entire contents of the clock registers and sram are written from a
|
1533 |
|
|
; buffer (RTCBuf) in one-shot rather than writing the registers individually.
|
1534 |
|
|
;
|
1535 |
|
|
; Parameters: none
|
1536 |
|
|
; Returns: r1 = 0 on success, otherwise non-zero
|
1537 |
|
|
; Modifies: r1 and RTCBuf
|
1538 |
|
|
; Stack space: 6 words
|
1539 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1540 |
|
|
|
1541 |
|
|
rtc_write:
|
1542 |
21 |
robfinch |
00FFE577 08EE30500 ldx #RTC
|
1543 |
|
|
00FFE57A 18E007FC0 ldy #RTCBuf
|
1544 |
13 |
robfinch |
|
1545 |
21 |
robfinch |
00FFE57D 0C6080 ldb #$80
|
1546 |
|
|
00FFE57F 0E7002 stb I2C_CTRL,x ; enable I2C
|
1547 |
|
|
00FFE581 0CC0900DE ldd #$900DE ; read address, write op, STA + wr bit
|
1548 |
|
|
00FFE584 08DF71 bsr i2c_wr_cmd
|
1549 |
|
|
00FFE586 0C5080 bitb #$80
|
1550 |
|
|
00FFE588 026FE9 bne rtc_rxerr
|
1551 |
|
|
00FFE58A 0CC010000 ldd #$10000 ; address zero, wr bit
|
1552 |
|
|
00FFE58D 08DF68 bsr i2c_wr_cmd
|
1553 |
|
|
00FFE58F 0C5080 bitb #$80
|
1554 |
|
|
00FFE591 026FE0 bne rtc_rxerr
|
1555 |
13 |
robfinch |
|
1556 |
21 |
robfinch |
00FFE593 0C6000 ldb #0
|
1557 |
13 |
robfinch |
rtcw0001:
|
1558 |
21 |
robfinch |
00FFE595 034004 pshs b
|
1559 |
|
|
00FFE597 0E6A05 ldb b,y
|
1560 |
|
|
00FFE599 086010 lda #$10
|
1561 |
|
|
00FFE59B 08DF5A bsr i2c_wr_cmd
|
1562 |
|
|
00FFE59D 0C5080 bitb #$80
|
1563 |
|
|
00FFE59F 035004 puls b
|
1564 |
|
|
00FFE5A1 026FD0 bne rtc_rxerr
|
1565 |
|
|
00FFE5A3 05C incb
|
1566 |
|
|
00FFE5A4 0C105F cmpb #$5F
|
1567 |
|
|
00FFE5A6 025FED blo rtcw0001
|
1568 |
|
|
00FFE5A8 0E6A05 ldb b,y
|
1569 |
|
|
00FFE5AA 086050 lda #$50 ; STO, wr bit
|
1570 |
|
|
00FFE5AC 08DF49 bsr i2c_wr_cmd
|
1571 |
|
|
00FFE5AE 0C5080 bitb #$80
|
1572 |
|
|
00FFE5B0 026FC1 bne rtc_rxerr
|
1573 |
|
|
00FFE5B2 04F05F clrd ; return 0
|
1574 |
|
|
00FFE5B4 06F002 clr I2C_CTRL,x ; disable I2C and return status
|
1575 |
|
|
00FFE5B6 039 rts
|
1576 |
13 |
robfinch |
|
1577 |
|
|
;==============================================================================
|
1578 |
4 |
robfinch |
; Keyboard I/O
|
1579 |
|
|
;==============================================================================
|
1580 |
|
|
|
1581 |
|
|
;--------------------------------------------------------------------------
|
1582 |
|
|
; PS2 scan codes to ascii conversion tables.
|
1583 |
|
|
;--------------------------------------------------------------------------
|
1584 |
|
|
;
|
1585 |
|
|
org (* + 127) & $FFFFFF80
|
1586 |
|
|
|
1587 |
|
|
unshiftedScanCodes:
|
1588 |
16 |
robfinch |
00FFE600 02E0A902E0A50A30A10A2 fcb $2e,$a9,$2e,$a5,$a3,$a1,$a2,$ac
|
1589 |
|
|
00FFE607 0AC
|
1590 |
|
|
00FFE608 02E0AA0A80A60A4009060 fcb $2e,$aa,$a8,$a6,$a4,$09,$60,$2e
|
1591 |
13 |
robfinch |
00FFE60F 02E
|
1592 |
16 |
robfinch |
00FFE610 02E02E02E02E02E071031 fcb $2e,$2e,$2e,$2e,$2e,$71,$31,$2e
|
1593 |
13 |
robfinch |
00FFE617 02E
|
1594 |
16 |
robfinch |
00FFE618 02E02E07A073061077032 fcb $2e,$2e,$7a,$73,$61,$77,$32,$2e
|
1595 |
13 |
robfinch |
00FFE61F 02E
|
1596 |
16 |
robfinch |
00FFE620 02E063078064065034033 fcb $2e,$63,$78,$64,$65,$34,$33,$2e
|
1597 |
13 |
robfinch |
00FFE627 02E
|
1598 |
16 |
robfinch |
00FFE628 02E020076066074072035 fcb $2e,$20,$76,$66,$74,$72,$35,$2e
|
1599 |
13 |
robfinch |
00FFE62F 02E
|
1600 |
16 |
robfinch |
00FFE630 02E06E062068067079036 fcb $2e,$6e,$62,$68,$67,$79,$36,$2e
|
1601 |
13 |
robfinch |
00FFE637 02E
|
1602 |
16 |
robfinch |
00FFE638 02E02E06D06A075037038 fcb $2e,$2e,$6d,$6a,$75,$37,$38,$2e
|
1603 |
13 |
robfinch |
00FFE63F 02E
|
1604 |
16 |
robfinch |
00FFE640 02E02C06B06906F030039 fcb $2e,$2c,$6b,$69,$6f,$30,$39,$2e
|
1605 |
13 |
robfinch |
00FFE647 02E
|
1606 |
16 |
robfinch |
00FFE648 02E02E02F06C03B07002D fcb $2e,$2e,$2f,$6c,$3b,$70,$2d,$2e
|
1607 |
13 |
robfinch |
00FFE64F 02E
|
1608 |
16 |
robfinch |
00FFE650 02E02E02702E05B03D02E fcb $2e,$2e,$27,$2e,$5b,$3d,$2e,$2e
|
1609 |
13 |
robfinch |
00FFE657 02E
|
1610 |
16 |
robfinch |
00FFE658 0AD02E00D05D02E05C02E fcb $ad,$2e,$0d,$5d,$2e,$5c,$2e,$2e
|
1611 |
13 |
robfinch |
00FFE65F 02E
|
1612 |
16 |
robfinch |
00FFE660 02E02E02E02E02E02E008 fcb $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
|
1613 |
13 |
robfinch |
00FFE667 02E
|
1614 |
16 |
robfinch |
00FFE668 02E09502E09309402E02E fcb $2e,$95,$2e,$93,$94,$2e,$2e,$2e
|
1615 |
13 |
robfinch |
00FFE66F 02E
|
1616 |
16 |
robfinch |
00FFE670 09807F09202E09109001B fcb $98,$7f,$92,$2e,$91,$90,$1b,$af
|
1617 |
|
|
00FFE677 0AF
|
1618 |
|
|
00FFE678 0AB02E09702E02E0960AE fcb $ab,$2e,$97,$2e,$2e,$96,$ae,$2e
|
1619 |
13 |
robfinch |
00FFE67F 02E
|
1620 |
4 |
robfinch |
|
1621 |
16 |
robfinch |
00FFE680 02E02E02E0A702E02E02E fcb $2e,$2e,$2e,$a7,$2e,$2e,$2e,$2e
|
1622 |
13 |
robfinch |
00FFE687 02E
|
1623 |
16 |
robfinch |
00FFE688 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1624 |
13 |
robfinch |
00FFE68F 02E
|
1625 |
16 |
robfinch |
00FFE690 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1626 |
13 |
robfinch |
00FFE697 02E
|
1627 |
16 |
robfinch |
00FFE698 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1628 |
13 |
robfinch |
00FFE69F 02E
|
1629 |
16 |
robfinch |
00FFE6A0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1630 |
13 |
robfinch |
00FFE6A7 02E
|
1631 |
16 |
robfinch |
00FFE6A8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1632 |
13 |
robfinch |
00FFE6AF 02E
|
1633 |
16 |
robfinch |
00FFE6B0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1634 |
13 |
robfinch |
00FFE6B7 02E
|
1635 |
16 |
robfinch |
00FFE6B8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1636 |
13 |
robfinch |
00FFE6BF 02E
|
1637 |
16 |
robfinch |
00FFE6C0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1638 |
13 |
robfinch |
00FFE6C7 02E
|
1639 |
16 |
robfinch |
00FFE6C8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1640 |
13 |
robfinch |
00FFE6CF 02E
|
1641 |
16 |
robfinch |
00FFE6D0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1642 |
13 |
robfinch |
00FFE6D7 02E
|
1643 |
16 |
robfinch |
00FFE6D8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1644 |
13 |
robfinch |
00FFE6DF 02E
|
1645 |
16 |
robfinch |
00FFE6E0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1646 |
13 |
robfinch |
00FFE6E7 02E
|
1647 |
|
|
00FFE6E8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1648 |
|
|
00FFE6EF 02E
|
1649 |
16 |
robfinch |
00FFE6F0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1650 |
13 |
robfinch |
00FFE6F7 02E
|
1651 |
16 |
robfinch |
00FFE6F8 02E02E0FA02E02E02E02E fcb $2e,$2e,$fa,$2e,$2e,$2e,$2e,$2e
|
1652 |
13 |
robfinch |
00FFE6FF 02E
|
1653 |
4 |
robfinch |
|
1654 |
16 |
robfinch |
shiftedScanCodes:
|
1655 |
13 |
robfinch |
00FFE700 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1656 |
|
|
00FFE707 02E
|
1657 |
16 |
robfinch |
00FFE708 02E02E02E02E02E00907E fcb $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
|
1658 |
13 |
robfinch |
00FFE70F 02E
|
1659 |
16 |
robfinch |
00FFE710 02E02E02E02E02E051021 fcb $2e,$2e,$2e,$2e,$2e,$51,$21,$2e
|
1660 |
13 |
robfinch |
00FFE717 02E
|
1661 |
16 |
robfinch |
00FFE718 02E02E05A053041057040 fcb $2e,$2e,$5a,$53,$41,$57,$40,$2e
|
1662 |
13 |
robfinch |
00FFE71F 02E
|
1663 |
16 |
robfinch |
00FFE720 02E043058044045024023 fcb $2e,$43,$58,$44,$45,$24,$23,$2e
|
1664 |
13 |
robfinch |
00FFE727 02E
|
1665 |
16 |
robfinch |
00FFE728 02E020056046054052025 fcb $2e,$20,$56,$46,$54,$52,$25,$2e
|
1666 |
13 |
robfinch |
00FFE72F 02E
|
1667 |
16 |
robfinch |
00FFE730 02E04E04204804705905E fcb $2e,$4e,$42,$48,$47,$59,$5e,$2e
|
1668 |
13 |
robfinch |
00FFE737 02E
|
1669 |
16 |
robfinch |
00FFE738 02E02E04D04A05502602A fcb $2e,$2e,$4d,$4a,$55,$26,$2a,$2e
|
1670 |
13 |
robfinch |
00FFE73F 02E
|
1671 |
16 |
robfinch |
00FFE740 02E03C04B04904F029028 fcb $2e,$3c,$4b,$49,$4f,$29,$28,$2e
|
1672 |
13 |
robfinch |
00FFE747 02E
|
1673 |
16 |
robfinch |
00FFE748 02E03E03F04C03A05005F fcb $2e,$3e,$3f,$4c,$3a,$50,$5f,$2e
|
1674 |
13 |
robfinch |
00FFE74F 02E
|
1675 |
16 |
robfinch |
00FFE750 02E02E02202E07B02B02E fcb $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
|
1676 |
13 |
robfinch |
00FFE757 02E
|
1677 |
16 |
robfinch |
00FFE758 02E02E00D07D02E07C02E fcb $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
|
1678 |
13 |
robfinch |
00FFE75F 02E
|
1679 |
16 |
robfinch |
00FFE760 02E02E02E02E02E02E008 fcb $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
|
1680 |
13 |
robfinch |
00FFE767 02E
|
1681 |
|
|
00FFE768 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1682 |
|
|
00FFE76F 02E
|
1683 |
16 |
robfinch |
00FFE770 02E07F02E02E02E02E01B fcb $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
|
1684 |
13 |
robfinch |
00FFE777 02E
|
1685 |
|
|
00FFE778 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1686 |
|
|
00FFE77F 02E
|
1687 |
4 |
robfinch |
|
1688 |
13 |
robfinch |
00FFE780 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1689 |
|
|
00FFE787 02E
|
1690 |
16 |
robfinch |
00FFE788 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1691 |
13 |
robfinch |
00FFE78F 02E
|
1692 |
16 |
robfinch |
00FFE790 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1693 |
13 |
robfinch |
00FFE797 02E
|
1694 |
16 |
robfinch |
00FFE798 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1695 |
13 |
robfinch |
00FFE79F 02E
|
1696 |
16 |
robfinch |
00FFE7A0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1697 |
13 |
robfinch |
00FFE7A7 02E
|
1698 |
16 |
robfinch |
00FFE7A8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1699 |
13 |
robfinch |
00FFE7AF 02E
|
1700 |
16 |
robfinch |
00FFE7B0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1701 |
13 |
robfinch |
00FFE7B7 02E
|
1702 |
16 |
robfinch |
00FFE7B8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1703 |
13 |
robfinch |
00FFE7BF 02E
|
1704 |
16 |
robfinch |
00FFE7C0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1705 |
13 |
robfinch |
00FFE7C7 02E
|
1706 |
16 |
robfinch |
00FFE7C8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1707 |
13 |
robfinch |
00FFE7CF 02E
|
1708 |
16 |
robfinch |
00FFE7D0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1709 |
13 |
robfinch |
00FFE7D7 02E
|
1710 |
16 |
robfinch |
00FFE7D8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1711 |
13 |
robfinch |
00FFE7DF 02E
|
1712 |
16 |
robfinch |
00FFE7E0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1713 |
13 |
robfinch |
00FFE7E7 02E
|
1714 |
|
|
00FFE7E8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1715 |
|
|
00FFE7EF 02E
|
1716 |
16 |
robfinch |
00FFE7F0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1717 |
13 |
robfinch |
00FFE7F7 02E
|
1718 |
|
|
00FFE7F8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1719 |
|
|
00FFE7FF 02E
|
1720 |
4 |
robfinch |
|
1721 |
16 |
robfinch |
; control
|
1722 |
|
|
keybdControlCodes:
|
1723 |
|
|
00FFE800 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1724 |
13 |
robfinch |
00FFE807 02E
|
1725 |
16 |
robfinch |
00FFE808 02E02E02E02E02E00907E fcb $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
|
1726 |
13 |
robfinch |
00FFE80F 02E
|
1727 |
16 |
robfinch |
00FFE810 02E02E02E02E02E011021 fcb $2e,$2e,$2e,$2e,$2e,$11,$21,$2e
|
1728 |
13 |
robfinch |
00FFE817 02E
|
1729 |
16 |
robfinch |
00FFE818 02E02E01A013001017040 fcb $2e,$2e,$1a,$13,$01,$17,$40,$2e
|
1730 |
13 |
robfinch |
00FFE81F 02E
|
1731 |
16 |
robfinch |
00FFE820 02E003018004005024023 fcb $2e,$03,$18,$04,$05,$24,$23,$2e
|
1732 |
13 |
robfinch |
00FFE827 02E
|
1733 |
16 |
robfinch |
00FFE828 02E020016006014012025 fcb $2e,$20,$16,$06,$14,$12,$25,$2e
|
1734 |
13 |
robfinch |
00FFE82F 02E
|
1735 |
16 |
robfinch |
00FFE830 02E00E00200800701905E fcb $2e,$0e,$02,$08,$07,$19,$5e,$2e
|
1736 |
13 |
robfinch |
00FFE837 02E
|
1737 |
16 |
robfinch |
00FFE838 02E02E00D00A01502602A fcb $2e,$2e,$0d,$0a,$15,$26,$2a,$2e
|
1738 |
13 |
robfinch |
00FFE83F 02E
|
1739 |
16 |
robfinch |
00FFE840 02E03C00B00900F029028 fcb $2e,$3c,$0b,$09,$0f,$29,$28,$2e
|
1740 |
13 |
robfinch |
00FFE847 02E
|
1741 |
16 |
robfinch |
00FFE848 02E03E03F00C03A01005F fcb $2e,$3e,$3f,$0c,$3a,$10,$5f,$2e
|
1742 |
13 |
robfinch |
00FFE84F 02E
|
1743 |
16 |
robfinch |
00FFE850 02E02E02202E07B02B02E fcb $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
|
1744 |
13 |
robfinch |
00FFE857 02E
|
1745 |
16 |
robfinch |
00FFE858 02E02E00D07D02E07C02E fcb $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
|
1746 |
13 |
robfinch |
00FFE85F 02E
|
1747 |
16 |
robfinch |
00FFE860 02E02E02E02E02E02E008 fcb $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
|
1748 |
13 |
robfinch |
00FFE867 02E
|
1749 |
16 |
robfinch |
00FFE868 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1750 |
13 |
robfinch |
00FFE86F 02E
|
1751 |
16 |
robfinch |
00FFE870 02E07F02E02E02E02E01B fcb $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
|
1752 |
13 |
robfinch |
00FFE877 02E
|
1753 |
16 |
robfinch |
00FFE878 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1754 |
13 |
robfinch |
00FFE87F 02E
|
1755 |
4 |
robfinch |
|
1756 |
16 |
robfinch |
keybdExtendedCodes:
|
1757 |
|
|
00FFE880 02E02E02E02E0A30A10A2 fcb $2e,$2e,$2e,$2e,$a3,$a1,$a2,$2e
|
1758 |
|
|
00FFE887 02E
|
1759 |
|
|
00FFE888 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1760 |
|
|
00FFE88F 02E
|
1761 |
|
|
00FFE890 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1762 |
|
|
00FFE897 02E
|
1763 |
|
|
00FFE898 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1764 |
|
|
00FFE89F 02E
|
1765 |
|
|
00FFE8A0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1766 |
|
|
00FFE8A7 02E
|
1767 |
|
|
00FFE8A8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1768 |
|
|
00FFE8AF 02E
|
1769 |
|
|
00FFE8B0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1770 |
|
|
00FFE8B7 02E
|
1771 |
|
|
00FFE8B8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1772 |
|
|
00FFE8BF 02E
|
1773 |
|
|
00FFE8C0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1774 |
|
|
00FFE8C7 02E
|
1775 |
|
|
00FFE8C8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1776 |
|
|
00FFE8CF 02E
|
1777 |
|
|
00FFE8D0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1778 |
|
|
00FFE8D7 02E
|
1779 |
|
|
00FFE8D8 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1780 |
|
|
00FFE8DF 02E
|
1781 |
|
|
00FFE8E0 02E02E02E02E02E02E02E fcb $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
|
1782 |
|
|
00FFE8E7 02E
|
1783 |
|
|
00FFE8E8 02E09502E09309402E02E fcb $2e,$95,$2e,$93,$94,$2e,$2e,$2e
|
1784 |
|
|
00FFE8EF 02E
|
1785 |
|
|
00FFE8F0 09809909202E09109002E fcb $98,$99,$92,$2e,$91,$90,$2e,$2e
|
1786 |
|
|
00FFE8F7 02E
|
1787 |
|
|
00FFE8F8 02E02E09702E02E09602E fcb $2e,$2e,$97,$2e,$2e,$96,$2e,$2e
|
1788 |
|
|
00FFE8FF 02E
|
1789 |
|
|
|
1790 |
4 |
robfinch |
; ============================================================================
|
1791 |
|
|
; __
|
1792 |
|
|
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
1793 |
|
|
; \ __ / All rights reserved.
|
1794 |
|
|
; \/_// robfinch@opencores.org
|
1795 |
|
|
; ||
|
1796 |
|
|
;
|
1797 |
|
|
;
|
1798 |
|
|
; Keyboard driver routines to interface to a PS2 style keyboard
|
1799 |
|
|
; Converts the scancode to ascii
|
1800 |
|
|
;
|
1801 |
|
|
; This source file is free software: you can redistribute it and/or modify
|
1802 |
|
|
; it under the terms of the GNU Lesser General Public License as published
|
1803 |
|
|
; by the Free Software Foundation, either version 3 of the License, or
|
1804 |
|
|
; (at your option) any later version.
|
1805 |
|
|
;
|
1806 |
|
|
; This source file is distributed in the hope that it will be useful,
|
1807 |
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1808 |
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
1809 |
|
|
; GNU General Public License for more details.
|
1810 |
|
|
;
|
1811 |
|
|
; You should have received a copy of the GNU General Public License
|
1812 |
|
|
; along with this program. If not, see .
|
1813 |
|
|
;
|
1814 |
|
|
; ============================================================================
|
1815 |
|
|
;
|
1816 |
|
|
SC_F12 EQU $07
|
1817 |
|
|
SC_C EQU $21
|
1818 |
|
|
SC_T EQU $2C
|
1819 |
|
|
SC_Z EQU $1A
|
1820 |
|
|
SC_DEL EQU $71 ; extend
|
1821 |
|
|
SC_KEYUP EQU $F0 ; should be $f0
|
1822 |
|
|
SC_EXTEND EQU $E0
|
1823 |
|
|
SC_CTRL EQU $14
|
1824 |
|
|
SC_RSHIFT EQU $59
|
1825 |
|
|
SC_NUMLOCK EQU $77
|
1826 |
|
|
SC_SCROLLLOCK EQU $7E
|
1827 |
|
|
SC_CAPSLOCK EQU $58
|
1828 |
|
|
SC_ALT EQU $11
|
1829 |
|
|
|
1830 |
|
|
;#define SC_LSHIFT EQU $12
|
1831 |
|
|
;SC_DEL EQU $71 ; extend
|
1832 |
|
|
;SC_LCTRL EQU $58
|
1833 |
|
|
|
1834 |
|
|
SC_TAB EQU $0D
|
1835 |
|
|
|
1836 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1837 |
|
|
; Recieve a byte from the keyboard, used after a command is sent to the
|
1838 |
|
|
; keyboard in order to wait for a response.
|
1839 |
|
|
;
|
1840 |
|
|
; Parameters: none
|
1841 |
|
|
; Returns: accd = recieved byte ($00 to $FF), -1 on timeout
|
1842 |
|
|
; Modifies: acc
|
1843 |
|
|
; Stack Space: 2 words
|
1844 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1845 |
|
|
|
1846 |
|
|
KeybdRecvByte:
|
1847 |
16 |
robfinch |
00FFE900 034010 pshs x
|
1848 |
|
|
00FFE902 08E000064 ldx #100 ; wait up to 1s
|
1849 |
4 |
robfinch |
krb3:
|
1850 |
16 |
robfinch |
00FFE905 08D05A bsr KeybdGetStatus ; wait for response from keyboard
|
1851 |
|
|
00FFE907 05D tstb
|
1852 |
|
|
00FFE908 02B00B bmi krb4 ; is input buffer full ? yes, branch
|
1853 |
|
|
00FFE90A 08D02D bsr Wait10ms ; wait a bit
|
1854 |
|
|
00FFE90C 0301FF dex
|
1855 |
|
|
00FFE90E 026FF5 bne krb3 ; go back and try again
|
1856 |
|
|
00FFE910 0CCFFFFFF ldd #-1 ; return -1
|
1857 |
|
|
00FFE913 035090 puls x,pc
|
1858 |
4 |
robfinch |
krb4:
|
1859 |
16 |
robfinch |
00FFE915 08D066 bsr KeybdGetScancode
|
1860 |
|
|
00FFE917 035090 puls x,pc
|
1861 |
4 |
robfinch |
|
1862 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1863 |
|
|
; Send a byte to the keyboard.
|
1864 |
|
|
;
|
1865 |
|
|
; Parameters: accb byte to send
|
1866 |
|
|
; Returns: none
|
1867 |
|
|
; Modifies: none
|
1868 |
|
|
; Stack Space: 0 words
|
1869 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1870 |
|
|
|
1871 |
|
|
KeybdSendByte:
|
1872 |
16 |
robfinch |
00FFE919 0150F7FFFE30400 stb KEYBD
|
1873 |
|
|
00FFE91E 039 rts
|
1874 |
4 |
robfinch |
|
1875 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1876 |
|
|
; Wait until the keyboard transmit is complete
|
1877 |
|
|
;
|
1878 |
|
|
; Parameters: none
|
1879 |
|
|
; Returns: r1 = 0 if successful, r1 = -1 timeout
|
1880 |
|
|
; Modifies: r1
|
1881 |
|
|
; Stack Space: 3 words
|
1882 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1883 |
|
|
|
1884 |
|
|
KeybdWaitTx:
|
1885 |
16 |
robfinch |
00FFE91F 034010 pshs x
|
1886 |
|
|
00FFE921 08E000064 ldx #100 ; wait a max of 1s
|
1887 |
4 |
robfinch |
kwt1:
|
1888 |
16 |
robfinch |
00FFE924 08D03B bsr KeybdGetStatus
|
1889 |
|
|
00FFE926 0C4040 andb #$40 ; check for transmit complete bit; branch if bit set
|
1890 |
|
|
00FFE928 02600B bne kwt2
|
1891 |
|
|
00FFE92A 08D00D bsr Wait10ms ; delay a little bit
|
1892 |
|
|
00FFE92C 0301FF dex
|
1893 |
|
|
00FFE92E 026FF4 bne kwt1 ; go back and try again
|
1894 |
|
|
00FFE930 0CCFFFFFF ldd #-1 ; timed out, return -1
|
1895 |
|
|
00FFE933 035090 puls x,pc
|
1896 |
4 |
robfinch |
kwt2:
|
1897 |
16 |
robfinch |
00FFE935 04F clra ; wait complete, return 0
|
1898 |
|
|
00FFE936 05F clrb
|
1899 |
|
|
00FFE937 035090 puls x,pc
|
1900 |
4 |
robfinch |
|
1901 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1902 |
|
|
; Wait for 10 ms
|
1903 |
|
|
;
|
1904 |
|
|
; Parameters: none
|
1905 |
|
|
; Returns: none
|
1906 |
|
|
; Modifies: none
|
1907 |
|
|
; Stack Space: 2 words
|
1908 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1909 |
|
|
|
1910 |
|
|
Wait10ms:
|
1911 |
16 |
robfinch |
00FFE939 034006 pshs d
|
1912 |
|
|
00FFE93B 0150B6FFFFFFFE7 lda MSCOUNT+3
|
1913 |
4 |
robfinch |
W10_0001:
|
1914 |
16 |
robfinch |
00FFE940 01F089 tfr a,b
|
1915 |
|
|
00FFE942 0150F0FFFFFFFE7 subb MSCOUNT+3
|
1916 |
|
|
00FFE947 0C1FFA cmpb #$FFA
|
1917 |
|
|
00FFE949 022FF5 bhi W10_0001
|
1918 |
|
|
00FFE94B 035086 puls d,pc
|
1919 |
4 |
robfinch |
|
1920 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1921 |
|
|
; Wait for 300 ms (256 ms)
|
1922 |
|
|
;
|
1923 |
|
|
; Parameters: none
|
1924 |
|
|
; Returns: none
|
1925 |
|
|
; Modifies: none
|
1926 |
|
|
; Stack Space: 2 words
|
1927 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1928 |
|
|
|
1929 |
|
|
Wait300ms:
|
1930 |
16 |
robfinch |
00FFE94D 034006 pshs d
|
1931 |
|
|
00FFE94F 0150B6FFFFFFFE7 lda MSCOUNT+3
|
1932 |
4 |
robfinch |
W300_0001:
|
1933 |
16 |
robfinch |
00FFE954 01F089 tfr a,b
|
1934 |
|
|
00FFE956 0150F0FFFFFFFE7 subb MSCOUNT+3
|
1935 |
|
|
00FFE95B 0C1F00 cmpb #$F00
|
1936 |
|
|
00FFE95D 022FF5 bhi W300_0001
|
1937 |
|
|
00FFE95F 035086 puls d,pc
|
1938 |
4 |
robfinch |
|
1939 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1940 |
|
|
; Get the keyboard status
|
1941 |
|
|
;
|
1942 |
|
|
; Parameters: none
|
1943 |
|
|
; Returns: d = status
|
1944 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1945 |
|
|
|
1946 |
|
|
KeybdGetStatus:
|
1947 |
|
|
kbgs3:
|
1948 |
16 |
robfinch |
00FFE961 0150F6FFFE30401 ldb KEYBD+1
|
1949 |
|
|
00FFE966 0C5080 bitb #$80
|
1950 |
|
|
00FFE968 02600E bne kbgs1
|
1951 |
|
|
00FFE96A 0C5001 bitb #$01 ; check parity error flag
|
1952 |
|
|
00FFE96C 026002 bne kbgs2
|
1953 |
|
|
00FFE96E 04F clra
|
1954 |
|
|
00FFE96F 039 rts
|
1955 |
4 |
robfinch |
kbgs2:
|
1956 |
16 |
robfinch |
00FFE970 0C60FE ldb #$FE ; request resend
|
1957 |
|
|
00FFE972 08DFA5 bsr KeybdSendByte
|
1958 |
|
|
00FFE974 08DFA9 bsr KeybdWaitTx
|
1959 |
|
|
00FFE976 020FE9 bra kbgs3
|
1960 |
4 |
robfinch |
kbgs1: ; return negative status
|
1961 |
16 |
robfinch |
00FFE978 0CAF00 orb #$F00
|
1962 |
|
|
00FFE97A 086FFF lda #-1
|
1963 |
|
|
00FFE97C 039 rts
|
1964 |
4 |
robfinch |
|
1965 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1966 |
|
|
; Get the scancode from the keyboard port
|
1967 |
|
|
;
|
1968 |
|
|
; Parameters: none
|
1969 |
|
|
; Returns: acca = scancode
|
1970 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1971 |
|
|
|
1972 |
|
|
KeybdGetScancode:
|
1973 |
16 |
robfinch |
00FFE97D 04F clra
|
1974 |
|
|
00FFE97E 0150F6FFFE30400 ldb KEYBD ; get the scan code
|
1975 |
|
|
00FFE983 01507FFFFE30401 clr KEYBD+1 ; clear receive register (write $00 to status reg)
|
1976 |
|
|
00FFE988 039 rts
|
1977 |
4 |
robfinch |
|
1978 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1979 |
|
|
; Set the LEDs on the keyboard.
|
1980 |
|
|
;
|
1981 |
|
|
; Parameters: d LED status to set
|
1982 |
|
|
; Returns: none
|
1983 |
|
|
; Modifies: none
|
1984 |
|
|
; Stack Space: 2 words
|
1985 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
1986 |
|
|
|
1987 |
|
|
KeybdSetLED:
|
1988 |
16 |
robfinch |
00FFE989 034004 pshs b
|
1989 |
|
|
00FFE98B 0C60ED ldb #$ED ; set LEDs command
|
1990 |
|
|
00FFE98D 08DF8A bsr KeybdSendByte
|
1991 |
|
|
00FFE98F 08DF8E bsr KeybdWaitTx
|
1992 |
|
|
00FFE991 08DF6D bsr KeybdRecvByte ; should be an ack
|
1993 |
|
|
00FFE993 035004 puls b
|
1994 |
|
|
00FFE995 08DF82 bsr KeybdSendByte
|
1995 |
|
|
00FFE997 08DF86 bsr KeybdWaitTx
|
1996 |
|
|
00FFE999 08DF65 bsr KeybdRecvByte ; should be an ack
|
1997 |
|
|
00FFE99B 039 rts
|
1998 |
4 |
robfinch |
|
1999 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2000 |
|
|
; Get ID - get the keyboards identifier code.
|
2001 |
|
|
;
|
2002 |
|
|
; Parameters: none
|
2003 |
|
|
; Returns: d = $AB83, $00 on fail
|
2004 |
|
|
; Modifies: d, KeybdID updated
|
2005 |
|
|
; Stack Space: 2 words
|
2006 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2007 |
|
|
|
2008 |
|
|
KeybdGetID:
|
2009 |
16 |
robfinch |
00FFE99C 0C60F2 ldb #$F2
|
2010 |
|
|
00FFE99E 08DF79 bsr KeybdSendByte
|
2011 |
|
|
00FFE9A0 08DF7D bsr KeybdWaitTx
|
2012 |
|
|
00FFE9A2 08DF5C bsr KeybdRecvByte
|
2013 |
|
|
00FFE9A4 0C5080 bitb #$80
|
2014 |
|
|
00FFE9A6 026014 bne kgnotKbd
|
2015 |
|
|
00FFE9A8 0C10AB cmpb #$AB
|
2016 |
|
|
00FFE9AA 026010 bne kgnotKbd
|
2017 |
|
|
00FFE9AC 08DF52 bsr KeybdRecvByte
|
2018 |
|
|
00FFE9AE 0C5080 bitb #$80
|
2019 |
|
|
00FFE9B0 02600A bne kgnotKbd
|
2020 |
|
|
00FFE9B2 0C1083 cmpb #$83
|
2021 |
|
|
00FFE9B4 026006 bne kgnotKbd
|
2022 |
|
|
00FFE9B6 0CC00AB83 ldd #$AB83
|
2023 |
4 |
robfinch |
kgid1:
|
2024 |
16 |
robfinch |
00FFE9B9 0DD124 std KeybdID
|
2025 |
|
|
00FFE9BB 039 rts
|
2026 |
4 |
robfinch |
kgnotKbd:
|
2027 |
16 |
robfinch |
00FFE9BC 04F clra
|
2028 |
|
|
00FFE9BD 05F clrb
|
2029 |
|
|
00FFE9BE 020FF9 bra kgid1
|
2030 |
4 |
robfinch |
|
2031 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2032 |
|
|
; Initialize the keyboard.
|
2033 |
|
|
;
|
2034 |
|
|
; Parameters:
|
2035 |
|
|
; none
|
2036 |
|
|
; Modifies:
|
2037 |
|
|
; none
|
2038 |
|
|
; Returns:
|
2039 |
|
|
; none
|
2040 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2041 |
|
|
|
2042 |
|
|
KeybdInit:
|
2043 |
16 |
robfinch |
00FFE9C0 034026 pshs d,y
|
2044 |
|
|
00FFE9C2 18E000005 ldy #5
|
2045 |
|
|
00FFE9C5 00F120 clr KeyState1 ; records key up/down state
|
2046 |
|
|
00FFE9C7 00F121 clr KeyState2 ; records shift,ctrl,alt state
|
2047 |
4 |
robfinch |
kbdi0002:
|
2048 |
16 |
robfinch |
00FFE9C9 08DF6E bsr Wait10ms
|
2049 |
|
|
00FFE9CB 01507FFFFE30401 clr KEYBD+1 ; clear receive register (write $00 to status reg)
|
2050 |
|
|
00FFE9D0 0C6FFF ldb #-1 ; send reset code to keyboard
|
2051 |
|
|
00FFE9D2 0150F7FFFE30401 stb KEYBD+1 ; write $FF to status reg to clear TX state
|
2052 |
|
|
00FFE9D7 08DF40 bsr KeybdSendByte ; now write to transmit register
|
2053 |
|
|
00FFE9D9 08DF44 bsr KeybdWaitTx ; wait until no longer busy
|
2054 |
|
|
00FFE9DB 08DF23 bsr KeybdRecvByte ; look for an ACK ($FA)
|
2055 |
|
|
00FFE9DD 0C10FA cmpb #$FA
|
2056 |
|
|
00FFE9DF 026021 bne kbdiTryAgain
|
2057 |
|
|
00FFE9E1 08DF1D bsr KeybdRecvByte ; look for BAT completion code ($AA)
|
2058 |
|
|
00FFE9E3 0C10FC cmpb #$FC ; reset error ?
|
2059 |
|
|
00FFE9E5 02701B beq kbdiTryAgain
|
2060 |
|
|
00FFE9E7 0C10AA cmpb #$AA ; reset complete okay ?
|
2061 |
|
|
00FFE9E9 026017 bne kbdiTryAgain
|
2062 |
4 |
robfinch |
|
2063 |
|
|
; After a reset, scan code set #2 should be active
|
2064 |
|
|
.config:
|
2065 |
16 |
robfinch |
00FFE9EB 0C60F0 ldb #$F0 ; send scan code select
|
2066 |
|
|
00FFE9ED 0150F7FFFE60001 stb LEDS
|
2067 |
|
|
00FFE9F2 08DF25 bsr KeybdSendByte
|
2068 |
|
|
00FFE9F4 08DF29 bsr KeybdWaitTx
|
2069 |
|
|
00FFE9F6 05D tstb
|
2070 |
|
|
00FFE9F7 02B009 bmi kbdiTryAgain
|
2071 |
|
|
00FFE9F9 08DF05 bsr KeybdRecvByte ; wait for response from keyboard
|
2072 |
|
|
00FFE9FB 04D tsta
|
2073 |
|
|
00FFE9FC 02B004 bmi kbdiTryAgain
|
2074 |
|
|
00FFE9FE 0C10FA cmpb #$FA ; ACK
|
2075 |
|
|
00FFEA00 02700C beq kbdi0004
|
2076 |
4 |
robfinch |
kbdiTryAgain:
|
2077 |
16 |
robfinch |
00FFEA02 0313FF dey
|
2078 |
|
|
00FFEA04 026FC3 bne kbdi0002
|
2079 |
4 |
robfinch |
.keybdErr:
|
2080 |
16 |
robfinch |
00FFEA06 0CCFFEA2E ldd #msgBadKeybd
|
2081 |
21 |
robfinch |
00FFEA09 017FFF9F1 lbsr DisplayStringCRLF
|
2082 |
4 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
2083 |
16 |
robfinch |
00FFEA0C 020014 bra ledxit
|
2084 |
4 |
robfinch |
kbdi0004:
|
2085 |
16 |
robfinch |
00FFEA0E 0C6002 ldb #2 ; select scan code set #2
|
2086 |
|
|
00FFEA10 08DF07 bsr KeybdSendByte
|
2087 |
|
|
00FFEA12 08DF0B bsr KeybdWaitTx
|
2088 |
|
|
00FFEA14 05D tstb
|
2089 |
|
|
00FFEA15 02BFEB bmi kbdiTryAgain
|
2090 |
|
|
00FFEA17 08DEE7 bsr KeybdRecvByte ; wait for response from keyboard
|
2091 |
|
|
00FFEA19 04D tsta
|
2092 |
|
|
00FFEA1A 02BFE6 bmi kbdiTryAgain
|
2093 |
|
|
00FFEA1C 0C10FA cmpb #$FA
|
2094 |
|
|
00FFEA1E 026FE2 bne kbdiTryAgain
|
2095 |
|
|
00FFEA20 08DF7A bsr KeybdGetID
|
2096 |
4 |
robfinch |
ledxit:
|
2097 |
16 |
robfinch |
00FFEA22 0C6007 ldb #$07
|
2098 |
|
|
00FFEA24 08DF63 bsr KeybdSetLED
|
2099 |
|
|
00FFEA26 08DF25 bsr Wait300ms
|
2100 |
|
|
00FFEA28 0C6000 ldb #$00
|
2101 |
|
|
00FFEA2A 08DF5D bsr KeybdSetLED
|
2102 |
|
|
00FFEA2C 0350A6 puls d,y,pc
|
2103 |
4 |
robfinch |
|
2104 |
|
|
msgBadKeybd:
|
2105 |
16 |
robfinch |
00FFEA2E 04B06507906206F061072 fcb "Keyboard error",0
|
2106 |
|
|
00FFEA35 06402006507207206F072
|
2107 |
|
|
00FFEA3C 000
|
2108 |
4 |
robfinch |
|
2109 |
13 |
robfinch |
;------------------------------------------------------------------------------
|
2110 |
|
|
; Calculate number of character in input buffer
|
2111 |
|
|
;
|
2112 |
|
|
; Parameters:
|
2113 |
|
|
; y = $Cn00000 where n is core id
|
2114 |
|
|
; Returns:
|
2115 |
|
|
; d = number of bytes in buffer.
|
2116 |
|
|
;------------------------------------------------------------------------------
|
2117 |
|
|
|
2118 |
|
|
kbdRcvCount:
|
2119 |
16 |
robfinch |
00FFEA3D 04F clra
|
2120 |
|
|
00FFEA3E 0E6A08128 ldb kbdTailRcv,y
|
2121 |
|
|
00FFEA41 0E0A08127 subb kbdHeadRcv,y
|
2122 |
|
|
00FFEA44 02C008 bge krcXit
|
2123 |
|
|
00FFEA46 0C6040 ldb #$40
|
2124 |
|
|
00FFEA48 0E0A08127 subb kbdHeadRcv,y
|
2125 |
|
|
00FFEA4B 0EBA08128 addb kbdTailRcv,y
|
2126 |
13 |
robfinch |
krcXit:
|
2127 |
16 |
robfinch |
00FFEA4E 039 rts
|
2128 |
13 |
robfinch |
|
2129 |
|
|
|
2130 |
4 |
robfinch |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2131 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2132 |
|
|
|
2133 |
13 |
robfinch |
KeybdIRQ:
|
2134 |
16 |
robfinch |
00FFEA4F 0150B6FFFE30401 lda KEYBD+1 ; check status
|
2135 |
|
|
00FFEA54 085080 bita #$80 ; was key pressed?
|
2136 |
|
|
00FFEA56 027034 beq notKbdIRQ ; if not, exit
|
2137 |
|
|
00FFEA58 0150F6FFFE30400 ldb KEYBD ; get the scan code
|
2138 |
|
|
00FFEA5D 01507FFFFE30401 clr KEYBD+1 ; clear receive register (write $00 to status reg)
|
2139 |
|
|
00FFEA62 034004 pshs b ; save it off
|
2140 |
|
|
00FFEA64 0B6FFC010 lda IOFocusID ; compute core memory address $Cn0000
|
2141 |
|
|
00FFEA67 05F clrb
|
2142 |
|
|
00FFEA68 048 asla
|
2143 |
|
|
00FFEA69 048 asla
|
2144 |
|
|
00FFEA6A 048 asla
|
2145 |
|
|
00FFEA6B 048 asla
|
2146 |
|
|
00FFEA6C 08AC00 ora #$C00 ; address $Cn0000
|
2147 |
|
|
00FFEA6E 01F002 tfr d,y ; y =
|
2148 |
|
|
00FFEA70 08DFCB bsr kbdRcvCount ; get count of scan codes in buffer
|
2149 |
|
|
00FFEA72 0C1040 cmpb #64 ; check if buffer full?
|
2150 |
|
|
00FFEA74 024017 bhs kbdBufFull ; if buffer full, ignore new keystroke
|
2151 |
|
|
00FFEA76 01F021 tfr y,x ; compute fifo address
|
2152 |
|
|
00FFEA78 0E6A08128 ldb kbdTailRcv,y ; b = buffer index
|
2153 |
|
|
00FFEA7B 035002 puls a ; get back scancode
|
2154 |
|
|
00FFEA7D 030040 leax kbdFifo,x ; x = base address for fifo
|
2155 |
|
|
00FFEA7F 0A7845 sta b,x ; store in buffer
|
2156 |
|
|
00FFEA81 05C incb ; increment buffer index
|
2157 |
|
|
00FFEA82 0C403F andb #$3f ; wrap around at 64 chars
|
2158 |
|
|
00FFEA84 0E7A08128 stb kbdTailRcv,y ; update it
|
2159 |
|
|
00FFEA87 08601C lda #28 ; Keyboard is IRQ #28
|
2160 |
|
|
00FFEA89 0B7FFC011 sta IrqSource ; stuff a byte indicating the IRQ source for PEEK()
|
2161 |
13 |
robfinch |
notKbdIRQ:
|
2162 |
16 |
robfinch |
00FFEA8C 039 rts
|
2163 |
13 |
robfinch |
kbdBufFull:
|
2164 |
16 |
robfinch |
00FFEA8D 032601 leas 1,s ; get rid of saved scancode
|
2165 |
|
|
00FFEA8F 039 rts
|
2166 |
13 |
robfinch |
|
2167 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2168 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2169 |
|
|
|
2170 |
4 |
robfinch |
DBGCheckForKey:
|
2171 |
16 |
robfinch |
00FFEA90 020ECF bra KeybdGetStatus
|
2172 |
4 |
robfinch |
|
2173 |
|
|
|
2174 |
|
|
; KeyState2 variable bit meanings
|
2175 |
|
|
;1176543210
|
2176 |
|
|
; ||||||||+ = shift
|
2177 |
|
|
; |||||||+- = alt
|
2178 |
|
|
; ||||||+-- = control
|
2179 |
|
|
; |||||+--- = numlock
|
2180 |
|
|
; ||||+---- = capslock
|
2181 |
|
|
; |||+----- = scrolllock
|
2182 |
|
|
; ||+------ =
|
2183 |
|
|
; |+------- = "
|
2184 |
|
|
; | = "
|
2185 |
|
|
; | = "
|
2186 |
|
|
; | = "
|
2187 |
|
|
; +-------- = extended
|
2188 |
|
|
|
2189 |
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2190 |
13 |
robfinch |
; Keyboard get routine.
|
2191 |
4 |
robfinch |
;
|
2192 |
13 |
robfinch |
; The routine may get characters directly from the scancode input or less
|
2193 |
|
|
; directly from the scancode buffer, if things are interrupt driven.
|
2194 |
|
|
;
|
2195 |
4 |
robfinch |
; Parameters:
|
2196 |
13 |
robfinch |
; b: bit 11 = blocking status 1=blocking, 0=non blocking
|
2197 |
|
|
; b: bit 1 = scancode source 1=scancode buffer, 0=direct
|
2198 |
4 |
robfinch |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2199 |
|
|
|
2200 |
13 |
robfinch |
GetKey:
|
2201 |
16 |
robfinch |
00FFEA92 034030 pshs x,y
|
2202 |
|
|
00FFEA94 0D7126 stb KeybdBlock ; save off blocking status
|
2203 |
4 |
robfinch |
dbgk2:
|
2204 |
16 |
robfinch |
00FFEA96 0D6126 ldb KeybdBlock
|
2205 |
|
|
00FFEA98 034004 pshs b
|
2206 |
|
|
00FFEA9A 0C5001 bitb #1 ; what is the scancode source
|
2207 |
|
|
00FFEA9C 02701A beq dbgk20 ; branch if direct read
|
2208 |
|
|
00FFEA9E 0150B6FFFFFFFE0 lda COREID ; compute core memory address
|
2209 |
|
|
00FFEAA3 05F clrb
|
2210 |
|
|
00FFEAA4 048 asla
|
2211 |
|
|
00FFEAA5 048 asla
|
2212 |
|
|
00FFEAA6 048 asla
|
2213 |
|
|
00FFEAA7 048 asla
|
2214 |
|
|
00FFEAA8 08AC00 ora #$C00
|
2215 |
|
|
00FFEAAA 01F002 tfr d,y ; y = $Cn0000
|
2216 |
|
|
00FFEAAC 08DF8F bsr kbdRcvCount
|
2217 |
|
|
00FFEAAE 05D tstb ; anything in buffer?
|
2218 |
|
|
00FFEAAF 035004 puls b
|
2219 |
|
|
00FFEAB1 026018 bne dbgk1 ; branch if something in buffer
|
2220 |
|
|
00FFEAB3 05D tstb
|
2221 |
|
|
00FFEAB4 02BFE0 bmi dbgk2 ; if no key and blocking - loop
|
2222 |
|
|
00FFEAB6 02000E bra dbgk24
|
2223 |
13 |
robfinch |
dbgk20:
|
2224 |
16 |
robfinch |
00FFEAB8 18E000000 ldy #0
|
2225 |
|
|
00FFEABB 08DEA4 bsr KeybdGetStatus
|
2226 |
|
|
00FFEABD 0C4080 andb #$80 ; is key available?
|
2227 |
|
|
00FFEABF 035004 puls b
|
2228 |
|
|
00FFEAC1 026008 bne dbgk1 ; branch if key
|
2229 |
|
|
00FFEAC3 05D tstb ; block?
|
2230 |
|
|
00FFEAC4 02BFD0 bmi dbgk2 ; If no key and blocking - loop
|
2231 |
13 |
robfinch |
dbgk24:
|
2232 |
16 |
robfinch |
00FFEAC6 0CCFFFFFF ldd #-1 ; return -1 if no block and no key
|
2233 |
|
|
00FFEAC9 0350B0 puls x,y,pc
|
2234 |
4 |
robfinch |
dbgk1:
|
2235 |
16 |
robfinch |
00FFEACB 18C000000 cmpy #0
|
2236 |
|
|
00FFEACE 026004 bne dbgk22
|
2237 |
|
|
00FFEAD0 08DEAB bsr KeybdGetScancode ; get scancode directly
|
2238 |
|
|
00FFEAD2 020011 bra dbgk23
|
2239 |
13 |
robfinch |
dbgk22:
|
2240 |
|
|
; Retrieve value from scancode buffer
|
2241 |
16 |
robfinch |
00FFEAD4 01F021 tfr y,x
|
2242 |
|
|
00FFEAD6 030040 leax kbdFifo,x ; x = fifo address
|
2243 |
|
|
00FFEAD8 0E6A08127 ldb kbdHeadRcv,y ; b = buffer index
|
2244 |
|
|
00FFEADB 0A6A0D lda b,x ; get the scancode
|
2245 |
|
|
00FFEADD 05C incb ; increment fifo index
|
2246 |
|
|
00FFEADE 0C403F andb #$3f ; and wrap around
|
2247 |
|
|
00FFEAE0 0E7A08127 stb kbdHeadRcv,y ; save it back
|
2248 |
|
|
00FFEAE3 01F089 tfr a,b ; the scancode is needed in accb
|
2249 |
13 |
robfinch |
dbgk23:
|
2250 |
4 |
robfinch |
; lbsr DispByteAsHex
|
2251 |
|
|
; Make sure there is a small delay between scancode reads
|
2252 |
16 |
robfinch |
00FFEAE5 08E000014 ldx #20
|
2253 |
4 |
robfinch |
dbgk3:
|
2254 |
16 |
robfinch |
00FFEAE8 0301FF dex
|
2255 |
|
|
00FFEAEA 026FFC bne dbgk3
|
2256 |
4 |
robfinch |
; switch on scan code
|
2257 |
16 |
robfinch |
00FFEAEC 0C10F0 cmpb #SC_KEYUP
|
2258 |
|
|
00FFEAEE 026004 bne dbgk4
|
2259 |
|
|
00FFEAF0 0D7120 stb KeyState1 ; make KeyState1 <> 0
|
2260 |
|
|
00FFEAF2 020FA2 bra dbgk2 ; loop back
|
2261 |
4 |
robfinch |
dbgk4:
|
2262 |
16 |
robfinch |
00FFEAF4 0C10E0 cmpb #SC_EXTEND
|
2263 |
|
|
00FFEAF6 026008 bne dbgk5
|
2264 |
|
|
00FFEAF8 096121 lda KeyState2
|
2265 |
|
|
00FFEAFA 08A800 ora #$800
|
2266 |
|
|
00FFEAFC 097121 sta KeyState2
|
2267 |
|
|
00FFEAFE 020F96 bra dbgk2
|
2268 |
4 |
robfinch |
dbgk5:
|
2269 |
16 |
robfinch |
00FFEB00 0C1014 cmpb #SC_CTRL
|
2270 |
|
|
00FFEB02 026016 bne dbgkNotCtrl
|
2271 |
|
|
00FFEB04 00D120 tst KeyState1
|
2272 |
|
|
00FFEB06 026008 bne dbgk7
|
2273 |
|
|
00FFEB08 096121 lda KeyState2
|
2274 |
|
|
00FFEB0A 08A004 ora #4
|
2275 |
|
|
00FFEB0C 097121 sta KeyState2
|
2276 |
|
|
00FFEB0E 020006 bra dbgk8
|
2277 |
4 |
robfinch |
dbgk7:
|
2278 |
16 |
robfinch |
00FFEB10 096121 lda KeyState2
|
2279 |
|
|
00FFEB12 084FFB anda #~4
|
2280 |
|
|
00FFEB14 097121 sta KeyState2
|
2281 |
4 |
robfinch |
dbgk8:
|
2282 |
16 |
robfinch |
00FFEB16 00F120 clr KeyState1
|
2283 |
|
|
00FFEB18 020F7C bra dbgk2
|
2284 |
4 |
robfinch |
dbgkNotCtrl:
|
2285 |
16 |
robfinch |
00FFEB1A 0C1059 cmpb #SC_RSHIFT
|
2286 |
|
|
00FFEB1C 026016 bne dbgkNotRshift
|
2287 |
|
|
00FFEB1E 00D120 tst KeyState1
|
2288 |
|
|
00FFEB20 026008 bne dbgk9
|
2289 |
|
|
00FFEB22 096121 lda KeyState2
|
2290 |
|
|
00FFEB24 08A001 ora #1
|
2291 |
|
|
00FFEB26 097121 sta KeyState2
|
2292 |
|
|
00FFEB28 020006 bra dbgk10
|
2293 |
4 |
robfinch |
dbgk9:
|
2294 |
16 |
robfinch |
00FFEB2A 096121 lda KeyState2
|
2295 |
|
|
00FFEB2C 084FFE anda #~1
|
2296 |
|
|
00FFEB2E 097121 sta KeyState2
|
2297 |
4 |
robfinch |
dbgk10:
|
2298 |
16 |
robfinch |
00FFEB30 00F120 clr KeyState1
|
2299 |
|
|
00FFEB32 020F62 bra dbgk2
|
2300 |
4 |
robfinch |
dbgkNotRshift:
|
2301 |
16 |
robfinch |
00FFEB34 0C1077 cmpb #SC_NUMLOCK
|
2302 |
|
|
00FFEB36 026013 bne dbgkNotNumlock
|
2303 |
|
|
00FFEB38 096121 lda KeyState2
|
2304 |
|
|
00FFEB3A 088010 eora #16
|
2305 |
|
|
00FFEB3C 097121 sta KeyState2
|
2306 |
|
|
00FFEB3E 096122 lda KeyLED
|
2307 |
|
|
00FFEB40 088002 eora #2
|
2308 |
|
|
00FFEB42 097122 sta KeyLED
|
2309 |
|
|
00FFEB44 01F089 tfr a,b
|
2310 |
|
|
00FFEB46 04F clra
|
2311 |
|
|
00FFEB47 08DE40 bsr KeybdSetLED
|
2312 |
|
|
00FFEB49 020F4B bra dbgk2
|
2313 |
4 |
robfinch |
dbgkNotNumlock:
|
2314 |
16 |
robfinch |
00FFEB4B 0C1058 cmpb #SC_CAPSLOCK
|
2315 |
|
|
00FFEB4D 026013 bne dbgkNotCapslock
|
2316 |
|
|
00FFEB4F 096121 lda KeyState2
|
2317 |
|
|
00FFEB51 088020 eora #32
|
2318 |
|
|
00FFEB53 097121 sta KeyState2
|
2319 |
|
|
00FFEB55 096122 lda KeyLED
|
2320 |
|
|
00FFEB57 088004 eora #4
|
2321 |
|
|
00FFEB59 097122 sta KeyLED
|
2322 |
|
|
00FFEB5B 01F089 tfr a,b
|
2323 |
|
|
00FFEB5D 04F clra
|
2324 |
|
|
00FFEB5E 08DE29 bsr KeybdSetLED
|
2325 |
|
|
00FFEB60 020F34 bra dbgk2
|
2326 |
4 |
robfinch |
dbgkNotCapslock:
|
2327 |
16 |
robfinch |
00FFEB62 0C107E cmpb #SC_SCROLLLOCK
|
2328 |
|
|
00FFEB64 026013 bne dbgkNotScrolllock
|
2329 |
|
|
00FFEB66 096121 lda KeyState2
|
2330 |
|
|
00FFEB68 088040 eora #64
|
2331 |
|
|
00FFEB6A 097121 sta KeyState2
|
2332 |
|
|
00FFEB6C 096122 lda KeyLED
|
2333 |
|
|
00FFEB6E 088001 eora #1
|
2334 |
|
|
00FFEB70 097122 sta KeyLED
|
2335 |
|
|
00FFEB72 01F089 tfr a,b
|
2336 |
|
|
00FFEB74 04F clra
|
2337 |
|
|
00FFEB75 08DE12 bsr KeybdSetLED
|
2338 |
|
|
00FFEB77 020F1D bra dbgk2
|
2339 |
4 |
robfinch |
dbgkNotScrolllock:
|
2340 |
16 |
robfinch |
00FFEB79 0C1011 cmpb #SC_ALT
|
2341 |
|
|
00FFEB7B 026016 bne dbgkNotAlt
|
2342 |
|
|
00FFEB7D 00D120 tst KeyState1
|
2343 |
|
|
00FFEB7F 026008 bne dbgk11
|
2344 |
|
|
00FFEB81 096121 lda KeyState2
|
2345 |
|
|
00FFEB83 08A002 ora #2
|
2346 |
|
|
00FFEB85 097121 sta KeyState2
|
2347 |
|
|
00FFEB87 020006 bra dbgk12
|
2348 |
4 |
robfinch |
dbgk11:
|
2349 |
16 |
robfinch |
00FFEB89 096121 lda KeyState2
|
2350 |
|
|
00FFEB8B 084FFD anda #~2
|
2351 |
|
|
00FFEB8D 097121 sta KeyState2
|
2352 |
4 |
robfinch |
dbgk12:
|
2353 |
16 |
robfinch |
00FFEB8F 00F120 clr KeyState1
|
2354 |
|
|
00FFEB91 020F03 bra dbgk2
|
2355 |
4 |
robfinch |
dbgkNotAlt:
|
2356 |
16 |
robfinch |
00FFEB93 00D120 tst KeyState1
|
2357 |
|
|
00FFEB95 027004 beq dbgk13
|
2358 |
|
|
00FFEB97 00F120 clr KeyState1
|
2359 |
|
|
00FFEB99 020EFB bra dbgk2
|
2360 |
4 |
robfinch |
dbgk13:
|
2361 |
16 |
robfinch |
00FFEB9B 096121 lda KeyState2 ; Check for CTRL-ALT-DEL
|
2362 |
|
|
00FFEB9D 084006 anda #6
|
2363 |
|
|
00FFEB9F 081006 cmpa #6
|
2364 |
|
|
00FFEBA1 026008 bne dbgk14
|
2365 |
|
|
00FFEBA3 0C1071 cmpb #SC_DEL
|
2366 |
|
|
00FFEBA5 026004 bne dbgk14
|
2367 |
|
|
00FFEBA7 06E90FFFFFFC jmp [$FFFFFC] ; jump to NMI vector
|
2368 |
4 |
robfinch |
dbgk14:
|
2369 |
16 |
robfinch |
00FFEBAB 00D121 tst KeyState2 ; extended code?
|
2370 |
|
|
00FFEBAD 02A00B bpl dbgk15
|
2371 |
|
|
00FFEBAF 096121 lda KeyState2
|
2372 |
|
|
00FFEBB1 0847FF anda #$7FF
|
2373 |
|
|
00FFEBB3 097121 sta KeyState2
|
2374 |
|
|
00FFEBB5 08EFFE880 ldx #keybdExtendedCodes
|
2375 |
|
|
00FFEBB8 020017 bra dbgk18
|
2376 |
4 |
robfinch |
dbgk15:
|
2377 |
16 |
robfinch |
00FFEBBA 096121 lda KeyState2 ; Is CTRL down?
|
2378 |
|
|
00FFEBBC 085004 bita #4
|
2379 |
|
|
00FFEBBE 027005 beq dbgk16
|
2380 |
|
|
00FFEBC0 08EFFE800 ldx #keybdControlCodes
|
2381 |
|
|
00FFEBC3 02000C bra dbgk18
|
2382 |
4 |
robfinch |
dbgk16:
|
2383 |
16 |
robfinch |
00FFEBC5 085001 bita #1 ; Is shift down?
|
2384 |
|
|
00FFEBC7 027005 beq dbgk17
|
2385 |
|
|
00FFEBC9 08EFFE700 ldx #shiftedScanCodes
|
2386 |
|
|
00FFEBCC 020003 bra dbgk18
|
2387 |
4 |
robfinch |
dbgk17:
|
2388 |
16 |
robfinch |
00FFEBCE 08EFFE600 ldx #unshiftedScanCodes
|
2389 |
4 |
robfinch |
dbgk18:
|
2390 |
16 |
robfinch |
00FFEBD1 0E690FFFE600 ldb b,x ; load accb with ascii from table
|
2391 |
|
|
00FFEBD5 04F clra
|
2392 |
|
|
00FFEBD6 0350B0 puls x,y,pc ; and return
|
2393 |
4 |
robfinch |
|
2394 |
|
|
|
2395 |
16 |
robfinch |
00FFEBD8 04B04505904204F041052 fcb "KEYBOARD"
|
2396 |
|
|
00FFEBDF 044
|
2397 |
|
|
00FFEBE0 FFEBEA fcw KeybdOpen
|
2398 |
|
|
00FFEBE2 FFEBEB fcw KeybdClose
|
2399 |
|
|
00FFEBE4 FFEBEC fcw KeybdRead
|
2400 |
|
|
00FFEBE6 FFEBED fcw KeybdWrite
|
2401 |
|
|
00FFEBE8 FFEBEE fcw KeybdSeek
|
2402 |
4 |
robfinch |
|
2403 |
|
|
; Keyboard Open:
|
2404 |
|
|
; Initialize the keyboard buffer head and tail indexes
|
2405 |
|
|
;
|
2406 |
|
|
KeybdOpen:
|
2407 |
16 |
robfinch |
00FFEBEA 039 rts
|
2408 |
4 |
robfinch |
|
2409 |
|
|
; Keyboard Close:
|
2410 |
|
|
; Nothing to do except maybe clear the keyboard buffer
|
2411 |
|
|
;
|
2412 |
|
|
KeybdClose:
|
2413 |
16 |
robfinch |
00FFEBEB 039 rts
|
2414 |
4 |
robfinch |
;
|
2415 |
|
|
KeybdRead:
|
2416 |
16 |
robfinch |
00FFEBEC 039 rts
|
2417 |
4 |
robfinch |
;
|
2418 |
|
|
KeybdWrite:
|
2419 |
16 |
robfinch |
00FFEBED 039 rts
|
2420 |
4 |
robfinch |
|
2421 |
|
|
KeybdSeek:
|
2422 |
16 |
robfinch |
00FFEBEE 039 rts
|
2423 |
4 |
robfinch |
|
2424 |
13 |
robfinch |
;==============================================================================
|
2425 |
|
|
; Serial I/O
|
2426 |
|
|
;==============================================================================
|
2427 |
|
|
|
2428 |
|
|
; ============================================================================
|
2429 |
|
|
; __
|
2430 |
|
|
; \\__/ o\ (C) 2022 Robert Finch, Waterloo
|
2431 |
|
|
; \ __ / All rights reserved.
|
2432 |
|
|
; \/_// robfinch@opencores.org
|
2433 |
|
|
; ||
|
2434 |
|
|
;
|
2435 |
|
|
;
|
2436 |
|
|
; Serial port routines for a WDC6551 compatible circuit.
|
2437 |
|
|
;
|
2438 |
|
|
; This source file is free software: you can redistribute it and/or modify
|
2439 |
|
|
; it under the terms of the GNU Lesser General Public License as published
|
2440 |
|
|
; by the Free Software Foundation, either version 3 of the License, or
|
2441 |
|
|
; (at your option) any later version.
|
2442 |
|
|
;
|
2443 |
|
|
; This source file is distributed in the hope that it will be useful,
|
2444 |
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2445 |
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2446 |
|
|
; GNU General Public License for more details.
|
2447 |
|
|
;
|
2448 |
|
|
; You should have received a copy of the GNU General Public License
|
2449 |
|
|
; along with this program. If not, see .
|
2450 |
|
|
;
|
2451 |
|
|
; ============================================================================
|
2452 |
|
|
;
|
2453 |
4 |
robfinch |
;------------------------------------------------------------------------------
|
2454 |
13 |
robfinch |
; Initialize serial port.
|
2455 |
|
|
;
|
2456 |
|
|
; Clear buffer indexes. Two bytes are used for the buffer index even though
|
2457 |
|
|
; only a single byte is needed. This is for convenience in calculating the
|
2458 |
|
|
; number of characters in the buffer, done later. The upper byte remains at
|
2459 |
|
|
; zero.
|
2460 |
|
|
; The port is initialized for 9600 baud, 1 stop bit and 8 bits data sent.
|
2461 |
|
|
; The internal baud rate generator is used.
|
2462 |
|
|
;
|
2463 |
|
|
; Parameters:
|
2464 |
|
|
; none
|
2465 |
|
|
; Modifies:
|
2466 |
|
|
; d
|
2467 |
|
|
; Returns:
|
2468 |
|
|
; none
|
2469 |
|
|
;------------------------------------------------------------------------------
|
2470 |
|
|
|
2471 |
21 |
robfinch |
setdp $FFC
|
2472 |
|
|
|
2473 |
13 |
robfinch |
InitSerial:
|
2474 |
|
|
SerialInit:
|
2475 |
21 |
robfinch |
00FFEBEF 034008 pshs dpr
|
2476 |
|
|
00FFEBF1 086FFC lda #$FFC
|
2477 |
|
|
00FFEBF3 01F08B tfr a,dpr
|
2478 |
|
|
00FFEBF5 04F clra
|
2479 |
|
|
00FFEBF6 05F clrb
|
2480 |
|
|
00FFEBF7 00F015 clr SerHeadRcv
|
2481 |
|
|
00FFEBF9 00F016 clr SerTailRcv
|
2482 |
|
|
00FFEBFB 00F017 clr SerHeadXmit
|
2483 |
|
|
00FFEBFD 00F018 clr SerTailXmit
|
2484 |
|
|
00FFEBFF 00F019 clr SerRcvXon
|
2485 |
|
|
00FFEC01 00F01A clr SerRcvXoff
|
2486 |
|
|
00FFEC03 0150B6FFFFFFFE0 lda COREID
|
2487 |
13 |
robfinch |
sini1:
|
2488 |
21 |
robfinch |
00FFEC08 091010 cmpa IOFocusID
|
2489 |
|
|
00FFEC0A 026FFC bne sini1
|
2490 |
|
|
00FFEC0C 0C600B ldb #$0B ; dtr,rts active, rxint enabled (bit 1=0), no parity
|
2491 |
|
|
00FFEC0E 0150F7FFFE30102 stb ACIA+ACIA_CMD
|
2492 |
|
|
00FFEC13 0C601E ldb #$1E ; baud 9600, 1 stop bit, 8 bit, internal baud gen
|
2493 |
|
|
00FFEC15 0150F7FFFE30103 stb ACIA+ACIA_CTRL
|
2494 |
|
|
00FFEC1A 0C60AC ldb #$0AC ; disable fifos (bit zero, one), reset fifos
|
2495 |
|
|
00FFEC1C 0150F7FFFE3010B stb ACIA+ACIA_CTRL2
|
2496 |
|
|
00FFEC21 035088 puls dpr,pc
|
2497 |
13 |
robfinch |
|
2498 |
|
|
;------------------------------------------------------------------------------
|
2499 |
|
|
; SerialGetChar
|
2500 |
|
|
;
|
2501 |
|
|
; Check the serial port buffer to see if there's a char available. If there's
|
2502 |
|
|
; a char available then return it. If the buffer is almost empty then send an
|
2503 |
|
|
; XON.
|
2504 |
|
|
;
|
2505 |
|
|
; Stack Space:
|
2506 |
21 |
robfinch |
; 3 words
|
2507 |
13 |
robfinch |
; Parameters:
|
2508 |
|
|
; none
|
2509 |
|
|
; Modifies:
|
2510 |
|
|
; none
|
2511 |
|
|
; Returns:
|
2512 |
|
|
; d = character or -1
|
2513 |
|
|
;------------------------------------------------------------------------------
|
2514 |
|
|
|
2515 |
|
|
SerialGetChar:
|
2516 |
21 |
robfinch |
00FFEC23 034039 pshs ccr,x,y,dpr
|
2517 |
|
|
00FFEC25 086FFC lda #$FFC
|
2518 |
|
|
00FFEC27 01F08B tfr a,dpr
|
2519 |
|
|
00FFEC29 01A010 sei ; disable interrupts
|
2520 |
|
|
00FFEC2B 08D090 bsr SerialRcvCount ; check number of chars in receive buffer
|
2521 |
|
|
00FFEC2D 0C1008 cmpb #8 ; less than 8?
|
2522 |
|
|
00FFEC2F 02200C bhi sgc2
|
2523 |
|
|
00FFEC31 0D6019 ldb SerRcvXon ; skip sending XON if already sent
|
2524 |
|
|
00FFEC33 026008 bne sgc2 ; XON already sent?
|
2525 |
|
|
00FFEC35 0C6011 ldb #XON ; if <8 send an XON
|
2526 |
|
|
00FFEC37 00F01A clr SerRcvXoff ; clear XOFF status
|
2527 |
|
|
00FFEC39 0D7019 stb SerRcvXon ; flag so we don't send it multiple times
|
2528 |
|
|
00FFEC3B 08D05D bsr SerialPutChar
|
2529 |
13 |
robfinch |
sgc2:
|
2530 |
21 |
robfinch |
00FFEC3D 0D6015 ldb SerHeadRcv ; check if anything is in buffer
|
2531 |
|
|
00FFEC3F 0D1016 cmpb SerTailRcv
|
2532 |
|
|
00FFEC41 02700D beq sgcNoChars ; no?
|
2533 |
|
|
00FFEC43 03080FFFB000 leax SerRcvBuf ; x = buffer address
|
2534 |
|
|
00FFEC47 04F clra
|
2535 |
|
|
00FFEC48 0E680FFFB000 ldb b,x ; get byte from buffer
|
2536 |
|
|
00FFEC4C 00C015 inc SerHeadRcv ; 4k wrap around
|
2537 |
|
|
00FFEC4E 020003 bra sgcXit
|
2538 |
13 |
robfinch |
sgcNoChars:
|
2539 |
21 |
robfinch |
00FFEC50 0CCFFFFFF ldd #-1
|
2540 |
13 |
robfinch |
sgcXit:
|
2541 |
21 |
robfinch |
00FFEC53 0350B9 puls ccr,x,y,dpr,pc
|
2542 |
13 |
robfinch |
|
2543 |
|
|
;------------------------------------------------------------------------------
|
2544 |
|
|
; SerialPeekChar
|
2545 |
|
|
;
|
2546 |
|
|
; Check the serial port buffer to see if there's a char available. If there's
|
2547 |
|
|
; a char available then return it. But don't update the buffer indexes. No need
|
2548 |
|
|
; to send an XON here.
|
2549 |
|
|
;
|
2550 |
|
|
; Stack Space:
|
2551 |
21 |
robfinch |
; 2 words
|
2552 |
13 |
robfinch |
; Parameters:
|
2553 |
|
|
; none
|
2554 |
|
|
; Modifies:
|
2555 |
|
|
; none
|
2556 |
|
|
; Returns:
|
2557 |
|
|
; d = character or -1
|
2558 |
|
|
;------------------------------------------------------------------------------
|
2559 |
|
|
|
2560 |
|
|
SerialPeekChar:
|
2561 |
21 |
robfinch |
00FFEC55 034019 pshs x,ccr,dpr
|
2562 |
|
|
00FFEC57 086FFC lda #$FFC
|
2563 |
|
|
00FFEC59 01F08B tfr a,dpr
|
2564 |
|
|
00FFEC5B 01A010 sei
|
2565 |
|
|
00FFEC5D 0D6015 ldb SerHeadRcv ; check if anything is in buffer
|
2566 |
|
|
00FFEC5F 0D1016 cmpb SerTailRcv
|
2567 |
|
|
00FFEC61 02700B beq spcNoChars ; no?
|
2568 |
|
|
00FFEC63 03080FFFB000 leax SerRcvBuf
|
2569 |
|
|
00FFEC67 04F clra
|
2570 |
|
|
00FFEC68 0E680FFFB000 ldb b,x ; get byte from buffer
|
2571 |
|
|
00FFEC6C 020003 bra spcXit
|
2572 |
13 |
robfinch |
spcNoChars:
|
2573 |
21 |
robfinch |
00FFEC6E 0CCFFFFFF ldd #-1
|
2574 |
13 |
robfinch |
spcXit:
|
2575 |
21 |
robfinch |
00FFEC71 035099 puls x,ccr,dpr,pc
|
2576 |
13 |
robfinch |
|
2577 |
|
|
;------------------------------------------------------------------------------
|
2578 |
|
|
; SerialPeekChar
|
2579 |
|
|
; Get a character directly from the I/O port. This bypasses the input
|
2580 |
|
|
; buffer.
|
2581 |
|
|
;
|
2582 |
|
|
; Stack Space:
|
2583 |
|
|
; 0 words
|
2584 |
|
|
; Parameters:
|
2585 |
|
|
; none
|
2586 |
|
|
; Modifies:
|
2587 |
|
|
; d
|
2588 |
|
|
; Returns:
|
2589 |
|
|
; d = character or -1
|
2590 |
|
|
;------------------------------------------------------------------------------
|
2591 |
|
|
|
2592 |
|
|
SerialPeekCharDirect:
|
2593 |
21 |
robfinch |
00FFEC73 034009 pshs ccr,dpr
|
2594 |
|
|
00FFEC75 086FFC lda #$FFC
|
2595 |
|
|
00FFEC77 01F08B tfr a,dpr
|
2596 |
|
|
00FFEC79 0150B6FFFFFFFE0 lda COREID ; Ensure we have the IO Focus
|
2597 |
|
|
00FFEC7E 091010 cmpa IOFocusID
|
2598 |
|
|
00FFEC80 026013 bne spcd0001
|
2599 |
13 |
robfinch |
; Disallow interrupts between status read and rx read.
|
2600 |
21 |
robfinch |
00FFEC82 01A010 sei
|
2601 |
|
|
00FFEC84 0150F6FFFE30101 ldb ACIA+ACIA_STAT
|
2602 |
|
|
00FFEC89 0C5008 bitb #8 ; look for Rx not empty
|
2603 |
|
|
00FFEC8B 027008 beq spcd0001
|
2604 |
|
|
00FFEC8D 04F clra
|
2605 |
|
|
00FFEC8E 0150F6FFFE30100 ldb ACIA+ACIA_RX
|
2606 |
|
|
00FFEC93 035089 puls ccr,dpr,pc
|
2607 |
13 |
robfinch |
spcd0001:
|
2608 |
21 |
robfinch |
00FFEC95 0CCFFFFFF ldd #-1
|
2609 |
|
|
00FFEC98 035089 puls ccr,dpr,pc
|
2610 |
13 |
robfinch |
|
2611 |
|
|
;------------------------------------------------------------------------------
|
2612 |
|
|
; SerialPutChar
|
2613 |
|
|
; Put a character to the serial transmitter. This routine blocks until the
|
2614 |
|
|
; transmitter is empty.
|
2615 |
|
|
;
|
2616 |
|
|
; Stack Space
|
2617 |
|
|
; 0 words
|
2618 |
|
|
; Parameters:
|
2619 |
|
|
; b = character to put
|
2620 |
|
|
; Modifies:
|
2621 |
|
|
; none
|
2622 |
|
|
;------------------------------------------------------------------------------
|
2623 |
|
|
|
2624 |
|
|
SerialPutChar:
|
2625 |
21 |
robfinch |
00FFEC9A 03400B pshs a,ccr,dpr
|
2626 |
|
|
00FFEC9C 086FFC lda #$FFC
|
2627 |
|
|
00FFEC9E 01F08B tfr a,dpr
|
2628 |
13 |
robfinch |
spc0001:
|
2629 |
21 |
robfinch |
00FFECA0 0150B6FFFFFFFE0 lda COREID ; Ensure we have the IO Focus
|
2630 |
|
|
00FFECA5 091010 cmpa IOFocusID
|
2631 |
|
|
00FFECA7 026FF7 bne spc0001
|
2632 |
|
|
00FFECA9 01C0EF cli ; provide a window for an interrupt to occur
|
2633 |
|
|
00FFECAB 01A010 sei
|
2634 |
13 |
robfinch |
; Between the status read and the transmit do not allow an
|
2635 |
|
|
; intervening interrupt.
|
2636 |
21 |
robfinch |
00FFECAD 0150B6FFFE30101 lda ACIA+ACIA_STAT ; wait until the uart indicates tx empty
|
2637 |
|
|
00FFECB2 085010 bita #16 ; bit #4 of the status reg
|
2638 |
|
|
00FFECB4 027FEA beq spc0001 ; branch if transmitter is not empty
|
2639 |
|
|
00FFECB6 0150F7FFFE30100 stb ACIA+ACIA_TX ; send the byte
|
2640 |
|
|
00FFECBB 03508B puls a,ccr,dpr,pc
|
2641 |
13 |
robfinch |
|
2642 |
|
|
;------------------------------------------------------------------------------
|
2643 |
21 |
robfinch |
; Calculate number of character in input buffer. Direct page must be set
|
2644 |
|
|
; already.
|
2645 |
13 |
robfinch |
;
|
2646 |
|
|
; Parameters:
|
2647 |
21 |
robfinch |
; none
|
2648 |
13 |
robfinch |
; Returns:
|
2649 |
|
|
; d = number of bytes in buffer.
|
2650 |
|
|
;------------------------------------------------------------------------------
|
2651 |
|
|
|
2652 |
|
|
SerialRcvCount:
|
2653 |
21 |
robfinch |
00FFECBD 04F clra
|
2654 |
|
|
00FFECBE 0D6016 ldb SerTailRcv
|
2655 |
|
|
00FFECC0 0D0015 subb SerHeadRcv
|
2656 |
|
|
00FFECC2 02C007 bge srcXit
|
2657 |
|
|
00FFECC4 0CC001000 ldd #$1000
|
2658 |
|
|
00FFECC7 093015 subd SerHeadRcv
|
2659 |
|
|
00FFECC9 0D3016 addd SerTailRcv
|
2660 |
13 |
robfinch |
srcXit:
|
2661 |
21 |
robfinch |
00FFECCB 039 rts
|
2662 |
13 |
robfinch |
|
2663 |
|
|
;------------------------------------------------------------------------------
|
2664 |
|
|
; Serial IRQ routine
|
2665 |
|
|
;
|
2666 |
|
|
; Keeps looping as long as it finds characters in the ACIA recieve buffer/fifo.
|
2667 |
|
|
; Received characters are buffered. If the buffer becomes full, new characters
|
2668 |
|
|
; will be lost.
|
2669 |
|
|
;
|
2670 |
|
|
; Parameters:
|
2671 |
|
|
; none
|
2672 |
|
|
; Modifies:
|
2673 |
|
|
; d,x
|
2674 |
|
|
; Returns:
|
2675 |
|
|
; none
|
2676 |
|
|
;------------------------------------------------------------------------------
|
2677 |
|
|
|
2678 |
|
|
SerialIRQ:
|
2679 |
21 |
robfinch |
00FFECCC 034008 pshs dpr ; set direct page register to boot variables
|
2680 |
|
|
00FFECCE 086FFC lda #$FFC
|
2681 |
|
|
00FFECD0 01F08B tfr a,dpr
|
2682 |
|
|
00FFECD2 0150B6FFFE3F0D3 lda PIC+$D3 ; Serial active interrupt flag
|
2683 |
|
|
00FFECD7 027042 beq notSerInt
|
2684 |
13 |
robfinch |
sirqNxtByte:
|
2685 |
21 |
robfinch |
00FFECD9 0150F6FFFE30104 ldb ACIA+ACIA_IRQS ; look for IRQs
|
2686 |
|
|
00FFECDE 02A03B bpl notSerInt ; quick test for any irqs
|
2687 |
|
|
00FFECE0 0150F6FFFE30101 ldb ACIA+ACIA_STAT ; check the status
|
2688 |
|
|
00FFECE5 0C5008 bitb #$08 ; bit 3 = rx full (not empty)
|
2689 |
|
|
00FFECE7 027030 beq notRxInt1
|
2690 |
|
|
00FFECE9 0150F6FFFE30100 ldb ACIA+ACIA_RX ; get data from Rx buffer to clear interrupt
|
2691 |
|
|
00FFECEE 096016 lda SerTailRcv ; check if recieve buffer full
|
2692 |
|
|
00FFECF0 04C inca
|
2693 |
|
|
00FFECF1 091015 cmpa SerHeadRcv
|
2694 |
|
|
00FFECF3 027026 beq sirqRxFull
|
2695 |
|
|
00FFECF5 097016 sta SerTailRcv ; update tail pointer
|
2696 |
|
|
00FFECF7 04A deca ; backup
|
2697 |
|
|
00FFECF8 01E089 exg a,b
|
2698 |
|
|
00FFECFA 03080FFFB000 leax SerRcvBuf ; x = buffer address
|
2699 |
|
|
00FFECFE 0A780FFFB000 sta b,x ; store recieved byte in buffer
|
2700 |
|
|
00FFED02 00D01A tst SerRcvXoff ; check if xoff already sent
|
2701 |
|
|
00FFED04 026FD3 bne sirqNxtByte
|
2702 |
|
|
00FFED06 08DFB5 bsr SerialRcvCount ; if more than 4070 chars in buffer
|
2703 |
|
|
00FFED08 0C1FE6 cmpb #4070
|
2704 |
|
|
00FFED0A 025FCD blo sirqNxtByte
|
2705 |
|
|
00FFED0C 0C6013 ldb #XOFF ; send an XOFF
|
2706 |
|
|
00FFED0E 00F019 clr SerRcvXon ; clear XON status
|
2707 |
|
|
00FFED10 0D701A stb SerRcvXoff ; set XOFF status
|
2708 |
|
|
00FFED12 0150F7FFFE30100 stb ACIA+ACIA_TX
|
2709 |
|
|
00FFED17 020FC0 bra sirqNxtByte ; check the status for another byte
|
2710 |
|
|
; Process other serial IRQs
|
2711 |
|
|
notRxInt1:
|
2712 |
|
|
00FFED19 035088 puls dpr,pc
|
2713 |
13 |
robfinch |
sirqRxFull:
|
2714 |
|
|
notRxInt:
|
2715 |
21 |
robfinch |
notSerInt:
|
2716 |
|
|
00FFED1B 035088 puls dpr,pc
|
2717 |
13 |
robfinch |
|
2718 |
|
|
nmeSerial:
|
2719 |
21 |
robfinch |
00FFED1D 05306507206906106C000 fcb "Serial",0
|
2720 |
13 |
robfinch |
|
2721 |
|
|
;------------------------------------------------------------------------------
|
2722 |
|
|
; Put a string to the serial port.
|
2723 |
|
|
;
|
2724 |
|
|
; Parameters:
|
2725 |
|
|
; d = pointer to string
|
2726 |
|
|
; Modifies:
|
2727 |
|
|
; none
|
2728 |
|
|
; Returns:
|
2729 |
|
|
; none
|
2730 |
|
|
;------------------------------------------------------------------------------
|
2731 |
|
|
|
2732 |
|
|
SerialPutString:
|
2733 |
21 |
robfinch |
00FFED24 034016 pshs d,x
|
2734 |
|
|
00FFED26 01F001 tfr d,x
|
2735 |
13 |
robfinch |
sps2:
|
2736 |
21 |
robfinch |
00FFED28 0E6804 ldb ,x
|
2737 |
|
|
00FFED2A 027006 beq spsXit
|
2738 |
|
|
00FFED2C 030001 inx
|
2739 |
|
|
00FFED2E 08DF6A bsr SerialPutChar
|
2740 |
|
|
00FFED30 020FF6 bra sps2
|
2741 |
13 |
robfinch |
spsXit:
|
2742 |
21 |
robfinch |
00FFED32 035096 puls d,x,pc
|
2743 |
13 |
robfinch |
|
2744 |
|
|
;------------------------------------------------------------------------------
|
2745 |
|
|
; A little routine to test serial output.
|
2746 |
|
|
;
|
2747 |
|
|
; Parameters:
|
2748 |
|
|
; none
|
2749 |
|
|
; Modifies:
|
2750 |
|
|
; none
|
2751 |
|
|
; Returns:
|
2752 |
|
|
; none
|
2753 |
|
|
;------------------------------------------------------------------------------
|
2754 |
|
|
|
2755 |
|
|
SerialOutputTest:
|
2756 |
21 |
robfinch |
00FFED34 034006 pshs d
|
2757 |
|
|
00FFED36 0CCFFED54 ldd #msgSerialTest
|
2758 |
|
|
00FFED39 017FFF6A1 lbsr DisplayString
|
2759 |
13 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
2760 |
21 |
robfinch |
00FFED3C 08DEB1 bsr SerialInit
|
2761 |
13 |
robfinch |
sotst1:
|
2762 |
21 |
robfinch |
00FFED3E 0C6011 ldb #XON
|
2763 |
|
|
00FFED40 08DF58 bsr SerialPutChar
|
2764 |
|
|
00FFED42 08DF56 bsr SerialPutChar
|
2765 |
|
|
00FFED44 08DF54 bsr SerialPutChar
|
2766 |
|
|
00FFED46 0CCFFED54 ldd #msgSerialTest
|
2767 |
|
|
00FFED49 08DFD9 bsr SerialPutString
|
2768 |
|
|
00FFED4B 017000443 lbsr INCH
|
2769 |
|
|
00FFED4E 0C1003 cmpb #CTRLC
|
2770 |
|
|
00FFED50 026FEC bne sotst1
|
2771 |
|
|
00FFED52 035086 puls d,pc
|
2772 |
13 |
robfinch |
|
2773 |
|
|
msgSerialTest:
|
2774 |
21 |
robfinch |
00FFED54 05306507206906106C020 fcb "Serial port test",CR,LF,0
|
2775 |
|
|
00FFED5B 07006F072074020074065
|
2776 |
|
|
00FFED62 07307400D00A000
|
2777 |
13 |
robfinch |
|
2778 |
21 |
robfinch |
setdp $000
|
2779 |
16 |
robfinch |
; ============================================================================
|
2780 |
|
|
; __
|
2781 |
|
|
; \\__/ o\ (C) 2022 Robert Finch, Waterloo
|
2782 |
|
|
; \ __ / All rights reserved.
|
2783 |
|
|
; \/_// robfinch@opencores.org
|
2784 |
|
|
; ||
|
2785 |
|
|
;
|
2786 |
|
|
;
|
2787 |
|
|
; BSD 3-Clause License
|
2788 |
|
|
; Redistribution and use in source and binary forms, with or without
|
2789 |
|
|
; modification, are permitted provided that the following conditions are met:
|
2790 |
|
|
;
|
2791 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
2792 |
|
|
; list of conditions and the following disclaimer.
|
2793 |
|
|
;
|
2794 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
2795 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
2796 |
|
|
; and/or other materials provided with the distribution.
|
2797 |
|
|
;
|
2798 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
2799 |
|
|
; contributors may be used to endorse or promote products derived from
|
2800 |
|
|
; this software without specific prior written permission.
|
2801 |
|
|
;
|
2802 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
2803 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
2804 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
2805 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
2806 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
2807 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
2808 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
2809 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
2810 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2811 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2812 |
|
|
;
|
2813 |
|
|
; ============================================================================
|
2814 |
|
|
;
|
2815 |
21 |
robfinch |
; S19 variables
|
2816 |
|
|
;
|
2817 |
16 |
robfinch |
s19Address EQU $940 ; to $943
|
2818 |
|
|
s19StartAddress EQU $944 ; to $947
|
2819 |
|
|
s19Rectype EQU $948
|
2820 |
|
|
s19Reclen EQU $949
|
2821 |
|
|
s19Abort EQU $94A
|
2822 |
21 |
robfinch |
s19Checksum EQU $94B
|
2823 |
|
|
s19SummaryChecksum EQU $94C
|
2824 |
|
|
s19Source EQU $94E
|
2825 |
|
|
s19XferAddress EQU $950 ; to $951
|
2826 |
13 |
robfinch |
|
2827 |
16 |
robfinch |
; ------------------------------------------------------------------------------
|
2828 |
21 |
robfinch |
; Input a character either from a file in memory or from the serial port.
|
2829 |
|
|
;
|
2830 |
|
|
; Parameters:
|
2831 |
|
|
; none
|
2832 |
|
|
; Returns:
|
2833 |
|
|
; accb = character input
|
2834 |
|
|
; ------------------------------------------------------------------------------
|
2835 |
|
|
|
2836 |
|
|
s19InputChar:
|
2837 |
|
|
00FFED67 07D00094E tst s19Source
|
2838 |
|
|
00FFED6A 02700D beq s19ic1
|
2839 |
|
|
00FFED6C 0E690F000950 ldb [s19XferAddress]
|
2840 |
|
|
00FFED70 07C000951 inc s19XferAddress+1 ; increment low byte of address pointer
|
2841 |
|
|
00FFED73 026003 bne s19ic2
|
2842 |
|
|
00FFED75 07C000950 inc s19XferAddress ; increment high byte of address pointer
|
2843 |
|
|
s19ic2:
|
2844 |
|
|
00FFED78 039 rts
|
2845 |
|
|
s19ic1:
|
2846 |
|
|
00FFED79 0CCFFFFFF ldd #-1 ; block until input is available
|
2847 |
|
|
00FFED7C 03F swi
|
2848 |
|
|
00FFED7D 001 fcb MF_INCH ; monitor input rout
|
2849 |
|
|
00FFED7E 039 rts
|
2850 |
|
|
|
2851 |
|
|
; ------------------------------------------------------------------------------
|
2852 |
16 |
robfinch |
; Skip over input to the next record.
|
2853 |
|
|
; ------------------------------------------------------------------------------
|
2854 |
|
|
|
2855 |
|
|
s19NextRecord:
|
2856 |
21 |
robfinch |
00FFED7F 08DFE6 bsr s19InputChar
|
2857 |
|
|
00FFED81 0C100A cmpb #LF ; line feed marks end of record
|
2858 |
|
|
00FFED83 027013 beq s19nr1
|
2859 |
|
|
00FFED85 0C1003 cmpb #CTRLC ; should not get this in a file transfer
|
2860 |
|
|
00FFED87 026003 bne s19nr2
|
2861 |
|
|
00FFED89 0F700094A stb s19Abort
|
2862 |
16 |
robfinch |
s19nr2:
|
2863 |
21 |
robfinch |
00FFED8C 0C101A cmpb #CTRLZ ; end of file marker?
|
2864 |
|
|
00FFED8E 026003 bne s19nr3
|
2865 |
|
|
00FFED90 0F700094A stb s19Abort
|
2866 |
16 |
robfinch |
s19nr3:
|
2867 |
21 |
robfinch |
00FFED93 07D00094A tst s19Abort
|
2868 |
|
|
00FFED96 027FE7 beq s19NextRecord
|
2869 |
16 |
robfinch |
s19nr1:
|
2870 |
21 |
robfinch |
00FFED98 039 rts
|
2871 |
16 |
robfinch |
|
2872 |
|
|
; ------------------------------------------------------------------------------
|
2873 |
21 |
robfinch |
; Update the checksum.
|
2874 |
|
|
; ------------------------------------------------------------------------------
|
2875 |
|
|
|
2876 |
|
|
s19AddCheck:
|
2877 |
|
|
00FFED99 034004 pshs b
|
2878 |
|
|
00FFED9B 0FB00094B addb s19Checksum
|
2879 |
|
|
00FFED9E 0F700094B stb s19Checksum
|
2880 |
|
|
00FFEDA1 035084 puls b,pc
|
2881 |
|
|
|
2882 |
|
|
; ------------------------------------------------------------------------------
|
2883 |
16 |
robfinch |
; Input a byte. There are three characters per byte since things are 12-bit.
|
2884 |
|
|
;
|
2885 |
|
|
; Parameters:
|
2886 |
|
|
; none
|
2887 |
|
|
; Returns:
|
2888 |
|
|
; accb = byte value converted from text
|
2889 |
|
|
; ------------------------------------------------------------------------------
|
2890 |
|
|
|
2891 |
|
|
s19GetByte:
|
2892 |
21 |
robfinch |
00FFEDA3 08DFC2 bsr s19InputChar ; get the first character
|
2893 |
|
|
00FFEDA5 0170007F7 lbsr AsciiToHexNybble ; convert to nybble
|
2894 |
|
|
00FFEDA8 07D00094A tst s19Abort ; check for abort
|
2895 |
|
|
00FFEDAB 027002 beq s19gb1
|
2896 |
|
|
00FFEDAD 04F clra
|
2897 |
|
|
00FFEDAE 039 rts
|
2898 |
16 |
robfinch |
s19gb1: ; shift the value four bits
|
2899 |
21 |
robfinch |
00FFEDAF 058 aslb
|
2900 |
|
|
00FFEDB0 058 aslb
|
2901 |
|
|
00FFEDB1 058 aslb
|
2902 |
|
|
00FFEDB2 058 aslb
|
2903 |
|
|
00FFEDB3 034004 pshs b ; save off value
|
2904 |
|
|
00FFEDB5 08DFB0 bsr s19InputChar ; get the second character
|
2905 |
|
|
00FFEDB7 0170007E5 lbsr AsciiToHexNybble ; convert to nybble
|
2906 |
|
|
00FFEDBA 07D00094A tst s19Abort ; check for abort
|
2907 |
|
|
00FFEDBD 026011 bne s19gb2
|
2908 |
|
|
00FFEDBF 0EAE00 orb ,s+ ; merge new nybble into value
|
2909 |
|
|
00FFEDC1 058 aslb ; shift the value four more bits
|
2910 |
|
|
00FFEDC2 058 aslb
|
2911 |
|
|
00FFEDC3 058 aslb
|
2912 |
|
|
00FFEDC4 058 aslb
|
2913 |
|
|
00FFEDC5 034004 pshs b ; save off value
|
2914 |
|
|
00FFEDC7 08DF9E bsr s19InputChar ; get the third character
|
2915 |
|
|
00FFEDC9 0170007D3 lbsr AsciiToHexNybble ; convert to nybble
|
2916 |
|
|
00FFEDCC 0EAE00 orb ,s+ ; merge in value
|
2917 |
|
|
00FFEDCE 04F clra ; make byte 000 to FFF in D
|
2918 |
|
|
00FFEDCF 039 rts
|
2919 |
16 |
robfinch |
s19gb2:
|
2920 |
21 |
robfinch |
00FFEDD0 032601 leas 1,s ; discard saved byte
|
2921 |
|
|
00FFEDD2 04F clra
|
2922 |
|
|
00FFEDD3 039 rts
|
2923 |
16 |
robfinch |
|
2924 |
|
|
; ------------------------------------------------------------------------------
|
2925 |
|
|
; Zero out address
|
2926 |
|
|
; ------------------------------------------------------------------------------
|
2927 |
|
|
|
2928 |
|
|
s19ClearAddress:
|
2929 |
21 |
robfinch |
00FFEDD4 07F000940 clr s19Address
|
2930 |
|
|
00FFEDD7 07F000941 clr s19Address+1
|
2931 |
|
|
00FFEDDA 07F000942 clr s19Address+2
|
2932 |
|
|
00FFEDDD 07F000943 clr s19Address+3
|
2933 |
|
|
00FFEDE0 039 rts
|
2934 |
16 |
robfinch |
|
2935 |
|
|
; ------------------------------------------------------------------------------
|
2936 |
|
|
; Get an address composed of two bytes (24 bit)
|
2937 |
|
|
;
|
2938 |
|
|
; Side Effects:
|
2939 |
|
|
; updates s19Address variable
|
2940 |
|
|
; Returns:
|
2941 |
|
|
; none
|
2942 |
|
|
; ------------------------------------------------------------------------------
|
2943 |
|
|
|
2944 |
|
|
s19GetAddress2:
|
2945 |
21 |
robfinch |
00FFEDE1 08DFF1 bsr s19ClearAddress
|
2946 |
|
|
00FFEDE3 08DFBE bsr s19GetByte
|
2947 |
|
|
00FFEDE5 08DFB2 bsr s19AddCheck
|
2948 |
|
|
00FFEDE7 0F7000942 stb s19Address+2
|
2949 |
|
|
00FFEDEA 07D00094A tst s19Abort
|
2950 |
|
|
00FFEDED 026007 bne s19ga1
|
2951 |
|
|
00FFEDEF 08DFB2 bsr s19GetByte
|
2952 |
|
|
00FFEDF1 08DFA6 bsr s19AddCheck
|
2953 |
|
|
00FFEDF3 0F7000943 stb s19Address+3
|
2954 |
16 |
robfinch |
s19ga1:
|
2955 |
21 |
robfinch |
00FFEDF6 039 rts
|
2956 |
16 |
robfinch |
|
2957 |
|
|
; ------------------------------------------------------------------------------
|
2958 |
|
|
; Get an address composed of three bytes (36 bit)
|
2959 |
|
|
;
|
2960 |
|
|
; Side Effects:
|
2961 |
|
|
; updates s19Address variable
|
2962 |
|
|
; Returns:
|
2963 |
|
|
; none
|
2964 |
|
|
; ------------------------------------------------------------------------------
|
2965 |
|
|
|
2966 |
|
|
s19GetAddress3:
|
2967 |
21 |
robfinch |
00FFEDF7 08DFDB bsr s19ClearAddress
|
2968 |
|
|
00FFEDF9 08DFA8 bsr s19GetByte
|
2969 |
|
|
00FFEDFB 08DF9C bsr s19AddCheck
|
2970 |
|
|
00FFEDFD 0F7000941 stb s19Address+1
|
2971 |
|
|
00FFEE00 07D00094A tst s19Abort
|
2972 |
|
|
00FFEE03 026013 bne s19ga2
|
2973 |
|
|
00FFEE05 08DF9C bsr s19GetByte
|
2974 |
|
|
00FFEE07 08DF90 bsr s19AddCheck
|
2975 |
|
|
00FFEE09 0F7000942 stb s19Address+2
|
2976 |
|
|
00FFEE0C 07D00094A tst s19Abort
|
2977 |
|
|
00FFEE0F 026007 bne s19ga2
|
2978 |
|
|
00FFEE11 08DF90 bsr s19GetByte
|
2979 |
|
|
00FFEE13 08DF84 bsr s19AddCheck
|
2980 |
|
|
00FFEE15 0F7000943 stb s19Address+3
|
2981 |
16 |
robfinch |
s19ga2:
|
2982 |
21 |
robfinch |
00FFEE18 039 rts
|
2983 |
16 |
robfinch |
|
2984 |
|
|
; ------------------------------------------------------------------------------
|
2985 |
|
|
; Put a byte to memory.
|
2986 |
|
|
; ------------------------------------------------------------------------------
|
2987 |
|
|
|
2988 |
|
|
s19PutMem:
|
2989 |
21 |
robfinch |
00FFEE19 05F clrb ; accb = current byte count
|
2990 |
16 |
robfinch |
s19pm3:
|
2991 |
21 |
robfinch |
00FFEE1A 034004 pshs b ; save byte count
|
2992 |
|
|
00FFEE1C 08DF85 bsr s19GetByte
|
2993 |
|
|
00FFEE1E 08DF79 bsr s19AddCheck
|
2994 |
|
|
00FFEE20 07D00094A tst s19Abort
|
2995 |
|
|
00FFEE23 02601E bne s19pm1
|
2996 |
|
|
00FFEE25 0150E790F000941 stb far [s19Address+1] ; store the byte using far addressing
|
2997 |
|
|
00FFEE2A 07C000943 inc s19Address+3
|
2998 |
|
|
00FFEE2D 026008 bne s19pm2
|
2999 |
|
|
00FFEE2F 07C000942 inc s19Address+2
|
3000 |
|
|
00FFEE32 026003 bne s19pm2
|
3001 |
|
|
00FFEE34 07C000941 inc s19Address+1
|
3002 |
16 |
robfinch |
s19pm2:
|
3003 |
21 |
robfinch |
00FFEE37 035004 puls b ; get back byte count
|
3004 |
|
|
00FFEE39 05C incb ; increment and
|
3005 |
|
|
00FFEE3A 0F1000949 cmpb s19Reclen ; compare to record length
|
3006 |
|
|
00FFEE3D 025FDB blo s19pm3
|
3007 |
|
|
00FFEE3F 08DF62 bsr s19GetByte ; get the checksum byte
|
3008 |
|
|
00FFEE41 020F56 bra s19AddCheck
|
3009 |
16 |
robfinch |
s19pm1:
|
3010 |
21 |
robfinch |
00FFEE43 032601 leas 1,s ; faster than actual pull
|
3011 |
|
|
00FFEE45 08DF5C bsr s19GetByte ; get the checksum byte
|
3012 |
|
|
00FFEE47 020F50 bra s19AddCheck
|
3013 |
16 |
robfinch |
|
3014 |
|
|
; ------------------------------------------------------------------------------
|
3015 |
|
|
; Processing for S1 record type.
|
3016 |
|
|
; ------------------------------------------------------------------------------
|
3017 |
|
|
|
3018 |
|
|
s19ProcessS1:
|
3019 |
21 |
robfinch |
00FFEE49 08DF96 bsr s19GetAddress2
|
3020 |
|
|
00FFEE4B 08DFCC bsr s19PutMem
|
3021 |
|
|
00FFEE4D 07D00094B tst s19Checksum
|
3022 |
|
|
00FFEE50 027008 beq s19p11
|
3023 |
|
|
00FFEE52 07C00094C inc s19SummaryChecksum
|
3024 |
|
|
00FFEE55 0CCFFEF19 ldd #msgChecksumErr
|
3025 |
|
|
00FFEE58 03F swi
|
3026 |
|
|
00FFEE59 004 fcb MF_DisplayString
|
3027 |
|
|
s19p11:
|
3028 |
|
|
00FFEE5A 020099 bra s19lnr
|
3029 |
16 |
robfinch |
|
3030 |
|
|
; ------------------------------------------------------------------------------
|
3031 |
|
|
; Processing for S2 record type.
|
3032 |
|
|
; ------------------------------------------------------------------------------
|
3033 |
|
|
|
3034 |
|
|
s19ProcessS2:
|
3035 |
21 |
robfinch |
00FFEE5C 08DF99 bsr s19GetAddress3
|
3036 |
|
|
00FFEE5E 08DFB9 bsr s19PutMem
|
3037 |
|
|
00FFEE60 07D00094B tst s19Checksum
|
3038 |
|
|
00FFEE63 027008 beq s19p21
|
3039 |
|
|
00FFEE65 07C00094C inc s19SummaryChecksum
|
3040 |
|
|
00FFEE68 0CCFFEF19 ldd #msgChecksumErr
|
3041 |
|
|
00FFEE6B 03F swi
|
3042 |
|
|
00FFEE6C 004 fcb MF_DisplayString
|
3043 |
|
|
s19p21:
|
3044 |
|
|
00FFEE6D 020086 bra s19lnr
|
3045 |
16 |
robfinch |
|
3046 |
|
|
; S3,4,5,6 not processed
|
3047 |
|
|
|
3048 |
|
|
; ------------------------------------------------------------------------------
|
3049 |
|
|
; Processing for S7 record type. Gets a two byte (24 bit) start address.
|
3050 |
|
|
; ------------------------------------------------------------------------------
|
3051 |
|
|
|
3052 |
|
|
s19ProcessS9:
|
3053 |
21 |
robfinch |
00FFEE6F 08DF70 bsr s19GetAddress2
|
3054 |
|
|
00FFEE71 0FC000942 ldd s19Address+2
|
3055 |
|
|
00FFEE74 0FD000946 std s19StartAddress+2
|
3056 |
|
|
00FFEE77 0FC000940 ldd s19Address+0
|
3057 |
|
|
00FFEE7A 0FD000944 std s19StartAddress+0
|
3058 |
|
|
00FFEE7D 020083 bra s19l2
|
3059 |
16 |
robfinch |
|
3060 |
|
|
; ------------------------------------------------------------------------------
|
3061 |
|
|
; Processing for S8 record type. Gets a three byte (36 bit) start address.
|
3062 |
|
|
; ------------------------------------------------------------------------------
|
3063 |
|
|
|
3064 |
|
|
s19ProcessS8:
|
3065 |
21 |
robfinch |
00FFEE7F 08DF76 bsr s19GetAddress3
|
3066 |
|
|
00FFEE81 0FC000942 ldd s19Address+2
|
3067 |
|
|
00FFEE84 0FD000946 std s19StartAddress+2
|
3068 |
|
|
00FFEE87 0FC000940 ldd s19Address+0
|
3069 |
|
|
00FFEE8A 0FD000944 std s19StartAddress+0
|
3070 |
|
|
00FFEE8D 020073 bra s19l2
|
3071 |
16 |
robfinch |
|
3072 |
|
|
; ------------------------------------------------------------------------------
|
3073 |
|
|
; S19 Loader
|
3074 |
|
|
;
|
3075 |
|
|
; Not all record types are processed. Some are skipped over.
|
3076 |
|
|
; ------------------------------------------------------------------------------
|
3077 |
|
|
|
3078 |
|
|
S19Loader:
|
3079 |
21 |
robfinch |
00FFEE8F 07F00094E clr s19Source
|
3080 |
|
|
00FFEE92 0170006FC lbsr GetNumber ; check for a file storage address
|
3081 |
|
|
00FFEE95 05D tstb
|
3082 |
|
|
00FFEE96 027009 beq s19l4 ; if not a memory file
|
3083 |
|
|
00FFEE98 07C00094E inc s19Source ; set flag indicating a memory file
|
3084 |
|
|
00FFEE9B 0FC000912 ldd mon_numwka+2 ; set transfer address variable
|
3085 |
|
|
00FFEE9E 0FD000950 std s19XferAddress
|
3086 |
|
|
s19l4:
|
3087 |
|
|
00FFEEA1 07F00094A clr s19Abort ; clear the abort flag
|
3088 |
|
|
00FFEEA4 0CCFFEF05 ldd #msgS19Loader ; signon banner
|
3089 |
|
|
00FFEEA7 03F swi
|
3090 |
|
|
00FFEEA8 004 fcb MF_DisplayString
|
3091 |
|
|
00FFEEA9 07F00094C clr s19SummaryChecksum
|
3092 |
16 |
robfinch |
s19l3:
|
3093 |
21 |
robfinch |
00FFEEAC 08DEB9 bsr s19InputChar ; get a character from input
|
3094 |
|
|
00FFEEAE 0C101A cmpb #CTRLZ ; is it CTRL-Z?
|
3095 |
|
|
00FFEEB0 027050 beq s19l2
|
3096 |
|
|
00FFEEB2 07F00094B clr s19Checksum
|
3097 |
|
|
00FFEEB5 0C1043 cmpb #'C' ; records must start with the letter C
|
3098 |
|
|
00FFEEB7 02603C bne s19lnr
|
3099 |
|
|
00FFEEB9 08DEAC bsr s19InputChar ; get the next character
|
3100 |
|
|
00FFEEBB 0C1030 cmpb #'0' ; must be a numeric digit
|
3101 |
|
|
00FFEEBD 025036 blo s19lnr
|
3102 |
|
|
00FFEEBF 0C1039 cmpb #'9'
|
3103 |
|
|
00FFEEC1 022032 bhi s19lnr
|
3104 |
|
|
00FFEEC3 0F7000948 stb s19Rectype ; save off in record type
|
3105 |
|
|
00FFEEC6 08DEDB bsr s19GetByte ; get a byte indicating record length
|
3106 |
|
|
00FFEEC8 08DECF bsr s19AddCheck
|
3107 |
|
|
00FFEECA 0F7000949 stb s19Reclen
|
3108 |
|
|
00FFEECD 07D00094A tst s19Abort ; check for abort
|
3109 |
|
|
00FFEED0 026030 bne s19l2
|
3110 |
|
|
00FFEED2 0F6000948 ldb s19Rectype ; process according to record type
|
3111 |
|
|
00FFEED5 0C1030 cmpb #'0'
|
3112 |
|
|
00FFEED7 02701C beq s19lnr
|
3113 |
|
|
00FFEED9 0C1031 cmpb #'1'
|
3114 |
|
|
00FFEEDB 027F6C beq s19ProcessS1 ; data record with a two byte address
|
3115 |
|
|
00FFEEDD 0C1032 cmpb #'2'
|
3116 |
|
|
00FFEEDF 027F7B beq s19ProcessS2 ; data record with a three byte address
|
3117 |
|
|
00FFEEE1 0C1033 cmpb #'3'
|
3118 |
|
|
00FFEEE3 027010 beq s19lnr
|
3119 |
|
|
00FFEEE5 0C1035 cmpb #'5' ; record count? ignore
|
3120 |
|
|
00FFEEE7 02700C beq s19lnr
|
3121 |
|
|
00FFEEE9 0C1037 cmpb #'7' ; ignore record with 48 bit address
|
3122 |
|
|
00FFEEEB 027015 beq s19l2
|
3123 |
|
|
00FFEEED 0C1038 cmpb #'8'
|
3124 |
|
|
00FFEEEF 027F8E beq s19ProcessS8 ; two byte start address
|
3125 |
|
|
00FFEEF1 0C1039 cmpb #'9'
|
3126 |
|
|
00FFEEF3 027F7A beq s19ProcessS9 ; three byte start address
|
3127 |
16 |
robfinch |
s19lnr:
|
3128 |
21 |
robfinch |
00FFEEF5 0C602E ldb #'.' ; output a progress indicator
|
3129 |
|
|
00FFEEF7 03F swi
|
3130 |
|
|
00FFEEF8 002 fcb MF_OUTCH
|
3131 |
|
|
00FFEEF9 08DE84 bsr s19NextRecord ; skip to the next record
|
3132 |
|
|
00FFEEFB 07D00094A tst S19Abort ; check for abort
|
3133 |
|
|
00FFEEFE 026002 bne s19l2
|
3134 |
|
|
00FFEF00 020FAA bra s19l3 ; loop back to process more records
|
3135 |
16 |
robfinch |
s19l2:
|
3136 |
21 |
robfinch |
00FFEF02 016000457 lbra Monitor
|
3137 |
16 |
robfinch |
|
3138 |
|
|
msgS19Loader:
|
3139 |
21 |
robfinch |
00FFEF05 05303103902004C06F061 fcb "S19 Loader Active",CR,LF,0
|
3140 |
|
|
00FFEF0C 064065072020041063074
|
3141 |
|
|
00FFEF13 06907606500D00A000
|
3142 |
|
|
msgChecksumErr:
|
3143 |
|
|
00FFEF19 053031039020043068065 fcb "S19 Checksum Err",CR,LF,0
|
3144 |
|
|
00FFEF20 06306B07307506D020045
|
3145 |
|
|
00FFEF27 07207200D00A000
|
3146 |
16 |
robfinch |
|
3147 |
|
|
|
3148 |
21 |
robfinch |
; ============================================================================
|
3149 |
|
|
; __
|
3150 |
|
|
; \\__/ o\ (C) 2022 Robert Finch, Waterloo
|
3151 |
|
|
; \ __ / All rights reserved.
|
3152 |
|
|
; \/_// robfinch@opencores.org
|
3153 |
|
|
; ||
|
3154 |
|
|
;
|
3155 |
|
|
;
|
3156 |
|
|
; BSD 3-Clause License
|
3157 |
|
|
; Redistribution and use in source and binary forms, with or without
|
3158 |
|
|
; modification, are permitted provided that the following conditions are met:
|
3159 |
|
|
;
|
3160 |
|
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
3161 |
|
|
; list of conditions and the following disclaimer.
|
3162 |
|
|
;
|
3163 |
|
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
3164 |
|
|
; this list of conditions and the following disclaimer in the documentation
|
3165 |
|
|
; and/or other materials provided with the distribution.
|
3166 |
|
|
;
|
3167 |
|
|
; 3. Neither the name of the copyright holder nor the names of its
|
3168 |
|
|
; contributors may be used to endorse or promote products derived from
|
3169 |
|
|
; this software without specific prior written permission.
|
3170 |
|
|
;
|
3171 |
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
3172 |
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
3173 |
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
3174 |
|
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
3175 |
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
3176 |
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
3177 |
|
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
3178 |
|
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
3179 |
|
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
3180 |
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
3181 |
|
|
;
|
3182 |
|
|
; ============================================================================
|
3183 |
|
|
;
|
3184 |
|
|
; Xmodem variables
|
3185 |
|
|
;
|
3186 |
|
|
xm_timer EQU $FFC020
|
3187 |
|
|
xm_protocol EQU $9F5
|
3188 |
|
|
xm_flag EQU $9F6
|
3189 |
|
|
xm_checksum EQU $9F7
|
3190 |
|
|
xm_tmp2 EQU $9F8
|
3191 |
|
|
xm_packetnum EQU $9FA
|
3192 |
|
|
xm_tmp EQU $9FC
|
3193 |
|
|
xm_crc EQU $9FE
|
3194 |
|
|
xm_ibuf EQU $A00 ; to $A7F
|
3195 |
|
|
xm_obuf EQU $A80 ; to $AFF
|
3196 |
16 |
robfinch |
|
3197 |
21 |
robfinch |
; ------------------------------------------------------------------------------
|
3198 |
|
|
; Send data using XModem.
|
3199 |
|
|
; ------------------------------------------------------------------------------
|
3200 |
|
|
|
3201 |
|
|
xm_SendStart:
|
3202 |
|
|
00FFEF2C 0170005A3 lbsr GetRange
|
3203 |
|
|
00FFEF2F 0BE000922 ldx mon_r1+2 ; x = buffer address
|
3204 |
|
|
00FFEF32 01F013 tfr x,u
|
3205 |
|
|
00FFEF34 0C6001 ldb #1 ; packet numbers start at one
|
3206 |
|
|
00FFEF36 0F70009FB stb xm_packetnum+1
|
3207 |
|
|
; Wait for receiver to send a NAK
|
3208 |
|
|
xm_send:
|
3209 |
|
|
00FFEF39 0CCFFFFFF ldd #-1 ; select blocking input
|
3210 |
|
|
00FFEF3C 03F swi
|
3211 |
|
|
00FFEF3D 001 fcb MF_INCH
|
3212 |
|
|
00FFEF3E 0C1015 cmpb #NAK ; should have got a NAK
|
3213 |
|
|
00FFEF40 027004 beq xm_send5
|
3214 |
|
|
00FFEF42 0C1043 cmpb #'C' ; or a 'C'
|
3215 |
|
|
00FFEF44 026FF3 bne xm_send
|
3216 |
|
|
xm_send5:
|
3217 |
|
|
00FFEF46 0F70009F5 stb xm_protocol
|
3218 |
|
|
xm_send4:
|
3219 |
|
|
00FFEF49 0C6001 ldb #SOH ; send start
|
3220 |
|
|
00FFEF4B 03F swi
|
3221 |
|
|
00FFEF4C 1C9 fcb OUTCH
|
3222 |
|
|
00FFEF4D 0F60009FB ldb xm_packetnum+1 ; send packet number
|
3223 |
|
|
00FFEF50 03F swi
|
3224 |
|
|
00FFEF51 002 fcb MF_OUTCH
|
3225 |
|
|
00FFEF52 053 comb ; one's complement
|
3226 |
|
|
00FFEF53 03F swi
|
3227 |
|
|
00FFEF54 002 fcb MF_OUTCH ; send packet number complement
|
3228 |
|
|
00FFEF55 04F clra ; acca = byte count
|
3229 |
|
|
00FFEF56 01F013 tfr x,u ; u = buffer address
|
3230 |
|
|
xm_send1:
|
3231 |
|
|
00FFEF58 0E6C00 ldb ,u+ ; grab a byte from the buffer
|
3232 |
|
|
00FFEF5A 03F swi
|
3233 |
|
|
00FFEF5B 002 fcb MF_OUTCH ; send it out
|
3234 |
|
|
00FFEF5C 04C inca
|
3235 |
|
|
00FFEF5D 081080 cmpa #128 ; number of bytes in payload
|
3236 |
|
|
00FFEF5F 025FF7 blo xm_send1
|
3237 |
|
|
00FFEF61 0F60009F5 ldb xm_protocol
|
3238 |
|
|
00FFEF64 0C1043 cmpb #'C' ; CRC protocol?
|
3239 |
|
|
00FFEF66 02601E bne xm_send2
|
3240 |
|
|
00FFEF68 08D17F bsr xm_calc_crc ; compute CRC
|
3241 |
|
|
00FFEF6A 0FC0009FE ldd xm_crc ; get crc
|
3242 |
|
|
00FFEF6D 044 lsra ; transfer high eight bits first, so
|
3243 |
|
|
00FFEF6E 056 rorb ; right shift D by eight
|
3244 |
|
|
00FFEF6F 044 lsra
|
3245 |
|
|
00FFEF70 056 rorb
|
3246 |
|
|
00FFEF71 044 lsra
|
3247 |
|
|
00FFEF72 056 rorb
|
3248 |
|
|
00FFEF73 044 lsra
|
3249 |
|
|
00FFEF74 056 rorb
|
3250 |
|
|
00FFEF75 044 lsra
|
3251 |
|
|
00FFEF76 056 rorb
|
3252 |
|
|
00FFEF77 044 lsra
|
3253 |
|
|
00FFEF78 056 rorb
|
3254 |
|
|
00FFEF79 044 lsra
|
3255 |
|
|
00FFEF7A 056 rorb
|
3256 |
|
|
00FFEF7B 044 lsra
|
3257 |
|
|
00FFEF7C 056 rorb
|
3258 |
|
|
00FFEF7D 03F swi
|
3259 |
|
|
00FFEF7E 002 fcb MF_OUTCH ; send out the byte
|
3260 |
|
|
00FFEF7F 0FC0009FE ldd xm_crc ; get back CRC
|
3261 |
|
|
00FFEF82 03F swi
|
3262 |
|
|
00FFEF83 002 fcb MF_OUTCH ; and send out low byte
|
3263 |
|
|
00FFEF84 020007 bra xm_send3
|
3264 |
|
|
xm_send2:
|
3265 |
|
|
00FFEF86 08D14F bsr xm_calc_checksum
|
3266 |
|
|
00FFEF88 0F60009F7 ldb xm_checksum
|
3267 |
|
|
00FFEF8B 03F swi
|
3268 |
|
|
00FFEF8C 002 fcb MF_OUTCH
|
3269 |
|
|
xm_send3:
|
3270 |
|
|
00FFEF8D 03F swi
|
3271 |
|
|
00FFEF8E 0CCFFFFFF ldd #-1 ; block until input is present
|
3272 |
|
|
00FFEF91 001 fcb MF_INCH
|
3273 |
|
|
00FFEF92 0C1006 cmpb #ACK
|
3274 |
|
|
00FFEF94 026FB3 bne xm_send4 ; not an ACK then resend the record
|
3275 |
|
|
00FFEF96 07C0009FA inc xm_packetnum ; increment packet number
|
3276 |
|
|
00FFEF99 030080 leax 128,x ; advance buffer pointer
|
3277 |
|
|
00FFEF9B 0BC000926 cmpx mon_r2+2
|
3278 |
|
|
00FFEF9E 025FA9 blo xm_send4 ; go send next record
|
3279 |
|
|
00FFEFA0 0C6004 ldb #EOT ; send end of transmission
|
3280 |
|
|
00FFEFA2 03F swi
|
3281 |
|
|
00FFEFA3 002 fcb MF_OUTCH
|
3282 |
|
|
00FFEFA4 03F swi
|
3283 |
|
|
00FFEFA5 002 fcb MF_OUTCH
|
3284 |
|
|
00FFEFA6 03F swi
|
3285 |
|
|
00FFEFA7 002 fcb MF_OUTCH
|
3286 |
|
|
00FFEFA8 039 rts
|
3287 |
|
|
|
3288 |
|
|
; ------------------------------------------------------------------------------
|
3289 |
|
|
; Get a byte, checking for a receive timeout.
|
3290 |
|
|
;
|
3291 |
|
|
; Returns:
|
3292 |
|
|
; accb = byte (0 to 255) or -1 if timed out
|
3293 |
|
|
; ------------------------------------------------------------------------------
|
3294 |
|
|
|
3295 |
|
|
xm_getbyte:
|
3296 |
|
|
xm_gb1:
|
3297 |
|
|
00FFEFA9 07DFFC020 tst xm_timer ; check the timeout - 2048 ticks (3 seconds approx.)
|
3298 |
|
|
00FFEFAC 02B009 bmi xm_gb2
|
3299 |
|
|
00FFEFAE 04F clra ; non-blocking
|
3300 |
|
|
00FFEFAF 05F clrb
|
3301 |
|
|
00FFEFB0 03F swi
|
3302 |
|
|
00FFEFB1 001 fcb MF_INCH ; try and get a character
|
3303 |
|
|
00FFEFB2 02BFF5 bmi xm_gb1 ; if no character, try again
|
3304 |
|
|
00FFEFB4 08D1BA bsr xm_outbyteAsHex
|
3305 |
|
|
00FFEFB6 039 rts
|
3306 |
|
|
xm_gb2:
|
3307 |
|
|
00FFEFB7 0C6FFF ldb #-1
|
3308 |
|
|
00FFEFB9 039 rts
|
3309 |
|
|
|
3310 |
|
|
; ------------------------------------------------------------------------------
|
3311 |
|
|
; XModem Receive
|
3312 |
|
|
;
|
3313 |
|
|
; Parameters:
|
3314 |
|
|
; none
|
3315 |
|
|
; Modifies:
|
3316 |
|
|
; All
|
3317 |
|
|
; Returns:
|
3318 |
|
|
; none
|
3319 |
|
|
; ------------------------------------------------------------------------------
|
3320 |
|
|
|
3321 |
|
|
xm_ReceiveStart:
|
3322 |
|
|
00FFEFBA 017FFF1FB lbsr Delay3s ; give a little bit of time for sender
|
3323 |
|
|
*** warning 1: Long branch within short branch range could be optimized
|
3324 |
|
|
00FFEFBD 017FFF1F8 lbsr Delay3s
|
3325 |
|
|
*** warning 1: Long branch within short branch range could be optimized
|
3326 |
|
|
00FFEFC0 017FFF1F5 lbsr Delay3s
|
3327 |
|
|
*** warning 1: Long branch within short branch range could be optimized
|
3328 |
|
|
00FFEFC3 0170005CB lbsr GetNumber ; Get the transfer address
|
3329 |
|
|
00FFEFC6 05D tstb ; Make sure we got a value
|
3330 |
|
|
00FFEFC7 127000392 lbeq Monitor
|
3331 |
|
|
00FFEFCA 0BE000912 ldx mon_numwka+2 ; X = transfer address
|
3332 |
|
|
00FFEFCD 07F0009FA clr xm_packetnum ; initialize
|
3333 |
|
|
00FFEFD0 086043 lda #'C' ; try for CRC first
|
3334 |
|
|
00FFEFD2 0B70009F5 sta xm_protocol
|
3335 |
|
|
xm_receive:
|
3336 |
|
|
00FFEFD5 086002 lda #2 ; number of times to retry -1
|
3337 |
|
|
xm_rcv5:
|
3338 |
|
|
00FFEFD7 0F60009F5 ldb xm_protocol ; indicate we want a transfer (send protocol byte)
|
3339 |
|
|
00FFEFDA 03F swi
|
3340 |
|
|
00FFEFDB 00D fcb MF_SerialPutchar
|
3341 |
|
|
xm_rcv4:
|
3342 |
|
|
00FFEFDC 07FFFC020 clr xm_timer ; clear the timeout
|
3343 |
|
|
xm_rcv1:
|
3344 |
|
|
00FFEFDF 08DFC8 bsr xm_getbyte
|
3345 |
|
|
00FFEFE1 05D tstb
|
3346 |
|
|
00FFEFE2 02B0A1 bmi xm_retry1 ; timeout on protocol id?
|
3347 |
|
|
00FFEFE4 0C1001 cmpb #SOH ; it should be start of a transfer
|
3348 |
|
|
00FFEFE6 027012 beq xm_SOH
|
3349 |
|
|
00FFEFE8 0C1004 cmpb #EOT
|
3350 |
|
|
00FFEFEA 027092 beq xm_EOT ; or end of transfer (EOT)
|
3351 |
|
|
00FFEFEC 0C1018 cmpb #CAN
|
3352 |
|
|
00FFEFEE 027FE5 beq xm_receive ; might be a cancel
|
3353 |
|
|
00FFEFF0 0C1017 cmpb #ETB
|
3354 |
|
|
00FFEFF2 02708A beq xm_EOT
|
3355 |
|
|
xm_rcv_nak: ; wasn't a valid start so
|
3356 |
|
|
00FFEFF4 0C6015 ldb #NAK ; send a NAK
|
3357 |
|
|
00FFEFF6 03F swi
|
3358 |
|
|
00FFEFF7 00D fcb MF_SerialPutchar ; and try again
|
3359 |
|
|
00FFEFF8 020FE2 bra xm_rcv4
|
3360 |
|
|
xm_SOH:
|
3361 |
|
|
00FFEFFA 08DFAD bsr xm_getbyte ; get packet number
|
3362 |
|
|
00FFEFFC 02B078 bmi xm_rcv_to1
|
3363 |
|
|
00FFEFFE 0F70009FB stb xm_packetnum+1
|
3364 |
|
|
00FFF001 034004 pshs b ; save it
|
3365 |
|
|
00FFF003 08DFA4 bsr xm_getbyte ; get complement of packet number
|
3366 |
|
|
00FFF005 02B06D bmi xm_rcv_to2
|
3367 |
|
|
00FFF007 0EBE04 addb ,s ; add the two values
|
3368 |
|
|
00FFF009 0C40FF andb #$FF ; the sum should be $FF
|
3369 |
|
|
00FFF00B 0C00FF subb #$FF
|
3370 |
|
|
00FFF00D 0F70009F6 stb xm_flag ; should be storing a zero if there is no error
|
3371 |
|
|
00FFF010 18E000000 ldy #0 ; y = payload byte counter
|
3372 |
|
|
00FFF013 01F013 tfr x,u
|
3373 |
|
|
xm_rcv2:
|
3374 |
|
|
00FFF015 08DF92 bsr xm_getbyte
|
3375 |
|
|
00FFF017 02B05D bmi xm_rcv_to1
|
3376 |
|
|
00FFF019 0E7C00 stb ,u+ ; store the byte to memory
|
3377 |
|
|
00FFF01B 031201 iny
|
3378 |
|
|
00FFF01D 18C000080 cmpy #128 ; 128 bytes per payload
|
3379 |
|
|
00FFF020 025FF3 blo xm_rcv2
|
3380 |
|
|
00FFF022 08DF85 bsr xm_getbyte ; get checksum or CRC byte
|
3381 |
|
|
00FFF024 02B050 bmi xm_rcv_to1
|
3382 |
|
|
00FFF026 0F70009FC stb xm_tmp ; stuff checksum/CRC byte
|
3383 |
|
|
00FFF029 0F60009F5 ldb xm_protocol
|
3384 |
|
|
00FFF02C 0C1043 cmpb #'C'
|
3385 |
|
|
00FFF02E 026022 bne xm_rcv_chksum
|
3386 |
|
|
00FFF030 08DF77 bsr xm_getbyte ; get low order CRC byte
|
3387 |
|
|
00FFF032 02B042 bmi xm_rcv_to1
|
3388 |
|
|
00FFF034 0B60009FC lda xm_tmp ; get the high byte
|
3389 |
|
|
00FFF037 058 aslb ; prepare to combine high and low order
|
3390 |
|
|
00FFF038 058 aslb
|
3391 |
|
|
00FFF039 058 aslb
|
3392 |
|
|
00FFF03A 058 aslb
|
3393 |
|
|
00FFF03B 044 lsra ; shift low nybble of acca into accb
|
3394 |
|
|
00FFF03C 056 rorb
|
3395 |
|
|
00FFF03D 044 lsra
|
3396 |
|
|
00FFF03E 056 rorb
|
3397 |
|
|
00FFF03F 044 lsra
|
3398 |
|
|
00FFF040 056 rorb
|
3399 |
|
|
00FFF041 044 lsra
|
3400 |
|
|
00FFF042 056 rorb
|
3401 |
|
|
00FFF043 08400F anda #$00F ; mask off any extra bits
|
3402 |
|
|
00FFF045 0FD0009F8 std xm_tmp2
|
3403 |
|
|
00FFF048 08D09F bsr xm_calc_crc ; compute the CRC-16 for the received data
|
3404 |
|
|
00FFF04A 0FC0009FE ldd xm_crc ; and compare to received value
|
3405 |
|
|
00FFF04D 1B30009F8 cmpd xm_tmp2
|
3406 |
|
|
00FFF050 020008 bra xm_rcv3
|
3407 |
|
|
xm_rcv_chksum:
|
3408 |
|
|
00FFF052 08D083 bsr xm_calc_checksum
|
3409 |
|
|
00FFF054 0F60009F7 ldb xm_checksum
|
3410 |
|
|
00FFF057 0F10009FC cmpb xm_tmp ; where we stuffed the byte
|
3411 |
|
|
xm_rcv3:
|
3412 |
|
|
00FFF05A 026F98 bne xm_rcv_nak ; if not the same, NAK
|
3413 |
|
|
00FFF05C 07D0009F6 tst xm_flag
|
3414 |
|
|
00FFF05F 026F93 bne xm_rcv_nak ; bad packet number?
|
3415 |
|
|
00FFF061 0C6006 ldb #ACK ; packet recieved okay, send back an ACK
|
3416 |
|
|
00FFF063 03F swi
|
3417 |
|
|
00FFF064 00D fcb MF_SerialPutchar
|
3418 |
|
|
00FFF065 0F60009FB ldb xm_packetnum+1 ; did we receive the same packet
|
3419 |
|
|
00FFF068 0F10009FA cmpb xm_packetnum
|
3420 |
|
|
00FFF06B 027F6F beq xm_rcv4 ; same packet received, dont update buffer pointer
|
3421 |
|
|
00FFF06D 0F70009FA stb xm_packetnum ; update last seen packet number
|
3422 |
|
|
00FFF070 030080 leax 128,x ; increment buffer pointer
|
3423 |
|
|
00FFF072 020F68 bra xm_rcv4 ; and go back for next packet
|
3424 |
|
|
xm_rcv_to2:
|
3425 |
|
|
00FFF074 032601 leas 1,s ; get rid of stacked byte
|
3426 |
|
|
xm_rcv_to1:
|
3427 |
|
|
00FFF076 0CCFFF09E ldd #msgXmTimeout
|
3428 |
|
|
00FFF079 03F swi
|
3429 |
|
|
00FFF07A 004 fcb MF_DisplayString
|
3430 |
|
|
00FFF07B 0160002DE lbra Monitor
|
3431 |
|
|
xm_EOT: ; end of transmission received, return
|
3432 |
|
|
00FFF07E 0C6006 ldb #ACK ; ACK the EOT
|
3433 |
|
|
00FFF080 03F swi
|
3434 |
|
|
00FFF081 00D fcb MF_SerialPutchar
|
3435 |
|
|
00FFF082 0160002D7 lbra Monitor
|
3436 |
|
|
xm_retry1:
|
3437 |
|
|
00FFF085 04A deca
|
3438 |
|
|
00FFF086 02AF4F bpl xm_rcv5
|
3439 |
|
|
00FFF088 0B60009F5 lda xm_protocol
|
3440 |
|
|
00FFF08B 081015 cmpa #NAK ; are we already lowered down to checksum protocol?
|
3441 |
|
|
00FFF08D 027007 beq xm_noTransmitter ; did we try both checksum and CRC?
|
3442 |
|
|
00FFF08F 086015 lda #NAK
|
3443 |
|
|
00FFF091 0B70009F5 sta xm_protocol
|
3444 |
|
|
00FFF094 020F3F bra xm_receive
|
3445 |
|
|
xm_noTransmitter:
|
3446 |
|
|
00FFF096 0CCFFF0B2 ldd #msgXmNoTransmitter
|
3447 |
|
|
00FFF099 03F swi
|
3448 |
|
|
00FFF09A 004 fcb MF_DisplayString
|
3449 |
|
|
00FFF09B 0160002BE lbra Monitor
|
3450 |
|
|
|
3451 |
|
|
msgXmTimeout:
|
3452 |
|
|
00FFF09E 05806D06F06406506D03A fcb "Xmodem: timed out",CR,LF,0
|
3453 |
|
|
00FFF0A5 02007406906D065064020
|
3454 |
|
|
00FFF0AC 06F07507400D00A000
|
3455 |
|
|
msgXmNoTransmitter:
|
3456 |
|
|
00FFF0B2 05804D06F06406506D03A fcb "XModem: transmitter not responding",CR,LF,0
|
3457 |
|
|
00FFF0B9 02007407206106E07306D
|
3458 |
|
|
00FFF0C0 06907407406507202006E
|
3459 |
|
|
00FFF0C7 06F074020072065073070
|
3460 |
|
|
00FFF0CE 06F06E06406906E06700D
|
3461 |
|
|
00FFF0D5 00A000
|
3462 |
|
|
|
3463 |
|
|
; ------------------------------------------------------------------------------
|
3464 |
|
|
; Calculate checksum value. The checksum is simply the low order eight bits of
|
3465 |
|
|
; the sum of all the bytes in the payload area.
|
3466 |
|
|
;
|
3467 |
|
|
; Stack space:
|
3468 |
|
|
; two words
|
3469 |
|
|
; Modifies:
|
3470 |
|
|
; xm_checksum contains the checksum value for the record
|
3471 |
|
|
; Parameters:
|
3472 |
|
|
; X = buffer address
|
3473 |
|
|
; Returns:
|
3474 |
|
|
; none
|
3475 |
|
|
; ------------------------------------------------------------------------------
|
3476 |
|
|
|
3477 |
|
|
xm_calc_checksum:
|
3478 |
|
|
00FFF0D7 034016 pshs d,x
|
3479 |
|
|
00FFF0D9 04F clra
|
3480 |
|
|
00FFF0DA 05F clrb
|
3481 |
|
|
xm_cs1:
|
3482 |
|
|
00FFF0DB 0EB800 addb ,x+
|
3483 |
|
|
00FFF0DD 04C inca
|
3484 |
|
|
00FFF0DE 081080 cmpa #128
|
3485 |
|
|
00FFF0E0 025FF9 blo xm_cs1
|
3486 |
|
|
00FFF0E2 0C40FF andb #$FF
|
3487 |
|
|
00FFF0E4 0F70009F7 stb xm_checksum
|
3488 |
|
|
00FFF0E7 035096 puls d,x,pc
|
3489 |
|
|
|
3490 |
|
|
; ------------------------------------------------------------------------------
|
3491 |
|
|
; Compute CRC-16 of buffer.
|
3492 |
|
|
;
|
3493 |
|
|
;int calcrc(char *ptr, int count)
|
3494 |
|
|
;{
|
3495 |
|
|
; int crc;
|
3496 |
|
|
; char i;
|
3497 |
|
|
; crc = 0;
|
3498 |
|
|
; while (--count >= 0)
|
3499 |
|
|
; {
|
3500 |
|
|
; crc = crc ^ (int) (*ptr++ << 8);
|
3501 |
|
|
; i = 8;
|
3502 |
|
|
; do
|
3503 |
|
|
; {
|
3504 |
|
|
; if (crc & 0x8000)
|
3505 |
|
|
; crc = crc << 1 ^ 0x1021;
|
3506 |
|
|
; else
|
3507 |
|
|
; crc = crc << 1;
|
3508 |
|
|
; } while(--i);
|
3509 |
|
|
; }
|
3510 |
|
|
; return (crc);
|
3511 |
|
|
;}
|
3512 |
|
|
;
|
3513 |
|
|
; Modifies:
|
3514 |
|
|
; xm_crc variable
|
3515 |
|
|
; Parameters:
|
3516 |
|
|
; u = buffer address
|
3517 |
|
|
; Returns:
|
3518 |
|
|
; none
|
3519 |
|
|
; ------------------------------------------------------------------------------
|
3520 |
|
|
|
3521 |
|
|
xm_calc_crc:
|
3522 |
|
|
00FFF0E9 034076 pshs d,x,y,u
|
3523 |
|
|
00FFF0EB 07F0009FE clr xm_crc
|
3524 |
|
|
00FFF0EE 07F0009FF clr xm_crc+1
|
3525 |
|
|
00FFF0F1 0CE000000 ldu #0 ; u = byte count
|
3526 |
|
|
xm_crc1:
|
3527 |
|
|
00FFF0F4 0E6800 ldb ,x+ ; get byte
|
3528 |
|
|
00FFF0F6 07F0009FC clr xm_tmp ; save in temp
|
3529 |
|
|
00FFF0F9 0F70009FD stb xm_tmp+1
|
3530 |
|
|
00FFF0FC 0780009FD asl xm_tmp+1 ; shift temp eight bits to left
|
3531 |
|
|
00FFF0FF 0790009FC rol xm_tmp
|
3532 |
|
|
00FFF102 0780009FD asl xm_tmp+1
|
3533 |
|
|
00FFF105 0790009FC rol xm_tmp
|
3534 |
|
|
00FFF108 0780009FD asl xm_tmp+1
|
3535 |
|
|
00FFF10B 0790009FC rol xm_tmp
|
3536 |
|
|
00FFF10E 0780009FD asl xm_tmp+1
|
3537 |
|
|
00FFF111 0790009FC rol xm_tmp
|
3538 |
|
|
00FFF114 0780009FD asl xm_tmp+1
|
3539 |
|
|
00FFF117 0790009FC rol xm_tmp
|
3540 |
|
|
00FFF11A 0780009FD asl xm_tmp+1
|
3541 |
|
|
00FFF11D 0790009FC rol xm_tmp
|
3542 |
|
|
00FFF120 0780009FD asl xm_tmp+1
|
3543 |
|
|
00FFF123 0790009FC rol xm_tmp
|
3544 |
|
|
00FFF126 0780009FD asl xm_tmp+1
|
3545 |
|
|
00FFF129 0790009FC rol xm_tmp
|
3546 |
|
|
00FFF12C 0FC0009FE ldd xm_crc ; crc = crc ^ tmp
|
3547 |
|
|
00FFF12F 0B80009FC eora xm_tmp
|
3548 |
|
|
00FFF132 0F80009FD eorb xm_tmp+1
|
3549 |
|
|
00FFF135 0FD0009FE std xm_crc
|
3550 |
|
|
00FFF138 18E000000 ldy #0
|
3551 |
|
|
xm_crc4:
|
3552 |
|
|
00FFF13B 0F60009FE ldb xm_crc ; get high byte
|
3553 |
|
|
00FFF13E 0C5008 bitb #$8 ; check for $8000
|
3554 |
|
|
00FFF140 02700E beq xm_crc2 ; no? then just go shift
|
3555 |
|
|
00FFF142 0FC0009FE ldd xm_crc ; load
|
3556 |
|
|
00FFF145 058 aslb ; shift
|
3557 |
|
|
00FFF146 049 rola
|
3558 |
|
|
00FFF147 0C8021 eorb #$021 ; and xor
|
3559 |
|
|
00FFF149 088001 eora #$001
|
3560 |
|
|
00FFF14B 0FD0009FE std xm_crc ; store it back
|
3561 |
|
|
00FFF14E 020008 bra xm_crc3
|
3562 |
|
|
xm_crc2:
|
3563 |
|
|
00FFF150 0FC0009FE ldd xm_crc ; load
|
3564 |
|
|
00FFF153 058 aslb ; shift
|
3565 |
|
|
00FFF154 049 rola
|
3566 |
|
|
00FFF155 0FD0009FE std xm_crc ; and store
|
3567 |
|
|
xm_crc3:
|
3568 |
|
|
00FFF158 031201 iny
|
3569 |
|
|
00FFF15A 18C000008 cmpy #8 ; repeat eight times
|
3570 |
|
|
00FFF15D 025FDC blo xm_crc4
|
3571 |
|
|
00FFF15F 033401 leau 1,u ; increment byte count
|
3572 |
|
|
00FFF161 283000080 cmpu #128
|
3573 |
|
|
00FFF164 0FC0009FE ldd xm_crc ; we want only a 16-bit CRC
|
3574 |
|
|
00FFF167 08400F anda #$0F
|
3575 |
|
|
00FFF169 0FD0009FE std xm_crc
|
3576 |
|
|
00FFF16C 025F86 blo xm_crc1
|
3577 |
|
|
00FFF16E 0350F6 puls d,x,y,u,pc
|
3578 |
|
|
|
3579 |
|
|
xm_outbyteAsHex:
|
3580 |
|
|
00FFF170 034006 pshs d
|
3581 |
|
|
00FFF172 0FC000800 ldd CharOutVec ; get current char out vector
|
3582 |
|
|
00FFF175 034006 pshs d ; save it
|
3583 |
|
|
00FFF177 0CCFFE31F ldd #ScreenDisplayChar ; set output vector to screen display
|
3584 |
|
|
00FFF17A 0FD000800 std CharOUtVec
|
3585 |
|
|
00FFF17D 0EC602 ldd 2,s ; get passed data
|
3586 |
|
|
00FFF17F 017FFF2B8 lbsr DispByteAsHex ; and display on-screen
|
3587 |
|
|
*** warning 1: Long branch within short branch range could be optimized
|
3588 |
|
|
00FFF182 0C6020 ldb #' '
|
3589 |
|
|
00FFF184 017FFF198 lbsr ScreenDisplayChar
|
3590 |
|
|
*** warning 1: Long branch within short branch range could be optimized
|
3591 |
|
|
00FFF187 035006 puls d ; get back old char out vector
|
3592 |
|
|
00FFF189 0FD000800 std CharOutVec ; and restore it
|
3593 |
|
|
00FFF18C 035006 puls d ; restore input arguments
|
3594 |
|
|
00FFF18E 039 rts
|
3595 |
|
|
|
3596 |
|
|
|
3597 |
|
|
|
3598 |
13 |
robfinch |
;------------------------------------------------------------------------------
|
3599 |
4 |
robfinch |
; Check if there is a keyboard character available. If so return true (<0)
|
3600 |
|
|
; otherwise return false (0) in accb.
|
3601 |
|
|
;------------------------------------------------------------------------------
|
3602 |
|
|
;
|
3603 |
|
|
KeybdCheckForKeyDirect:
|
3604 |
21 |
robfinch |
00FFF18F 0208FF bra DBGCheckForKey
|
3605 |
4 |
robfinch |
|
3606 |
|
|
;------------------------------------------------------------------------------
|
3607 |
|
|
;------------------------------------------------------------------------------
|
3608 |
|
|
INCH:
|
3609 |
21 |
robfinch |
00FFF191 034004 pshs b
|
3610 |
13 |
robfinch |
INCH2:
|
3611 |
21 |
robfinch |
00FFF193 0150F6FFFFFFFE0 ldb COREID
|
3612 |
|
|
00FFF198 0F1FFC010 cmpb IOFocusID ; if we do not have focus, block
|
3613 |
|
|
00FFF19B 026FF6 bne INCH2
|
3614 |
13 |
robfinch |
; ldb #$800 ; block if no key available, get scancode directly
|
3615 |
|
|
; bra GetKey
|
3616 |
|
|
; jsr [CharInVec] ; vector is being overwritten somehow
|
3617 |
21 |
robfinch |
00FFF19D 017FFFAD3 lbsr SerialPeekCharDirect
|
3618 |
13 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
3619 |
21 |
robfinch |
; lbsr SerialGetChar
|
3620 |
|
|
00FFF1A0 04D tsta
|
3621 |
|
|
00FFF1A1 02B003 bmi INCH1 ; block if no key available
|
3622 |
|
|
00FFF1A3 032601 leas 1,s ; get rid of blocking status
|
3623 |
|
|
00FFF1A5 039 rts ; return character
|
3624 |
13 |
robfinch |
INCH1:
|
3625 |
21 |
robfinch |
00FFF1A6 035004 puls b ; check blocking status
|
3626 |
|
|
00FFF1A8 05D tstb
|
3627 |
|
|
00FFF1A9 02BFE6 bmi INCH ; if blocking, loop
|
3628 |
|
|
00FFF1AB 0CCFFFFFF ldd #-1 ; return -1 if no char available
|
3629 |
|
|
00FFF1AE 039 rts
|
3630 |
4 |
robfinch |
|
3631 |
|
|
INCHE:
|
3632 |
21 |
robfinch |
00FFF1AF 08DFE0 bsr INCH
|
3633 |
|
|
00FFF1B1 020009 bra INCHEK3
|
3634 |
4 |
robfinch |
|
3635 |
|
|
INCHEK:
|
3636 |
21 |
robfinch |
00FFF1B3 08DFDC bsr INCH
|
3637 |
|
|
00FFF1B5 01507DFFFFFCA00 tst KeybdEcho
|
3638 |
|
|
00FFF1BA 02700C beq INCHEK1
|
3639 |
4 |
robfinch |
INCHEK3:
|
3640 |
21 |
robfinch |
00FFF1BC 08100D cmpa #CR
|
3641 |
|
|
00FFF1BE 026005 bne INCHEK2
|
3642 |
|
|
00FFF1C0 017FFDF0F lbsr CRLF
|
3643 |
4 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
3644 |
21 |
robfinch |
00FFF1C3 020003 bra INCHEK1
|
3645 |
4 |
robfinch |
INCHEK2:
|
3646 |
21 |
robfinch |
00FFF1C5 017FFF154 lbsr DisplayChar
|
3647 |
13 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
3648 |
4 |
robfinch |
INCHEK1:
|
3649 |
21 |
robfinch |
00FFF1C8 039 rts
|
3650 |
4 |
robfinch |
|
3651 |
|
|
OUTCH:
|
3652 |
21 |
robfinch |
00FFF1C9 06E90F000800 jmp [CharOutVec]
|
3653 |
4 |
robfinch |
|
3654 |
|
|
;------------------------------------------------------------------------------
|
3655 |
|
|
; r1 0=echo off, non-zero = echo on
|
3656 |
|
|
;------------------------------------------------------------------------------
|
3657 |
|
|
;
|
3658 |
|
|
SetKeyboardEcho:
|
3659 |
21 |
robfinch |
00FFF1CD 0150F7FFFFFCA00 stb KeybdEcho
|
3660 |
|
|
00FFF1D2 039 rts
|
3661 |
4 |
robfinch |
|
3662 |
|
|
|
3663 |
|
|
;------------------------------------------------------------------------------
|
3664 |
|
|
; Parameters:
|
3665 |
|
|
; x,d bitmap of sprites to enable
|
3666 |
|
|
;------------------------------------------------------------------------------
|
3667 |
|
|
|
3668 |
|
|
ShowSprites:
|
3669 |
21 |
robfinch |
00FFF1D3 0150BFFFFE103C0 stx SPRITE_CTRL+SPRITE_EN
|
3670 |
|
|
00FFF1D8 0150FDFFFE103C2 std SPRITE_CTRL+SPRITE_EN+2
|
3671 |
|
|
00FFF1DD 039 rts
|
3672 |
4 |
robfinch |
|
3673 |
|
|
;==============================================================================
|
3674 |
13 |
robfinch |
; Femtiki Operating System.
|
3675 |
|
|
;==============================================================================
|
3676 |
|
|
|
3677 |
|
|
OSCallTbl:
|
3678 |
21 |
robfinch |
00FFF1DE 000000 fcw 0
|
3679 |
|
|
00FFF1E0 000000 fcw 0
|
3680 |
|
|
00FFF1E2 000000 fcw 0
|
3681 |
|
|
00FFF1E4 000000 fcw 0
|
3682 |
|
|
00FFF1E6 000000 fcw 0
|
3683 |
|
|
00FFF1E8 000000 fcw 0
|
3684 |
|
|
00FFF1EA 000000 fcw 0
|
3685 |
|
|
00FFF1EC 000000 fcw 0
|
3686 |
|
|
00FFF1EE 000000 fcw 0
|
3687 |
|
|
00FFF1F0 000000 fcw 0
|
3688 |
|
|
00FFF1F2 000000 fcw 0
|
3689 |
|
|
00FFF1F4 000000 fcw 0
|
3690 |
|
|
00FFF1F6 000000 fcw 0
|
3691 |
|
|
00FFF1F8 000000 fcw 0
|
3692 |
|
|
00FFF1FA 000000 fcw 0
|
3693 |
|
|
00FFF1FC 000000 fcw 0
|
3694 |
|
|
00FFF1FE 000000 fcw 0
|
3695 |
|
|
00FFF200 000000 fcw 0
|
3696 |
|
|
00FFF202 000000 fcw 0
|
3697 |
|
|
00FFF204 000000 fcw 0
|
3698 |
|
|
00FFF206 000000 fcw 0
|
3699 |
|
|
00FFF208 000000 fcw 0
|
3700 |
|
|
00FFF20A FFF227 fcw ReleaseIOFocus
|
3701 |
|
|
00FFF20C 000000 fcw 0
|
3702 |
|
|
00FFF20E FFF210 fcw RequestIOFocus
|
3703 |
13 |
robfinch |
|
3704 |
15 |
robfinch |
NumOSFuncs EQU (*-OSCallTbl)/2
|
3705 |
13 |
robfinch |
|
3706 |
|
|
RequestIOFocus:
|
3707 |
21 |
robfinch |
00FFF210 0150F6FFFFFFFE0 ldb COREID
|
3708 |
|
|
00FFF215 08EFFC000 ldx #IOFocusList
|
3709 |
|
|
00FFF218 03A abx
|
3710 |
|
|
00FFF219 0A7804 sta ,x
|
3711 |
|
|
00FFF21B 07DFFC010 tst IOFocusID
|
3712 |
|
|
00FFF21E 1260008DC lbne oscx
|
3713 |
|
|
00FFF221 0F7FFC010 stb IOFocusID
|
3714 |
|
|
00FFF224 0160008D6 lbra oscx
|
3715 |
13 |
robfinch |
|
3716 |
|
|
ReleaseIOFocus:
|
3717 |
21 |
robfinch |
00FFF227 0150F6FFFFFFFE0 ldb COREID
|
3718 |
|
|
00FFF22C 08EFFC000 ldx #IOFocusList
|
3719 |
|
|
00FFF22F 03A abx
|
3720 |
|
|
00FFF230 06F804 clr ,x ; clear the request indicator
|
3721 |
|
|
00FFF232 017FFEFD7 lbsr CopyScreenToVirtualScreen
|
3722 |
13 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
3723 |
21 |
robfinch |
00FFF235 0F1FFC010 cmpb IOFocusID ; are we the one with the focus?
|
3724 |
|
|
00FFF238 1260008C2 lbne oscx
|
3725 |
13 |
robfinch |
; We had the focus, so now a new core needs the focus.
|
3726 |
|
|
; Search the focus list for a requestor. If no requester
|
3727 |
|
|
; is found, give focus to core #1.
|
3728 |
21 |
robfinch |
00FFF23B 08600F lda #15
|
3729 |
13 |
robfinch |
riof2:
|
3730 |
21 |
robfinch |
00FFF23D 05C incb
|
3731 |
|
|
00FFF23E 0C400F andb #15
|
3732 |
|
|
00FFF240 03A abx
|
3733 |
|
|
00FFF241 06D804 tst ,x
|
3734 |
|
|
00FFF243 026009 bne riof1
|
3735 |
|
|
00FFF245 04A deca
|
3736 |
|
|
00FFF246 026FF5 bne riof2
|
3737 |
13 |
robfinch |
; If no focus is requested by anyone, give to core #1
|
3738 |
21 |
robfinch |
00FFF248 0C6001 ldb #1
|
3739 |
|
|
00FFF24A 086018 lda #24
|
3740 |
|
|
00FFF24C 0A7804 sta ,x
|
3741 |
13 |
robfinch |
riof1:
|
3742 |
21 |
robfinch |
00FFF24E 0F7FFC010 stb IOFocusID
|
3743 |
|
|
00FFF251 017FFEF81 lbsr CopyVirtualScreenToScreen
|
3744 |
13 |
robfinch |
*** warning 1: Long branch within short branch range could be optimized
|
3745 |
21 |
robfinch |
00FFF254 0160008A6 lbra oscx
|
3746 |
13 |
robfinch |