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

Subversion Repositories rf6809

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

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
                              XON             EQU     $11
87
                              XOFF    EQU     $13
88
 
89
                              FIRST_CORE      EQU     1
90
                              MAX_TASKNO      EQU 63
91
                              DRAM_BASE       EQU $10000000
92
 
93 15 robfinch
                              ; ROM monitor functions
94
                              ;
95
                              MF_Monitor      EQU             0
96
                              MF_INCH                 EQU             1
97
                              MF_OUTCH                EQU     2
98
                              MF_CRLF                 EQU             3
99
                              MF_DisplayString        EQU             4
100
                              MF_DisplayByteAsHex             EQU     5
101
                              MF_DisplayWordAsHex             EQU     6
102
                              MF_ShowSprites  EQU             7
103
                              MF_Srand                EQU             8
104
                              MF_Random               EQU             9
105
                              MF_OSCALL               EQU             10
106
                              MF_GetRange     EQU             11
107
 
108
                              mon_numwka      EQU             $910
109
                              mon_r1          EQU             $920
110
                              mon_r2          EQU             $924
111
                              ; ============================================================================
112
                              ;        __
113
                              ;   \\__/ o\    (C) S2022  Robert Finch, Waterloo
114
                              ;    \  __ /    All rights reserved.
115
                              ;     \/_//     robfinch@opencores.org
116
                              ;       ||
117
                              ;
118
                              ;
119
                              ; BSD 3-Clause License
120
                              ; Redistribution and use in source and binary forms, with or without
121
                              ; modification, are permitted provided that the following conditions are met:
122
                              ;
123
                              ; 1. Redistributions of source code must retain the above copyright notice, this
124
                              ;    list of conditions and the following disclaimer.
125
                              ;
126
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
127
                              ;    this list of conditions and the following disclaimer in the documentation
128
                              ;    and/or other materials provided with the distribution.
129
                              ;
130
                              ; 3. Neither the name of the copyright holder nor the names of its
131
                              ;    contributors may be used to endorse or promote products derived from
132
                              ;    this software without specific prior written permission.
133
                              ;
134
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
135
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
137
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
138
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
139
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
140
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
141
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
142
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
143
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
144
                              ;
145
                              ; ============================================================================
146
 
147
                              COREID  EQU             $FFFFFFFE0
148
                              MSCOUNT EQU             $FFFFFFFE4
149
                              LEDS            EQU             $FFFE60001
150
                              VIA                     EQU             $FFFE60000
151
                              VIA_PA          EQU             1
152
                              VIA_DDRA        EQU             3
153
                              VIA_ACR                 EQU             11
154
                              VIA_IFR                 EQU             13
155
                              VIA_IER                 EQU             14
156
                              VIA_T3LL                EQU             18
157
                              VIA_T3LH                EQU             19
158
                              VIA_T3CMPL      EQU             20
159
                              VIA_T3CMPH      EQU             21
160
                              TEXTSCR         EQU             $FFFE00000
161
                              TEXTREG         EQU             $FFFE07F00
162
                              TEXT_COLS       EQU             0
163
                              TEXT_ROWS       EQU             1
164
                              TEXT_CURPOS     EQU             34
165
                              COLS            EQU             64
166
                              ROWS            EQU             32
167
                              ACIA            EQU             $FFFE30100
168
                              ACIA_TX         EQU             0
169
                              ACIA_RX         EQU             0
170
                              ACIA_STAT       EQU             1
171
                              ACIA_CMD        EQU             2
172
                              ACIA_CTRL       EQU             3
173
                              ACIA_CTRL2      EQU             11
174
                              RTC                             EQU             $FFFE30500      ; I2C
175
                              RTCBuf          EQU             $7FC0
176
                              PRNG            EQU             $FFFE30600
177
                              KEYBD           EQU             $FFFE30400
178
                              KEYBDCLR        EQU             $FFFE30402
179
                              PIC                     EQU             $FFFE3F000
180
                              SPRITE_CTRL             EQU             $FFFE10000
181
                              SPRITE_EN                       EQU             $3C0
182
 
183
                              OUTSEMA EQU     $EF0000
184
                              SEMAABS EQU     $1000
185
                              OSSEMA  EQU     $EF0010
186
 
187 4 robfinch
                              ScreenLocation          EQU             $10
188
                              ColorCodeLocation       EQU             $14
189
                              ScreenLocation2         EQU             $18
190
                              BlkcpySrc                       EQU             $1C
191
                              BlkcpyDst                       EQU             $20
192
                              Strptr                          EQU             $24
193
                              PICptr                          EQU             $28
194
                              ; Forth Area
195
                              ; 0x30-0x60
196
 
197
                              ; Task control blocks, room for 256 tasks
198
                              TCB_NxtRdy              EQU             $00     ; next task on ready / timeout list
199
                              TCB_PrvRdy              EQU             $04     ; previous task on ready / timeout list
200
                              TCB_NxtTCB              EQU             $08
201
                              TCB_Timeout             EQU             $0C
202
                              TCB_Priority    EQU             $10
203
                              TCB_MSGPTR_D1   EQU             $14
204
                              TCB_MSGPTR_D2   EQU             $18
205
                              TCB_hJCB                        EQU             $1C
206
                              TCB_Status              EQU             $1E
207
                              TCB_CursorRow   EQU             $20
208
                              TCB_CursorCol   EQU             $21
209
                              TCB_hWaitMbx    EQU             $22     ; handle of mailbox task is waiting at
210
                              TCB_mbq_next    EQU             $24     ; mailbox queue next
211
                              TCB_mbq_prev    EQU             $28     ; mailbox queue previous
212
                              TCB_iof_next    EQU             $2C
213
                              TCB_iof_prev    EQU             $30
214
                              TCB_SPSave              EQU             $34     ; TCB_SPSave area
215
                              TCB_mmu_map             EQU             $38
216
 
217
                              KeybdHead               EQU             $FFFFFC800
218
                              KeybdTail               EQU             $FFFFFC900
219
                              KeybdEcho               EQU             $FFFFFCA00
220
                              KeybdBad                EQU             $FFFFFCB00
221
                              KeybdAck                EQU             $FFFFFCC00
222
                              KeybdLocks              EQU             $FFFFFCD00
223
                              KeybdBuffer             EQU             $FFFFFC000      ; buffer is 16 chars
224
 
225
                              BIOS_SCREENS    EQU     $17000000       ; $17000000 to $171FFFFF
226
 
227
                              ; EhBASIC vars:
228
                              ;
229 15 robfinch
                              NmiBase         EQU             $FFC013
230
                              IrqBase         EQU             $FFC014
231 4 robfinch
 
232
                              IOFocusNdx      EQU             $100
233
 
234 13 robfinch
                              ; These variables in global OS storage area
235
 
236 15 robfinch
                              IOFocusList     EQU             $FFC000 ; to $FF000F
237
                              IOFocusID               EQU             $FFC010
238
                              IrqSource               EQU             $FFC011
239
                              IRQFlag                 EQU             $FFC012
240
                              RunningID               EQU             $FFC013
241 13 robfinch
 
242 4 robfinch
                              ; These variables use direct page access
243
                              CursorRow       EQU             $110
244
                              CursorCol       EQU             $111
245
                              CharColor       EQU             $112
246
                              ScreenColor     EQU             $113
247
                              CursorFlash     EQU             $114
248
                              KeyState1       EQU     $120
249
                              KeyState2       EQU     $121
250
                              KeyLED          EQU     $122
251
                              KeybdID         EQU     $124
252 13 robfinch
                              KeybdBlock      EQU     $126
253
                              kbdHeadRcv      EQU     $127
254
                              kbdTailRcv      EQU     $128
255
                              kbdFifo                 EQU     $40                             ; in local RAM
256
                              kbdFifoAlias    EQU     $C00040 ; to $C0007F    ; alias for $40 to $7F
257
                              SerhZero                EQU     $130
258
                              SerHeadRcv      EQU     $131
259
                              SertZero                EQU     $132
260
                              SerTailRcv      EQU     $133
261
                              SerHeadXmit     EQU     $136
262
                              SerTailXmit     EQU     $138
263
                              SerRcvXon               EQU     $139
264
                              SerRcvXoff      EQU     $140
265
                              SerRcvBuf               EQU     $BFF000 ; 4kB serial recieve buffer
266 4 robfinch
 
267 14 robfinch
                              farflag EQU             $15F
268 13 robfinch
                              asmbuf  EQU             $160    ; to $17F
269
 
270 4 robfinch
                              QNdx0           EQU             $780
271
                              QNdx1           EQU             QNdx0+2
272
                              QNdx2           EQU             QNdx1+2
273
                              QNdx3           EQU             QNdx2+2
274
                              QNdx4           EQU             QNdx3+2
275
                              FreeTCB         EQU             QNdx4+2
276
                              TimeoutList     EQU             FreeTCB+2
277
                              FreeMbx         EQU             RunningTCB + 2
278
                              nMailbox        EQU             FreeMbx + 2
279
                              FreeMsg         EQU             nMailbox + 2
280
                              nMsgBlk         EQU             FreeMsg + 2
281
 
282
 
283
                              CharOutVec      EQU             $800
284
                              CharInVec       EQU             $804
285 13 robfinch
                              CmdPromptJI     EQU     $808
286 14 robfinch
                              MonErrVec       EQU             $80C
287 15 robfinch
                              BreakpointFlag  EQU             $810
288
                              NumSetBreakpoints       EQU     $811
289
                              Breakpoints                     EQU             $820    ; to $82F
290
                              BreakpointBytes EQU             $830    ; to $83F
291
                              mon_vectb                               EQU             $880
292 4 robfinch
 
293
                              ; Register save area for monitor
294
                              mon_DSAVE       EQU             $900
295
                              mon_XSAVE       EQU             $902
296
                              mon_YSAVE       EQU             $904
297
                              mon_USAVE       EQU             $906
298
                              mon_SSAVE       EQU             $908
299
                              mon_PCSAVE      EQU             $90A
300
                              mon_DPRSAVE     EQU             $90E
301
                              mon_CCRSAVE     EQU             $90F
302
 
303
                              mon_numwka      EQU             $910
304
                              mon_r1          EQU             $920
305 13 robfinch
                              mon_r2          EQU             $924
306 15 robfinch
                              jmpvec          EQU             $928
307 4 robfinch
 
308
                              ; The ORG directive must set an address a multiple of 4 in order for the Verilog
309
                              ; output to work correctly.
310
 
311
                                      org             $FFD0AC
312
 00FFD0AC 012                             nop
313
 00FFD0AD 012                             nop
314
 00FFD0AE 012                             nop
315
                              XBLANK
316
 00FFD0AF 0C6020                          ldb             #' '
317 13 robfinch
 00FFD0B1 017001C5E                       lbsr    OUTCH
318 4 robfinch
 00FFD0B4 039                             rts
319
 
320
                                      org             $FFD0D0
321
 00FFD0D0 012                             nop
322
 00FFD0D1 012                             nop
323
                              CRLF
324
                              CRLF1:
325
 00FFD0D2 0C600D                          ldb             #CR
326 13 robfinch
 00FFD0D4 017001C3B                       lbsr    OUTCH
327 4 robfinch
 00FFD0D7 0C600A                          ldb             #LF
328 13 robfinch
 00FFD0D9 017001C36                       lbsr    OUTCH
329 4 robfinch
 00FFD0DC 039                             rts
330
 
331
                                      org             $FFD0F0
332
 00FFD0F0 012                             nop
333
 00FFD0F1 020FDF                          bra             CRLF1
334
 
335
                                      org             $FFD1DC
336
                              ONEKEY
337
 00FFD1DC 06E90F000804                    jmp             [CharInVec]
338
 
339
                                      org             $FFD2C0
340
 00FFD2C0 012                             nop
341
                              LETTER
342 13 robfinch
 00FFD2C1 017001A4E                       lbsr    OUTCH
343 4 robfinch
 00FFD2C4 039                             rts
344
 
345
                                      org             $FFD2CC
346
 00FFD2CC 012                             nop
347
 00FFD2CD 012                             nop
348
                              HEX2
349 15 robfinch
 00FFD2CE 017001142                       lbsr    DispByteAsHex
350 4 robfinch
 00FFD2D1 039                             rts
351
                              HEX4
352 15 robfinch
 00FFD2D2 017001135                       lbsr    DispWordAsHex
353 4 robfinch
 00FFD2D5 039                             rts
354
 
355
                                      org             $FFD300
356
                              ClearScreenJmp
357 15 robfinch
 00FFD300 016000F2B                       lbra    ClearScreen
358 4 robfinch
                                      org             $FFD308
359
                              HomeCursorJmp
360 15 robfinch
 00FFD308 016000F96                       lbra    HomeCursor
361 4 robfinch
 
362 13 robfinch
                                      org             $FFD400
363 4 robfinch
 
364
                              ; Local RAM test routine
365
                              ; Checkerboard testing.
366
                              ; There is 70kB of local RAM
367
                              ; Does not use any RAM including no stack
368
 
369
                              ramtest:
370 13 robfinch
 00FFD400 18E000000                       ldy             #0
371
 00FFD403 086001                          lda             #1
372
 00FFD405 0150B7FFFE60001                 sta             LEDS
373
 00FFD40A 0CCAAA555                       ldd             #$AAA555
374 4 robfinch
                              ramtest1:
375 13 robfinch
 00FFD40D 0EDA01                          std             ,y++
376
 00FFD40F 18C008000                       cmpy    #$8000
377
 00FFD412 025FF9                          blo             ramtest1
378 4 robfinch
                                      ; now readback values and compare
379 13 robfinch
 00FFD414 18E000000                       ldy             #0
380 4 robfinch
                              ramtest3:
381 13 robfinch
 00FFD417 0ECA01                          ldd             ,y++
382
 00FFD419 183AAA555                       cmpd    #$AAA555
383
 00FFD41C 02600E                          bne             ramerr
384
 00FFD41E 18C008000                       cmpy    #$8000
385
 00FFD421 025FF4                          blo             ramtest3
386
 00FFD423 086002                          lda             #2
387
 00FFD425 0150B7FFFE60001                 sta             LEDS
388
 00FFD42A 06EC04                          jmp             ,u
389 4 robfinch
                              ramerr:
390 13 robfinch
 00FFD42C 086080                          lda             #$80
391
 00FFD42E 0150B7FFFE60001                 sta             LEDS
392
 00FFD433 08EE00000                       ldx             #TEXTSCR
393
 00FFD436 0150F6FFFFFFFE0                 ldb             COREID
394
 00FFD43B 03A                             abx
395
 00FFD43C 086046                          lda             #'F'
396
 00FFD43E 0A7804                          sta             ,x
397
 00FFD440 013                             sync
398
 00FFD441 06EC04                          jmp             ,u
399 4 robfinch
 
400 15 robfinch
                              dramtest:
401
 00FFD443 18E010000                       ldy             #$10000                 ; DRAM starts here
402
 00FFD446 086001                          lda             #1
403
 00FFD448 0150B7FFFE60001                 sta             LEDS
404
 00FFD44D 0CEAAA555                       ldu             #$AAA555
405
 00FFD450 017FFFC7F                       lbsr    CRLF
406
*** warning 1: Long branch within short branch range could be optimized
407
                              dramtest1:
408
 00FFD453 04A                             deca
409
 00FFD454 02600A                          bne             dramtest4
410
 00FFD456 01F020                          tfr             y,d
411
 00FFD458 017000FAF                       lbsr    DispWordAsHex
412
 00FFD45B 0C600D                          ldb             #CR
413
 00FFD45D 0170018B2                       lbsr    OUTCH
414
                              dramtest4:
415
 00FFD460 0EFA01                          stu             ,y++
416
 00FFD462 18CE00000                       cmpy    #$E00000                ; DRAM ends here
417
 00FFD465 025FEC                          blo             dramtest1
418
                                      ; now readback values and compare
419
 00FFD467 18E010000                       ldy             #$10000
420
 00FFD46A 086001                          lda             #1
421
 00FFD46C 017FFFC63                       lbsr    CRLF
422
*** warning 1: Long branch within short branch range could be optimized
423
                              dramtest3:
424
 00FFD46F 04A                             deca
425
 00FFD470 02600A                          bne             dramtest5
426
 00FFD472 01F020                          tfr             y,d
427
 00FFD474 017000F93                       lbsr    DispWordAsHex
428
 00FFD477 0C600D                          ldb             #CR
429
 00FFD479 017001896                       lbsr    OUTCH
430
                              dramtest5:
431
 00FFD47C 2A3A01                          cmpu    ,y++
432
 00FFD47E 02600F                          bne             dramerr
433
 00FFD480 18CE00000                       cmpy    #$E00000
434
 00FFD483 025FEA                          blo             dramtest3
435
 00FFD485 086002                          lda             #2
436
 00FFD487 0150B7FFFE60001                 sta             LEDS
437
 00FFD48C 016001A18                       lbra    Monitor
438
                              dramerr:
439
 00FFD48F 086080                          lda             #$80
440
 00FFD491 0150B7FFFE60001                 sta             LEDS
441
 00FFD496 08EE00000                       ldx             #TEXTSCR
442
 00FFD499 0150F6FFFFFFFE0                 ldb             COREID
443
 00FFD49E 03A                             abx
444
 00FFD49F 086046                          lda             #'F'
445
 00FFD4A1 0A7804                          sta             ,x
446
 00FFD4A3 016001A01                       lbra    Monitor
447
 
448 13 robfinch
                                      org             $FFE000
449 15 robfinch
 00FFE000 FFEEA7                          FDB Monitor
450 13 robfinch
 00FFE002 FFE022                          FDB DumRts      ;       NEXTCMD
451
 00FFE004 FFECDA                          FDB INCH
452
 00FFE006 FFECF8                          FDB INCHE
453
 00FFE008 FFECFC                          FDB INCHEK
454
 00FFE00A FFED12                          FDB OUTCH
455 15 robfinch
 00FFE00C FFE3F7                          FDB PDATA
456
 00FFE00E FFE3EA                          FDB PCRLF
457
 00FFE010 FFE3E6                          FDB PSTRNG
458 13 robfinch
 00FFE012 FFE022                          FDB DumRts                      ; LRA
459
 00FFE014 FFE022                          FDB DumRts
460
 00FFE016 FFE022                          FDB DumRts
461
 00FFE018 FFE022                          FDB DumRts
462
 00FFE01A FFE022                          FDB DumRts                      ; VINIZ
463 15 robfinch
 00FFE01C FFE2FE                          FDB DisplayChar ;       VOUTCH
464 13 robfinch
 00FFE01E FFE022                          FDB DumRts                      ; ACINIZ
465
 00FFE020 FFE022                          FDB DumRts                      ; AOUTCH
466 4 robfinch
 
467
                              DumRts:
468 13 robfinch
 00FFE022 039                             rts
469 4 robfinch
 
470
                              ;------------------------------------------------------------------------------
471
                              ;------------------------------------------------------------------------------
472
 
473
                              start:
474 13 robfinch
 00FFE023 086FFF                          lda             #$FFF                   ; all cores can do this
475
 00FFE025 0150B7FFFE60003                 sta             VIA+VIA_DDRA
476
 00FFE02A 086055                          lda             #$55                    ; see if we can at least set LEDs
477
 00FFE02C 0150B7FFFE60001                 sta             LEDS
478
 00FFE031 086001                          lda             #1                              ; prime OS semaphore
479
 00FFE033 0B7EF1010                       sta             OSSEMA+$1000
480 15 robfinch
 00FFE036 0B7EF1000                       sta             OUTSEMA+$1000
481
 00FFE039 0CEFFE03F                       ldu             #st6                    ; U = return address
482
 00FFE03C 07EFFD400                       jmp             ramtest         ; JMP dont JSR
483 4 robfinch
                              st6:
484 15 robfinch
 00FFE03F 1CE006FFF                       lds             #$6FFF          ; boot up stack area
485
 00FFE042 0150B6FFFFFFFE0                 lda             COREID
486
 00FFE047 081001                          cmpa    #FIRST_CORE
487 4 robfinch
                              ;       beq             st8
488
                              ;       sync                                            ; halt cores other than 2
489
                              st8:
490
                              ;       bne             skip_init
491
                              ;       bsr             romToRam
492
                              ;       ldd             #st7 & $FFFF
493
                              ;       tfr             d,x
494
                              ;       jmp             ,x                              ; jump to the BIOS now in local RAM
495
                              st7:
496 15 robfinch
 00FFE049 08D15F                          bsr             Delay3s         ; give some time for devices to reset
497
 00FFE04B 07F000810                       clr             BreakpointFlag
498
 00FFE04E 07F000811                       clr             NumSetBreakpoints
499
 00FFE051 0860AA                          lda             #$AA
500
 00FFE053 0150B7FFFE60001                 sta             LEDS
501
 00FFE058 086001                          lda             #FIRST_CORE
502
 00FFE05A 0B7FFC010                       sta             IOFocusID       ; core #2 has focus
503
 00FFE05D 0B7FFC013                       sta             RunningID
504 14 robfinch
                                      ; Clear IO focus list
505 15 robfinch
 00FFE060 08E000000                       ldx             #0
506 14 robfinch
                              st9:
507 15 robfinch
 00FFE063 06F80A000FFC000                 clr             IOFocusList,x
508
 00FFE068 030001                          inx
509
 00FFE06A 08C000010                       cmpx    #16
510
 00FFE06D 025FF4                          blo             st9
511
 00FFE06F 086018                          lda             #24
512
 00FFE071 0B7FFC001                       sta             IOFocusList+FIRST_CORE
513 14 robfinch
 
514 15 robfinch
 00FFE074 0860CE                          lda             #$0CE
515
 00FFE076 097113                          sta             ScreenColor
516
 00FFE078 097112                          sta             CharColor
517
 00FFE07A 08D1B2                          bsr             ClearScreen
518
 00FFE07C 0CCFFE2FE                       ldd             #DisplayChar
519
 00FFE07F 0FD000800                       std             CharOutVec
520
 00FFE082 0CCFFEBE4                       ldd             #SerialPeekCharDirect
521
 00FFE085 0FD000804                       std             CharInVec
522
                              ;       swi
523
                              ;       fcb             MF_OSCALL
524
                              ;       fcb             24                                      ; request IO focus
525
 00FFE088 0150F6FFFFFFFE0                 ldb             COREID
526
 00FFE08D 0C1001                          cmpb    #FIRST_CORE
527
 00FFE08F 02700D                          beq             init
528
 00FFE091 02004B                          bra             skip_init
529
 00FFE093 0200B3                          bra             multi_sieve
530 4 robfinch
                              st3:
531 15 robfinch
 00FFE095 0860FF                          lda             #$FF
532
 00FFE097 0150B7FFFE60001                 sta             LEDS
533
 00FFE09C 020FF7                          bra             st3
534 4 robfinch
 
535
                                      ; initialize interrupt controller
536
                                      ; first, zero out all the vectors
537
                              init:
538 15 robfinch
 00FFE09E 01700042F                       lbsr    rtc_read        ; get clock values
539
 00FFE0A1 08E000127                       ldx             #kbdHeadRcv
540
 00FFE0A4 0C6020                          ldb             #32                             ; number of bytes to zero out
541 13 robfinch
                              init1:
542 15 robfinch
 00FFE0A6 06F800                          clr             ,x+
543
 00FFE0A8 05A                             decb
544
 00FFE0A9 026FFB                          bne             init1
545
 00FFE0AB 017000393                       lbsr    TimerInit
546
 00FFE0AE 017000ABE                       lbsr    InitSerial
547
 00FFE0B1 08E000080                       ldx             #128
548
 00FFE0B4 086001                          lda             #1                      ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
549
 00FFE0B6 0C6001                          ldb             #FIRST_CORE                     ; serving core id
550 4 robfinch
                              st1:
551 15 robfinch
 00FFE0B8 06F809E3F000                    clr             PIC,x                   ; cause code
552
 00FFE0BC 0A7809E3F001                    sta             PIC+1,x
553
 00FFE0C0 0E7809E3F002                    stb             PIC+2,x
554
 00FFE0C4 030004                          leax    4,x
555
 00FFE0C6 08C000100                       cmpx    #256
556
 00FFE0C9 025FED                          blo             st1
557 4 robfinch
                              ;       lda             #4                              ; make the timer interrupt edge sensitive
558
                              ;       sta             PIC+4                   ; reg #4 is the edge sensitivity setting
559
                              ;       sta             PIC                             ; reg #0 is interrupt enable
560 15 robfinch
 00FFE0CB 086081                          lda             #$81                    ; make irq edge sensitive
561
 00FFE0CD 0150B7FFFE3F0FD                 sta             PIC+$FD
562
 00FFE0D2 08601F                          lda             #31                             ; enable timer interrupt
563
 00FFE0D4 0150B7FFFE3F009                 sta             PIC+9
564
 00FFE0D9 0C6001                          ldb             #1
565
 00FFE0DB 0F7EF1000                       stb             OUTSEMA+SEMAABS ; set semaphore to 1 available slot
566 4 robfinch
                              skip_init:
567 15 robfinch
 00FFE0DE 01C0EF                          andcc   #$EF                    ; unmask irq
568
 00FFE0E0 086040                          lda             #COLS
569
 00FFE0E2 0150B7FFFE07F00                 sta             TEXTREG+TEXT_COLS
570
 00FFE0E7 086020                          lda             #ROWS
571
 00FFE0E9 0150B7FFFE07F01                 sta             TEXTREG+TEXT_ROWS
572
 00FFE0EE 08D13E                          bsr             ClearScreen
573
 00FFE0F0 08D1AF                          bsr             HomeCursor
574
 00FFE0F2 086005                          lda             #5
575
 00FFE0F4 0150B7FFFE60001                 sta             LEDS
576
 00FFE0F9 0CCFFE111                       ldd             #msgStartup
577
 00FFE0FC 08D2C1                          bsr             DisplayString
578
 00FFE0FE 08E000000                       ldx             #0
579
 00FFE101 0CC000000                       ldd             #0
580
 00FFE104 017000C15                       lbsr    ShowSprites
581
 00FFE107 017000836                       lbsr    KeybdInit
582
 00FFE10A 0DC124                          ldd             KeybdID
583
 00FFE10C 08D2FC                          bsr             DispWordAsHex
584
 00FFE10E 07EFFEE60                       jmp             MonitorStart
585 4 robfinch
 
586
                              msgStartup
587 15 robfinch
 00FFE111 072066036038030039020           fcb             "rf6809 12-bit System Starting.",CR,LF,0
588
 00FFE118 03103202D062069074020
589
 00FFE11F 05307907307406506D020
590
 00FFE126 05307406107207406906E
591
 00FFE12D 06702E00D00A000
592 4 robfinch
 
593
                              ;------------------------------------------------------------------------------
594
                              ; The checkpoint register must be cleared within 1 second or a NMI interrupt
595
                              ; will occur. checkpoint should be called with a JSR so that the global ROM
596
                              ; routine is called.
597
                              ;
598
                              ; Modifies:
599
                              ;               none
600
                              ;------------------------------------------------------------------------------
601
 
602
                              checkpoint:
603 15 robfinch
 00FFE132 01507FFFFFFFFE1                 clr             $FFFFFFFE1      ; writing any value will do
604
 00FFE137 039                             rts
605 4 robfinch
 
606
                              ;------------------------------------------------------------------------------
607
                              ; Copy the system ROM to local RAM
608
                              ; Running the code from local RAM is probably an order of magnitude faster
609
                              ; then running from the global ROM. It also reduces the network traffic to
610
                              ; run from local RAM.
611
                              ;
612
                              ; Modifies:
613
                              ;               d,x,y
614
                              ;------------------------------------------------------------------------------
615
 
616
                              romToRam:
617 15 robfinch
 00FFE138 08EFFC000                       ldx             #$FFC000
618
 00FFE13B 18E00C000                       ldy             #$00C000
619 4 robfinch
                              romToRam1:
620 15 robfinch
 00FFE13E 0EC801                          ldd             ,x++
621
 00FFE140 0EDA01                          std             ,y++
622
 00FFE142 08C000000                       cmpx    #0
623
 00FFE145 026FF7                          bne             romToRam1
624
 00FFE147 039                             rts
625 4 robfinch
 
626
                              ;------------------------------------------------------------------------------
627
                              ; Multi-core sieve program.
628
                              ;------------------------------------------------------------------------------
629
 
630
                              ; First fill screen chars with 'P' indicating prime positions
631
                              ; Each core is responsible for the Nth position where N is the
632
                              ; core number minus two.
633
                              ;
634
                              multi_sieve:
635 15 robfinch
 00FFE148 086050                          lda             #'P'                                    ; indicate prime
636
 00FFE14A 0150F6FFFFFFFE0                 ldb             COREID                          ; find out which core we are
637
 00FFE14F 0C0001                          subb    #FIRST_CORE
638
 00FFE151 08E000000                       ldx             #0                                              ; start at first char of screen
639
 00FFE154 03A                             abx
640 4 robfinch
                              multi_sieve3:
641 15 robfinch
 00FFE155 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
642
 00FFE159 030008                          leax    8,x                                             ; advance to next position
643
 00FFE15B 08C000FFF                       cmpx    #4095
644
 00FFE15E 025FF5                          blo             multi_sieve3
645
 00FFE160 0BDFFE132                       jsr             checkpoint
646 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
647 15 robfinch
 00FFE163 0CB002                          addb    #2                                              ; start sieve at 2 (core id)
648
 00FFE165 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
649 4 robfinch
                              multi_sieve2:
650 15 robfinch
 00FFE167 08E000000                       ldx             #0
651
 00FFE16A 03A                             abx                                                                     ; skip the first position - might be prime
652 4 robfinch
                              multi_sieve1:
653 15 robfinch
 00FFE16B 03A                             abx                                                                     ; increment
654
 00FFE16C 0A7809E00000                    sta             TEXTSCR,x
655
 00FFE170 08C000FFF                       cmpx    #4095
656
 00FFE173 025FF6                          blo             multi_sieve1
657
 00FFE175 0BDFFE132                       jsr             checkpoint
658 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
659 15 robfinch
 00FFE178 0CB008                          addb    #8                                              ; number of cores working on it
660
 00FFE17A 0C1FF0                          cmpb    #4080
661
 00FFE17C 025FE9                          blo             multi_sieve2
662 4 robfinch
                              multi_sieve4:                                   ; hang machine
663 15 robfinch
 00FFE17E 013                             sync
664
 00FFE17F 016000D25                       lbra    Monitor
665 4 robfinch
 
666 13 robfinch
                              ;------------------------------------------------------------------------------
667
                              ; Single core sieve.
668
                              ;------------------------------------------------------------------------------
669
 
