OpenCores
URL https://opencores.org/ocsvn/rf6809/rf6809/trunk

Subversion Repositories rf6809

[/] [rf6809/] [trunk/] [software/] [boot/] [boot_rom.lst] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 robfinch
3 error(s), 526 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 4 robfinch
                              CR      EQU     $0D             ;ASCII equates
75
                              LF      EQU     $0A
76
                              TAB     EQU     $09
77
                              CTRLC   EQU     $03
78
                              CTRLH   EQU     $08
79
                              CTRLI   EQU     $09
80
                              CTRLJ   EQU     $0A
81
                              CTRLK   EQU     $0B
82
                              CTRLM   EQU $0D
83
                              CTRLS   EQU     $13
84 13 robfinch
                              CTRLT EQU $14
85 4 robfinch
                              CTRLX   EQU     $18
86 16 robfinch
                              CTRLZ   EQU     $1A
87 4 robfinch
                              XON             EQU     $11
88
                              XOFF    EQU     $13
89
 
90
                              FIRST_CORE      EQU     1
91
                              MAX_TASKNO      EQU 63
92
                              DRAM_BASE       EQU $10000000
93
 
94 15 robfinch
                              ; ROM monitor functions
95
                              ;
96
                              MF_Monitor      EQU             0
97
                              MF_INCH                 EQU             1
98
                              MF_OUTCH                EQU     2
99
                              MF_CRLF                 EQU             3
100
                              MF_DisplayString        EQU             4
101
                              MF_DisplayByteAsHex             EQU     5
102
                              MF_DisplayWordAsHex             EQU     6
103
                              MF_ShowSprites  EQU             7
104
                              MF_Srand                EQU             8
105
                              MF_Random               EQU             9
106
                              MF_OSCALL               EQU             10
107 16 robfinch
                              MF_GetRange     EQU             11      ; gets a pair of numbers last>first
108
                              MF_GetNumber    EQU     12
109 15 robfinch
 
110
                              mon_numwka      EQU             $910
111
                              mon_r1          EQU             $920
112
                              mon_r2          EQU             $924
113
                              ; ============================================================================
114
                              ;        __
115
                              ;   \\__/ o\    (C) S2022  Robert Finch, Waterloo
116
                              ;    \  __ /    All rights reserved.
117
                              ;     \/_//     robfinch@opencores.org
118
                              ;       ||
119
                              ;
120
                              ;
121
                              ; BSD 3-Clause License
122
                              ; Redistribution and use in source and binary forms, with or without
123
                              ; modification, are permitted provided that the following conditions are met:
124
                              ;
125
                              ; 1. Redistributions of source code must retain the above copyright notice, this
126
                              ;    list of conditions and the following disclaimer.
127
                              ;
128
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
129
                              ;    this list of conditions and the following disclaimer in the documentation
130
                              ;    and/or other materials provided with the distribution.
131
                              ;
132
                              ; 3. Neither the name of the copyright holder nor the names of its
133
                              ;    contributors may be used to endorse or promote products derived from
134
                              ;    this software without specific prior written permission.
135
                              ;
136
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
137
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
138
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
139
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
140
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
141
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
142
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
143
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
144
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146
                              ;
147
                              ; ============================================================================
148
 
149
                              COREID  EQU             $FFFFFFFE0
150
                              MSCOUNT EQU             $FFFFFFFE4
151
                              LEDS            EQU             $FFFE60001
152
                              VIA                     EQU             $FFFE60000
153
                              VIA_PA          EQU             1
154
                              VIA_DDRA        EQU             3
155
                              VIA_ACR                 EQU             11
156
                              VIA_IFR                 EQU             13
157
                              VIA_IER                 EQU             14
158
                              VIA_T3LL                EQU             18
159
                              VIA_T3LH                EQU             19
160
                              VIA_T3CMPL      EQU             20
161
                              VIA_T3CMPH      EQU             21
162
                              TEXTSCR         EQU             $FFFE00000
163
                              TEXTREG         EQU             $FFFE07F00
164
                              TEXT_COLS       EQU             0
165
                              TEXT_ROWS       EQU             1
166
                              TEXT_CURPOS     EQU             34
167
                              COLS            EQU             64
168
                              ROWS            EQU             32
169
                              ACIA            EQU             $FFFE30100
170
                              ACIA_TX         EQU             0
171
                              ACIA_RX         EQU             0
172
                              ACIA_STAT       EQU             1
173
                              ACIA_CMD        EQU             2
174
                              ACIA_CTRL       EQU             3
175
                              ACIA_CTRL2      EQU             11
176
                              RTC                             EQU             $FFFE30500      ; I2C
177
                              RTCBuf          EQU             $7FC0
178
                              PRNG            EQU             $FFFE30600
179
                              KEYBD           EQU             $FFFE30400
180
                              KEYBDCLR        EQU             $FFFE30402
181
                              PIC                     EQU             $FFFE3F000
182
                              SPRITE_CTRL             EQU             $FFFE10000
183
                              SPRITE_EN                       EQU             $3C0
184
 
185
                              OUTSEMA EQU     $EF0000
186
                              SEMAABS EQU     $1000
187
                              OSSEMA  EQU     $EF0010
188
 
189 16 robfinch
                              OPC_SWI                         EQU             $03F
190 4 robfinch
                              ScreenLocation          EQU             $10
191
                              ColorCodeLocation       EQU             $14
192
                              ScreenLocation2         EQU             $18
193
                              BlkcpySrc                       EQU             $1C
194
                              BlkcpyDst                       EQU             $20
195
                              Strptr                          EQU             $24
196
                              PICptr                          EQU             $28
197
                              ; Forth Area
198
                              ; 0x30-0x60
199
 
200
                              ; Task control blocks, room for 256 tasks
201
                              TCB_NxtRdy              EQU             $00     ; next task on ready / timeout list
202
                              TCB_PrvRdy              EQU             $04     ; previous task on ready / timeout list
203
                              TCB_NxtTCB              EQU             $08
204
                              TCB_Timeout             EQU             $0C
205
                              TCB_Priority    EQU             $10
206
                              TCB_MSGPTR_D1   EQU             $14
207
                              TCB_MSGPTR_D2   EQU             $18
208
                              TCB_hJCB                        EQU             $1C
209
                              TCB_Status              EQU             $1E
210
                              TCB_CursorRow   EQU             $20
211
                              TCB_CursorCol   EQU             $21
212
                              TCB_hWaitMbx    EQU             $22     ; handle of mailbox task is waiting at
213
                              TCB_mbq_next    EQU             $24     ; mailbox queue next
214
                              TCB_mbq_prev    EQU             $28     ; mailbox queue previous
215
                              TCB_iof_next    EQU             $2C
216
                              TCB_iof_prev    EQU             $30
217
                              TCB_SPSave              EQU             $34     ; TCB_SPSave area
218
                              TCB_mmu_map             EQU             $38
219
 
220
                              KeybdHead               EQU             $FFFFFC800
221
                              KeybdTail               EQU             $FFFFFC900
222
                              KeybdEcho               EQU             $FFFFFCA00
223
                              KeybdBad                EQU             $FFFFFCB00
224
                              KeybdAck                EQU             $FFFFFCC00
225
                              KeybdLocks              EQU             $FFFFFCD00
226
                              KeybdBuffer             EQU             $FFFFFC000      ; buffer is 16 chars
227
 
228
                              BIOS_SCREENS    EQU     $17000000       ; $17000000 to $171FFFFF
229
 
230
                              ; EhBASIC vars:
231
                              ;
232 15 robfinch
                              NmiBase         EQU             $FFC013
233
                              IrqBase         EQU             $FFC014
234 4 robfinch
 
235
                              IOFocusNdx      EQU             $100
236
 
237 13 robfinch
                              ; These variables in global OS storage area
238
 
239 15 robfinch
                              IOFocusList     EQU             $FFC000 ; to $FF000F
240
                              IOFocusID               EQU             $FFC010
241
                              IrqSource               EQU             $FFC011
242
                              IRQFlag                 EQU             $FFC012
243
                              RunningID               EQU             $FFC013
244 16 robfinch
                              ; Top of boot stack is at $FFC0FF
245 13 robfinch
 
246 4 robfinch
                              ; These variables use direct page access
247
                              CursorRow       EQU             $110
248
                              CursorCol       EQU             $111
249
                              CharColor       EQU             $112
250
                              ScreenColor     EQU             $113
251
                              CursorFlash     EQU             $114
252
                              KeyState1       EQU     $120
253
                              KeyState2       EQU     $121
254
                              KeyLED          EQU     $122
255
                              KeybdID         EQU     $124
256 13 robfinch
                              KeybdBlock      EQU     $126
257
                              kbdHeadRcv      EQU     $127
258
                              kbdTailRcv      EQU     $128
259
                              kbdFifo                 EQU     $40                             ; in local RAM
260
                              kbdFifoAlias    EQU     $C00040 ; to $C0007F    ; alias for $40 to $7F
261
                              SerhZero                EQU     $130
262
                              SerHeadRcv      EQU     $131
263
                              SertZero                EQU     $132
264
                              SerTailRcv      EQU     $133
265
                              SerHeadXmit     EQU     $136
266
                              SerTailXmit     EQU     $138
267
                              SerRcvXon               EQU     $139
268
                              SerRcvXoff      EQU     $140
269
                              SerRcvBuf               EQU     $BFF000 ; 4kB serial recieve buffer
270 4 robfinch
 
271 14 robfinch
                              farflag EQU             $15F
272 13 robfinch
                              asmbuf  EQU             $160    ; to $17F
273
 
274 4 robfinch
                              QNdx0           EQU             $780
275
                              QNdx1           EQU             QNdx0+2
276
                              QNdx2           EQU             QNdx1+2
277
                              QNdx3           EQU             QNdx2+2
278
                              QNdx4           EQU             QNdx3+2
279
                              FreeTCB         EQU             QNdx4+2
280
                              TimeoutList     EQU             FreeTCB+2
281
                              FreeMbx         EQU             RunningTCB + 2
282
                              nMailbox        EQU             FreeMbx + 2
283
                              FreeMsg         EQU             nMailbox + 2
284
                              nMsgBlk         EQU             FreeMsg + 2
285
 
286
 
287
                              CharOutVec      EQU             $800
288
                              CharInVec       EQU             $804
289 13 robfinch
                              CmdPromptJI     EQU     $808
290 14 robfinch
                              MonErrVec       EQU             $80C
291 15 robfinch
                              BreakpointFlag  EQU             $810
292
                              NumSetBreakpoints       EQU     $811
293
                              Breakpoints                     EQU             $820    ; to $82F
294
                              BreakpointBytes EQU             $830    ; to $83F
295
                              mon_vectb                               EQU             $880
296 4 robfinch
 
297
                              ; Register save area for monitor
298
                              mon_DSAVE       EQU             $900
299
                              mon_XSAVE       EQU             $902
300
                              mon_YSAVE       EQU             $904
301
                              mon_USAVE       EQU             $906
302
                              mon_SSAVE       EQU             $908
303
                              mon_PCSAVE      EQU             $90A
304
                              mon_DPRSAVE     EQU             $90E
305
                              mon_CCRSAVE     EQU             $90F
306
 
307
                              mon_numwka      EQU             $910
308
                              mon_r1          EQU             $920
309 13 robfinch
                              mon_r2          EQU             $924
310 15 robfinch
                              jmpvec          EQU             $928
311 16 robfinch
                              mon_init        EQU             $92C
312
                              mon_retflag     EQU     $930
313 4 robfinch
 
314
                              ; The ORG directive must set an address a multiple of 4 in order for the Verilog
315
                              ; output to work correctly.
316
 
317
                                      org             $FFD0AC
318
 00FFD0AC 012                             nop
319
 00FFD0AD 012                             nop
320
 00FFD0AE 012                             nop
321
                              XBLANK
322
 00FFD0AF 0C6020                          ldb             #' '
323 16 robfinch
 00FFD0B1 017001E2D                       lbsr    OUTCH
324 4 robfinch
 00FFD0B4 039                             rts
325
 
326
                                      org             $FFD0D0
327
 00FFD0D0 012                             nop
328
 00FFD0D1 012                             nop
329
                              CRLF
330
                              CRLF1:
331
 00FFD0D2 0C600D                          ldb             #CR
332 16 robfinch
 00FFD0D4 017001E0A                       lbsr    OUTCH
333 4 robfinch
 00FFD0D7 0C600A                          ldb             #LF
334 16 robfinch
 00FFD0D9 017001E05                       lbsr    OUTCH
335 4 robfinch
 00FFD0DC 039                             rts
336
 
337
                                      org             $FFD0F0
338
 00FFD0F0 012                             nop
339
 00FFD0F1 020FDF                          bra             CRLF1
340
 
341
                                      org             $FFD1DC
342
                              ONEKEY
343
 00FFD1DC 06E90F000804                    jmp             [CharInVec]
344
 
345
                                      org             $FFD2C0
346
 00FFD2C0 012                             nop
347
                              LETTER
348 16 robfinch
 00FFD2C1 017001C1D                       lbsr    OUTCH
349 4 robfinch
 00FFD2C4 039                             rts
350
 
351
                                      org             $FFD2CC
352
 00FFD2CC 012                             nop
353
 00FFD2CD 012                             nop
354
                              HEX2
355 16 robfinch
 00FFD2CE 017001166                       lbsr    DispByteAsHex
356 4 robfinch
 00FFD2D1 039                             rts
357
                              HEX4
358 16 robfinch
 00FFD2D2 017001159                       lbsr    DispWordAsHex
359 4 robfinch
 00FFD2D5 039                             rts
360
 
361
                                      org             $FFD300
362
                              ClearScreenJmp
363 16 robfinch
 00FFD300 016000F36                       lbra    ClearScreen
364 4 robfinch
                                      org             $FFD308
365
                              HomeCursorJmp
366 16 robfinch
 00FFD308 016000FA5                       lbra    HomeCursor
367 4 robfinch
 
368 13 robfinch
                                      org             $FFD400
369 4 robfinch
 
370
                              ; Local RAM test routine
371
                              ; Checkerboard testing.
372
                              ; There is 70kB of local RAM
373
                              ; Does not use any RAM including no stack
374
 
375
                              ramtest:
376 13 robfinch
 00FFD400 18E000000                       ldy             #0
377
 00FFD403 086001                          lda             #1
378
 00FFD405 0150B7FFFE60001                 sta             LEDS
379
 00FFD40A 0CCAAA555                       ldd             #$AAA555
380 4 robfinch
                              ramtest1:
381 13 robfinch
 00FFD40D 0EDA01                          std             ,y++
382
 00FFD40F 18C008000                       cmpy    #$8000
383
 00FFD412 025FF9                          blo             ramtest1
384 4 robfinch
                                      ; now readback values and compare
385 13 robfinch
 00FFD414 18E000000                       ldy             #0
386 4 robfinch
                              ramtest3:
387 13 robfinch
 00FFD417 0ECA01                          ldd             ,y++
388
 00FFD419 183AAA555                       cmpd    #$AAA555
389
 00FFD41C 02600E                          bne             ramerr
390
 00FFD41E 18C008000                       cmpy    #$8000
391
 00FFD421 025FF4                          blo             ramtest3
392
 00FFD423 086002                          lda             #2
393
 00FFD425 0150B7FFFE60001                 sta             LEDS
394
 00FFD42A 06EC04                          jmp             ,u
395 4 robfinch
                              ramerr:
396 13 robfinch
 00FFD42C 086080                          lda             #$80
397
 00FFD42E 0150B7FFFE60001                 sta             LEDS
398 16 robfinch
 00FFD433 0150F6FFFFFFFE0                 ldb             COREID
399
 00FFD438 0C1020                          cmpb    #$20
400
 00FFD43A 027009                          beq             ramerr1
401
 00FFD43C 08EE00000                       ldx             #TEXTSCR
402
 00FFD43F 03A                             abx
403
 00FFD440 086046                          lda             #'F'
404
 00FFD442 0A7804                          sta             ,x
405
 00FFD444 013                             sync
406
                              ramerr1:
407
 00FFD445 06EC04                          jmp             ,u
408 4 robfinch
 
409 15 robfinch
 
410 13 robfinch
                                      org             $FFE000
411 16 robfinch
 00FFE000 FFF039                          FDB Monitor
412 13 robfinch
 00FFE002 FFE022                          FDB DumRts      ;       NEXTCMD
413 16 robfinch
 00FFE004 FFEEA9                          FDB INCH
414
 00FFE006 FFEEC7                          FDB INCHE
415
 00FFE008 FFEECB                          FDB INCHEK
416
 00FFE00A FFEEE1                          FDB OUTCH
417
 00FFE00C FFE41B                          FDB PDATA
418
 00FFE00E FFE40E                          FDB PCRLF
419
 00FFE010 FFE40A                          FDB PSTRNG
420 13 robfinch
 00FFE012 FFE022                          FDB DumRts                      ; LRA
421
 00FFE014 FFE022                          FDB DumRts
422
 00FFE016 FFE022                          FDB DumRts
423
 00FFE018 FFE022                          FDB DumRts
424
 00FFE01A FFE022                          FDB DumRts                      ; VINIZ
425 16 robfinch
 00FFE01C FFE319                          FDB DisplayChar ;       VOUTCH
426 13 robfinch
 00FFE01E FFE022                          FDB DumRts                      ; ACINIZ
427
 00FFE020 FFE022                          FDB DumRts                      ; AOUTCH
428 4 robfinch
 
429
                              DumRts:
430 13 robfinch
 00FFE022 039                             rts
431 4 robfinch
 
432
                              ;------------------------------------------------------------------------------
433
                              ;------------------------------------------------------------------------------
434
 
435
                              start:
436 13 robfinch
 00FFE023 086FFF                          lda             #$FFF                   ; all cores can do this
437
 00FFE025 0150B7FFFE60003                 sta             VIA+VIA_DDRA
438
 00FFE02A 086055                          lda             #$55                    ; see if we can at least set LEDs
439
 00FFE02C 0150B7FFFE60001                 sta             LEDS
440
 00FFE031 086001                          lda             #1                              ; prime OS semaphore
441
 00FFE033 0B7EF1010                       sta             OSSEMA+$1000
442 15 robfinch
 00FFE036 0B7EF1000                       sta             OUTSEMA+$1000
443 16 robfinch
 00FFE039 0CEFFE03C                       ldu             #st6                    ; U = return address
444
                              ;       jmp             ramtest         ; JMP dont JSR
445 4 robfinch
                              st6:
446 16 robfinch
 00FFE03C 1CE006FFF                       lds             #$6FFF          ; boot up stack area
447
 00FFE03F 0150B6FFFFFFFE0                 lda             COREID
448
 00FFE044 081001                          cmpa    #FIRST_CORE
449 4 robfinch
                              ;       beq             st8
450
                              ;       sync                                            ; halt cores other than 2
451
                              st8:
452
                              ;       bne             skip_init
453
                              ;       bsr             romToRam
454
                              ;       ldd             #st7 & $FFFF
455
                              ;       tfr             d,x
456
                              ;       jmp             ,x                              ; jump to the BIOS now in local RAM
457
                              st7:
458 16 robfinch
 00FFE046 08D16D                          bsr             Delay3s         ; give some time for devices to reset
459
 00FFE048 07F000810                       clr             BreakpointFlag
460
 00FFE04B 07F000811                       clr             NumSetBreakpoints
461
 00FFE04E 0860AA                          lda             #$AA
462
 00FFE050 0150B7FFFE60001                 sta             LEDS
463
 00FFE055 0150B6FFFFFFFE0                 lda             COREID
464
 00FFE05A 081020                          cmpa    #$20
465
 00FFE05C 027002                          beq             st11
466
 00FFE05E 086001                          lda             #FIRST_CORE
467
                              st11:
468
 00FFE060 0B7FFC010                       sta             IOFocusID       ; core #2 has focus
469
 00FFE063 0B7FFC013                       sta             RunningID
470 14 robfinch
                                      ; Clear IO focus list
471 16 robfinch
 00FFE066 08E000000                       ldx             #0
472 14 robfinch
                              st9:
473 16 robfinch
 00FFE069 06F80A000FFC000                 clr             IOFocusList,x
474
 00FFE06E 030001                          inx
475
 00FFE070 08C000010                       cmpx    #16
476
 00FFE073 025FF4                          blo             st9
477
 00FFE075 086018                          lda             #24
478
 00FFE077 0B7FFC001                       sta             IOFocusList+FIRST_CORE
479 14 robfinch
 
480 16 robfinch
 00FFE07A 0860CE                          lda             #$0CE
481
 00FFE07C 097113                          sta             ScreenColor
482
 00FFE07E 097112                          sta             CharColor
483
 00FFE080 08D1B7                          bsr             ClearScreen
484
 00FFE082 0CCFFE319                       ldd             #DisplayChar
485
 00FFE085 0FD000800                       std             CharOutVec
486
 00FFE088 0CCFFEC64                       ldd             #SerialPeekCharDirect
487
 00FFE08B 0FD000804                       std             CharInVec
488 15 robfinch
                              ;       swi
489
                              ;       fcb             MF_OSCALL
490
                              ;       fcb             24                                      ; request IO focus
491 16 robfinch
 00FFE08E 0150F6FFFFFFFE0                 ldb             COREID
492
 00FFE093 0C1001                          cmpb    #FIRST_CORE
493
 00FFE095 027011                          beq             init
494
 00FFE097 0C1020                          cmpb    #$20                            ; CmodA709 core?
495
 00FFE099 02705D                          beq             init2
496
 00FFE09B 02006D                          bra             skip_init
497
 00FFE09D 0200B4                          bra             multi_sieve
498 4 robfinch
                              st3:
499 16 robfinch
 00FFE09F 0860FF                          lda             #$FF
500
 00FFE0A1 0150B7FFFE60001                 sta             LEDS
501
 00FFE0A6 020FF7                          bra             st3
502 4 robfinch
 
503
                                      ; initialize interrupt controller
504
                                      ; first, zero out all the vectors
505
                              init:
506 16 robfinch
 00FFE0A8 017000449                       lbsr    rtc_read        ; get clock values
507
 00FFE0AB 08E000127                       ldx             #kbdHeadRcv
508
 00FFE0AE 0C6020                          ldb             #32                             ; number of bytes to zero out
509 13 robfinch
                              init1:
510 16 robfinch
 00FFE0B0 06F800                          clr             ,x+
511
 00FFE0B2 05A                             decb
512
 00FFE0B3 026FFB                          bne             init1
513 4 robfinch
                              st1:
514 16 robfinch
 00FFE0B5 06F809E3F000                    clr             PIC,x                   ; cause code
515
 00FFE0B9 0A7809E3F001                    sta             PIC+1,x
516
 00FFE0BD 0E7809E3F002                    stb             PIC+2,x
517
 00FFE0C1 030004                          leax    4,x
518
 00FFE0C3 08C000100                       cmpx    #256
519
 00FFE0C6 025FED                          blo             st1
520
 00FFE0C8 086081                          lda             #$81                    ; make irq edge sensitive
521
 00FFE0CA 0150B7FFFE3F0FD                 sta             PIC+$FD
522
 00FFE0CF 08601F                          lda             #31                             ; enable timer interrupt
523
 00FFE0D1 0150B7FFFE3F009                 sta             PIC+9
524
 00FFE0D6 086040                          lda             #COLS
525
 00FFE0D8 0150B7FFFE07F00                 sta             TEXTREG+TEXT_COLS
526
 00FFE0DD 086020                          lda             #ROWS
527
 00FFE0DF 0150B7FFFE07F01                 sta             TEXTREG+TEXT_ROWS
528
 00FFE0E4 08D153                          bsr             ClearScreen
529
 00FFE0E6 08D1C8                          bsr             HomeCursor
530
 00FFE0E8 08E000000                       ldx             #0
531
 00FFE0EB 0CC000000                       ldd             #0
532
 00FFE0EE 017000DFA                       lbsr    ShowSprites
533
 00FFE0F1 0170008CC                       lbsr    KeybdInit
534
 00FFE0F4 0DC124                          ldd             KeybdID
535
 00FFE0F6 08D336                          bsr             DispWordAsHex
536
                              init2:
537
 00FFE0F8 01700036A                       lbsr    TimerInit
538
 00FFE0FB 017000AF1                       lbsr    InitSerial
539
 00FFE0FE 08E000080                       ldx             #128
540
 00FFE101 086001                          lda             #1                      ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
541
 00FFE103 0C6001                          ldb             #FIRST_CORE                     ; serving core id
542 4 robfinch
                              ;       lda             #4                              ; make the timer interrupt edge sensitive
543
                              ;       sta             PIC+4                   ; reg #4 is the edge sensitivity setting
544
                              ;       sta             PIC                             ; reg #0 is interrupt enable
545 16 robfinch
 00FFE105 0C6001                          ldb             #1
546
 00FFE107 0F7EF1000                       stb             OUTSEMA+SEMAABS ; set semaphore to 1 available slot
547 4 robfinch
                              skip_init:
548 16 robfinch
 00FFE10A 01C0EF                          andcc   #$EF                    ; unmask irq
549
 00FFE10C 086005                          lda             #5
550
 00FFE10E 0150B7FFFE60001                 sta             LEDS
551
 00FFE113 0CCFFE11C                       ldd             #msgStartup
552
 00FFE116 08D2C2                          bsr             DisplayString
553
                              st10:
554
 00FFE118 03F                             swi
555
 00FFE119 000                             fcb             MF_Monitor
556
 00FFE11A 020FFC                          bra             st10
557 4 robfinch
 
558
                              msgStartup
559 16 robfinch
 00FFE11C 072066036038030039020           fcb             "rf6809 12-bit System Starting.",CR,LF,0
560
 00FFE123 03103202D062069074020
561
 00FFE12A 05307907307406506D020
562
 00FFE131 05307406107207406906E
563
 00FFE138 06702E00D00A000
564 4 robfinch
 
565
                              ;------------------------------------------------------------------------------
566
                              ; The checkpoint register must be cleared within 1 second or a NMI interrupt
567
                              ; will occur. checkpoint should be called with a JSR so that the global ROM
568
                              ; routine is called.
569
                              ;
570
                              ; Modifies:
571
                              ;               none
572
                              ;------------------------------------------------------------------------------
573
 
574
                              checkpoint:
575 16 robfinch
 00FFE13D 01507FFFFFFFFE1                 clr             $FFFFFFFE1      ; writing any value will do
576
 00FFE142 039                             rts
577 4 robfinch
 
578
                              ;------------------------------------------------------------------------------
579
                              ; Copy the system ROM to local RAM
580
                              ; Running the code from local RAM is probably an order of magnitude faster
581
                              ; then running from the global ROM. It also reduces the network traffic to
582
                              ; run from local RAM.
583
                              ;
584
                              ; Modifies:
585
                              ;               d,x,y
586
                              ;------------------------------------------------------------------------------
587
 
588
                              romToRam:
589 16 robfinch
 00FFE143 08EFFC000                       ldx             #$FFC000
590
 00FFE146 18E00C000                       ldy             #$00C000
591 4 robfinch
                              romToRam1:
592 16 robfinch
 00FFE149 0EC801                          ldd             ,x++
593
 00FFE14B 0EDA01                          std             ,y++
594
 00FFE14D 08C000000                       cmpx    #0
595
 00FFE150 026FF7                          bne             romToRam1
596
 00FFE152 039                             rts
597 4 robfinch
 
598
                              ;------------------------------------------------------------------------------
599
                              ; Multi-core sieve program.
600
                              ;------------------------------------------------------------------------------
601
 
602
                              ; First fill screen chars with 'P' indicating prime positions
603
                              ; Each core is responsible for the Nth position where N is the
604
                              ; core number minus two.
605
                              ;
606
                              multi_sieve:
607 16 robfinch
 00FFE153 086050                          lda             #'P'                                    ; indicate prime
608
 00FFE155 0150F6FFFFFFFE0                 ldb             COREID                          ; find out which core we are
609
 00FFE15A 0C0001                          subb    #FIRST_CORE
610
 00FFE15C 08E000000                       ldx             #0                                              ; start at first char of screen
611
 00FFE15F 03A                             abx
612 4 robfinch
                              multi_sieve3:
613 16 robfinch
 00FFE160 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
614
 00FFE164 030008                          leax    8,x                                             ; advance to next position
615
 00FFE166 08C000FFF                       cmpx    #4095
616
 00FFE169 025FF5                          blo             multi_sieve3
617
 00FFE16B 0BDFFE13D                       jsr             checkpoint
618 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
619 16 robfinch
 00FFE16E 0CB002                          addb    #2                                              ; start sieve at 2 (core id)
620
 00FFE170 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
621 4 robfinch
                              multi_sieve2:
622 16 robfinch
 00FFE172 08E000000                       ldx             #0
623
 00FFE175 03A                             abx                                                                     ; skip the first position - might be prime
624 4 robfinch
                              multi_sieve1:
625 16 robfinch
 00FFE176 03A                             abx                                                                     ; increment
626
 00FFE177 0A7809E00000                    sta             TEXTSCR,x
627
 00FFE17B 08C000FFF                       cmpx    #4095
628
 00FFE17E 025FF6                          blo             multi_sieve1
629
 00FFE180 0BDFFE13D                       jsr             checkpoint
630 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
631 16 robfinch
 00FFE183 0CB008                          addb    #8                                              ; number of cores working on it
632
 00FFE185 0C1FF0                          cmpb    #4080
633
 00FFE187 025FE9                          blo             multi_sieve2
634 4 robfinch
                              multi_sieve4:                                   ; hang machine
635 16 robfinch
 00FFE189 013                             sync
636
 00FFE18A 016000EAC                       lbra    Monitor
637 4 robfinch
 
638 13 robfinch
                              ;------------------------------------------------------------------------------
639
                              ; Single core sieve.
640
                              ;------------------------------------------------------------------------------
641
 
642 4 robfinch
                              sieve:
643 16 robfinch
 00FFE18D 086050                          lda             #'P'                                    ; indicate prime
644
 00FFE18F 08E000000                       ldx             #0                                              ; start at first char of screen
645 4 robfinch
                              sieve3:
646 16 robfinch
 00FFE192 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
647
 00FFE196 030001                          inx                                                                     ; advance to next position
648
 00FFE198 08C000FFF                       cmpx    #4095
649
 00FFE19B 025FF5                          blo             sieve3
650
 00FFE19D 0C6002                          ldb             #2                                              ; start sieve at 2
651
 00FFE19F 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
652 4 robfinch
                              sieve2:
653 16 robfinch
 00FFE1A1 08E000000                       ldx             #0
654
 00FFE1A4 03A                             abx                                                                     ; skip the first position - might be prime
655 4 robfinch
                              sieve1:
656 16 robfinch
 00FFE1A5 03A                             abx                                                                     ; increment
657
 00FFE1A6 0A7809E00000                    sta             TEXTSCR,x
658
 00FFE1AA 08C000FFF                       cmpx    #4095
659
 00FFE1AD 025FC7                          blo             multi_sieve1
660
 00FFE1AF 05C                             incb                                                            ; number of cores working on it
661
 00FFE1B0 0C1FF0                          cmpb    #4080
662
 00FFE1B2 025FED                          blo             sieve2
663 4 robfinch
                              sieve4:                                                         ; hang machine
664 16 robfinch
 00FFE1B4 039                             rts
665 4 robfinch
 
666
                              ;------------------------------------------------------------------------------
667
                              ; Three second delay for user convenience and to allow some devices time to
668
                              ; reset.
669
                              ;------------------------------------------------------------------------------
670
 
671
                              Delay3s:
672 16 robfinch
 00FFE1B5 0CC895440                       ldd             #9000000
673 4 robfinch
                              dly3s1:
674 16 robfinch
 00FFE1B8 0C10FF                          cmpb    #$FF
675
 00FFE1BA 026000                          bne             dly3s2
676 4 robfinch
                              dly3s2:
677 16 robfinch
 00FFE1BC 0150B7FFFE60001                 sta             LEDS
678
 00FFE1C1 083000001                       subd    #1
679
 00FFE1C4 026FF2                          bne             dly3s1
680
 00FFE1C6 039                             rts
681 4 robfinch
 
682
                              ;------------------------------------------------------------------------------
683
                              ;------------------------------------------------------------------------------
684
                              ShiftLeft5:
685 16 robfinch
 00FFE1C7 058                             aslb
686
 00FFE1C8 049                             rola
687
 00FFE1C9 058                             aslb
688
 00FFE1CA 049                             rola
689
 00FFE1CB 058                             aslb
690
 00FFE1CC 049                             rola
691
 00FFE1CD 058                             aslb
692
 00FFE1CE 049                             rola
693
 00FFE1CF 058                             aslb
694
 00FFE1D0 049                             rola
695
 00FFE1D1 039                             rts
696 4 robfinch
 
697
                              ;------------------------------------------------------------------------------
698 13 robfinch
                              ; Parameters:
699
                              ;               b = core id of core to copy
700 4 robfinch
                              ;------------------------------------------------------------------------------
701
                              ;
702
                              CopyVirtualScreenToScreen:
703 16 robfinch
 00FFE1D2 034076                          pshs    d,x,y,u
704 13 robfinch
                                      ; Compute virtual screen location for core passed in accb.
705 16 robfinch
 00FFE1D4 01F098                          tfr             b,a
706
 00FFE1D6 048                             asla
707
 00FFE1D7 048                             asla
708
 00FFE1D8 048                             asla
709
 00FFE1D9 048                             asla
710
 00FFE1DA 08AC00                          ora             #$C00
711
 00FFE1DC 05F                             clrb
712
 00FFE1DD 01F001                          tfr             d,x
713
 00FFE1DF 034006                          pshs    d
714
 00FFE1E1 18EE00000                       ldy             #TEXTSCR
715
 00FFE1E4 0CE000400                       ldu             #COLS*ROWS/2
716 4 robfinch
                              cv2s1:
717 16 robfinch
 00FFE1E7 0EC801                          ldd             ,x++
718
 00FFE1E9 0EDA01                          std             ,y++
719
 00FFE1EB 0335FF                          leau    -1,u
720
 00FFE1ED 283000000                       cmpu    #0
721
 00FFE1F0 026FF5                          bne             cv2s1
722 4 robfinch
                                      ; reset the cursor position in the text controller
723 16 robfinch
 00FFE1F2 035010                          puls    x
724
 00FFE1F4 0E6808110                       ldb             CursorRow,x
725
 00FFE1F7 086040                          lda             #COLS
726
 00FFE1F9 03D                             mul
727
 00FFE1FA 01F002                          tfr             d,y
728
 00FFE1FC 0E6808111                       ldb             CursorCol,x
729
 00FFE1FF 01F021                          tfr             y,x
730
 00FFE201 03A                             abx
731
 00FFE202 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
732
 00FFE207 0350F6                          puls    d,x,y,u,pc
733 4 robfinch
 
734
                              ;------------------------------------------------------------------------------
735
                              ;------------------------------------------------------------------------------
736
                              ;
737
                              CopyScreenToVirtualScreen:
738 16 robfinch
 00FFE209 034076                          pshs    d,x,y,u
739
 00FFE20B 08D08D                          bsr             GetScreenLocation
740
 00FFE20D 01F002                          tfr             d,y
741
 00FFE20F 08EE00000                       ldx             #TEXTSCR
742
 00FFE212 0CE000400                       ldu             #COLS*ROWS/2
743 4 robfinch
                              cs2v1:
744 16 robfinch
 00FFE215 0EC801                          ldd             ,x++
745
 00FFE217 0EDA01                          std             ,y++
746
 00FFE219 0335FF                          leau    -1,u
747
 00FFE21B 283000000                       cmpu    #0
748
 00FFE21E 026FF5                          bne             cs2v1
749
 00FFE220 0350F6                          puls    d,x,y,u,pc
750 4 robfinch
 
751
                              ;------------------------------------------------------------------------------
752
                              ;------------------------------------------------------------------------------
753 16 robfinch
 00FFE222 054045058054053043052           fcb             "TEXTSCR "
754
 00FFE229 020
755
 00FFE22A FFE234                          fcw             TextOpen
756
 00FFE22C FFE235                          fcw             TextClose
757
 00FFE22E FFE236                          fcw             TextRead
758
 00FFE230 FFE237                          fcw             TextWrite
759
 00FFE232 FFE238                          fcw             TextSeek
760 4 robfinch
 
761
                              TextOpen:
762 16 robfinch
 00FFE234 039                             rts
763 4 robfinch
                              TextClose:
764 16 robfinch
 00FFE235 039                             rts
765 4 robfinch
                              TextRead:
766 16 robfinch
 00FFE236 039                             rts
767 4 robfinch
                              TextWrite:
768 16 robfinch
 00FFE237 039                             rts
769 4 robfinch
                              TextSeek:
770 16 robfinch
 00FFE238 039                             rts
771 4 robfinch
 
772
                              ;------------------------------------------------------------------------------
773
                              ; Clear the screen and the screen color memory
774
                              ; We clear the screen to give a visual indication that the system
775
                              ; is working at all.
776
                              ;
777
                              ; Modifies:
778
                              ;               none
779
                              ;------------------------------------------------------------------------------
780
 
781
                              ClearScreen:
782 16 robfinch
 00FFE239 034076                          pshs    d,x,y,u
783
 00FFE23B 08E000800                       ldx             #COLS*ROWS
784
 00FFE23E 01F013                          tfr             x,u
785
 00FFE240 08D058                          bsr             GetScreenLocation
786
 00FFE242 01F002                          tfr             d,y
787
 00FFE244 0C6020                          ldb             #' '                            ; space char
788 4 robfinch
                              cs1:
789 16 robfinch
 00FFE246 0E7A00                          stb             ,y+                                     ; set text to space
790
 00FFE248 0301FF                          leax    -1,x                            ; decrement x
791
 00FFE24A 026FFA                          bne             cs1
792
 00FFE24C 0150F6FFFFFFFE0                 ldb             COREID                  ; update colors only if we have focus
793
 00FFE251 0F1FFC010                       cmpb    IOFocusID
794
 00FFE254 02000D                          bra             cs3
795
 00FFE256 18EE02000                       ldy             #TEXTSCR+$2000
796 4 robfinch
                              ;       lda             CharColor
797 16 robfinch
 00FFE259 0860CE                          lda             #$0CE
798
 00FFE25B 01F031                          tfr             u,x                                     ; get back count
799 4 robfinch
                              cs2:
800 16 robfinch
 00FFE25D 0A7A00                          sta             ,y+
801
 00FFE25F 0301FF                          dex                                                             ; decrement x
802
 00FFE261 026FFA                          bne             cs2
803 4 robfinch
                              cs3:
804 16 robfinch
 00FFE263 0350F6                          puls    d,x,y,u,pc
805 4 robfinch
 
806
                              ;------------------------------------------------------------------------------
807
                              ; Scroll text on the screen upwards
808
                              ;
809
                              ; Modifies:
810
                              ;               none
811
                              ;------------------------------------------------------------------------------
812
 
813
                              ScrollUp:
814 16 robfinch
 00FFE265 034076                          pshs    d,x,y,u
815
 00FFE267 18E0003FF                       ldy             #(COLS*ROWS-1)/2        ; y = num chars/2 to move
816
 00FFE26A 08D02E                          bsr             GetScreenLocation
817
 00FFE26C 01F001                          tfr             d,x
818
 00FFE26E 01F003                          tfr             d,u
819
 00FFE270 030040                          leax    COLS,x          ; x = index to source row
820 4 robfinch
                              scrup1:
821 16 robfinch
 00FFE272 0EC801                          ldd             ,x++                    ; move 2 characters
822
 00FFE274 0EDC01                          std             ,u++
823
 00FFE276 0313FF                          dey
824
 00FFE278 026FF8                          bne             scrup1
825
 00FFE27A 08601F                          lda             #ROWS-1
826
 00FFE27C 08D002                          bsr             BlankLine
827
 00FFE27E 0350F6                          puls    d,x,y,u,pc
828 4 robfinch
 
829
                              ;------------------------------------------------------------------------------
830
                              ; Blank out a line on the display
831
                              ;
832
                              ; Modifies:
833
                              ;               none
834
                              ; Parameters:
835
                              ;       acca = line number to blank
836
                              ;------------------------------------------------------------------------------
837
 
838
                              BlankLine:
839 16 robfinch
 00FFE280 034016                          pshs    d,x
840
 00FFE282 034002                          pshs    a
841
 00FFE284 08D014                          bsr             GetScreenLocation
842
 00FFE286 01F001                          tfr             d,x
843
 00FFE288 035002                          puls    a
844
 00FFE28A 0C6040                          ldb             #COLS   ; b = # chars to blank out from video controller