670 4 robfinch
                              sieve:
671 15 robfinch
 00FFE182 086050                          lda             #'P'                                    ; indicate prime
672
 00FFE184 08E000000                       ldx             #0                                              ; start at first char of screen
673 4 robfinch
                              sieve3:
674 15 robfinch
 00FFE187 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
675
 00FFE18B 030001                          inx                                                                     ; advance to next position
676
 00FFE18D 08C000FFF                       cmpx    #4095
677
 00FFE190 025FF5                          blo             sieve3
678
 00FFE192 0C6002                          ldb             #2                                              ; start sieve at 2
679
 00FFE194 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
680 4 robfinch
                              sieve2:
681 15 robfinch
 00FFE196 08E000000                       ldx             #0
682
 00FFE199 03A                             abx                                                                     ; skip the first position - might be prime
683 4 robfinch
                              sieve1:
684 15 robfinch
 00FFE19A 03A                             abx                                                                     ; increment
685
 00FFE19B 0A7809E00000                    sta             TEXTSCR,x
686
 00FFE19F 08C000FFF                       cmpx    #4095
687
 00FFE1A2 025FC7                          blo             multi_sieve1
688
 00FFE1A4 05C                             incb                                                            ; number of cores working on it
689
 00FFE1A5 0C1FF0                          cmpb    #4080
690
 00FFE1A7 025FED                          blo             sieve2
691 4 robfinch
                              sieve4:                                                         ; hang machine
692 15 robfinch
 00FFE1A9 039                             rts
693 4 robfinch
 
694
                              ;------------------------------------------------------------------------------
695
                              ; Three second delay for user convenience and to allow some devices time to
696
                              ; reset.
697
                              ;------------------------------------------------------------------------------
698
 
699
                              Delay3s:
700 15 robfinch
 00FFE1AA 0CC895440                       ldd             #9000000
701 4 robfinch
                              dly3s1:
702 15 robfinch
 00FFE1AD 0C10FF                          cmpb    #$FF
703
 00FFE1AF 026000                          bne             dly3s2
704 4 robfinch
                              dly3s2:
705 15 robfinch
 00FFE1B1 0150B7FFFE60001                 sta             LEDS
706
 00FFE1B6 083000001                       subd    #1
707
 00FFE1B9 026FF2                          bne             dly3s1
708
 00FFE1BB 039                             rts
709 4 robfinch
 
710
                              ;------------------------------------------------------------------------------
711
                              ;------------------------------------------------------------------------------
712
                              ShiftLeft5:
713 15 robfinch
 00FFE1BC 058                             aslb
714
 00FFE1BD 049                             rola
715
 00FFE1BE 058                             aslb
716
 00FFE1BF 049                             rola
717
 00FFE1C0 058                             aslb
718
 00FFE1C1 049                             rola
719
 00FFE1C2 058                             aslb
720
 00FFE1C3 049                             rola
721
 00FFE1C4 058                             aslb
722
 00FFE1C5 049                             rola
723
 00FFE1C6 039                             rts
724 4 robfinch
 
725
                              ;------------------------------------------------------------------------------
726 13 robfinch
                              ; Parameters:
727
                              ;               b = core id of core to copy
728 4 robfinch
                              ;------------------------------------------------------------------------------
729
                              ;
730
                              CopyVirtualScreenToScreen:
731 15 robfinch
 00FFE1C7 034076                          pshs    d,x,y,u
732 13 robfinch
                                      ; Compute virtual screen location for core passed in accb.
733 15 robfinch
 00FFE1C9 01F098                          tfr             b,a
734
 00FFE1CB 048                             asla
735
 00FFE1CC 048                             asla
736
 00FFE1CD 048                             asla
737
 00FFE1CE 048                             asla
738
 00FFE1CF 08AC00                          ora             #$C00
739
 00FFE1D1 05F                             clrb
740
 00FFE1D2 01F001                          tfr             d,x
741
 00FFE1D4 034006                          pshs    d
742
 00FFE1D6 18EE00000                       ldy             #TEXTSCR
743
 00FFE1D9 0CE000400                       ldu             #COLS*ROWS/2
744 4 robfinch
                              cv2s1:
745 15 robfinch
 00FFE1DC 0EC801                          ldd             ,x++
746
 00FFE1DE 0EDA01                          std             ,y++
747
 00FFE1E0 0335FF                          leau    -1,u
748
 00FFE1E2 283000000                       cmpu    #0
749
 00FFE1E5 026FF5                          bne             cv2s1
750 4 robfinch
                                      ; reset the cursor position in the text controller
751 15 robfinch
 00FFE1E7 035010                          puls    x
752
 00FFE1E9 0E6808110                       ldb             CursorRow,x
753
 00FFE1EC 086040                          lda             #COLS
754
 00FFE1EE 03D                             mul
755
 00FFE1EF 01F002                          tfr             d,y
756
 00FFE1F1 0E6808111                       ldb             CursorCol,x
757
 00FFE1F4 01F021                          tfr             y,x
758
 00FFE1F6 03A                             abx
759
 00FFE1F7 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
760
 00FFE1FC 0350F6                          puls    d,x,y,u,pc
761 4 robfinch
 
762
                              ;------------------------------------------------------------------------------
763
                              ;------------------------------------------------------------------------------
764
                              ;
765
                              CopyScreenToVirtualScreen:
766 15 robfinch
 00FFE1FE 034076                          pshs    d,x,y,u
767
 00FFE200 08D08D                          bsr             GetScreenLocation
768
 00FFE202 01F002                          tfr             d,y
769
 00FFE204 08EE00000                       ldx             #TEXTSCR
770
 00FFE207 0CE000400                       ldu             #COLS*ROWS/2
771 4 robfinch
                              cs2v1:
772 15 robfinch
 00FFE20A 0EC801                          ldd             ,x++
773
 00FFE20C 0EDA01                          std             ,y++
774
 00FFE20E 0335FF                          leau    -1,u
775
 00FFE210 283000000                       cmpu    #0
776
 00FFE213 026FF5                          bne             cs2v1
777
 00FFE215 0350F6                          puls    d,x,y,u,pc
778 4 robfinch
 
779
                              ;------------------------------------------------------------------------------
780
                              ;------------------------------------------------------------------------------
781 15 robfinch
 00FFE217 054045058054053043052           fcb             "TEXTSCR "
782
 00FFE21E 020
783
 00FFE21F FFE229                          fcw             TextOpen
784
 00FFE221 FFE22A                          fcw             TextClose
785
 00FFE223 FFE22B                          fcw             TextRead
786
 00FFE225 FFE22C                          fcw             TextWrite
787
 00FFE227 FFE22D                          fcw             TextSeek
788 4 robfinch
 
789
                              TextOpen:
790 15 robfinch
 00FFE229 039                             rts
791 4 robfinch
                              TextClose:
792 15 robfinch
 00FFE22A 039                             rts
793 4 robfinch
                              TextRead:
794 15 robfinch
 00FFE22B 039                             rts
795 4 robfinch
                              TextWrite:
796 15 robfinch
 00FFE22C 039                             rts
797 4 robfinch
                              TextSeek:
798 15 robfinch
 00FFE22D 039                             rts
799 4 robfinch
 
800
                              ;------------------------------------------------------------------------------
801
                              ; Clear the screen and the screen color memory
802
                              ; We clear the screen to give a visual indication that the system
803
                              ; is working at all.
804
                              ;
805
                              ; Modifies:
806
                              ;               none
807
                              ;------------------------------------------------------------------------------
808
 
809
                              ClearScreen:
810 15 robfinch
 00FFE22E 034076                          pshs    d,x,y,u
811
 00FFE230 08E000800                       ldx             #COLS*ROWS
812
 00FFE233 01F013                          tfr             x,u
813
 00FFE235 08D058                          bsr             GetScreenLocation
814
 00FFE237 01F002                          tfr             d,y
815
 00FFE239 0C6020                          ldb             #' '                            ; space char
816 4 robfinch
                              cs1:
817 15 robfinch
 00FFE23B 0E7A00                          stb             ,y+                                     ; set text to space
818
 00FFE23D 0301FF                          leax    -1,x                            ; decrement x
819
 00FFE23F 026FFA                          bne             cs1
820
 00FFE241 0150F6FFFFFFFE0                 ldb             COREID                  ; update colors only if we have focus
821
 00FFE246 0F1FFC010                       cmpb    IOFocusID
822
 00FFE249 02000D                          bra             cs3
823
 00FFE24B 18EE02000                       ldy             #TEXTSCR+$2000
824 4 robfinch
                              ;       lda             CharColor
825 15 robfinch
 00FFE24E 0860CE                          lda             #$0CE
826
 00FFE250 01F031                          tfr             u,x                                     ; get back count
827 4 robfinch
                              cs2:
828 15 robfinch
 00FFE252 0A7A00                          sta             ,y+
829
 00FFE254 0301FF                          dex                                                             ; decrement x
830
 00FFE256 026FFA                          bne             cs2
831 4 robfinch
                              cs3:
832 15 robfinch
 00FFE258 0350F6                          puls    d,x,y,u,pc
833 4 robfinch
 
834
                              ;------------------------------------------------------------------------------
835
                              ; Scroll text on the screen upwards
836
                              ;
837
                              ; Modifies:
838
                              ;               none
839
                              ;------------------------------------------------------------------------------
840
 
841
                              ScrollUp:
842 15 robfinch
 00FFE25A 034076                          pshs    d,x,y,u
843
 00FFE25C 18E0003FF                       ldy             #(COLS*ROWS-1)/2        ; y = num chars/2 to move
844
 00FFE25F 08D02E                          bsr             GetScreenLocation
845
 00FFE261 01F001                          tfr             d,x
846
 00FFE263 01F003                          tfr             d,u
847
 00FFE265 030040                          leax    COLS,x          ; x = index to source row
848 4 robfinch
                              scrup1:
849 15 robfinch
 00FFE267 0EC801                          ldd             ,x++                    ; move 2 characters
850
 00FFE269 0EDC01                          std             ,u++
851
 00FFE26B 0313FF                          dey
852
 00FFE26D 026FF8                          bne             scrup1
853
 00FFE26F 08601F                          lda             #ROWS-1
854
 00FFE271 08D002                          bsr             BlankLine
855
 00FFE273 0350F6                          puls    d,x,y,u,pc
856 4 robfinch
 
857
                              ;------------------------------------------------------------------------------
858
                              ; Blank out a line on the display
859
                              ;
860
                              ; Modifies:
861
                              ;               none
862
                              ; Parameters:
863
                              ;       acca = line number to blank
864
                              ;------------------------------------------------------------------------------
865
 
866
                              BlankLine:
867 15 robfinch
 00FFE275 034016                          pshs    d,x
868
 00FFE277 034002                          pshs    a
869
 00FFE279 08D014                          bsr             GetScreenLocation
870
 00FFE27B 01F001                          tfr             d,x
871
 00FFE27D 035002                          puls    a
872
 00FFE27F 0C6040                          ldb             #COLS   ; b = # chars to blank out from video controller
873
 00FFE281 03D                             mul                                     ; d = screen index (row# * #cols)
874
 00FFE282 03080B                          leax    d,x
875
 00FFE284 086020                          lda             #' '
876
 00FFE286 0C6040                          ldb             #COLS   ; b = # chars to blank out from video controller
877 4 robfinch
                              blnkln1:
878 15 robfinch
 00FFE288 0A7800                          sta             ,x+
879
 00FFE28A 05A                             decb
880
 00FFE28B 026FFB                          bne             blnkln1
881
 00FFE28D 035096                          puls    d,x,pc
882 4 robfinch
 
883
                              ;------------------------------------------------------------------------------
884
                              ; Get the location of the screen memory. The location
885
                              ; depends on whether or not the task has the output focus.
886
                              ;
887
                              ; Modifies:
888
                              ;               d
889
                              ; Retuns:
890
                              ;               d = screen location
891
                              ;------------------------------------------------------------------------------
892
 
893
                              GetScreenLocation:
894 15 robfinch
 00FFE28F 0150B6FFFFFFFE0                 lda             COREID                  ; which core are we?
895
 00FFE294 0B1FFC010                       cmpa    IOFocusID               ; do we have the IO focus
896
 00FFE297 026004                          bne             gsl1                            ; no, go pick virtual screen address
897
 00FFE299 0CCE00000                       ldd             #TEXTSCR                ; yes, we update the real screen
898
 00FFE29C 039                             rts
899 4 robfinch
                              gsl1:
900 15 robfinch
 00FFE29D 0CC007800                       ldd             #$7800
901
 00FFE2A0 039                             rts
902 4 robfinch
 
903
                              ;------------------------------------------------------------------------------
904
                              ; HomeCursor
905
                              ; Set the cursor location to the top left of the screen.
906
                              ;
907
                              ; Modifies:
908
                              ;               none
909
                              ;------------------------------------------------------------------------------
910
 
911
                              HomeCursor:
912 15 robfinch
 00FFE2A1 034016                          pshs    d,x
913
 00FFE2A3 00F110                          clr             CursorRow
914
 00FFE2A5 00F111                          clr             CursorCol
915
 00FFE2A7 0150F6FFFFFFFE0                 ldb             COREID
916
 00FFE2AC 0F1FFC010                       cmpb    IOFocusID
917
 00FFE2AF 026006                          bne             hc1
918
 00FFE2B1 04F                             clra
919
 00FFE2B2 0150B7FFFE07F22                 sta             TEXTREG+TEXT_CURPOS
920 4 robfinch
                              hc1:
921 15 robfinch
 00FFE2B7 035096                          puls    d,x,pc
922 4 robfinch
 
923
                              ;------------------------------------------------------------------------------
924
                              ; Update the cursor position in the text controller based on the
925
                              ;  CursorRow,CursorCol.
926
                              ;
927
                              ; Modifies:
928
                              ;               none
929
                              ;------------------------------------------------------------------------------
930
                              ;
931
                              UpdateCursorPos:
932 15 robfinch
 00FFE2B9 034016                          pshs    d,x
933
 00FFE2BB 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
934
 00FFE2C0 0F1FFC010                       cmpb    IOFocusID                       ; only for the task with the output focus
935
 00FFE2C3 026014                          bne             ucp1
936
 00FFE2C5 096110                          lda             CursorRow
937
 00FFE2C7 08403F                          anda    #$3F                                    ; limit of 63 rows
938
 00FFE2C9 0150F6FFFE07F00                 ldb             TEXTREG+TEXT_COLS
939
 00FFE2CE 03D                             mul
940
 00FFE2CF 01F001                          tfr             d,x
941
 00FFE2D1 0D6111                          ldb             CursorCol
942
 00FFE2D3 03A                             abx
943
 00FFE2D4 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
944 4 robfinch
                              ucp1:
945 15 robfinch
 00FFE2D9 035096                          puls    d,x,pc
946 4 robfinch
 
947
                              ;------------------------------------------------------------------------------
948
                              ; Calculate screen memory location from CursorRow,CursorCol.
949
                              ; Also refreshes the cursor location.
950
                              ;
951
                              ; Modifies:
952
                              ;               d
953
                              ; Returns:
954
                              ;       d = screen location
955
                              ;------------------------------------------------------------------------------
956
                              ;
957
                              CalcScreenLoc:
958 15 robfinch
 00FFE2DB 034010                          pshs    x
959
 00FFE2DD 096110                          lda             CursorRow
960
 00FFE2DF 0C6040                          ldb             #COLS
961
 00FFE2E1 03D                             mul
962
 00FFE2E2 01F001                          tfr             d,x
963
 00FFE2E4 0D6111                          ldb             CursorCol
964
 00FFE2E6 03A                             abx
965
 00FFE2E7 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
966
 00FFE2EC 0F1FFC010                       cmpb    IOFocusID                       ; only for the task with the output focus
967
 00FFE2EF 026005                          bne             csl1
968
 00FFE2F1 0150BFFFFE07F22                 stx             TEXTREG+TEXT_CURPOS
969 4 robfinch
                              csl1:
970 15 robfinch
 00FFE2F6 08DF97                          bsr             GetScreenLocation
971
 00FFE2F8 03080B                          leax    d,x
972
 00FFE2FA 01F010                          tfr             x,d
973
 00FFE2FC 035090                          puls    x,pc
974 4 robfinch
 
975
                              ;------------------------------------------------------------------------------
976
                              ; Display a character on the screen.
977
                              ; If the task doesn't have the I/O focus then the character is written to
978
                              ; the virtual screen.
979
                              ;
980
                              ; Modifies:
981
                              ;               none
982
                              ; Parameters:
983
                              ;       accb = char to display
984
                              ;------------------------------------------------------------------------------
985
                              ;
986
                              DisplayChar:
987 15 robfinch
 00FFE2FE 017000907                       lbsr    SerialPutChar
988
 00FFE301 034016                          pshs    d,x
989
 00FFE303 0C100D                          cmpb    #CR                                     ; carriage return ?
990
 00FFE305 026007                          bne             dccr
991
 00FFE307 00F111                          clr             CursorCol               ; just set cursor column to zero on a CR
992
 00FFE309 08DFAE                          bsr             UpdateCursorPos
993 4 robfinch
                              dcx14:
994 15 robfinch
 00FFE30B 01600008C                       lbra            dcx4
995 4 robfinch
                              dccr:
996 15 robfinch
 00FFE30E 0C1091                          cmpb    #$91                            ; cursor right ?
997
 00FFE310 02600D                          bne             dcx6
998
 00FFE312 096111                          lda             CursorCol
999
 00FFE314 081040                          cmpa    #COLS
1000
 00FFE316 024003                          bhs             dcx7
1001
 00FFE318 04C                             inca
1002
 00FFE319 097111                          sta             CursorCol
1003 4 robfinch
                              dcx7:
1004 15 robfinch
 00FFE31B 08DF9C                          bsr             UpdateCursorPos
1005
 00FFE31D 035096                          puls    d,x,pc
1006 4 robfinch
                              dcx6:
1007 15 robfinch
 00FFE31F 0C1090                          cmpb    #$90                            ; cursor up ?
1008
 00FFE321 026009                          bne             dcx8
1009
 00FFE323 096110                          lda             CursorRow
1010
 00FFE325 027FF4                          beq             dcx7
1011
 00FFE327 04A                             deca
1012
 00FFE328 097110                          sta             CursorRow
1013
 00FFE32A 020FEF                          bra             dcx7
1014 4 robfinch
                              dcx8:
1015 15 robfinch
 00FFE32C 0C1093                          cmpb    #$93                            ; cursor left ?
1016
 00FFE32E 026009                          bne             dcx9
1017
 00FFE330 096111                          lda             CursorCol
1018
 00FFE332 027FE7                          beq             dcx7
1019
 00FFE334 04A                             deca
1020
 00FFE335 097111                          sta             CursorCol
1021
 00FFE337 020FE2                          bra             dcx7
1022 4 robfinch
                              dcx9:
1023 15 robfinch
 00FFE339 0C1092                          cmpb    #$92                            ; cursor down ?
1024
 00FFE33B 02600B                          bne             dcx10
1025
 00FFE33D 096110                          lda             CursorRow
1026
 00FFE33F 081020                          cmpa    #ROWS
1027
 00FFE341 027FD8                          beq             dcx7
1028
 00FFE343 04C                             inca
1029
 00FFE344 097110                          sta             CursorRow
1030
 00FFE346 020FD3                          bra             dcx7
1031 4 robfinch
                              dcx10:
1032 15 robfinch
 00FFE348 0C1094                          cmpb    #$94                            ; cursor home ?
1033
 00FFE34A 02600C                          bne             dcx11
1034
 00FFE34C 096111                          lda             CursorCol
1035
 00FFE34E 027004                          beq             dcx12
1036
 00FFE350 00F111                          clr             CursorCol
1037
 00FFE352 020FC7                          bra             dcx7
1038 4 robfinch
                              dcx12:
1039 15 robfinch
 00FFE354 00F110                          clr             CursorRow
1040
 00FFE356 020FC3                          bra             dcx7
1041 4 robfinch
                              dcx11:
1042 15 robfinch
 00FFE358 0C1099                          cmpb    #$99                            ; delete ?
1043
 00FFE35A 026008                          bne             dcx13
1044
 00FFE35C 08DF7D                          bsr             CalcScreenLoc
1045
 00FFE35E 01F001                          tfr             d,x
1046
 00FFE360 096111                          lda             CursorCol               ; acc = cursor column
1047
 00FFE362 020011                          bra             dcx5
1048 4 robfinch
                              dcx13
1049 15 robfinch
 00FFE364 0C1008                          cmpb    #CTRLH                  ; backspace ?
1050
 00FFE366 02601E                          bne             dcx3
1051
 00FFE368 096111                          lda             CursorCol
1052
 00FFE36A 02702E                          beq             dcx4
1053
 00FFE36C 04A                             deca
1054
 00FFE36D 097111                          sta             CursorCol
1055
 00FFE36F 08DF6A                          bsr             CalcScreenLoc
1056
 00FFE371 01F001                          tfr             d,x
1057
 00FFE373 096111                          lda             CursorCol
1058 4 robfinch
                              dcx5:
1059 15 robfinch
 00FFE375 0E6001                          ldb             1,x
1060
 00FFE377 0E7801                          stb             ,x++
1061
 00FFE379 04C                             inca
1062
 00FFE37A 081040                          cmpa    #COLS
1063
 00FFE37C 025FF7                          blo             dcx5
1064
 00FFE37E 0C6020                          ldb             #' '
1065
 00FFE380 0301FF                          dex
1066
 00FFE382 0E7804                          stb             ,x
1067
 00FFE384 020014                          bra             dcx4
1068 4 robfinch
                              dcx3:
1069 15 robfinch
 00FFE386 0C100A                          cmpb    #LF                             ; linefeed ?
1070
 00FFE388 02700E                          beq             dclf
1071
 00FFE38A 034004                          pshs    b
1072
 00FFE38C 08DF4D                          bsr     CalcScreenLoc
1073
 00FFE38E 01F001                          tfr             d,x
1074
 00FFE390 035004                          puls    b
1075
 00FFE392 0E7804                          stb             ,x
1076 4 robfinch
                                      ; ToDo character color
1077
                              ;       lda             CharColor
1078
                              ;       sta             $2000,x
1079 15 robfinch
 00FFE394 08D006                          bsr             IncCursorPos
1080
 00FFE396 020002                          bra             dcx4
1081 4 robfinch
                              dclf:
1082 15 robfinch
 00FFE398 08D011                          bsr             IncCursorRow
1083 4 robfinch
                              dcx4:
1084 15 robfinch
 00FFE39A 035096                          puls    d,x,pc
1085 4 robfinch
 
1086
                              ;------------------------------------------------------------------------------
1087
                              ; Increment the cursor position, scroll the screen if needed.
1088
                              ;
1089
                              ; Modifies:
1090
                              ;               none
1091
                              ;------------------------------------------------------------------------------
1092
 
1093
                              IncCursorPos:
1094 15 robfinch
 00FFE39C 034016                          pshs    d,x
1095
 00FFE39E 096111                          lda             CursorCol
1096
 00FFE3A0 04C                             inca
1097
 00FFE3A1 097111                          sta             CursorCol
1098
 00FFE3A3 081040                          cmpa    #COLS
1099
 00FFE3A5 025014                          blo             icc1
1100
 00FFE3A7 00F111                          clr             CursorCol               ; column = 0
1101
 00FFE3A9 020002                          bra             icr1
1102 4 robfinch
                              IncCursorRow:
1103 15 robfinch
 00FFE3AB 034016                          pshs    d,x
1104 4 robfinch
                              icr1:
1105 15 robfinch
 00FFE3AD 096110                          lda             CursorRow
1106
 00FFE3AF 04C                             inca
1107
 00FFE3B0 097110                          sta             CursorRow
1108
 00FFE3B2 081020                          cmpa    #ROWS
1109
 00FFE3B4 025005                          blo             icc1
1110
 00FFE3B6 04A                             deca                                                    ; backup the cursor row, we are scrolling up
1111
 00FFE3B7 097110                          sta             CursorRow
1112
 00FFE3B9 08DE9F                          bsr             ScrollUp
1113 4 robfinch
                              icc1:
1114 15 robfinch
 00FFE3BB 08DEFC                          bsr             UpdateCursorPos
1115 4 robfinch
                              icc2:
1116 15 robfinch
 00FFE3BD 035096                          puls    d,x,pc
1117 4 robfinch
 
1118
                              ;------------------------------------------------------------------------------
1119
                              ; Display a string on the screen.
1120
                              ;
1121
                              ; Modifies:
1122
                              ;               none
1123
                              ; Parameters:
1124
                              ;               d = pointer to string
1125
                              ;------------------------------------------------------------------------------
1126
                              ;
1127
                              DisplayString:
1128 15 robfinch
 00FFE3BF 034016                          pshs    d,x
1129
 00FFE3C1 01F001                          tfr             d,x
1130 13 robfinch
                              dspj2:                                          ; lock semaphore for access
1131 15 robfinch
 00FFE3C3 0B6EF0001                       lda             OUTSEMA+1
1132
 00FFE3C6 027FFB                          beq             dspj2
1133 4 robfinch
                              dspj1B:
1134 15 robfinch
 00FFE3C8 0E6800                          ldb             ,x+                             ; move string char into acc
1135
 00FFE3CA 027005                          beq             dsretB          ; is it end of string ?
1136
 00FFE3CC 017000943                       lbsr    OUTCH                   ; display character
1137
 00FFE3CF 020FF7                          bra             dspj1B
1138 4 robfinch
                              dsretB:
1139 15 robfinch
 00FFE3D1 07FEF0001                       clr             OUTSEMA+1       ; unlock semaphore
1140
 00FFE3D4 035096                          puls    d,x,pc
1141 4 robfinch
 
1142
                              DisplayStringCRLF:
1143 15 robfinch
 00FFE3D6 034006                          pshs    d
1144
 00FFE3D8 08DFE5                          bsr             DisplayString
1145
 00FFE3DA 0C600D                          ldb             #CR
1146
 00FFE3DC 017000933                       lbsr    OUTCH
1147
 00FFE3DF 0C600A                          ldb             #LF
1148
 00FFE3E1 01700092E                       lbsr    OUTCH
1149
 00FFE3E4 035086                          puls    d,pc
1150 4 robfinch
 
1151
                              ;
1152
                              ; PRINT CR, LF, STRING
1153
                              ;
1154
                              PSTRNG
1155 15 robfinch
 00FFE3E6 08D002                          BSR             PCRLF
1156
 00FFE3E8 02000D                          BRA             PDATA
1157 4 robfinch
                              PCRLF
1158 15 robfinch
 00FFE3EA 034010                          PSHS    X
1159
 00FFE3EC 08EFFE3FE                       LDX             #CRLFST
1160
 00FFE3EF 08D006                          BSR             PDATA
1161
 00FFE3F1 035010                          PULS    X
1162
 00FFE3F3 039                             RTS
1163 4 robfinch
 
1164
                              PRINT
1165 15 robfinch
 00FFE3F4 0BDFFED12                       JSR             OUTCH
1166 4 robfinch
                              PDATA
1167 15 robfinch
 00FFE3F7 0E6800                          LDB             ,X+
1168
 00FFE3F9 0C1004                          CMPB    #$04
1169
 00FFE3FB 026FF7                          BNE             PRINT
1170
 00FFE3FD 039                             RTS
1171 4 robfinch
 
1172
                              CRLFST
1173 15 robfinch
 00FFE3FE 00D00A004                       fcb     CR,LF,4
1174 4 robfinch
 
1175
                              DispDWordAsHex:
1176 15 robfinch
 00FFE401 08D007                          bsr             DispWordAsHex
1177
 00FFE403 01E001                          exg             d,x
1178
 00FFE405 08D003                          bsr             DispWordAsHex
1179
 00FFE407 01E001                          exg             d,x
1180
 00FFE409 039                             rts
1181 4 robfinch
 
1182
                              DispWordAsHex:
1183 15 robfinch
 00FFE40A 01E089                          exg             a,b
1184
 00FFE40C 08D005                          bsr             DispByteAsHex
1185
 00FFE40E 01E089                          exg             a,b
1186
 00FFE410 08D001                          bsr             DispByteAsHex
1187
 00FFE412 039                             rts
1188 4 robfinch
 
1189
                              DispByteAsHex:
1190 15 robfinch
 00FFE413 034004                    pshs  b
1191
 00FFE415 054                             lsrb
1192
 00FFE416 054                             lsrb
1193
 00FFE417 054                             lsrb
1194
 00FFE418 054                             lsrb
1195
 00FFE419 054                             lsrb
1196 14 robfinch
 00FFE41A 054                             lsrb
1197
 00FFE41B 054                             lsrb
1198
 00FFE41C 054                             lsrb
1199 15 robfinch
 00FFE41D 08D00C                          bsr             DispNyb
1200
 00FFE41F 035004                          puls    b
1201
 00FFE421 034004                          pshs    b
1202
 00FFE423 054                             lsrb
1203
 00FFE424 054                             lsrb
1204
 00FFE425 054                             lsrb
1205
 00FFE426 054                             lsrb
1206
 00FFE427 08D002                          bsr             DispNyb
1207
 00FFE429 035004                          puls    b
1208 4 robfinch
 
1209
                              DispNyb
1210 15 robfinch
 00FFE42B 034004                          pshs    b
1211
 00FFE42D 0C400F                          andb    #$0F
1212
 00FFE42F 0C100A                          cmpb    #10
1213
 00FFE431 025007                          blo             DispNyb1
1214
 00FFE433 0CB037                          addb    #'A'-10
1215
 00FFE435 0170008DA                       lbsr    OUTCH
1216
 00FFE438 035084                          puls    b,pc
1217 4 robfinch
                              DispNyb1
1218 15 robfinch
 00FFE43A 0CB030                          addb    #'0'
1219
 00FFE43C 0170008D3                       lbsr    OUTCH
1220
 00FFE43F 035084                          puls    b,pc
1221 4 robfinch
 
1222
                              ;==============================================================================
1223 13 robfinch
                              ; Timer
1224
                              ;==============================================================================
1225
 
1226
                              ; ============================================================================
1227
                              ;        __
1228
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
1229
                              ;    \  __ /    All rights reserved.
1230
                              ;     \/_//     robfinch@opencores.org
1231
                              ;       ||
1232
                              ;
1233
                              ;
1234
                              ; Timer routines for a WDC6522 compatible circuit.
1235
                              ;
1236
                              ; This source file is free software: you can redistribute it and/or modify
1237
                              ; it under the terms of the GNU Lesser General Public License as published
1238
                              ; by the Free Software Foundation, either version 3 of the License, or
1239
                              ; (at your option) any later version.
1240
                              ;
1241
                              ; This source file is distributed in the hope that it will be useful,
1242
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
1243
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1244
                              ; GNU General Public License for more details.
1245
                              ;
1246
                              ; You should have received a copy of the GNU General Public License
1247
                              ; along with this program.  If not, see .
1248
                              ;
1249
                              ; ============================================================================
1250
                              ;
1251
                              TimerInit:
1252 15 robfinch
 00FFE441 0CC061A80                       ldd             #$61A80                                 ; compare to 400000 (100 Hz assuming 40MHz clock)
1253
 00FFE444 0150F7FFFE60014                 stb             VIA+VIA_T3CMPL
1254
 00FFE449 0150B7FFFE60015                 sta             VIA+VIA_T3CMPH
1255
 00FFE44E 01507FFFFE60012                 clr             VIA+VIA_T3LL
1256
 00FFE453 01507FFFFE60013                 clr             VIA+VIA_T3LH
1257
 00FFE458 0150B6FFFE6000B                 lda             VIA+VIA_ACR                     ; set continuous mode for timer
1258
 00FFE45D 08A100                          ora             #$100
1259
 00FFE45F 0150B7FFFE6000B                 sta             VIA+VIA_ACR                     ; enable timer #3 interrupts
1260
 00FFE464 086810                          lda             #$810
1261
 00FFE466 0150B7FFFE6000E                 sta             VIA+VIA_IER
1262
 00FFE46B 039                             rts
1263 13 robfinch
 
1264
                              TimerIRQ:
1265
                                      ; Reset the edge sense circuit in the PIC
1266 15 robfinch
 00FFE46C 08601F                          lda             #31                                                     ; Timer is IRQ #31
1267
 00FFE46E 0B7FFC011                       sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
1268
 00FFE471 0150B7FFFE3F010                 sta             PIC+16                                  ; register 16 is edge sense reset reg
1269
 00FFE476 0150B6FFFE6000D                 lda             VIA+VIA_IFR
1270
 00FFE47B 02A011                          bpl             notTimerIRQ
1271
 00FFE47D 085080                          bita    #$80                                            ; timer3 irq is bit 7
1272
 00FFE47F 02700D                          beq             notTimerIRQ
1273
 00FFE481 01507FFFFE60012                 clr             VIA+VIA_T3LL
1274
 00FFE486 01507FFFFE60013                 clr             VIA+VIA_T3LH
1275
 00FFE48B 07CE00037                       inc             $E00037                                 ; update timer IRQ screen flag
1276 13 robfinch
                              notTimerIRQ:
1277 15 robfinch
 00FFE48E 039                             rts
1278 13 robfinch
 
1279
 
1280
 
1281
                              ; ============================================================================
1282
                              ;        __
1283
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
1284
                              ;    \  __ /    All rights reserved.
1285
                              ;     \/_//     robfinch@opencores.org
1286
                              ;       ||
1287
                              ;
1288
                              ;
1289
                              ; BSD 3-Clause License
1290
                              ; Redistribution and use in source and binary forms, with or without
1291
                              ; modification, are permitted provided that the following conditions are met:
1292
                              ;
1293
                              ; 1. Redistributions of source code must retain the above copyright notice, this
1294
                              ;    list of conditions and the following disclaimer.
1295
                              ;
1296
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
1297
                              ;    this list of conditions and the following disclaimer in the documentation
1298
                              ;    and/or other materials provided with the distribution.
1299
                              ;
1300
                              ; 3. Neither the name of the copyright holder nor the names of its
1301
                              ;    contributors may be used to endorse or promote products derived from
1302
                              ;    this software without specific prior written permission.
1303
                              ;
1304
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1305
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1306
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1307
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1308
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1309
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1310
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1311
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1312
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1313
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1314
                              ;
1315
                              ; ============================================================================
1316
                              ;
1317
                              ;===============================================================================
1318
                              ; Generic I2C routines
1319
                              ;
1320
                              ; It is assumed there may be more than one I2C controller in the system, so
1321
                              ; the address of the controller is passed in the X register.
1322
                              ;===============================================================================
1323
 
1324
                              I2C_PREL        EQU             $0
1325
                              I2C_PREH        EQU             $1
1326
                              I2C_CTRL        EQU             $2
1327
                              I2C_RXR         EQU             $3
1328
                              I2C_TXR         EQU             $3
1329
                              I2C_CMD         EQU             $4
1330
                              I2C_STAT        EQU             $4
1331
 
1332
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1333
                              ; i2c initialization, sets the clock prescaler
1334
                              ;
1335
                              ; Parameters:
1336
                              ;               x = I2C controller address
1337
                              ; Returns: none
1338
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1339
 
1340 15 robfinch
                              i2c_init:
1341
 00FFE48F 034004                          pshs    b
1342
 00FFE491 0C6004                          ldb             #4                                                                      ; setup prescale for 400kHz clock
1343
 00FFE493 0E7804                          stb             I2C_PREL,x
1344
 00FFE495 06F001                          clr             I2C_PREH,x
1345
 00FFE497 035084                          puls    b,pc
1346 13 robfinch
 
1347
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1348
                              ; Wait for I2C transfer to complete
1349
                              ;
1350
                              ; Parameters
1351
                              ;       x - I2C controller base address
1352
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1353
 
1354
                              i2c_wait_tip:
1355 15 robfinch
 00FFE499 034004                          pshs            b
1356 13 robfinch
                              i2cw1:
1357 15 robfinch
 00FFE49B 0E6004                          ldb                     I2C_STAT,x              ; would use lvb, but lb is okay since its the I/O area
1358
 00FFE49D 0C5001                          bitb            #1                                              ; wait for tip to clear
1359
 00FFE49F 026FFA                          bne                     i2cw1
1360
 00FFE4A1 035084                          puls            b,pc
1361 13 robfinch
 
1362
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1363
                              ; Write command to i2c
1364
                              ;
1365
                              ; Parameters
1366
                              ;               accb - data to transmit
1367
                              ;               acca - command value
1368
                              ;               x       - I2C controller base address
1369
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1370
 
1371
                              i2c_wr_cmd:
1372 15 robfinch
 00FFE4A3 0E7003                          stb             I2C_TXR,x
1373
 00FFE4A5 0A7004                          sta             I2C_CMD,x
1374
 00FFE4A7 08DFF0                          bsr             i2c_wait_tip
1375
 00FFE4A9 0E6004                          ldb             I2C_STAT,x
1376
 00FFE4AB 039                             rts
1377 13 robfinch
 
1378
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1379
                              ; Parameters
1380
                              ;               x - I2C controller base address
1381
                              ;               accb - data to send
1382
                              ; Returns: none
1383
                              ; Stack space: 2 words
1384
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1385
 
1386 15 robfinch
                              i2c_xmit1:
1387
 00FFE4AC 034006                          pshs    d                                                               ; save data value
1388
 00FFE4AE 034006                          pshs    d                                                               ; and save it again
1389
 00FFE4B0 0C6001                          ldb             #1
1390
 00FFE4B2 0E7002                          stb             I2C_CTRL,x                      ; enable the core
1391
 00FFE4B4 0C6076                          ldb             #$76                                            ; set slave address = %0111011
1392
 00FFE4B6 086090                          lda             #$90                                            ; set STA, WR
1393
 00FFE4B8 08DFE9                          bsr             i2c_wr_cmd
1394
 00FFE4BA 08D00A                          bsr             i2c_wait_rx_nack
1395
 00FFE4BC 035006                          puls    d                                                               ; get back data value
1396
 00FFE4BE 086050                          lda             #$50                                            ; set STO, WR
1397
 00FFE4C0 08DFE1                          bsr             i2c_wr_cmd
1398
 00FFE4C2 08D002                          bsr             i2c_wait_rx_nack
1399
 00FFE4C4 035086                          puls    d,pc
1400 13 robfinch
 
1401
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1402
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1403
 
1404
                              i2c_wait_rx_nack:
1405 15 robfinch
 00FFE4C6 034004                          pshs    b                                                               ; save off accb
1406 13 robfinch
                              i2cwr1:
1407 15 robfinch
 00FFE4C8 0E6004                          ldb             I2C_STAT,x                      ; wait for RXack = 0
1408
 00FFE4CA 0C5080                          bitb    #$80                                            ; test for nack
1409
 00FFE4CC 026FFA                          bne             i2cwr1
1410
 00FFE4CE 035084                          puls    b,pc
1411 13 robfinch
 
1412
                              ; ============================================================================
1413
                              ;        __
1414
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
1415
                              ;    \  __ /    All rights reserved.
1416
                              ;     \/_//     robfinch@opencores.org
1417
                              ;       ||
1418
                              ;
1419
                              ;
1420
                              ; BSD 3-Clause License
1421
                              ; Redistribution and use in source and binary forms, with or without
1422
                              ; modification, are permitted provided that the following conditions are met:
1423
                              ;
1424
                              ; 1. Redistributions of source code must retain the above copyright notice, this
1425
                              ;    list of conditions and the following disclaimer.
1426
                              ;
1427
                              ; 2. Redistributions in binary form must reproduce the above copyright notice,
1428
                              ;    this list of conditions and the following disclaimer in the documentation
1429
                              ;    and/or other materials provided with the distribution.
1430
                              ;
1431
                              ; 3. Neither the name of the copyright holder nor the names of its
1432
                              ;    contributors may be used to endorse or promote products derived from
1433
                              ;    this software without specific prior written permission.
1434
                              ;
1435
                              ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1436
                              ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1437
                              ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1438
                              ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1439
                              ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1440
                              ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1441
                              ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1442
                              ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1443
                              ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1444
                              ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1445
                              ;
1446
                              ; ============================================================================
1447
 
1448
                              ;===============================================================================
1449
                              ; Realtime clock routines
1450
                              ;===============================================================================
1451
 
1452
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1453
                              ; Read the real-time-clock chip.
1454
                              ;
1455
                              ; The entire contents of the clock registers and sram are read into a buffer
1456
                              ; in one-shot rather than reading the registers individually.
1457
                              ;
1458
                              ; Parameters: none
1459
                              ; Returns: d = 0 on success, otherwise non-zero
1460
                              ; Modifies: d and RTCBuf
1461
                              ; Stack space: 6 words
1462
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1463
 
1464
                              rtc_read:
1465 15 robfinch
 00FFE4D0 08EE30500                       ldx                     #RTC
1466
 00FFE4D3 18E007FC0                       ldy                     #RTCBuf
1467
 00FFE4D6 0C6080                          ldb                     #$80
1468
 00FFE4D8 0E7002                          stb                     I2C_CTRL,x              ; enable I2C
1469
 00FFE4DA 0CC0900DE                       ldd                     #$900DE                         ; read address, write op, STA + wr bit
1470
 00FFE4DD 08DFC4                          bsr                     i2c_wr_cmd
1471 14 robfinch
 00FFE4DF 0C5080                          bitb            #$80
1472 15 robfinch
 00FFE4E1 02603C                          bne                     rtc_rxerr
1473
 00FFE4E3 0CC010000                       ldd                     #$10000                         ; address zero, wr bit
1474
 00FFE4E6 08DFBB                          bsr                     i2c_wr_cmd
1475 14 robfinch
 00FFE4E8 0C5080                          bitb            #$80
1476 15 robfinch
 00FFE4EA 026033                          bne                     rtc_rxerr
1477
 00FFE4EC 0CC0900DF                       ldd                     #$900DF                         ; read address, read op, STA + wr bit
1478
 00FFE4EF 08DFB2                          bsr                     i2c_wr_cmd
1479
 00FFE4F1 0C5080                          bitb            #$80
1480
 00FFE4F3 02602A                          bne                     rtc_rxerr
1481 13 robfinch
 
1482 15 robfinch
 00FFE4F5 05F                             clrb
1483 13 robfinch
                              rtcr0001:
1484 15 robfinch
 00FFE4F6 086020                          lda                     #$20
1485
 00FFE4F8 0A7004                          sta                     I2C_CMD,x                       ; rd bit
1486
 00FFE4FA 08DF9D                          bsr                     i2c_wait_tip
1487
 00FFE4FC 08DFC8                          bsr                     i2c_wait_rx_nack
1488
 00FFE4FE 0A6004                          lda                     I2C_STAT,x
1489
 00FFE500 085080                          bita            #$80
1490
 00FFE502 02601B                          bne                     rtc_rxerr
1491
 00FFE504 0A6003                          lda                     I2C_RXR,x
1492
 00FFE506 0A7A07                          sta                     b,y
1493
 00FFE508 05C                             incb
1494
 00FFE509 0C105F                          cmpb            #$5F
1495
 00FFE50B 025FE9                          blo                     rtcr0001
1496
 00FFE50D 086068                          lda                     #$68
1497
 00FFE50F 0A7004                          sta                     I2C_CMD,x                       ; STO, rd bit + nack
1498
 00FFE511 08DF86                          bsr                     i2c_wait_tip
1499
 00FFE513 0A6004                          lda                     I2C_STAT,x
1500
 00FFE515 085080                          bita            #$80
1501
 00FFE517 026006                          bne                     rtc_rxerr
1502
 00FFE519 0A6003                          lda                     I2C_RXR,x
1503
 00FFE51B 0A7A07                          sta                     b,y
1504
 00FFE51D 04F05F                          clrd                                                                    ; return 0
1505 13 robfinch
                              rtc_rxerr:
1506 15 robfinch
 00FFE51F 06F002                          clr                     I2C_CTRL,x      ; disable I2C and return status
1507
 00FFE521 04F                             clra
1508
 00FFE522 039                             rts
1509 13 robfinch
 
1510
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1511
                              ; Write the real-time-clock chip.
1512
                              ;
1513
                              ; The entire contents of the clock registers and sram are written from a
1514
                              ; buffer (RTCBuf) in one-shot rather than writing the registers individually.
1515
                              ;
1516
                              ; Parameters: none
1517
                              ; Returns: r1 = 0 on success, otherwise non-zero
1518
                              ; Modifies: r1 and RTCBuf
1519
                              ; Stack space: 6 words
1520
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1521
 
1522
                              rtc_write:
1523 15 robfinch
 00FFE523 08EE30500                       ldx             #RTC
1524
 00FFE526 18E007FC0                       ldy             #RTCBuf
1525 13 robfinch
 
1526 15 robfinch
 00FFE529 0C6080                          ldb             #$80
1527
 00FFE52B 0E7002                          stb             I2C_CTRL,x              ; enable I2C
1528
 00FFE52D 0CC0900DE                       ldd             #$900DE                         ; read address, write op, STA + wr bit
1529
 00FFE530 08DF71                          bsr             i2c_wr_cmd
1530 14 robfinch
 00FFE532 0C5080                          bitb    #$80
1531 15 robfinch
 00FFE534 026FE9                          bne             rtc_rxerr
1532
 00FFE536 0CC010000                       ldd             #$10000                         ; address zero, wr bit
1533
 00FFE539 08DF68                          bsr             i2c_wr_cmd
1534
 00FFE53B 0C5080                          bitb    #$80
1535
 00FFE53D 026FE0                          bne             rtc_rxerr
1536 13 robfinch
 
1537 15 robfinch
 00FFE53F 0C6000                          ldb             #0
1538 13 robfinch
                              rtcw0001:
1539 15 robfinch
 00FFE541 034004                          pshs    b
1540
 00FFE543 0E6A05                          ldb             b,y
1541
 00FFE545 086010                          lda             #$10
1542
 00FFE547 08DF5A                          bsr             i2c_wr_cmd
1543
 00FFE549 0C5080                          bitb    #$80
1544
 00FFE54B 035004                          puls    b
1545
 00FFE54D 026FD0                          bne             rtc_rxerr
1546
 00FFE54F 05C                             incb
1547
 00FFE550 0C105F                          cmpb    #$5F
1548
 00FFE552 025FED                          blo             rtcw0001
1549
 00FFE554 0E6A05                          ldb             b,y
1550
 00FFE556 086050                          lda             #$50                                    ; STO, wr bit
1551
 00FFE558 08DF49                          bsr             i2c_wr_cmd
1552
 00FFE55A 0C5080                          bitb    #$80
1553
 00FFE55C 026FC1                          bne             rtc_rxerr
1554
 00FFE55E 04F05F                          clrd                                                            ; return 0
1555
 00FFE560 06F002                          clr             I2C_CTRL,x              ; disable I2C and return status
1556
 00FFE562 039                             rts
1557 13 robfinch
 
1558
                              ;==============================================================================
1559 4 robfinch
                              ; Keyboard I/O
1560
                              ;==============================================================================
1561
 
1562
                                      ;--------------------------------------------------------------------------
1563
                                      ; PS2 scan codes to ascii conversion tables.
1564
                                      ;--------------------------------------------------------------------------
1565
                                      ;
1566
                                      org     (* + 127) & $FFFFFF80
1567
 
1568
                              unshiftedScanCodes:
1569 13 robfinch
 00FFE580 02E0A902E0A50A30A10A2           fcb     $2e,$a9,$2e,$a5,$a3,$a1,$a2,$ac
1570
 00FFE587 0AC
1571
 00FFE588 02E0AA0A80A60A4009060           fcb     $2e,$aa,$a8,$a6,$a4,$09,$60,$2e
1572
 00FFE58F 02E
1573
 00FFE590 02E02E02E02E02E071031           fcb     $2e,$2e,$2e,$2e,$2e,$71,$31,$2e
1574
 00FFE597 02E
1575
 00FFE598 02E02E07A073061077032           fcb     $2e,$2e,$7a,$73,$61,$77,$32,$2e
1576
 00FFE59F 02E
1577
 00FFE5A0 02E063078064065034033           fcb     $2e,$63,$78,$64,$65,$34,$33,$2e
1578
 00FFE5A7 02E
1579
 00FFE5A8 02E020076066074072035           fcb     $2e,$20,$76,$66,$74,$72,$35,$2e
1580
 00FFE5AF 02E
1581
 00FFE5B0 02E06E062068067079036           fcb     $2e,$6e,$62,$68,$67,$79,$36,$2e
1582
 00FFE5B7 02E
1583
 00FFE5B8 02E02E06D06A075037038           fcb     $2e,$2e,$6d,$6a,$75,$37,$38,$2e
1584
 00FFE5BF 02E
1585
 00FFE5C0 02E02C06B06906F030039           fcb     $2e,$2c,$6b,$69,$6f,$30,$39,$2e
1586
 00FFE5C7 02E
1587
 00FFE5C8 02E02E02F06C03B07002D           fcb     $2e,$2e,$2f,$6c,$3b,$70,$2d,$2e
1588
 00FFE5CF 02E
1589
 00FFE5D0 02E02E02702E05B03D02E           fcb     $2e,$2e,$27,$2e,$5b,$3d,$2e,$2e
1590
 00FFE5D7 02E
1591
 00FFE5D8 0AD02E00D05D02E05C02E           fcb     $ad,$2e,$0d,$5d,$2e,$5c,$2e,$2e
1592
 00FFE5DF 02E
1593
 00FFE5E0 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1594
 00FFE5E7 02E
1595
 00FFE5E8 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1596
 00FFE5EF 02E
1597
 00FFE5F0 09807F09202E09109001B           fcb     $98,$7f,$92,$2e,$91,$90,$1b,$af
1598
 00FFE5F7 0AF
1599
 00FFE5F8 0AB02E09702E02E0960AE           fcb     $ab,$2e,$97,$2e,$2e,$96,$ae,$2e
1600
 00FFE5FF 02E
1601 4 robfinch
 
1602 13 robfinch
 00FFE600 02E02E02E0A702E02E02E           fcb     $2e,$2e,$2e,$a7,$2e,$2e,$2e,$2e
1603
 00FFE607 02E
1604
 00FFE608 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1605
 00FFE60F 02E
1606
 00FFE610 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1607
 00FFE617 02E
1608
 00FFE618 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1609
 00FFE61F 02E
1610
 00FFE620 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1611
 00FFE627 02E
1612
 00FFE628 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1613
 00FFE62F 02E
1614
 00FFE630 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1615
 00FFE637 02E
1616
 00FFE638 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1617
 00FFE63F 02E
1618
 00FFE640 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1619
 00FFE647 02E
1620
 00FFE648 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1621
 00FFE64F 02E
1622
 00FFE650 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1623
 00FFE657 02E
1624
 00FFE658 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1625
 00FFE65F 02E
1626
 00FFE660 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1627
 00FFE667 02E
1628
 00FFE668 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1629
 00FFE66F 02E
1630
 00FFE670 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1631
 00FFE677 02E
1632
 00FFE678 02E02E0FA02E02E02E02E           fcb     $2e,$2e,$fa,$2e,$2e,$2e,$2e,$2e
1633
 00FFE67F 02E
1634 4 robfinch
 
1635
                              shiftedScanCodes:
1636 13 robfinch
 00FFE680 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1637
 00FFE687 02E
1638
 00FFE688 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1639
 00FFE68F 02E
1640
 00FFE690 02E02E02E02E02E051021           fcb     $2e,$2e,$2e,$2e,$2e,$51,$21,$2e
1641
 00FFE697 02E
1642
 00FFE698 02E02E05A053041057040           fcb     $2e,$2e,$5a,$53,$41,$57,$40,$2e
1643
 00FFE69F 02E
1644
 00FFE6A0 02E043058044045024023           fcb     $2e,$43,$58,$44,$45,$24,$23,$2e
1645
 00FFE6A7 02E
1646
 00FFE6A8 02E020056046054052025           fcb     $2e,$20,$56,$46,$54,$52,$25,$2e
1647
 00FFE6AF 02E
1648
 00FFE6B0 02E04E04204804705905E           fcb     $2e,$4e,$42,$48,$47,$59,$5e,$2e
1649
 00FFE6B7 02E
1650
 00FFE6B8 02E02E04D04A05502602A           fcb     $2e,$2e,$4d,$4a,$55,$26,$2a,$2e
1651
 00FFE6BF 02E
1652
 00FFE6C0 02E03C04B04904F029028           fcb     $2e,$3c,$4b,$49,$4f,$29,$28,$2e
1653
 00FFE6C7 02E
1654
 00FFE6C8 02E03E03F04C03A05005F           fcb     $2e,$3e,$3f,$4c,$3a,$50,$5f,$2e
1655
 00FFE6CF 02E
1656
 00FFE6D0 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1657
 00FFE6D7 02E
1658
 00FFE6D8 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1659
 00FFE6DF 02E
1660
 00FFE6E0 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1661
 00FFE6E7 02E
1662
 00FFE6E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1663
 00FFE6EF 02E
1664
 00FFE6F0 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1665
 00FFE6F7 02E
1666
 00FFE6F8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1667
 00FFE6FF 02E
1668 4 robfinch
 
1669 13 robfinch
 00FFE700 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1670
 00FFE707 02E
1671
 00FFE708 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1672
 00FFE70F 02E
1673
 00FFE710 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1674
 00FFE717 02E
1675
 00FFE718 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1676
 00FFE71F 02E
1677
 00FFE720 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1678
 00FFE727 02E
1679
 00FFE728 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1680
 00FFE72F 02E
1681
 00FFE730 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1682
 00FFE737 02E
1683
 00FFE738 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1684
 00FFE73F 02E
1685
 00FFE740 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1686
 00FFE747 02E
1687
 00FFE748 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1688
 00FFE74F 02E
1689
 00FFE750 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1690
 00FFE757 02E
1691
 00FFE758 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1692
 00FFE75F 02E
1693
 00FFE760 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1694
 00FFE767 02E
1695
 00FFE768 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1696
 00FFE76F 02E
1697
 00FFE770 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1698
 00FFE777 02E
1699
 00FFE778 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1700
 00FFE77F 02E
1701 4 robfinch
 
1702
                              ; control
1703
                              keybdControlCodes:
1704 13 robfinch
 00FFE780 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1705
 00FFE787 02E
1706
 00FFE788 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1707
 00FFE78F 02E
1708
 00FFE790 02E02E02E02E02E011021           fcb     $2e,$2e,$2e,$2e,$2e,$11,$21,$2e
1709
 00FFE797 02E
1710
 00FFE798 02E02E01A013001017040           fcb     $2e,$2e,$1a,$13,$01,$17,$40,$2e
1711
 00FFE79F 02E
1712
 00FFE7A0 02E003018004005024023           fcb     $2e,$03,$18,$04,$05,$24,$23,$2e
1713
 00FFE7A7 02E
1714
 00FFE7A8 02E020016006014012025           fcb     $2e,$20,$16,$06,$14,$12,$25,$2e
1715
 00FFE7AF 02E
1716
 00FFE7B0 02E00E00200800701905E           fcb     $2e,$0e,$02,$08,$07,$19,$5e,$2e
1717
 00FFE7B7 02E
1718
 00FFE7B8 02E02E00D00A01502602A           fcb     $2e,$2e,$0d,$0a,$15,$26,$2a,$2e
1719
 00FFE7BF 02E
1720
 00FFE7C0 02E03C00B00900F029028           fcb     $2e,$3c,$0b,$09,$0f,$29,$28,$2e
1721
 00FFE7C7 02E
1722
 00FFE7C8 02E03E03F00C03A01005F           fcb     $2e,$3e,$3f,$0c,$3a,$10,$5f,$2e
1723
 00FFE7CF 02E
1724
 00FFE7D0 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1725
 00FFE7D7 02E
1726
 00FFE7D8 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1727
 00FFE7DF 02E
1728
 00FFE7E0 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1729
 00FFE7E7 02E
1730
 00FFE7E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1731
 00FFE7EF 02E
1732
 00FFE7F0 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1733
 00FFE7F7 02E
1734
 00FFE7F8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1735
 00FFE7FF 02E
1736 4 robfinch
 
1737
                              keybdExtendedCodes:
1738 13 robfinch
 00FFE800 02E02E02E02E0A30A10A2           fcb     $2e,$2e,$2e,$2e,$a3,$a1,$a2,$2e
1739
 00FFE807 02E
1740
 00FFE808 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1741
 00FFE80F 02E
1742
 00FFE810 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1743
 00FFE817 02E
1744
 00FFE818 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1745
 00FFE81F 02E
1746
 00FFE820 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1747
 00FFE827 02E
1748
 00FFE828 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1749
 00FFE82F 02E
1750
 00FFE830 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1751
 00FFE837 02E
1752
 00FFE838 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1753
 00FFE83F 02E
1754
 00FFE840 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1755
 00FFE847 02E
1756
 00FFE848 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1757
 00FFE84F 02E
1758
 00FFE850 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1759
 00FFE857 02E
1760
 00FFE858 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1761
 00FFE85F 02E
1762
 00FFE860 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1763
 00FFE867 02E
1764
 00FFE868 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1765
 00FFE86F 02E
1766
 00FFE870 09809909202E09109002E           fcb     $98,$99,$92,$2e,$91,$90,$2e,$2e
1767
 00FFE877 02E
1768
 00FFE878 02E02E09702E02E09602E           fcb     $2e,$2e,$97,$2e,$2e,$96,$2e,$2e
1769
 00FFE87F 02E
1770 4 robfinch
 
1771
                              ; ============================================================================
1772
                              ;        __
1773
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
1774
                              ;    \  __ /    All rights reserved.
1775
                              ;     \/_//     robfinch@opencores.org
1776
                              ;       ||
1777
                              ;
1778
                              ;
1779
                              ;       Keyboard driver routines to interface to a PS2 style keyboard
1780
                              ; Converts the scancode to ascii
1781
                              ;
1782
                              ; This source file is free software: you can redistribute it and/or modify
1783
                              ; it under the terms of the GNU Lesser General Public License as published
1784
                              ; by the Free Software Foundation, either version 3 of the License, or
1785
                              ; (at your option) any later version.
1786
                              ;
1787
                              ; This source file is distributed in the hope that it will be useful,
1788
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
1789
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1790
                              ; GNU General Public License for more details.
1791
                              ;
1792
                              ; You should have received a copy of the GNU General Public License
1793
                              ; along with this program.  If not, see .
1794
                              ;
1795
                              ; ============================================================================
1796
                              ;
1797
                              SC_F12  EQU     $07
1798
                              SC_C    EQU             $21
1799
                              SC_T    EQU         $2C
1800
                              SC_Z            EQU     $1A
1801
                              SC_DEL  EQU                     $71     ; extend
1802
                              SC_KEYUP        EQU             $F0     ; should be $f0
1803
                              SC_EXTEND EQU     $E0
1804
                              SC_CTRL EQU                     $14
1805
                              SC_RSHIFT               EQU     $59
1806
                              SC_NUMLOCK      EQU     $77
1807
                              SC_SCROLLLOCK           EQU     $7E
1808
                              SC_CAPSLOCK             EQU             $58
1809
                              SC_ALT  EQU                     $11
1810
 
1811
                              ;#define SC_LSHIFT      EQU             $12
1812
                              ;SC_DEL         EQU             $71             ; extend
1813
                              ;SC_LCTRL       EQU             $58
1814
 
1815
                              SC_TAB  EQU     $0D
1816
 
1817
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1818
                              ; Recieve a byte from the keyboard, used after a command is sent to the
1819
                              ; keyboard in order to wait for a response.
1820
                              ;
1821
                              ; Parameters: none
1822
                              ; Returns: accd = recieved byte ($00 to $FF), -1 on timeout
1823
                              ; Modifies: acc
1824
                              ; Stack Space: 2 words
1825
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1826
 
1827
                              KeybdRecvByte:
1828 13 robfinch
 00FFE880 034010                          pshs    x
1829
 00FFE882 08E000064                       ldx             #100                                            ; wait up to 1s
1830 4 robfinch
                              krb3:
1831 13 robfinch
 00FFE885 08D05A                          bsr             KeybdGetStatus  ; wait for response from keyboard
1832
 00FFE887 05D                             tstb
1833
 00FFE888 02B00B                          bmi             krb4                                            ; is input buffer full ? yes, branch
1834
 00FFE88A 08D02D                          bsr             Wait10ms                                ; wait a bit
1835
 00FFE88C 0301FF                          dex
1836
 00FFE88E 026FF5                          bne             krb3                                            ; go back and try again
1837
 00FFE890 0CCFFFFFF                       ldd             #-1                                                     ; return -1
1838
 00FFE893 035090                          puls    x,pc
1839 4 robfinch
                              krb4:
1840 13 robfinch
 00FFE895 08D066                          bsr             KeybdGetScancode
1841
 00FFE897 035090                          puls    x,pc
1842 4 robfinch
 
1843
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1844
                              ; Send a byte to the keyboard.
1845
                              ;
1846
                              ; Parameters: accb byte to send
1847
                              ; Returns: none
1848
                              ; Modifies: none
1849
                              ; Stack Space: 0 words
1850
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1851
 
1852
                              KeybdSendByte:
1853 13 robfinch
 00FFE899 0150F7FFFE30400                 stb             KEYBD
1854
 00FFE89E 039                             rts
1855 4 robfinch
 
1856
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1857
                              ; Wait until the keyboard transmit is complete
1858
                              ;
1859
                              ; Parameters: none
1860
                              ; Returns: r1 = 0 if successful, r1 = -1 timeout
1861
                              ; Modifies: r1
1862
                              ; Stack Space: 3 words
1863
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1864
 
1865
                              KeybdWaitTx:
1866 13 robfinch
 00FFE89F 034010                          pshs    x
1867
 00FFE8A1 08E000064                       ldx             #100                            ; wait a max of 1s
1868 4 robfinch
                              kwt1:
1869 13 robfinch
 00FFE8A4 08D03B                          bsr             KeybdGetStatus
1870
 00FFE8A6 0C4040                          andb    #$40                            ; check for transmit complete bit; branch if bit set
1871
 00FFE8A8 02600B                          bne             kwt2
1872
 00FFE8AA 08D00D                          bsr             Wait10ms                ; delay a little bit
1873
 00FFE8AC 0301FF                          dex
1874
 00FFE8AE 026FF4                          bne             kwt1                            ; go back and try again
1875
 00FFE8B0 0CCFFFFFF                       ldd             #-1                                     ; timed out, return -1
1876
 00FFE8B3 035090                          puls    x,pc
1877 4 robfinch
                              kwt2:
1878 13 robfinch
 00FFE8B5 04F                             clra                                                    ; wait complete, return 0
1879
 00FFE8B6 05F                             clrb
1880
 00FFE8B7 035090                          puls    x,pc
1881 4 robfinch
 
1882
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1883
                              ; Wait for 10 ms
1884
                              ;
1885
                              ; Parameters: none
1886
                              ; Returns: none
1887
                              ; Modifies: none
1888
                              ; Stack Space: 2 words
1889
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1890
 
1891
                              Wait10ms:
1892 13 robfinch
 00FFE8B9 034006                          pshs    d
1893
 00FFE8BB 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1894 4 robfinch
                              W10_0001:
1895 13 robfinch
 00FFE8C0 01F089                          tfr             a,b
1896
 00FFE8C2 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1897
 00FFE8C7 0C1FFA                          cmpb    #$FFA
1898
 00FFE8C9 022FF5                          bhi             W10_0001
1899
 00FFE8CB 035086                          puls    d,pc
1900 4 robfinch
 
1901
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1902
                              ; Wait for 300 ms (256 ms)
1903
                              ;
1904
                              ; Parameters: none
1905
                              ; Returns: none
1906
                              ; Modifies: none
1907
                              ; Stack Space: 2 words
1908
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1909
 
1910
                              Wait300ms:
1911 13 robfinch
 00FFE8CD 034006                          pshs    d
1912
 00FFE8CF 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1913 4 robfinch
                              W300_0001:
1914 13 robfinch
 00FFE8D4 01F089                          tfr             a,b
1915
 00FFE8D6 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1916
 00FFE8DB 0C1F00                          cmpb    #$F00
1917
 00FFE8DD 022FF5                          bhi     W300_0001
1918
 00FFE8DF 035086                          puls    d,pc
1919 4 robfinch
 
1920
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1921
                              ; Get the keyboard status
1922
                              ;
1923
                              ; Parameters: none
1924
                              ; Returns: d = status
1925
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1926
 
1927
                              KeybdGetStatus:
1928
                              kbgs3:
1929 13 robfinch
 00FFE8E1 0150F6FFFE30401                 ldb             KEYBD+1
1930
 00FFE8E6 0C5080                          bitb    #$80
1931
 00FFE8E8 02600E                          bne             kbgs1
1932
 00FFE8EA 0C5001                          bitb    #$01            ; check parity error flag
1933
 00FFE8EC 026002                          bne             kbgs2
1934
 00FFE8EE 04F                             clra
1935
 00FFE8EF 039                             rts
1936 4 robfinch
                              kbgs2:
1937 13 robfinch
 00FFE8F0 0C60FE                          ldb             #$FE            ; request resend
1938
 00FFE8F2 08DFA5                          bsr             KeybdSendByte
1939
 00FFE8F4 08DFA9                          bsr             KeybdWaitTx
1940
 00FFE8F6 020FE9                          bra             kbgs3
1941 4 robfinch
                              kbgs1:                                  ; return negative status
1942 13 robfinch
 00FFE8F8 0CAF00                          orb             #$F00
1943
 00FFE8FA 086FFF                          lda             #-1
1944
 00FFE8FC 039                             rts
1945 4 robfinch
 
1946
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1947
                              ; Get the scancode from the keyboard port
1948
                              ;
1949
                              ; Parameters: none
1950
                              ; Returns: acca = scancode
1951
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1952
 
1953
                              KeybdGetScancode:
1954 13 robfinch
 00FFE8FD 04F                             clra
1955
 00FFE8FE 0150F6FFFE30400                 ldb             KEYBD                           ; get the scan code
1956
 00FFE903 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
1957
 00FFE908 039                             rts
1958 4 robfinch
 
1959
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1960
                              ; Set the LEDs on the keyboard.
1961
                              ;
1962
                              ; Parameters: d LED status to set
1963
                              ; Returns: none
1964
                              ; Modifies: none
1965
                              ; Stack Space: 2 words
1966
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1967
 
1968
                              KeybdSetLED:
1969 13 robfinch
 00FFE909 034004                          pshs    b
1970
 00FFE90B 0C60ED                          ldb             #$ED                                            ; set LEDs command
1971
 00FFE90D 08DF8A                          bsr             KeybdSendByte
1972
 00FFE90F 08DF8E                          bsr             KeybdWaitTx
1973
 00FFE911 08DF6D                          bsr             KeybdRecvByte   ; should be an ack
1974
 00FFE913 035004                          puls    b
1975
 00FFE915 08DF82                          bsr             KeybdSendByte
1976
 00FFE917 08DF86                          bsr             KeybdWaitTx
1977
 00FFE919 08DF65                          bsr             KeybdRecvByte   ; should be an ack
1978
 00FFE91B 039                             rts
1979 4 robfinch
 
1980
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1981
                              ; Get ID - get the keyboards identifier code.
1982
                              ;
1983
                              ; Parameters: none
1984
                              ; Returns: d = $AB83, $00 on fail
1985
                              ; Modifies: d, KeybdID updated
1986
                              ; Stack Space: 2 words
1987
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1988
 
1989
                              KeybdGetID:
1990 13 robfinch
 00FFE91C 0C60F2                          ldb             #$F2
1991
 00FFE91E 08DF79                          bsr             KeybdSendByte
1992
 00FFE920 08DF7D                          bsr             KeybdWaitTx
1993
 00FFE922 08DF5C                          bsr             KeybdRecvByte
1994
 00FFE924 0C5080                          bitb    #$80
1995
 00FFE926 026014                          bne             kgnotKbd
1996
 00FFE928 0C10AB                          cmpb    #$AB
1997
 00FFE92A 026010                          bne             kgnotKbd
1998
 00FFE92C 08DF52                          bsr             KeybdRecvByte
1999
 00FFE92E 0C5080                          bitb    #$80
2000
 00FFE930 02600A                          bne             kgnotKbd
2001
 00FFE932 0C1083                          cmpb    #$83
2002
 00FFE934 026006                          bne             kgnotKbd
2003
 00FFE936 0CC00AB83                       ldd             #$AB83
2004 4 robfinch
                              kgid1:
2005 13 robfinch
 00FFE939 0DD124                          std             KeybdID
2006
 00FFE93B 039                             rts
2007 4 robfinch
                              kgnotKbd:
2008 13 robfinch
 00FFE93C 04F                             clra
2009
 00FFE93D 05F                             clrb
2010
 00FFE93E 020FF9                          bra             kgid1
2011 4 robfinch
 
2012
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2013
                              ; Initialize the keyboard.
2014
                              ;
2015
                              ; Parameters:
2016
                              ;               none
2017
                              ;       Modifies:
2018
                              ;               none
2019
                              ; Returns:
2020
                              ;               none
2021
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2022
 
2023
                              KeybdInit:
2024 13 robfinch
 00FFE940 034026                          pshs    d,y
2025
 00FFE942 18E000005                       ldy             #5
2026
 00FFE945 00F120                          clr             KeyState1               ; records key up/down state
2027
 00FFE947 00F121                          clr             KeyState2               ; records shift,ctrl,alt state
2028 4 robfinch
                              kbdi0002:
2029 13 robfinch
 00FFE949 08DF6E                          bsr             Wait10ms
2030
 00FFE94B 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
2031
 00FFE950 0C6FFF                          ldb             #-1                                     ; send reset code to keyboard
2032
 00FFE952 0150F7FFFE30401                 stb             KEYBD+1                 ; write $FF to status reg to clear TX state
2033
 00FFE957 08DF40                          bsr             KeybdSendByte   ; now write to transmit register
2034
 00FFE959 08DF44                          bsr             KeybdWaitTx             ; wait until no longer busy
2035
 00FFE95B 08DF23                          bsr             KeybdRecvByte   ; look for an ACK ($FA)
2036
 00FFE95D 0C10FA                          cmpb    #$FA
2037
 00FFE95F 026021                          bne             kbdiTryAgain
2038
 00FFE961 08DF1D                          bsr             KeybdRecvByte   ; look for BAT completion code ($AA)
2039
 00FFE963 0C10FC                          cmpb    #$FC                            ; reset error ?
2040
 00FFE965 02701B                          beq             kbdiTryAgain
2041
 00FFE967 0C10AA                          cmpb    #$AA                            ; reset complete okay ?
2042
 00FFE969 026017                          bne             kbdiTryAgain
2043 4 robfinch
 
2044
                                      ; After a reset, scan code set #2 should be active
2045
                              .config:
2046 13 robfinch
 00FFE96B 0C60F0                          ldb             #$F0                    ; send scan code select
2047
 00FFE96D 0150F7FFFE60001                 stb             LEDS
2048
 00FFE972 08DF25                          bsr             KeybdSendByte
2049
 00FFE974 08DF29                          bsr             KeybdWaitTx
2050
 00FFE976 05D                             tstb
2051
 00FFE977 02B009                          bmi             kbdiTryAgain
2052
 00FFE979 08DF05                          bsr             KeybdRecvByte   ; wait for response from keyboard
2053
 00FFE97B 04D                             tsta
2054
 00FFE97C 02B004                          bmi             kbdiTryAgain
2055
 00FFE97E 0C10FA                          cmpb    #$FA                                    ; ACK
2056
 00FFE980 02700C                          beq             kbdi0004
2057 4 robfinch
                              kbdiTryAgain:
2058 13 robfinch
 00FFE982 0313FF                          dey
2059
 00FFE984 026FC3                          bne       kbdi0002
2060 4 robfinch
                              .keybdErr:
2061 13 robfinch
 00FFE986 0CCFFE9AE                       ldd             #msgBadKeybd
2062 15 robfinch
 00FFE989 017FFFA4A                       lbsr    DisplayStringCRLF
2063 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
2064 13 robfinch
 00FFE98C 020014                          bra             ledxit
2065 4 robfinch
                              kbdi0004:
2066 13 robfinch
 00FFE98E 0C6002                          ldb             #2                      ; select scan code set #2
2067
 00FFE990 08DF07                          bsr             KeybdSendByte
2068
 00FFE992 08DF0B                          bsr             KeybdWaitTx
2069
 00FFE994 05D                             tstb
2070
 00FFE995 02BFEB                          bmi             kbdiTryAgain
2071
 00FFE997 08DEE7                          bsr             KeybdRecvByte   ; wait for response from keyboard
2072
 00FFE999 04D                             tsta
2073
 00FFE99A 02BFE6                          bmi             kbdiTryAgain
2074
 00FFE99C 0C10FA                          cmpb    #$FA
2075
 00FFE99E 026FE2                          bne             kbdiTryAgain
2076
 00FFE9A0 08DF7A                          bsr             KeybdGetID
2077 4 robfinch
                              ledxit:
2078 13 robfinch
 00FFE9A2 0C6007                          ldb             #$07
2079
 00FFE9A4 08DF63                          bsr             KeybdSetLED
2080
 00FFE9A6 08DF25                          bsr             Wait300ms
2081
 00FFE9A8 0C6000                          ldb             #$00
2082
 00FFE9AA 08DF5D                          bsr             KeybdSetLED
2083
 00FFE9AC 0350A6                          puls    d,y,pc
2084 4 robfinch
 
2085
                              msgBadKeybd:
2086 13 robfinch
 00FFE9AE 04B06507906206F061072           fcb             "Keyboard error",0
2087
 00FFE9B5 06402006507207206F072
2088
 00FFE9BC 000
2089 4 robfinch
 
2090 13 robfinch
                              ;------------------------------------------------------------------------------
2091
                              ; Calculate number of character in input buffer
2092
                              ;
2093
                              ; Parameters:
2094
                              ;               y = $Cn00000 where n is core id
2095
                              ; Returns:
2096
                              ;               d = number of bytes in buffer.
2097
                              ;------------------------------------------------------------------------------
2098
 
2099
                              kbdRcvCount:
2100
 00FFE9BD 04F                             clra
2101
 00FFE9BE 0E6A08128                       ldb             kbdTailRcv,y
2102
 00FFE9C1 0E0A08127                       subb    kbdHeadRcv,y
2103
 00FFE9C4 02C008                          bge             krcXit
2104
 00FFE9C6 0C6040                          ldb             #$40
2105
 00FFE9C8 0E0A08127                       subb    kbdHeadRcv,y
2106
 00FFE9CB 0EBA08128                       addb    kbdTailRcv,y
2107
                              krcXit:
2108
 00FFE9CE 039                             rts
2109
 
2110
 
2111 4 robfinch
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2112
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2113
 
2114 13 robfinch
                              KeybdIRQ:
2115
 00FFE9CF 0150B6FFFE30401                 lda             KEYBD+1                                         ; check status
2116
 00FFE9D4 085080                          bita    #$80                                                    ; was key pressed?
2117
 00FFE9D6 027034                          beq             notKbdIRQ                                       ; if not, exit
2118
 00FFE9D8 0150F6FFFE30400                 ldb             KEYBD                                                   ; get the scan code
2119
 00FFE9DD 01507FFFFE30401                 clr             KEYBD+1                                         ; clear receive register (write $00 to status reg)
2120
 00FFE9E2 034004                          pshs    b                                                                       ; save it off
2121 15 robfinch
 00FFE9E4 0B6FFC010                       lda             IOFocusID                                       ; compute core memory address $Cn0000
2122 13 robfinch
 00FFE9E7 05F                             clrb
2123
 00FFE9E8 048                             asla
2124
 00FFE9E9 048                             asla
2125
 00FFE9EA 048                             asla
2126
 00FFE9EB 048                             asla
2127
 00FFE9EC 08AC00                          ora             #$C00                                                   ; address $Cn0000
2128
 00FFE9EE 01F002                          tfr             d,y                                                             ; y =
2129
 00FFE9F0 08DFCB                          bsr             kbdRcvCount                             ; get count of scan codes in buffer
2130
 00FFE9F2 0C1040                          cmpb    #64                                                             ; check if buffer full?
2131
 00FFE9F4 024017                          bhs             kbdBufFull                              ; if buffer full, ignore new keystroke
2132
 00FFE9F6 01F021                          tfr             y,x                                                             ; compute fifo address
2133
 00FFE9F8 0E6A08128                       ldb             kbdTailRcv,y                    ; b = buffer index
2134
 00FFE9FB 035002                          puls    a                                                                       ; get back scancode
2135
 00FFE9FD 030040                          leax    kbdFifo,x                                       ; x = base address for fifo
2136
 00FFE9FF 0A7845                          sta             b,x                                                             ; store in buffer
2137
 00FFEA01 05C                             incb                                                                            ; increment buffer index
2138
 00FFEA02 0C403F                          andb    #$3f                                                    ; wrap around at 64 chars
2139
 00FFEA04 0E7A08128                       stb             kbdTailRcv,y                    ; update it
2140
 00FFEA07 08601C                          lda             #28                                                             ; Keyboard is IRQ #28
2141 15 robfinch
 00FFEA09 0B7FFC011                       sta             IrqSource                                       ; stuff a byte indicating the IRQ source for PEEK()
2142 13 robfinch
                              notKbdIRQ:
2143
 00FFEA0C 039                             rts
2144
                              kbdBufFull:
2145
 00FFEA0D 032601                          leas    1,s                                                             ; get rid of saved scancode
2146
 00FFEA0F 039                             rts
2147
 
2148
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2149
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2150
 
2151 4 robfinch
                              DBGCheckForKey:
2152 13 robfinch
 00FFEA10 020ECF                          bra             KeybdGetStatus
2153 4 robfinch
 
2154
 
2155
                              ; KeyState2 variable bit meanings
2156
                              ;1176543210
2157
                              ; ||||||||+ = shift
2158
                              ; |||||||+- = alt
2159
                              ; ||||||+-- = control
2160
                              ; |||||+--- = numlock
2161
                              ; ||||+---- = capslock
2162
                              ; |||+----- = scrolllock
2163
                              ; ||+------ = 
2164
                              ; |+------- =    "
2165
                              ; |         =    "
2166
                              ; |         =    "
2167
                              ; |         =    "
2168
                              ; +-------- = extended
2169
 
2170
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2171 13 robfinch
                              ; Keyboard get routine.
2172 4 robfinch
                              ;
2173 13 robfinch
                              ; The routine may get characters directly from the scancode input or less
2174
                              ; directly from the scancode buffer, if things are interrupt driven.
2175
                              ;
2176 4 robfinch
                              ; Parameters:
2177 13 robfinch
                              ;               b:  bit 11 = blocking status 1=blocking, 0=non blocking
2178
                              ;               b:      bit 1  = scancode source 1=scancode buffer, 0=direct
2179 4 robfinch
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2180
 
2181 13 robfinch
                              GetKey:
2182
 00FFEA12 034030                          pshs    x,y
2183
 00FFEA14 0D7126                          stb             KeybdBlock                              ; save off blocking status
2184 4 robfinch
                              dbgk2:
2185 13 robfinch
 00FFEA16 0D6126                          ldb             KeybdBlock
2186
 00FFEA18 034004                          pshs    b
2187
 00FFEA1A 0C5001                          bitb    #1                                                              ; what is the scancode source
2188
 00FFEA1C 02701A                          beq             dbgk20                                          ; branch if direct read
2189
 00FFEA1E 0150B6FFFFFFFE0                 lda             COREID                                          ; compute core memory address
2190
 00FFEA23 05F                             clrb
2191
 00FFEA24 048                             asla
2192
 00FFEA25 048                             asla
2193
 00FFEA26 048                             asla
2194
 00FFEA27 048                             asla
2195
 00FFEA28 08AC00                          ora             #$C00
2196
 00FFEA2A 01F002                          tfr             d,y                                                             ; y = $Cn0000
2197
 00FFEA2C 08DF8F                          bsr             kbdRcvCount
2198
 00FFEA2E 05D                             tstb                                                                            ; anything in buffer?
2199
 00FFEA2F 035004                          puls    b
2200
 00FFEA31 026018                          bne             dbgk1                                                   ; branch if something in buffer
2201
 00FFEA33 05D                             tstb
2202
 00FFEA34 02BFE0                          bmi             dbgk2                                                   ; if no key and blocking - loop
2203
 00FFEA36 02000E                          bra             dbgk24
2204
                              dbgk20:
2205
 00FFEA38 18E000000                       ldy             #0
2206
 00FFEA3B 08DEA4                          bsr             KeybdGetStatus
2207
 00FFEA3D 0C4080                          andb    #$80                                                    ; is key available?
2208
 00FFEA3F 035004                          puls    b
2209
 00FFEA41 026008                          bne             dbgk1                                                   ; branch if key
2210
 00FFEA43 05D                             tstb                                                                            ; block?
2211
 00FFEA44 02BFD0                          bmi             dbgk2                                                   ; If no key and blocking - loop
2212
                              dbgk24:
2213
 00FFEA46 0CCFFFFFF                       ldd             #-1                                                             ; return -1 if no block and no key
2214
 00FFEA49 0350B0                          puls    x,y,pc
2215 4 robfinch
                              dbgk1:
2216 13 robfinch
 00FFEA4B 18C000000                       cmpy    #0
2217
 00FFEA4E 026004                          bne             dbgk22
2218
 00FFEA50 08DEAB                          bsr             KeybdGetScancode        ; get scancode directly
2219
 00FFEA52 020011                          bra             dbgk23
2220
                              dbgk22:
2221
                                      ; Retrieve value from scancode buffer
2222
 00FFEA54 01F021                          tfr             y,x
2223
 00FFEA56 030040                          leax    kbdFifo,x                                       ; x = fifo address
2224
 00FFEA58 0E6A08127                       ldb             kbdHeadRcv,y                    ; b = buffer index
2225
 00FFEA5B 0A6A0D                          lda             b,x                                                             ; get the scancode
2226
 00FFEA5D 05C                             incb                                                                            ; increment fifo index
2227
 00FFEA5E 0C403F                          andb    #$3f                                                    ; and wrap around
2228
 00FFEA60 0E7A08127                       stb             kbdHeadRcv,y                    ; save it back
2229
 00FFEA63 01F089                          tfr             a,b                                                             ; the scancode is needed in accb
2230
                              dbgk23:
2231 4 robfinch
                              ;       lbsr    DispByteAsHex
2232
                                      ; Make sure there is a small delay between scancode reads
2233 13 robfinch
 00FFEA65 08E000014                       ldx             #20
2234 4 robfinch
                              dbgk3:
2235 13 robfinch
 00FFEA68 0301FF                          dex
2236
 00FFEA6A 026FFC                          bne             dbgk3
2237 4 robfinch
                                      ; switch on scan code
2238 13 robfinch
 00FFEA6C 0C10F0                          cmpb    #SC_KEYUP
2239
 00FFEA6E 026004                          bne             dbgk4
2240
 00FFEA70 0D7120                          stb             KeyState1                                       ; make KeyState1 <> 0
2241
 00FFEA72 020FA2                          bra             dbgk2                                                   ; loop back
2242 4 robfinch
                              dbgk4:
2243 13 robfinch
 00FFEA74 0C10E0                          cmpb    #SC_EXTEND
2244
 00FFEA76 026008                          bne             dbgk5
2245
 00FFEA78 096121                          lda             KeyState2
2246
 00FFEA7A 08A800                          ora             #$800
2247
 00FFEA7C 097121                          sta             KeyState2
2248
 00FFEA7E 020F96                          bra             dbgk2
2249 4 robfinch
                              dbgk5:
2250 13 robfinch
 00FFEA80 0C1014                          cmpb    #SC_CTRL
2251
 00FFEA82 026016                          bne             dbgkNotCtrl
2252
 00FFEA84 00D120                          tst             KeyState1
2253
 00FFEA86 026008                          bne             dbgk7
2254
 00FFEA88 096121                          lda             KeyState2
2255
 00FFEA8A 08A004                          ora             #4
2256
 00FFEA8C 097121                          sta             KeyState2
2257
 00FFEA8E 020006                          bra             dbgk8
2258 4 robfinch
                              dbgk7:
2259 13 robfinch
 00FFEA90 096121                          lda             KeyState2
2260
 00FFEA92 084FFB                          anda    #~4
2261
 00FFEA94 097121                          sta             KeyState2
2262 4 robfinch
                              dbgk8:
2263 13 robfinch
 00FFEA96 00F120                          clr             KeyState1
2264
 00FFEA98 020F7C                          bra             dbgk2
2265 4 robfinch
                              dbgkNotCtrl:
2266 13 robfinch
 00FFEA9A 0C1059                          cmpb    #SC_RSHIFT
2267
 00FFEA9C 026016                          bne             dbgkNotRshift
2268
 00FFEA9E 00D120                          tst             KeyState1
2269
 00FFEAA0 026008                          bne             dbgk9
2270
 00FFEAA2 096121                          lda             KeyState2
2271
 00FFEAA4 08A001                          ora             #1
2272
 00FFEAA6 097121                          sta             KeyState2
2273
 00FFEAA8 020006                          bra             dbgk10
2274 4 robfinch
                              dbgk9:
2275 13 robfinch
 00FFEAAA 096121                          lda             KeyState2
2276
 00FFEAAC 084FFE                          anda    #~1
2277
 00FFEAAE 097121                          sta             KeyState2
2278 4 robfinch
                              dbgk10:
2279 13 robfinch
 00FFEAB0 00F120                          clr             KeyState1
2280
 00FFEAB2 020F62                          bra             dbgk2
2281 4 robfinch
                              dbgkNotRshift:
2282 13 robfinch
 00FFEAB4 0C1077                          cmpb    #SC_NUMLOCK
2283
 00FFEAB6 026013                          bne             dbgkNotNumlock
2284
 00FFEAB8 096121                          lda             KeyState2
2285
 00FFEABA 088010                          eora    #16
2286
 00FFEABC 097121                          sta             KeyState2
2287
 00FFEABE 096122                          lda             KeyLED
2288
 00FFEAC0 088002                          eora    #2
2289
 00FFEAC2 097122                          sta             KeyLED
2290
 00FFEAC4 01F089                          tfr             a,b
2291
 00FFEAC6 04F                             clra
2292
 00FFEAC7 08DE40                          bsr             KeybdSetLED
2293
 00FFEAC9 020F4B                          bra             dbgk2
2294 4 robfinch
                              dbgkNotNumlock:
2295 13 robfinch
 00FFEACB 0C1058                          cmpb    #SC_CAPSLOCK
2296
 00FFEACD 026013                          bne             dbgkNotCapslock
2297
 00FFEACF 096121                          lda             KeyState2
2298
 00FFEAD1 088020                          eora    #32
2299
 00FFEAD3 097121                          sta             KeyState2
2300
 00FFEAD5 096122                          lda             KeyLED
2301
 00FFEAD7 088004                          eora    #4
2302
 00FFEAD9 097122                          sta             KeyLED
2303
 00FFEADB 01F089                          tfr             a,b
2304
 00FFEADD 04F                             clra
2305
 00FFEADE 08DE29                          bsr             KeybdSetLED
2306
 00FFEAE0 020F34                          bra             dbgk2
2307 4 robfinch
                              dbgkNotCapslock:
2308 13 robfinch
 00FFEAE2 0C107E                          cmpb    #SC_SCROLLLOCK
2309
 00FFEAE4 026013                          bne             dbgkNotScrolllock
2310
 00FFEAE6 096121                          lda             KeyState2
2311
 00FFEAE8 088040                          eora    #64
2312
 00FFEAEA 097121                          sta             KeyState2
2313
 00FFEAEC 096122                          lda             KeyLED
2314
 00FFEAEE 088001                          eora    #1
2315
 00FFEAF0 097122                          sta             KeyLED
2316
 00FFEAF2 01F089                          tfr             a,b
2317
 00FFEAF4 04F                             clra
2318
 00FFEAF5 08DE12                          bsr             KeybdSetLED
2319
 00FFEAF7 020F1D                          bra             dbgk2
2320 4 robfinch
                              dbgkNotScrolllock:
2321 13 robfinch
 00FFEAF9 0C1011                          cmpb    #SC_ALT
2322
 00FFEAFB 026016                          bne             dbgkNotAlt
2323
 00FFEAFD 00D120                          tst             KeyState1
2324
 00FFEAFF 026008                          bne             dbgk11
2325
 00FFEB01 096121                          lda             KeyState2
2326
 00FFEB03 08A002                          ora             #2
2327
 00FFEB05 097121                          sta             KeyState2
2328
 00FFEB07 020006                          bra             dbgk12
2329 4 robfinch
                              dbgk11:
2330 13 robfinch
 00FFEB09 096121                          lda             KeyState2
2331
 00FFEB0B 084FFD                          anda    #~2
2332
 00FFEB0D 097121                          sta             KeyState2
2333 4 robfinch
                              dbgk12:
2334 13 robfinch
 00FFEB0F 00F120                          clr             KeyState1
2335
 00FFEB11 020F03                          bra             dbgk2
2336 4 robfinch
                              dbgkNotAlt:
2337 13 robfinch
 00FFEB13 00D120                          tst             KeyState1
2338
 00FFEB15 027004                          beq             dbgk13
2339
 00FFEB17 00F120                          clr             KeyState1
2340
 00FFEB19 020EFB                          bra             dbgk2
2341 4 robfinch
                              dbgk13:
2342 13 robfinch
 00FFEB1B 096121                          lda             KeyState2               ; Check for CTRL-ALT-DEL
2343
 00FFEB1D 084006                          anda    #6
2344
 00FFEB1F 081006                          cmpa    #6
2345
 00FFEB21 026008                          bne             dbgk14
2346
 00FFEB23 0C1071                          cmpb    #SC_DEL
2347
 00FFEB25 026004                          bne             dbgk14
2348
 00FFEB27 06E90FFFFFFC                    jmp             [$FFFFFC]               ; jump to NMI vector
2349 4 robfinch
                              dbgk14:
2350 13 robfinch
 00FFEB2B 00D121                          tst             KeyState2               ; extended code?
2351
 00FFEB2D 02A00B                          bpl             dbgk15
2352
 00FFEB2F 096121                          lda             KeyState2
2353
 00FFEB31 0847FF                          anda    #$7FF
2354
 00FFEB33 097121                          sta             KeyState2
2355
 00FFEB35 08EFFE800                       ldx             #keybdExtendedCodes
2356
 00FFEB38 020017                          bra             dbgk18
2357 4 robfinch
                              dbgk15:
2358 13 robfinch
 00FFEB3A 096121                          lda             KeyState2               ; Is CTRL down?
2359
 00FFEB3C 085004                          bita    #4
2360
 00FFEB3E 027005                          beq             dbgk16
2361
 00FFEB40 08EFFE780                       ldx             #keybdControlCodes
2362
 00FFEB43 02000C                          bra             dbgk18
2363 4 robfinch
                              dbgk16:
2364 13 robfinch
 00FFEB45 085001                          bita    #1                                      ; Is shift down?
2365
 00FFEB47 027005                          beq             dbgk17
2366
 00FFEB49 08EFFE680                       ldx             #shiftedScanCodes
2367
 00FFEB4C 020003                          bra             dbgk18
2368 4 robfinch
                              dbgk17:
2369 13 robfinch
 00FFEB4E 08EFFE580                       ldx             #unshiftedScanCodes
2370 4 robfinch
                              dbgk18:
2371 13 robfinch
 00FFEB51 0E690FFFE580                    ldb             b,x                                     ; load accb with ascii from table
2372
 00FFEB55 04F                             clra
2373
 00FFEB56 0350B0                          puls    x,y,pc                  ; and return
2374 4 robfinch
 
2375
 
2376 13 robfinch
 00FFEB58 04B04505904204F041052           fcb             "KEYBOARD"
2377
 00FFEB5F 044
2378
 00FFEB60 FFEB6A                          fcw             KeybdOpen
2379
 00FFEB62 FFEB6B                          fcw             KeybdClose
2380
 00FFEB64 FFEB6C                          fcw             KeybdRead
2381
 00FFEB66 FFEB6D                          fcw             KeybdWrite
2382
 00FFEB68 FFEB6E                          fcw             KeybdSeek
2383 4 robfinch
 
2384
                              ; Keyboard Open:
2385
                              ; Initialize the keyboard buffer head and tail indexes
2386
                              ;
2387
                              KeybdOpen:
2388 13 robfinch
 00FFEB6A 039                             rts
2389 4 robfinch
 
2390
                              ; Keyboard Close:
2391
                              ; Nothing to do except maybe clear the keyboard buffer
2392
                              ;
2393
                              KeybdClose:
2394 13 robfinch
 00FFEB6B 039                             rts
2395 4 robfinch
                              ;
2396
                              KeybdRead:
2397 13 robfinch
 00FFEB6C 039                             rts
2398 4 robfinch
                              ;
2399
                              KeybdWrite:
2400 13 robfinch
 00FFEB6D 039                             rts
2401 4 robfinch
 
2402
                              KeybdSeek:
2403 13 robfinch
 00FFEB6E 039                             rts
2404 4 robfinch
 
2405 13 robfinch
                              ;==============================================================================
2406
                              ; Serial I/O
2407
                              ;==============================================================================
2408
 
2409
                              ; ============================================================================
2410
                              ;        __
2411
                              ;   \\__/ o\    (C) 2022  Robert Finch, Waterloo
2412
                              ;    \  __ /    All rights reserved.
2413
                              ;     \/_//     robfinch@opencores.org
2414
                              ;       ||
2415
                              ;
2416
                              ;
2417
                              ; Serial port routines for a WDC6551 compatible circuit.
2418
                              ;
2419
                              ; This source file is free software: you can redistribute it and/or modify
2420
                              ; it under the terms of the GNU Lesser General Public License as published
2421
                              ; by the Free Software Foundation, either version 3 of the License, or
2422
                              ; (at your option) any later version.
2423
                              ;
2424
                              ; This source file is distributed in the hope that it will be useful,
2425
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
2426
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2427
                              ; GNU General Public License for more details.
2428
                              ;
2429
                              ; You should have received a copy of the GNU General Public License
2430
                              ; along with this program.  If not, see .
2431
                              ;
2432
                              ; ============================================================================
2433
                              ;
2434 4 robfinch
                              ;------------------------------------------------------------------------------
2435 13 robfinch
                              ; Initialize serial port.
2436
                              ;
2437
                              ; Clear buffer indexes. Two bytes are used for the buffer index even though
2438
                              ; only a single byte is needed. This is for convenience in calculating the
2439
                              ; number of characters in the buffer, done later. The upper byte remains at
2440
                              ; zero.
2441
                              ; The port is initialized for 9600 baud, 1 stop bit and 8 bits data sent.
2442
                              ; The internal baud rate generator is used.
2443
                              ;
2444
                              ; Parameters:
2445
                              ;               none
2446
                              ; Modifies:
2447
                              ;               d
2448
                              ; Returns:
2449
                              ;               none
2450
                              ;------------------------------------------------------------------------------
2451
 
2452
                              InitSerial:
2453
                              SerialInit:
2454
 00FFEB6F 04F                             clra
2455
 00FFEB70 05F                             clrb
2456
 00FFEB71 0DD130                          std             SerHeadRcv-1
2457
 00FFEB73 0DD132                          std             SerTailRcv-1
2458
 00FFEB75 0DD135                          std             SerHeadXmit-1
2459
 00FFEB77 0DD137                          std             SerTailXmit-1
2460
 00FFEB79 00F139                          clr             SerRcvXon
2461
 00FFEB7B 00F140                          clr             SerRcvXoff
2462
 00FFEB7D 0150B6FFFFFFFE0                 lda             COREID
2463
                              sini1:
2464 15 robfinch
 00FFEB82 0B1FFC010                       cmpa    IOFocusID
2465 13 robfinch
 00FFEB85 026FFB                          bne             sini1
2466
 00FFEB87 0C6009                          ldb             #$09                                            ; dtr,rts active, rxint enabled, no parity
2467
 00FFEB89 0150F7FFFE30102                 stb             ACIA+ACIA_CMD
2468 14 robfinch
 00FFEB8E 0C601F                          ldb             #$1F                                            ; baud 9600, 1 stop bit, 8 bit, internal baud gen
2469 13 robfinch
 00FFEB90 0150F7FFFE30103                 stb             ACIA+ACIA_CTRL
2470
 00FFEB95 0C60A6                          ldb             #$0A6                                           ; diable fifos, reset fifos
2471
 00FFEB97 0150F7FFFE3010B                 stb             ACIA+ACIA_CTRL2
2472
 00FFEB9C 039                             rts
2473
 
2474
                              ;------------------------------------------------------------------------------
2475
                              ; SerialGetChar
2476
                              ;
2477
                              ; Check the serial port buffer to see if there's a char available. If there's
2478
                              ; a char available then return it. If the buffer is almost empty then send an
2479
                              ; XON.
2480
                              ;
2481
                              ; Stack Space:
2482
                              ;               2 words
2483
                              ; Parameters:
2484
                              ;               none
2485
                              ; Modifies:
2486
                              ;               none
2487
                              ; Returns:
2488
                              ;               d = character or -1
2489
                              ;------------------------------------------------------------------------------
2490
 
2491
                              SerialGetChar:
2492
 00FFEB9D 034030                                  pshs    x,y
2493
 00FFEB9F 18E000000                               ldy             #0
2494
 00FFEBA2 01A010                                  sei                                                                             ; disable interrupts
2495
 00FFEBA4 08D082                                  bsr             SerialRcvCount                  ; check number of chars in receive buffer
2496
 00FFEBA6 0C1008                                  cmpb    #8                                                      ; less than 8?
2497
 00FFEBA8 02200C                                  bhi             sgc2
2498
 00FFEBAA 0D6139                                  ldb             SerRcvXon                               ; skip sending XON if already sent
2499
 00FFEBAC 026008                                  bne       sgc2            ; XON already sent?
2500
 00FFEBAE 0C6011                                  ldb             #XON                                            ; if <8 send an XON
2501
 00FFEBB0 00F140                                  clr             SerRcvXoff                      ; clear XOFF status
2502
 00FFEBB2 0D7139                                  stb             SerRcvXon                               ; flag so we don't send it multiple times
2503
 00FFEBB4 08D052                                  bsr             SerialPutChar
2504
                              sgc2:
2505
 00FFEBB6 0D6131                                  ldb             SerHeadRcv                      ; check if anything is in buffer
2506
 00FFEBB8 0D1133                                  cmpb    SerTailRcv
2507
 00FFEBBA 02700A                                  beq             sgcNoChars                      ; no?
2508
 00FFEBBC 08EBFF000                               ldx             #SerRcvBuf
2509
 00FFEBBF 04F                                     clra
2510
 00FFEBC0 0E6835                                  ldb             b,x                                                     ; get byte from buffer
2511
 00FFEBC2 00C131                                  inc             SerHeadRcv                      ; 4k wrap around
2512
 00FFEBC4 020003                                  bra             sgcXit
2513
                              sgcNoChars:
2514
 00FFEBC6 0CCFFFFFF                               ldd             #-1
2515
                              sgcXit:
2516
 00FFEBC9 01C0EF                                  cli
2517
 00FFEBCB 0350B0                                  puls    x,y,pc
2518
 
2519
                              ;------------------------------------------------------------------------------
2520
                              ; SerialPeekChar
2521
                              ;
2522
                              ; Check the serial port buffer to see if there's a char available. If there's
2523
                              ; a char available then return it. But don't update the buffer indexes. No need
2524
                              ; to send an XON here.
2525
                              ;
2526
                              ; Stack Space:
2527
                              ;               0 words
2528
                              ; Parameters:
2529
                              ;               none
2530
                              ; Modifies:
2531
                              ;               none
2532
                              ; Returns:
2533
                              ;               d = character or -1
2534
                              ;------------------------------------------------------------------------------
2535
 
2536
                              SerialPeekChar:
2537
 00FFEBCD 034011                          pshs    x,ccr
2538
 00FFEBCF 01A010                          sei
2539
 00FFEBD1 0D6131                          ldb             SerHeadRcv                              ; check if anything is in buffer
2540
 00FFEBD3 0D1133                          cmpb    SerTailRcv
2541
 00FFEBD5 027008                          beq             spcNoChars                              ; no?
2542
 00FFEBD7 08EBFF000                       ldx             #SerRcvBuf
2543
 00FFEBDA 04F                             clra
2544
 00FFEBDB 0E6815                          ldb             b,x                                                             ; get byte from buffer
2545
 00FFEBDD 020003                          bra             spcXit
2546
                              spcNoChars:
2547
 00FFEBDF 0CCFFFFFF                       ldd             #-1
2548
                              spcXit:
2549
 00FFEBE2 035091                          puls    x,ccr,pc
2550
 
2551
                              ;------------------------------------------------------------------------------
2552
                              ; SerialPeekChar
2553
                              ;               Get a character directly from the I/O port. This bypasses the input
2554
                              ; buffer.
2555
                              ;
2556
                              ; Stack Space:
2557
                              ;               0 words
2558
                              ; Parameters:
2559
                              ;               none
2560
                              ; Modifies:
2561
                              ;               d
2562
                              ; Returns:
2563
                              ;               d = character or -1
2564
                              ;------------------------------------------------------------------------------
2565
 
2566
                              SerialPeekCharDirect:
2567
 00FFEBE4 0150B6FFFFFFFE0                 lda             COREID                                                  ; Ensure we have the IO Focus
2568 15 robfinch
 00FFEBE9 0B1FFC010                       cmpa    IOFocusID
2569 13 robfinch
 00FFEBEC 026014                          bne             spcd0001
2570
                                      ; Disallow interrupts between status read and rx read.
2571
 00FFEBEE 01A010                          sei
2572
 00FFEBF0 0150F6FFFE30101                 ldb             ACIA+ACIA_STAT
2573
 00FFEBF5 0C5008                          bitb    #8                                                                      ; look for Rx not empty
2574
 00FFEBF7 027009                          beq             spcd0001
2575
 00FFEBF9 04F                             clra
2576
 00FFEBFA 0150F6FFFE30100                 ldb             ACIA+ACIA_RX
2577
 00FFEBFF 01C0EF                          cli
2578
 00FFEC01 039                             rts
2579
                              spcd0001:
2580
 00FFEC02 0CCFFFFFF                       ldd             #-1
2581
 00FFEC05 01C0EF                          cli
2582
 00FFEC07 039                             rts
2583
 
2584
                              ;------------------------------------------------------------------------------
2585
                              ; SerialPutChar
2586
                              ;    Put a character to the serial transmitter. This routine blocks until the
2587
                              ; transmitter is empty.
2588
                              ;
2589
                              ; Stack Space
2590
                              ;               0 words
2591
                              ; Parameters:
2592
                              ;               b = character to put
2593
                              ; Modifies:
2594
                              ;               none
2595
                              ;------------------------------------------------------------------------------
2596
 
2597
                              SerialPutChar:
2598
 00FFEC08 034003                          pshs    a,ccr
2599
                              spc0001:
2600
 00FFEC0A 0150B6FFFFFFFE0                 lda             COREID                                  ; Ensure we have the IO Focus
2601 15 robfinch
 00FFEC0F 0B1FFC010                       cmpa    IOFocusID
2602 13 robfinch
 00FFEC12 026FF6                          bne             spc0001
2603
 00FFEC14 01C0EF                          cli                                                                             ; provide a window for an interrupt to occur
2604
 00FFEC16 01A010                          sei
2605
                                      ; Between the status read and the transmit do not allow an
2606
                                      ; intervening interrupt.
2607
 00FFEC18 0150B6FFFE30101                 lda             ACIA+ACIA_STAT  ; wait until the uart indicates tx empty
2608
 00FFEC1D 085010                          bita    #16                                                     ; bit #4 of the status reg
2609
 00FFEC1F 027FE9                          beq             spc0001                     ; branch if transmitter is not empty
2610
 00FFEC21 0150F7FFFE30100                 stb             ACIA+ACIA_TX            ; send the byte
2611
 00FFEC26 035083                          puls    a,ccr,pc
2612
 
2613
                              ;------------------------------------------------------------------------------
2614
                              ; Calculate number of character in input buffer
2615
                              ;
2616
                              ; Parameters:
2617
                              ;               y = 0 if current core, otherwise reference to core memory area $Cyxxxx
2618
                              ; Returns:
2619
                              ;               d = number of bytes in buffer.
2620
                              ;------------------------------------------------------------------------------
2621
 
2622
                              SerialRcvCount:
2623
 00FFEC28 04F                             clra
2624
 00FFEC29 0E6A08133                       ldb             SerTailRcv,y
2625
 00FFEC2C 0E0A08131                       subb    SerHeadRcv,y
2626
 00FFEC2F 02C009                          bge             srcXit
2627
 00FFEC31 0CC001000                       ldd             #$1000
2628
 00FFEC34 0A3A08131                       subd    SerHeadRcv,y
2629
 00FFEC37 0E3A08133                       addd    SerTailRcv,y
2630
                              srcXit:
2631
 00FFEC3A 039                             rts
2632
 
2633
                              ;------------------------------------------------------------------------------
2634
                              ; Serial IRQ routine
2635
                              ;
2636
                              ; Keeps looping as long as it finds characters in the ACIA recieve buffer/fifo.
2637
                              ; Received characters are buffered. If the buffer becomes full, new characters
2638
                              ; will be lost.
2639
                              ;
2640
                              ; Parameters:
2641
                              ;               none
2642
                              ; Modifies:
2643
                              ;               d,x
2644
                              ; Returns:
2645
                              ;               none
2646
                              ;------------------------------------------------------------------------------
2647
 
2648
                              SerialIRQ:
2649
                              sirqNxtByte:
2650
 00FFEC3B 0150F6FFFE30101                 ldb             ACIA+ACIA_STAT  ; check the status
2651
 00FFEC40 0C5008                          bitb    #$08                                            ; bit 3 = rx full
2652
 00FFEC42 027049                          beq             notRxInt
2653
 00FFEC44 0150F6FFFE30100                 ldb             ACIA+ACIA_RX            ; get data from Rx buffer to clear interrupt
2654
 00FFEC49 0C1014                          cmpb    #CTRLT                                  ; detect special keystroke
2655
 00FFEC4B 026000                          bne     sirq0001
2656
                              ;       bsr     DumpTraceQueue
2657
                              sirq0001:
2658
 00FFEC4D 034004                          pshs    b
2659
                                      ; Compute receive buffer address
2660 15 robfinch
 00FFEC4F 0B6FFC010                       lda             IOFocusID
2661 13 robfinch
 00FFEC52 048                             asla
2662
 00FFEC53 048                             asla
2663
 00FFEC54 048                             asla
2664
 00FFEC55 048                             asla
2665
 00FFEC56 08AC00                          ora             #$C00
2666
 00FFEC58 05F                             clrb
2667
 00FFEC59 01F002                          tfr             d,y
2668
 00FFEC5B 035004                          puls    b
2669
 00FFEC5D 0A6A08133                       lda             SerTailRcv,y                    ; check if recieve buffer full
2670
 00FFEC60 04C                             inca
2671
 00FFEC61 0A1A08131                       cmpa    SerHeadRcv,y
2672
 00FFEC64 027027                          beq             sirqRxFull
2673
 00FFEC66 0A7A08133                       sta             SerTailRcv,y            ; update tail pointer
2674
 00FFEC69 04A                             deca                                                                    ; backup
2675
 00FFEC6A 01E089                          exg             a,b
2676
 00FFEC6C 030A0A000BFF000                 leax    SerRcvBuf,y                     ; x = buffer address
2677
 00FFEC71 0A7A0F                          sta             b,x                                                     ; store recieved byte in buffer
2678
 00FFEC73 06DA08140                       tst             SerRcvXoff,y            ; check if xoff already sent
2679
 00FFEC76 026FC3                          bne             sirqNxtByte
2680
 00FFEC78 08DFAE                          bsr             SerialRcvCount  ; if more than 4080 chars in buffer
2681
 00FFEC7A 0C1FF0                          cmpb    #4080
2682
 00FFEC7C 025FBD                          blo             sirqNxtByte
2683
 00FFEC7E 0C6013                          ldb             #XOFF                                           ; send an XOFF
2684
 00FFEC80 06FA08139                       clr             SerRcvXon,y                     ; clear XON status
2685
 00FFEC83 0E7A08140                       stb             SerRcvXoff,y            ; set XOFF status
2686
 00FFEC86 0150F7FFFE30100                 stb             ACIA+ACIA_TX
2687
 00FFEC8B 020FAE                          bra             sirqNxtByte     ; check the status for another byte
2688
                              sirqRxFull:
2689
                              notRxInt:
2690
 00FFEC8D 039                             rts
2691
 
2692
                              nmeSerial:
2693
 00FFEC8E 05306507206906106C000           fcb             "Serial",0
2694
 
2695
                              ;------------------------------------------------------------------------------
2696
                              ; Put a string to the serial port.
2697
                              ;
2698
                              ; Parameters:
2699
                              ;               d = pointer to string
2700
                              ; Modifies:
2701
                              ;               none
2702
                              ; Returns:
2703
                              ;               none
2704
                              ;------------------------------------------------------------------------------
2705
 
2706
                              SerialPutString:
2707
 00FFEC95 034016                          pshs    d,x
2708
 00FFEC97 01F001                          tfr             d,x
2709
                              sps2:
2710
 00FFEC99 0E6804                          ldb             ,x
2711
 00FFEC9B 027006                          beq             spsXit
2712
 00FFEC9D 030001                          inx
2713
 00FFEC9F 08DF67                          bsr             SerialPutChar
2714
 00FFECA1 020FF6                          bra             sps2
2715
                              spsXit:
2716
 00FFECA3 035096                          puls    d,x,pc
2717
 
2718
                              ;------------------------------------------------------------------------------
2719
                              ; A little routine to test serial output.
2720
                              ;
2721
                              ; Parameters:
2722
                              ;               none
2723
                              ; Modifies:
2724
                              ;               none
2725
                              ; Returns:
2726
                              ;               none
2727
                              ;------------------------------------------------------------------------------
2728
 
2729
                              SerialOutputTest:
2730
 00FFECA5 034006                          pshs    d
2731
 00FFECA7 0CCFFECC5                       ldd             #msgSerialTest
2732 15 robfinch
 00FFECAA 017FFF712                       lbsr    DisplayString
2733 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2734
 00FFECAD 08DEC0                          bsr             SerialInit
2735
                              sotst1:
2736
 00FFECAF 0C6011                          ldb             #XON
2737
 00FFECB1 08DF55                          bsr             SerialPutChar
2738
 00FFECB3 08DF53                          bsr             SerialPutChar
2739
 00FFECB5 08DF51                          bsr             SerialPutChar
2740
 00FFECB7 0CCFFECC5                       ldd             #msgSerialTest
2741
 00FFECBA 08DFD9                          bsr             SerialPutString
2742
 00FFECBC 01700001B                       lbsr    INCH
2743
 00FFECBF 0C1003                          cmpb    #CTRLC
2744
 00FFECC1 026FEC                          bne             sotst1
2745
 00FFECC3 035086                          puls    d,pc
2746
 
2747
                              msgSerialTest:
2748
 00FFECC5 05306507206906106C020           fcb     "Serial port test",CR,LF,0
2749
 00FFECCC 07006F072074020074065
2750
 00FFECD3 07307400D00A000
2751
 
2752
 
2753
                              ;------------------------------------------------------------------------------
2754 4 robfinch
                              ; Check if there is a keyboard character available. If so return true (<0)
2755
                              ; otherwise return false (0) in accb.
2756
                              ;------------------------------------------------------------------------------
2757
                              ;
2758
                              KeybdCheckForKeyDirect:
2759 13 robfinch
 00FFECD8 020D36                          bra             DBGCheckForKey
2760 4 robfinch
 
2761
                              ;------------------------------------------------------------------------------
2762
                              ;------------------------------------------------------------------------------
2763
                              INCH:
2764 13 robfinch
 00FFECDA 034004                          pshs    b
2765
                              INCH2:
2766
 00FFECDC 0150F6FFFFFFFE0                 ldb             COREID
2767 15 robfinch
 00FFECE1 0F1FFC010                       cmpb    IOFocusID       ; if we do not have focus, block
2768 13 robfinch
 00FFECE4 026FF6                          bne             INCH2
2769
                              ;       ldb             #$800                   ; block if no key available, get scancode directly
2770
                              ;       bra             GetKey
2771
                              ;       jsr             [CharInVec]     ; vector is being overwritten somehow
2772
 00FFECE6 017FFFEFB                       lbsr    SerialPeekCharDirect
2773
*** warning 1: Long branch within short branch range could be optimized
2774
 00FFECE9 04D                             tsta
2775
 00FFECEA 02B003                          bmi             INCH1                   ; block if no key available
2776
 00FFECEC 032601                          leas    1,s                             ; get rid of blocking status
2777
 00FFECEE 039                             rts
2778
                              INCH1:
2779
 00FFECEF 035004                          puls    b                                       ; check blocking status
2780
 00FFECF1 05D                             tstb
2781
 00FFECF2 02BFE6                          bmi     INCH                    ; if blocking, loop
2782
 00FFECF4 0CCFFFFFF                       ldd             #-1                             ; return -1 if no char available
2783
 00FFECF7 039                             rts
2784 4 robfinch
 
2785
                              INCHE:
2786 13 robfinch
 00FFECF8 08DFE0                          bsr             INCH
2787
 00FFECFA 020009                          bra             INCHEK3
2788 4 robfinch
 
2789
                              INCHEK:
2790 13 robfinch
 00FFECFC 08DFDC                          bsr             INCH
2791
 00FFECFE 01507DFFFFFCA00                 tst             KeybdEcho
2792
 00FFED03 02700C                          beq             INCHEK1
2793 4 robfinch
                              INCHEK3:
2794 13 robfinch
 00FFED05 08100D                          cmpa    #CR
2795
 00FFED07 026005                          bne             INCHEK2
2796
 00FFED09 017FFE3C6                       lbsr            CRLF
2797 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
2798 13 robfinch
 00FFED0C 020003                          bra             INCHEK1
2799 4 robfinch
                              INCHEK2:
2800 15 robfinch
 00FFED0E 017FFF5ED                       lbsr    DisplayChar
2801 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2802 4 robfinch
                              INCHEK1:
2803 13 robfinch
 00FFED11 039                             rts
2804 4 robfinch
 
2805
                              OUTCH:
2806 13 robfinch
 00FFED12 06E90F000800                    jmp             [CharOutVec]
2807 4 robfinch
 
2808
                              ;------------------------------------------------------------------------------
2809
                              ; r1 0=echo off, non-zero = echo on
2810
                              ;------------------------------------------------------------------------------
2811
                              ;
2812
                              SetKeyboardEcho:
2813 13 robfinch
 00FFED16 0150F7FFFFFCA00                 stb             KeybdEcho
2814
 00FFED1B 039                             rts
2815 4 robfinch
 
2816
 
2817
                              ;------------------------------------------------------------------------------
2818
                              ; Parameters:
2819
                              ;               x,d     bitmap of sprites to enable
2820
                              ;------------------------------------------------------------------------------
2821
 
2822
                              ShowSprites:
2823 13 robfinch
 00FFED1C 0150BFFFFE103C0                 stx             SPRITE_CTRL+SPRITE_EN
2824
 00FFED21 0150FDFFFE103C2                 std             SPRITE_CTRL+SPRITE_EN+2
2825
 00FFED26 039                             rts
2826 4 robfinch
 
2827
                              ;==============================================================================
2828 13 robfinch
                              ; Femtiki Operating System.
2829
                              ;==============================================================================
2830
 
2831
                              OSCallTbl:
2832
 00FFED27 000000                          fcw             0
2833
 00FFED29 000000                          fcw             0
2834
 00FFED2B 000000                          fcw             0
2835
 00FFED2D 000000                          fcw             0
2836
 00FFED2F 000000                          fcw             0
2837
 00FFED31 000000                          fcw             0
2838
 00FFED33 000000                          fcw             0
2839
 00FFED35 000000                          fcw             0
2840
 00FFED37 000000                          fcw             0
2841
 00FFED39 000000                          fcw             0
2842
 00FFED3B 000000                          fcw             0
2843
 00FFED3D 000000                          fcw             0
2844
 00FFED3F 000000                          fcw             0
2845
 00FFED41 000000                          fcw             0
2846
 00FFED43 000000                          fcw             0
2847
 00FFED45 000000                          fcw             0
2848
 00FFED47 000000                          fcw             0
2849
 00FFED49 000000                          fcw             0
2850
 00FFED4B 000000                          fcw             0
2851
 00FFED4D 000000                          fcw             0
2852
 00FFED4F 000000                          fcw             0
2853
 00FFED51 000000                          fcw             0
2854 15 robfinch
 00FFED53 FFED70                          fcw             ReleaseIOFocus
2855 13 robfinch
 00FFED55 000000                          fcw             0
2856 15 robfinch
 00FFED57 FFED59                          fcw             RequestIOFocus
2857 13 robfinch
 
2858 15 robfinch
                              NumOSFuncs      EQU     (*-OSCallTbl)/2
2859 13 robfinch
 
2860
                              RequestIOFocus:
2861 15 robfinch
 00FFED59 0150F6FFFFFFFE0                 ldb             COREID
2862
 00FFED5E 08EFFC000                       ldx             #IOFocusList
2863
 00FFED61 03A                             abx
2864
 00FFED62 0A7804                          sta             ,x
2865
 00FFED64 07DFFC010                       tst             IOFocusID
2866
 00FFED67 1260006FF                       lbne    oscx
2867
 00FFED6A 0F7FFC010                       stb             IOFocusID
2868
 00FFED6D 0160006F9                       lbra    oscx
2869 13 robfinch
 
2870
                              ReleaseIOFocus:
2871 15 robfinch
 00FFED70 0150F6FFFFFFFE0                 ldb             COREID
2872
 00FFED75 08EFFC000                       ldx             #IOFocusList
2873
 00FFED78 03A                             abx
2874
 00FFED79 06F804                          clr             ,x                                              ; clear the request indicator
2875
 00FFED7B 017FFF480                       lbsr    CopyScreenToVirtualScreen
2876 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2877 15 robfinch
 00FFED7E 0F1FFC010                       cmpb    IOFocusID                       ; are we the one with the focus?
2878
 00FFED81 1260006E5                       lbne    oscx
2879 13 robfinch
                                      ; We had the focus, so now a new core needs the focus.
2880
                                      ; Search the focus list for a requestor. If no requester
2881
                                      ; is found, give focus to core #1.
2882 15 robfinch
 00FFED84 08600F                          lda             #15
2883 13 robfinch
                              riof2:
2884 15 robfinch
 00FFED86 05C                             incb
2885
 00FFED87 0C400F                          andb    #15
2886
 00FFED89 03A                             abx
2887
 00FFED8A 06D804                          tst             ,x
2888
 00FFED8C 026009                          bne             riof1
2889
 00FFED8E 04A                             deca
2890
 00FFED8F 026FF5                          bne             riof2
2891 13 robfinch
                                      ; If no focus is requested by anyone, give to core #1
2892 15 robfinch
 00FFED91 0C6001                          ldb             #1
2893
 00FFED93 086018                          lda             #24
2894
 00FFED95 0A7804                          sta             ,x
2895 13 robfinch
                              riof1:
2896 15 robfinch
 00FFED97 0F7FFC010                       stb             IOFocusID
2897
 00FFED9A 017FFF42A                       lbsr    CopyVirtualScreenToScreen
2898 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2899 15 robfinch
 00FFED9D 0160006C9                       lbra    oscx
2900 13 robfinch
 
2901
 
2902
                              ;==============================================================================
2903
                              ;==============================================================================
2904
 
2905 15 robfinch
                              ;------------------------------------------------------------------------------
2906
                              ; Seed the random number generator. All channels are seeded with the same
2907
                              ; value.
2908 13 robfinch
                              ;
2909 15 robfinch
                              ; Parameters:
2910
                              ;               d = 'z' part of seed
2911
                              ;               x = 'w' part of seed
2912
                              ; Returns:
2913
                              ;               none
2914
                              ;------------------------------------------------------------------------------
2915 13 robfinch
 
2916 15 robfinch
                              mon_srand:
2917
 00FFEDA0 18E000000                       ldy     #0
2918
                              mon_srand1:
2919
 00FFEDA3 0151BFFFFE30604                 sty     PRNG+4                          ; select channel
2920
 00FFEDA8 01507FFFFE30608                 clr     PRNG+8
2921
 00FFEDAD 01507FFFFE30609                 clr PRNG+9
2922
 00FFEDB2 0150FDFFFE3060A                 std     PRNG+10                         ; update low half of value
2923
 00FFEDB7 01507FFFFE3060C                 clr PRNG+12
2924
 00FFEDBC 01507FFFFE3060D                 clr PRNG+13
2925
 00FFEDC1 0150BFFFFE3060E                 stx     PRNG+14                         ; update low half of value
2926
 00FFEDC6 031201                          iny
2927
 00FFEDC8 18C000400                       cmpy    #$400                           ; 1k channels
2928
 00FFEDCB 025FD6                          blo             mon_srand1
2929
 00FFEDCD 039                             rts
2930 13 robfinch
 
2931 15 robfinch
                              ;------------------------------------------------------------------------------
2932
                              ; Get a random number and generate the next one.
2933
                              ;
2934
                              ; Parameters:
2935
                              ;               d = channel to use
2936
                              ; Returns:
2937
                              ;               x,d = 36 bit random value
2938
                              ;------------------------------------------------------------------------------
2939 13 robfinch
 
2940 15 robfinch
                              mon_rand:
2941
 00FFEDCE 0150FDFFFE30604                 std     PRNG+4                          ; select channel
2942
 00FFEDD3 0150BEFFFE30600                 ldx     PRNG+0
2943
 00FFEDD8 0150FCFFFE30602                 ldd     PRNG+2
2944
 00FFEDDD 0150F7FFFE30603                 stb     PRNG+3                          ; trigger calc of next number
2945
 00FFEDE2 039                             rts
2946 13 robfinch
 
2947 15 robfinch
                              ;==============================================================================
2948
                              ; System Monitor
2949
                              ;==============================================================================
2950 13 robfinch
 
2951 15 robfinch
                              ; Command Table
2952 13 robfinch
 
2953 15 robfinch
                              cmdTable1:
2954
 00FFEDE3 03C83E                          fcb             '<','>'+$800
2955
 00FFEDE5 062873                          fcb             'b','s'+$800
2956
 00FFEDE7 062863                          fcb             'b','c'+$800
2957
 00FFEDE9 044852                          fcb             'D','R'+$800
2958
 00FFEDEB 844                             fcb             'D'+$800
2959
 00FFEDEC 83A                             fcb             ':'+$800
2960
 00FFEDED 046049847                       fcb             "FI",'G'+$800
2961
 00FFEDF0 04604984C                       fcb             "FI",'L'+$800
2962
 00FFEDF3 04684C                          fcb             'F','L'+$800
2963
 00FFEDF5 84A                             fcb             'J'+$800
2964
 00FFEDF6 05204104D054045053854           fcb             "RAMTES",'T'+$800
2965
 00FFEDFD 053050844                       fcb             "SP",'D'+$800
2966
 00FFEE00 054049852                       fcb             "TI",'R'+$800
2967
 00FFEE03 855                             fcb             'U'+$800
2968
 00FFEE04 065078069874                    fcb             "exi",'t'+$800
2969
 00FFEE08 83F                             fcb             '?'+$800
2970
 00FFEE09 04304C853                       fcb             "CL",'S'+$800
2971
 00FFEE0C 000000                          fcw             0
2972 13 robfinch
 
2973 15 robfinch
                              cmdTable2:
2974
 00FFEE0E FFEF11                          fcw             Redirect
2975
 00FFEE10 FFF4AC                          fcw             ArmBreakpoint
2976
 00FFEE12 FFF4D3                          fcw             DisarmBreakpoint
2977
 00FFEE14 FFF2CF                          fcw             DumpRegs
2978
 00FFEE16 FFF209                          fcw             DumpMemory
2979
 00FFEE18 FFF265                          fcw             EditMemory
2980
 00FFEE1A FE0000                          fcw             $FE0000                                 ; FIG forth
2981
 00FFEE1C FFF2A5                          fcw             FillMemory
2982
 00FFEE1E FFF390                          fcw             DumpIOFocusList
2983
 00FFEE20 FFF31A                          fcw             jump_to_code
2984
 00FFEE22 FFD443                          fcw             dramtest
2985
 00FFEE24 FF8000                          fcw             $FF8000                                 ; sprite demo
2986
 00FFEE26 FFE4D0                          fcw             rtc_read
2987
 00FFEE28 FF8003                          fcw             $FF8003                                 ; unassembler
2988
 00FFEE2A FFF451                          fcw             xitMonitor
2989
 00FFEE2C FFEF37                          fcw             PromptHelp
2990
 00FFEE2E FFEF3F                          fcw             PromptClearscreen
2991 13 robfinch
 
2992
                              CmdPrompt:
2993 15 robfinch
 00FFEE30 017FFE29F                       lbsr    CRLF
2994 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2995 15 robfinch
 00FFEE33 0C6024                          ldb             #'$'
2996
 00FFEE35 017FFFEDA                       lbsr    OUTCH
2997 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
2998 15 robfinch
 00FFEE38 016FFFED7                       lbra    OUTCH
2999 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3000
 
3001
                              msgF09Starting:
3002 15 robfinch
 00FFEE3B 04606506D07406906B069           fcb             "Femtiki F09 Multi-core OS Starting",CR,LF,0
3003
 00FFEE42 02004603003902004D075
3004
 00FFEE49 06C07406902D06306F072
3005
 00FFEE50 06502004F053020053074
3006
 00FFEE57 06107207406906E06700D
3007
 00FFEE5E 00A000
3008 13 robfinch
 
3009 4 robfinch
                              MonitorStart:
3010 15 robfinch
 00FFEE60 07F000810                       clr             BreakpointFlag
3011
 00FFEE63 07F000811                       clr             NumSetBreakpoints
3012
 00FFEE66 0CC00007B                       ldd             #123
3013
 00FFEE69 08E00028E                       ldx             #654
3014
 00FFEE6C 017FFFF31                       lbsr    mon_srand
3015 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3016 15 robfinch
 00FFEE6F 0CCFFEE3B                       ldd             #msgF09Starting
3017
 00FFEE72 017FFF54A                       lbsr    DisplayString
3018 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3019 15 robfinch
 00FFEE75 0CCFFF06E                       ldd             #HelpMsg
3020
 00FFEE78 017FFF544                       lbsr    DisplayString
3021
*** warning 1: Long branch within short branch range could be optimized
3022
 00FFEE7B 0CCFFEE30                       ldd             #CmdPrompt
3023
 00FFEE7E 0FD000808                       std             CmdPromptJI
3024
 00FFEE81 0CCFFF055                       ldd             #DisplayErr
3025
 00FFEE84 0FD00080C                       std             MonErrVec
3026
 00FFEE87 0CC0063FF                       ldd             #$63FF                  ; default app stack
3027
 00FFEE8A 0FD000908                       std             mon_SSAVE
3028
 00FFEE8D 07F00090E                       clr             mon_DPRSAVE     ;
3029
 00FFEE90 01F0A8                          tfr             ccr,a
3030
 00FFEE92 0B700090F                       sta             mon_CCRSAVE
3031
 00FFEE95 07F00090A                       clr             mon_PCSAVE
3032
 00FFEE98 0CCFFEEA7                       ldd             #Monitor
3033
 00FFEE9B 0FD00090B                       std             mon_PCSAVE+1
3034
 00FFEE9E 07F000902                       clr             mon_XSAVE
3035
 00FFEEA1 07F000904                       clr             mon_YSAVE
3036
 00FFEEA4 07F000906                       clr             mon_USAVE
3037 4 robfinch
                              Monitor:
3038 15 robfinch
 00FFEEA7 03280F006FFF                    leas    $6FFF                           ; reset stack pointer
3039
 00FFEEAB 05F                             clrb                                                    ; turn off keyboard echo
3040
 00FFEEAC 017FFFE67                       lbsr    SetKeyboardEcho
3041 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3042
                                      ; Reset IO vectors
3043 15 robfinch
 00FFEEAF 0CCFFEBE4                       ldd             #SerialPeekCharDirect
3044
 00FFEEB2 0FD000804                       std             CharInVec
3045
 00FFEEB5 0CCFFE2FE                       ldd             #DisplayChar
3046
 00FFEEB8 0FD000800                       std             CharOutVec
3047
 00FFEEBB 0CCFFEE30                       ldd             #CmdPrompt
3048
 00FFEEBE 0FD000808                       std             CmdPromptJI
3049 4 robfinch
                              ;       jsr             RequestIOFocus
3050
                              PromptLn:
3051 15 robfinch
 00FFEEC1 0AD90F000808                    jsr             [CmdPromptJI]
3052 4 robfinch
 
3053
                              ; Get characters until a CR is keyed
3054
 
3055
                              Prompt3:
3056 15 robfinch
 00FFEEC5 0CCFFFFFF                       ldd             #-1                                     ; block until key present
3057
 00FFEEC8 017FFFE0F                       lbsr    INCH
3058 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3059 15 robfinch
 00FFEECB 0C100D                          cmpb    #CR                                     ; carriage return?
3060
 00FFEECD 027005                          beq             Prompt1
3061
 00FFEECF 017FFFE40                       lbsr    OUTCH                           ; spit out the character
3062 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3063 15 robfinch
 00FFEED2 020FF1                          bra             Prompt3                 ; and keep going
3064 4 robfinch
 
3065
                              ; Process the screen line that the CR was keyed on
3066
                              ;
3067
                              Prompt1:
3068 15 robfinch
 00FFEED4 0CC005050                       ldd             #$5050
3069
 00FFEED7 0150FDFFFE60001                 std             LEDS
3070 13 robfinch
                              ;       ldb             RunningID
3071
                              ;       cmpb    #61
3072
                              ;       bhi             Prompt3
3073 15 robfinch
 00FFEEDC 00F111                          clr             CursorCol                       ; go back to the start of the line
3074
 00FFEEDE 017FFF3FA                       lbsr    CalcScreenLoc   ; calc screen memory location
3075 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3076 15 robfinch
 00FFEEE1 01F002                          tfr             d,y
3077 13 robfinch
                              skipDollar:
3078 15 robfinch
 00FFEEE3 08D067                          bsr             MonGetNonSpace
3079
 00FFEEE5 0C1024                          cmpb    #'$'
3080
 00FFEEE7 027FFA                          beq             skipDollar              ; skip over '$' prompt character
3081 4 robfinch
 
3082 15 robfinch
                              ; Dispatch based on command
3083 4 robfinch
                              ;
3084 15 robfinch
 00FFEEE9 0313FF                          dey
3085
 00FFEEEB 01F023                          tfr             y,u                                                     ; save off input position
3086
 00FFEEED 05F                             clrb
3087
 00FFEEEE 08EFFEDE3                       ldx             #cmdTable1
3088
                              parseCmd1:
3089
 00FFEEF1 0A6A00                          lda             ,y+                                                     ; get input character
3090
 00FFEEF3 06D804                          tst             ,x                                                      ; test for end of command
3091
 00FFEEF5 02B00F                          bmi             endOfWord                               ;
3092
 00FFEEF7 0A1800                          cmpa    ,x+                                                     ; does input match command?
3093
 00FFEEF9 027FF6                          beq             parseCmd1
3094
                              scanNextWord:
3095
 00FFEEFB 06D800                          tst             ,x+
3096
 00FFEEFD 027FA8                          beq             Monitor                                 ; if end of table reached, not a command
3097
 00FFEEFF 02AFFA                          bpl             scanNextWord
3098
 00FFEF01 05C                             incb
3099
 00FFEF02 01F032                          tfr             u,y                                                     ; reset input pointer
3100
 00FFEF04 020FEB                          bra             parseCmd1                               ; try again
3101
                              endOfWord:
3102
 00FFEF06 0A8804                          eora    ,x
3103
 00FFEF08 048                             asla
3104
 00FFEF09 026FF0                          bne             scanNextWord
3105
                                      ; we found the command in the table
3106
 00FFEF0B 058                             aslb                                                                    ; b = word index
3107
 00FFEF0C 08EFFEE0E                       ldx             #cmdTable2
3108
 00FFEF0F 06E905                          jmp             [b,x]                                           ; execute command
3109
 
3110
                              Redirect:
3111
 00FFEF11 08D034                          bsr             MonGetch
3112
 00FFEF13 0C1073                          cmpb    #'s'
3113
 00FFEF15 02600E                          bne             Prompt2a
3114
 00FFEF17 0CCFFEBE4                       ldd             #SerialPeekCharDirect
3115
 00FFEF1A 0FD000804                       std             CharInVec
3116
 00FFEF1D 0CCFFEC08                       ldd             #SerialPutChar
3117
 00FFEF20 0FD000800                       std             CharOutVec
3118
 00FFEF23 020F82                          bra             Monitor
3119 13 robfinch
                              Prompt2a:
3120 15 robfinch
 00FFEF25 0C1063                          cmpb    #'c'
3121
 00FFEF27 026F7E                          bne             Monitor
3122
 00FFEF29 0CCFFEA12                       ldd             #GetKey
3123
 00FFEF2C 0FD000804                       std             CharInVec
3124
 00FFEF2F 0CCFFE2FE                       ldd             #DisplayChar
3125
 00FFEF32 0FD000800                       std             CharOutVec
3126
 00FFEF35 020F70                          bra             Monitor
3127
 
3128 13 robfinch
                              PromptHelp:
3129 15 robfinch
 00FFEF37 0CCFFF06E                       ldd             #HelpMsg
3130
 00FFEF3A 017FFF482                       lbsr    DisplayString
3131 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3132 15 robfinch
 00FFEF3D 020F68                          bra             Monitor
3133
 
3134
                              PromptClearscreen:
3135
 00FFEF3F 017FFF2EC                       lbsr    ClearScreen
3136 4 robfinch
*** warning 1: Long branch within short branch range could be optimized
3137 15 robfinch
 00FFEF42 017FFF35C                       lbsr    HomeCursor
3138 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3139 15 robfinch
 00FFEF45 020F60                          bra             Monitor
3140 4 robfinch
 
3141
                              MonGetch:
3142 15 robfinch
 00FFEF47 0E6A04                          ldb             ,y
3143
 00FFEF49 031201                          iny
3144
 00FFEF4B 039                             rts
3145 4 robfinch
 
3146
                              MonGetNonSpace:
3147 15 robfinch
 00FFEF4C 08DFF9                          bsr             MonGetCh
3148
 00FFEF4E 0C1020                          cmpb    #' '
3149
 00FFEF50 027FFA                          beq             MonGetNonSpace
3150
 00FFEF52 039                             rts
3151 4 robfinch
 
3152
                              ;------------------------------------------------------------------------------
3153
                              ; Ignore blanks in the input
3154
                              ; Y = text pointer
3155
                              ; D destroyed
3156
                              ;------------------------------------------------------------------------------
3157
                              ;
3158
                              ignBlanks:
3159
                              ignBlanks1:
3160 15 robfinch
 00FFEF53 08DFF2                          bsr             MonGetch
3161
 00FFEF55 0C1020                          cmpb    #' '
3162
 00FFEF57 027FFA                          beq             ignBlanks1
3163
 00FFEF59 0313FF                          dey
3164
 00FFEF5B 039                             rts
3165 4 robfinch
 
3166
                              ;------------------------------------------------------------------------------
3167 15 robfinch
                              ; Multiply number in work area by 10.
3168 4 robfinch
                              ;------------------------------------------------------------------------------
3169 15 robfinch
                              Times10:
3170
 00FFEF5C 0FC000910                       ldd             mon_numwka              ; make a copy of the number
3171
 00FFEF5F 0FD000918                       std             mon_numwka+8
3172
 00FFEF62 0FC000912                       ldd             mon_numwka+2
3173
 00FFEF65 0FD00091A                       std             mon_numwka+10
3174
 00FFEF68 078000913                       asl             mon_numwka+3    ; shift left = *2
3175
 00FFEF6B 079000912                       rol             mon_numwka+2
3176
 00FFEF6E 079000911                       rol             mon_numwka+1
3177
 00FFEF71 079000910                       rol             mon_numwka+0
3178
 00FFEF74 078000913                       asl             mon_numwka+3    ; shift left = *4
3179
 00FFEF77 079000912                       rol             mon_numwka+2
3180
 00FFEF7A 079000911                       rol             mon_numwka+1
3181
 00FFEF7D 079000910                       rol             mon_numwka+0
3182
 00FFEF80 0FC000912                       ldd             mon_numwka+2    ; add in original value
3183
 00FFEF83 0F300091A                       addd    mon_numwka+10   ; = *5
3184
 00FFEF86 0F6000911                       ldb             mon_numwka+1
3185
 00FFEF89 0F9000919                       adcb    mon_numwka+9
3186
 00FFEF8C 0F7000911                       stb             mon_numwka+1
3187
 00FFEF8F 0B6000910                       lda             mon_numwka+0
3188
 00FFEF92 0B9000918                       adca    mon_numwka+8
3189
 00FFEF95 0B7000910                       sta             mon_numwka+0
3190
 00FFEF98 078000913                       asl             mon_numwka+3    ; shift left = * 10
3191
 00FFEF9B 079000912                       rol             mon_numwka+2
3192
 00FFEF9E 079000911                       rol             mon_numwka+1
3193
 00FFEFA1 079000910                       rol             mon_numwka+0
3194
 00FFEFA4 039                             rts
3195
 
3196
                              ;------------------------------------------------------------------------------
3197
                              ;------------------------------------------------------------------------------
3198 4 robfinch
                              GetTwoParams:
3199 15 robfinch
 00FFEFA5 08DFAC                          bsr             ignBlanks
3200
 00FFEFA7 08D046                          bsr             GetHexNumber    ; get start address of dump
3201
 00FFEFA9 0FC000910                       ldd             mon_numwka
3202
 00FFEFAC 0FD000920                       std             mon_r1
3203
 00FFEFAF 0FC000912                       ldd             mon_numwka+2
3204
 00FFEFB2 0FD000922                       std             mon_r1+2
3205
 00FFEFB5 08DF9C                          bsr             ignBlanks
3206
 00FFEFB7 08D036                          bsr             GetHexNumber    ; get end address of dump
3207
 00FFEFB9 0FC000910                       ldd             mon_numwka
3208
 00FFEFBC 0FD000924                       std             mon_r2
3209
 00FFEFBF 0FC000912                       ldd             mon_numwka+2
3210
 00FFEFC2 0FD000926                       std             mon_r2+2
3211
 00FFEFC5 039                             rts
3212 4 robfinch
 
3213
                              ;------------------------------------------------------------------------------
3214
                              ; Get a range, the end must be greater or equal to the start.
3215
                              ;------------------------------------------------------------------------------
3216
                              GetRange:
3217 15 robfinch
 00FFEFC6 08DFDD                          bsr             GetTwoParams
3218
 00FFEFC8 0FC000926                       ldd             mon_r2+2
3219
 00FFEFCB 0B3000922                       subd    mon_r1+2
3220
 00FFEFCE 0FC000924                       ldd             mon_r2
3221
 00FFEFD1 0F2000921                       sbcb    mon_r1+1
3222
 00FFEFD4 0B2000920                       sbca    mon_r1
3223
 00FFEFD7 124000007                       lbcc    grng1
3224
 00FFEFDA 0AD90F00080C                    jsr             [MonErrVec]
3225
 00FFEFDE 016FFFEC6                       lbra    Monitor
3226 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3227
                              grng1:
3228 15 robfinch
 00FFEFE1 039                             rts
3229 4 robfinch
 
3230
                              shl_numwka:
3231 15 robfinch
 00FFEFE2 078000913                       asl             mon_numwka+3
3232
 00FFEFE5 079000912                       rol             mon_numwka+2
3233
 00FFEFE8 079000911                       rol             mon_numwka+1
3234
 00FFEFEB 079000910                       rol             mon_numwka
3235
 00FFEFEE 039                             rts
3236 4 robfinch
 
3237
                              ;------------------------------------------------------------------------------
3238 13 robfinch
                              ; Get a hexidecimal number. Maximum of twelve digits.
3239
                              ;
3240
                              ; Modifies:
3241
                              ;       Y = text pointer (updated)
3242
                              ;       D = number of digits
3243
                              ;       mon_numwka contains number
3244 4 robfinch
                              ;------------------------------------------------------------------------------
3245
                              ;
3246
                              GetHexNumber:
3247 15 robfinch
 00FFEFEF 04F05F                          clrd
3248
 00FFEFF1 0FD000910                       std             mon_numwka      ; zero out work area
3249
 00FFEFF4 0FD000912                       std             mon_numwka+2
3250
 00FFEFF7 034010                          pshs    x
3251
 00FFEFF9 08E000000                       ldx             #0                                      ; max 12 eight digits
3252 4 robfinch
                              gthxn2:
3253 15 robfinch
 00FFEFFC 08DF49                          bsr             MonGetch
3254
 00FFEFFE 08D01F                          bsr             AsciiToHexNybble
3255
 00FFF000 0C1FFF                          cmpb    #-1
3256
 00FFF002 027017                          beq             gthxn1
3257
 00FFF004 08DFDC                          bsr             shl_numwka
3258
 00FFF006 08DFDA                          bsr             shl_numwka
3259
 00FFF008 08DFD8                          bsr             shl_numwka
3260
 00FFF00A 08DFD6                          bsr             shl_numwka
3261
 00FFF00C 0C400F                          andb    #$0f
3262
 00FFF00E 0FA000913                       orb             mon_numwka+3
3263
 00FFF011 0F7000913                       stb             mon_numwka+3
3264
 00FFF014 030001                          inx
3265
 00FFF016 08C00000C                       cmpx    #12
3266
 00FFF019 025FE1                          blo             gthxn2
3267 4 robfinch
                              gthxn1:
3268 15 robfinch
 00FFF01B 01F010                          tfr             x,d
3269
 00FFF01D 035090                          puls    x,pc
3270 4 robfinch
 
3271
                              ;GetDecNumber:
3272
                              ;       phx
3273
                              ;       push    r4
3274
                              ;       push    r5
3275
                              ;       ldx             #0
3276
                              ;       ld              r4,#10
3277
                              ;       ld              r5,#10
3278
                              ;gtdcn2:
3279
                              ;       jsr             MonGetch
3280
                              ;       jsr             AsciiToDecNybble
3281
                              ;       cmp             #-1
3282
                              ;       beq             gtdcn1
3283
                              ;       mul             r2,r2,r5
3284
                              ;       add             r2,r1
3285
                              ;       dec             r4
3286
                              ;       bne             gtdcn2
3287
                              ;gtdcn1:
3288
                              ;       txa
3289
                              ;       pop             r5
3290
                              ;       pop             r4
3291
                              ;       plx
3292
                              ;       rts
3293
 
3294
                              ;------------------------------------------------------------------------------
3295
                              ; Convert ASCII character in the range '0' to '9', 'a' to 'f' or 'A' to 'F'
3296
                              ; to a hex nybble.
3297
                              ;------------------------------------------------------------------------------
3298
                              ;
3299
                              AsciiToHexNybble:
3300 15 robfinch
 00FFF01F 0C1030                          cmpb    #'0'
3301
 00FFF021 025021                          blo             gthx3
3302
 00FFF023 0C1039                          cmpb    #'9'
3303
 00FFF025 022003                          bhi             gthx5
3304
 00FFF027 0C0030                          subb    #'0'
3305
 00FFF029 039                             rts
3306 4 robfinch
                              gthx5:
3307 15 robfinch
 00FFF02A 0C1041                          cmpb    #'A'
3308
 00FFF02C 025016                          blo             gthx3
3309
 00FFF02E 0C1046                          cmpb    #'F'
3310
 00FFF030 022005                          bhi             gthx6
3311
 00FFF032 0C0041                          subb    #'A'
3312
 00FFF034 0CB00A                          addb    #10
3313
 00FFF036 039                             rts
3314 4 robfinch
                              gthx6:
3315 15 robfinch
 00FFF037 0C1061                          cmpb    #'a'
3316
 00FFF039 025009                          blo             gthx3
3317
 00FFF03B 0C107A                          cmpb    #'z'
3318
 00FFF03D 022005                          bhi             gthx3
3319
 00FFF03F 0C0061                          subb    #'a'
3320
 00FFF041 0CB00A                          addb    #10
3321
 00FFF043 039                             rts
3322 4 robfinch
                              gthx3:
3323 15 robfinch
 00FFF044 0C6FFF                          ldb             #-1             ; not a hex number
3324
 00FFF046 039                             rts
3325 4 robfinch
 
3326
                              AsciiToDecNybble:
3327 15 robfinch
 00FFF047 0C1030                          cmpb    #'0'
3328
 00FFF049 024007                          bcc             gtdc3
3329
 00FFF04B 0C103A                          cmpb    #'9'+1
3330
 00FFF04D 025003                          bcs             gtdc3
3331
 00FFF04F 0C0030                          subb    #'0'
3332
 00FFF051 039                             rts
3333 4 robfinch
                              gtdc3:
3334 15 robfinch
 00FFF052 0C6FFF                          ldb             #-1
3335
 00FFF054 039                             rts
3336 4 robfinch
 
3337
                              DisplayErr:
3338 15 robfinch
 00FFF055 0CCFFF066                       ldd             #msgErr
3339
 00FFF058 017FFF364                       lbsr    DisplayString
3340 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3341 15 robfinch
 00FFF05B 07EFFEEA7                       jmp             Monitor
3342 4 robfinch
 
3343
                              DisplayStringDX
3344 15 robfinch
 00FFF05E 0DD024                          std             Strptr
3345
 00FFF060 09F026                          stx             Strptr+2
3346
 00FFF062 0BDFFE3BF                       jsr             DisplayString
3347
 00FFF065 039                             rts
3348 4 robfinch
 
3349
                              msgErr:
3350 15 robfinch
 00FFF066 02A02A04507207200D00A           fcb     "**Err",CR,LF,0
3351
 00FFF06D 000
3352 4 robfinch
 
3353
                              HelpMsg:
3354 15 robfinch
 00FFF06E 03F02003D020044069073           fcb             "? = Display help",CR,LF
3355
 00FFF075 07006C061079020068065
3356
 00FFF07C 06C07000D00A
3357
 00FFF080 04304C05302003D020063           fcb     "CLS = clear screen",CR,LF
3358
 00FFF087 06C065061072020073063
3359
 00FFF08E 07206506506E00D00A
3360
 00FFF094 06207302003D020073065           fcb     "bs = set breakpoint",CR,LF
3361
 00FFF09B 07402006207206506106B
3362
 00FFF0A2 07006F06906E07400D00A
3363
 00FFF0A9 06206302003D02006306C           fcb     "bc = clear breakpoint",CR,LF
3364
 00FFF0B0 065061072020062072065
3365
 00FFF0B7 06106B07006F06906E074
3366
 00FFF0BE 00D00A
3367 4 robfinch
                              ;       db      "S = Boot from SD Card",CR,LF
3368 15 robfinch
 00FFF0C0 03A02003D020045064069           fcb     ": = Edit memory bytes",CR,LF
3369
 00FFF0C7 07402006D06506D06F072
3370
 00FFF0CE 079020062079074065073
3371
 00FFF0D5 00D00A
3372 4 robfinch
                              ;       db      "L = Load sector",CR,LF
3373
                              ;       db      "W = Write sector",CR,LF
3374 15 robfinch
 00FFF0D7 04405202003D020044075           fcb "DR = Dump registers",CR,LF
3375
 00FFF0DE 06D070020072065067069
3376
 00FFF0E5 07307406507207300D00A
3377
 00FFF0EC 04402003D02004407506D           fcb     "D = Dump memory",CR,LF
3378
 00FFF0F3 07002006D06506D06F072
3379
 00FFF0FA 07900D00A
3380
 00FFF0FD 04602003D02004606906C           fcb     "F = Fill memory",CR,LF
3381
 00FFF104 06C02006D06506D06F072
3382
 00FFF10B 07900D00A
3383
 00FFF10E 04604C02003D020044075           fcb "FL = Dump I/O Focus List",CR,LF
3384
 00FFF115 06D07002004902F04F020
3385
 00FFF11C 04606F06307507302004C
3386
 00FFF123 06907307400D00A
3387
 00FFF128 04604904702003D020073           fcb "FIG = start FIG Forth",CR,LF
3388
 00FFF12F 074061072074020046049
3389
 00FFF136 04702004606F072074068
3390
 00FFF13D 00D00A
3391 4 robfinch
                              ;       db      "KILL n = kill task #n",CR,LF
3392
                              ;       db      "B = start tiny basic",CR,LF
3393
                              ;       db      "b = start EhBasic 6502",CR,LF
3394 15 robfinch
 00FFF13F 04A02003D02004A07506D           fcb     "J = Jump to code",CR,LF
3395
 00FFF146 07002007406F02006306F
3396
 00FFF14D 06406500D00A
3397
 00FFF151 05204104D02003D020074           fcb "RAM = test RAM",CR,LF
3398
 00FFF158 06507307402005204104D
3399
 00FFF15F 00D00A
3400 4 robfinch
                              ;       db      "R[n] = Set register value",CR,LF
3401
                              ;       db      "r = random lines - test bitmap",CR,LF
3402
                              ;       db      "e = ethernet test",CR,LF
3403 15 robfinch
 00FFF161 07302003D020073065072           fcb     "s = serial output test",CR,LF
3404
 00FFF168 06906106C02006F075074
3405
 00FFF16F 070075074020074065073
3406
 00FFF176 07400D00A
3407
 00FFF179 05305002003D020073070           fcb     "SP = sprite demo",CR,LF
3408
 00FFF180 072069074065020064065
3409
 00FFF187 06D06F00D00A
3410 4 robfinch
                              ;       db      "T = Dump task list",CR,LF
3411
                              ;       db      "TO = Dump timeout list",CR,LF
3412 15 robfinch
 00FFF18B 05404902003D020064069           fcb     "TI = display date/time",CR,LF
3413
 00FFF192 07307006C061079020064
3414
 00FFF199 06107406502F07406906D
3415
 00FFF1A0 06500D00A
3416 4 robfinch
                              ;       db      "TEMP = display temperature",CR,LF
3417 15 robfinch
 00FFF1A3 05502003D02007506E061           fcb     "U = unassemble",CR,LF
3418
 00FFF1AA 07307306506D06206C065
3419
 00FFF1B1 00D00A
3420
                              ;       db      "P = Piano",CR,LF
3421
 00FFF1B3 07802003D020065078069           fcb     "x = exit monitor",CR,LF
3422
 00FFF1BA 07402006D06F06E069074
3423
 00FFF1C1 06F07200D00A
3424
 00FFF1C5 000                             fcb             0
3425 4 robfinch
 
3426
                              msgRegHeadings
3427 15 robfinch
 00FFF1C6 00D00A02002004402F041           fcb     CR,LF,"  D/AB     X      Y      U      S       PC    DP  CCR",CR,LF,0
3428
 00FFF1CD 042020020020020020058
3429
 00FFF1D4 020020020020020020059
3430
 00FFF1DB 020020020020020020055
3431
 00FFF1E2 020020020020020020053
3432
 00FFF1E9 020020020020020020020
3433
 00FFF1F0 050043020020020020044
3434
 00FFF1F7 05002002004304305200D
3435
 00FFF1FE 00A000
3436 4 robfinch
 
3437
                              nHEX4:
3438 15 robfinch
 00FFF200 0BDFFD2D2                       jsr             HEX4
3439
 00FFF203 039                             rts
3440 4 robfinch
 
3441
                              nXBLANK:
3442 15 robfinch
 00FFF204 0C6020                          ldb             #' '
3443
 00FFF206 016FFFB09                       lbra    OUTCH
3444 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3445 4 robfinch
 
3446 13 robfinch
                              ;------------------------------------------------------------------------------
3447
                              ; Dump Memory
3448
                              ;
3449
                              ; Usage:
3450 14 robfinch
                              ;       $D FFFC12 FFFC20
3451 13 robfinch
                              ;
3452
                              ; Dump formatted to look like:
3453
                              ;               :FFFC12 012 012 012 012 555 666 777 888
3454
                              ;
3455
                              ;------------------------------------------------------------------------------
3456 4 robfinch
 
3457 13 robfinch
                              DumpMemory:
3458 15 robfinch
 00FFF209 08DDBB                          bsr             GetRange
3459
 00FFF20B 18E000000                       ldy             #0
3460
 00FFF20E 1BE000922                       ldy             mon_r1+2
3461 13 robfinch
                              dmpm2:
3462 15 robfinch
 00FFF211 017FFDEBE                       lbsr    CRLF
3463 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3464 15 robfinch
 00FFF214 0C603A                          ldb             #':'
3465
 00FFF216 017FFFAF9                       lbsr    OUTCH
3466 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3467 15 robfinch
 00FFF219 01F020                          tfr             y,d
3468 13 robfinch
                                      ;addd   mon_r1+2                                        ; output the address
3469 15 robfinch
 00FFF21B 017FFF1EC                       lbsr    DispWordAsHex
3470 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3471 15 robfinch
 00FFF21E 0C6020                          ldb             #' '
3472
 00FFF220 017FFFAEF                       lbsr    OUTCH
3473 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3474 15 robfinch
 00FFF223 08E000008                       ldx             #8                                                              ; number of bytes to display
3475 13 robfinch
                              dmpm1:
3476
                              ;       ldb             far [mon_r1+1],y
3477
                                      ;ldb            [mon_r1+2],y
3478 15 robfinch
 00FFF226 0E6A04                          ldb             ,y
3479
 00FFF228 031201                          iny
3480
 00FFF22A 017FFF1E6                       lbsr    DispByteAsHex                   ; display byte
3481 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3482 15 robfinch
 00FFF22D 0C6020                          ldb             #' '                                                    ; followed by a space
3483
 00FFF22F 017FFFAE0                       lbsr    OUTCH
3484 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3485 15 robfinch
 00FFF232 05F                             clrb
3486
 00FFF233 04F                             clra
3487
 00FFF234 017FFFAA3                       lbsr    INCH
3488 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3489 15 robfinch
 00FFF237 0C1003                          cmpb    #CTRLC
3490
 00FFF239 027024                          beq             dmpm3
3491
 00FFF23B 0301FF                          dex
3492
 00FFF23D 026FE7                          bne             dmpm1
3493 13 robfinch
                                      ; Now output ascii
3494 15 robfinch
 00FFF23F 0C6020                          ldb             #' '
3495
 00FFF241 017FFFACE                       lbsr    OUTCH
3496 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3497 15 robfinch
 00FFF244 08E000008                       ldx             #8                                                              ; 8 chars to output
3498
 00FFF247 0313F8                          leay    -8,y                                                    ; backup pointer
3499 13 robfinch
                              dmpm5:
3500
                              ;       ldb             far [mon_r1+1],y        ; get the char
3501
                              ;       ldb             [mon_r1+2],y                    ; get the char
3502 15 robfinch
 00FFF249 0E6A04                          ldb             ,y
3503
 00FFF24B 0C1020                          cmpb    #$20                                                    ; is it a control char?
3504
 00FFF24D 024002                          bhs             dmpm4
3505
 00FFF24F 0C602E                          ldb             #'.'
3506 13 robfinch
                              dmpm4:
3507 15 robfinch
 00FFF251 017FFFABE                       lbsr    OUTCH
3508 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3509 15 robfinch
 00FFF254 031201                          iny
3510
 00FFF256 0301FF                          dex
3511
 00FFF258 026FEF                          bne             dmpm5
3512
 00FFF25A 1BC000926                       cmpy    mon_r2+2
3513
 00FFF25D 025FB2                          blo             dmpm2
3514 13 robfinch
                              dmpm3:
3515 15 robfinch
 00FFF25F 017FFDE70                       lbsr    CRLF
3516 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3517 15 robfinch
 00FFF262 016FFFC42                       lbra    Monitor
3518 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3519
 
3520
                              ;------------------------------------------------------------------------------
3521 14 robfinch
                              ; Edit Memory
3522
                              ;
3523
                              ; Usage:
3524
                              ;       $$:FFFC12 8 "Hello World!" 0
3525
                              ;
3526
                              ; Dump formatted to look like:
3527
                              ;               :FFFC12 012 012 012 012 555 666 777 888
3528
                              ;
3529
                              ;------------------------------------------------------------------------------
3530
 
3531
                              EditMemory:
3532 15 robfinch
 00FFF265 0CE000008                       ldu             #8                                              ; set max byte count
3533
 00FFF268 017FFFD84                       lbsr    GetHexNumber    ; get the start address
3534 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3535 15 robfinch
 00FFF26B 0BE000912                       ldx             mon_numwka+2
3536 14 robfinch
                              EditMem2:
3537 15 robfinch
 00FFF26E 017FFFCE2                       lbsr    ignBlanks                       ; skip over blanks
3538 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3539 15 robfinch
 00FFF271 017FFFD7B                       lbsr    GetHexNumber    ; get the byte value
3540 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3541 15 robfinch
 00FFF274 05D                             tstb                                                            ; check for valid value
3542
 00FFF275 02700C                          beq             EditMem1                        ; if invalid, quit
3543
 00FFF277 0F6000913                       ldb             mon_numwka+3    ; get value
3544
 00FFF27A 0E7800                          stb             ,x+                                             ; update memory at address
3545
 00FFF27C 0335FF                          leau    -1,u                                    ; decremeent byte count
3546
 00FFF27E 283000000                       cmpu    #0
3547
 00FFF281 026FEB                          bne             EditMem2                        ; go back for annother byte
3548 14 robfinch
                              EditMem1:
3549 15 robfinch
 00FFF283 017FFFCC1                       lbsr    MonGetch                        ; see if a string is being entered
3550 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3551 15 robfinch
 00FFF286 0C1022                          cmpb    #'"'
3552
 00FFF288 026018                          bne             EditMem3                        ; no string, we're done
3553
 00FFF28A 0CE000028                       ldu             #40                                             ; string must be less than 40 chars
3554 14 robfinch
                              EditMem4:
3555 15 robfinch
 00FFF28D 017FFFCB7                       lbsr    MonGetch                        ; look for close quote
3556 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3557 15 robfinch
 00FFF290 0C1022                          cmpb    #'"'
3558
 00FFF292 026005                          bne             EditMem6                        ; end of string?
3559
 00FFF294 0CE000008                       ldu             #8                                              ; reset the byte count
3560
 00FFF297 020FD5                          bra             EditMem2
3561 14 robfinch
                              EditMem6:
3562 15 robfinch
 00FFF299 0E7800                          stb             ,x+                                             ; store the character in memory
3563
 00FFF29B 0335FF                          leau    -1,u                                    ; decrement byte count
3564
 00FFF29D 283000000                       cmpu    #0
3565
 00FFF2A0 022FEB                          bhi             EditMem4                        ; max 40 chars
3566 14 robfinch
                              EditMem3:
3567 15 robfinch
 00FFF2A2 016FFFC02                       lbra    Monitor
3568 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3569
 
3570
 
3571
                              ;------------------------------------------------------------------------------
3572 15 robfinch
                              ; Fill Memory
3573
                              ;
3574
                              ; Usage:
3575
                              ;       $$F FFFC12 FFFC30 89F
3576
                              ;
3577
                              ;------------------------------------------------------------------------------
3578
 
3579
                              FillMemory:
3580
 00FFF2A5 017FFFD1E                       lbsr    GetRange                        ; get address range to fill
3581
*** warning 1: Long branch within short branch range could be optimized
3582
 00FFF2A8 017FFFCA8                       lbsr    ignBlanks
3583
*** warning 1: Long branch within short branch range could be optimized
3584
 00FFF2AB 017FFFD41                       lbsr    GetHexNumber    ; get target byte to write
3585
*** warning 1: Long branch within short branch range could be optimized
3586
 00FFF2AE 0F6000913                       ldb             mon_numwka+3
3587
 00FFF2B1 0BE000922                       ldx             mon_r1+2
3588
 00FFF2B4 04F                             clra
3589
                              fillm1:                                                         ; Check for a CTRL-C every page of memory
3590
 00FFF2B5 04D                             tsta
3591
 00FFF2B6 02600D                          bne             fillm2
3592
 00FFF2B8 05F                             clrb                                                            ; we want a non-blocking check
3593
 00FFF2B9 04F                             clra
3594
 00FFF2BA 017FFFA1D                       lbsr    INCH
3595
*** warning 1: Long branch within short branch range could be optimized
3596
 00FFF2BD 0C1003                          cmpb    #CTRLC
3597
 00FFF2BF 127FFFBE5                       lbeq    Monitor
3598
*** warning 1: Long branch within short branch range could be optimized
3599
 00FFF2C2 0F6000913                       ldb             mon_numwka+3    ; reset target byte
3600
                              fillm2:
3601
 00FFF2C5 0E7800                          stb             ,x+
3602
 00FFF2C7 0BC000926                       cmpx    mon_r2+2
3603
 00FFF2CA 023FE9                          bls             fillm1
3604
                              fillm3:
3605
 00FFF2CC 016FFFBD8                       lbra    Monitor
3606
*** warning 1: Long branch within short branch range could be optimized
3607
 
3608
                              ;------------------------------------------------------------------------------
3609 13 robfinch
                              ; Dump Registers
3610
                              ;
3611
                              ;       Usage:
3612
                              ;               $DR
3613
                              ;------------------------------------------------------------------------------
3614
 
3615
                              DumpRegs:
3616 15 robfinch
 00FFF2CF 0CCFFF1C6                       ldd             #msgRegHeadings
3617
 00FFF2D2 017FFF0EA                       lbsr    DisplayString
3618 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3619 15 robfinch
 00FFF2D5 08DF2D                          bsr             nXBLANK
3620
 00FFF2D7 0FC000900                       ldd             mon_DSAVE
3621
 00FFF2DA 08DF24                          bsr             nHEX4
3622
 00FFF2DC 08DF26                          bsr             nXBLANK
3623
 00FFF2DE 0FC000902                       ldd             mon_XSAVE
3624
 00FFF2E1 08DF1D                          bsr             nHEX4
3625
 00FFF2E3 08DF1F                          bsr             nXBLANK
3626
 00FFF2E5 0FC000904                       ldd             mon_YSAVE
3627
 00FFF2E8 08DF16                          bsr             nHEX4
3628
 00FFF2EA 08DF18                          bsr             nXBLANK
3629
 00FFF2EC 0FC000906                       ldd             mon_USAVE
3630
 00FFF2EF 08DF0F                          bsr             nHEX4
3631
 00FFF2F1 08DF11                          bsr             nXBLANK
3632
 00FFF2F3 0FC000908                       ldd             mon_SSAVE
3633
 00FFF2F6 08DF08                          bsr             nHEX4
3634
 00FFF2F8 08DF0A                          bsr             nXBLANK
3635
 00FFF2FA 0F600090B                       ldb             mon_PCSAVE+1
3636
 00FFF2FD 017FFF113                       lbsr    DispByteAsHex
3637 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3638 15 robfinch
 00FFF300 0FC00090C                       ldd             mon_PCSAVE+2
3639
 00FFF303 08DEFB                          bsr             nHEX4
3640
 00FFF305 08DEFD                          bsr             nXBLANK
3641
 00FFF307 0FC00090E                       ldd             mon_DPRSAVE
3642
 00FFF30A 0BDFFD2CE                       jsr             HEX2
3643
 00FFF30D 08DEF5                          bsr             nXBLANK
3644
 00FFF30F 0B600090F                       lda             mon_CCRSAVE
3645
 00FFF312 017FFDFB9                       lbsr    HEX2
3646 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3647 15 robfinch
 00FFF315 08DEED                          bsr             nXBLANK
3648
 00FFF317 016FFFB8D                       lbra    Monitor
3649 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3650
 
3651
                              ;------------------------------------------------------------------------------
3652 4 robfinch
                              ; Jump to code
3653 13 robfinch
                              ;
3654
                              ; Registers are loaded with values from the monitor register save area before
3655
                              ; the code is jumped to.
3656
                              ;
3657
                              ; J 
3658
                              ;------------------------------------------------------------------------------
3659
 
3660 4 robfinch
                              jump_to_code:
3661 15 robfinch
 00FFF31A 08DCD3                          bsr             GetHexNumber
3662
 00FFF31C 01A010                          sei
3663
 00FFF31E 1FE000908                       lds             mon_SSAVE
3664
 00FFF321 0CCFFF355                       ldd             #
3665
 00FFF324 034006                          pshs    d
3666
 00FFF326 0C6000                          ldb             #>jtc_exit
3667
 00FFF328 034004                          pshs    b
3668
 00FFF32A 0FC000912                       ldd             mon_numwka+2    ; get the address parameter
3669
 00FFF32D 034006                          pshs    d
3670
 00FFF32F 0F6000911                       ldb             mon_numwka+1
3671
 00FFF332 034004                          pshs    b
3672
 00FFF334 0FC000906                       ldd             mon_USAVE
3673
 00FFF337 034006                          pshs    d
3674
 00FFF339 0FC000904                       ldd             mon_YSAVE
3675
 00FFF33C 034006                          pshs    d
3676
 00FFF33E 0FC000902                       ldd             mon_XSAVE
3677
 00FFF341 034006                          pshs    d
3678
 00FFF343 0B600090E                       lda             mon_DPRSAVE
3679
 00FFF346 034002                          pshs    a
3680
 00FFF348 0FC000900                       ldd             mon_DSAVE
3681
 00FFF34B 034006                          pshs    d
3682
 00FFF34D 0B600090F                       lda             mon_CCRSAVE
3683
 00FFF350 034002                          pshs    a
3684
 00FFF352 0150350FF                       puls    far ccr,d,dpr,x,y,u,pc
3685 4 robfinch
                              jtc_exit:
3686 15 robfinch
 00FFF355 1FF000908                       sts             >mon_SSAVE              ; need to use extended addressing, no direct page setting
3687
 00FFF358 03280F006FFF                    leas    $6FFF                                   ; reset stack to system area, dont modify flags register!
3688
 00FFF35C 034001                          pshs    ccr                                             ; now the stack can be used
3689
 00FFF35E 034002                          pshs    a                                                       ; save acca register so we can use it
3690
 00FFF360 01F0B8                          tfr             dpr,a                                   ; a = outgoing dpr value
3691
 00FFF362 0B700090E                       sta             >mon_DPRSAVE    ; force extended addressing mode usage here dpr is not set
3692
 00FFF365 04F                             clra                                                            ; dpg register must be set to zero before values are
3693
 00FFF366 01F08B                          tfr             a,dpr                                   ; saved in the monitor register save area.
3694
 00FFF368 035002                          puls    a                                                       ; get back acca
3695
 00FFF36A 0FD000900                       std             mon_DSAVE                       ; save regsters, can use direct addressing now
3696
 00FFF36D 0BF000902                       stx             mon_XSAVE
3697
 00FFF370 1BF000904                       sty             mon_YSAVE
3698
 00FFF373 0FF000906                       stu             mon_USAVE
3699
 00FFF376 035002                          puls    a                                                       ; get back ccr
3700
 00FFF378 0B700090F                       sta             mon_CCRSAVE             ; and save it too
3701 13 robfinch
                                      ; Reset vectors in case they got toasted.
3702 15 robfinch
 00FFF37B 0CCFFEBE4                       ldd             #SerialPeekCharDirect
3703
 00FFF37E 0FD000804                       std             CharInVec
3704
 00FFF381 0CCFFE2FE                       ldd             #DisplayChar
3705
 00FFF384 0FD000800                       std             CharOutVec
3706
 00FFF387 0FCFFF055                       ldd             DisplayErr
3707
 00FFF38A 0FD00080C                       std             MonErrVec
3708 4 robfinch
                                      ; todo set according to coreid
3709 15 robfinch
 00FFF38D 016FFFF3F                       lbra    DumpRegs                        ; now go do a register dump
3710 13 robfinch
*** warning 1: Long branch within short branch range could be optimized
3711 4 robfinch
 
3712
                              ;------------------------------------------------------------------------------
3713
                              ;------------------------------------------------------------------------------
3714 14 robfinch
 
3715
                              DumpIOFocusList:
3716 15 robfinch
 00FFF390 08E000000                       ldx             #0
3717 14 robfinch
                              dfl2:
3718 15 robfinch
 00FFF393 0E680A000FFC000                 ldb             IOFocusList,x
3719
 00FFF398 0C1018                          cmpb    #24
3720
 00FFF39A 02600A                          bne             dfl1
3721
 00FFF39C 01F010                          tfr             x,d
3722
 00FFF39E 017FFF072                       lbsr    DispByteAsHex
3723 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3724 15 robfinch
 00FFF3A1 0C6020                          ldb             #' '
3725
 00FFF3A3 017FFF96C                       lbsr    OUTCH
3726 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3727
                              dfl1:
3728 15 robfinch
 00FFF3A6 030001                          inx
3729
 00FFF3A8 08C000010                       cmpx    #16
3730
 00FFF3AB 025FE6                          blo             dfl2
3731
 00FFF3AD 017FFDD22                       lbsr    CRLF
3732 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3733 15 robfinch
 00FFF3B0 016FFFAF4                       lbra    Monitor
3734 14 robfinch
*** warning 1: Long branch within short branch range could be optimized
3735
 
3736 15 robfinch
                              bootpg:
3737
 00FFF3B3 000                             fcb             $000
3738
                              boot_stack:
3739
 00FFF3B4 006FFF                          fcw             $006FFF
3740
                              numBreakpoints:
3741
 00FFF3B6 008                             fcb             8
3742
                              mon_rom_vectab:
3743
 00FFF3B7 FFF3B9                          fcw             mon_rom_vecs
3744
                              mon_rom_vecs:
3745
 00FFF3B9 FFEEA7                          fcw             Monitor                                         ; enter monitor program
3746
 00FFF3BB FFECDA                          fcw             INCH                                                    ; input a character
3747
 00FFF3BD FFED12                          fcw             OUTCH                                                   ; output a character
3748
 00FFF3BF FFD0D2                          fcw             CRLF                                                    ; output carriage-return, line feed
3749
 00FFF3C1 FFE3BF                          fcw             DisplayString
3750
 00FFF3C3 FFE413                          fcw             DispByteAsHex
3751
 00FFF3C5 FFE40A                          fcw             DispWordAsHex
3752
 00FFF3C7 FFED1C                          fcw             ShowSprites
3753
 00FFF3C9 FFEDA0                          fcw             mon_srand
3754
 00FFF3CB FFEDCE                          fcw             mon_rand
3755
 00FFF3CD 000000                          fcw             0                                                                       ; operating system call
3756
 00FFF3CF FFEFC6                          fcw             GetRange
3757 14 robfinch
 
3758 15 robfinch
                              NumFuncs        EQU     (*-mon_rom_vectab)/2
3759
 
3760 14 robfinch
                              ;------------------------------------------------------------------------------
3761 15 robfinch
                              ; SWI routine.
3762
                              ;
3763
                              ; SWI is used to call ROM monitor routines and process breakpoints.
3764
                              ;
3765
                              ;       swi
3766
                              ;       fcb 
3767 14 robfinch
                              ;------------------------------------------------------------------------------
3768 15 robfinch
 
3769
                              swi_rout:
3770
 00FFF3D1 0E680CFDF                       ldb             bootpg,pcr                      ; reset direct page
3771
 00FFF3D4 01F09B                          tfr             b,dp
3772
                              swi_rout1:
3773
 00FFF3D6 0EE60B                          ldu             11,s                                            ; get program counter (low order 2 bytes)
3774
 00FFF3D8 0335FF                          leau    -1,u                                            ; backup a byte
3775
 00FFF3DA 07D000810                       tst             BreakpointFlag  ; are we in breakpoint mode?
3776
 00FFF3DD 02700F                          beq             swiNotBkpt
3777
 00FFF3DF 0CE000820                       ldu             #Breakpoints
3778
 00FFF3E2 0F6000811                       ldb             NumSetBreakpoints
3779
 00FFF3E5 027007                          beq             swiNotBkpt
3780
                              swi_rout2:
3781
 00FFF3E7 2A3A01                          cmpu    ,y++
3782
 00FFF3E9 027033                          beq             processBreakpoint
3783
 00FFF3EB 05A                             decb
3784
 00FFF3EC 026FF9                          bne             swi_rout2
3785
                              swiNotBkpt:
3786
 00FFF3EE 07F000810                       clr             BreakpointFlag
3787
 00FFF3F1 037006                          pulu    d                                                               ; get function #, increment PC
3788
 00FFF3F3 0C100D                          cmpb    #NumFuncs
3789
 00FFF3F5 122FFFC5D                       lbhi    DisplayErr
3790
*** warning 1: Long branch within short branch range could be optimized
3791
 00FFF3F8 0EF60B                          stu             11,s                                            ; save updated PC on stack
3792
 00FFF3FA 0C100A                          cmpb    #MF_OSCALL
3793
 00FFF3FC 027056                          beq             swiCallOS
3794
 00FFF3FE 058                             aslb                                                                    ; 2 bytes per vector
3795
 00FFF3FF 0AE80CFB5                       ldx             mon_rom_vectab,pcr
3796
 00FFF402 03A                             abx
3797
 00FFF403 0AE804                          ldx             ,x
3798
 00FFF405 0BF000928                       stx             jmpvec
3799
 00FFF408 1FF000908                       sts             mon_SSAVE                               ; save the stack pointer
3800
 00FFF40B 0EC601                          ldd             1,s                                                     ; get back D
3801
 00FFF40D 0AE604                          ldx             4,s                                                     ; get back X
3802
 00FFF40F 1AE606                          ldy             6,s                                                     ; get back Y
3803
 00FFF411 0EE608                          ldu             8,s                                                     ; get back U
3804
 00FFF413 1EE80CF9E                       lds             boot_stack,pcr  ; and use our own stack
3805
 00FFF416 0AD90F000928                    jsr             [jmpvec]                                ; call the routine
3806
                              swi_rout3:
3807
 00FFF41A 1FE000908                       lds             mon_SSAVE                               ; restore stack
3808
 00FFF41D 03B                             rti
3809
 
3810
                              processBreakpoint:
3811
 00FFF41E 0A6E04                          lda             ,s
3812
 00FFF420 0B700090F                       sta             mon_CCRSAVE
3813
 00FFF423 0EC601                          ldd             1,s
3814
 00FFF425 0FD000900                       std             mon_DSAVE
3815
 00FFF428 0E6603                          ldb             3,s
3816
 00FFF42A 0F700090E                       stb             mon_DPRSAVE
3817
 00FFF42D 0EC604                          ldd             4,s
3818
 00FFF42F 0FD000902                       std             mon_XSAVE
3819
 00FFF432 0EC606                          ldd             6,s
3820
 00FFF434 0FD000904                       std             mon_YSAVE
3821
 00FFF437 0EC608                          ldd             8,s
3822
 00FFF439 0FD000906                       std             mon_USAVE
3823
 00FFF43C 1FF000908                       sts             mon_SSAVE
3824
 00FFF43F 0EC60B                          ldd             11,s
3825
 00FFF441 0FD00090A                       std             mon_PCSAVE
3826
 00FFF444 1EE80CF6D                       lds             boot_stack,pcr
3827
 00FFF447 0CCFFF41A                       ldd             #swi_rout3                      ; setup so monitor can return
3828
 00FFF44A 034006                          pshs    d
3829
 00FFF44C 08D020                          bsr             DisarmAllBreakpoints
3830
 00FFF44E 016FFFE7E                       lbra    DumpRegs
3831
*** warning 1: Long branch within short branch range could be optimized
3832
 
3833
                              xitMonitor:
3834
 00FFF451 08D03A                          bsr             ArmAllBreakpoints
3835
 00FFF453 039                             rts
3836
 
3837
                              swiCallOS:
3838
 00FFF454 033401                          leau    1,u                                                     ; next byte is func number
3839
 00FFF456 0E6C00                          ldb             ,u+
3840
 00FFF458 0C1019                          cmpb    #NumOSFuncs                     ; check for valid range
3841
 00FFF45A 122FFFBF8                       lbhi    DisplayErr
3842
*** warning 1: Long branch within short branch range could be optimized
3843
 00FFF45D 0EF60B                          stu             11,s                                            ; save updateed PC on stack
3844
 00FFF45F 058                             aslb                                                                    ; compute vector address
3845
 00FFF460 08EFFED27                       ldx             #OSCallTbl
3846
 00FFF463 06DE0F                          tst             b,x                                                     ; check for non-zero vector
3847
 00FFF465 027FB3                          beq             swi_rout3
3848
                              osc1:
3849
                              ;       tst             OSSEMA+1                                ; wait for availability
3850
                              ;       beq             osc1
3851
 00FFF467 0ADF0F                          jsr             [b,x]                                           ; call the OS routine
3852
                              oscx:
3853
 00FFF469 07FEF0011                       clr             OSSEMA+1
3854
 00FFF46C 020FAC                          bra             swi_rout3
3855
 
3856
                              DisarmAllBreakpoints:
3857
 00FFF46E 034036                          pshs    d,x,y
3858
 00FFF470 18E000000                       ldy             #0
3859
 00FFF473 05F                             clrb
3860
 00FFF474 08E000830                       ldx             #BreakpointBytes        ; x = breakpoint byte table address
3861
                              disarm2:
3862
 00FFF477 0C13B6                          cmpb    #numBreakpoints         ; safety check
3863
 00FFF479 024010                          bhs             disarm1
3864
 00FFF47B 0F1000811                       cmpb    NumSetBreakpoints
3865
 00FFF47E 02400B                          bhs             disarm1
3866
 00FFF480 0A6837                          lda             b,x                                                             ; get memory byte
3867
 00FFF482 0A7B09000820                    sta             [Breakpoints,y]         ; and store it back to memory
3868
 00FFF486 031202                          leay    2,y                                                             ; increment for next address
3869
 00FFF488 05C                             incb                                                                            ; increment to next byte
3870
 00FFF489 020FEC                          bra             disarm2                                         ; loop back
3871
                              disarm1:
3872
 00FFF48B 0350B6                          puls    d,x,y,pc
3873
 
3874
                              ArmAllBreakpoints:
3875
 00FFF48D 034036                          pshs    d,x,y
3876
 00FFF48F 18E000000                       ldy             #0
3877
 00FFF492 05F                             clrb
3878
 00FFF493 08E000830                       ldx             #BreakpointBytes        ; x = breakpoint byte table address
3879
                              arm2:
3880
 00FFF496 0C13B6                          cmpb    #numBreakpoints         ; safety check
3881
 00FFF498 024010                          bhs             arm1
3882
 00FFF49A 0F1000811                       cmpb    NumSetBreakpoints
3883
 00FFF49D 02400B                          bhs             arm1
3884
 00FFF49F 0A6B09000820                    lda             [Breakpoints,y]         ; load byte at memory address
3885
 00FFF4A3 0A7B0D                          sta             b,x                                                             ; save in table
3886
 00FFF4A5 031202                          leay    2,y                                                             ; increment for next address
3887
 00FFF4A7 05C                             incb                                                                            ; increment to next byte
3888
 00FFF4A8 020FEC                          bra             arm2                                                    ; loop back
3889
                              arm1:
3890
 00FFF4AA 0350B6                          puls    d,x,y,pc
3891
 
3892
                              ArmBreakpoint:
3893
 00FFF4AC 034036                          pshs    d,x,y
3894
 00FFF4AE 0B6000811                       lda             NumSetBreakpoints               ; check if too many breakpoints set
3895
 00FFF4B1 0813B6                          cmpa    #numBreakpoints
3896
 00FFF4B3 124FFFB9F                       lbhs    DisplayErr
3897
*** warning 1: Long branch within short branch range could be optimized
3898
 00FFF4B6 017FFFB36                       lbsr    GetHexNumber                            ; get address parameter
3899
*** warning 1: Long branch within short branch range could be optimized
3900
 00FFF4B9 0F6000811                       ldb             NumSetBreakpoints               ; bv= number of set breakpoints
3901
 00FFF4BC 1BE000912                       ldy             mon_numwka+2                            ; get address
3902
 00FFF4BF 0A6A04                          lda             ,y                                                                      ; get byte at address
3903
 00FFF4C1 08E000830                       ldx             #BreakpointBytes                ; and store byte in a table
3904
 00FFF4C4 0A7A05                          sta             b,x
3905
 00FFF4C6 08E000820                       ldx             #Breakpoints                            ; also store the address in a table
3906
 00FFF4C9 058                             aslb                                                                                    ; index for 2 byte values
3907
 00FFF4CA 1AFA05                          sty             b,x
3908
 00FFF4CC 054                             lsrb                                                                                    ; size back to single byte
3909
 00FFF4CD 05C                             incb
3910
 00FFF4CE 0F7000811                       stb             NumSetBreakpoints
3911
 00FFF4D1 0350B6                          puls    d,x,y,pc
3912
 
3913
                              DisarmBreakpoint:
3914
 00FFF4D3 034076                          pshs    d,x,y,u
3915
 00FFF4D5 017FFFB17                       lbsr    GetHexNumber
3916
*** warning 1: Long branch within short branch range could be optimized
3917
 00FFF4D8 05F                             clrb
3918
 00FFF4D9 05F                             clrb
3919
 00FFF4DA 01F001                          tfr             d,x                                                                     ; x = zero too
3920
                              disarm6:
3921
 00FFF4DC 0C13B6                          cmpb    #numBreakpoints                 ; no more than this many may be set
3922
 00FFF4DE 02403F                          bhs             disarm4
3923
 00FFF4E0 0F1000811                       cmpb    NumSetBreakpoints               ; number actually set
3924
 00FFF4E3 02403A                          bhs             disarm4
3925
 00FFF4E5 1AE809000820                    ldy             Breakpoints,x                           ; y = breakpoint address
3926
 00FFF4E9 1BC000912                       cmpy    mon_numwka+2                            ; is it the one we want?
3927
 00FFF4EC 02602C                          bne             disarm3                                                 ; if not, go increment to next
3928
 00FFF4EE 0BE000912                       ldx             mon_numwka+2                            ; x = memory address
3929
 00FFF4F1 18E000830                       ldy             #BreakpointBytes
3930
 00FFF4F4 0A6A0D                          lda             b,y                                                                     ; get saved byte from table
3931
 00FFF4F6 0A7804                          sta             ,x                                                                      ; set the byte at the memory address
3932
                                      ; compress breakpoint table by removing breakpoint
3933
 00FFF4F8 07A000811                       dec             NumSetBreakpoints               ; set the new number of set breakpoints
3934
 00FFF4FB 034004                          pshs    b                                                                               ; save the position we're removing from
3935
                              disarm7:
3936
 00FFF4FD 05C                             incb                                                                                    ; set index for next byte
3937
 00FFF4FE 0A6A05                          lda             b,y                                                                     ; get byte
3938
 00FFF500 05A                             decb                                                                                    ; and store it back
3939
 00FFF501 0A7A05                          sta             b,y
3940
 00FFF503 05C                             incb                                                                                    ; move to next position
3941
 00FFF504 0C13B6                          cmpb    #numBreakpoints                 ; hit end of table?
3942
 00FFF506 025FF5                          blo             disarm7
3943
 00FFF508 035004                          puls    b                                                                               ; get back position
3944
 00FFF50A 058                             aslb                                                                                    ; times two for word index
3945
 00FFF50B 04F                             clra
3946
 00FFF50C 01F002                          tfr             d,y
3947
 00FFF50E 054                             lsrb                                                                                    ; back to byte index value
3948
                              disarm8:
3949
 00FFF50F 0EE202                          ldu             2,y                                                                     ; get next breakpoint address
3950
 00FFF511 0EFA01                          stu             ,y++                                                            ; store in current pos, increment
3951
 00FFF513 05C                             incb                                                                                    ; increment count
3952
 00FFF514 0C13B6                          cmpb    #numBreakpoints                 ; hit end of table?
3953
 00FFF516 025FF7                          blo             disarm8
3954
 00FFF518 0350F6                          puls    d,x,y,u,pc
3955
                              disarm3:
3956
 00FFF51A 030002                          leax    2,x
3957
 00FFF51C 05C                             incb
3958
 00FFF51D 020FBD                          bra             disarm6
3959
                              disarm4:
3960
 00FFF51F 0350F6                          puls    d,x,y,u,pc
3961
 
3962
                              ;------------------------------------------------------------------------------
3963
                              ;------------------------------------------------------------------------------
3964 4 robfinch
                              swi3_rout:
3965 15 robfinch
 00FFF521 01A010                          sei
3966
 00FFF523 0A6E04                          lda             ,s
3967
 00FFF525 0B700090F                       sta             mon_CCRSAVE
3968
 00FFF528 0EC601                          ldd             1,s
3969
 00FFF52A 0FD000900                       std             mon_DSAVE
3970
 00FFF52D 0E6603                          ldb             3,s
3971
 00FFF52F 0F700090E                       stb             mon_DPRSAVE
3972
 00FFF532 0EC604                          ldd             4,s
3973
 00FFF534 0FD000902                       std             mon_XSAVE
3974
 00FFF537 0EC606                          ldd             6,s
3975
 00FFF539 0FD000904                       std             mon_YSAVE
3976
 00FFF53C 0EC608                          ldd             8,s
3977
 00FFF53E 0FD000906                       std             mon_USAVE
3978
 00FFF541 1FF000908                       sts             mon_SSAVE
3979
 00FFF544 0EC60B                          ldd             11,s
3980
 00FFF546 0FD00090A                       std             mon_PCSAVE
3981
 00FFF549 1FF000908                       sts             mon_SSAVE
3982
 00FFF54C 1CE003FFF                       lds             #$3FFF
3983
 00FFF54F 0CCFFF559                       ldd             #swi3_exit
3984
 00FFF552 034006                          pshs    d
3985
 00FFF554 01C0EF                          cli
3986
 00FFF556 07EFFF2CF                       jmp             DumpRegs
3987 4 robfinch
                              swi3_exit:
3988 15 robfinch
 00FFF559 1FE000908                       lds             mon_SSAVE
3989
 00FFF55C 03B                             rti
3990 4 robfinch
 
3991
                              ;------------------------------------------------------------------------------
3992
                              ;------------------------------------------------------------------------------
3993 13 robfinch
                              firq_rout:
3994 15 robfinch
 00FFF55D 03B                             rti
3995 13 robfinch
 
3996 4 robfinch
                              irq_rout:
3997 13 robfinch
                              ;       lbsr    SerialIRQ       ; check for recieved character
3998 15 robfinch
 00FFF55E 017FFEF0B                       lbsr    TimerIRQ
3999
*** warning 1: Long branch within short branch range could be optimized
4000 13 robfinch
 
4001 4 robfinch
                                      ; Reset the edge sense circuit in the PIC
4002 15 robfinch
                              ;       lda             #31                                                     ; Timer is IRQ #31
4003
                              ;       sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
4004
                              ;       sta             PIC+16                                  ; register 16 is edge sense reset reg
4005
                              ;       lda             VIA+VIA_IFR
4006
                              ;       bpl             notTimerIRQ2
4007
                              ;       bita    #$800
4008
                              ;       beq             notTimerIRQ2
4009
                              ;       clr             VIA+VIA_T3LL
4010
                              ;       clr             VIA+VIA_T3LH
4011
                              ;       inc             $E00037                                 ; update timer IRQ screen flag
4012
                              ;notTimerIRQ2:
4013 4 robfinch
 
4014 15 robfinch
 00FFF561 0B6FFC014                       lda             IrqBase                 ; get the IRQ flag byte
4015
 00FFF564 044                             lsra
4016
 00FFF565 0BAFFC014                       ora             IrqBase
4017
 00FFF568 084FE0                          anda    #$FE0
4018
 00FFF56A 0B7FFC014                       sta             IrqBase
4019 4 robfinch
 
4020 13 robfinch
                              ;       inc             TEXTSCR+54              ; update IRQ live indicator on screen
4021 4 robfinch
 
4022
                                      ; flash the cursor
4023
                                      ; only bother to flash the cursor for the task with the IO focus.
4024 13 robfinch
                              ;       lda             COREID
4025
                              ;       cmpa    IOFocusID
4026
                              ;       bne             tr1a
4027
                              ;       lda             CursorFlash             ; test if we want a flashing cursor
4028
                              ;       beq             tr1a
4029
                              ;       lbsr    CalcScreenLoc   ; compute cursor location in memory
4030
                              ;       tfr             d,y
4031
                              ;       lda             $2000,y                 ; get color code $2000 higher in memory
4032
                              ;       ldb             IRQFlag                 ; get counter
4033
                              ;       lsrb
4034
                              ;       lsra
4035
                              ;       lsra
4036
                              ;       lsra
4037
                              ;       lsra
4038
                              ;       lsrb
4039
                              ;       rola
4040
                              ;       lsrb
4041
                              ;       rola
4042
                              ;       lsrb
4043
                              ;       rola
4044
                              ;       lsrb
4045
                              ;       rola
4046
                              ;       sta             $E00000,y               ; store the color code back to memory
4047
                              tr1a:
4048 15 robfinch
 00FFF56D 03B                             rti
4049 4 robfinch
 
4050
                              ;------------------------------------------------------------------------------
4051
                              ;------------------------------------------------------------------------------
4052
                              nmi_rout:
4053 15 robfinch
 00FFF56E 0150F6FFFFFFFE0                 ldb             COREID
4054
 00FFF573 086049                          lda             #'I'
4055
 00FFF575 08EE00028                       ldx             #TEXTSCR+40
4056
 00FFF578 0A7807                          sta             b,x
4057 13 robfinch
                              rti_insn:
4058 15 robfinch
 00FFF57A 03B                             rti
4059 4 robfinch
 
4060 13 robfinch
                              ; Special Register Area
4061
                                      org             $FFFFE0
4062
 
4063
                              ; Interrupt vector table
4064
 
4065 4 robfinch
                                      org             $FFFFF0
4066 15 robfinch
 00FFFFF0 FFF57A                          fcw             rti_insn                ; reserved
4067
 00FFFFF2 FFF521                          fcw             swi3_rout               ; SWI3
4068
 00FFFFF4 FFF57A                          fcw             rti_insn                ; SWI2
4069
 00FFFFF6 FFF55D                          fcw             firq_rout               ; FIRQ
4070
 00FFFFF8 FFF55E                          fcw             irq_rout                ; IRQ
4071
 00FFFFFA FFF3D1                          fcw             swi_rout                ; SWI
4072
 00FFFFFC FFF56E                          fcw             nmi_rout                ; NMI
4073 13 robfinch
 00FFFFFE FFE023                          fcw             start                           ; RST
4074 4 robfinch
 
4075 15 robfinch
66 warning(s) in pass 2.
4076 4 robfinch
 
4077
SYMBOL TABLE
4078 13 robfinch
      ACIA 00 FFE30100  ACIA_CMD 00 00000002 ACIA_CTRL 00 00000003 ACIA_CTRL2 00 0000000B
4079 15 robfinch
   ACIA_RX 00 00000000 ACIA_STAT 00 00000001   ACIA_TX 00 00000000      ARM1 02 00FFF4AA
4080
      ARM2 02 00FFF496 ARMALLBREAKPOINTS 02 00FFF48D ARMBREAKPOINT 02 00FFF4AC ASCIITODECNYBBLE 02 00FFF047
4081
 ASCIITOHEXNYBBLE 02 00FFF01F    ASMBUF 00 00000160 BIOS_SCREENS 00 17000000 BLANKLINE 02 00FFE275
4082
 BLKCPYDST 00 00000020 BLKCPYSRC 00 0000001C   BLNKLN1 02 00FFE288    BOOTPG 02 00FFF3B3
4083
 BOOT_STACK 02 00FFF3B4 BREAKPOINTBYTES 00 00000830 BREAKPOINTFLAG 00 00000810 BREAKPOINTS 00 00000820
4084
 CALCSCREENLOC 02 00FFE2DB CHARCOLOR 00 00000112 CHARINVEC 00 00000804 CHAROUTVEC 00 00000800
4085
 CHECKPOINT 02 00FFE132 CLEARSCREEN 02 00FFE22E CLEARSCREENJMP 02 00FFD300 CMDPROMPT 02 00FFEE30
4086
 CMDPROMPTJI 00 00000808 CMDTABLE1 02 00FFEDE3 CMDTABLE2 02 00FFEE0E COLORCODELOCATION 00 00000014
4087
      COLS 00 00000040 COPYSCREENTOVIRTUALSCREEN 02 00FFE1FE COPYVIRTUALSCREENTOSCREEN 02 00FFE1C7    COREID 00 FFFFFFE0
4088
        CR 00 0000000D      CRLF 02 00FFD0D2     CRLF1 02 00FFD0D2    CRLFST 02 00FFE3FE
4089
       CS1 02 00FFE23B       CS2 02 00FFE252     CS2V1 02 00FFE20A       CS3 02 00FFE258
4090
      CSL1 02 00FFE2F6     CTRLC 00 00000003     CTRLH 00 00000008     CTRLI 00 00000009
4091
     CTRLJ 00 0000000A     CTRLK 00 0000000B     CTRLM 00 0000000D     CTRLS 00 00000013
4092
     CTRLT 00 00000014     CTRLX 00 00000018 CURSORCOL 00 00000111 CURSORFLASH 00 00000114
4093
 CURSORROW 00 00000110     CV2S1 02 00FFE1DC DBGCHECKFORKEY 02 00FFEA10     DBGK1 02 00FFEA4B
4094
    DBGK10 02 00FFEAB0    DBGK11 02 00FFEB09    DBGK12 02 00FFEB0F    DBGK13 02 00FFEB1B
4095
    DBGK14 02 00FFEB2B    DBGK15 02 00FFEB3A    DBGK16 02 00FFEB45    DBGK17 02 00FFEB4E
4096
    DBGK18 02 00FFEB51     DBGK2 02 00FFEA16    DBGK20 02 00FFEA38    DBGK22 02 00FFEA54
4097
    DBGK23 02 00FFEA65    DBGK24 02 00FFEA46     DBGK3 02 00FFEA68     DBGK4 02 00FFEA74
4098
     DBGK5 02 00FFEA80     DBGK7 02 00FFEA90     DBGK8 02 00FFEA96     DBGK9 02 00FFEAAA
4099
 DBGKNOTALT 02 00FFEB13 DBGKNOTCAPSLOCK 02 00FFEAE2 DBGKNOTCTRL 02 00FFEA9A DBGKNOTNUMLOCK 02 00FFEACB
4100
 DBGKNOTRSHIFT 02 00FFEAB4 DBGKNOTSCROLLLOCK 02 00FFEAF9      DCCR 02 00FFE30E      DCLF 02 00FFE398
4101
     DCX10 02 00FFE348     DCX11 02 00FFE358     DCX12 02 00FFE354     DCX13 02 00FFE364
4102
     DCX14 02 00FFE30B      DCX3 02 00FFE386      DCX4 02 00FFE39A      DCX5 02 00FFE375
4103
      DCX6 02 00FFE31F      DCX7 02 00FFE31B      DCX8 02 00FFE32C      DCX9 02 00FFE339
4104
   DELAY3S 02 00FFE1AA      DFL1 02 00FFF3A6      DFL2 02 00FFF393   DISARM1 02 00FFF48B
4105
   DISARM2 02 00FFF477   DISARM3 02 00FFF51A   DISARM4 02 00FFF51F   DISARM6 02 00FFF4DC
4106
   DISARM7 02 00FFF4FD   DISARM8 02 00FFF50F DISARMALLBREAKPOINTS 02 00FFF46E DISARMBREAKPOINT 02 00FFF4D3
4107
 DISPBYTEASHEX 02 00FFE413 DISPDWORDASHEX 02 00FFE401 DISPLAYCHAR 02 00FFE2FE DISPLAYERR 02 00FFF055
4108
 DISPLAYSTRING 02 00FFE3BF DISPLAYSTRINGCRLF 02 00FFE3D6 DISPLAYSTRINGDX 02 00FFF05E   DISPNYB 02 00FFE42B
4109
  DISPNYB1 02 00FFE43A DISPWORDASHEX 02 00FFE40A    DLY3S1 02 00FFE1AD    DLY3S2 02 00FFE1B1
4110
     DMPM1 02 00FFF226     DMPM2 02 00FFF211     DMPM3 02 00FFF25F     DMPM4 02 00FFF251
4111
     DMPM5 02 00FFF249   DRAMERR 02 00FFD48F  DRAMTEST 02 00FFD443 DRAMTEST1 02 00FFD453
4112
 DRAMTEST3 02 00FFD46F DRAMTEST4 02 00FFD460 DRAMTEST5 02 00FFD47C DRAM_BASE 00 10000000
4113
    DSPJ1B 02 00FFE3C8     DSPJ2 02 00FFE3C3    DSRETB 02 00FFE3D1 DUMPIOFOCUSLIST 02 00FFF390
4114
 DUMPMEMORY 02 00FFF209  DUMPREGS 02 00FFF2CF    DUMRTS 02 00FFE022  EDITMEM1 02 00FFF283
4115
  EDITMEM2 02 00FFF26E  EDITMEM3 02 00FFF2A2  EDITMEM4 02 00FFF28D  EDITMEM6 02 00FFF299
4116
 EDITMEMORY 02 00FFF265 ENDOFWORD 02 00FFEF06   FARFLAG 00 0000015F    FILLM1 02 00FFF2B5
4117
    FILLM2 02 00FFF2C5    FILLM3 02 00FFF2CC FILLMEMORY 02 00FFF2A5 FIRQ_ROUT 02 00FFF55D
4118
 FIRST_CORE 00 00000001   FREEMBX 02 00000002   FREEMSG 02 00000006   FREETCB 00 0000078A
4119
 GETHEXNUMBER 02 00FFEFEF    GETKEY 02 00FFEA12  GETRANGE 02 00FFEFC6 GETSCREENLOCATION 02 00FFE28F
4120
 GETTWOPARAMS 02 00FFEFA5     GRNG1 02 00FFEFE1      GSL1 02 00FFE29D     GTDC3 02 00FFF052
4121
     GTHX3 02 00FFF044     GTHX5 02 00FFF02A     GTHX6 02 00FFF037    GTHXN1 02 00FFF01B
4122
    GTHXN2 02 00FFEFFC       HC1 02 00FFE2B7   HELPMSG 02 00FFF06E      HEX2 02 00FFD2CE
4123
      HEX4 02 00FFD2D2 HOMECURSOR 02 00FFE2A1 HOMECURSORJMP 02 00FFD308     I2CW1 02 00FFE49B
4124
    I2CWR1 02 00FFE4C8   I2C_CMD 00 00000004  I2C_CTRL 00 00000002  I2C_INIT 02 00FFE48F
4125
  I2C_PREH 00 00000001  I2C_PREL 00 00000000   I2C_RXR 00 00000003  I2C_STAT 00 00000004
4126
   I2C_TXR 00 00000003 I2C_WAIT_RX_NACK 02 00FFE4C6 I2C_WAIT_TIP 02 00FFE499 I2C_WR_CMD 02 00FFE4A3
4127
 I2C_XMIT1 02 00FFE4AC      ICC1 02 00FFE3BB      ICC2 02 00FFE3BD      ICR1 02 00FFE3AD
4128
 IGNBLANKS 02 00FFEF53 IGNBLANKS1 02 00FFEF53 INCCURSORPOS 02 00FFE39C INCCURSORROW 02 00FFE3AB
4129
      INCH 02 00FFECDA     INCH1 02 00FFECEF     INCH2 02 00FFECDC     INCHE 02 00FFECF8
4130
    INCHEK 02 00FFECFC   INCHEK1 02 00FFED11   INCHEK2 02 00FFED0E   INCHEK3 02 00FFED05
4131
      INIT 02 00FFE09E     INIT1 02 00FFE0A6 INITSERIAL 02 00FFEB6F IOFOCUSID 00 00FFC010
4132
 IOFOCUSLIST 00 00FFC000 IOFOCUSNDX 00 00000100   IRQBASE 00 00FFC014   IRQFLAG 00 00FFC012
4133
 IRQSOURCE 00 00FFC011  IRQ_ROUT 02 00FFF55E    JMPVEC 00 00000928  JTC_EXIT 02 00FFF355
4134
 JUMP_TO_CODE 02 00FFF31A KBDBUFFULL 02 00FFEA0D   KBDFIFO 00 00000040 KBDFIFOALIAS 00 00C00040
4135
 KBDHEADRCV 00 00000127  KBDI0002 02 00FFE949  KBDI0004 02 00FFE98E KBDITRYAGAIN 02 00FFE982
4136
 KBDRCVCOUNT 02 00FFE9BD KBDTAILRCV 00 00000128     KBGS1 02 00FFE8F8     KBGS2 02 00FFE8F0
4137
     KBGS3 02 00FFE8E1     KEYBD 00 FFE30400  KEYBDACK 00 FFFFCC00  KEYBDBAD 00 FFFFCB00
4138
 KEYBDBLOCK 00 00000126 KEYBDBUFFER 00 FFFFC000 KEYBDCHECKFORKEYDIRECT 02 00FFECD8 KEYBDCLOSE 02 00FFEB6B
4139
  KEYBDCLR 00 FFE30402 KEYBDCONTROLCODES 02 00FFE780 KEYBDECHO 00 FFFFCA00 KEYBDEXTENDEDCODES 02 00FFE800
4140
 KEYBDGETID 02 00FFE91C KEYBDGETSCANCODE 02 00FFE8FD KEYBDGETSTATUS 02 00FFE8E1 KEYBDHEAD 00 FFFFC800
4141
   KEYBDID 00 00000124 KEYBDINIT 02 00FFE940  KEYBDIRQ 02 00FFE9CF KEYBDLOCKS 00 FFFFCD00
4142
 KEYBDOPEN 02 00FFEB6A KEYBDREAD 02 00FFEB6C KEYBDRECVBYTE 02 00FFE880 KEYBDSEEK 02 00FFEB6E
4143
 KEYBDSENDBYTE 02 00FFE899 KEYBDSETLED 02 00FFE909 KEYBDTAIL 00 FFFFC900 KEYBDWAITTX 02 00FFE89F
4144
 KEYBDWRITE 02 00FFEB6D    KEYLED 00 00000122 KEYSTATE1 00 00000120 KEYSTATE2 00 00000121
4145
     KGID1 02 00FFE939  KGNOTKBD 02 00FFE93C      KRB3 02 00FFE885      KRB4 02 00FFE895
4146
    KRCXIT 02 00FFE9CE      KWT1 02 00FFE8A4      KWT2 02 00FFE8B5      LEDS 00 FFE60001
4147
    LEDXIT 02 00FFE9A2    LETTER 02 00FFD2C1        LF 00 0000000A MAX_TASKNO 00 0000003F
4148
   MF_CRLF 00 00000003 MF_DISPLAYBYTEASHEX 00 00000005 MF_DISPLAYSTRING 00 00000004 MF_DISPLAYWORDASHEX 00 00000006
4149
 MF_GETRANGE 00 0000000B   MF_INCH 00 00000001 MF_MONITOR 00 00000000 MF_OSCALL 00 0000000A
4150
  MF_OUTCH 00 00000002 MF_RANDOM 00 00000009 MF_SHOWSPRITES 00 00000007  MF_SRAND 00 00000008
4151
 MONERRVEC 00 0000080C  MONGETCH 02 00FFEF47 MONGETNONSPACE 02 00FFEF4C   MONITOR 02 00FFEEA7
4152
 MONITORSTART 02 00FFEE60 MON_CCRSAVE 00 0000090F MON_DPRSAVE 00 0000090E MON_DSAVE 00 00000900
4153
 MON_NUMWKA 00 00000910 MON_PCSAVE 00 0000090A    MON_R1 00 00000920    MON_R2 00 00000924
4154
  MON_RAND 02 00FFEDCE MON_ROM_VECS 02 00FFF3B9 MON_ROM_VECTAB 02 00FFF3B7 MON_SRAND 02 00FFEDA0
4155
 MON_SRAND1 02 00FFEDA3 MON_SSAVE 00 00000908 MON_USAVE 00 00000906 MON_VECTB 00 00000880
4156 14 robfinch
 MON_XSAVE 00 00000902 MON_YSAVE 00 00000904   MSCOUNT 00 FFFFFFE4 MSGBADKEYBD 02 00FFE9AE
4157 15 robfinch
    MSGERR 02 00FFF066 MSGF09STARTING 02 00FFEE3B MSGREGHEADINGS 02 00FFF1C6 MSGSERIALTEST 02 00FFECC5
4158
 MSGSTARTUP 02 00FFE111 MULTI_SIEVE 02 00FFE148 MULTI_SIEVE1 02 00FFE16B MULTI_SIEVE2 02 00FFE167
4159
 MULTI_SIEVE3 02 00FFE155 MULTI_SIEVE4 02 00FFE17E     NHEX4 02 00FFF200  NMAILBOX 02 00000004
4160
 NMESERIAL 02 00FFEC8E   NMIBASE 00 00FFC013  NMI_ROUT 02 00FFF56E   NMSGBLK 02 00000008
4161
 NOTKBDIRQ 02 00FFEA0C  NOTRXINT 02 00FFEC8D NOTTIMERIRQ 02 00FFE48E NUMBREAKPOINTS 02 00FFF3B6
4162
  NUMFUNCS 00 0000000D NUMOSFUNCS 00 00000019 NUMSETBREAKPOINTS 00 00000811   NXBLANK 02 00FFF204
4163
    ONEKEY 02 00FFD1DC      OSC1 02 00FFF467 OSCALLTBL 02 00FFED27      OSCX 02 00FFF469
4164
    OSSEMA 00 00EF0010     OUTCH 02 00FFED12   OUTSEMA 00 00EF0000 PARSECMD1 02 00FFEEF1
4165
     PCRLF 02 00FFE3EA     PDATA 02 00FFE3F7       PIC 00 FFE3F000    PICPTR 00 00000028
4166
     PRINT 02 00FFE3F4      PRNG 00 FFE30600 PROCESSBREAKPOINT 02 00FFF41E   PROMPT1 02 00FFEED4
4167
  PROMPT2A 02 00FFEF25   PROMPT3 02 00FFEEC5 PROMPTCLEARSCREEN 02 00FFEF3F PROMPTHELP 02 00FFEF37
4168
  PROMPTLN 02 00FFEEC1    PSTRNG 02 00FFE3E6     QNDX0 00 00000780     QNDX1 00 00000782
4169
     QNDX2 00 00000784     QNDX3 00 00000786     QNDX4 00 00000788    RAMERR 02 00FFD42C
4170
   RAMTEST 02 00FFD400  RAMTEST1 02 00FFD40D  RAMTEST3 02 00FFD417  REDIRECT 02 00FFEF11
4171
 RELEASEIOFOCUS 02 00FFED70 REQUESTIOFOCUS 02 00FFED59     RIOF1 02 00FFED97     RIOF2 02 00FFED86
4172
  ROMTORAM 02 00FFE138 ROMTORAM1 02 00FFE13E      ROWS 00 00000020       RTC 00 FFE30500
4173
    RTCBUF 00 00007FC0  RTCR0001 02 00FFE4F6  RTCW0001 02 00FFE541  RTC_READ 02 00FFE4D0
4174
 RTC_RXERR 02 00FFE51F RTC_WRITE 02 00FFE523  RTI_INSN 02 00FFF57A RUNNINGID 00 00FFC013
4175
 RUNNINGTCB 06 00000000 SCANNEXTWORD 02 00FFEEFB SCREENCOLOR 00 00000113 SCREENLOCATION 00 00000010
4176
 SCREENLOCATION2 00 00000018  SCROLLUP 02 00FFE25A    SCRUP1 02 00FFE267    SC_ALT 00 00000011
4177
      SC_C 00 00000021 SC_CAPSLOCK 00 00000058   SC_CTRL 00 00000014    SC_DEL 00 00000071
4178
 SC_EXTEND 00 000000E0    SC_F12 00 00000007  SC_KEYUP 00 000000F0 SC_NUMLOCK 00 00000077
4179
 SC_RSHIFT 00 00000059 SC_SCROLLLOCK 00 0000007E      SC_T 00 0000002C    SC_TAB 00 0000000D
4180
      SC_Z 00 0000001A   SEMAABS 00 00001000 SERHEADRCV 00 00000131 SERHEADXMIT 00 00000136
4181
  SERHZERO 00 00000130 SERIALGETCHAR 02 00FFEB9D SERIALINIT 02 00FFEB6F SERIALIRQ 02 00FFEC3B
4182
 SERIALOUTPUTTEST 02 00FFECA5 SERIALPEEKCHAR 02 00FFEBCD SERIALPEEKCHARDIRECT 02 00FFEBE4 SERIALPUTCHAR 02 00FFEC08
4183
 SERIALPUTSTRING 02 00FFEC95 SERIALRCVCOUNT 02 00FFEC28 SERRCVBUF 00 00BFF000 SERRCVXOFF 00 00000140
4184
 SERRCVXON 00 00000139 SERTAILRCV 00 00000133 SERTAILXMIT 00 00000138  SERTZERO 00 00000132
4185
 SETKEYBOARDECHO 02 00FFED16      SGC2 02 00FFEBB6 SGCNOCHARS 02 00FFEBC6    SGCXIT 02 00FFEBC9
4186
 SHIFTEDSCANCODES 02 00FFE680 SHIFTLEFT5 02 00FFE1BC SHL_NUMWKA 02 00FFEFE2 SHOWSPRITES 02 00FFED1C
4187
     SIEVE 02 00FFE182    SIEVE1 02 00FFE19A    SIEVE2 02 00FFE196    SIEVE3 02 00FFE187
4188
    SIEVE4 02 00FFE1A9     SINI1 02 00FFEB82  SIRQ0001 02 00FFEC4D SIRQNXTBYTE 02 00FFEC3B
4189
 SIRQRXFULL 02 00FFEC8D SKIPDOLLAR 02 00FFEEE3 SKIP_INIT 02 00FFE0DE    SOTST1 02 00FFECAF
4190
   SPC0001 02 00FFEC0A  SPCD0001 02 00FFEC02 SPCNOCHARS 02 00FFEBDF    SPCXIT 02 00FFEBE2
4191
 SPRITE_CTRL 00 FFE10000 SPRITE_EN 00 000003C0      SPS2 02 00FFEC99    SPSXIT 02 00FFECA3
4192
    SRCXIT 02 00FFEC3A       ST1 02 00FFE0B8       ST3 02 00FFE095       ST6 02 00FFE03F
4193
       ST7 02 00FFE049       ST8 02 00FFE049       ST9 02 00FFE063     START 02 00FFE023
4194
    STRPTR 00 00000024 SWI3_EXIT 02 00FFF559 SWI3_ROUT 02 00FFF521 SWICALLOS 02 00FFF454
4195
 SWINOTBKPT 02 00FFF3EE  SWI_ROUT 02 00FFF3D1 SWI_ROUT1 02 00FFF3D6 SWI_ROUT2 02 00FFF3E7
4196
 SWI_ROUT3 02 00FFF41A       TAB 00 00000009 TCB_CURSORCOL 00 00000021 TCB_CURSORROW 00 00000020
4197
  TCB_HJCB 00 0000001C TCB_HWAITMBX 00 00000022 TCB_IOF_NEXT 00 0000002C TCB_IOF_PREV 00 00000030
4198
 TCB_MBQ_NEXT 00 00000024 TCB_MBQ_PREV 00 00000028 TCB_MMU_MAP 00 00000038 TCB_MSGPTR_D1 00 00000014
4199
 TCB_MSGPTR_D2 00 00000018 TCB_NXTRDY 00 00000000 TCB_NXTTCB 00 00000008 TCB_PRIORITY 00 00000010
4200
 TCB_PRVRDY 00 00000004 TCB_SPSAVE 00 00000034 TCB_STATUS 00 0000001E TCB_TIMEOUT 00 0000000C
4201
 TEXTCLOSE 02 00FFE22A  TEXTOPEN 02 00FFE229  TEXTREAD 02 00FFE22B   TEXTREG 00 FFE07F00
4202
   TEXTSCR 00 FFE00000  TEXTSEEK 02 00FFE22D TEXTWRITE 02 00FFE22C TEXT_COLS 00 00000000
4203
 TEXT_CURPOS 00 00000022 TEXT_ROWS 00 00000001 TIMEOUTLIST 00 0000078C TIMERINIT 02 00FFE441
4204
  TIMERIRQ 02 00FFE46C   TIMES10 02 00FFEF5C      TR1A 02 00FFF56D      UCP1 02 00FFE2D9
4205
 UNSHIFTEDSCANCODES 02 00FFE580 UPDATECURSORPOS 02 00FFE2B9       VIA 00 FFE60000   VIA_ACR 00 0000000B
4206
  VIA_DDRA 00 00000003   VIA_IER 00 0000000E   VIA_IFR 00 0000000D    VIA_PA 00 00000001
4207
 VIA_T3CMPH 00 00000015 VIA_T3CMPL 00 00000014  VIA_T3LH 00 00000013  VIA_T3LL 00 00000012
4208
  W10_0001 02 00FFE8C0 W300_0001 02 00FFE8D4  WAIT10MS 02 00FFE8B9 WAIT300MS 02 00FFE8CD
4209
    XBLANK 02 00FFD0AF XITMONITOR 02 00FFF451      XOFF 00 00000013       XON 00 00000011
4210
528 SYMBOLS
4211 4 robfinch
 
4212 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.