845
 00FFE28C 03D                             mul                                     ; d = screen index (row# * #cols)
846
 00FFE28D 03080B                          leax    d,x
847
 00FFE28F 086020                          lda             #' '
848
 00FFE291 0C6040                          ldb             #COLS   ; b = # chars to blank out from video controller
849 4 robfinch
                              blnkln1:
850 16 robfinch
 00FFE293 0A7800                          sta             ,x+
851
 00FFE295 05A                             decb
852
 00FFE296 026FFB                          bne             blnkln1
853
 00FFE298 035096                          puls    d,x,pc
854 4 robfinch
 
855
                              ;------------------------------------------------------------------------------
856
                              ; Get the location of the screen memory. The location
857
                              ; depends on whether or not the task has the output focus.
858
                              ;
859
                              ; Modifies:
860
                              ;               d
861
                              ; Retuns:
862
                              ;               d = screen location
863
                              ;------------------------------------------------------------------------------
864
 
865
                              GetScreenLocation:
866 16 robfinch
 00FFE29A 0150B6FFFFFFFE0                 lda             COREID                  ; which core are we?
867
 00FFE29F 0B1FFC010                       cmpa    IOFocusID               ; do we have the IO focus
868
 00FFE2A2 026008                          bne             gsl1                            ; no, go pick virtual screen address
869
 00FFE2A4 081020                          cmpa    #$20                            ; CmodA709?
870
 00FFE2A6 027004                          beq             gsl1
871
 00FFE2A8 0CCE00000                       ldd             #TEXTSCR                ; yes, we update the real screen
872
 00FFE2AB 039                             rts
873 4 robfinch
                              gsl1:
874 16 robfinch
 00FFE2AC 0CC007800                       ldd             #$7800
875
 00FFE2AF 039                             rts
876 4 robfinch
 
877
                              ;------------------------------------------------------------------------------
878
                              ; HomeCursor
879
                              ; Set the cursor location to the top left of the screen.
880
                              ;
881
                              ; Modifies:
882
                              ;               none
883
                              ;------------------------------------------------------------------------------
884
 
885
                              HomeCursor:
886 16 robfinch
 00FFE2B0 034016                          pshs    d,x
887
 00FFE2B2 00F110                          clr             CursorRow
888
 00FFE2B4 00F111                          clr             CursorCol
889
 00FFE2B6 0150F6FFFFFFFE0                 ldb             COREID
890
 00FFE2BB 0F1FFC010                       cmpb    IOFocusID
891
 00FFE2BE 02600A                          bne             hc1
892
 00FFE2C0 0C1020                          cmpb    #$20
893
 00FFE2C2 027006                          beq             hc1
894
 00FFE2C4 04F                             clra
895
 00FFE2C5 0150B7FFFE07F22                 sta             TEXTREG+TEXT_CURPOS
896 4 robfinch
                              hc1:
897 16 robfinch
 00FFE2CA 035096                          puls    d,x,pc
898 4 robfinch
 
899
                              ;------------------------------------------------------------------------------
900
                              ; Update the cursor position in the text controller based on the
901
                              ;  CursorRow,CursorCol.
902
                              ;
903
                              ; Modifies:
904
                              ;               none
905
                              ;------------------------------------------------------------------------------
906
                              ;
907
                              UpdateCursorPos:
908 16 robfinch
 00FFE2CC 034016                          pshs    d,x
909
 00FFE2CE 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
910
 00FFE2D3 0F1FFC010                       cmpb    IOFocusID                       ; only for the task with the output focus
911
 00FFE2D6 026018                          bne             ucp1
912
 00FFE2D8 0C1020                          cmpb    #$20                                    ; and not for CmodA709
913
 00FFE2DA 027014                          beq             ucp1
914
 00FFE2DC 096110                          lda             CursorRow
915
 00FFE2DE 08403F                          anda    #$3F                                    ; limit of 63 rows
916
 00FFE2E0 0150F6FFFE07F00                 ldb             TEXTREG+TEXT_COLS
917
 00FFE2E5 03D                             mul
918
 00FFE2E6 01F001                          tfr             d,x
919
 00FFE2E8 0D6111                          ldb             CursorCol
920
 00FFE2EA 03A                             abx
921
 00FFE2EB 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
922 4 robfinch
                              ucp1:
923 16 robfinch
 00FFE2F0 035096                          puls    d,x,pc
924 4 robfinch
 
925
                              ;------------------------------------------------------------------------------
926
                              ; Calculate screen memory location from CursorRow,CursorCol.
927
                              ; Also refreshes the cursor location.
928
                              ;
929
                              ; Modifies:
930
                              ;               d
931
                              ; Returns:
932
                              ;       d = screen location
933
                              ;------------------------------------------------------------------------------
934
                              ;
935
                              CalcScreenLoc:
936 16 robfinch
 00FFE2F2 034010                          pshs    x
937
 00FFE2F4 096110                          lda             CursorRow
938
 00FFE2F6 0C6040                          ldb             #COLS
939
 00FFE2F8 03D                             mul
940
 00FFE2F9 01F001                          tfr             d,x
941
 00FFE2FB 0D6111                          ldb             CursorCol
942
 00FFE2FD 03A                             abx
943
 00FFE2FE 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
944
 00FFE303 0F1FFC010                       cmpb    IOFocusID                       ; only for the task with the output focus
945
 00FFE306 026009                          bne             csl1
946
 00FFE308 0C1020                          cmpb    #$20
947
 00FFE30A 027005                          beq             csl1
948
 00FFE30C 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
949 4 robfinch
                              csl1:
950 16 robfinch
 00FFE311 08DF87                          bsr             GetScreenLocation
951
 00FFE313 03080B                          leax    d,x
952
 00FFE315 01F010                          tfr             x,d
953
 00FFE317 035090                          puls    x,pc
954 4 robfinch
 
955
                              ;------------------------------------------------------------------------------
956
                              ; Display a character on the screen.
957
                              ; If the task doesn't have the I/O focus then the character is written to
958
                              ; the virtual screen.
959
                              ;
960
                              ; Modifies:
961
                              ;               none
962
                              ; Parameters:
963
                              ;       accb = char to display
964
                              ;------------------------------------------------------------------------------
965
                              ;
966
                              DisplayChar:
967 16 robfinch
 00FFE319 01700096C                       lbsr    SerialPutChar
968
 00FFE31C 034016                          pshs    d,x
969
 00FFE31E 0C100D                          cmpb    #CR                                     ; carriage return ?
970
 00FFE320 026007                          bne             dccr
971
 00FFE322 00F111                          clr             CursorCol               ; just set cursor column to zero on a CR
972
 00FFE324 08DFA6                          bsr             UpdateCursorPos
973 4 robfinch
                              dcx14:
974 16 robfinch
 00FFE326 01600008C                       lbra            dcx4
975 4 robfinch
                              dccr:
976 16 robfinch
 00FFE329 0C1091                          cmpb    #$91                            ; cursor right ?
977
 00FFE32B 02600D                          bne             dcx6
978
 00FFE32D 096111                          lda             CursorCol
979
 00FFE32F 081040                          cmpa    #COLS
980
 00FFE331 024003                          bhs             dcx7
981
 00FFE333 04C                             inca
982
 00FFE334 097111                          sta             CursorCol
983 4 robfinch
                              dcx7:
984 16 robfinch
 00FFE336 08DF94                          bsr             UpdateCursorPos
985
 00FFE338 035096                          puls    d,x,pc
986 4 robfinch
                              dcx6:
987 16 robfinch
 00FFE33A 0C1090                          cmpb    #$90                            ; cursor up ?
988
 00FFE33C 026009                          bne             dcx8
989
 00FFE33E 096110                          lda             CursorRow
990
 00FFE340 027FF4                          beq             dcx7
991
 00FFE342 04A                             deca
992
 00FFE343 097110                          sta             CursorRow
993
 00FFE345 020FEF                          bra             dcx7
994 4 robfinch
                              dcx8:
995 16 robfinch
 00FFE347 0C1093                          cmpb    #$93                            ; cursor left ?
996
 00FFE349 026009                          bne             dcx9
997
 00FFE34B 096111                          lda             CursorCol
998
 00FFE34D 027FE7                          beq             dcx7
999
 00FFE34F 04A                             deca
1000
 00FFE350 097111                          sta             CursorCol
1001
 00FFE352 020FE2                          bra             dcx7
1002 4 robfinch
                              dcx9:
1003 16 robfinch
 00FFE354 0C1092                          cmpb    #$92                            ; cursor down ?
1004
 00FFE356 02600B                          bne             dcx10
1005
 00FFE358 096110                          lda             CursorRow
1006
 00FFE35A 081020                          cmpa    #ROWS
1007
 00FFE35C 027FD8                          beq             dcx7
1008
 00FFE35E 04C                             inca
1009
 00FFE35F 097110                          sta             CursorRow
1010
 00FFE361 020FD3                          bra             dcx7
1011 4 robfinch
                              dcx10:
1012 16 robfinch
 00FFE363 0C1094                          cmpb    #$94                            ; cursor home ?
1013
 00FFE365 02600C                          bne             dcx11
1014
 00FFE367 096111                          lda             CursorCol
1015
 00FFE369 027004                          beq             dcx12
1016
 00FFE36B 00F111                          clr             CursorCol
1017
 00FFE36D 020FC7                          bra             dcx7
1018 4 robfinch
                              dcx12:
1019 16 robfinch
 00FFE36F 00F110                          clr             CursorRow
1020
 00FFE371 020FC3                          bra             dcx7
1021 4 robfinch
                              dcx11:
1022 16 robfinch
 00FFE373 0C1099                          cmpb    #$99                            ; delete ?
1023
 00FFE375 026008                          bne             dcx13
1024
 00FFE377 08DF79                          bsr             CalcScreenLoc
1025
 00FFE379 01F001                          tfr             d,x
1026
 00FFE37B 096111                          lda             CursorCol               ; acc = cursor column
1027
 00FFE37D 020011                          bra             dcx5
1028 4 robfinch
                              dcx13
1029 16 robfinch
 00FFE37F 0C1008                          cmpb    #CTRLH                  ; backspace ?
1030
 00FFE381 02601E                          bne             dcx3
1031
 00FFE383 096111                          lda             CursorCol
1032
 00FFE385 02702E                          beq             dcx4
1033
 00FFE387 04A                             deca
1034
 00FFE388 097111                          sta             CursorCol
1035
 00FFE38A 08DF66                          bsr             CalcScreenLoc
1036
 00FFE38C 01F001                          tfr             d,x
1037
 00FFE38E 096111                          lda             CursorCol
1038 4 robfinch
                              dcx5:
1039 16 robfinch
 00FFE390 0E6001                          ldb             1,x
1040
 00FFE392 0E7801                          stb             ,x++
1041
 00FFE394 04C                             inca
1042
 00FFE395 081040                          cmpa    #COLS
1043
 00FFE397 025FF7                          blo             dcx5
1044
 00FFE399 0C6020                          ldb             #' '
1045
 00FFE39B 0301FF                          dex
1046
 00FFE39D 0E7804                          stb             ,x
1047
 00FFE39F 020014                          bra             dcx4
1048 4 robfinch
                              dcx3:
1049 16 robfinch
 00FFE3A1 0C100A                          cmpb    #LF                             ; linefeed ?
1050
 00FFE3A3 02700E                          beq             dclf
1051
 00FFE3A5 034004                          pshs    b
1052
 00FFE3A7 08DF49                          bsr     CalcScreenLoc
1053
 00FFE3A9 01F001                          tfr             d,x
1054
 00FFE3AB 035004                          puls    b
1055
 00FFE3AD 0E7804                          stb             ,x
1056 4 robfinch
                                      ; ToDo character color
1057
                              ;       lda             CharColor
1058
                              ;       sta             $2000,x
1059 16 robfinch
 00FFE3AF 08D006                          bsr             IncCursorPos
1060
 00FFE3B1 020002                          bra             dcx4
1061 4 robfinch
                              dclf:
1062 16 robfinch
 00FFE3B3 08D011                          bsr             IncCursorRow
1063 4 robfinch
                              dcx4:
1064 16 robfinch
 00FFE3B5 035096                          puls    d,x,pc
1065 4 robfinch
 
1066
                              ;------------------------------------------------------------------------------
1067
                              ; Increment the cursor position, scroll the screen if needed.
1068
                              ;
1069
                              ; Modifies:
1070
                              ;               none
1071
                              ;------------------------------------------------------------------------------
1072
 
1073
                              IncCursorPos:
1074 16 robfinch
 00FFE3B7 034016                          pshs    d,x
1075
 00FFE3B9 096111                          lda             CursorCol
1076
 00FFE3BB 04C                             inca
1077
 00FFE3BC 097111                          sta             CursorCol
1078
 00FFE3BE 081040                          cmpa    #COLS
1079
 00FFE3C0 025014                          blo             icc1
1080
 00FFE3C2 00F111                          clr             CursorCol               ; column = 0
1081
 00FFE3C4 020002                          bra             icr1
1082 4 robfinch
                              IncCursorRow:
1083 16 robfinch
 00FFE3C6 034016                          pshs    d,x
1084 4 robfinch
                              icr1:
1085 16 robfinch
 00FFE3C8 096110                          lda             CursorRow
1086
 00FFE3CA 04C                             inca
1087
 00FFE3CB 097110                          sta             CursorRow
1088
 00FFE3CD 081020                          cmpa    #ROWS
1089
 00FFE3CF 025005                          blo             icc1
1090
 00FFE3D1 04A                             deca                                                    ; backup the cursor row, we are scrolling up
1091
 00FFE3D2 097110                          sta             CursorRow
1092
 00FFE3D4 08DE8F                          bsr             ScrollUp
1093 4 robfinch
                              icc1:
1094 16 robfinch
 00FFE3D6 08DEF4                          bsr             UpdateCursorPos
1095 4 robfinch
                              icc2:
1096 16 robfinch
 00FFE3D8 035096                          puls    d,x,pc
1097 4 robfinch
 
1098
                              ;------------------------------------------------------------------------------
1099
                              ; Display a string on the screen.
1100
                              ;
1101
                              ; Modifies:
1102
                              ;               none
1103
                              ; Parameters:
1104
                              ;               d = pointer to string
1105
                              ;------------------------------------------------------------------------------
1106
                              ;
1107
                              DisplayString:
1108 16 robfinch
 00FFE3DA 034016                          pshs    d,x
1109
 00FFE3DC 01F001                          tfr             d,x
1110
 00FFE3DE 0150B6FFFFFFFE0                 lda             COREID
1111
 00FFE3E3 081020                          cmpa    #$20
1112
 00FFE3E5 027005                          beq             dspj1B
1113 13 robfinch
                              dspj2:                                          ; lock semaphore for access
1114 16 robfinch
 00FFE3E7 0B6EF0001                       lda             OUTSEMA+1
1115
 00FFE3EA 027FFB                          beq             dspj2
1116 4 robfinch
                              dspj1B:
1117 16 robfinch
 00FFE3EC 0E6800                          ldb             ,x+                             ; move string char into acc
1118
 00FFE3EE 027005                          beq             dsretB          ; is it end of string ?
1119
 00FFE3F0 017000AEE                       lbsr    OUTCH                   ; display character
1120
 00FFE3F3 020FF7                          bra             dspj1B
1121 4 robfinch
                              dsretB:
1122 16 robfinch
 00FFE3F5 07FEF0001                       clr             OUTSEMA+1       ; unlock semaphore
1123
 00FFE3F8 035096                          puls    d,x,pc
1124 4 robfinch
 
1125
                              DisplayStringCRLF:
1126 16 robfinch
 00FFE3FA 034006                          pshs    d
1127
 00FFE3FC 08DFDC                          bsr             DisplayString
1128
 00FFE3FE 0C600D                          ldb             #CR
1129
 00FFE400 017000ADE                       lbsr    OUTCH
1130
 00FFE403 0C600A                          ldb             #LF
1131
 00FFE405 017000AD9                       lbsr    OUTCH
1132
 00FFE408 035086                          puls    d,pc
1133 4 robfinch
 
1134
                              ;
1135
                              ; PRINT CR, LF, STRING
1136
                              ;
1137
                              PSTRNG
1138 16 robfinch
 00FFE40A 08D002                          BSR             PCRLF
1139
 00FFE40C 02000D                          BRA             PDATA
1140 4 robfinch
                              PCRLF
1141 16 robfinch
 00FFE40E 034010                          PSHS    X
1142
 00FFE410 08EFFE422                       LDX             #CRLFST
1143
 00FFE413 08D006                          BSR             PDATA
1144
 00FFE415 035010                          PULS    X
1145
 00FFE417 039                             RTS
1146 4 robfinch
 
1147
                              PRINT
1148 16 robfinch
 00FFE418 0BDFFEEE1                       JSR             OUTCH
1149 4 robfinch
                              PDATA
1150 16 robfinch
 00FFE41B 0E6800                          LDB             ,X+
1151
 00FFE41D 0C1004                          CMPB    #$04
1152
 00FFE41F 026FF7                          BNE             PRINT
1153
 00FFE421 039                             RTS
1154 4 robfinch
 
1155
                              CRLFST
1156 16 robfinch
 00FFE422 00D00A004                       fcb     CR,LF,4
1157 4 robfinch
 
1158
                              DispDWordAsHex:
1159 16 robfinch
 00FFE425 08D007                          bsr             DispWordAsHex
1160
 00FFE427 01E001                          exg             d,x
1161
 00FFE429 08D003                          bsr             DispWordAsHex
1162
 00FFE42B 01E001                          exg             d,x
1163
 00FFE42D 039                             rts
1164 4 robfinch
 
1165
                              DispWordAsHex:
1166 16 robfinch
 00FFE42E 01E089                          exg             a,b
1167
 00FFE430 08D005                          bsr             DispByteAsHex
1168
 00FFE432 01E089                          exg             a,b
1169
 00FFE434 08D001                          bsr             DispByteAsHex
1170
 00FFE436 039                             rts
1171 4 robfinch
 
1172
                              DispByteAsHex:
1173 16 robfinch
 00FFE437 034004                    pshs  b
1174
 00FFE439 054                             lsrb
1175
 00FFE43A 054                             lsrb
1176
 00FFE43B 054                             lsrb
1177
 00FFE43C 054                             lsrb
1178
 00FFE43D 054                             lsrb
1179
 00FFE43E 054                             lsrb
1180
 00FFE43F 054                             lsrb
1181
 00FFE440 054                             lsrb
1182
 00FFE441 08D00C                          bsr             DispNyb
1183
 00FFE443 035004                          puls    b
1184
 00FFE445 034004                          pshs    b
1185
 00FFE447 054                             lsrb
1186
 00FFE448 054                             lsrb
1187
 00FFE449 054                             lsrb
1188
 00FFE44A 054                             lsrb
1189
 00FFE44B 08D002                          bsr             DispNyb
1190
 00FFE44D 035004                          puls    b
1191 4 robfinch
 
1192
                              DispNyb
1193 16 robfinch
 00FFE44F 034004                          pshs    b
1194
 00FFE451 0C400F                          andb    #$0F
1195
 00FFE453 0C100A                          cmpb    #10
1196
 00FFE455 025007                          blo             DispNyb1
1197
 00FFE457 0CB037                          addb    #'A'-10
1198
 00FFE459 017000A85                       lbsr    OUTCH
1199
 00FFE45C 035084                          puls    b,pc
1200 4 robfinch
                              DispNyb1
1201 16 robfinch
 00FFE45E 0CB030                          addb    #'0'
1202
 00FFE460 017000A7E                       lbsr    OUTCH
1203
 00FFE463 035084                          puls    b,pc
1204 4 robfinch
 
1205
                              ;==============================================================================
1206 13 robfinch
                              ; Timer
1207
                              ;==============================================================================
1208
 
1209
                              ; ============================================================================
1210
                              ;        __
1211
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
1212
                              ;    \  __ /    All rights reserved.
1213
                              ;     \/_//     robfinch@opencores.org
1214
                              ;       ||
1215
                              ;
1216
                              ;
1217
                              ; Timer routines for a WDC6522 compatible circuit.
1218
                              ;
1219
                              ; This source file is free software: you can redistribute it and/or modify
1220
                              ; it under the terms of the GNU Lesser General Public License as published
1221
                              ; by the Free Software Foundation, either version 3 of the License, or
1222
                              ; (at your option) any later version.
1223
                              ;
1224
                              ; This source file is distributed in the hope that it will be useful,
1225
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
1226
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1227
                              ; GNU General Public License for more details.
1228
                              ;
1229
                              ; You should have received a copy of the GNU General Public License
1230
                              ; along with this program.  If not, see .
1231
                              ;
1232
                              ; ============================================================================
1233
                              ;
1234
                              TimerInit:
1235 16 robfinch
 00FFE465 0CC061A80                       ldd             #$61A80                                 ; compare to 400000 (100 Hz assuming 40MHz clock)
1236
 00FFE468 0150F7FFFE60014                 stb             VIA+VIA_T3CMPL
1237
 00FFE46D 0150B7FFFE60015                 sta             VIA+VIA_T3CMPH
1238
 00FFE472 01507FFFFE60012                 clr             VIA+VIA_T3LL
1239
 00FFE477 01507FFFFE60013                 clr             VIA+VIA_T3LH
1240
 00FFE47C 0150B6FFFE6000B                 lda             VIA+VIA_ACR                     ; set continuous mode for timer
1241
 00FFE481 08A100                          ora             #$100
1242
 00FFE483 0150B7FFFE6000B                 sta             VIA+VIA_ACR                     ; enable timer #3 interrupts
1243
 00FFE488 086810                          lda             #$810
1244
 00FFE48A 0150B7FFFE6000E                 sta             VIA+VIA_IER
1245
 00FFE48F 039                             rts
1246 13 robfinch
 
1247
                              TimerIRQ:
1248
                                      ; Reset the edge sense circuit in the PIC
1249 16 robfinch
 00FFE490 08601F                          lda             #31                                                     ; Timer is IRQ #31
1250
 00FFE492 0B7FFC011                       sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
1251
 00FFE495 0150B7FFFE3F010                 sta             PIC+16                                  ; register 16 is edge sense reset reg
1252
 00FFE49A 0150B6FFFE6000D                 lda             VIA+VIA_IFR
1253
 00FFE49F 02A011                          bpl             notTimerIRQ
1254
 00FFE4A1 085080                          bita    #$80                                            ; timer3 irq is bit 7
1255
 00FFE4A3 02700D                          beq             notTimerIRQ
1256
 00FFE4A5 01507FFFFE60012                 clr             VIA+VIA_T3LL
1257
 00FFE4AA 01507FFFFE60013                 clr             VIA+VIA_T3LH
1258
 00FFE4AF 07CE00037                       inc             $E00037                                 ; update timer IRQ screen flag
1259 13 robfinch
                              notTimerIRQ:
1260 16 robfinch
 00FFE4B2 039                             rts
1261 13 robfinch
 
1262
 
1263
 
1264
                              ; ============================================================================
1265
                              ;        __
1266
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
1267
                              ;    \  __ /    All rights reserved.
1268
                              ;     \/_//     robfinch@opencores.org
1269
                              ;       ||
1270
                              ;
1271
                              ;
1272
                              ; BSD 3-Clause License
1273
                              ; Redistribution and use in source and binary forms, with or without
1274
                              ; modification, are permitted provided that the following conditions are met:
1275
                              ;
1276
                              ; 1. Redistributions of source code must retain the above copyright notice, this
1277
                              ;    list of conditions and the following disclaimer.
1278
                              ;
1279
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
1280
                              ;    this list of conditions and the following disclaimer in the documentation
1281
                              ;    and/or other materials provided with the distribution.
1282
                              ;
1283
                              ; 3. Neither the name of the copyright holder nor the names of its
1284
                              ;    contributors may be used to endorse or promote products derived from
1285
                              ;    this software without specific prior written permission.
1286
                              ;
1287
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1288
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1289
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1290
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1291
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1292
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1293
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1294
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1295
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1296
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1297
                              ;
1298
                              ; ============================================================================
1299
                              ;
1300
                              ;===============================================================================
1301
                              ; Generic I2C routines
1302
                              ;
1303
                              ; It is assumed there may be more than one I2C controller in the system, so
1304
                              ; the address of the controller is passed in the X register.
1305
                              ;===============================================================================
1306
 
1307
                              I2C_PREL        EQU             $0
1308
                              I2C_PREH        EQU             $1
1309
                              I2C_CTRL        EQU             $2
1310
                              I2C_RXR         EQU             $3
1311
                              I2C_TXR         EQU             $3
1312
                              I2C_CMD         EQU             $4
1313
                              I2C_STAT        EQU             $4
1314
 
1315
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1316
                              ; i2c initialization, sets the clock prescaler
1317
                              ;
1318
                              ; Parameters:
1319
                              ;               x = I2C controller address
1320
                              ; Returns: none
1321
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1322
 
1323 15 robfinch
                              i2c_init:
1324 16 robfinch
 00FFE4B3 034004                          pshs    b
1325
 00FFE4B5 0C6004                          ldb             #4                                                                      ; setup prescale for 400kHz clock
1326
 00FFE4B7 0E7804                          stb             I2C_PREL,x
1327
 00FFE4B9 06F001                          clr             I2C_PREH,x
1328
 00FFE4BB 035084                          puls    b,pc
1329 13 robfinch
 
1330
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1331
                              ; Wait for I2C transfer to complete
1332
                              ;
1333
                              ; Parameters
1334
                              ;       x - I2C controller base address
1335
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1336
 
1337
                              i2c_wait_tip:
1338 16 robfinch
 00FFE4BD 034004                          pshs            b
1339 13 robfinch
                              i2cw1:
1340 16 robfinch
 00FFE4BF 0E6004                          ldb                     I2C_STAT,x              ; would use lvb, but lb is okay since its the I/O area
1341
 00FFE4C1 0C5001                          bitb            #1                                              ; wait for tip to clear
1342
 00FFE4C3 026FFA                          bne                     i2cw1
1343
 00FFE4C5 035084                          puls            b,pc
1344 13 robfinch
 
1345
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1346
                              ; Write command to i2c
1347
                              ;
1348
                              ; Parameters
1349
                              ;               accb - data to transmit
1350
                              ;               acca - command value
1351
                              ;               x       - I2C controller base address
1352
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1353
 
1354
                              i2c_wr_cmd:
1355 16 robfinch
 00FFE4C7 0E7003                          stb             I2C_TXR,x
1356
 00FFE4C9 0A7004                          sta             I2C_CMD,x
1357
 00FFE4CB 08DFF0                          bsr             i2c_wait_tip
1358
 00FFE4CD 0E6004                          ldb             I2C_STAT,x
1359
 00FFE4CF 039                             rts
1360 13 robfinch
 
1361
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1362
                              ; Parameters
1363
                              ;               x - I2C controller base address
1364
                              ;               accb - data to send
1365
                              ; Returns: none
1366
                              ; Stack space: 2 words
1367
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1368
 
1369 15 robfinch
                              i2c_xmit1:
1370 16 robfinch
 00FFE4D0 034006                          pshs    d                                                               ; save data value
1371
 00FFE4D2 034006                          pshs    d                                                               ; and save it again
1372
 00FFE4D4 0C6001                          ldb             #1
1373
 00FFE4D6 0E7002                          stb             I2C_CTRL,x                      ; enable the core
1374
 00FFE4D8 0C6076                          ldb             #$76                                            ; set slave address = %0111011
1375
 00FFE4DA 086090                          lda             #$90                                            ; set STA, WR
1376
 00FFE4DC 08DFE9                          bsr             i2c_wr_cmd
1377
 00FFE4DE 08D00A                          bsr             i2c_wait_rx_nack
1378
 00FFE4E0 035006                          puls    d                                                               ; get back data value
1379
 00FFE4E2 086050                          lda             #$50                                            ; set STO, WR
1380
 00FFE4E4 08DFE1                          bsr             i2c_wr_cmd
1381
 00FFE4E6 08D002                          bsr             i2c_wait_rx_nack
1382
 00FFE4E8 035086                          puls    d,pc
1383 13 robfinch
 
1384
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1385
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1386
 
1387
                              i2c_wait_rx_nack:
1388 16 robfinch
 00FFE4EA 034004                          pshs    b                                                               ; save off accb
1389 13 robfinch
                              i2cwr1:
1390 16 robfinch
 00FFE4EC 0E6004                          ldb             I2C_STAT,x                      ; wait for RXack = 0
1391
 00FFE4EE 0C5080                          bitb    #$80                                            ; test for nack
1392
 00FFE4F0 026FFA                          bne             i2cwr1
1393
 00FFE4F2 035084                          puls    b,pc
1394 13 robfinch
 
1395
                              ; ============================================================================
1396
                              ;        __
1397
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
1398
                              ;    \  __ /    All rights reserved.
1399
                              ;     \/_//     robfinch@opencores.org
1400
                              ;       ||
1401
                              ;
1402
                              ;
1403
                              ; BSD 3-Clause License
1404
                              ; Redistribution and use in source and binary forms, with or without
1405
                              ; modification, are permitted provided that the following conditions are met:
1406
                              ;
1407
                              ; 1. Redistributions of source code must retain the above copyright notice, this
1408
                              ;    list of conditions and the following disclaimer.
1409
                              ;
1410
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
1411
                              ;    this list of conditions and the following disclaimer in the documentation
1412
                              ;    and/or other materials provided with the distribution.
1413
                              ;
1414
                              ; 3. Neither the name of the copyright holder nor the names of its
1415
                              ;    contributors may be used to endorse or promote products derived from
1416
                              ;    this software without specific prior written permission.
1417
                              ;
1418
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1419
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1420
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1421
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1422
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1423
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1424
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1425
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1426
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1427
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1428
                              ;
1429
                              ; ============================================================================
1430
 
1431
                              ;===============================================================================
1432
                              ; Realtime clock routines
1433
                              ;===============================================================================
1434
 
1435
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1436
                              ; Read the real-time-clock chip.
1437
                              ;
1438
                              ; The entire contents of the clock registers and sram are read into a buffer
1439
                              ; in one-shot rather than reading the registers individually.
1440
                              ;
1441
                              ; Parameters: none
1442
                              ; Returns: d = 0 on success, otherwise non-zero
1443
                              ; Modifies: d and RTCBuf
1444
                              ; Stack space: 6 words
1445
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1446
 
1447
                              rtc_read:
1448 16 robfinch
 00FFE4F4 08EE30500                       ldx                     #RTC
1449
 00FFE4F7 18E007FC0                       ldy                     #RTCBuf
1450
 00FFE4FA 0C6080                          ldb                     #$80
1451
 00FFE4FC 0E7002                          stb                     I2C_CTRL,x              ; enable I2C
1452
 00FFE4FE 0CC0900DE                       ldd                     #$900DE                         ; read address, write op, STA + wr bit
1453
 00FFE501 08DFC4                          bsr                     i2c_wr_cmd
1454
 00FFE503 0C5080                          bitb            #$80
1455
 00FFE505 02603C                          bne                     rtc_rxerr
1456
 00FFE507 0CC010000                       ldd                     #$10000                         ; address zero, wr bit
1457
 00FFE50A 08DFBB                          bsr                     i2c_wr_cmd
1458
 00FFE50C 0C5080                          bitb            #$80
1459
 00FFE50E 026033                          bne                     rtc_rxerr
1460
 00FFE510 0CC0900DF                       ldd                     #$900DF                         ; read address, read op, STA + wr bit
1461
 00FFE513 08DFB2                          bsr                     i2c_wr_cmd
1462
 00FFE515 0C5080                          bitb            #$80
1463
 00FFE517 02602A                          bne                     rtc_rxerr
1464 13 robfinch
 
1465 16 robfinch
 00FFE519 05F                             clrb
1466 13 robfinch
                              rtcr0001:
1467 16 robfinch
 00FFE51A 086020                          lda                     #$20
1468
 00FFE51C 0A7004                          sta                     I2C_CMD,x                       ; rd bit
1469
 00FFE51E 08DF9D                          bsr                     i2c_wait_tip
1470
 00FFE520 08DFC8                          bsr                     i2c_wait_rx_nack
1471
 00FFE522 0A6004                          lda                     I2C_STAT,x
1472
 00FFE524 085080                          bita            #$80
1473
 00FFE526 02601B                          bne                     rtc_rxerr
1474
 00FFE528 0A6003                          lda                     I2C_RXR,x
1475
 00FFE52A 0A7A07                          sta                     b,y
1476
 00FFE52C 05C                             incb
1477
 00FFE52D 0C105F                          cmpb            #$5F
1478
 00FFE52F 025FE9                          blo                     rtcr0001
1479
 00FFE531 086068                          lda                     #$68
1480
 00FFE533 0A7004                          sta                     I2C_CMD,x                       ; STO, rd bit + nack
1481
 00FFE535 08DF86                          bsr                     i2c_wait_tip
1482
 00FFE537 0A6004                          lda                     I2C_STAT,x
1483
 00FFE539 085080                          bita            #$80
1484
 00FFE53B 026006                          bne                     rtc_rxerr
1485
 00FFE53D 0A6003                          lda                     I2C_RXR,x
1486
 00FFE53F 0A7A07                          sta                     b,y
1487
 00FFE541 04F05F                          clrd                                                                    ; return 0
1488 13 robfinch
                              rtc_rxerr:
1489 16 robfinch
 00FFE543 06F002                          clr                     I2C_CTRL,x      ; disable I2C and return status
1490
 00FFE545 04F                             clra
1491
 00FFE546 039                             rts
1492 13 robfinch
 
1493
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1494
                              ; Write the real-time-clock chip.
1495
                              ;
1496
                              ; The entire contents of the clock registers and sram are written from a
1497
                              ; buffer (RTCBuf) in one-shot rather than writing the registers individually.
1498
                              ;
1499
                              ; Parameters: none
1500
                              ; Returns: r1 = 0 on success, otherwise non-zero
1501
                              ; Modifies: r1 and RTCBuf
1502
                              ; Stack space: 6 words
1503
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1504
 
1505
                              rtc_write:
1506 16 robfinch
 00FFE547 08EE30500                       ldx             #RTC
1507
 00FFE54A 18E007FC0                       ldy             #RTCBuf
1508 13 robfinch
 
1509 16 robfinch
 00FFE54D 0C6080                          ldb             #$80
1510
 00FFE54F 0E7002                          stb             I2C_CTRL,x              ; enable I2C
1511
 00FFE551 0CC0900DE                       ldd             #$900DE                         ; read address, write op, STA + wr bit
1512
 00FFE554 08DF71                          bsr             i2c_wr_cmd
1513
 00FFE556 0C5080                          bitb    #$80
1514
 00FFE558 026FE9                          bne             rtc_rxerr
1515
 00FFE55A 0CC010000                       ldd             #$10000                         ; address zero, wr bit
1516
 00FFE55D 08DF68                          bsr             i2c_wr_cmd
1517
 00FFE55F 0C5080                          bitb    #$80
1518
 00FFE561 026FE0                          bne             rtc_rxerr
1519 13 robfinch
 
1520 16 robfinch
 00FFE563 0C6000                          ldb             #0
1521 13 robfinch
                              rtcw0001:
1522 16 robfinch
 00FFE565 034004                          pshs    b
1523
 00FFE567 0E6A05                          ldb             b,y
1524
 00FFE569 086010                          lda             #$10
1525
 00FFE56B 08DF5A                          bsr             i2c_wr_cmd
1526
 00FFE56D 0C5080                          bitb    #$80
1527
 00FFE56F 035004                          puls    b
1528
 00FFE571 026FD0                          bne             rtc_rxerr
1529
 00FFE573 05C                             incb
1530
 00FFE574 0C105F                          cmpb    #$5F
1531
 00FFE576 025FED                          blo             rtcw0001
1532
 00FFE578 0E6A05                          ldb             b,y
1533
 00FFE57A 086050                          lda             #$50                                    ; STO, wr bit
1534
 00FFE57C 08DF49                          bsr             i2c_wr_cmd
1535
 00FFE57E 0C5080                          bitb    #$80
1536
 00FFE580 026FC1                          bne             rtc_rxerr
1537
 00FFE582 04F05F                          clrd                                                            ; return 0
1538
 00FFE584 06F002                          clr             I2C_CTRL,x              ; disable I2C and return status
1539
 00FFE586 039                             rts
1540 13 robfinch
 
1541
                              ;==============================================================================
1542 4 robfinch
                              ; Keyboard I/O
1543
                              ;==============================================================================
1544
 
1545
                                      ;--------------------------------------------------------------------------
1546
                                      ; PS2 scan codes to ascii conversion tables.
1547
                                      ;--------------------------------------------------------------------------
1548
                                      ;
1549
                                      org     (* + 127) & $FFFFFF80
1550
 
1551
                              unshiftedScanCodes:
1552 16 robfinch
 00FFE600 02E0A902E0A50A30A10A2           fcb     $2e,$a9,$2e,$a5,$a3,$a1,$a2,$ac
1553
 00FFE607 0AC
1554
 00FFE608 02E0AA0A80A60A4009060           fcb     $2e,$aa,$a8,$a6,$a4,$09,$60,$2e
1555 13 robfinch
 00FFE60F 02E
1556 16 robfinch
 00FFE610 02E02E02E02E02E071031           fcb     $2e,$2e,$2e,$2e,$2e,$71,$31,$2e
1557 13 robfinch
 00FFE617 02E
1558 16 robfinch
 00FFE618 02E02E07A073061077032           fcb     $2e,$2e,$7a,$73,$61,$77,$32,$2e
1559 13 robfinch
 00FFE61F 02E
1560 16 robfinch
 00FFE620 02E063078064065034033           fcb     $2e,$63,$78,$64,$65,$34,$33,$2e
1561 13 robfinch
 00FFE627 02E
1562 16 robfinch
 00FFE628 02E020076066074072035           fcb     $2e,$20,$76,$66,$74,$72,$35,$2e
1563 13 robfinch
 00FFE62F 02E
1564 16 robfinch
 00FFE630 02E06E062068067079036           fcb     $2e,$6e,$62,$68,$67,$79,$36,$2e
1565 13 robfinch
 00FFE637 02E
1566 16 robfinch
 00FFE638 02E02E06D06A075037038           fcb     $2e,$2e,$6d,$6a,$75,$37,$38,$2e
1567 13 robfinch
 00FFE63F 02E
1568 16 robfinch
 00FFE640 02E02C06B06906F030039           fcb     $2e,$2c,$6b,$69,$6f,$30,$39,$2e
1569 13 robfinch
 00FFE647 02E
1570 16 robfinch
 00FFE648 02E02E02F06C03B07002D           fcb     $2e,$2e,$2f,$6c,$3b,$70,$2d,$2e
1571 13 robfinch
 00FFE64F 02E
1572 16 robfinch
 00FFE650 02E02E02702E05B03D02E           fcb     $2e,$2e,$27,$2e,$5b,$3d,$2e,$2e
1573 13 robfinch
 00FFE657 02E
1574 16 robfinch
 00FFE658 0AD02E00D05D02E05C02E           fcb     $ad,$2e,$0d,$5d,$2e,$5c,$2e,$2e
1575 13 robfinch
 00FFE65F 02E
1576 16 robfinch
 00FFE660 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1577 13 robfinch
 00FFE667 02E
1578 16 robfinch
 00FFE668 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1579 13 robfinch
 00FFE66F 02E
1580 16 robfinch
 00FFE670 09807F09202E09109001B           fcb     $98,$7f,$92,$2e,$91,$90,$1b,$af
1581
 00FFE677 0AF
1582
 00FFE678 0AB02E09702E02E0960AE           fcb     $ab,$2e,$97,$2e,$2e,$96,$ae,$2e
1583 13 robfinch
 00FFE67F 02E
1584 4 robfinch
 
1585 16 robfinch
 00FFE680 02E02E02E0A702E02E02E           fcb     $2e,$2e,$2e,$a7,$2e,$2e,$2e,$2e
1586 13 robfinch
 00FFE687 02E
1587 16 robfinch
 00FFE688 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1588 13 robfinch
 00FFE68F 02E
1589 16 robfinch
 00FFE690 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1590 13 robfinch
 00FFE697 02E
1591 16 robfinch
 00FFE698 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1592 13 robfinch
 00FFE69F 02E
1593 16 robfinch
 00FFE6A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1594 13 robfinch
 00FFE6A7 02E
1595 16 robfinch
 00FFE6A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1596 13 robfinch
 00FFE6AF 02E
1597 16 robfinch
 00FFE6B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1598 13 robfinch
 00FFE6B7 02E
1599 16 robfinch
 00FFE6B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1600 13 robfinch
 00FFE6BF 02E
1601 16 robfinch
 00FFE6C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1602 13 robfinch
 00FFE6C7 02E
1603 16 robfinch
 00FFE6C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1604 13 robfinch
 00FFE6CF 02E
1605 16 robfinch
 00FFE6D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1606 13 robfinch
 00FFE6D7 02E
1607 16 robfinch
 00FFE6D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1608 13 robfinch
 00FFE6DF 02E
1609 16 robfinch
 00FFE6E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1610 13 robfinch
 00FFE6E7 02E
1611
 00FFE6E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1612
 00FFE6EF 02E
1613 16 robfinch
 00FFE6F0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1614 13 robfinch
 00FFE6F7 02E
1615 16 robfinch
 00FFE6F8 02E02E0FA02E02E02E02E           fcb     $2e,$2e,$fa,$2e,$2e,$2e,$2e,$2e
1616 13 robfinch
 00FFE6FF 02E
1617 4 robfinch
 
1618 16 robfinch
                              shiftedScanCodes:
1619 13 robfinch
 00FFE700 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1620
 00FFE707 02E
1621 16 robfinch
 00FFE708 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1622 13 robfinch
 00FFE70F 02E
1623 16 robfinch
 00FFE710 02E02E02E02E02E051021           fcb     $2e,$2e,$2e,$2e,$2e,$51,$21,$2e
1624 13 robfinch
 00FFE717 02E
1625 16 robfinch
 00FFE718 02E02E05A053041057040           fcb     $2e,$2e,$5a,$53,$41,$57,$40,$2e
1626 13 robfinch
 00FFE71F 02E
1627 16 robfinch
 00FFE720 02E043058044045024023           fcb     $2e,$43,$58,$44,$45,$24,$23,$2e
1628 13 robfinch
 00FFE727 02E
1629 16 robfinch
 00FFE728 02E020056046054052025           fcb     $2e,$20,$56,$46,$54,$52,$25,$2e
1630 13 robfinch
 00FFE72F 02E
1631 16 robfinch
 00FFE730 02E04E04204804705905E           fcb     $2e,$4e,$42,$48,$47,$59,$5e,$2e
1632 13 robfinch
 00FFE737 02E
1633 16 robfinch
 00FFE738 02E02E04D04A05502602A           fcb     $2e,$2e,$4d,$4a,$55,$26,$2a,$2e
1634 13 robfinch
 00FFE73F 02E
1635 16 robfinch
 00FFE740 02E03C04B04904F029028           fcb     $2e,$3c,$4b,$49,$4f,$29,$28,$2e
1636 13 robfinch
 00FFE747 02E
1637 16 robfinch
 00FFE748 02E03E03F04C03A05005F           fcb     $2e,$3e,$3f,$4c,$3a,$50,$5f,$2e
1638 13 robfinch
 00FFE74F 02E
1639 16 robfinch
 00FFE750 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1640 13 robfinch
 00FFE757 02E
1641 16 robfinch
 00FFE758 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1642 13 robfinch
 00FFE75F 02E
1643 16 robfinch
 00FFE760 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1644 13 robfinch
 00FFE767 02E
1645
 00FFE768 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1646
 00FFE76F 02E
1647 16 robfinch
 00FFE770 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1648 13 robfinch
 00FFE777 02E
1649
 00FFE778 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1650
 00FFE77F 02E
1651 4 robfinch
 
1652 13 robfinch
 00FFE780 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1653
 00FFE787 02E
1654 16 robfinch
 00FFE788 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1655 13 robfinch
 00FFE78F 02E
1656 16 robfinch
 00FFE790 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1657 13 robfinch
 00FFE797 02E
1658 16 robfinch
 00FFE798 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1659 13 robfinch
 00FFE79F 02E
1660 16 robfinch
 00FFE7A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1661 13 robfinch
 00FFE7A7 02E
1662 16 robfinch
 00FFE7A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1663 13 robfinch
 00FFE7AF 02E
1664 16 robfinch
 00FFE7B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1665 13 robfinch
 00FFE7B7 02E
1666 16 robfinch
 00FFE7B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1667 13 robfinch
 00FFE7BF 02E
1668 16 robfinch
 00FFE7C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1669 13 robfinch
 00FFE7C7 02E
1670 16 robfinch
 00FFE7C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1671 13 robfinch
 00FFE7CF 02E
1672 16 robfinch
 00FFE7D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1673 13 robfinch
 00FFE7D7 02E
1674 16 robfinch
 00FFE7D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1675 13 robfinch
 00FFE7DF 02E
1676 16 robfinch
 00FFE7E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1677 13 robfinch
 00FFE7E7 02E
1678
 00FFE7E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1679
 00FFE7EF 02E
1680 16 robfinch
 00FFE7F0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1681 13 robfinch
 00FFE7F7 02E
1682
 00FFE7F8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1683
 00FFE7FF 02E
1684 4 robfinch
 
1685 16 robfinch
                              ; control
1686
                              keybdControlCodes:
1687
 00FFE800 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1688 13 robfinch
 00FFE807 02E
1689 16 robfinch
 00FFE808 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1690 13 robfinch
 00FFE80F 02E
1691 16 robfinch
 00FFE810 02E02E02E02E02E011021           fcb     $2e,$2e,$2e,$2e,$2e,$11,$21,$2e
1692 13 robfinch
 00FFE817 02E
1693 16 robfinch
 00FFE818 02E02E01A013001017040           fcb     $2e,$2e,$1a,$13,$01,$17,$40,$2e
1694 13 robfinch
 00FFE81F 02E
1695 16 robfinch
 00FFE820 02E003018004005024023           fcb     $2e,$03,$18,$04,$05,$24,$23,$2e
1696 13 robfinch
 00FFE827 02E
1697 16 robfinch
 00FFE828 02E020016006014012025           fcb     $2e,$20,$16,$06,$14,$12,$25,$2e
1698 13 robfinch
 00FFE82F 02E
1699 16 robfinch
 00FFE830 02E00E00200800701905E           fcb     $2e,$0e,$02,$08,$07,$19,$5e,$2e
1700 13 robfinch
 00FFE837 02E
1701 16 robfinch
 00FFE838 02E02E00D00A01502602A           fcb     $2e,$2e,$0d,$0a,$15,$26,$2a,$2e
1702 13 robfinch
 00FFE83F 02E
1703 16 robfinch
 00FFE840 02E03C00B00900F029028           fcb     $2e,$3c,$0b,$09,$0f,$29,$28,$2e
1704 13 robfinch
 00FFE847 02E
1705 16 robfinch
 00FFE848 02E03E03F00C03A01005F           fcb     $2e,$3e,$3f,$0c,$3a,$10,$5f,$2e
1706 13 robfinch
 00FFE84F 02E
1707 16 robfinch
 00FFE850 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1708 13 robfinch
 00FFE857 02E
1709 16 robfinch
 00FFE858 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1710 13 robfinch
 00FFE85F 02E
1711 16 robfinch
 00FFE860 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1712 13 robfinch
 00FFE867 02E
1713 16 robfinch
 00FFE868 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1714 13 robfinch
 00FFE86F 02E
1715 16 robfinch
 00FFE870 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1716 13 robfinch
 00FFE877 02E
1717 16 robfinch
 00FFE878 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1718 13 robfinch
 00FFE87F 02E
1719 4 robfinch
 
1720 16 robfinch
                              keybdExtendedCodes:
1721
 00FFE880 02E02E02E02E0A30A10A2           fcb     $2e,$2e,$2e,$2e,$a3,$a1,$a2,$2e
1722
 00FFE887 02E
1723
 00FFE888 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1724
 00FFE88F 02E
1725
 00FFE890 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1726
 00FFE897 02E
1727
 00FFE898 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1728
 00FFE89F 02E
1729
 00FFE8A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1730
 00FFE8A7 02E
1731
 00FFE8A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1732
 00FFE8AF 02E
1733
 00FFE8B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1734
 00FFE8B7 02E
1735
 00FFE8B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1736
 00FFE8BF 02E
1737
 00FFE8C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1738
 00FFE8C7 02E
1739
 00FFE8C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1740
 00FFE8CF 02E
1741
 00FFE8D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1742
 00FFE8D7 02E
1743
 00FFE8D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1744
 00FFE8DF 02E
1745
 00FFE8E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1746
 00FFE8E7 02E
1747
 00FFE8E8 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1748
 00FFE8EF 02E
1749
 00FFE8F0 09809909202E09109002E           fcb     $98,$99,$92,$2e,$91,$90,$2e,$2e
1750
 00FFE8F7 02E
1751
 00FFE8F8 02E02E09702E02E09602E           fcb     $2e,$2e,$97,$2e,$2e,$96,$2e,$2e
1752
 00FFE8FF 02E
1753
 
1754 4 robfinch
                              ; ============================================================================
1755
                              ;        __
1756
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
1757
                              ;    \  __ /    All rights reserved.
1758
                              ;     \/_//     robfinch@opencores.org
1759
                              ;       ||
1760
                              ;
1761
                              ;
1762
                              ;       Keyboard driver routines to interface to a PS2 style keyboard
1763
                              ; Converts the scancode to ascii
1764
                              ;
1765
                              ; This source file is free software: you can redistribute it and/or modify
1766
                              ; it under the terms of the GNU Lesser General Public License as published
1767
                              ; by the Free Software Foundation, either version 3 of the License, or
1768
                              ; (at your option) any later version.
1769
                              ;
1770
                              ; This source file is distributed in the hope that it will be useful,
1771
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
1772
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1773
                              ; GNU General Public License for more details.
1774
                              ;
1775
                              ; You should have received a copy of the GNU General Public License
1776
                              ; along with this program.  If not, see .
1777
                              ;
1778
                              ; ============================================================================
1779
                              ;
1780
                              SC_F12  EQU     $07
1781
                              SC_C    EQU             $21
1782
                              SC_T    EQU         $2C
1783
                              SC_Z            EQU     $1A
1784
                              SC_DEL  EQU                     $71     ; extend
1785
                              SC_KEYUP        EQU             $F0     ; should be $f0
1786
                              SC_EXTEND EQU     $E0
1787
                              SC_CTRL EQU                     $14
1788
                              SC_RSHIFT               EQU     $59
1789
                              SC_NUMLOCK      EQU     $77
1790
                              SC_SCROLLLOCK           EQU     $7E
1791
                              SC_CAPSLOCK             EQU             $58
1792
                              SC_ALT  EQU                     $11
1793
 
1794
                              ;#define SC_LSHIFT      EQU             $12
1795
                              ;SC_DEL         EQU             $71             ; extend
1796
                              ;SC_LCTRL       EQU             $58
1797
 
1798
                              SC_TAB  EQU     $0D
1799
 
1800
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1801
                              ; Recieve a byte from the keyboard, used after a command is sent to the
1802
                              ; keyboard in order to wait for a response.
1803
                              ;
1804
                              ; Parameters: none
1805
                              ; Returns: accd = recieved byte ($00 to $FF), -1 on timeout
1806
                              ; Modifies: acc
1807
                              ; Stack Space: 2 words
1808
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1809
 
1810
                              KeybdRecvByte:
1811 16 robfinch
 00FFE900 034010                          pshs    x
1812
 00FFE902 08E000064                       ldx             #100                                            ; wait up to 1s
1813 4 robfinch
                              krb3:
1814 16 robfinch
 00FFE905 08D05A                          bsr             KeybdGetStatus  ; wait for response from keyboard
1815
 00FFE907 05D                             tstb
1816
 00FFE908 02B00B                          bmi             krb4                                            ; is input buffer full ? yes, branch
1817
 00FFE90A 08D02D                          bsr             Wait10ms                                ; wait a bit
1818
 00FFE90C 0301FF                          dex
1819
 00FFE90E 026FF5                          bne             krb3                                            ; go back and try again
1820
 00FFE910 0CCFFFFFF                       ldd             #-1                                                     ; return -1
1821
 00FFE913 035090                          puls    x,pc
1822 4 robfinch
                              krb4:
1823 16 robfinch
 00FFE915 08D066                          bsr             KeybdGetScancode
1824
 00FFE917 035090                          puls    x,pc
1825 4 robfinch
 
1826
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1827
                              ; Send a byte to the keyboard.
1828
                              ;
1829
                              ; Parameters: accb byte to send
1830
                              ; Returns: none
1831
                              ; Modifies: none
1832
                              ; Stack Space: 0 words
1833
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1834
 
1835
                              KeybdSendByte:
1836 16 robfinch
 00FFE919 0150F7FFFE30400                 stb             KEYBD
1837
 00FFE91E 039                             rts
1838 4 robfinch
 
1839
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1840
                              ; Wait until the keyboard transmit is complete
1841
                              ;
1842
                              ; Parameters: none
1843
                              ; Returns: r1 = 0 if successful, r1 = -1 timeout
1844
                              ; Modifies: r1
1845
                              ; Stack Space: 3 words
1846
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1847
 
1848
                              KeybdWaitTx:
1849 16 robfinch
 00FFE91F 034010                          pshs    x
1850
 00FFE921 08E000064                       ldx             #100                            ; wait a max of 1s
1851 4 robfinch
                              kwt1:
1852 16 robfinch
 00FFE924 08D03B                          bsr             KeybdGetStatus
1853
 00FFE926 0C4040                          andb    #$40                            ; check for transmit complete bit; branch if bit set
1854
 00FFE928 02600B                          bne             kwt2
1855
 00FFE92A 08D00D                          bsr             Wait10ms                ; delay a little bit
1856
 00FFE92C 0301FF                          dex
1857
 00FFE92E 026FF4                          bne             kwt1                            ; go back and try again
1858
 00FFE930 0CCFFFFFF                       ldd             #-1                                     ; timed out, return -1
1859
 00FFE933 035090                          puls    x,pc
1860 4 robfinch
                              kwt2:
1861 16 robfinch
 00FFE935 04F                             clra                                                    ; wait complete, return 0
1862
 00FFE936 05F                             clrb
1863
 00FFE937 035090                          puls    x,pc
1864 4 robfinch
 
1865
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1866
                              ; Wait for 10 ms
1867
                              ;
1868
                              ; Parameters: none
1869
                              ; Returns: none
1870
                              ; Modifies: none
1871
                              ; Stack Space: 2 words
1872
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1873
 
1874
                              Wait10ms:
1875 16 robfinch
 00FFE939 034006                          pshs    d
1876
 00FFE93B 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1877 4 robfinch
                              W10_0001:
1878 16 robfinch
 00FFE940 01F089                          tfr             a,b
1879
 00FFE942 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1880
 00FFE947 0C1FFA                          cmpb    #$FFA
1881
 00FFE949 022FF5                          bhi             W10_0001
1882
 00FFE94B 035086                          puls    d,pc
1883 4 robfinch
 
1884
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1885
                              ; Wait for 300 ms (256 ms)
1886
                              ;
1887
                              ; Parameters: none
1888
                              ; Returns: none
1889
                              ; Modifies: none
1890
                              ; Stack Space: 2 words
1891
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1892
 
1893
                              Wait300ms:
1894 16 robfinch
 00FFE94D 034006                          pshs    d
1895
 00FFE94F 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1896 4 robfinch
                              W300_0001:
1897 16 robfinch
 00FFE954 01F089                          tfr             a,b
1898
 00FFE956 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1899
 00FFE95B 0C1F00                          cmpb    #$F00
1900
 00FFE95D 022FF5                          bhi     W300_0001
1901
 00FFE95F 035086                          puls    d,pc
1902 4 robfinch
 
1903
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1904
                              ; Get the keyboard status
1905
                              ;
1906
                              ; Parameters: none
1907
                              ; Returns: d = status
1908
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1909
 
1910
                              KeybdGetStatus:
1911
                              kbgs3:
1912 16 robfinch
 00FFE961 0150F6FFFE30401                 ldb             KEYBD+1
1913
 00FFE966 0C5080                          bitb    #$80
1914
 00FFE968 02600E                          bne             kbgs1
1915
 00FFE96A 0C5001                          bitb    #$01            ; check parity error flag
1916
 00FFE96C 026002                          bne             kbgs2
1917
 00FFE96E 04F                             clra
1918
 00FFE96F 039                             rts
1919 4 robfinch
                              kbgs2:
1920 16 robfinch
 00FFE970 0C60FE                          ldb             #$FE            ; request resend
1921
 00FFE972 08DFA5                          bsr             KeybdSendByte
1922
 00FFE974 08DFA9                          bsr             KeybdWaitTx
1923
 00FFE976 020FE9                          bra             kbgs3
1924 4 robfinch
                              kbgs1:                                  ; return negative status
1925 16 robfinch
 00FFE978 0CAF00                          orb             #$F00
1926
 00FFE97A 086FFF                          lda             #-1
1927
 00FFE97C 039                             rts
1928 4 robfinch
 
1929
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1930
                              ; Get the scancode from the keyboard port
1931
                              ;
1932
                              ; Parameters: none
1933
                              ; Returns: acca = scancode
1934
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1935
 
1936
                              KeybdGetScancode:
1937 16 robfinch
 00FFE97D 04F                             clra
1938
 00FFE97E 0150F6FFFE30400                 ldb             KEYBD                           ; get the scan code
1939
 00FFE983 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
1940
 00FFE988 039                             rts
1941 4 robfinch
 
1942
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1943
                              ; Set the LEDs on the keyboard.
1944
                              ;
1945
                              ; Parameters: d LED status to set
1946
                              ; Returns: none
1947
                              ; Modifies: none
1948
                              ; Stack Space: 2 words
1949
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1950
 
1951
                              KeybdSetLED:
1952 16 robfinch
 00FFE989 034004                          pshs    b
1953
 00FFE98B 0C60ED                          ldb             #$ED                                            ; set LEDs command
1954
 00FFE98D 08DF8A                          bsr             KeybdSendByte
1955
 00FFE98F 08DF8E                          bsr             KeybdWaitTx
1956
 00FFE991 08DF6D                          bsr             KeybdRecvByte   ; should be an ack
1957
 00FFE993 035004                          puls    b
1958
 00FFE995 08DF82                          bsr             KeybdSendByte
1959
 00FFE997 08DF86                          bsr             KeybdWaitTx
1960
 00FFE999 08DF65                          bsr             KeybdRecvByte   ; should be an ack
1961
 00FFE99B 039                             rts
1962 4 robfinch
 
1963
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1964
                              ; Get ID - get the keyboards identifier code.
1965
                              ;
1966
                              ; Parameters: none
1967
                              ; Returns: d = $AB83, $00 on fail
1968
                              ; Modifies: d, KeybdID updated
1969
                              ; Stack Space: 2 words
1970
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1971
 
1972
                              KeybdGetID:
1973 16 robfinch
 00FFE99C 0C60F2                          ldb             #$F2
1974
 00FFE99E 08DF79                          bsr             KeybdSendByte
1975
 00FFE9A0 08DF7D                          bsr             KeybdWaitTx
1976
 00FFE9A2 08DF5C                          bsr             KeybdRecvByte
1977
 00FFE9A4 0C5080                          bitb    #$80
1978
 00FFE9A6 026014                          bne             kgnotKbd
1979
 00FFE9A8 0C10AB                          cmpb    #$AB
1980
 00FFE9AA 026010                          bne             kgnotKbd
1981
 00FFE9AC 08DF52                          bsr             KeybdRecvByte
1982
 00FFE9AE 0C5080                          bitb    #$80
1983
 00FFE9B0 02600A                          bne             kgnotKbd
1984
 00FFE9B2 0C1083                          cmpb    #$83
1985
 00FFE9B4 026006                          bne             kgnotKbd
1986
 00FFE9B6 0CC00AB83                       ldd             #$AB83
1987 4 robfinch
                              kgid1:
1988 16 robfinch
 00FFE9B9 0DD124                          std             KeybdID
1989
 00FFE9BB 039                             rts
1990 4 robfinch
                              kgnotKbd:
1991 16 robfinch
 00FFE9BC 04F                             clra
1992
 00FFE9BD 05F                             clrb
1993
 00FFE9BE 020FF9                          bra             kgid1
1994 4 robfinch
 
1995
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1996
                              ; Initialize the keyboard.
1997
                              ;
1998
                              ; Parameters:
1999
                              ;               none
2000
                              ;       Modifies:
2001
                              ;               none
2002
                              ; Returns:
2003
                              ;               none
2004
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2005
 
2006
                              KeybdInit:
2007 16 robfinch
 00FFE9C0 034026                          pshs    d,y
2008
 00FFE9C2 18E000005                       ldy             #5
2009
 00FFE9C5 00F120                          clr             KeyState1               ; records key up/down state
2010
 00FFE9C7 00F121                          clr             KeyState2               ; records shift,ctrl,alt state
2011 4 robfinch
                              kbdi0002:
2012 16 robfinch
 00FFE9C9 08DF6E                          bsr             Wait10ms
2013
 00FFE9CB 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
2014
 00FFE9D0 0C6FFF                          ldb             #-1                                     ; send reset code to keyboard
2015
 00FFE9D2 0150F7FFFE30401                 stb             KEYBD+1                 ; write $FF to status reg to clear TX state
2016
 00FFE9D7 08DF40                          bsr             KeybdSendByte   ; now write to transmit register
2017
 00FFE9D9 08DF44                          bsr             KeybdWaitTx             ; wait until no longer busy
2018
 00FFE9DB 08DF23                          bsr             KeybdRecvByte   ; look for an ACK ($FA)
2019
 00FFE9DD 0C10FA                          cmpb    #$FA
2020
 00FFE9DF 026021                          bne             kbdiTryAgain
2021
 00FFE9E1 08DF1D                          bsr             KeybdRecvByte   ; look for BAT completion code ($AA)
2022
 00FFE9E3 0C10FC                          cmpb    #$FC                            ; reset error ?
2023
 00FFE9E5 02701B                          beq             kbdiTryAgain
2024
 00FFE9E7 0C10AA                          cmpb    #$AA                            ; reset complete okay ?
2025
 00FFE9E9 026017                          bne             kbdiTryAgain
2026 4 robfinch
 
2027
                                      ; After a reset, scan code set #2 should be active
2028
                              .config:
2029 16 robfinch
 00FFE9EB 0C60F0                          ldb             #$F0                    ; send scan code select
2030
 00FFE9ED 0150F7FFFE60001                 stb             LEDS
2031
 00FFE9F2 08DF25                          bsr             KeybdSendByte
2032
 00FFE9F4 08DF29                          bsr             KeybdWaitTx
2033
 00FFE9F6 05D                             tstb
2034
 00FFE9F7 02B009                          bmi             kbdiTryAgain
2035
 00FFE9F9 08DF05                          bsr             KeybdRecvByte   ; wait for response from keyboard
2036
 00FFE9FB 04D                             tsta
2037
 00FFE9FC 02B004                          bmi             kbdiTryAgain
2038
 00FFE9FE 0C10FA                          cmpb    #$FA                                    ; ACK
2039
 00FFEA00 02700C                          beq             kbdi0004
2040 4 robfinch
                              kbdiTryAgain:
2041 16 robfinch
 00FFEA02 0313FF                          dey
2042
 00FFEA04 026FC3                          bne       kbdi0002
2043 4 robfinch
                              .keybdErr:
2044 16 robfinch
 00FFEA06 0CCFFEA2E                       ldd             #msgBadKeybd
2045
 00FFEA09 017FFF9EE                       lbsr    DisplayStringCRLF
2046 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
2047 16 robfinch
 00FFEA0C 020014                          bra             ledxit
2048 4 robfinch
                              kbdi0004:
2049 16 robfinch
 00FFEA0E 0C6002                          ldb             #2                      ; select scan code set #2
2050
 00FFEA10 08DF07                          bsr             KeybdSendByte
2051
 00FFEA12 08DF0B                          bsr             KeybdWaitTx
2052
 00FFEA14 05D                             tstb
2053
 00FFEA15 02BFEB                          bmi             kbdiTryAgain
2054
 00FFEA17 08DEE7                          bsr             KeybdRecvByte   ; wait for response from keyboard
2055
 00FFEA19 04D                             tsta
2056
 00FFEA1A 02BFE6                          bmi             kbdiTryAgain
2057
 00FFEA1C 0C10FA                          cmpb    #$FA
2058
 00FFEA1E 026FE2                          bne             kbdiTryAgain
2059
 00FFEA20 08DF7A                          bsr             KeybdGetID
2060 4 robfinch
                              ledxit:
2061 16 robfinch
 00FFEA22 0C6007                          ldb             #$07
2062
 00FFEA24 08DF63                          bsr             KeybdSetLED
2063
 00FFEA26 08DF25                          bsr             Wait300ms
2064
 00FFEA28 0C6000                          ldb             #$00
2065
 00FFEA2A 08DF5D                          bsr             KeybdSetLED
2066
 00FFEA2C 0350A6                          puls    d,y,pc
2067 4 robfinch
 
2068
                              msgBadKeybd:
2069 16 robfinch
 00FFEA2E 04B06507906206F061072           fcb             "Keyboard error",0
2070
 00FFEA35 06402006507207206F072
2071
 00FFEA3C 000
2072 4 robfinch
 
2073 13 robfinch
                              ;------------------------------------------------------------------------------
2074
                              ; Calculate number of character in input buffer
2075
                              ;
2076
                              ; Parameters:
2077
                              ;               y = $Cn00000 where n is core id
2078
                              ; Returns:
2079
                              ;               d = number of bytes in buffer.
2080
                              ;------------------------------------------------------------------------------
2081
 
2082
                              kbdRcvCount:
2083 16 robfinch
 00FFEA3D 04F                             clra
2084
 00FFEA3E 0E6A08128                       ldb             kbdTailRcv,y
2085
 00FFEA41 0E0A08127                       subb    kbdHeadRcv,y
2086
 00FFEA44 02C008                          bge             krcXit
2087
 00FFEA46 0C6040                          ldb             #$40
2088
 00FFEA48 0E0A08127                       subb    kbdHeadRcv,y
2089
 00FFEA4B 0EBA08128                       addb    kbdTailRcv,y
2090 13 robfinch
                              krcXit:
2091 16 robfinch
 00FFEA4E 039                             rts
2092 13 robfinch
 
2093
 
2094 4 robfinch
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2095
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2096
 
2097 13 robfinch
                              KeybdIRQ:
2098 16 robfinch
 00FFEA4F 0150B6FFFE30401                 lda             KEYBD+1                                         ; check status
2099
 00FFEA54 085080                          bita    #$80                                                    ; was key pressed?
2100
 00FFEA56 027034                          beq             notKbdIRQ                                       ; if not, exit
2101
 00FFEA58 0150F6FFFE30400                 ldb             KEYBD                                                   ; get the scan code
2102
 00FFEA5D 01507FFFFE30401                 clr             KEYBD+1                                         ; clear receive register (write $00 to status reg)
2103
 00FFEA62 034004                          pshs    b                                                                       ; save it off
2104
 00FFEA64 0B6FFC010                       lda             IOFocusID                                       ; compute core memory address $Cn0000
2105
 00FFEA67 05F                             clrb
2106
 00FFEA68 048                             asla
2107
 00FFEA69 048                             asla
2108
 00FFEA6A 048                             asla
2109
 00FFEA6B 048                             asla
2110
 00FFEA6C 08AC00                          ora             #$C00                                                   ; address $Cn0000
2111
 00FFEA6E 01F002                          tfr             d,y                                                             ; y =
2112
 00FFEA70 08DFCB                          bsr             kbdRcvCount                             ; get count of scan codes in buffer
2113
 00FFEA72 0C1040                          cmpb    #64                                                             ; check if buffer full?
2114
 00FFEA74 024017                          bhs             kbdBufFull                              ; if buffer full, ignore new keystroke
2115
 00FFEA76 01F021                          tfr             y,x                                                             ; compute fifo address
2116
 00FFEA78 0E6A08128                       ldb             kbdTailRcv,y                    ; b = buffer index
2117
 00FFEA7B 035002                          puls    a                                                                       ; get back scancode
2118
 00FFEA7D 030040                          leax    kbdFifo,x                                       ; x = base address for fifo
2119
 00FFEA7F 0A7845                          sta             b,x                                                             ; store in buffer
2120
 00FFEA81 05C                             incb                                                                            ; increment buffer index
2121
 00FFEA82 0C403F                          andb    #$3f                                                    ; wrap around at 64 chars
2122
 00FFEA84 0E7A08128                       stb             kbdTailRcv,y                    ; update it
2123
 00FFEA87 08601C                          lda             #28                                                             ; Keyboard is IRQ #28
2124
 00FFEA89 0B7FFC011                       sta             IrqSource                                       ; stuff a byte indicating the IRQ source for PEEK()
2125 13 robfinch
                              notKbdIRQ:
2126 16 robfinch
 00FFEA8C 039                             rts
2127 13 robfinch
                              kbdBufFull:
2128 16 robfinch
 00FFEA8D 032601                          leas    1,s                                                             ; get rid of saved scancode
2129
 00FFEA8F 039                             rts
2130 13 robfinch
 
2131
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2132
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2133
 
2134 4 robfinch
                              DBGCheckForKey:
2135 16 robfinch
 00FFEA90 020ECF                          bra             KeybdGetStatus
2136 4 robfinch
 
2137
 
2138
                              ; KeyState2 variable bit meanings
2139
                              ;1176543210
2140
                              ; ||||||||+ = shift
2141
                              ; |||||||+- = alt
2142
                              ; ||||||+-- = control
2143
                              ; |||||+--- = numlock
2144
                              ; ||||+---- = capslock
2145
                              ; |||+----- = scrolllock
2146
                              ; ||+------ = 
2147
                              ; |+------- =    "
2148
                              ; |         =    "
2149
                              ; |         =    "
2150
                              ; |         =    "
2151
                              ; +-------- = extended
2152
 
2153
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2154 13 robfinch
                              ; Keyboard get routine.
2155 4 robfinch
                              ;
2156 13 robfinch
                              ; The routine may get characters directly from the scancode input or less
2157
                              ; directly from the scancode buffer, if things are interrupt driven.
2158
                              ;
2159 4 robfinch
                              ; Parameters:
2160 13 robfinch
                              ;               b:  bit 11 = blocking status 1=blocking, 0=non blocking
2161
                              ;               b:      bit 1  = scancode source 1=scancode buffer, 0=direct
2162 4 robfinch
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2163
 
2164 13 robfinch
                              GetKey:
2165 16 robfinch
 00FFEA92 034030                          pshs    x,y
2166
 00FFEA94 0D7126                          stb             KeybdBlock                              ; save off blocking status
2167 4 robfinch
                              dbgk2:
2168 16 robfinch
 00FFEA96 0D6126                          ldb             KeybdBlock
2169
 00FFEA98 034004                          pshs    b
2170
 00FFEA9A 0C5001                          bitb    #1                                                              ; what is the scancode source
2171
 00FFEA9C 02701A                          beq             dbgk20                                          ; branch if direct read
2172
 00FFEA9E 0150B6FFFFFFFE0                 lda             COREID                                          ; compute core memory address
2173
 00FFEAA3 05F                             clrb
2174
 00FFEAA4 048                             asla
2175
 00FFEAA5 048                             asla
2176
 00FFEAA6 048                             asla
2177
 00FFEAA7 048                             asla
2178
 00FFEAA8 08AC00                          ora             #$C00
2179
 00FFEAAA 01F002                          tfr             d,y                                                             ; y = $Cn0000
2180
 00FFEAAC 08DF8F                          bsr             kbdRcvCount
2181
 00FFEAAE 05D                             tstb                                                                            ; anything in buffer?
2182
 00FFEAAF 035004                          puls    b
2183
 00FFEAB1 026018                          bne             dbgk1                                                   ; branch if something in buffer
2184
 00FFEAB3 05D                             tstb
2185
 00FFEAB4 02BFE0                          bmi             dbgk2                                                   ; if no key and blocking - loop
2186
 00FFEAB6 02000E                          bra             dbgk24
2187 13 robfinch
                              dbgk20:
2188 16 robfinch
 00FFEAB8 18E000000                       ldy             #0
2189
 00FFEABB 08DEA4                          bsr             KeybdGetStatus
2190
 00FFEABD 0C4080                          andb    #$80                                                    ; is key available?
2191
 00FFEABF 035004                          puls    b
2192
 00FFEAC1 026008                          bne             dbgk1                                                   ; branch if key
2193
 00FFEAC3 05D                             tstb                                                                            ; block?
2194
 00FFEAC4 02BFD0                          bmi             dbgk2                                                   ; If no key and blocking - loop
2195 13 robfinch
                              dbgk24:
2196 16 robfinch
 00FFEAC6 0CCFFFFFF                       ldd             #-1                                                             ; return -1 if no block and no key
2197
 00FFEAC9 0350B0                          puls    x,y,pc
2198 4 robfinch
                              dbgk1:
2199 16 robfinch
 00FFEACB 18C000000                       cmpy    #0
2200
 00FFEACE 026004                          bne             dbgk22
2201
 00FFEAD0 08DEAB                          bsr             KeybdGetScancode        ; get scancode directly
2202
 00FFEAD2 020011                          bra             dbgk23
2203 13 robfinch
                              dbgk22:
2204
                                      ; Retrieve value from scancode buffer
2205 16 robfinch
 00FFEAD4 01F021                          tfr             y,x
2206
 00FFEAD6 030040                          leax    kbdFifo,x                                       ; x = fifo address
2207
 00FFEAD8 0E6A08127                       ldb             kbdHeadRcv,y                    ; b = buffer index
2208
 00FFEADB 0A6A0D                          lda             b,x                                                             ; get the scancode
2209
 00FFEADD 05C                             incb                                                                            ; increment fifo index
2210
 00FFEADE 0C403F                          andb    #$3f                                                    ; and wrap around
2211
 00FFEAE0 0E7A08127                       stb             kbdHeadRcv,y                    ; save it back
2212
 00FFEAE3 01F089                          tfr             a,b                                                             ; the scancode is needed in accb
2213 13 robfinch
                              dbgk23:
2214 4 robfinch
                              ;       lbsr    DispByteAsHex
2215
                                      ; Make sure there is a small delay between scancode reads
2216 16 robfinch
 00FFEAE5 08E000014                       ldx             #20
2217 4 robfinch
                              dbgk3:
2218 16 robfinch
 00FFEAE8 0301FF                          dex
2219
 00FFEAEA 026FFC                          bne             dbgk3
2220 4 robfinch
                                      ; switch on scan code
2221 16 robfinch
 00FFEAEC 0C10F0                          cmpb    #SC_KEYUP
2222
 00FFEAEE 026004                          bne             dbgk4
2223
 00FFEAF0 0D7120                          stb             KeyState1                                       ; make KeyState1 <> 0
2224
 00FFEAF2 020FA2                          bra             dbgk2                                                   ; loop back
2225 4 robfinch
                              dbgk4:
2226 16 robfinch
 00FFEAF4 0C10E0                          cmpb    #SC_EXTEND
2227
 00FFEAF6 026008                          bne             dbgk5
2228
 00FFEAF8 096121                          lda             KeyState2
2229
 00FFEAFA 08A800                          ora             #$800
2230
 00FFEAFC 097121                          sta             KeyState2
2231
 00FFEAFE 020F96                          bra             dbgk2
2232 4 robfinch
                              dbgk5:
2233 16 robfinch
 00FFEB00 0C1014                          cmpb    #SC_CTRL
2234
 00FFEB02 026016                          bne             dbgkNotCtrl
2235
 00FFEB04 00D120                          tst             KeyState1
2236
 00FFEB06 026008                          bne             dbgk7
2237
 00FFEB08 096121                          lda             KeyState2
2238
 00FFEB0A 08A004                          ora             #4
2239
 00FFEB0C 097121                          sta             KeyState2
2240
 00FFEB0E 020006                          bra             dbgk8
2241 4 robfinch
                              dbgk7:
2242 16 robfinch
 00FFEB10 096121                          lda             KeyState2
2243
 00FFEB12 084FFB                          anda    #~4
2244
 00FFEB14 097121                          sta             KeyState2
2245 4 robfinch
                              dbgk8:
2246 16 robfinch
 00FFEB16 00F120                          clr             KeyState1
2247
 00FFEB18 020F7C                          bra             dbgk2
2248 4 robfinch
                              dbgkNotCtrl:
2249 16 robfinch
 00FFEB1A 0C1059                          cmpb    #SC_RSHIFT
2250
 00FFEB1C 026016                          bne             dbgkNotRshift
2251
 00FFEB1E 00D120                          tst             KeyState1
2252
 00FFEB20 026008                          bne             dbgk9
2253
 00FFEB22 096121                          lda             KeyState2
2254
 00FFEB24 08A001                          ora             #1
2255
 00FFEB26 097121                          sta             KeyState2
2256
 00FFEB28 020006                          bra             dbgk10
2257 4 robfinch
                              dbgk9:
2258 16 robfinch
 00FFEB2A 096121                          lda             KeyState2
2259
 00FFEB2C 084FFE                          anda    #~1
2260
 00FFEB2E 097121                          sta             KeyState2
2261 4 robfinch
                              dbgk10:
2262 16 robfinch
 00FFEB30 00F120                          clr             KeyState1
2263
 00FFEB32 020F62                          bra             dbgk2
2264 4 robfinch
                              dbgkNotRshift:
2265 16 robfinch
 00FFEB34 0C1077                          cmpb    #SC_NUMLOCK
2266
 00FFEB36 026013                          bne             dbgkNotNumlock
2267
 00FFEB38 096121                          lda             KeyState2
2268
 00FFEB3A 088010                          eora    #16
2269
 00FFEB3C 097121                          sta             KeyState2
2270
 00FFEB3E 096122                          lda             KeyLED
2271
 00FFEB40 088002                          eora    #2
2272
 00FFEB42 097122                          sta             KeyLED
2273
 00FFEB44 01F089                          tfr             a,b
2274
 00FFEB46 04F                             clra
2275
 00FFEB47 08DE40                          bsr             KeybdSetLED
2276
 00FFEB49 020F4B                          bra             dbgk2
2277 4 robfinch
                              dbgkNotNumlock:
2278 16 robfinch
 00FFEB4B 0C1058                          cmpb    #SC_CAPSLOCK
2279
 00FFEB4D 026013                          bne             dbgkNotCapslock
2280
 00FFEB4F 096121                          lda             KeyState2
2281
 00FFEB51 088020                          eora    #32
2282
 00FFEB53 097121                          sta             KeyState2
2283
 00FFEB55 096122                          lda             KeyLED
2284
 00FFEB57 088004                          eora    #4
2285
 00FFEB59 097122                          sta             KeyLED
2286
 00FFEB5B 01F089                          tfr             a,b
2287
 00FFEB5D 04F                             clra
2288
 00FFEB5E 08DE29                          bsr             KeybdSetLED
2289
 00FFEB60 020F34                          bra             dbgk2
2290 4 robfinch
                              dbgkNotCapslock:
2291 16 robfinch
 00FFEB62 0C107E                          cmpb    #SC_SCROLLLOCK
2292
 00FFEB64 026013                          bne             dbgkNotScrolllock
2293
 00FFEB66 096121                          lda             KeyState2
2294
 00FFEB68 088040                          eora    #64
2295
 00FFEB6A 097121                          sta             KeyState2
2296
 00FFEB6C 096122                          lda             KeyLED
2297
 00FFEB6E 088001                          eora    #1
2298
 00FFEB70 097122                          sta             KeyLED
2299
 00FFEB72 01F089                          tfr             a,b
2300
 00FFEB74 04F                             clra
2301
 00FFEB75 08DE12                          bsr             KeybdSetLED
2302
 00FFEB77 020F1D                          bra             dbgk2
2303 4 robfinch
                              dbgkNotScrolllock:
2304 16 robfinch
 00FFEB79 0C1011                          cmpb    #SC_ALT
2305
 00FFEB7B 026016                          bne             dbgkNotAlt
2306
 00FFEB7D 00D120                          tst             KeyState1
2307
 00FFEB7F 026008                          bne             dbgk11
2308
 00FFEB81 096121                          lda             KeyState2
2309
 00FFEB83 08A002                          ora             #2
2310
 00FFEB85 097121                          sta             KeyState2
2311
 00FFEB87 020006                          bra             dbgk12
2312 4 robfinch
                              dbgk11:
2313 16 robfinch
 00FFEB89 096121                          lda             KeyState2
2314
 00FFEB8B 084FFD                          anda    #~2
2315
 00FFEB8D 097121                          sta             KeyState2
2316 4 robfinch
                              dbgk12:
2317 16 robfinch
 00FFEB8F 00F120                          clr             KeyState1
2318
 00FFEB91 020F03                          bra             dbgk2
2319 4 robfinch
                              dbgkNotAlt:
2320 16 robfinch
 00FFEB93 00D120                          tst             KeyState1
2321
 00FFEB95 027004                          beq             dbgk13
2322
 00FFEB97 00F120                          clr             KeyState1
2323
 00FFEB99 020EFB                          bra             dbgk2
2324 4 robfinch
                              dbgk13:
2325 16 robfinch
 00FFEB9B 096121                          lda             KeyState2               ; Check for CTRL-ALT-DEL
2326
 00FFEB9D 084006                          anda    #6
2327
 00FFEB9F 081006                          cmpa    #6
2328
 00FFEBA1 026008                          bne             dbgk14
2329
 00FFEBA3 0C1071                          cmpb    #SC_DEL
2330
 00FFEBA5 026004                          bne             dbgk14
2331
 00FFEBA7 06E90FFFFFFC                    jmp             [$FFFFFC]               ; jump to NMI vector
2332 4 robfinch
                              dbgk14:
2333 16 robfinch
 00FFEBAB 00D121                          tst             KeyState2               ; extended code?
2334
 00FFEBAD 02A00B                          bpl             dbgk15
2335
 00FFEBAF 096121                          lda             KeyState2
2336
 00FFEBB1 0847FF                          anda    #$7FF
2337
 00FFEBB3 097121                          sta             KeyState2
2338
 00FFEBB5 08EFFE880                       ldx             #keybdExtendedCodes
2339
 00FFEBB8 020017                          bra             dbgk18
2340 4 robfinch
                              dbgk15:
2341 16 robfinch
 00FFEBBA 096121                          lda             KeyState2               ; Is CTRL down?
2342
 00FFEBBC 085004                          bita    #4
2343
 00FFEBBE 027005                          beq             dbgk16
2344
 00FFEBC0 08EFFE800                       ldx             #keybdControlCodes
2345
 00FFEBC3 02000C                          bra             dbgk18
2346 4 robfinch
                              dbgk16:
2347 16 robfinch
 00FFEBC5 085001                          bita    #1                                      ; Is shift down?
2348
 00FFEBC7 027005                          beq             dbgk17
2349
 00FFEBC9 08EFFE700                       ldx             #shiftedScanCodes
2350
 00FFEBCC 020003                          bra             dbgk18
2351 4 robfinch
                              dbgk17:
2352 16 robfinch
 00FFEBCE 08EFFE600                       ldx             #unshiftedScanCodes
2353 4 robfinch
                              dbgk18:
2354 16 robfinch
 00FFEBD1 0E690FFFE600                    ldb             b,x                                     ; load accb with ascii from table
2355
 00FFEBD5 04F                             clra
2356
 00FFEBD6 0350B0                          puls    x,y,pc                  ; and return
2357 4 robfinch
 
2358
 
2359 16 robfinch
 00FFEBD8 04B04505904204F041052           fcb             "KEYBOARD"
2360
 00FFEBDF 044
2361
 00FFEBE0 FFEBEA                          fcw             KeybdOpen
2362
 00FFEBE2 FFEBEB                          fcw             KeybdClose
2363
 00FFEBE4 FFEBEC                          fcw             KeybdRead
2364
 00FFEBE6 FFEBED                          fcw             KeybdWrite
2365
 00FFEBE8 FFEBEE                          fcw             KeybdSeek
2366 4 robfinch
 
2367
                              ; Keyboard Open:
2368
                              ; Initialize the keyboard buffer head and tail indexes
2369
                              ;
2370
                              KeybdOpen:
2371 16 robfinch
 00FFEBEA 039                             rts
2372 4 robfinch
 
2373
                              ; Keyboard Close:
2374
                              ; Nothing to do except maybe clear the keyboard buffer
2375
                              ;
2376
                              KeybdClose:
2377 16 robfinch
 00FFEBEB 039                             rts
2378 4 robfinch
                              ;
2379
                              KeybdRead:
2380 16 robfinch
 00FFEBEC 039                             rts
2381 4 robfinch
                              ;
2382
                              KeybdWrite:
2383 16 robfinch
 00FFEBED 039                             rts
2384 4 robfinch
 
2385
                              KeybdSeek:
2386 16 robfinch
 00FFEBEE 039                             rts
2387 4 robfinch
 
2388 13 robfinch
                              ;==============================================================================
2389
                              ; Serial I/O
2390
                              ;==============================================================================
2391
 
2392
                              ; ============================================================================
2393
                              ;        __
2394
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
2395
                              ;    \  __ /    All rights reserved.
2396
                              ;     \/_//     robfinch@opencores.org
2397
                              ;       ||
2398
                              ;
2399
                              ;
2400
                              ; Serial port routines for a WDC6551 compatible circuit.
2401
                              ;
2402
                              ; This source file is free software: you can redistribute it and/or modify
2403
                              ; it under the terms of the GNU Lesser General Public License as published
2404
                              ; by the Free Software Foundation, either version 3 of the License, or
2405
                              ; (at your option) any later version.
2406
                              ;
2407
                              ; This source file is distributed in the hope that it will be useful,
2408
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
2409
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2410
                              ; GNU General Public License for more details.
2411
                              ;
2412
                              ; You should have received a copy of the GNU General Public License
2413
                              ; along with this program.  If not, see .
2414
                              ;
2415
                              ; ============================================================================
2416
                              ;
2417 4 robfinch
                              ;------------------------------------------------------------------------------
2418 13 robfinch
                              ; Initialize serial port.
2419
                              ;
2420
                              ; Clear buffer indexes. Two bytes are used for the buffer index even though
2421
                              ; only a single byte is needed. This is for convenience in calculating the
2422
                              ; number of characters in the buffer, done later. The upper byte remains at
2423
                              ; zero.
2424
                              ; The port is initialized for 9600 baud, 1 stop bit and 8 bits data sent.
2425
                              ; The internal baud rate generator is used.
2426
                              ;
2427
                              ; Parameters:
2428
                              ;               none
2429
                              ; Modifies:
2430
                              ;               d
2431
                              ; Returns:
2432
                              ;               none
2433
                              ;------------------------------------------------------------------------------
2434
 
2435
                              InitSerial:
2436
                              SerialInit:
2437 16 robfinch
 00FFEBEF 04F                             clra
2438
 00FFEBF0 05F                             clrb
2439
 00FFEBF1 0DD130                          std             SerHeadRcv-1
2440
 00FFEBF3 0DD132                          std             SerTailRcv-1
2441
 00FFEBF5 0DD135                          std             SerHeadXmit-1
2442
 00FFEBF7 0DD137                          std             SerTailXmit-1
2443
 00FFEBF9 00F139                          clr             SerRcvXon
2444
 00FFEBFB 00F140                          clr             SerRcvXoff
2445
 00FFEBFD 0150B6FFFFFFFE0                 lda             COREID
2446 13 robfinch
                              sini1:
2447 16 robfinch
 00FFEC02 0B1FFC010                       cmpa    IOFocusID
2448
 00FFEC05 026FFB                          bne             sini1
2449
 00FFEC07 0C6009                          ldb             #$09                                            ; dtr,rts active, rxint enabled, no parity
2450
 00FFEC09 0150F7FFFE30102                 stb             ACIA+ACIA_CMD
2451
 00FFEC0E 0C601E                          ldb             #$1E                                            ; baud 9600, 1 stop bit, 8 bit, internal baud gen
2452
 00FFEC10 0150F7FFFE30103                 stb             ACIA+ACIA_CTRL
2453
 00FFEC15 0C60A6                          ldb             #$0A6                                           ; diable fifos, reset fifos
2454
 00FFEC17 0150F7FFFE3010B                 stb             ACIA+ACIA_CTRL2
2455
 00FFEC1C 039                             rts
2456 13 robfinch
 
2457
                              ;------------------------------------------------------------------------------
2458
                              ; SerialGetChar
2459
                              ;
2460
                              ; Check the serial port buffer to see if there's a char available. If there's
2461
                              ; a char available then return it. If the buffer is almost empty then send an
2462
                              ; XON.
2463
                              ;
2464
                              ; Stack Space:
2465
                              ;               2 words
2466
                              ; Parameters:
2467
                              ;               none
2468
                              ; Modifies:
2469
                              ;               none
2470
                              ; Returns:
2471
                              ;               d = character or -1
2472
                              ;------------------------------------------------------------------------------
2473
 
2474
                              SerialGetChar:
2475 16 robfinch
 00FFEC1D 034030                                  pshs    x,y
2476
 00FFEC1F 18E000000                               ldy             #0
2477
 00FFEC22 01A010                                  sei                                                                             ; disable interrupts
2478
 00FFEC24 08D082                                  bsr             SerialRcvCount                  ; check number of chars in receive buffer
2479
 00FFEC26 0C1008                                  cmpb    #8                                                      ; less than 8?
2480
 00FFEC28 02200C                                  bhi             sgc2
2481
 00FFEC2A 0D6139                                  ldb             SerRcvXon                               ; skip sending XON if already sent
2482
 00FFEC2C 026008                                  bne       sgc2            ; XON already sent?
2483
 00FFEC2E 0C6011                                  ldb             #XON                                            ; if <8 send an XON
2484
 00FFEC30 00F140                                  clr             SerRcvXoff                      ; clear XOFF status
2485
 00FFEC32 0D7139                                  stb             SerRcvXon                               ; flag so we don't send it multiple times
2486
 00FFEC34 08D052                                  bsr             SerialPutChar
2487 13 robfinch
                              sgc2:
2488 16 robfinch
 00FFEC36 0D6131                                  ldb             SerHeadRcv                      ; check if anything is in buffer
2489
 00FFEC38 0D1133                                  cmpb    SerTailRcv
2490
 00FFEC3A 02700A                                  beq             sgcNoChars                      ; no?
2491
 00FFEC3C 08EBFF000                               ldx             #SerRcvBuf
2492
 00FFEC3F 04F                                     clra
2493
 00FFEC40 0E6835                                  ldb             b,x                                                     ; get byte from buffer
2494
 00FFEC42 00C131                                  inc             SerHeadRcv                      ; 4k wrap around
2495
 00FFEC44 020003                                  bra             sgcXit
2496 13 robfinch
                              sgcNoChars:
2497 16 robfinch
 00FFEC46 0CCFFFFFF                               ldd             #-1
2498 13 robfinch
                              sgcXit:
2499 16 robfinch
 00FFEC49 01C0EF                                  cli
2500
 00FFEC4B 0350B0                                  puls    x,y,pc
2501 13 robfinch
 
2502
                              ;------------------------------------------------------------------------------
2503
                              ; SerialPeekChar
2504
                              ;
2505
                              ; Check the serial port buffer to see if there's a char available. If there's
2506
                              ; a char available then return it. But don't update the buffer indexes. No need
2507
                              ; to send an XON here.
2508
                              ;
2509
                              ; Stack Space:
2510
                              ;               0 words
2511
                              ; Parameters:
2512
                              ;               none
2513
                              ; Modifies:
2514
                              ;               none
2515
                              ; Returns:
2516
                              ;               d = character or -1
2517
                              ;------------------------------------------------------------------------------
2518
 
2519
                              SerialPeekChar:
2520 16 robfinch
 00FFEC4D 034011                          pshs    x,ccr
2521
 00FFEC4F 01A010                          sei
2522
 00FFEC51 0D6131                          ldb             SerHeadRcv                              ; check if anything is in buffer
2523
 00FFEC53 0D1133                          cmpb    SerTailRcv
2524
 00FFEC55 027008                          beq             spcNoChars                              ; no?
2525
 00FFEC57 08EBFF000                       ldx             #SerRcvBuf
2526
 00FFEC5A 04F                             clra
2527
 00FFEC5B 0E6815                          ldb             b,x                                                             ; get byte from buffer
2528
 00FFEC5D 020003                          bra             spcXit
2529 13 robfinch
                              spcNoChars:
2530 16 robfinch
 00FFEC5F 0CCFFFFFF                       ldd             #-1
2531 13 robfinch
                              spcXit:
2532 16 robfinch
 00FFEC62 035091                          puls    x,ccr,pc
2533 13 robfinch
 
2534
                              ;------------------------------------------------------------------------------
2535
                              ; SerialPeekChar
2536
                              ;               Get a character directly from the I/O port. This bypasses the input
2537
                              ; buffer.
2538
                              ;
2539
                              ; Stack Space:
2540
                              ;               0 words
2541
                              ; Parameters:
2542
                              ;               none
2543
                              ; Modifies:
2544
                              ;               d
2545
                              ; Returns:
2546
                              ;               d = character or -1
2547
                              ;------------------------------------------------------------------------------
2548
 
2549
                              SerialPeekCharDirect:
2550 16 robfinch
 00FFEC64 0150B6FFFFFFFE0                 lda             COREID                                                  ; Ensure we have the IO Focus
2551
 00FFEC69 0B1FFC010                       cmpa    IOFocusID
2552
 00FFEC6C 026014                          bne             spcd0001
2553 13 robfinch
                                      ; Disallow interrupts between status read and rx read.
2554 16 robfinch
 00FFEC6E 01A010                          sei
2555
 00FFEC70 0150F6FFFE30101                 ldb             ACIA+ACIA_STAT
2556
 00FFEC75 0C5008                          bitb    #8                                                                      ; look for Rx not empty
2557
 00FFEC77 027009                          beq             spcd0001
2558
 00FFEC79 04F                             clra
2559
 00FFEC7A 0150F6FFFE30100                 ldb             ACIA+ACIA_RX
2560
 00FFEC7F 01C0EF                          cli
2561
 00FFEC81 039                             rts
2562 13 robfinch
                              spcd0001:
2563 16 robfinch
 00FFEC82 0CCFFFFFF                       ldd             #-1
2564
 00FFEC85 01C0EF                          cli
2565
 00FFEC87 039                             rts
2566 13 robfinch
 
2567
                              ;------------------------------------------------------------------------------
2568
                              ; SerialPutChar
2569
                              ;    Put a character to the serial transmitter. This routine blocks until the
2570
                              ; transmitter is empty.
2571
                              ;
2572
                              ; Stack Space
2573
                              ;               0 words
2574
                              ; Parameters:
2575
                              ;               b = character to put
2576
                              ; Modifies:
2577
                              ;               none
2578
                              ;------------------------------------------------------------------------------
2579
 
2580
                              SerialPutChar:
2581 16 robfinch
 00FFEC88 034003                          pshs    a,ccr
2582 13 robfinch
                              spc0001:
2583 16 robfinch
 00FFEC8A 0150B6FFFFFFFE0                 lda             COREID                                  ; Ensure we have the IO Focus
2584
 00FFEC8F 0B1FFC010                       cmpa    IOFocusID
2585
 00FFEC92 026FF6                          bne             spc0001
2586
 00FFEC94 01C0EF                          cli                                                                             ; provide a window for an interrupt to occur
2587
 00FFEC96 01A010                          sei
2588 13 robfinch
                                      ; Between the status read and the transmit do not allow an
2589
                                      ; intervening interrupt.
2590 16 robfinch
 00FFEC98 0150B6FFFE30101                 lda             ACIA+ACIA_STAT  ; wait until the uart indicates tx empty
2591
 00FFEC9D 085010                          bita    #16                                                     ; bit #4 of the status reg
2592
 00FFEC9F 027FE9                          beq             spc0001                     ; branch if transmitter is not empty
2593
 00FFECA1 0150F7FFFE30100                 stb             ACIA+ACIA_TX            ; send the byte
2594
 00FFECA6 035083                          puls    a,ccr,pc
2595 13 robfinch
 
2596
                              ;------------------------------------------------------------------------------
2597
                              ; Calculate number of character in input buffer
2598
                              ;
2599
                              ; Parameters:
2600
                              ;               y = 0 if current core, otherwise reference to core memory area $Cyxxxx
2601
                              ; Returns:
2602
                              ;               d = number of bytes in buffer.
2603
                              ;------------------------------------------------------------------------------
2604
 
2605
                              SerialRcvCount:
2606 16 robfinch
 00FFECA8 04F                             clra
2607
 00FFECA9 0E6A08133                       ldb             SerTailRcv,y
2608
 00FFECAC 0E0A08131                       subb    SerHeadRcv,y
2609
 00FFECAF 02C009                          bge             srcXit
2610
 00FFECB1 0CC001000                       ldd             #$1000
2611
 00FFECB4 0A3A08131                       subd    SerHeadRcv,y
2612
 00FFECB7 0E3A08133                       addd    SerTailRcv,y
2613 13 robfinch
                              srcXit:
2614 16 robfinch
 00FFECBA 039                             rts
2615 13 robfinch
 
2616
                              ;------------------------------------------------------------------------------
2617
                              ; Serial IRQ routine
2618
                              ;
2619
                              ; Keeps looping as long as it finds characters in the ACIA recieve buffer/fifo.
2620
                              ; Received characters are buffered. If the buffer becomes full, new characters
2621
                              ; will be lost.
2622
                              ;
2623
                              ; Parameters:
2624
                              ;               none
2625
                              ; Modifies:
2626
                              ;               d,x
2627
                              ; Returns:
2628
                              ;               none
2629
                              ;------------------------------------------------------------------------------
2630
 
2631
                              SerialIRQ:
2632
                              sirqNxtByte:
2633 16 robfinch
 00FFECBB 0150F6FFFE30101                 ldb             ACIA+ACIA_STAT  ; check the status
2634
 00FFECC0 0C5008                          bitb    #$08                                            ; bit 3 = rx full
2635
 00FFECC2 027049                          beq             notRxInt
2636
 00FFECC4 0150F6FFFE30100                 ldb             ACIA+ACIA_RX            ; get data from Rx buffer to clear interrupt
2637
 00FFECC9 0C1014                          cmpb    #CTRLT                                  ; detect special keystroke
2638
 00FFECCB 026000                          bne     sirq0001
2639 13 robfinch
                              ;       bsr     DumpTraceQueue
2640
                              sirq0001:
2641 16 robfinch
 00FFECCD 034004                          pshs    b
2642 13 robfinch
                                      ; Compute receive buffer address
2643 16 robfinch
 00FFECCF 0B6FFC010                       lda             IOFocusID
2644
 00FFECD2 048                             asla
2645
 00FFECD3 048                             asla
2646
 00FFECD4 048                             asla
2647
 00FFECD5 048                             asla
2648
 00FFECD6 08AC00                          ora             #$C00
2649
 00FFECD8 05F                             clrb
2650
 00FFECD9 01F002                          tfr             d,y
2651
 00FFECDB 035004                          puls    b
2652
 00FFECDD 0A6A08133                       lda             SerTailRcv,y                    ; check if recieve buffer full
2653
 00FFECE0 04C                             inca
2654
 00FFECE1 0A1A08131                       cmpa    SerHeadRcv,y
2655
 00FFECE4 027027                          beq             sirqRxFull
2656
 00FFECE6 0A7A08133                       sta             SerTailRcv,y            ; update tail pointer
2657
 00FFECE9 04A                             deca                                                                    ; backup
2658
 00FFECEA 01E089                          exg             a,b
2659
 00FFECEC 030A0A000BFF000                 leax    SerRcvBuf,y                     ; x = buffer address
2660
 00FFECF1 0A7A0F                          sta             b,x                                                     ; store recieved byte in buffer
2661
 00FFECF3 06DA08140                       tst             SerRcvXoff,y            ; check if xoff already sent
2662
 00FFECF6 026FC3                          bne             sirqNxtByte
2663
 00FFECF8 08DFAE                          bsr             SerialRcvCount  ; if more than 4080 chars in buffer
2664
 00FFECFA 0C1FF0                          cmpb    #4080
2665
 00FFECFC 025FBD                          blo             sirqNxtByte
2666
 00FFECFE 0C6013                          ldb             #XOFF                                           ; send an XOFF
2667
 00FFED00 06FA08139                       clr             SerRcvXon,y                     ; clear XON status
2668
 00FFED03 0E7A08140                       stb             SerRcvXoff,y            ; set XOFF status
2669
 00FFED06 0150F7FFFE30100                 stb             ACIA+ACIA_TX
2670
 00FFED0B 020FAE                          bra             sirqNxtByte     ; check the status for another byte
2671 13 robfinch
                              sirqRxFull:
2672
                              notRxInt:
2673 16 robfinch
 00FFED0D 039                             rts
2674 13 robfinch
 
2675
                              nmeSerial:
2676 16 robfinch
 00FFED0E 05306507206906106C000           fcb             "Serial",0
2677 13 robfinch
 
2678
                              ;------------------------------------------------------------------------------
2679
                              ; Put a string to the serial port.
2680
                              ;
2681
                              ; Parameters:
2682
                              ;               d = pointer to string
2683
                              ; Modifies:
2684
                              ;               none
2685
                              ; Returns:
2686
                              ;               none
2687
                              ;------------------------------------------------------------------------------
2688
 
2689
                              SerialPutString:
2690 16 robfinch
 00FFED15 034016                          pshs    d,x
2691
 00FFED17 01F001                          tfr             d,x
2692 13 robfinch
                              sps2:
2693 16 robfinch
 00FFED19 0E6804                          ldb             ,x
2694
 00FFED1B 027006                          beq             spsXit
2695
 00FFED1D 030001                          inx
2696
 00FFED1F 08DF67                          bsr             SerialPutChar
2697
 00FFED21 020FF6                          bra             sps2
2698 13 robfinch
                              spsXit:
2699 16 robfinch
 00FFED23 035096                          puls    d,x,pc
2700 13 robfinch
 
2701
                              ;------------------------------------------------------------------------------
2702
                              ; A little routine to test serial output.
2703
                              ;
2704
                              ; Parameters:
2705
                              ;               none
2706
                              ; Modifies:
2707
                              ;               none
2708
                              ; Returns:
2709
                              ;               none
2710
                              ;------------------------------------------------------------------------------
2711
 
2712
                              SerialOutputTest:
2713 16 robfinch
 00FFED25 034006                          pshs    d
2714
 00FFED27 0CCFFED45                       ldd             #msgSerialTest
2715
 00FFED2A 017FFF6AD                       lbsr    DisplayString
2716 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2717 16 robfinch
 00FFED2D 08DEC0                          bsr             SerialInit
2718 13 robfinch
                              sotst1:
2719 16 robfinch
 00FFED2F 0C6011                          ldb             #XON
2720
 00FFED31 08DF55                          bsr             SerialPutChar
2721
 00FFED33 08DF53                          bsr             SerialPutChar
2722
 00FFED35 08DF51                          bsr             SerialPutChar
2723
 00FFED37 0CCFFED45                       ldd             #msgSerialTest
2724
 00FFED3A 08DFD9                          bsr             SerialPutString
2725
 00FFED3C 01700016A                       lbsr    INCH
2726
 00FFED3F 0C1003                          cmpb    #CTRLC
2727
 00FFED41 026FEC                          bne             sotst1
2728
 00FFED43 035086                          puls    d,pc
2729 13 robfinch
 
2730
                              msgSerialTest:
2731 16 robfinch
 00FFED45 05306507206906106C020           fcb     "Serial port test",CR,LF,0
2732
 00FFED4C 07006F072074020074065
2733
 00FFED53 07307400D00A000
2734 13 robfinch
 
2735 16 robfinch
                              ; ============================================================================
2736
                              ;        __
2737
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
2738
                              ;    \  __ /    All rights reserved.
2739
                              ;     \/_//     robfinch@opencores.org
2740
                              ;       ||
2741
                              ;
2742
                              ;
2743
                              ; BSD 3-Clause License
2744
                              ; Redistribution and use in source and binary forms, with or without
2745
                              ; modification, are permitted provided that the following conditions are met:
2746
                              ;
2747
                              ; 1. Redistributions of source code must retain the above copyright notice, this
2748
                              ;    list of conditions and the following disclaimer.
2749
                              ;
2750
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
2751
                              ;    this list of conditions and the following disclaimer in the documentation
2752
                              ;    and/or other materials provided with the distribution.
2753
                              ;
2754
                              ; 3. Neither the name of the copyright holder nor the names of its
2755
                              ;    contributors may be used to endorse or promote products derived from
2756
                              ;    this software without specific prior written permission.
2757
                              ;
2758
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2759
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2760
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2761
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2762
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2763
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2764
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2765
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2766
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2767
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2768
                              ;
2769
                              ; ============================================================================
2770
                              ;
2771
                              s19Address                      EQU             $940    ; to $943
2772
                              s19StartAddress EQU             $944    ; to $947
2773
                              s19Rectype                      EQU             $948
2774
                              s19Reclen                               EQU             $949
2775
                              s19Abort                                EQU             $94A
2776 13 robfinch
 
2777 16 robfinch
                              ; ------------------------------------------------------------------------------
2778
                              ; Skip over input to the next record.
2779
                              ; ------------------------------------------------------------------------------
2780
 
2781
                              s19NextRecord:
2782
 00FFED58 0CCFFFFFF                       ldd             #-1                                                     ; block until input is available
2783
 00FFED5B 03F                             swi
2784
 00FFED5C 001                             fcb             MF_INCH                                 ; monitor input rout
2785
 00FFED5D 0C100A                          cmpb    #LF                                                     ; line feed marks end of record
2786
 00FFED5F 027013                          beq             s19nr1
2787
 00FFED61 0C1003                          cmpb    #CTRLC                                  ; should not get this in a file transfer
2788
 00FFED63 026003                          bne             s19nr2
2789
 00FFED65 0F700094A                       stb             s19Abort
2790
                              s19nr2:
2791
 00FFED68 0C101A                          cmpb    #CTRLZ                                  ; end of file marker?
2792
 00FFED6A 026003                          bne             s19nr3
2793
 00FFED6C 0F700094A                       stb             s19Abort
2794
                              s19nr3:
2795
 00FFED6F 07D00094A                       tst             s19Abort
2796
 00FFED72 027FE4                          beq             s19NextRecord
2797
                              s19nr1:
2798
 00FFED74 039                             rts
2799
 
2800
                              ; ------------------------------------------------------------------------------
2801
                              ; Input a byte. There are three characters per byte since things are 12-bit.
2802
                              ;
2803
                              ;       Parameters:
2804
                              ;               none
2805
                              ; Returns:
2806
                              ;               accb = byte value converted from text
2807
                              ; ------------------------------------------------------------------------------
2808
 
2809
                              s19GetByte:
2810
 00FFED75 03F                             swi
2811
 00FFED76 001                             fcb             MF_INCH                                         ; get the first character
2812
 00FFED77 0170004F6                       lbsr    AsciiToHexNybble        ; convert to nybble
2813
 00FFED7A 07D00094A                       tst             s19Abort                                        ; check for abort
2814
 00FFED7D 027002                          beq             s19gb1
2815
 00FFED7F 04F                             clra
2816
 00FFED80 039                             rts
2817
                              s19gb1:                                                                         ; shift the value four bits
2818
 00FFED81 058                             aslb
2819
 00FFED82 058                             aslb
2820
 00FFED83 058                             aslb
2821
 00FFED84 058                             aslb
2822
 00FFED85 034004                          pshs    b                                                                       ; save off value
2823
 00FFED87 03F                             swi
2824
 00FFED88 001                             fcb             MF_INCH                                         ; get the second character
2825
 00FFED89 0170004E4                       lbsr    AsciiToHexNybble        ; convert to nybble
2826
 00FFED8C 07D00094A                       tst             s19Abort                                        ; check for abort
2827
 00FFED8F 026011                          bne             s19gb2
2828
 00FFED91 0EAE00                          orb             ,s+                                                             ; merge new nybble into value
2829
 00FFED93 058                             aslb                                                                            ; shift the value four more bits
2830
 00FFED94 058                             aslb
2831
 00FFED95 058                             aslb
2832
 00FFED96 058                             aslb
2833
 00FFED97 034004                          pshs    b                                                                       ; save off value
2834
 00FFED99 03F                             swi
2835
 00FFED9A 001                             fcb             MF_INCH                                         ; get third character
2836
 00FFED9B 0170004D2                       lbsr    AsciiToHexNybble        ; convert to nybble
2837
 00FFED9E 0EAE00                          orb             ,s+                                                             ; merge in value
2838
 00FFEDA0 04F                             clra                                                                            ; make byte 000 to FFF in D
2839
 00FFEDA1 039                             rts
2840
                              s19gb2:
2841
 00FFEDA2 032601                          leas    1,s                                                             ; discard saved byte
2842
 00FFEDA4 04F                             clra
2843
 00FFEDA5 039                             rts
2844
 
2845
                              ; ------------------------------------------------------------------------------
2846
                              ; Zero out address
2847
                              ; ------------------------------------------------------------------------------
2848
 
2849
                              s19ClearAddress:
2850
 00FFEDA6 07F000940                       clr             s19Address
2851
 00FFEDA9 07F000941                       clr             s19Address+1
2852
 00FFEDAC 07F000942                       clr             s19Address+2
2853
 00FFEDAF 07F000943                       clr             s19Address+3
2854
 00FFEDB2 039                             rts
2855
 
2856
                              ; ------------------------------------------------------------------------------
2857
                              ; Get an address composed of two bytes (24 bit)
2858
                              ;
2859
                              ; Side Effects:
2860
                              ;               updates s19Address variable
2861
                              ; Returns:
2862
                              ;       none
2863
                              ; ------------------------------------------------------------------------------
2864
 
2865
                              s19GetAddress2:
2866
 00FFEDB3 08DFF1                          bsr             s19ClearAddress
2867
 00FFEDB5 08DFBE                          bsr             s19GetByte
2868
 00FFEDB7 0F7000942                       stb             s19Address+2
2869
 00FFEDBA 07D00094A                       tst             s19Abort
2870
 00FFEDBD 026005                          bne             s19ga1
2871
 00FFEDBF 08DFB4                          bsr             s19GetByte
2872
 00FFEDC1 0F7000943                       stb             s19Address+3
2873
                              s19ga1:
2874
 00FFEDC4 039                             rts
2875
 
2876
                              ; ------------------------------------------------------------------------------
2877
                              ; Get an address composed of three bytes (36 bit)
2878
                              ;
2879
                              ; Side Effects:
2880
                              ;               updates s19Address variable
2881
                              ; Returns:
2882
                              ;       none
2883
                              ; ------------------------------------------------------------------------------
2884
 
2885
                              s19GetAddress3:
2886
 00FFEDC5 08DFDF                          bsr             s19ClearAddress
2887
 00FFEDC7 08DFAC                          bsr             s19GetByte
2888
 00FFEDC9 0F7000941                       stb             s19Address+1
2889
 00FFEDCC 07D00094A                       tst             s19Abort
2890
 00FFEDCF 02600F                          bne             s19ga2
2891
 00FFEDD1 08DFA2                          bsr             s19GetByte
2892
 00FFEDD3 0F7000942                       stb             s19Address+2
2893
 00FFEDD6 07D00094A                       tst             s19Abort
2894
 00FFEDD9 026005                          bne             s19ga2
2895
 00FFEDDB 08DF98                          bsr             s19GetByte
2896
 00FFEDDD 0F7000943                       stb             s19Address+3
2897
                              s19ga2:
2898
 00FFEDE0 039                             rts
2899
 
2900
                              ; ------------------------------------------------------------------------------
2901
                              ; Put a byte to memory.
2902
                              ; ------------------------------------------------------------------------------
2903
 
2904
                              s19PutMem:
2905
 00FFEDE1 05F                             clrb                                                            ; accb = current byte count
2906
                              s19pm3:
2907
 00FFEDE2 034004                          pshs    b                                                       ; save byte count
2908
 00FFEDE4 08DF8F                          bsr             s19GetByte
2909
 00FFEDE6 07D00094A                       tst             s19Abort
2910
 00FFEDE9 02601C                          bne             s19pm1
2911
 00FFEDEB 0150E790F000941                 stb             far [s19Address+1]      ; store the byte using far addressing
2912
 00FFEDF0 07C000943                       inc             s19Address+3
2913
 00FFEDF3 026008                          bne             s19pm2
2914
 00FFEDF5 07C000942                       inc             s19Address+2
2915
 00FFEDF8 026003                          bne             s19pm2
2916
 00FFEDFA 07C000941                       inc             s19Address+1
2917
                              s19pm2:
2918
 00FFEDFD 035004                          puls    b                                                       ; get back byte count
2919
 00FFEDFF 05C                             incb                                                            ; increment and
2920
 00FFEE00 0F1000949                       cmpb    s19Reclen                       ; compare to record length
2921
 00FFEE03 025FDD                          blo             s19pm3
2922
 00FFEE05 020F6E                          bra             s19GetByte              ; get the checksum byte
2923
                              s19pm1:
2924
 00FFEE07 032601                          leas    1,s                                             ; faster than actual pull
2925
 00FFEE09 020F6A                          bra             s19GetByte              ; get the checksum byte
2926
 
2927
                              ; ------------------------------------------------------------------------------
2928
                              ; Processing for S1 record type.
2929
                              ; ------------------------------------------------------------------------------
2930
 
2931
                              s19ProcessS1:
2932
 00FFEE0B 08DFA6                          bsr             s19GetAddress2
2933
 00FFEE0D 08DFD2                          bsr             s19PutMem
2934
 00FFEE0F 020072                          bra             s19lnr
2935
 
2936
                              ; ------------------------------------------------------------------------------
2937
                              ; Processing for S2 record type.
2938
                              ; ------------------------------------------------------------------------------
2939
 
2940
                              s19ProcessS2:
2941
 00FFEE11 08DFB2                          bsr             s19GetAddress3
2942
 00FFEE13 08DFCC                          bsr             s19PutMem
2943
 00FFEE15 02006C                          bra             s19lnr
2944
 
2945
                              ; S3,4,5,6 not processed
2946
 
2947
                              ; ------------------------------------------------------------------------------
2948
                              ; Processing for S7 record type. Gets a two byte (24 bit) start address.
2949
                              ; ------------------------------------------------------------------------------
2950
 
2951
                              s19ProcessS9:
2952
 00FFEE17 08DF9A                          bsr             s19GetAddress2
2953
 00FFEE19 0FC000942                       ldd             s19Address+2
2954
 00FFEE1C 0FD000946                       std             s19StartAddress+2
2955
 00FFEE1F 0FC000940                       ldd             s19Address+0
2956
 00FFEE22 0FD000944                       std             s19StartAddress+0
2957
 00FFEE25 020069                          bra             s19l2
2958
 
2959
                              ; ------------------------------------------------------------------------------
2960
                              ; Processing for S8 record type. Gets a three byte (36 bit) start address.
2961
                              ; ------------------------------------------------------------------------------
2962
 
2963
                              s19ProcessS8:
2964
 00FFEE27 08DF9C                          bsr             s19GetAddress3
2965
 00FFEE29 0FC000942                       ldd             s19Address+2
2966
 00FFEE2C 0FD000946                       std             s19StartAddress+2
2967
 00FFEE2F 0FC000940                       ldd             s19Address+0
2968
 00FFEE32 0FD000944                       std             s19StartAddress+0
2969
 00FFEE35 020059                          bra             s19l2
2970
 
2971
                              ; ------------------------------------------------------------------------------
2972
                              ; S19 Loader
2973
                              ;
2974
                              ; Not all record types are processed. Some are skipped over.
2975
                              ; ------------------------------------------------------------------------------
2976
 
2977
                              S19Loader:
2978
 00FFEE37 07F00094A                       clr             s19Abort                                ; clear the abort flag
2979
 00FFEE3A 0CCFFEE93                       ldd             #msgS19Loader           ; signon banner
2980
 00FFEE3D 03F                             swi
2981
 00FFEE3E 004                             fcb             MF_DisplayString
2982
                              s19l3:
2983
 00FFEE3F 03F                             swi                                                                             ; get a character from input
2984
 00FFEE40 001                             fcb             MF_INCH
2985
 00FFEE41 0C101A                          cmpb    #CTRLZ                                  ; is it CTRL-Z?
2986
 00FFEE43 02704B                          beq             s19l2
2987
 00FFEE45 0C1053                          cmpb    #'S'                                            ; records must start with the letter S
2988
 00FFEE47 02603A                          bne             s19lnr
2989
 00FFEE49 03F                             swi                                                                             ; get the next character
2990
 00FFEE4A 001                             fcb             MF_INCH
2991
 00FFEE4B 0C1030                          cmpb    #'0'                                            ; must be a numeric digit
2992
 00FFEE4D 025034                          blo             s19lnr
2993
 00FFEE4F 0C1039                          cmpb    #'9'
2994
 00FFEE51 022030                          bhi             s19lnr
2995
 00FFEE53 0F7000948                       stb             s19Rectype                      ; save off in record type
2996
 00FFEE56 08DF1D                          bsr             s19GetByte                      ; get a byte indicating record length
2997
 00FFEE58 0F7000949                       stb             s19Reclen
2998
 00FFEE5B 07D00094A                       tst             s19Abort                                ; check for abort
2999
 00FFEE5E 026030                          bne             s19l2
3000
 00FFEE60 0F6000948                       ldb             s19Rectype                      ; process according to record type
3001
 00FFEE63 0C1030                          cmpb    #'0'
3002
 00FFEE65 02701C                          beq             s19lnr
3003
 00FFEE67 0C1031                          cmpb    #'1'
3004
 00FFEE69 027FA0                          beq             s19ProcessS1            ; data record with a two byte address
3005
 00FFEE6B 0C1032                          cmpb    #'2'
3006
 00FFEE6D 027FA2                          beq             s19ProcessS2            ; data record with a three byte address
3007
 00FFEE6F 0C1033                          cmpb    #'3'
3008
 00FFEE71 027010                          beq             s19lnr
3009
 00FFEE73 0C1035                          cmpb    #'5'                                            ; record count? ignore
3010
 00FFEE75 02700C                          beq             s19lnr
3011
 00FFEE77 0C1037                          cmpb    #'7'                                            ; ignore record with 48 bit address
3012
 00FFEE79 027015                          beq             s19l2
3013
 00FFEE7B 0C1038                          cmpb    #'8'
3014
 00FFEE7D 027FA8                          beq             s19ProcessS8            ; two byte start address
3015
 00FFEE7F 0C1039                          cmpb    #'9'
3016
 00FFEE81 027F94                          beq             s19ProcessS9            ; three byte start address
3017
                              s19lnr:
3018
 00FFEE83 0C602E                          ldb             #'.'                                            ; output a progress indicator
3019
 00FFEE85 03F                             swi
3020
 00FFEE86 002                             fcb             MF_OUTCH
3021
 00FFEE87 08DECF                          bsr             s19NextRecord           ; skip to the next record
3022
 00FFEE89 07D00094A                       tst             S19Abort                                ; check for abort
3023
 00FFEE8C 026002                          bne             s19l2
3024
 00FFEE8E 020FAF                          bra             s19l3                                           ; loop back to process more records
3025
                              s19l2:
3026
 00FFEE90 0160001A6                       lbra    Monitor
3027
 
3028
                              msgS19Loader:
3029
 00FFEE93 05303103902004C06F061           fcb     "S19 Loader Active",CR,LF,0
3030
 00FFEE9A 064065072020041063074
3031
 00FFEEA1 06907606500D00A000
3032
 
3033
 
3034
 
3035 13 robfinch
                              ;------------------------------------------------------------------------------
3036 4 robfinch
                              ; Check if there is a keyboard character available. If so return true (<0)
3037
                              ; otherwise return false (0) in accb.
3038
                              ;------------------------------------------------------------------------------
3039
                              ;
3040
                              KeybdCheckForKeyDirect:
3041 16 robfinch
 00FFEEA7 020BE7                          bra             DBGCheckForKey
3042 4 robfinch
 
3043
                              ;------------------------------------------------------------------------------
3044
                              ;------------------------------------------------------------------------------
3045
                              INCH:
3046 16 robfinch
 00FFEEA9 034004                          pshs    b
3047 13 robfinch
                              INCH2:
3048 16 robfinch
 00FFEEAB 0150F6FFFFFFFE0                 ldb             COREID
3049
 00FFEEB0 0F1FFC010                       cmpb    IOFocusID       ; if we do not have focus, block
3050
 00FFEEB3 026FF6                          bne             INCH2
3051 13 robfinch
                              ;       ldb             #$800                   ; block if no key available, get scancode directly
3052
                              ;       bra             GetKey
3053
                              ;       jsr             [CharInVec]     ; vector is being overwritten somehow
3054 16 robfinch
 00FFEEB5 017FFFDAC                       lbsr    SerialPeekCharDirect
3055 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3056 16 robfinch
 00FFEEB8 04D                             tsta
3057
 00FFEEB9 02B003                          bmi             INCH1                   ; block if no key available
3058
 00FFEEBB 032601                          leas    1,s                             ; get rid of blocking status
3059
 00FFEEBD 039                             rts
3060 13 robfinch
                              INCH1:
3061 16 robfinch
 00FFEEBE 035004                          puls    b                                       ; check blocking status
3062
 00FFEEC0 05D                             tstb
3063
 00FFEEC1 02BFE6                          bmi     INCH                    ; if blocking, loop
3064
 00FFEEC3 0CCFFFFFF                       ldd             #-1                             ; return -1 if no char available
3065
 00FFEEC6 039                             rts
3066 4 robfinch
 
3067
                              INCHE:
3068 16 robfinch
 00FFEEC7 08DFE0                          bsr             INCH
3069
 00FFEEC9 020009                          bra             INCHEK3
3070 4 robfinch
 
3071
                              INCHEK:
3072 16 robfinch
 00FFEECB 08DFDC                          bsr             INCH
3073
 00FFEECD 01507DFFFFFCA00                 tst             KeybdEcho
3074
 00FFEED2 02700C                          beq             INCHEK1
3075 4 robfinch
                              INCHEK3:
3076 16 robfinch
 00FFEED4 08100D                          cmpa    #CR
3077
 00FFEED6 026005                          bne             INCHEK2
3078
 00FFEED8 017FFE1F7                       lbsr            CRLF
3079 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
3080 16 robfinch
 00FFEEDB 020003                          bra             INCHEK1
3081 4 robfinch
                              INCHEK2:
3082 16 robfinch
 00FFEEDD 017FFF439                       lbsr    DisplayChar
3083 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3084 4 robfinch
                              INCHEK1:
3085 16 robfinch
 00FFEEE0 039                             rts
3086 4 robfinch
 
3087
                              OUTCH:
3088 16 robfinch
 00FFEEE1 06E90F000800                    jmp             [CharOutVec]
3089 4 robfinch
 
3090
                              ;------------------------------------------------------------------------------
3091
                              ; r1 0=echo off, non-zero = echo on
3092
                              ;------------------------------------------------------------------------------
3093
                              ;
3094
                              SetKeyboardEcho:
3095 16 robfinch
 00FFEEE5 0150F7FFFFFCA00                 stb             KeybdEcho
3096
 00FFEEEA 039                             rts
3097 4 robfinch
 
3098
 
3099
                              ;------------------------------------------------------------------------------
3100
                              ; Parameters:
3101
                              ;               x,d     bitmap of sprites to enable
3102
                              ;------------------------------------------------------------------------------
3103
 
3104
                              ShowSprites:
3105 16 robfinch
 00FFEEEB 0150BFFFFE103C0                 stx             SPRITE_CTRL+SPRITE_EN
3106
 00FFEEF0 0150FDFFFE103C2                 std             SPRITE_CTRL+SPRITE_EN+2
3107
 00FFEEF5 039                             rts
3108 4 robfinch
 
3109
                              ;==============================================================================
3110 13 robfinch
                              ; Femtiki Operating System.
3111
                              ;==============================================================================
3112
 
3113
                              OSCallTbl:
3114 16 robfinch
 00FFEEF6 000000                          fcw             0
3115
 00FFEEF8 000000                          fcw             0
3116
 00FFEEFA 000000                          fcw             0
3117
 00FFEEFC 000000                          fcw             0
3118
 00FFEEFE 000000                          fcw             0
3119
 00FFEF00 000000                          fcw             0
3120
 00FFEF02 000000                          fcw             0
3121
 00FFEF04 000000                          fcw             0
3122
 00FFEF06 000000                          fcw             0
3123
 00FFEF08 000000                          fcw             0
3124
 00FFEF0A 000000                          fcw             0
3125
 00FFEF0C 000000                          fcw             0
3126
 00FFEF0E 000000                          fcw             0
3127
 00FFEF10 000000                          fcw             0
3128
 00FFEF12 000000                          fcw             0
3129
 00FFEF14 000000                          fcw             0
3130
 00FFEF16 000000                          fcw             0
3131
 00FFEF18 000000                          fcw             0
3132
 00FFEF1A 000000                          fcw             0
3133
 00FFEF1C 000000                          fcw             0
3134
 00FFEF1E 000000                          fcw             0
3135
 00FFEF20 000000                          fcw             0
3136
 00FFEF22 FFEF3F                          fcw             ReleaseIOFocus
3137
 00FFEF24 000000                          fcw             0
3138
 00FFEF26 FFEF28                          fcw             RequestIOFocus
3139 13 robfinch
 
3140 15 robfinch
                              NumOSFuncs      EQU     (*-OSCallTbl)/2
3141 13 robfinch
 
3142
                              RequestIOFocus:
3143 16 robfinch
 00FFEF28 0150F6FFFFFFFE0                 ldb             COREID
3144
 00FFEF2D 08EFFC000                       ldx             #IOFocusList
3145
 00FFEF30 03A                             abx
3146
 00FFEF31 0A7804                          sta             ,x
3147
 00FFEF33 07DFFC010                       tst             IOFocusID
3148
 00FFEF36 1260007D1                       lbne    oscx
3149
 00FFEF39 0F7FFC010                       stb             IOFocusID
3150
 00FFEF3C 0160007CB                       lbra    oscx
3151 13 robfinch
 
3152
                              ReleaseIOFocus:
3153 16 robfinch
 00FFEF3F 0150F6FFFFFFFE0                 ldb             COREID
3154
 00FFEF44 08EFFC000                       ldx             #IOFocusList
3155
 00FFEF47 03A                             abx
3156
 00FFEF48 06F804                          clr             ,x                                              ; clear the request indicator
3157
 00FFEF4A 017FFF2BC                       lbsr    CopyScreenToVirtualScreen
3158 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3159 16 robfinch
 00FFEF4D 0F1FFC010                       cmpb    IOFocusID                       ; are we the one with the focus?
3160
 00FFEF50 1260007B7                       lbne    oscx
3161 13 robfinch
                                      ; We had the focus, so now a new core needs the focus.
3162
                                      ; Search the focus list for a requestor. If no requester
3163
                                      ; is found, give focus to core #1.
3164 16 robfinch
 00FFEF53 08600F                          lda             #15
3165 13 robfinch
                              riof2:
3166 16 robfinch
 00FFEF55 05C                             incb
3167
 00FFEF56 0C400F                          andb    #15
3168
 00FFEF58 03A                             abx
3169
 00FFEF59 06D804                          tst             ,x
3170
 00FFEF5B 026009                          bne             riof1
3171
 00FFEF5D 04A                             deca
3172
 00FFEF5E 026FF5                          bne             riof2
3173 13 robfinch
                                      ; If no focus is requested by anyone, give to core #1
3174 16 robfinch
 00FFEF60 0C6001                          ldb             #1
3175
 00FFEF62 086018                          lda             #24
3176
 00FFEF64 0A7804                          sta             ,x
3177 13 robfinch
                              riof1:
3178 16 robfinch
 00FFEF66 0F7FFC010                       stb             IOFocusID
3179
 00FFEF69 017FFF266                       lbsr    CopyVirtualScreenToScreen
3180 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3181 16 robfinch
 00FFEF6C 01600079B                       lbra    oscx
3182 13 robfinch
 
3183
 
3184
                              ;==============================================================================
3185
                              ;==============================================================================
3186
 
3187 15 robfinch
                              ;------------------------------------------------------------------------------
3188
                              ; Seed the random number generator. All channels are seeded with the same
3189
                              ; value.
3190 13 robfinch
                              ;
3191 15 robfinch
                              ; Parameters:
3192
                              ;               d = 'z' part of seed
3193
                              ;               x = 'w' part of seed
3194
                              ; Returns:
3195
                              ;               none
3196
                              ;------------------------------------------------------------------------------
3197 13 robfinch
 
3198 15 robfinch
                              mon_srand:
3199 16 robfinch
 00FFEF6F 18E000000                       ldy     #0
3200 15 robfinch
                              mon_srand1:
3201 16 robfinch
 00FFEF72 0151BFFFFE30604                 sty     PRNG+4                          ; select channel
3202
 00FFEF77 01507FFFFE30608                 clr     PRNG+8
3203
 00FFEF7C 01507FFFFE30609                 clr PRNG+9
3204
 00FFEF81 0150FDFFFE3060A                 std     PRNG+10                         ; update low half of value
3205
 00FFEF86 01507FFFFE3060C                 clr PRNG+12
3206
 00FFEF8B 01507FFFFE3060D                 clr PRNG+13
3207
 00FFEF90 0150BFFFFE3060E                 stx     PRNG+14                         ; update low half of value
3208
 00FFEF95 031201                          iny
3209
 00FFEF97 18C000400                       cmpy    #$400                           ; 1k channels
3210
 00FFEF9A 025FD6                          blo             mon_srand1
3211
 00FFEF9C 039                             rts
3212 13 robfinch
 
3213 15 robfinch
                              ;------------------------------------------------------------------------------
3214
                              ; Get a random number and generate the next one.
3215
                              ;
3216
                              ; Parameters:
3217
                              ;               d = channel to use
3218
                              ; Returns:
3219
                              ;               x,d = 36 bit random value
3220
                              ;------------------------------------------------------------------------------
3221 13 robfinch
 
3222 15 robfinch
                              mon_rand:
3223 16 robfinch
 00FFEF9D 0150FDFFFE30604                 std     PRNG+4                          ; select channel
3224
 00FFEFA2 0150BEFFFE30600                 ldx     PRNG+0
3225
 00FFEFA7 0150FCFFFE30602                 ldd     PRNG+2
3226
 00FFEFAC 0150F7FFFE30603                 stb     PRNG+3                          ; trigger calc of next number
3227
 00FFEFB1 039                             rts
3228 13 robfinch
 
3229 15 robfinch
                              ;==============================================================================
3230
                              ; System Monitor
3231
                              ;==============================================================================
3232 13 robfinch
 
3233 16 robfinch
                              ; Command Tables
3234 13 robfinch
 
3235 15 robfinch
                              cmdTable1:
3236 16 robfinch
 00FFEFB2 03C83E                          fcb             '<','>'+$800
3237
 00FFEFB4 062873                          fcb             'b','s'+$800
3238
 00FFEFB6 062863                          fcb             'b','c'+$800
3239
 00FFEFB8 044852                          fcb             'D','R'+$800
3240
 00FFEFBA 844                             fcb             'D'+$800
3241
 00FFEFBB 83A                             fcb             ':'+$800
3242
 00FFEFBC 046049847                       fcb             "FI",'G'+$800
3243
 00FFEFBF 04604984C                       fcb             "FI",'L'+$800
3244
 00FFEFC2 04684C                          fcb             'F','L'+$800
3245
 00FFEFC4 84A                             fcb             'J'+$800
3246
 00FFEFC5 05204104D054045053854           fcb             "RAMTES",'T'+$800
3247
 00FFEFCC 053050844                       fcb             "SP",'D'+$800
3248
 00FFEFCF 054049852                       fcb             "TI",'R'+$800
3249
 00FFEFD2 855                             fcb             'U'+$800
3250
 00FFEFD3 065078069874                    fcb             "exi",'t'+$800
3251
 00FFEFD7 83F                             fcb             '?'+$800
3252
 00FFEFD8 04304C853                       fcb             "CL",'S'+$800
3253
 00FFEFDB 053031839                       fcb             "S1",'9'+$800
3254
 00FFEFDE 04A044834                       fcb             "JD",'4'+$800
3255
 00FFEFE1 000000                          fcw             0
3256 13 robfinch
 
3257 15 robfinch
                              cmdTable2:
3258 16 robfinch
 00FFEFE3 FFF0F8                          fcw             Redirect
3259
 00FFEFE5 FFF13A                          fcw             MonArmBreakpoint
3260
 00FFEFE7 FFF145                          fcw             MonDisarmBreakpoint
3261
 00FFEFE9 FFF54A                          fcw             DumpRegs
3262
 00FFEFEB FFF484                          fcw             DumpMemory
3263
 00FFEFED FFF4E0                          fcw             EditMemory
3264
 00FFEFEF FE0000                          fcw             $FE0000                                 ; FIG forth
3265
 00FFEFF1 FFF520                          fcw             FillMemory
3266
 00FFEFF3 FFF60B                          fcw             DumpIOFocusList
3267
 00FFEFF5 FFF595                          fcw             jump_to_code
3268
 00FFEFF7 FFD400                          fcw             $FFD400
3269
 00FFEFF9 FF8000                          fcw             $FF8000                                 ; sprite demo
3270
 00FFEFFB FFE4F4                          fcw             rtc_read
3271
 00FFEFFD FF8003                          fcw             $FF8003                                 ; unassembler
3272
 00FFEFFF FFF6F3                          fcw             xitMonitor
3273
 00FFF001 FFF11E                          fcw             PromptHelp
3274
 00FFF003 FFF126                          fcw             PromptClearscreen
3275
 00FFF005 FFEE37                          fcw             S19Loader
3276
 00FFF007 FFD400                          fcw             $FFD400
3277 13 robfinch
 
3278
                              CmdPrompt:
3279 16 robfinch
 00FFF009 017FFE0C6                       lbsr    CRLF
3280 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3281 16 robfinch
 00FFF00C 0C6024                          ldb             #'$'
3282
 00FFF00E 017FFFED0                       lbsr    OUTCH
3283 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3284 16 robfinch
 00FFF011 016FFFECD                       lbra    OUTCH
3285 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3286
 
3287
                              msgF09Starting:
3288 16 robfinch
 00FFF014 04606506D07406906B069           fcb             "Femtiki F09 Multi-core OS Starting",CR,LF,0
3289
 00FFF01B 02004603003902004D075
3290
 00FFF022 06C07406902D06306F072
3291
 00FFF029 06502004F053020053074
3292
 00FFF030 06107207406906E06700D
3293
 00FFF037 00A000
3294 13 robfinch
 
3295 16 robfinch
                              Monitor:
3296
 00FFF039 0FC00092C                       ldd             mon_init                        ; check special code to see if monitor has been initialized
3297
 00FFF03C 18312D687                       cmpd    #1234567
3298
 00FFF03F 02704D                          beq             mon1
3299
 00FFF041 07F000810                       clr             BreakpointFlag
3300
 00FFF044 07F000811                       clr             NumSetBreakpoints
3301
 00FFF047 0CC00007B                       ldd             #123
3302
 00FFF04A 08E00028E                       ldx             #654
3303
 00FFF04D 017FFFF1F                       lbsr    mon_srand
3304 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3305 16 robfinch
 00FFF050 0CCFFF014                       ldd             #msgF09Starting
3306
 00FFF053 017FFF384                       lbsr    DisplayString
3307 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3308 16 robfinch
 00FFF056 0CCFFF2CF                       ldd             #HelpMsg
3309
 00FFF059 017FFF37E                       lbsr    DisplayString
3310 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3311 16 robfinch
 00FFF05C 0CCFFF009                       ldd             #CmdPrompt
3312
 00FFF05F 0FD000808                       std             CmdPromptJI
3313
 00FFF062 0CCFFF2B6                       ldd             #DisplayErr
3314
 00FFF065 0FD00080C                       std             MonErrVec
3315
 00FFF068 0CC0063FF                       ldd             #$63FF                  ; default app stack
3316
 00FFF06B 0FD000908                       std             mon_SSAVE
3317
 00FFF06E 07F00090E                       clr             mon_DPRSAVE     ;
3318
 00FFF071 01F0A8                          tfr             ccr,a
3319
 00FFF073 0B700090F                       sta             mon_CCRSAVE
3320
 00FFF076 07F00090A                       clr             mon_PCSAVE
3321
 00FFF079 0CCFFF039                       ldd             #Monitor
3322
 00FFF07C 0FD00090B                       std             mon_PCSAVE+1
3323
 00FFF07F 07F000902                       clr             mon_XSAVE
3324
 00FFF082 07F000904                       clr             mon_YSAVE
3325
 00FFF085 07F000906                       clr             mon_USAVE
3326
 00FFF088 0CC12D687                       ldd             #1234567
3327
 00FFF08B 0FD00092C                       std             mon_init
3328
                              mon1:
3329
 00FFF08E 03280F006FFF                    leas    $6FFF                           ; reset stack pointer
3330
 00FFF092 05F                             clrb                                                    ; turn off keyboard echo
3331
 00FFF093 017FFFE4F                       lbsr    SetKeyboardEcho
3332 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3333
                                      ; Reset IO vectors
3334 16 robfinch
 00FFF096 0CCFFEC64                       ldd             #SerialPeekCharDirect
3335
 00FFF099 0FD000804                       std             CharInVec
3336
 00FFF09C 0CCFFE319                       ldd             #DisplayChar
3337
 00FFF09F 0FD000800                       std             CharOutVec
3338
 00FFF0A2 0CCFFF009                       ldd             #CmdPrompt
3339
 00FFF0A5 0FD000808                       std             CmdPromptJI
3340 4 robfinch
                              ;       jsr             RequestIOFocus
3341
                              PromptLn:
3342 16 robfinch
 00FFF0A8 0AD90F000808                    jsr             [CmdPromptJI]
3343 4 robfinch
 
3344
                              ; Get characters until a CR is keyed
3345
 
3346
                              Prompt3:
3347 16 robfinch
 00FFF0AC 0CCFFFFFF                       ldd             #-1                                     ; block until key present
3348
 00FFF0AF 017FFFDF7                       lbsr    INCH
3349 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3350 16 robfinch
 00FFF0B2 0C100D                          cmpb    #CR                                     ; carriage return?
3351
 00FFF0B4 027005                          beq             Prompt1
3352
 00FFF0B6 017FFFE28                       lbsr    OUTCH                           ; spit out the character
3353 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3354 16 robfinch
 00FFF0B9 020FF1                          bra             Prompt3                 ; and keep going
3355 4 robfinch
 
3356
                              ; Process the screen line that the CR was keyed on
3357
                              ;
3358
                              Prompt1:
3359 16 robfinch
 00FFF0BB 0CC005050                       ldd             #$5050
3360
 00FFF0BE 0150FDFFFE60001                 std             LEDS
3361 13 robfinch
                              ;       ldb             RunningID
3362
                              ;       cmpb    #61
3363
                              ;       bhi             Prompt3
3364 16 robfinch
 00FFF0C3 00F111                          clr             CursorCol                       ; go back to the start of the line
3365
 00FFF0C5 017FFF22A                       lbsr    CalcScreenLoc   ; calc screen memory location
3366 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3367 16 robfinch
 00FFF0C8 01F002                          tfr             d,y
3368 13 robfinch
                              skipDollar:
3369 16 robfinch
 00FFF0CA 08D067                          bsr             MonGetNonSpace
3370
 00FFF0CC 0C1024                          cmpb    #'$'
3371
 00FFF0CE 027FFA                          beq             skipDollar              ; skip over '$' prompt character
3372 4 robfinch
 
3373 15 robfinch
                              ; Dispatch based on command
3374 4 robfinch
                              ;
3375 16 robfinch
 00FFF0D0 0313FF                          dey
3376
 00FFF0D2 01F023                          tfr             y,u                                                     ; save off input position
3377
 00FFF0D4 05F                             clrb
3378
 00FFF0D5 08EFFEFB2                       ldx             #cmdTable1
3379 15 robfinch
                              parseCmd1:
3380 16 robfinch
 00FFF0D8 0A6A00                          lda             ,y+                                                     ; get input character
3381
 00FFF0DA 06D804                          tst             ,x                                                      ; test for end of command
3382
 00FFF0DC 02B00F                          bmi             endOfWord                               ;
3383
 00FFF0DE 0A1800                          cmpa    ,x+                                                     ; does input match command?
3384
 00FFF0E0 027FF6                          beq             parseCmd1
3385 15 robfinch
                              scanNextWord:
3386 16 robfinch
 00FFF0E2 06D800                          tst             ,x+
3387
 00FFF0E4 027F53                          beq             Monitor                                 ; if end of table reached, not a command
3388
 00FFF0E6 02AFFA                          bpl             scanNextWord
3389
 00FFF0E8 05C                             incb
3390
 00FFF0E9 01F032                          tfr             u,y                                                     ; reset input pointer
3391
 00FFF0EB 020FEB                          bra             parseCmd1                               ; try again
3392 15 robfinch
                              endOfWord:
3393 16 robfinch
 00FFF0ED 0A8804                          eora    ,x
3394
 00FFF0EF 048                             asla
3395
 00FFF0F0 026FF0                          bne             scanNextWord
3396 15 robfinch
                                      ; we found the command in the table
3397 16 robfinch
 00FFF0F2 058                             aslb                                                                    ; b = word index
3398
 00FFF0F3 08EFFEFE3                       ldx             #cmdTable2
3399
 00FFF0F6 06E905                          jmp             [b,x]                                           ; execute command
3400 15 robfinch
 
3401
                              Redirect:
3402 16 robfinch
 00FFF0F8 08D034                          bsr             MonGetch
3403
 00FFF0FA 0C1073                          cmpb    #'s'
3404
 00FFF0FC 02600E                          bne             Prompt2a
3405
 00FFF0FE 0CCFFEC64                       ldd             #SerialPeekCharDirect
3406
 00FFF101 0FD000804                       std             CharInVec
3407
 00FFF104 0CCFFEC88                       ldd             #SerialPutChar
3408
 00FFF107 0FD000800                       std             CharOutVec
3409
 00FFF10A 020F2D                          bra             Monitor
3410 13 robfinch
                              Prompt2a:
3411 16 robfinch
 00FFF10C 0C1063                          cmpb    #'c'
3412
 00FFF10E 026F29                          bne             Monitor
3413
 00FFF110 0CCFFEA92                       ldd             #GetKey
3414
 00FFF113 0FD000804                       std             CharInVec
3415
 00FFF116 0CCFFE319                       ldd             #DisplayChar
3416
 00FFF119 0FD000800                       std             CharOutVec
3417
 00FFF11C 020F1B                          bra             Monitor
3418 15 robfinch
 
3419 13 robfinch
                              PromptHelp:
3420 16 robfinch
 00FFF11E 0CCFFF2CF                       ldd             #HelpMsg
3421
 00FFF121 017FFF2B6                       lbsr    DisplayString
3422 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3423 16 robfinch
 00FFF124 020F13                          bra             Monitor
3424 15 robfinch
 
3425
                              PromptClearscreen:
3426 16 robfinch
 00FFF126 017FFF110                       lbsr    ClearScreen
3427 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
3428 16 robfinch
 00FFF129 017FFF184                       lbsr    HomeCursor
3429 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3430 16 robfinch
 00FFF12C 020F0B                          bra             Monitor
3431 4 robfinch
 
3432
                              MonGetch:
3433 16 robfinch
 00FFF12E 0E6A04                          ldb             ,y
3434
 00FFF130 031201                          iny
3435
 00FFF132 039                             rts
3436 4 robfinch
 
3437
                              MonGetNonSpace:
3438 16 robfinch
 00FFF133 08DFF9                          bsr             MonGetCh
3439
 00FFF135 0C1020                          cmpb    #' '
3440
 00FFF137 027FFA                          beq             MonGetNonSpace
3441
 00FFF139 039                             rts
3442 4 robfinch
 
3443 16 robfinch
                              MonArmBreakpoint:
3444
 00FFF13A 017000611                       lbsr    ArmBreakpoint
3445
 00FFF13D 0C6FFF                          ldb             #$FFF
3446
 00FFF13F 0F7000810                       stb             BreakpointFlag
3447
 00FFF142 016FFFEF4                       lbra    Monitor
3448
*** warning 1: Long branch within short branch range could be optimized
3449
                              MonDisarmBreakpoint:
3450
 00FFF145 017000632                       lbsr    DisarmBreakpoint
3451
 00FFF148 016FFFEEE                       lbra    Monitor
3452
*** warning 1: Long branch within short branch range could be optimized
3453
 
3454 4 robfinch
                              ;------------------------------------------------------------------------------
3455
                              ; Ignore blanks in the input
3456
                              ; Y = text pointer
3457
                              ; D destroyed
3458
                              ;------------------------------------------------------------------------------
3459
                              ;
3460
                              ignBlanks:
3461
                              ignBlanks1:
3462 16 robfinch
 00FFF14B 08DFE1                          bsr             MonGetch
3463
 00FFF14D 0C1020                          cmpb    #' '
3464
 00FFF14F 027FFA                          beq             ignBlanks1
3465
 00FFF151 0313FF                          dey
3466
 00FFF153 039                             rts
3467 4 robfinch
 
3468
                              ;------------------------------------------------------------------------------
3469 15 robfinch
                              ; Multiply number in work area by 10.
3470 4 robfinch
                              ;------------------------------------------------------------------------------
3471 15 robfinch
                              Times10:
3472 16 robfinch
 00FFF154 034006                          pshs    d
3473
 00FFF156 0FC000910                       ldd             mon_numwka              ; make a copy of the number
3474
 00FFF159 0FD000918                       std             mon_numwka+8
3475
 00FFF15C 0FC000912                       ldd             mon_numwka+2
3476
 00FFF15F 0FD00091A                       std             mon_numwka+10
3477
 00FFF162 08D05B                          bsr             shl_numwka              ; shift left = *2
3478
 00FFF164 08D059                          bsr             shl_numwka              ; shift left = *4
3479
 00FFF166 0FC000912                       ldd             mon_numwka+2    ; add in original value
3480
 00FFF169 0F300091A                       addd    mon_numwka+10   ; = *5
3481
 00FFF16C 0F6000911                       ldb             mon_numwka+1
3482
 00FFF16F 0F9000919                       adcb    mon_numwka+9
3483
 00FFF172 0F7000911                       stb             mon_numwka+1
3484
 00FFF175 0B6000910                       lda             mon_numwka+0
3485
 00FFF178 0B9000918                       adca    mon_numwka+8
3486
 00FFF17B 0B7000910                       sta             mon_numwka+0
3487
 00FFF17E 08D03F                          bsr             shl_numwka              ; shift left = * 10
3488
 00FFF180 035086                          puls    d,pc
3489 15 robfinch
 
3490
                              ;------------------------------------------------------------------------------
3491
                              ;------------------------------------------------------------------------------
3492 4 robfinch
                              GetTwoParams:
3493 16 robfinch
 00FFF182 08DFC7                          bsr             ignBlanks
3494
 00FFF184 08D0DC                          bsr             GetNumber                       ; get start address of dump
3495
 00FFF186 0FC000910                       ldd             mon_numwka
3496
 00FFF189 0FD000920                       std             mon_r1
3497
 00FFF18C 0FC000912                       ldd             mon_numwka+2
3498
 00FFF18F 0FD000922                       std             mon_r1+2
3499
 00FFF192 08DFB7                          bsr             ignBlanks
3500
 00FFF194 08D0CC                          bsr             GetNumber                       ; get end address of dump
3501
 00FFF196 0FC000910                       ldd             mon_numwka
3502
 00FFF199 0FD000924                       std             mon_r2
3503
 00FFF19C 0FC000912                       ldd             mon_numwka+2
3504
 00FFF19F 0FD000926                       std             mon_r2+2
3505
 00FFF1A2 039                             rts
3506 4 robfinch
 
3507
                              ;------------------------------------------------------------------------------
3508
                              ; Get a range, the end must be greater or equal to the start.
3509
                              ;------------------------------------------------------------------------------
3510
                              GetRange:
3511 16 robfinch
 00FFF1A3 08DFDD                          bsr             GetTwoParams
3512
 00FFF1A5 0FC000926                       ldd             mon_r2+2
3513
 00FFF1A8 0B3000922                       subd    mon_r1+2
3514
 00FFF1AB 0FC000924                       ldd             mon_r2
3515
 00FFF1AE 0F2000921                       sbcb    mon_r1+1
3516
 00FFF1B1 0B2000920                       sbca    mon_r1
3517
 00FFF1B4 124000007                       lbcc    grng1
3518
 00FFF1B7 0AD90F00080C                    jsr             [MonErrVec]
3519
 00FFF1BB 016FFFE7B                       lbra    Monitor
3520 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3521
                              grng1:
3522 16 robfinch
 00FFF1BE 039                             rts
3523 4 robfinch
 
3524
                              shl_numwka:
3525 16 robfinch
 00FFF1BF 078000913                       asl             mon_numwka+3
3526
 00FFF1C2 079000912                       rol             mon_numwka+2
3527
 00FFF1C5 079000911                       rol             mon_numwka+1
3528
 00FFF1C8 079000910                       rol             mon_numwka
3529
 00FFF1CB 039                             rts
3530 4 robfinch
 
3531
                              ;------------------------------------------------------------------------------
3532 13 robfinch
                              ; Get a hexidecimal number. Maximum of twelve digits.
3533
                              ;
3534
                              ; Modifies:
3535
                              ;       Y = text pointer (updated)
3536
                              ;       D = number of digits
3537
                              ;       mon_numwka contains number
3538 4 robfinch
                              ;------------------------------------------------------------------------------
3539
                              ;
3540
                              GetHexNumber:
3541 16 robfinch
 00FFF1CC 04F05F                          clrd
3542
 00FFF1CE 0FD000910                       std             mon_numwka      ; zero out work area
3543
 00FFF1D1 0FD000912                       std             mon_numwka+2
3544
 00FFF1D4 034010                          pshs    x
3545
 00FFF1D6 08E000000                       ldx             #0                                      ; max 12 eight digits
3546 4 robfinch
                              gthxn2:
3547 16 robfinch
 00FFF1D9 08DF53                          bsr             MonGetch
3548
 00FFF1DB 08D093                          bsr             AsciiToHexNybble
3549
 00FFF1DD 0C1FFF                          cmpb    #-1
3550
 00FFF1DF 027017                          beq             gthxn1
3551
 00FFF1E1 08DFDC                          bsr             shl_numwka
3552
 00FFF1E3 08DFDA                          bsr             shl_numwka
3553
 00FFF1E5 08DFD8                          bsr             shl_numwka
3554
 00FFF1E7 08DFD6                          bsr             shl_numwka
3555
 00FFF1E9 0C400F                          andb    #$0f
3556
 00FFF1EB 0FA000913                       orb             mon_numwka+3
3557
 00FFF1EE 0F7000913                       stb             mon_numwka+3
3558
 00FFF1F1 030001                          inx
3559
 00FFF1F3 08C00000C                       cmpx    #12
3560
 00FFF1F6 025FE1                          blo             gthxn2
3561 4 robfinch
                              gthxn1:
3562 16 robfinch
 00FFF1F8 01F010                          tfr             x,d
3563
 00FFF1FA 035090                          puls    x,pc
3564 4 robfinch
 
3565 16 robfinch
                              GetBinNumber:
3566
 00FFF1FC 04F05F                          clrd
3567
 00FFF1FE 0FD000910                       std             mon_numwka
3568
 00FFF201 0FD000912                       std             mon_numwka+2
3569
 00FFF204 034010                          pshs    x
3570
 00FFF206 08E000000                       ldx             #0
3571
                              gtbin2:
3572
 00FFF209 08DF23                          bsr             MonGetch
3573
 00FFF20B 08D099                          bsr             AsciiToBinDigit
3574
 00FFF20D 05D                             tstb
3575
 00FFF20E 02B00F                          bmi             gtbin1
3576
 00FFF210 08DFAD                          bsr             shl_numwka
3577
 00FFF212 0FA000913                       orb             mon_numwka+3
3578
 00FFF215 0F7000913                       stb             mon_numwka+3
3579
 00FFF218 030001                          inx
3580
 00FFF21A 08C000030                       cpx             #48
3581
 00FFF21D 025FEA                          blo             gtbin2
3582
                              gtbin1:
3583
 00FFF21F 01F010                          tfr             x,d
3584
 00FFF221 035090                          puls    x,pc
3585
 
3586
                              GetDecNumber:
3587
 00FFF223 04F05F                          clrd
3588
 00FFF225 0FD000910                       std             mon_numwka
3589
 00FFF228 0FD000912                       std             mon_numwka+2
3590
 00FFF22B 034010                          pshs    x
3591
 00FFF22D 08E000000                       ldx             #0
3592
                              gtdec2:
3593
 00FFF230 08DEFC                          bsr             MonGetch
3594
 00FFF232 08D064                          bsr             AsciiToDecDigit
3595
 00FFF234 05D                             tstb
3596
 00FFF235 02B027                          bmi             gtdec1
3597
 00FFF237 08DF1B                          bsr             Times10
3598
 00FFF239 0FB000913                       addb    mon_numwka+3
3599
 00FFF23C 0F7000913                       stb             mon_numwka+3
3600
 00FFF23F 0F6000912                       ldb             mon_numwka+2
3601
 00FFF242 0C9000                          adcb    #0
3602
 00FFF244 0F7000912                       stb             mon_numwka+2
3603
 00FFF247 0F6000911                       ldb             mon_numwka+1
3604
 00FFF24A 0C9000                          adcb    #0
3605
 00FFF24C 0F7000911                       stb             mon_numwka+1
3606
 00FFF24F 0F6000910                       ldb             mon_numwka+0
3607
 00FFF252 0C9000                          adcb    #0
3608
 00FFF254 0F7000910                       stb             mon_numwka+0
3609
 00FFF257 030001                          inx
3610
 00FFF259 08C00000F                       cpx             #15
3611
 00FFF25C 025FD2                          blo             gtdec2
3612
                              gtdec1:
3613
 00FFF25E 01F010                          tfr             x,d
3614
 00FFF260 035090                          puls    x,pc
3615
 
3616
                              GetNumber:
3617
 00FFF262 08DECA                          bsr             MonGetch
3618
 00FFF264 0C102B                          cmpb    #'+'
3619
 00FFF266 027FBB                          beq             GetDecNumber
3620
 00FFF268 0C1025                          cmpb    #'%'
3621
 00FFF26A 027F90                          beq             GetBinNumber
3622
 00FFF26C 0313FF                          dey
3623
 00FFF26E 020F5C                          bra             GetHexNumber
3624
 
3625 4 robfinch
                              ;       phx
3626
                              ;       push    r4
3627
                              ;       push    r5
3628
                              ;       ldx             #0
3629
                              ;       ld              r4,#10
3630
                              ;       ld              r5,#10
3631
                              ;gtdcn2:
3632
                              ;       jsr             MonGetch
3633
                              ;       jsr             AsciiToDecNybble
3634
                              ;       cmp             #-1
3635
                              ;       beq             gtdcn1
3636
                              ;       mul             r2,r2,r5
3637
                              ;       add             r2,r1
3638
                              ;       dec             r4
3639
                              ;       bne             gtdcn2
3640
                              ;gtdcn1:
3641
                              ;       txa
3642
                              ;       pop             r5
3643
                              ;       pop             r4
3644
                              ;       plx
3645
                              ;       rts
3646
 
3647
                              ;------------------------------------------------------------------------------
3648
                              ; Convert ASCII character in the range '0' to '9', 'a' to 'f' or 'A' to 'F'
3649
                              ; to a hex nybble.
3650
                              ;------------------------------------------------------------------------------
3651
                              ;
3652
                              AsciiToHexNybble:
3653 16 robfinch
 00FFF270 0C1030                          cmpb    #'0'
3654
 00FFF272 025021                          blo             gthx3
3655
 00FFF274 0C1039                          cmpb    #'9'
3656
 00FFF276 022003                          bhi             gthx5
3657
 00FFF278 0C0030                          subb    #'0'
3658
 00FFF27A 039                             rts
3659 4 robfinch
                              gthx5:
3660 16 robfinch
 00FFF27B 0C1041                          cmpb    #'A'
3661
 00FFF27D 025016                          blo             gthx3
3662
 00FFF27F 0C1046                          cmpb    #'F'
3663
 00FFF281 022005                          bhi             gthx6
3664
 00FFF283 0C0041                          subb    #'A'
3665
 00FFF285 0CB00A                          addb    #10
3666
 00FFF287 039                             rts
3667 4 robfinch
                              gthx6:
3668 16 robfinch
 00FFF288 0C1061                          cmpb    #'a'
3669
 00FFF28A 025009                          blo             gthx3
3670
 00FFF28C 0C107A                          cmpb    #'z'
3671
 00FFF28E 022005                          bhi             gthx3
3672
 00FFF290 0C0061                          subb    #'a'
3673
 00FFF292 0CB00A                          addb    #10
3674
 00FFF294 039                             rts
3675 4 robfinch
                              gthx3:
3676 16 robfinch
 00FFF295 0C6FFF                          ldb             #-1             ; not a hex number
3677
 00FFF297 039                             rts
3678 4 robfinch
 
3679 16 robfinch
                              AsciiToDecDigit:
3680
 00FFF298 0C1030                          cmpb    #'0'
3681
 00FFF29A 025007                          blo             gtdc3
3682
 00FFF29C 0C1039                          cmpb    #'9'
3683
 00FFF29E 022003                          bhi             gtdc3
3684
 00FFF2A0 0C0030                          subb    #'0'
3685
 00FFF2A2 039                             rts
3686 4 robfinch
                              gtdc3:
3687 16 robfinch
 00FFF2A3 0C6FFF                          ldb             #-1
3688
 00FFF2A5 039                             rts
3689 4 robfinch
 
3690 16 robfinch
                              AsciiToBinDigit:
3691
 00FFF2A6 0C1030                          cmpb    #'0'
3692
 00FFF2A8 026002                          bne             abd1
3693
 00FFF2AA 05F                             clrb
3694
 00FFF2AB 039                             rts
3695
                              abd1:
3696
 00FFF2AC 0C1031                          cmpb    #'1'
3697
 00FFF2AE 026003                          bne             abd2
3698
 00FFF2B0 0C6001                          ldb             #1
3699
 00FFF2B2 039                             rts
3700
                              abd2:
3701
 00FFF2B3 0C6FFF                          ldb             #-1
3702
 00FFF2B5 039                             rts
3703
 
3704 4 robfinch
                              DisplayErr:
3705 16 robfinch
 00FFF2B6 0CCFFF2C7                       ldd             #msgErr
3706
 00FFF2B9 017FFF11E                       lbsr    DisplayString
3707 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3708 16 robfinch
 00FFF2BC 07EFFF039                       jmp             Monitor
3709 4 robfinch
 
3710
                              DisplayStringDX
3711 16 robfinch
 00FFF2BF 0DD024                          std             Strptr
3712
 00FFF2C1 09F026                          stx             Strptr+2
3713
 00FFF2C3 0BDFFE3DA                       jsr             DisplayString
3714
 00FFF2C6 039                             rts
3715 4 robfinch
 
3716
                              msgErr:
3717 16 robfinch
 00FFF2C7 02A02A04507207200D00A           fcb     "**Err",CR,LF,0
3718
 00FFF2CE 000
3719 4 robfinch
 
3720
                              HelpMsg:
3721 16 robfinch
 00FFF2CF 03F02003D020044069073           fcb             "? = Display help",CR,LF
3722
 00FFF2D6 07006C061079020068065
3723
 00FFF2DD 06C07000D00A
3724
 00FFF2E1 04304C05302003D020063           fcb     "CLS = clear screen",CR,LF
3725
 00FFF2E8 06C065061072020073063
3726
 00FFF2EF 07206506506E00D00A
3727
 00FFF2F5 06207302003D020073065           fcb     "bs = set breakpoint",CR,LF
3728
 00FFF2FC 07402006207206506106B
3729
 00FFF303 07006F06906E07400D00A
3730
 00FFF30A 06206302003D02006306C           fcb     "bc = clear breakpoint",CR,LF
3731
 00FFF311 065061072020062072065
3732
 00FFF318 06106B07006F06906E074
3733
 00FFF31F 00D00A
3734 4 robfinch
                              ;       db      "S = Boot from SD Card",CR,LF
3735 16 robfinch
 00FFF321 03A02003D020045064069           fcb     ": = Edit memory bytes",CR,LF
3736
 00FFF328 07402006D06506D06F072
3737
 00FFF32F 079020062079074065073
3738
 00FFF336 00D00A
3739 4 robfinch
                              ;       db      "L = Load sector",CR,LF
3740
                              ;       db      "W = Write sector",CR,LF
3741 16 robfinch
 00FFF338 04405202003D020044075           fcb "DR = Dump registers",CR,LF
3742
 00FFF33F 06D070020072065067069
3743
 00FFF346 07307406507207300D00A
3744
 00FFF34D 04402003D02004407506D           fcb     "D = Dump memory",CR,LF
3745
 00FFF354 07002006D06506D06F072
3746
 00FFF35B 07900D00A
3747
 00FFF35E 04602003D02004606906C           fcb     "F = Fill memory",CR,LF
3748
 00FFF365 06C02006D06506D06F072
3749
 00FFF36C 07900D00A
3750
 00FFF36F 04604C02003D020044075           fcb "FL = Dump I/O Focus List",CR,LF
3751
 00FFF376 06D07002004902F04F020
3752
 00FFF37D 04606F06307507302004C
3753
 00FFF384 06907307400D00A
3754
                              ;       fcb "FIG = start FIG Forth",CR,LF
3755 4 robfinch
                              ;       db      "KILL n = kill task #n",CR,LF
3756
                              ;       db      "B = start tiny basic",CR,LF
3757
                              ;       db      "b = start EhBasic 6502",CR,LF
3758 16 robfinch
 00FFF389 04A02003D02004A07506D           fcb     "J = Jump to code",CR,LF
3759
 00FFF390 07002007406F02006306F
3760
 00FFF397 06406500D00A
3761
 00FFF39B 04A04403402003D02004A           fcb     "JD4 = Jump to $FFD400",CR,LF
3762
 00FFF3A2 07506D07002007406F020
3763
 00FFF3A9 024046046044034030030
3764
 00FFF3B0 00D00A
3765
 00FFF3B2 05204104D054045053054           fcb "RAMTEST = test RAM",CR,LF
3766
 00FFF3B9 02003D020074065073074
3767
 00FFF3C0 02005204104D00D00A
3768 4 robfinch
                              ;       db      "R[n] = Set register value",CR,LF
3769
                              ;       db      "r = random lines - test bitmap",CR,LF
3770
                              ;       db      "e = ethernet test",CR,LF
3771 16 robfinch
 00FFF3C6 07302003D020073065072           fcb     "s = serial output test",CR,LF
3772
 00FFF3CD 06906106C02006F075074
3773
 00FFF3D4 070075074020074065073
3774
 00FFF3DB 07400D00A
3775
 00FFF3DE 05303103902003D020072           fcb     "S19 = run S19 loader",CR,LF
3776
 00FFF3E5 07506E020053031039020
3777
 00FFF3EC 06C06F06106406507200D
3778
 00FFF3F3 00A
3779
 00FFF3F4 05305002003D020073070           fcb     "SP = sprite demo",CR,LF
3780
 00FFF3FB 072069074065020064065
3781
 00FFF402 06D06F00D00A
3782 4 robfinch
                              ;       db      "T = Dump task list",CR,LF
3783
                              ;       db      "TO = Dump timeout list",CR,LF
3784 16 robfinch
 00FFF406 05404902003D020064069           fcb     "TI = display date/time",CR,LF
3785
 00FFF40D 07307006C061079020064
3786
 00FFF414 06107406502F07406906D
3787
 00FFF41B 06500D00A
3788 4 robfinch
                              ;       db      "TEMP = display temperature",CR,LF
3789 16 robfinch
 00FFF41E 05502003D02007506E061           fcb     "U = unassemble",CR,LF
3790
 00FFF425 07307306506D06206C065
3791
 00FFF42C 00D00A
3792 15 robfinch
                              ;       db      "P = Piano",CR,LF
3793 16 robfinch
 00FFF42E 07802003D020065078069           fcb     "x = exit monitor",CR,LF
3794
 00FFF435 07402006D06F06E069074
3795
 00FFF43C 06F07200D00A
3796
 00FFF440 000                             fcb             0
3797 4 robfinch
 
3798
                              msgRegHeadings
3799 16 robfinch
 00FFF441 00D00A02002004402F041           fcb     CR,LF,"  D/AB     X      Y      U      S       PC    DP  CCR",CR,LF,0
3800
 00FFF448 042020020020020020058
3801
 00FFF44F 020020020020020020059
3802
 00FFF456 020020020020020020055
3803
 00FFF45D 020020020020020020053
3804
 00FFF464 020020020020020020020
3805
 00FFF46B 050043020020020020044
3806
 00FFF472 05002002004304305200D
3807
 00FFF479 00A000
3808 4 robfinch
 
3809
                              nHEX4:
3810 16 robfinch
 00FFF47B 0BDFFD2D2                       jsr             HEX4
3811
 00FFF47E 039                             rts
3812 4 robfinch
 
3813
                              nXBLANK:
3814 16 robfinch
 00FFF47F 0C6020                          ldb             #' '
3815
 00FFF481 016FFFA5D                       lbra    OUTCH
3816 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3817 4 robfinch
 
3818 13 robfinch
                              ;------------------------------------------------------------------------------
3819
                              ; Dump Memory
3820
                              ;
3821
                              ; Usage:
3822 14 robfinch
                              ;       $D FFFC12 FFFC20
3823 13 robfinch
                              ;
3824
                              ; Dump formatted to look like:
3825
                              ;               :FFFC12 012 012 012 012 555 666 777 888
3826
                              ;
3827
                              ;------------------------------------------------------------------------------
3828 4 robfinch
 
3829 13 robfinch
                              DumpMemory:
3830 16 robfinch
 00FFF484 08DD1D                          bsr             GetRange
3831
 00FFF486 18E000000                       ldy             #0
3832
 00FFF489 1BE000922                       ldy             mon_r1+2
3833 13 robfinch
                              dmpm2:
3834 16 robfinch
 00FFF48C 017FFDC43                       lbsr    CRLF
3835 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3836 16 robfinch
 00FFF48F 0C603A                          ldb             #':'
3837
 00FFF491 017FFFA4D                       lbsr    OUTCH
3838 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3839 16 robfinch
 00FFF494 01F020                          tfr             y,d
3840 13 robfinch
                                      ;addd   mon_r1+2                                        ; output the address
3841 16 robfinch
 00FFF496 017FFEF95                       lbsr    DispWordAsHex
3842 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3843 16 robfinch
 00FFF499 0C6020                          ldb             #' '
3844
 00FFF49B 017FFFA43                       lbsr    OUTCH
3845 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3846 16 robfinch
 00FFF49E 08E000008                       ldx             #8                                                              ; number of bytes to display
3847 13 robfinch
                              dmpm1:
3848
                              ;       ldb             far [mon_r1+1],y
3849
                                      ;ldb            [mon_r1+2],y
3850 16 robfinch
 00FFF4A1 0E6A04                          ldb             ,y
3851
 00FFF4A3 031201                          iny
3852
 00FFF4A5 017FFEF8F                       lbsr    DispByteAsHex                   ; display byte
3853 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3854 16 robfinch
 00FFF4A8 0C6020                          ldb             #' '                                                    ; followed by a space
3855
 00FFF4AA 017FFFA34                       lbsr    OUTCH
3856 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3857 16 robfinch
 00FFF4AD 05F                             clrb
3858
 00FFF4AE 04F                             clra
3859
 00FFF4AF 017FFF9F7                       lbsr    INCH
3860 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3861 16 robfinch
 00FFF4B2 0C1003                          cmpb    #CTRLC
3862
 00FFF4B4 027024                          beq             dmpm3
3863
 00FFF4B6 0301FF                          dex
3864
 00FFF4B8 026FE7                          bne             dmpm1
3865 13 robfinch
                                      ; Now output ascii
3866 16 robfinch
 00FFF4BA 0C6020                          ldb             #' '
3867
 00FFF4BC 017FFFA22                       lbsr    OUTCH
3868 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3869 16 robfinch
 00FFF4BF 08E000008                       ldx             #8                                                              ; 8 chars to output
3870
 00FFF4C2 0313F8                          leay    -8,y                                                    ; backup pointer
3871 13 robfinch
                              dmpm5:
3872
                              ;       ldb             far [mon_r1+1],y        ; get the char
3873
                              ;       ldb             [mon_r1+2],y                    ; get the char
3874 16 robfinch
 00FFF4C4 0E6A04                          ldb             ,y
3875
 00FFF4C6 0C1020                          cmpb    #$20                                                    ; is it a control char?
3876
 00FFF4C8 024002                          bhs             dmpm4
3877
 00FFF4CA 0C602E                          ldb             #'.'
3878 13 robfinch
                              dmpm4:
3879 16 robfinch
 00FFF4CC 017FFFA12                       lbsr    OUTCH
3880 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3881 16 robfinch
 00FFF4CF 031201                          iny
3882
 00FFF4D1 0301FF                          dex
3883
 00FFF4D3 026FEF                          bne             dmpm5
3884
 00FFF4D5 1BC000926                       cmpy    mon_r2+2
3885
 00FFF4D8 025FB2                          blo             dmpm2
3886 13 robfinch
                              dmpm3:
3887 16 robfinch
 00FFF4DA 017FFDBF5                       lbsr    CRLF
3888 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3889 16 robfinch
 00FFF4DD 016FFFB59                       lbra    Monitor
3890 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3891
 
3892
                              ;------------------------------------------------------------------------------
3893 14 robfinch
                              ; Edit Memory
3894
                              ;
3895
                              ; Usage:
3896
                              ;       $$:FFFC12 8 "Hello World!" 0
3897
                              ;
3898
                              ; Dump formatted to look like:
3899
                              ;               :FFFC12 012 012 012 012 555 666 777 888
3900
                              ;
3901
                              ;------------------------------------------------------------------------------
3902
 
3903
                              EditMemory:
3904 16 robfinch
 00FFF4E0 0CE000008                       ldu             #8                                              ; set max byte count
3905
 00FFF4E3 017FFFCE6                       lbsr    GetHexNumber    ; get the start address
3906 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3907 16 robfinch
 00FFF4E6 0BE000912                       ldx             mon_numwka+2
3908 14 robfinch
                              EditMem2:
3909 16 robfinch
 00FFF4E9 017FFFC5F                       lbsr    ignBlanks                       ; skip over blanks
3910 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3911 16 robfinch
 00FFF4EC 017FFFCDD                       lbsr    GetHexNumber    ; get the byte value
3912 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3913 16 robfinch
 00FFF4EF 05D                             tstb                                                            ; check for valid value
3914
 00FFF4F0 02700C                          beq             EditMem1                        ; if invalid, quit
3915
 00FFF4F2 0F6000913                       ldb             mon_numwka+3    ; get value
3916
 00FFF4F5 0E7800                          stb             ,x+                                             ; update memory at address
3917
 00FFF4F7 0335FF                          leau    -1,u                                    ; decremeent byte count
3918
 00FFF4F9 283000000                       cmpu    #0
3919
 00FFF4FC 026FEB                          bne             EditMem2                        ; go back for annother byte
3920 14 robfinch
                              EditMem1:
3921 16 robfinch
 00FFF4FE 017FFFC2D                       lbsr    MonGetch                        ; see if a string is being entered
3922 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3923 16 robfinch
 00FFF501 0C1022                          cmpb    #'"'
3924
 00FFF503 026018                          bne             EditMem3                        ; no string, we're done
3925
 00FFF505 0CE000028                       ldu             #40                                             ; string must be less than 40 chars
3926 14 robfinch
                              EditMem4:
3927 16 robfinch
 00FFF508 017FFFC23                       lbsr    MonGetch                        ; look for close quote
3928 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3929 16 robfinch
 00FFF50B 0C1022                          cmpb    #'"'
3930
 00FFF50D 026005                          bne             EditMem6                        ; end of string?
3931
 00FFF50F 0CE000008                       ldu             #8                                              ; reset the byte count
3932
 00FFF512 020FD5                          bra             EditMem2
3933 14 robfinch
                              EditMem6:
3934 16 robfinch
 00FFF514 0E7800                          stb             ,x+                                             ; store the character in memory
3935
 00FFF516 0335FF                          leau    -1,u                                    ; decrement byte count
3936
 00FFF518 283000000                       cmpu    #0
3937
 00FFF51B 022FEB                          bhi             EditMem4                        ; max 40 chars
3938 14 robfinch
                              EditMem3:
3939 16 robfinch
 00FFF51D 016FFFB19                       lbra    Monitor
3940 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3941
 
3942
 
3943
                              ;------------------------------------------------------------------------------
3944 15 robfinch
                              ; Fill Memory
3945
                              ;
3946
                              ; Usage:
3947
                              ;       $$F FFFC12 FFFC30 89F
3948
                              ;
3949
                              ;------------------------------------------------------------------------------
3950
 
3951
                              FillMemory:
3952 16 robfinch
 00FFF520 017FFFC80                       lbsr    GetRange                        ; get address range to fill
3953 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3954 16 robfinch
 00FFF523 017FFFC25                       lbsr    ignBlanks
3955 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3956 16 robfinch
 00FFF526 017FFFCA3                       lbsr    GetHexNumber    ; get target byte to write
3957 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3958 16 robfinch
 00FFF529 0F6000913                       ldb             mon_numwka+3
3959
 00FFF52C 0BE000922                       ldx             mon_r1+2
3960
 00FFF52F 04F                             clra
3961 15 robfinch
                              fillm1:                                                         ; Check for a CTRL-C every page of memory
3962 16 robfinch
 00FFF530 04D                             tsta
3963
 00FFF531 02600D                          bne             fillm2
3964
 00FFF533 05F                             clrb                                                            ; we want a non-blocking check
3965
 00FFF534 04F                             clra
3966
 00FFF535 017FFF971                       lbsr    INCH
3967 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3968 16 robfinch
 00FFF538 0C1003                          cmpb    #CTRLC
3969
 00FFF53A 127FFFAFC                       lbeq    Monitor
3970 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3971 16 robfinch
 00FFF53D 0F6000913                       ldb             mon_numwka+3    ; reset target byte
3972 15 robfinch
                              fillm2:
3973 16 robfinch
 00FFF540 0E7800                          stb             ,x+
3974
 00FFF542 0BC000926                       cmpx    mon_r2+2
3975
 00FFF545 023FE9                          bls             fillm1
3976 15 robfinch
                              fillm3:
3977 16 robfinch
 00FFF547 016FFFAEF                       lbra    Monitor
3978 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
3979
 
3980
                              ;------------------------------------------------------------------------------
3981 13 robfinch
                              ; Dump Registers
3982
                              ;
3983
                              ;       Usage:
3984
                              ;               $DR
3985
                              ;------------------------------------------------------------------------------
3986
 
3987
                              DumpRegs:
3988 16 robfinch
 00FFF54A 0CCFFF441                       ldd             #msgRegHeadings
3989
 00FFF54D 017FFEE8A                       lbsr    DisplayString
3990 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3991 16 robfinch
 00FFF550 08DF2D                          bsr             nXBLANK
3992
 00FFF552 0FC000900                       ldd             mon_DSAVE
3993
 00FFF555 08DF24                          bsr             nHEX4
3994
 00FFF557 08DF26                          bsr             nXBLANK
3995
 00FFF559 0FC000902                       ldd             mon_XSAVE
3996
 00FFF55C 08DF1D                          bsr             nHEX4
3997
 00FFF55E 08DF1F                          bsr             nXBLANK
3998
 00FFF560 0FC000904                       ldd             mon_YSAVE
3999
 00FFF563 08DF16                          bsr             nHEX4
4000
 00FFF565 08DF18                          bsr             nXBLANK
4001
 00FFF567 0FC000906                       ldd             mon_USAVE
4002
 00FFF56A 08DF0F                          bsr             nHEX4
4003
 00FFF56C 08DF11                          bsr             nXBLANK
4004
 00FFF56E 0FC000908                       ldd             mon_SSAVE
4005
 00FFF571 08DF08                          bsr             nHEX4
4006
 00FFF573 08DF0A                          bsr             nXBLANK
4007
 00FFF575 0F600090B                       ldb             mon_PCSAVE+1
4008
 00FFF578 017FFEEBC                       lbsr    DispByteAsHex
4009 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
4010 16 robfinch
 00FFF57B 0FC00090C                       ldd             mon_PCSAVE+2
4011
 00FFF57E 08DEFB                          bsr             nHEX4
4012
 00FFF580 08DEFD                          bsr             nXBLANK
4013
 00FFF582 0FC00090E                       ldd             mon_DPRSAVE
4014
 00FFF585 0BDFFD2CE                       jsr             HEX2
4015
 00FFF588 08DEF5                          bsr             nXBLANK
4016
 00FFF58A 0B600090F                       lda             mon_CCRSAVE
4017
 00FFF58D 017FFDD3E                       lbsr    HEX2
4018 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
4019 16 robfinch
 00FFF590 08DEED                          bsr             nXBLANK
4020
 00FFF592 016FFFAA4                       lbra    Monitor
4021 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
4022
 
4023
                              ;------------------------------------------------------------------------------
4024 4 robfinch
                              ; Jump to code
4025 13 robfinch
                              ;
4026
                              ; Registers are loaded with values from the monitor register save area before
4027
                              ; the code is jumped to.
4028
                              ;
4029
                              ; J 
4030
                              ;------------------------------------------------------------------------------
4031
 
4032 4 robfinch
                              jump_to_code:
4033 16 robfinch
 00FFF595 08DCCB                          bsr             GetNumber
4034
 00FFF597 01A010                          sei
4035
 00FFF599 1FE000908                       lds             mon_SSAVE
4036
 00FFF59C 0CCFFF5D0                       ldd             #jtc_exit               ; setup stack for RTS back to monitor
4037
 00FFF59F 034006                          pshs    d
4038
 00FFF5A1 0C6000                          ldb             #0
4039
 00FFF5A3 034004                          pshs    b
4040
 00FFF5A5 0FC000912                       ldd             mon_numwka+2    ; get the address parameter
4041
 00FFF5A8 034006                          pshs    d
4042
 00FFF5AA 0F6000911                       ldb             mon_numwka+1
4043
 00FFF5AD 034004                          pshs    b
4044
 00FFF5AF 0FC000906                       ldd             mon_USAVE
4045
 00FFF5B2 034006                          pshs    d
4046
 00FFF5B4 0FC000904                       ldd             mon_YSAVE
4047
 00FFF5B7 034006                          pshs    d
4048
 00FFF5B9 0FC000902                       ldd             mon_XSAVE
4049
 00FFF5BC 034006                          pshs    d
4050
 00FFF5BE 0B600090E                       lda             mon_DPRSAVE
4051
 00FFF5C1 034002                          pshs    a
4052
 00FFF5C3 0FC000900                       ldd             mon_DSAVE
4053
 00FFF5C6 034006                          pshs    d
4054
 00FFF5C8 0B600090F                       lda             mon_CCRSAVE
4055
 00FFF5CB 034002                          pshs    a
4056
 00FFF5CD 0150350FF                       puls    far ccr,d,dpr,x,y,u,pc
4057 4 robfinch
                              jtc_exit:
4058 16 robfinch
 00FFF5D0 1FF000908                       sts             >mon_SSAVE              ; need to use extended addressing, no direct page setting
4059
 00FFF5D3 03280F006FFF                    leas    $6FFF                                   ; reset stack to system area, dont modify flags register!
4060
 00FFF5D7 034001                          pshs    ccr                                             ; now the stack can be used
4061
 00FFF5D9 034002                          pshs    a                                                       ; save acca register so we can use it
4062
 00FFF5DB 01F0B8                          tfr             dpr,a                                   ; a = outgoing dpr value
4063
 00FFF5DD 0B700090E                       sta             >mon_DPRSAVE    ; force extended addressing mode usage here dpr is not set
4064
 00FFF5E0 04F                             clra                                                            ; dpg register must be set to zero before values are
4065
 00FFF5E1 01F08B                          tfr             a,dpr                                   ; saved in the monitor register save area.
4066
 00FFF5E3 035002                          puls    a                                                       ; get back acca
4067
 00FFF5E5 0FD000900                       std             mon_DSAVE                       ; save regsters, can use direct addressing now
4068
 00FFF5E8 0BF000902                       stx             mon_XSAVE
4069
 00FFF5EB 1BF000904                       sty             mon_YSAVE
4070
 00FFF5EE 0FF000906                       stu             mon_USAVE
4071
 00FFF5F1 035002                          puls    a                                                       ; get back ccr
4072
 00FFF5F3 0B700090F                       sta             mon_CCRSAVE             ; and save it too
4073 13 robfinch
                                      ; Reset vectors in case they got toasted.
4074 16 robfinch
 00FFF5F6 0CCFFEC64                       ldd             #SerialPeekCharDirect
4075
 00FFF5F9 0FD000804                       std             CharInVec
4076
 00FFF5FC 0CCFFE319                       ldd             #DisplayChar
4077
 00FFF5FF 0FD000800                       std             CharOutVec
4078
 00FFF602 0FCFFF2B6                       ldd             DisplayErr
4079
 00FFF605 0FD00080C                       std             MonErrVec
4080 4 robfinch
                                      ; todo set according to coreid
4081 16 robfinch
 00FFF608 016FFFF3F                       lbra    DumpRegs                        ; now go do a register dump
4082 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
4083 4 robfinch
 
4084
                              ;------------------------------------------------------------------------------
4085
                              ;------------------------------------------------------------------------------
4086 14 robfinch
 
4087
                              DumpIOFocusList:
4088 16 robfinch
 00FFF60B 08E000000                       ldx             #0
4089 14 robfinch
                              dfl2:
4090 16 robfinch
 00FFF60E 0E680A000FFC000                 ldb             IOFocusList,x
4091
 00FFF613 0C1018                          cmpb    #24
4092
 00FFF615 02600A                          bne             dfl1
4093
 00FFF617 01F010                          tfr             x,d
4094
 00FFF619 017FFEE1B                       lbsr    DispByteAsHex
4095 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
4096 16 robfinch
 00FFF61C 0C6020                          ldb             #' '
4097
 00FFF61E 017FFF8C0                       lbsr    OUTCH
4098 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
4099
                              dfl1:
4100 16 robfinch
 00FFF621 030001                          inx
4101
 00FFF623 08C000010                       cmpx    #16
4102
 00FFF626 025FE6                          blo             dfl2
4103
 00FFF628 017FFDAA7                       lbsr    CRLF
4104 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
4105 16 robfinch
 00FFF62B 016FFFA0B                       lbra    Monitor
4106 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
4107
 
4108 15 robfinch
                              bootpg:
4109 16 robfinch
 00FFF62E 000                             fcb             $000
4110 15 robfinch
                              boot_stack:
4111 16 robfinch
 00FFF62F FFC0FF                          fcw             $FFC0FF
4112 15 robfinch
                              numBreakpoints:
4113 16 robfinch
 00FFF631 008                             fcb             8
4114 15 robfinch
                              mon_rom_vectab:
4115 16 robfinch
 00FFF632 FFF634                          fcw             mon_rom_vecs
4116 15 robfinch
                              mon_rom_vecs:
4117 16 robfinch
 00FFF634 FFF039                          fcw             Monitor                                         ; enter monitor program
4118
 00FFF636 FFEEA9                          fcw             INCH                                                    ; input a character
4119
 00FFF638 FFEEE1                          fcw             OUTCH                                                   ; output a character
4120
 00FFF63A FFD0D2                          fcw             CRLF                                                    ; output carriage-return, line feed
4121
 00FFF63C FFE3DA                          fcw             DisplayString
4122
 00FFF63E FFE437                          fcw             DispByteAsHex
4123
 00FFF640 FFE42E                          fcw             DispWordAsHex
4124
 00FFF642 FFEEEB                          fcw             ShowSprites
4125
 00FFF644 FFEF6F                          fcw             mon_srand
4126
 00FFF646 FFEF9D                          fcw             mon_rand
4127
 00FFF648 000000                          fcw             0                                                                       ; operating system call
4128
 00FFF64A FFF1A3                          fcw             GetRange
4129
 00FFF64C FFF262                          fcw             GetNumber
4130 14 robfinch
 
4131 15 robfinch
                              NumFuncs        EQU     (*-mon_rom_vectab)/2
4132
 
4133 16 robfinch
                              ; The following table indicates which routines need to return values in the
4134
                              ; D and possibly X registers.
4135
 
4136
                              mon_rettab:
4137
 00FFF64E 000                             fcb             0                       ; monitor
4138
 00FFF64F 800                             fcb             $800    ; INCH
4139
 00FFF650 000                             fcb             0                       ; OUTCH
4140
 00FFF651 000                             fcb             0                       ; CRLF
4141
 00FFF652 000                             fcb             0                       ; DisplayString
4142
 00FFF653 000                             fcb             0                       ; DisplayByte
4143
 00FFF654 000                             fcb             0                       ; DisplayWord
4144
 00FFF655 000                             fcb             0                       ; show sprites
4145
 00FFF656 000                             fcb             0                       ; srand
4146
 00FFF657 C00                             fcb             $C00    ; rand
4147
 00FFF658 C00                             fcb             $C00    ; OS call
4148
 00FFF659 000                             fcb             0                       ; GetRange
4149
 00FFF65A 800                             fcb             $800    ; GetNumber
4150
 
4151 14 robfinch
                              ;------------------------------------------------------------------------------
4152 15 robfinch
                              ; SWI routine.
4153
                              ;
4154
                              ; SWI is used to call ROM monitor routines and process breakpoints.
4155
                              ;
4156
                              ;       swi
4157
                              ;       fcb 
4158 14 robfinch
                              ;------------------------------------------------------------------------------
4159 15 robfinch
 
4160
                              swi_rout:
4161 16 robfinch
 00FFF65B 0E680CFD0                       ldb             bootpg,pcr                      ; reset direct page
4162
 00FFF65E 01F09B                          tfr             b,dp
4163 15 robfinch
                              swi_rout1:
4164 16 robfinch
 00FFF660 0EE60B                          ldu             11,s                                            ; get program counter (low order 2 bytes)
4165
 00FFF662 0335FF                          leau    -1,u                                            ; backup a byte
4166
 00FFF664 07D000810                       tst             BreakpointFlag  ; are we in breakpoint mode?
4167
 00FFF667 02700F                          beq             swiNotBkpt
4168
 00FFF669 0CE000820                       ldu             #Breakpoints
4169
 00FFF66C 0F6000811                       ldb             NumSetBreakpoints
4170
 00FFF66F 027007                          beq             swiNotBkpt
4171 15 robfinch
                              swi_rout2:
4172 16 robfinch
 00FFF671 2A3A01                          cmpu    ,y++
4173
 00FFF673 02704B                          beq             processBreakpoint
4174
 00FFF675 05A                             decb
4175
 00FFF676 026FF9                          bne             swi_rout2
4176 15 robfinch
                              swiNotBkpt:
4177 16 robfinch
 00FFF678 07F000810                       clr             BreakpointFlag
4178
 00FFF67B 037006                          pulu    d                                                               ; get function #, increment PC
4179
 00FFF67D 0C100E                          cmpb    #NumFuncs
4180
 00FFF67F 122FFFC34                       lbhi    DisplayErr
4181 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4182 16 robfinch
 00FFF682 0EF60B                          stu             11,s                                            ; save updated PC on stack
4183
 00FFF684 0C100A                          cmpb    #MF_OSCALL
4184
 00FFF686 02706D                          beq             swiCallOS
4185
 00FFF688 058                             aslb                                                                    ; 2 bytes per vector
4186
 00FFF689 0AE80CFA6                       ldx             mon_rom_vectab,pcr
4187
 00FFF68C 03A                             abx
4188
 00FFF68D 0AE804                          ldx             ,x
4189
 00FFF68F 0BF000928                       stx             jmpvec
4190
 00FFF692 054                             lsrb
4191
 00FFF693 08EFFF64E                       ldx             #mon_rettab
4192
 00FFF696 03A                             abx
4193
 00FFF697 0E6804                          ldb             ,x
4194
 00FFF699 0F7000930                       stb             mon_retflag
4195
 00FFF69C 1FF000908                       sts             mon_SSAVE                               ; save the stack pointer
4196
 00FFF69F 0EC601                          ldd             1,s                                                     ; get back D
4197
 00FFF6A1 0AE604                          ldx             4,s                                                     ; get back X
4198
 00FFF6A3 1AE606                          ldy             6,s                                                     ; get back Y
4199
 00FFF6A5 0EE608                          ldu             8,s                                                     ; get back U
4200
 00FFF6A7 1EE80CF85                       lds             boot_stack,pcr  ; and use our own stack
4201
 00FFF6AA 0AD90F000928                    jsr             [jmpvec]                                ; call the routine
4202 15 robfinch
                              swi_rout3:
4203 16 robfinch
 00FFF6AE 1FE000908                       lds             mon_SSAVE                               ; restore stack
4204
 00FFF6B1 07D000930                       tst             mon_retflag
4205
 00FFF6B4 02A009                          bpl             swi_rout4
4206
 00FFF6B6 0ED601                          std             1,s                                                     ; return value in D
4207
 00FFF6B8 078000930                       asl             mon_retflag
4208
 00FFF6BB 02A002                          bpl             swi_rout4
4209
 00FFF6BD 0AF604                          stx             4,s                                                     ; return value in X
4210
                              swi_rout4:
4211
 00FFF6BF 03B                             rti
4212 15 robfinch
 
4213
                              processBreakpoint:
4214 16 robfinch
 00FFF6C0 0A6E04                          lda             ,s
4215
 00FFF6C2 0B700090F                       sta             mon_CCRSAVE
4216
 00FFF6C5 0EC601                          ldd             1,s
4217
 00FFF6C7 0FD000900                       std             mon_DSAVE
4218
 00FFF6CA 0E6603                          ldb             3,s
4219
 00FFF6CC 0F700090E                       stb             mon_DPRSAVE
4220
 00FFF6CF 0EC604                          ldd             4,s
4221
 00FFF6D1 0FD000902                       std             mon_XSAVE
4222
 00FFF6D4 0EC606                          ldd             6,s
4223
 00FFF6D6 0FD000904                       std             mon_YSAVE
4224
 00FFF6D9 0EC608                          ldd             8,s
4225
 00FFF6DB 0FD000906                       std             mon_USAVE
4226
 00FFF6DE 1FF000908                       sts             mon_SSAVE
4227
 00FFF6E1 0EC60B                          ldd             11,s
4228
 00FFF6E3 0FD00090A                       std             mon_PCSAVE
4229
 00FFF6E6 1EE80CF46                       lds             boot_stack,pcr
4230
 00FFF6E9 0CCFFF6AE                       ldd             #swi_rout3                      ; setup so monitor can return
4231
 00FFF6EC 034006                          pshs    d
4232
 00FFF6EE 08D01F                          bsr             DisarmAllBreakpoints
4233
 00FFF6F0 016FFFE57                       lbra    DumpRegs
4234 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4235
 
4236
                              xitMonitor:
4237 16 robfinch
 00FFF6F3 020039                          bra             ArmAllBreakpoints
4238 15 robfinch
 
4239
                              swiCallOS:
4240 16 robfinch
 00FFF6F5 033401                          leau    1,u                                                     ; next byte is func number
4241
 00FFF6F7 0E6C00                          ldb             ,u+
4242
 00FFF6F9 0C1019                          cmpb    #NumOSFuncs                     ; check for valid range
4243
 00FFF6FB 122FFFBB8                       lbhi    DisplayErr
4244 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4245 16 robfinch
 00FFF6FE 0EF60B                          stu             11,s                                            ; save updateed PC on stack
4246
 00FFF700 058                             aslb                                                                    ; compute vector address
4247
 00FFF701 08EFFEEF6                       ldx             #OSCallTbl
4248
 00FFF704 06DE0F                          tst             b,x                                                     ; check for non-zero vector
4249
 00FFF706 027FA6                          beq             swi_rout3
4250 15 robfinch
                              osc1:
4251
                              ;       tst             OSSEMA+1                                ; wait for availability
4252
                              ;       beq             osc1
4253 16 robfinch
 00FFF708 0ADF0F                          jsr             [b,x]                                           ; call the OS routine
4254 15 robfinch
                              oscx:
4255 16 robfinch
 00FFF70A 07FEF0011                       clr             OSSEMA+1
4256
 00FFF70D 020F9F                          bra             swi_rout3
4257 15 robfinch
 
4258
                              DisarmAllBreakpoints:
4259 16 robfinch
 00FFF70F 034036                          pshs    d,x,y
4260
 00FFF711 18E000000                       ldy             #0
4261
 00FFF714 05F                             clrb
4262
 00FFF715 08E000830                       ldx             #BreakpointBytes        ; x = breakpoint byte table address
4263 15 robfinch
                              disarm2:
4264 16 robfinch
 00FFF718 0C1631                          cmpb    #numBreakpoints         ; safety check
4265
 00FFF71A 024010                          bhs             disarm1
4266
 00FFF71C 0F1000811                       cmpb    NumSetBreakpoints
4267
 00FFF71F 02400B                          bhs             disarm1
4268
 00FFF721 0A6837                          lda             b,x                                                             ; get memory byte
4269
 00FFF723 0A7B09000820                    sta             [Breakpoints,y]         ; and store it back to memory
4270
 00FFF727 031202                          leay    2,y                                                             ; increment for next address
4271
 00FFF729 05C                             incb                                                                            ; increment to next byte
4272
 00FFF72A 020FEC                          bra             disarm2                                         ; loop back
4273 15 robfinch
                              disarm1:
4274 16 robfinch
 00FFF72C 0350B6                          puls    d,x,y,pc
4275 15 robfinch
 
4276
                              ArmAllBreakpoints:
4277 16 robfinch
 00FFF72E 034036                          pshs    d,x,y
4278
 00FFF730 18E000000                       ldy             #0
4279
 00FFF733 05F                             clrb
4280
 00FFF734 08E000830                       ldx             #BreakpointBytes        ; x = breakpoint byte table address
4281 15 robfinch
                              arm2:
4282 16 robfinch
 00FFF737 0F1FFF631                       cmpb    numBreakpoints          ; safety check
4283
 00FFF73A 024010                          bhs             arm1
4284
 00FFF73C 0F1000811                       cmpb    NumSetBreakpoints
4285
 00FFF73F 02400B                          bhs             arm1
4286
 00FFF741 0A6B09000820                    lda             [Breakpoints,y]         ; load byte at memory address
4287
 00FFF745 0A7B0D                          sta             b,x                                                             ; save in table
4288
 00FFF747 031202                          leay    2,y                                                             ; increment for next address
4289
 00FFF749 05C                             incb                                                                            ; increment to next byte
4290
 00FFF74A 020FEB                          bra             arm2                                                    ; loop back
4291 15 robfinch
                              arm1:
4292 16 robfinch
 00FFF74C 0350B6                          puls    d,x,y,pc
4293 15 robfinch
 
4294
                              ArmBreakpoint:
4295 16 robfinch
 00FFF74E 034036                          pshs    d,x,y
4296
 00FFF750 0B6000811                       lda             NumSetBreakpoints               ; check if too many breakpoints set
4297
 00FFF753 0B1FFF631                       cmpa    numBreakpoints
4298
 00FFF756 124FFFB5D                       lbhs    DisplayErr
4299 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4300 16 robfinch
 00FFF759 017FFFA70                       lbsr    GetHexNumber                            ; get address parameter
4301 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4302 16 robfinch
 00FFF75C 0F6000811                       ldb             NumSetBreakpoints               ; bv= number of set breakpoints
4303
 00FFF75F 1BE000912                       ldy             mon_numwka+2                            ; get address
4304
 00FFF762 0A6A04                          lda             ,y                                                                      ; get byte at address
4305
 00FFF764 08E000830                       ldx             #BreakpointBytes                ; and store byte in a table
4306
 00FFF767 0A7A05                          sta             b,x                                                                     ; record
4307
 00FFF769 08603F                          lda             #OPC_SWI                                                ; put a SWI instruction in place
4308
 00FFF76B 0A7A04                          sta             ,y
4309
 00FFF76D 08E000820                       ldx             #Breakpoints                            ; also store the address in a table
4310
 00FFF770 058                             aslb                                                                                    ; index for 2 byte values
4311
 00FFF771 1AFA05                          sty             b,x
4312
 00FFF773 054                             lsrb                                                                                    ; size back to single byte
4313
 00FFF774 05C                             incb
4314
 00FFF775 0F7000811                       stb             NumSetBreakpoints
4315
 00FFF778 0350B6                          puls    d,x,y,pc
4316 15 robfinch
 
4317
                              DisarmBreakpoint:
4318 16 robfinch
 00FFF77A 034076                          pshs    d,x,y,u
4319
 00FFF77C 017FFFA4D                       lbsr    GetHexNumber
4320 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4321 16 robfinch
 00FFF77F 05F                             clrb
4322
 00FFF780 05F                             clrb
4323
 00FFF781 01F001                          tfr             d,x                                                                     ; x = zero too
4324 15 robfinch
                              disarm6:
4325 16 robfinch
 00FFF783 0F1FFF631                       cmpb    numBreakpoints                  ; no more than this many may be set
4326
 00FFF786 024041                          bhs             disarm4
4327
 00FFF788 0F1000811                       cmpb    NumSetBreakpoints               ; number actually set
4328
 00FFF78B 02403C                          bhs             disarm4
4329
 00FFF78D 1AE809000820                    ldy             Breakpoints,x                           ; y = breakpoint address
4330
 00FFF791 1BC000912                       cmpy    mon_numwka+2                            ; is it the one we want?
4331
 00FFF794 02602E                          bne             disarm3                                                 ; if not, go increment to next
4332
 00FFF796 0BE000912                       ldx             mon_numwka+2                            ; x = memory address
4333
 00FFF799 18E000830                       ldy             #BreakpointBytes
4334
 00FFF79C 0A6A0D                          lda             b,y                                                                     ; get saved byte from table
4335
 00FFF79E 0A7804                          sta             ,x                                                                      ; set the byte at the memory address
4336 15 robfinch
                                      ; compress breakpoint table by removing breakpoint
4337 16 robfinch
 00FFF7A0 07A000811                       dec             NumSetBreakpoints               ; set the new number of set breakpoints
4338
 00FFF7A3 034004                          pshs    b                                                                               ; save the position we're removing from
4339 15 robfinch
                              disarm7:
4340 16 robfinch
 00FFF7A5 05C                             incb                                                                                    ; set index for next byte
4341
 00FFF7A6 0A6A05                          lda             b,y                                                                     ; get byte
4342
 00FFF7A8 05A                             decb                                                                                    ; and store it back
4343
 00FFF7A9 0A7A05                          sta             b,y
4344
 00FFF7AB 05C                             incb                                                                                    ; move to next position
4345
 00FFF7AC 0F1FFF631                       cmpb    numBreakpoints                  ; hit end of table?
4346
 00FFF7AF 025FF4                          blo             disarm7
4347
 00FFF7B1 035004                          puls    b                                                                               ; get back position
4348
 00FFF7B3 058                             aslb                                                                                    ; times two for word index
4349
 00FFF7B4 04F                             clra
4350
 00FFF7B5 01F002                          tfr             d,y
4351
 00FFF7B7 054                             lsrb                                                                                    ; back to byte index value
4352 15 robfinch
                              disarm8:
4353 16 robfinch
 00FFF7B8 0EE202                          ldu             2,y                                                                     ; get next breakpoint address
4354
 00FFF7BA 0EFA01                          stu             ,y++                                                            ; store in current pos, increment
4355
 00FFF7BC 05C                             incb                                                                                    ; increment count
4356
 00FFF7BD 0F1FFF631                       cmpb    numBreakpoints                  ; hit end of table?
4357
 00FFF7C0 025FF6                          blo             disarm8
4358
 00FFF7C2 0350F6                          puls    d,x,y,u,pc
4359 15 robfinch
                              disarm3:
4360 16 robfinch
 00FFF7C4 030002                          leax    2,x
4361
 00FFF7C6 05C                             incb
4362
 00FFF7C7 020FBA                          bra             disarm6
4363 15 robfinch
                              disarm4:
4364 16 robfinch
 00FFF7C9 0350F6                          puls    d,x,y,u,pc
4365 15 robfinch
 
4366
                              ;------------------------------------------------------------------------------
4367
                              ;------------------------------------------------------------------------------
4368 4 robfinch
                              swi3_rout:
4369 16 robfinch
 00FFF7CB 01A010                          sei
4370
 00FFF7CD 0A6E04                          lda             ,s
4371
 00FFF7CF 0B700090F                       sta             mon_CCRSAVE
4372
 00FFF7D2 0EC601                          ldd             1,s
4373
 00FFF7D4 0FD000900                       std             mon_DSAVE
4374
 00FFF7D7 0E6603                          ldb             3,s
4375
 00FFF7D9 0F700090E                       stb             mon_DPRSAVE
4376
 00FFF7DC 0EC604                          ldd             4,s
4377
 00FFF7DE 0FD000902                       std             mon_XSAVE
4378
 00FFF7E1 0EC606                          ldd             6,s
4379
 00FFF7E3 0FD000904                       std             mon_YSAVE
4380
 00FFF7E6 0EC608                          ldd             8,s
4381
 00FFF7E8 0FD000906                       std             mon_USAVE
4382
 00FFF7EB 1FF000908                       sts             mon_SSAVE
4383
 00FFF7EE 0EC60B                          ldd             11,s
4384
 00FFF7F0 0FD00090A                       std             mon_PCSAVE
4385
 00FFF7F3 1FF000908                       sts             mon_SSAVE
4386
 00FFF7F6 1CE003FFF                       lds             #$3FFF
4387
 00FFF7F9 0CCFFF803                       ldd             #swi3_exit
4388
 00FFF7FC 034006                          pshs    d
4389
 00FFF7FE 01C0EF                          cli
4390
 00FFF800 07EFFF54A                       jmp             DumpRegs
4391 4 robfinch
                              swi3_exit:
4392 16 robfinch
 00FFF803 1FE000908                       lds             mon_SSAVE
4393
 00FFF806 03B                             rti
4394 4 robfinch
 
4395
                              ;------------------------------------------------------------------------------
4396
                              ;------------------------------------------------------------------------------
4397 13 robfinch
                              firq_rout:
4398 16 robfinch
 00FFF807 03B                             rti
4399 13 robfinch
 
4400 4 robfinch
                              irq_rout:
4401 13 robfinch
                              ;       lbsr    SerialIRQ       ; check for recieved character
4402 16 robfinch
 00FFF808 017FFEC85                       lbsr    TimerIRQ
4403 15 robfinch
*** warning 1: Long branch within short branch range could be optimized
4404 13 robfinch
 
4405 4 robfinch
                                      ; Reset the edge sense circuit in the PIC
4406 15 robfinch
                              ;       lda             #31                                                     ; Timer is IRQ #31
4407
                              ;       sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
4408
                              ;       sta             PIC+16                                  ; register 16 is edge sense reset reg
4409
                              ;       lda             VIA+VIA_IFR
4410
                              ;       bpl             notTimerIRQ2
4411
                              ;       bita    #$800
4412
                              ;       beq             notTimerIRQ2
4413
                              ;       clr             VIA+VIA_T3LL
4414
                              ;       clr             VIA+VIA_T3LH
4415
                              ;       inc             $E00037                                 ; update timer IRQ screen flag
4416
                              ;notTimerIRQ2:
4417 4 robfinch
 
4418 16 robfinch
 00FFF80B 0B6FFC014                       lda             IrqBase                 ; get the IRQ flag byte
4419
 00FFF80E 044                             lsra
4420
 00FFF80F 0BAFFC014                       ora             IrqBase
4421
 00FFF812 084FE0                          anda    #$FE0
4422
 00FFF814 0B7FFC014                       sta             IrqBase
4423 4 robfinch
 
4424 13 robfinch
                              ;       inc             TEXTSCR+54              ; update IRQ live indicator on screen
4425 4 robfinch
 
4426
                                      ; flash the cursor
4427
                                      ; only bother to flash the cursor for the task with the IO focus.
4428 13 robfinch
                              ;       lda             COREID
4429
                              ;       cmpa    IOFocusID
4430
                              ;       bne             tr1a
4431
                              ;       lda             CursorFlash             ; test if we want a flashing cursor
4432
                              ;       beq             tr1a
4433
                              ;       lbsr    CalcScreenLoc   ; compute cursor location in memory
4434
                              ;       tfr             d,y
4435
                              ;       lda             $2000,y                 ; get color code $2000 higher in memory
4436
                              ;       ldb             IRQFlag                 ; get counter
4437
                              ;       lsrb
4438
                              ;       lsra
4439
                              ;       lsra
4440
                              ;       lsra
4441
                              ;       lsra
4442
                              ;       lsrb
4443
                              ;       rola
4444
                              ;       lsrb
4445
                              ;       rola
4446
                              ;       lsrb
4447
                              ;       rola
4448
                              ;       lsrb
4449
                              ;       rola
4450
                              ;       sta             $E00000,y               ; store the color code back to memory
4451
                              tr1a:
4452 16 robfinch
 00FFF817 03B                             rti
4453 4 robfinch
 
4454
                              ;------------------------------------------------------------------------------
4455
                              ;------------------------------------------------------------------------------
4456
                              nmi_rout:
4457 16 robfinch
 00FFF818 0150F6FFFFFFFE0                 ldb             COREID
4458
 00FFF81D 086049                          lda             #'I'
4459
 00FFF81F 08EE00028                       ldx             #TEXTSCR+40
4460
 00FFF822 0A7807                          sta             b,x
4461 13 robfinch
                              rti_insn:
4462 16 robfinch
 00FFF824 03B                             rti
4463 4 robfinch
 
4464 13 robfinch
                              ; Special Register Area
4465
                                      org             $FFFFE0
4466
 
4467
                              ; Interrupt vector table
4468
 
4469 4 robfinch
                                      org             $FFFFF0
4470 16 robfinch
 00FFFFF0 FFF824                          fcw             rti_insn                ; reserved
4471
 00FFFFF2 FFF7CB                          fcw             swi3_rout               ; SWI3
4472
 00FFFFF4 FFF824                          fcw             rti_insn                ; SWI2
4473
 00FFFFF6 FFF807                          fcw             firq_rout               ; FIRQ
4474
 00FFFFF8 FFF808                          fcw             irq_rout                ; IRQ
4475
 00FFFFFA FFF65B                          fcw             swi_rout                ; SWI
4476
 00FFFFFC FFF818                          fcw             nmi_rout                ; NMI
4477 13 robfinch
 00FFFFFE FFE023                          fcw             start                           ; RST
4478 4 robfinch
 
4479 15 robfinch
66 warning(s) in pass 2.
4480 4 robfinch
 
4481
SYMBOL TABLE
4482 16 robfinch
      ABD1 02 00FFF2AC      ABD2 02 00FFF2B3      ACIA 00 FFE30100  ACIA_CMD 00 00000002
4483
 ACIA_CTRL 00 00000003 ACIA_CTRL2 00 0000000B   ACIA_RX 00 00000000 ACIA_STAT 00 00000001
4484
   ACIA_TX 00 00000000      ARM1 02 00FFF74C      ARM2 02 00FFF737 ARMALLBREAKPOINTS 02 00FFF72E
4485
 ARMBREAKPOINT 02 00FFF74E ASCIITOBINDIGIT 02 00FFF2A6 ASCIITODECDIGIT 02 00FFF298 ASCIITOHEXNYBBLE 02 00FFF270
4486
    ASMBUF 00 00000160 BIOS_SCREENS 00 17000000 BLANKLINE 02 00FFE280 BLKCPYDST 00 00000020
4487
 BLKCPYSRC 00 0000001C   BLNKLN1 02 00FFE293    BOOTPG 02 00FFF62E BOOT_STACK 02 00FFF62F
4488
 BREAKPOINTBYTES 00 00000830 BREAKPOINTFLAG 00 00000810 BREAKPOINTS 00 00000820 CALCSCREENLOC 02 00FFE2F2
4489
 CHARCOLOR 00 00000112 CHARINVEC 00 00000804 CHAROUTVEC 00 00000800 CHECKPOINT 02 00FFE13D
4490
 CLEARSCREEN 02 00FFE239 CLEARSCREENJMP 02 00FFD300 CMDPROMPT 02 00FFF009 CMDPROMPTJI 00 00000808
4491
 CMDTABLE1 02 00FFEFB2 CMDTABLE2 02 00FFEFE3 COLORCODELOCATION 00 00000014      COLS 00 00000040
4492
 COPYSCREENTOVIRTUALSCREEN 02 00FFE209 COPYVIRTUALSCREENTOSCREEN 02 00FFE1D2    COREID 00 FFFFFFE0        CR 00 0000000D
4493
      CRLF 02 00FFD0D2     CRLF1 02 00FFD0D2    CRLFST 02 00FFE422       CS1 02 00FFE246
4494
       CS2 02 00FFE25D     CS2V1 02 00FFE215       CS3 02 00FFE263      CSL1 02 00FFE311
4495
     CTRLC 00 00000003     CTRLH 00 00000008     CTRLI 00 00000009     CTRLJ 00 0000000A
4496
     CTRLK 00 0000000B     CTRLM 00 0000000D     CTRLS 00 00000013     CTRLT 00 00000014
4497
     CTRLX 00 00000018     CTRLZ 00 0000001A CURSORCOL 00 00000111 CURSORFLASH 00 00000114
4498
 CURSORROW 00 00000110     CV2S1 02 00FFE1E7 DBGCHECKFORKEY 02 00FFEA90     DBGK1 02 00FFEACB
4499
    DBGK10 02 00FFEB30    DBGK11 02 00FFEB89    DBGK12 02 00FFEB8F    DBGK13 02 00FFEB9B
4500
    DBGK14 02 00FFEBAB    DBGK15 02 00FFEBBA    DBGK16 02 00FFEBC5    DBGK17 02 00FFEBCE
4501
    DBGK18 02 00FFEBD1     DBGK2 02 00FFEA96    DBGK20 02 00FFEAB8    DBGK22 02 00FFEAD4
4502
    DBGK23 02 00FFEAE5    DBGK24 02 00FFEAC6     DBGK3 02 00FFEAE8     DBGK4 02 00FFEAF4
4503
     DBGK5 02 00FFEB00     DBGK7 02 00FFEB10     DBGK8 02 00FFEB16     DBGK9 02 00FFEB2A
4504
 DBGKNOTALT 02 00FFEB93 DBGKNOTCAPSLOCK 02 00FFEB62 DBGKNOTCTRL 02 00FFEB1A DBGKNOTNUMLOCK 02 00FFEB4B
4505
 DBGKNOTRSHIFT 02 00FFEB34 DBGKNOTSCROLLLOCK 02 00FFEB79      DCCR 02 00FFE329      DCLF 02 00FFE3B3
4506
     DCX10 02 00FFE363     DCX11 02 00FFE373     DCX12 02 00FFE36F     DCX13 02 00FFE37F
4507
     DCX14 02 00FFE326      DCX3 02 00FFE3A1      DCX4 02 00FFE3B5      DCX5 02 00FFE390
4508
      DCX6 02 00FFE33A      DCX7 02 00FFE336      DCX8 02 00FFE347      DCX9 02 00FFE354
4509
   DELAY3S 02 00FFE1B5      DFL1 02 00FFF621      DFL2 02 00FFF60E   DISARM1 02 00FFF72C
4510
   DISARM2 02 00FFF718   DISARM3 02 00FFF7C4   DISARM4 02 00FFF7C9   DISARM6 02 00FFF783
4511
   DISARM7 02 00FFF7A5   DISARM8 02 00FFF7B8 DISARMALLBREAKPOINTS 02 00FFF70F DISARMBREAKPOINT 02 00FFF77A
4512
 DISPBYTEASHEX 02 00FFE437 DISPDWORDASHEX 02 00FFE425 DISPLAYCHAR 02 00FFE319 DISPLAYERR 02 00FFF2B6
4513
 DISPLAYSTRING 02 00FFE3DA DISPLAYSTRINGCRLF 02 00FFE3FA DISPLAYSTRINGDX 02 00FFF2BF   DISPNYB 02 00FFE44F
4514
  DISPNYB1 02 00FFE45E DISPWORDASHEX 02 00FFE42E    DLY3S1 02 00FFE1B8    DLY3S2 02 00FFE1BC
4515
     DMPM1 02 00FFF4A1     DMPM2 02 00FFF48C     DMPM3 02 00FFF4DA     DMPM4 02 00FFF4CC
4516
     DMPM5 02 00FFF4C4 DRAM_BASE 00 10000000    DSPJ1B 02 00FFE3EC     DSPJ2 02 00FFE3E7
4517
    DSRETB 02 00FFE3F5 DUMPIOFOCUSLIST 02 00FFF60B DUMPMEMORY 02 00FFF484  DUMPREGS 02 00FFF54A
4518
    DUMRTS 02 00FFE022  EDITMEM1 02 00FFF4FE  EDITMEM2 02 00FFF4E9  EDITMEM3 02 00FFF51D
4519
  EDITMEM4 02 00FFF508  EDITMEM6 02 00FFF514 EDITMEMORY 02 00FFF4E0 ENDOFWORD 02 00FFF0ED
4520
   FARFLAG 00 0000015F    FILLM1 02 00FFF530    FILLM2 02 00FFF540    FILLM3 02 00FFF547
4521
 FILLMEMORY 02 00FFF520 FIRQ_ROUT 02 00FFF807 FIRST_CORE 00 00000001   FREEMBX 02 00000002
4522
   FREEMSG 02 00000006   FREETCB 00 0000078A GETBINNUMBER 02 00FFF1FC GETDECNUMBER 02 00FFF223
4523
 GETHEXNUMBER 02 00FFF1CC    GETKEY 02 00FFEA92 GETNUMBER 02 00FFF262  GETRANGE 02 00FFF1A3
4524
 GETSCREENLOCATION 02 00FFE29A GETTWOPARAMS 02 00FFF182     GRNG1 02 00FFF1BE      GSL1 02 00FFE2AC
4525
    GTBIN1 02 00FFF21F    GTBIN2 02 00FFF209     GTDC3 02 00FFF2A3    GTDEC1 02 00FFF25E
4526
    GTDEC2 02 00FFF230     GTHX3 02 00FFF295     GTHX5 02 00FFF27B     GTHX6 02 00FFF288
4527
    GTHXN1 02 00FFF1F8    GTHXN2 02 00FFF1D9       HC1 02 00FFE2CA   HELPMSG 02 00FFF2CF
4528
      HEX2 02 00FFD2CE      HEX4 02 00FFD2D2 HOMECURSOR 02 00FFE2B0 HOMECURSORJMP 02 00FFD308
4529
     I2CW1 02 00FFE4BF    I2CWR1 02 00FFE4EC   I2C_CMD 00 00000004  I2C_CTRL 00 00000002
4530
  I2C_INIT 02 00FFE4B3  I2C_PREH 00 00000001  I2C_PREL 00 00000000   I2C_RXR 00 00000003
4531
  I2C_STAT 00 00000004   I2C_TXR 00 00000003 I2C_WAIT_RX_NACK 02 00FFE4EA I2C_WAIT_TIP 02 00FFE4BD
4532
 I2C_WR_CMD 02 00FFE4C7 I2C_XMIT1 02 00FFE4D0      ICC1 02 00FFE3D6      ICC2 02 00FFE3D8
4533
      ICR1 02 00FFE3C8 IGNBLANKS 02 00FFF14B IGNBLANKS1 02 00FFF14B INCCURSORPOS 02 00FFE3B7
4534
 INCCURSORROW 02 00FFE3C6      INCH 02 00FFEEA9     INCH1 02 00FFEEBE     INCH2 02 00FFEEAB
4535
     INCHE 02 00FFEEC7    INCHEK 02 00FFEECB   INCHEK1 02 00FFEEE0   INCHEK2 02 00FFEEDD
4536
   INCHEK3 02 00FFEED4      INIT 02 00FFE0A8     INIT1 02 00FFE0B0     INIT2 02 00FFE0F8
4537
 INITSERIAL 02 00FFEBEF IOFOCUSID 00 00FFC010 IOFOCUSLIST 00 00FFC000 IOFOCUSNDX 00 00000100
4538
   IRQBASE 00 00FFC014   IRQFLAG 00 00FFC012 IRQSOURCE 00 00FFC011  IRQ_ROUT 02 00FFF808
4539
    JMPVEC 00 00000928  JTC_EXIT 02 00FFF5D0 JUMP_TO_CODE 02 00FFF595 KBDBUFFULL 02 00FFEA8D
4540
   KBDFIFO 00 00000040 KBDFIFOALIAS 00 00C00040 KBDHEADRCV 00 00000127  KBDI0002 02 00FFE9C9
4541
  KBDI0004 02 00FFEA0E KBDITRYAGAIN 02 00FFEA02 KBDRCVCOUNT 02 00FFEA3D KBDTAILRCV 00 00000128
4542
     KBGS1 02 00FFE978     KBGS2 02 00FFE970     KBGS3 02 00FFE961     KEYBD 00 FFE30400
4543
  KEYBDACK 00 FFFFCC00  KEYBDBAD 00 FFFFCB00 KEYBDBLOCK 00 00000126 KEYBDBUFFER 00 FFFFC000
4544
 KEYBDCHECKFORKEYDIRECT 02 00FFEEA7 KEYBDCLOSE 02 00FFEBEB  KEYBDCLR 00 FFE30402 KEYBDCONTROLCODES 02 00FFE800
4545
 KEYBDECHO 00 FFFFCA00 KEYBDEXTENDEDCODES 02 00FFE880 KEYBDGETID 02 00FFE99C KEYBDGETSCANCODE 02 00FFE97D
4546
 KEYBDGETSTATUS 02 00FFE961 KEYBDHEAD 00 FFFFC800   KEYBDID 00 00000124 KEYBDINIT 02 00FFE9C0
4547
  KEYBDIRQ 02 00FFEA4F KEYBDLOCKS 00 FFFFCD00 KEYBDOPEN 02 00FFEBEA KEYBDREAD 02 00FFEBEC
4548
 KEYBDRECVBYTE 02 00FFE900 KEYBDSEEK 02 00FFEBEE KEYBDSENDBYTE 02 00FFE919 KEYBDSETLED 02 00FFE989
4549
 KEYBDTAIL 00 FFFFC900 KEYBDWAITTX 02 00FFE91F KEYBDWRITE 02 00FFEBED    KEYLED 00 00000122
4550
 KEYSTATE1 00 00000120 KEYSTATE2 00 00000121     KGID1 02 00FFE9B9  KGNOTKBD 02 00FFE9BC
4551
      KRB3 02 00FFE905      KRB4 02 00FFE915    KRCXIT 02 00FFEA4E      KWT1 02 00FFE924
4552
      KWT2 02 00FFE935      LEDS 00 FFE60001    LEDXIT 02 00FFEA22    LETTER 02 00FFD2C1
4553
        LF 00 0000000A MAX_TASKNO 00 0000003F   MF_CRLF 00 00000003 MF_DISPLAYBYTEASHEX 00 00000005
4554
 MF_DISPLAYSTRING 00 00000004 MF_DISPLAYWORDASHEX 00 00000006 MF_GETNUMBER 00 0000000C MF_GETRANGE 00 0000000B
4555
   MF_INCH 00 00000001 MF_MONITOR 00 00000000 MF_OSCALL 00 0000000A  MF_OUTCH 00 00000002
4556
 MF_RANDOM 00 00000009 MF_SHOWSPRITES 00 00000007  MF_SRAND 00 00000008      MON1 02 00FFF08E
4557
 MONARMBREAKPOINT 02 00FFF13A MONDISARMBREAKPOINT 02 00FFF145 MONERRVEC 00 0000080C  MONGETCH 02 00FFF12E
4558
 MONGETNONSPACE 02 00FFF133   MONITOR 02 00FFF039 MON_CCRSAVE 00 0000090F MON_DPRSAVE 00 0000090E
4559
 MON_DSAVE 00 00000900  MON_INIT 00 0000092C MON_NUMWKA 00 00000910 MON_PCSAVE 00 0000090A
4560
    MON_R1 00 00000920    MON_R2 00 00000924  MON_RAND 02 00FFEF9D MON_RETFLAG 00 00000930
4561
 MON_RETTAB 02 00FFF64E MON_ROM_VECS 02 00FFF634 MON_ROM_VECTAB 02 00FFF632 MON_SRAND 02 00FFEF6F
4562
 MON_SRAND1 02 00FFEF72 MON_SSAVE 00 00000908 MON_USAVE 00 00000906 MON_VECTB 00 00000880
4563
 MON_XSAVE 00 00000902 MON_YSAVE 00 00000904   MSCOUNT 00 FFFFFFE4 MSGBADKEYBD 02 00FFEA2E
4564
    MSGERR 02 00FFF2C7 MSGF09STARTING 02 00FFF014 MSGREGHEADINGS 02 00FFF441 MSGS19LOADER 02 00FFEE93
4565
 MSGSERIALTEST 02 00FFED45 MSGSTARTUP 02 00FFE11C MULTI_SIEVE 02 00FFE153 MULTI_SIEVE1 02 00FFE176
4566
 MULTI_SIEVE2 02 00FFE172 MULTI_SIEVE3 02 00FFE160 MULTI_SIEVE4 02 00FFE189     NHEX4 02 00FFF47B
4567
  NMAILBOX 02 00000004 NMESERIAL 02 00FFED0E   NMIBASE 00 00FFC013  NMI_ROUT 02 00FFF818
4568
   NMSGBLK 02 00000008 NOTKBDIRQ 02 00FFEA8C  NOTRXINT 02 00FFED0D NOTTIMERIRQ 02 00FFE4B2
4569
 NUMBREAKPOINTS 02 00FFF631  NUMFUNCS 00 0000000E NUMOSFUNCS 00 00000019 NUMSETBREAKPOINTS 00 00000811
4570
   NXBLANK 02 00FFF47F    ONEKEY 02 00FFD1DC   OPC_SWI 00 0000003F      OSC1 02 00FFF708
4571
 OSCALLTBL 02 00FFEEF6      OSCX 02 00FFF70A    OSSEMA 00 00EF0010     OUTCH 02 00FFEEE1
4572
   OUTSEMA 00 00EF0000 PARSECMD1 02 00FFF0D8     PCRLF 02 00FFE40E     PDATA 02 00FFE41B
4573
       PIC 00 FFE3F000    PICPTR 00 00000028     PRINT 02 00FFE418      PRNG 00 FFE30600
4574
 PROCESSBREAKPOINT 02 00FFF6C0   PROMPT1 02 00FFF0BB  PROMPT2A 02 00FFF10C   PROMPT3 02 00FFF0AC
4575
 PROMPTCLEARSCREEN 02 00FFF126 PROMPTHELP 02 00FFF11E  PROMPTLN 02 00FFF0A8    PSTRNG 02 00FFE40A
4576
     QNDX0 00 00000780     QNDX1 00 00000782     QNDX2 00 00000784     QNDX3 00 00000786
4577
     QNDX4 00 00000788    RAMERR 02 00FFD42C   RAMERR1 02 00FFD445   RAMTEST 02 00FFD400
4578
  RAMTEST1 02 00FFD40D  RAMTEST3 02 00FFD417  REDIRECT 02 00FFF0F8 RELEASEIOFOCUS 02 00FFEF3F
4579
 REQUESTIOFOCUS 02 00FFEF28     RIOF1 02 00FFEF66     RIOF2 02 00FFEF55  ROMTORAM 02 00FFE143
4580
 ROMTORAM1 02 00FFE149      ROWS 00 00000020       RTC 00 FFE30500    RTCBUF 00 00007FC0
4581
  RTCR0001 02 00FFE51A  RTCW0001 02 00FFE565  RTC_READ 02 00FFE4F4 RTC_RXERR 02 00FFE543
4582
 RTC_WRITE 02 00FFE547  RTI_INSN 02 00FFF824 RUNNINGID 00 00FFC013 RUNNINGTCB 06 00000000
4583
  S19ABORT 00 0000094A S19ADDRESS 00 00000940 S19CLEARADDRESS 02 00FFEDA6    S19GA1 02 00FFEDC4
4584
    S19GA2 02 00FFEDE0    S19GB1 02 00FFED81    S19GB2 02 00FFEDA2 S19GETADDRESS2 02 00FFEDB3
4585
 S19GETADDRESS3 02 00FFEDC5 S19GETBYTE 02 00FFED75     S19L2 02 00FFEE90     S19L3 02 00FFEE3F
4586
    S19LNR 02 00FFEE83 S19LOADER 02 00FFEE37 S19NEXTRECORD 02 00FFED58    S19NR1 02 00FFED74
4587
    S19NR2 02 00FFED68    S19NR3 02 00FFED6F    S19PM1 02 00FFEE07    S19PM2 02 00FFEDFD
4588
    S19PM3 02 00FFEDE2 S19PROCESSS1 02 00FFEE0B S19PROCESSS2 02 00FFEE11 S19PROCESSS8 02 00FFEE27
4589
 S19PROCESSS9 02 00FFEE17 S19PUTMEM 02 00FFEDE1 S19RECLEN 00 00000949 S19RECTYPE 00 00000948
4590
 S19STARTADDRESS 00 00000944 SCANNEXTWORD 02 00FFF0E2 SCREENCOLOR 00 00000113 SCREENLOCATION 00 00000010
4591
 SCREENLOCATION2 00 00000018  SCROLLUP 02 00FFE265    SCRUP1 02 00FFE272    SC_ALT 00 00000011
4592 15 robfinch
      SC_C 00 00000021 SC_CAPSLOCK 00 00000058   SC_CTRL 00 00000014    SC_DEL 00 00000071
4593
 SC_EXTEND 00 000000E0    SC_F12 00 00000007  SC_KEYUP 00 000000F0 SC_NUMLOCK 00 00000077
4594
 SC_RSHIFT 00 00000059 SC_SCROLLLOCK 00 0000007E      SC_T 00 0000002C    SC_TAB 00 0000000D
4595
      SC_Z 00 0000001A   SEMAABS 00 00001000 SERHEADRCV 00 00000131 SERHEADXMIT 00 00000136
4596 16 robfinch
  SERHZERO 00 00000130 SERIALGETCHAR 02 00FFEC1D SERIALINIT 02 00FFEBEF SERIALIRQ 02 00FFECBB
4597
 SERIALOUTPUTTEST 02 00FFED25 SERIALPEEKCHAR 02 00FFEC4D SERIALPEEKCHARDIRECT 02 00FFEC64 SERIALPUTCHAR 02 00FFEC88
4598
 SERIALPUTSTRING 02 00FFED15 SERIALRCVCOUNT 02 00FFECA8 SERRCVBUF 00 00BFF000 SERRCVXOFF 00 00000140
4599 15 robfinch
 SERRCVXON 00 00000139 SERTAILRCV 00 00000133 SERTAILXMIT 00 00000138  SERTZERO 00 00000132
4600 16 robfinch
 SETKEYBOARDECHO 02 00FFEEE5      SGC2 02 00FFEC36 SGCNOCHARS 02 00FFEC46    SGCXIT 02 00FFEC49
4601
 SHIFTEDSCANCODES 02 00FFE700 SHIFTLEFT5 02 00FFE1C7 SHL_NUMWKA 02 00FFF1BF SHOWSPRITES 02 00FFEEEB
4602
     SIEVE 02 00FFE18D    SIEVE1 02 00FFE1A5    SIEVE2 02 00FFE1A1    SIEVE3 02 00FFE192
4603
    SIEVE4 02 00FFE1B4     SINI1 02 00FFEC02  SIRQ0001 02 00FFECCD SIRQNXTBYTE 02 00FFECBB
4604
 SIRQRXFULL 02 00FFED0D SKIPDOLLAR 02 00FFF0CA SKIP_INIT 02 00FFE10A    SOTST1 02 00FFED2F
4605
   SPC0001 02 00FFEC8A  SPCD0001 02 00FFEC82 SPCNOCHARS 02 00FFEC5F    SPCXIT 02 00FFEC62
4606
 SPRITE_CTRL 00 FFE10000 SPRITE_EN 00 000003C0      SPS2 02 00FFED19    SPSXIT 02 00FFED23
4607
    SRCXIT 02 00FFECBA       ST1 02 00FFE0B5      ST10 02 00FFE118      ST11 02 00FFE060
4608
       ST3 02 00FFE09F       ST6 02 00FFE03C       ST7 02 00FFE046       ST8 02 00FFE046
4609
       ST9 02 00FFE069     START 02 00FFE023    STRPTR 00 00000024 SWI3_EXIT 02 00FFF803
4610
 SWI3_ROUT 02 00FFF7CB SWICALLOS 02 00FFF6F5 SWINOTBKPT 02 00FFF678  SWI_ROUT 02 00FFF65B
4611
 SWI_ROUT1 02 00FFF660 SWI_ROUT2 02 00FFF671 SWI_ROUT3 02 00FFF6AE SWI_ROUT4 02 00FFF6BF
4612
       TAB 00 00000009 TCB_CURSORCOL 00 00000021 TCB_CURSORROW 00 00000020  TCB_HJCB 00 0000001C
4613
 TCB_HWAITMBX 00 00000022 TCB_IOF_NEXT 00 0000002C TCB_IOF_PREV 00 00000030 TCB_MBQ_NEXT 00 00000024
4614
 TCB_MBQ_PREV 00 00000028 TCB_MMU_MAP 00 00000038 TCB_MSGPTR_D1 00 00000014 TCB_MSGPTR_D2 00 00000018
4615
 TCB_NXTRDY 00 00000000 TCB_NXTTCB 00 00000008 TCB_PRIORITY 00 00000010 TCB_PRVRDY 00 00000004
4616
 TCB_SPSAVE 00 00000034 TCB_STATUS 00 0000001E TCB_TIMEOUT 00 0000000C TEXTCLOSE 02 00FFE235
4617
  TEXTOPEN 02 00FFE234  TEXTREAD 02 00FFE236   TEXTREG 00 FFE07F00   TEXTSCR 00 FFE00000
4618
  TEXTSEEK 02 00FFE238 TEXTWRITE 02 00FFE237 TEXT_COLS 00 00000000 TEXT_CURPOS 00 00000022
4619
 TEXT_ROWS 00 00000001 TIMEOUTLIST 00 0000078C TIMERINIT 02 00FFE465  TIMERIRQ 02 00FFE490
4620
   TIMES10 02 00FFF154      TR1A 02 00FFF817      UCP1 02 00FFE2F0 UNSHIFTEDSCANCODES 02 00FFE600
4621
 UPDATECURSORPOS 02 00FFE2CC       VIA 00 FFE60000   VIA_ACR 00 0000000B  VIA_DDRA 00 00000003
4622
   VIA_IER 00 0000000E   VIA_IFR 00 0000000D    VIA_PA 00 00000001 VIA_T3CMPH 00 00000015
4623
 VIA_T3CMPL 00 00000014  VIA_T3LH 00 00000013  VIA_T3LL 00 00000012  W10_0001 02 00FFE940
4624
 W300_0001 02 00FFE954  WAIT10MS 02 00FFE939 WAIT300MS 02 00FFE94D    XBLANK 02 00FFD0AF
4625
 XITMONITOR 02 00FFF6F3      XOFF 00 00000013       XON 00 00000011
4626
575 SYMBOLS
4627 4 robfinch
 
4628 15 robfinch
3 error(s), 592 warning(s)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.