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

Subversion Repositories rf6809

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

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

Line No. Rev Author Line
1 4 robfinch
 
2
                              ; ============================================================================
3
                              ;        __
4
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Stratford
5
                              ;    \  __ /    All rights reserved.
6
                              ;     \/_//     robfinch@opencores.org
7
                              ;       ||
8
                              ;
9
                              ;
10
                              ; This source file is free software: you can redistribute it and/or modify
11
                              ; it under the terms of the GNU Lesser General Public License as published
12
                              ; by the Free Software Foundation, either version 3 of the License, or
13
                              ; (at your option) any later version.
14
                              ;
15
                              ; This source file is distributed in the hope that it will be useful,
16
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
17
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
                              ; GNU General Public License for more details.
19
                              ;
20
                              ; You should have received a copy of the GNU General Public License
21
                              ; along with this program.  If not, see .
22
                              ;
23
                              ; ============================================================================
24
                              ;
25
                              CR      EQU     $0D             ;ASCII equates
26
                              LF      EQU     $0A
27
                              TAB     EQU     $09
28
                              CTRLC   EQU     $03
29
                              CTRLH   EQU     $08
30
                              CTRLI   EQU     $09
31
                              CTRLJ   EQU     $0A
32
                              CTRLK   EQU     $0B
33
                              CTRLM   EQU $0D
34
                              CTRLS   EQU     $13
35
                              CTRLX   EQU     $18
36
                              XON             EQU     $11
37
                              XOFF    EQU     $13
38
 
39
                              FIRST_CORE      EQU     1
40
                              MAX_TASKNO      EQU 63
41
                              DRAM_BASE       EQU $10000000
42
 
43
                              ScreenLocation          EQU             $10
44
                              ColorCodeLocation       EQU             $14
45
                              ScreenLocation2         EQU             $18
46
                              BlkcpySrc                       EQU             $1C
47
                              BlkcpyDst                       EQU             $20
48
                              Strptr                          EQU             $24
49
                              PICptr                          EQU             $28
50
                              ; Forth Area
51
                              ; 0x30-0x60
52
 
53
                              RunningID                       EQU             $800000
54
 
55
                              ; Task control blocks, room for 256 tasks
56
                              TCB_NxtRdy              EQU             $00     ; next task on ready / timeout list
57
                              TCB_PrvRdy              EQU             $04     ; previous task on ready / timeout list
58
                              TCB_NxtTCB              EQU             $08
59
                              TCB_Timeout             EQU             $0C
60
                              TCB_Priority    EQU             $10
61
                              TCB_MSGPTR_D1   EQU             $14
62
                              TCB_MSGPTR_D2   EQU             $18
63
                              TCB_hJCB                        EQU             $1C
64
                              TCB_Status              EQU             $1E
65
                              TCB_CursorRow   EQU             $20
66
                              TCB_CursorCol   EQU             $21
67
                              TCB_hWaitMbx    EQU             $22     ; handle of mailbox task is waiting at
68
                              TCB_mbq_next    EQU             $24     ; mailbox queue next
69
                              TCB_mbq_prev    EQU             $28     ; mailbox queue previous
70
                              TCB_iof_next    EQU             $2C
71
                              TCB_iof_prev    EQU             $30
72
                              TCB_SPSave              EQU             $34     ; TCB_SPSave area
73
                              TCB_mmu_map             EQU             $38
74
 
75
                              KeybdHead               EQU             $FFFFFC800
76
                              KeybdTail               EQU             $FFFFFC900
77
                              KeybdEcho               EQU             $FFFFFCA00
78
                              KeybdBad                EQU             $FFFFFCB00
79
                              KeybdAck                EQU             $FFFFFCC00
80
                              KeybdLocks              EQU             $FFFFFCD00
81
                              KeybdBuffer             EQU             $FFFFFC000      ; buffer is 16 chars
82
 
83
                              COREID  EQU             $FFFFFFFE0
84
                              MSCOUNT EQU             $FFFFFFFE4
85
                              LEDS            EQU             $FFFE60000
86
                              TEXTSCR         EQU             $FFFE00000
87
                              TEXTREG         EQU             $FFFE0DF00
88
                              TEXT_COLS       EQU             0
89
                              TEXT_ROWS       EQU             1
90
                              TEXT_CURPOS     EQU             34
91
                              KEYBD           EQU             $FFFE30400
92
                              KEYBDCLR        EQU             $FFFE30402
93
                              PIC                     EQU             $FFFE3F000
94
                              SPRITE_CTRL             EQU             $FFFE10000
95
                              SPRITE_EN                       EQU             $3C0
96
 
97
                              BIOS_SCREENS    EQU     $17000000       ; $17000000 to $171FFFFF
98
 
99
                              ; EhBASIC vars:
100
                              ;
101
                              NmiBase         EQU             $DC
102
                              IrqBase         EQU             $DF
103
 
104
                              ; The IO focus list is a doubly linked list formed into a ring.
105
                              ;
106
                              IOFocusNdx      EQU             $100
107
                              IOFocusID               EQU             $100
108
 
109
                              ; These variables use direct page access
110
                              CursorRow       EQU             $110
111
                              CursorCol       EQU             $111
112
                              CharColor       EQU             $112
113
                              ScreenColor     EQU             $113
114
                              CursorFlash     EQU             $114
115
                              KeyState1       EQU     $120
116
                              KeyState2       EQU     $121
117
                              KeyLED          EQU     $122
118
                              KeybdID         EQU     $124
119
 
120
                              QNdx0           EQU             $780
121
                              QNdx1           EQU             QNdx0+2
122
                              QNdx2           EQU             QNdx1+2
123
                              QNdx3           EQU             QNdx2+2
124
                              QNdx4           EQU             QNdx3+2
125
                              FreeTCB         EQU             QNdx4+2
126
                              TimeoutList     EQU             FreeTCB+2
127
                              FreeMbx         EQU             RunningTCB + 2
128
                              nMailbox        EQU             FreeMbx + 2
129
                              FreeMsg         EQU             nMailbox + 2
130
                              nMsgBlk         EQU             FreeMsg + 2
131
 
132
                              IrqSource       EQU             $79A
133
 
134
                              IRQFlag         EQU             $7C6
135
 
136
                              CharOutVec      EQU             $800
137
                              CharInVec       EQU             $804
138
 
139
                              ; Register save area for monitor
140
                              mon_DSAVE       EQU             $900
141
                              mon_XSAVE       EQU             $902
142
                              mon_YSAVE       EQU             $904
143
                              mon_USAVE       EQU             $906
144
                              mon_SSAVE       EQU             $908
145
                              mon_PCSAVE      EQU             $90A
146
                              mon_DPRSAVE     EQU             $90E
147
                              mon_CCRSAVE     EQU             $90F
148
 
149
                              mon_numwka      EQU             $910
150
                              mon_r1          EQU             $920
151
                              mon_r2          EQU             $922
152
 
153
                              ; The ORG directive must set an address a multiple of 4 in order for the Verilog
154
                              ; output to work correctly.
155
 
156
                                      org             $FFD0AC
157
 00FFD0AC 012                             nop
158
 00FFD0AD 012                             nop
159
 00FFD0AE 012                             nop
160
                              XBLANK
161
 00FFD0AF 0C6020                          ldb             #' '
162
 00FFD0B1 0170028C8                       lbsr    OUTCH
163
 00FFD0B4 039                             rts
164
 
165
                                      org             $FFD0D0
166
 00FFD0D0 012                             nop
167
 00FFD0D1 012                             nop
168
                              CRLF
169
                              CRLF1:
170
 00FFD0D2 0C600D                          ldb             #CR
171
 00FFD0D4 0170028A5                       lbsr    OUTCH
172
 00FFD0D7 0C600A                          ldb             #LF
173
 00FFD0D9 0170028A0                       lbsr    OUTCH
174
 00FFD0DC 039                             rts
175
 
176
                                      org             $FFD0F0
177
 00FFD0F0 012                             nop
178
 00FFD0F1 020FDF                          bra             CRLF1
179
 
180
                                      org             $FFD1DC
181
                              ONEKEY
182
 00FFD1DC 06E90F000804                    jmp             [CharInVec]
183
 
184
                                      org             $FFD2C0
185
 00FFD2C0 012                             nop
186
                              LETTER
187
 00FFD2C1 0170026B8                       lbsr    OUTCH
188
 00FFD2C4 039                             rts
189
 
190
                                      org             $FFD2CC
191
 00FFD2CC 012                             nop
192
 00FFD2CD 012                             nop
193
                              HEX2
194
 00FFD2CE 0170020CC                       lbsr    DispByteAsHex
195
 00FFD2D1 039                             rts
196
                              HEX4
197
 00FFD2D2 0170020BF                       lbsr    DispWordAsHex
198
 00FFD2D5 039                             rts
199
 
200
                                      org             $FFD300
201
                              ClearScreenJmp
202
 00FFD300 016001ECD                       lbra    ClearScreen
203
                                      org             $FFD308
204
                              HomeCursorJmp
205
 00FFD308 016001F36                       lbra    HomeCursor
206
 
207
                                      org             $FFE000
208
 
209
                              ; Local RAM test routine
210
                              ; Checkerboard testing.
211
                              ; There is 70kB of local RAM
212
                              ; Does not use any RAM including no stack
213
 
214
                              ramtest:
215
 00FFE000 18E000000                       ldy             #0
216
 00FFE003 086001                          lda             #1
217
 00FFE005 0150B7FFFE60000                 sta             LEDS
218
 00FFE00A 0CCAAA555                       ldd             #$AAA555
219
                              ramtest1:
220
 00FFE00D 0EDA01                          std             ,y++
221
 00FFE00F 18CC00000                       cmpy    #$C00000
222
 00FFE012 025FF9                          blo             ramtest1
223
                                      ; now readback values and compare
224
 00FFE014 18E000000                       ldy             #0
225
                              ramtest3:
226
 00FFE017 0ECA01                          ldd             ,y++
227
 00FFE019 183AAA555                       cmpd    #$AAA555
228
 00FFE01C 02600E                          bne             ramerr
229
 00FFE01E 18CC00000                       cmpy    #$C00000
230
 00FFE021 025FF4                          blo             ramtest3
231
 00FFE023 086002                          lda             #2
232
 00FFE025 0150B7FFFE60000                 sta             LEDS
233
 00FFE02A 06EC04                          jmp             ,u
234
                              ramerr:
235
 00FFE02C 086080                          lda             #$80
236
 00FFE02E 0150B7FFFE60000                 sta             LEDS
237
 00FFE033 08EE00000                       ldx             #TEXTSCR
238
 00FFE036 0150F6FFFFFFFE0                 ldb             COREID
239
 00FFE03B 03A                             abx
240
 00FFE03C 086046                          lda             #'F'
241
 00FFE03E 0A7804                          sta             ,x
242
 00FFE040 013                             sync
243
 00FFE041 06EC04                          jmp             ,u
244
 
245
                                      org             $FFF000
246
 00FFF000 FFF996                          FDB Monitor
247
 00FFF002 FFF022                          FDB DumRts      ;       NEXTCMD
248
 00FFF004 FFF95E                          FDB INCH
249
 00FFF006 FFF963                          FDB INCHE
250
 00FFF008 FFF967                          FDB INCHEK
251
 00FFF00A FFF97C                          FDB OUTCH
252
 00FFF00C FFF381                          FDB PDATA
253
 00FFF00E FFF374                          FDB PCRLF
254
 00FFF010 FFF370                          FDB PSTRNG
255
 00FFF012 FFF022                          FDB DumRts                      ; LRA
256
 00FFF014 FFF022                          FDB DumRts
257
 00FFF016 FFF022                          FDB DumRts
258
 00FFF018 FFF022                          FDB DumRts
259
 00FFF01A FFF022                          FDB DumRts                      ; VINIZ
260
 00FFF01C FFF29B                          FDB DisplayChar ;       VOUTCH
261
 00FFF01E FFF022                          FDB DumRts                      ; ACINIZ
262
 00FFF020 FFF022                          FDB DumRts                      ; AOUTCH
263
 
264
                              DumRts:
265
 00FFF022 039                             rts
266
 
267
                              ;------------------------------------------------------------------------------
268
                              ;------------------------------------------------------------------------------
269
 
270
                              start:
271
 00FFF023 086055                          lda             #$55                    ; see if we can at least set LEDs
272
 00FFF025 0150B7FFFE60000                 sta             LEDS
273
 00FFF02A 0CEFFF030                       ldu             #st6                    ; U = return address
274
 00FFF02D 07EFFE000                       jmp             ramtest         ; JMP dont JSR
275
                              st6:
276
 00FFF030 1CE003FFF                       lds             #$3FFF          ; boot up stack area
277
 00FFF033 0150B6FFFFFFFE0                 lda             COREID
278
 00FFF038 081001                          cmpa    #FIRST_CORE
279
                              ;       beq             st8
280
                              ;       sync                                            ; halt cores other than 2
281
                              st8:
282
                              ;       bne             skip_init
283
                              ;       bsr             romToRam
284
                              ;       ldd             #st7 & $FFFF
285
                              ;       tfr             d,x
286
                              ;       jmp             ,x                              ; jump to the BIOS now in local RAM
287
                              st7:
288
 00FFF03A 08D11F                          bsr             Delay3s         ; give some time for devices to reset
289
 00FFF03C 0860AA                          lda             #$AA
290
 00FFF03E 0150B7FFFE60000                 sta             LEDS
291
 00FFF043 086002                          lda             #2
292
 00FFF045 097100                          sta             IOFocusID       ; core #2 has focus
293
 00FFF047 0B7800000                       sta             RunningID
294
 00FFF04A 0860CE                          lda             #$0CE
295
 00FFF04C 097113                          sta             ScreenColor
296
 00FFF04E 097112                          sta             CharColor
297
 00FFF050 08D17E                          bsr             ClearScreen
298
 00FFF052 0CCFFF29B                       ldd             #DisplayChar
299
 00FFF055 0DD800                          std             CharOutVec
300
 00FFF057 0CCFFF83B                       ldd             #DBGGetKey
301
 00FFF05A 0DD804                          std             CharInVec
302
 00FFF05C 0150F6FFFFFFFE0                 ldb             COREID
303
 00FFF061 0C1001                          cmpb    #FIRST_CORE
304
 00FFF063 02700D                          beq             init
305
 00FFF065 020025                          bra             skip_init
306
 00FFF067 02008D                          bra             multi_sieve
307
                              st3:
308
 00FFF069 0860FF                          lda             #$FF
309
 00FFF06B 0150B7FFFE60000                 sta             LEDS
310
 00FFF070 020FF7                          bra             st3
311
 
312
                                      ; initialize interrupt controller
313
                                      ; first, zero out all the vectors
314
                              init:
315
 00FFF072 08E000080                       ldx             #128
316
 00FFF075 086001                          lda             #1                      ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
317
 00FFF077 0C6001                          ldb             #FIRST_CORE                     ; serving core id
318
                              st1:
319
 00FFF079 06F809E3F000                    clr             PIC,x           ; cause code
320
 00FFF07D 0A7809E3F001                    sta             PIC+1,x
321
 00FFF081 0E7809E3F002                    stb             PIC+2,x
322
 00FFF085 030004                          leax    4,x
323
 00FFF087 08C000100                       cmpx    #256
324
 00FFF08A 025FED                          blo             st1
325
                              ;       lda             #4                              ; make the timer interrupt edge sensitive
326
                              ;       sta             PIC+4                   ; reg #4 is the edge sensitivity setting
327
                              ;       sta             PIC                             ; reg #0 is interrupt enable
328
 
329
                              skip_init:
330
 00FFF08C 01C0EF                          andcc   #$EF                    ; unmask irq
331
 00FFF08E 086038                          lda             #56
332
 00FFF090 0150B7FFFE0DF00                 sta             TEXTREG+TEXT_COLS
333
 00FFF095 08601D                          lda             #29
334
 00FFF097 0150B7FFFE0DF01                 sta             TEXTREG+TEXT_ROWS
335
 00FFF09C 08D132                          bsr             ClearScreen
336
 00FFF09E 08D1A1                          bsr             HomeCursor
337
 00FFF0A0 086005                          lda             #5
338
 00FFF0A2 0150B7FFFE60000                 sta             LEDS
339
 00FFF0A7 0CCFFF0BF                       ldd             #msgStartup
340
 00FFF0AA 08D2A8                          bsr             DisplayString
341
 00FFF0AC 08E000000                       ldx             #0
342
 00FFF0AF 0CC000000                       ldd             #0
343
 00FFF0B2 0170008D1                       lbsr    ShowSprites
344
 00FFF0B5 017000708                       lbsr    KeybdInit
345
 00FFF0B8 0DC124                          ldd             KeybdID
346
 00FFF0BA 08D2D8                          bsr             DispWordAsHex
347
 00FFF0BC 07EFFF991                       jmp             MonitorStart
348
 
349
                              msgStartup
350
 00FFF0BF 072066036038030039020           fcb             "rf6809 12-bit System Starting.",CR,LF,0
351
 00FFF0C6 03103202D062069074020
352
 00FFF0CD 05307907307406506D020
353
 00FFF0D4 05307406107207406906E
354
 00FFF0DB 06702E00D00A000
355
 
356
                              ;------------------------------------------------------------------------------
357
                              ; The checkpoint register must be cleared within 1 second or a NMI interrupt
358
                              ; will occur. checkpoint should be called with a JSR so that the global ROM
359
                              ; routine is called.
360
                              ;
361
                              ; Modifies:
362
                              ;               none
363
                              ;------------------------------------------------------------------------------
364
 
365
                              checkpoint:
366
 00FFF0E0 01507FFFFFFFFE1                 clr             $FFFFFFFE1      ; writing any value will do
367
 00FFF0E5 039                             rts
368
 
369
                              ;------------------------------------------------------------------------------
370
                              ; Copy the system ROM to local RAM
371
                              ; Running the code from local RAM is probably an order of magnitude faster
372
                              ; then running from the global ROM. It also reduces the network traffic to
373
                              ; run from local RAM.
374
                              ;
375
                              ; Modifies:
376
                              ;               d,x,y
377
                              ;------------------------------------------------------------------------------
378
 
379
                              romToRam:
380
 00FFF0E6 08EFFC000                       ldx             #$FFC000
381
 00FFF0E9 18E00C000                       ldy             #$00C000
382
                              romToRam1:
383
 00FFF0EC 0EC801                          ldd             ,x++
384
 00FFF0EE 0EDA01                          std             ,y++
385
 00FFF0F0 08C000000                       cmpx    #0
386
 00FFF0F3 026FF7                          bne             romToRam1
387
 00FFF0F5 039                             rts
388
 
389
                              ;------------------------------------------------------------------------------
390
                              ; Multi-core sieve program.
391
                              ;------------------------------------------------------------------------------
392
 
393
                              ; First fill screen chars with 'P' indicating prime positions
394
                              ; Each core is responsible for the Nth position where N is the
395
                              ; core number minus two.
396
                              ;
397
                              multi_sieve:
398
 00FFF0F6 086050                          lda             #'P'                                    ; indicate prime
399
 00FFF0F8 0150F6FFFFFFFE0                 ldb             COREID                          ; find out which core we are
400
 00FFF0FD 0C0001                          subb    #FIRST_CORE
401
 00FFF0FF 08E000000                       ldx             #0                                              ; start at first char of screen
402
 00FFF102 03A                             abx
403
                              multi_sieve3:
404
 00FFF103 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
405
 00FFF107 030008                          leax    8,x                                             ; advance to next position
406
 00FFF109 08C000FFF                       cmpx    #4095
407
 00FFF10C 025FF5                          blo             multi_sieve3
408
 00FFF10E 0BDFFF0E0                       jsr             checkpoint
409
*** warning 1: Long branch within short branch range could be optimized
410
 00FFF111 0CB002                          addb    #2                                              ; start sieve at 2 (core id)
411
 00FFF113 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
412
                              multi_sieve2:
413
 00FFF115 08E000000                       ldx             #0
414
 00FFF118 03A                             abx                                                                     ; skip the first position - might be prime
415
                              multi_sieve1:
416
 00FFF119 03A                             abx                                                                     ; increment
417
 00FFF11A 0A7809E00000                    sta             TEXTSCR,x
418
 00FFF11E 08C000FFF                       cmpx    #4095
419
 00FFF121 025FF6                          blo             multi_sieve1
420
 00FFF123 0BDFFF0E0                       jsr             checkpoint
421
*** warning 1: Long branch within short branch range could be optimized
422
 00FFF126 0CB008                          addb    #8                                              ; number of cores working on it
423
 00FFF128 0C1FF0                          cmpb    #4080
424
 00FFF12A 025FE9                          blo             multi_sieve2
425
                              multi_sieve4:                                   ; hang machine
426
 00FFF12C 013                             sync
427
 00FFF12D 016000866                       lbra    Monitor
428
 
429
                              sieve:
430
 00FFF130 086050                          lda             #'P'                                    ; indicate prime
431
 00FFF132 08E000000                       ldx             #0                                              ; start at first char of screen
432
                              sieve3:
433
 00FFF135 0A7809E00000                    sta             TEXTSCR,x                       ; store 'P'
434
 00FFF139 030001                          inx                                                                     ; advance to next position
435
 00FFF13B 08C000FFF                       cmpx    #4095
436
 00FFF13E 025FF5                          blo             sieve3
437
 00FFF140 0C6002                          ldb             #2                                              ; start sieve at 2
438
 00FFF142 08604E                          lda             #'N'                                    ; flag position value of 'N' for non-prime
439
                              sieve2:
440
 00FFF144 08E000000                       ldx             #0
441
 00FFF147 03A                             abx                                                                     ; skip the first position - might be prime
442
                              sieve1:
443
 00FFF148 03A                             abx                                                                     ; increment
444
 00FFF149 0A7809E00000                    sta             TEXTSCR,x
445
 00FFF14D 08C000FFF                       cmpx    #4095
446
 00FFF150 025FC7                          blo             multi_sieve1
447
 00FFF152 05C                             incb                                                            ; number of cores working on it
448
 00FFF153 0C1FF0                          cmpb    #4080
449
 00FFF155 025FED                          blo             sieve2
450
                              sieve4:                                                         ; hang machine
451
 00FFF157 013                             sync
452
 00FFF158 016000836                       lbra    MonitorStart
453
 
454
                              ;------------------------------------------------------------------------------
455
                              ; Three second delay for user convenience and to allow some devices time to
456
                              ; reset.
457
                              ;------------------------------------------------------------------------------
458
 
459
                              Delay3s:
460
 00FFF15B 0CC895440                       ldd             #9000000
461
                              dly3s1:
462
 00FFF15E 0C10FF                          cmpb    #$FF
463
 00FFF160 026000                          bne             dly3s2
464
                              dly3s2:
465
 00FFF162 0150B7FFFE60000                 sta             LEDS
466
 00FFF167 083000001                       subd    #1
467
 00FFF16A 026FF2                          bne             dly3s1
468
 00FFF16C 039                             rts
469
 
470
                              ;------------------------------------------------------------------------------
471
                              ;------------------------------------------------------------------------------
472
                              ShiftLeft5:
473
 00FFF16D 058                             aslb
474
 00FFF16E 049                             rola
475
 00FFF16F 058                             aslb
476
 00FFF170 049                             rola
477
 00FFF171 058                             aslb
478
 00FFF172 049                             rola
479
 00FFF173 058                             aslb
480
 00FFF174 049                             rola
481
 00FFF175 058                             aslb
482
 00FFF176 049                             rola
483
 00FFF177 039                             rts
484
 
485
                              ;------------------------------------------------------------------------------
486
                              ;------------------------------------------------------------------------------
487
                              ;
488
                              CopyVirtualScreenToScreen:
489
 00FFF178 034076                          pshs    d,x,y,u
490
 00FFF17A 08D0B4                          bsr             GetScreenLocation
491
 00FFF17C 01F001                          tfr             d,x
492
 00FFF17E 18EE00000                       ldy             #TEXTSCR
493
 00FFF181 0CE00032C                       ldu             #56*29/2
494
                              cv2s1:
495
 00FFF184 0EC801                          ldd             ,x++
496
 00FFF186 0EDA01                          std             ,y++
497
 00FFF188 0335FF                          leau    -1,u
498
 00FFF18A 283000000                       cmpu    #0
499
 00FFF18D 026FF5                          bne             cv2s1
500
                                      ; reset the cursor position in the text controller
501
 00FFF18F 0D6110                          ldb             CursorRow
502
 00FFF191 086038                          lda             #56
503
 00FFF193 03D                             mul
504
 00FFF194 01F001                          tfr             d,x
505
 00FFF196 0D6111                          ldb             CursorCol
506
 00FFF198 03A                             abx
507
 00FFF199 0150BFFFFE0DF22                 stx             TEXTREG+TEXT_CURPOS
508
 00FFF19E 0350F6                          puls    d,x,y,u,pc
509
 
510
                              ;------------------------------------------------------------------------------
511
                              ;------------------------------------------------------------------------------
512
                              ;
513
                              CopyScreenToVirtualScreen:
514
 00FFF1A0 034076                          pshs    d,x,y,u
515
 00FFF1A2 08D08C                          bsr             GetScreenLocation
516
 00FFF1A4 01F002                          tfr             d,y
517
 00FFF1A6 08EE00000                       ldx             #TEXTSCR
518
 00FFF1A9 0CE00032C                       ldu             #56*29/2
519
                              cs2v1:
520
 00FFF1AC 0EC801                          ldd             ,x++
521
 00FFF1AE 0EDA01                          std             ,y++
522
 00FFF1B0 0335FF                          leau    -1,u
523
 00FFF1B2 283000000                       cmpu    #0
524
 00FFF1B5 026FF5                          bne             cs2v1
525
 00FFF1B7 0350F6                          puls    d,x,y,u,pc
526
 
527
                              ;------------------------------------------------------------------------------
528
                              ;------------------------------------------------------------------------------
529
 00FFF1B9 054045058054053043052           fcb             "TEXTSCR "
530
 00FFF1C0 020
531
 00FFF1C1 FFF1CB                          fcw             TextOpen
532
 00FFF1C3 FFF1CC                          fcw             TextClose
533
 00FFF1C5 FFF1CD                          fcw             TextRead
534
 00FFF1C7 FFF1CE                          fcw             TextWrite
535
 00FFF1C9 FFF1CF                          fcw             TextSeek
536
 
537
                              TextOpen:
538
 00FFF1CB 039                             rts
539
                              TextClose:
540
 00FFF1CC 039                             rts
541
                              TextRead:
542
 00FFF1CD 039                             rts
543
                              TextWrite:
544
 00FFF1CE 039                             rts
545
                              TextSeek:
546
 00FFF1CF 039                             rts
547
 
548
                              ;------------------------------------------------------------------------------
549
                              ; Clear the screen and the screen color memory
550
                              ; We clear the screen to give a visual indication that the system
551
                              ; is working at all.
552
                              ;
553
                              ; Modifies:
554
                              ;               none
555
                              ;------------------------------------------------------------------------------
556
 
557
                              ClearScreen:
558
 00FFF1D0 034076                          pshs    d,x,y,u
559
 00FFF1D2 08E000658                       ldx             #56*29
560
 00FFF1D5 01F013                          tfr             x,u
561
 00FFF1D7 08D057                          bsr             GetScreenLocation
562
 00FFF1D9 01F002                          tfr             d,y
563
 00FFF1DB 0C6020                          ldb             #' '                            ; space char
564
                              cs1:
565
 00FFF1DD 0E7A00                          stb             ,y+                                     ; set text to space
566
 00FFF1DF 0301FF                          leax    -1,x                            ; decrement x
567
 00FFF1E1 026FFA                          bne             cs1
568
 00FFF1E3 0150F6FFFFFFFE0                 ldb             COREID                  ; update colors only if we have focus
569
 00FFF1E8 0D1100                          cmpb    IOFocusID
570
 00FFF1EA 02000D                          bra             cs3
571
 00FFF1EC 18EE02000                       ldy             #TEXTSCR+$2000
572
                              ;       lda             CharColor
573
 00FFF1EF 0860CE                          lda             #$0CE
574
 00FFF1F1 01F031                          tfr             u,x                                     ; get back count
575
                              cs2:
576
 00FFF1F3 0A7A00                          sta             ,y+
577
 00FFF1F5 0301FF                          leax    -1,x                            ; decrement x
578
 00FFF1F7 026FFA                          bne             cs2
579
                              cs3:
580
 00FFF1F9 0350F6                          puls    d,x,y,u,pc
581
 
582
                              ;------------------------------------------------------------------------------
583
                              ; Scroll text on the screen upwards
584
                              ;
585
                              ; Modifies:
586
                              ;               none
587
                              ;------------------------------------------------------------------------------
588
 
589
                              ScrollUp:
590
 00FFF1FB 034076                          pshs    d,x,y,u
591
 00FFF1FD 18E00032B                       ldy             #(56*29-1)/2    ; y = num chars/2 to move
592
 00FFF200 08D02E                          bsr             GetScreenLocation
593
 00FFF202 01F001                          tfr             d,x
594
 00FFF204 01F003                          tfr             d,u
595
 00FFF206 030038                          leax    56,x                    ; x = index to source row
596
                              scrup1:
597
 00FFF208 0EC801                          ldd             ,x++                    ; move 2 characters
598
 00FFF20A 0EDC01                          std             ,u++
599
 00FFF20C 0313FF                          leay    -1,y
600
 00FFF20E 026FF8                          bne             scrup1
601
 00FFF210 08601E                          lda             #30
602
 00FFF212 08D002                          bsr             BlankLine
603
 00FFF214 0350F6                          puls    d,x,y,u,pc
604
 
605
                              ;------------------------------------------------------------------------------
606
                              ; Blank out a line on the display
607
                              ;
608
                              ; Modifies:
609
                              ;               none
610
                              ; Parameters:
611
                              ;       acca = line number to blank
612
                              ;------------------------------------------------------------------------------
613
 
614
                              BlankLine:
615
 00FFF216 034016                          pshs    d,x
616
 00FFF218 034002                          pshs    a
617
 00FFF21A 08D014                          bsr             GetScreenLocation
618
 00FFF21C 01F001                          tfr             d,x
619
 00FFF21E 035002                          puls    a
620
 00FFF220 0C6038                          ldb             #56             ; b = # chars to blank out from video controller
621
 00FFF222 03D                             mul                                     ; d = screen index (row# * #cols)
622
 00FFF223 03080B                          leax    d,x
623
 00FFF225 086020                          lda             #' '
624
 00FFF227 0C6038                          ldb             #56             ; b = # chars to blank out from video controller
625
                              blnkln1:
626
 00FFF229 0A7800                          sta             ,x+
627
 00FFF22B 05A                             decb
628
 00FFF22C 026FFB                          bne             blnkln1
629
 00FFF22E 035096                          puls    d,x,pc
630
 
631
                              ;------------------------------------------------------------------------------
632
                              ; Get the location of the screen memory. The location
633
                              ; depends on whether or not the task has the output focus.
634
                              ;
635
                              ; Modifies:
636
                              ;               d
637
                              ; Retuns:
638
                              ;               d = screen location
639
                              ;------------------------------------------------------------------------------
640
 
641
                              GetScreenLocation:
642
 00FFF230 0150B6FFFFFFFE0                 lda             COREID                  ; which core are we?
643
 00FFF235 091100                          cmpa    IOFocusID               ; do we have the IO focus
644
 00FFF237 026004                          bne             gsl1                            ; no, go pick virtual screen address
645
 00FFF239 0CCE00000                       ldd             #TEXTSCR                ; yes, we update the real screen
646
 00FFF23C 039                             rts
647
                              gsl1:
648
 00FFF23D 0CC007800                       ldd             #$7800
649
 00FFF240 039                             rts
650
 
651
                              ;------------------------------------------------------------------------------
652
                              ; HomeCursor
653
                              ; Set the cursor location to the top left of the screen.
654
                              ;
655
                              ; Modifies:
656
                              ;               none
657
                              ;------------------------------------------------------------------------------
658
 
659
                              HomeCursor:
660
 00FFF241 034016                          pshs    d,x
661
 00FFF243 00F110                          clr             CursorRow
662
 00FFF245 00F111                          clr             CursorCol
663
 00FFF247 0150F6FFFFFFFE0                 ldb             COREID
664
 00FFF24C 0D1100                          cmpb    IOFocusID
665
 00FFF24E 026006                          bne             hc1
666
 00FFF250 04F                             clra
667
 00FFF251 0150B7FFFE0DF22                 sta             TEXTREG+TEXT_CURPOS
668
                              hc1:
669
 00FFF256 035096                          puls    d,x,pc
670
 
671
                              ;------------------------------------------------------------------------------
672
                              ; Update the cursor position in the text controller based on the
673
                              ;  CursorRow,CursorCol.
674
                              ;
675
                              ; Modifies:
676
                              ;               none
677
                              ;------------------------------------------------------------------------------
678
                              ;
679
                              UpdateCursorPos:
680
 00FFF258 034016                          pshs    d,x
681
 00FFF25A 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
682
 00FFF25F 0D1100                          cmpb    IOFocusID                       ; only for the task with the output focus
683
 00FFF261 026014                          bne             ucp1
684
 00FFF263 096110                          lda             CursorRow
685
 00FFF265 08403F                          anda    #$3F                                    ; limit of 63 rows
686
 00FFF267 0150F6FFFE0DF00                 ldb             TEXTREG+TEXT_COLS
687
 00FFF26C 03D                             mul
688
 00FFF26D 01F001                          tfr             d,x
689
 00FFF26F 0D6111                          ldb             CursorCol
690
 00FFF271 03A                             abx
691
 00FFF272 0150BFFFFE0DF22                 stx             TEXTREG+TEXT_CURPOS
692
                              ucp1:
693
 00FFF277 035096                          puls    d,x,pc
694
 
695
                              ;------------------------------------------------------------------------------
696
                              ; Calculate screen memory location from CursorRow,CursorCol.
697
                              ; Also refreshes the cursor location.
698
                              ;
699
                              ; Modifies:
700
                              ;               d
701
                              ; Returns:
702
                              ;       d = screen location
703
                              ;------------------------------------------------------------------------------
704
                              ;
705
                              CalcScreenLoc:
706
 00FFF279 034010                          pshs    x
707
 00FFF27B 096110                          lda             CursorRow
708
 00FFF27D 0C6038                          ldb             #56
709
 00FFF27F 03D                             mul
710
 00FFF280 01F001                          tfr             d,x
711
 00FFF282 0D6111                          ldb             CursorCol
712
 00FFF284 03A                             abx
713
 00FFF285 0150F6FFFFFFFE0                 ldb             COREID                          ; update cursor position in text controller
714
 00FFF28A 0D1100                          cmpb    IOFocusID                       ; only for the task with the output focus
715
 00FFF28C 026005                          bne             csl1
716
 00FFF28E 0150BFFFFE0DF22                 stx             TEXTREG+TEXT_CURPOS
717
                              csl1:
718
 00FFF293 08DF9B                          bsr             GetScreenLocation
719
 00FFF295 03080B                          leax    d,x
720
 00FFF297 01F010                          tfr             x,d
721
 00FFF299 035090                          puls    x,pc
722
 
723
                              ;------------------------------------------------------------------------------
724
                              ; Display a character on the screen.
725
                              ; If the task doesn't have the I/O focus then the character is written to
726
                              ; the virtual screen.
727
                              ;
728
                              ; Modifies:
729
                              ;               none
730
                              ; Parameters:
731
                              ;       accb = char to display
732
                              ;------------------------------------------------------------------------------
733
                              ;
734
                              DisplayChar:
735
 00FFF29B 034016                          pshs    d,x
736
 00FFF29D 0C100D                          cmpb    #CR                                     ; carriage return ?
737
 00FFF29F 026006                          bne             dccr
738
 00FFF2A1 00F111                          clr             CursorCol               ; just set cursor column to zero on a CR
739
 00FFF2A3 08DFB3                          bsr             UpdateCursorPos
740
                              dcx14:
741
 00FFF2A5 035096                          puls    d,x,pc
742
                              dccr:
743
 00FFF2A7 0C1091                          cmpb    #$91                            ; cursor right ?
744
 00FFF2A9 02600D                          bne             dcx6
745
 00FFF2AB 096111                          lda             CursorCol
746
 00FFF2AD 081038                          cmpa    #56
747
 00FFF2AF 024003                          bhs             dcx7
748
 00FFF2B1 04C                             inca
749
 00FFF2B2 097111                          sta             CursorCol
750
                              dcx7:
751
 00FFF2B4 08DFA2                          bsr             UpdateCursorPos
752
 00FFF2B6 035096                          puls    d,x,pc
753
                              dcx6:
754
 00FFF2B8 0C1090                          cmpb    #$90                            ; cursor up ?
755
 00FFF2BA 026009                          bne             dcx8
756
 00FFF2BC 096110                          lda             CursorRow
757
 00FFF2BE 027FF4                          beq             dcx7
758
 00FFF2C0 04A                             deca
759
 00FFF2C1 097110                          sta             CursorRow
760
 00FFF2C3 020FEF                          bra             dcx7
761
                              dcx8:
762
 00FFF2C5 0C1093                          cmpb    #$93                            ; cursor left ?
763
 00FFF2C7 026009                          bne             dcx9
764
 00FFF2C9 096111                          lda             CursorCol
765
 00FFF2CB 027FE7                          beq             dcx7
766
 00FFF2CD 04A                             deca
767
 00FFF2CE 097111                          sta             CursorCol
768
 00FFF2D0 020FE2                          bra             dcx7
769
                              dcx9:
770
 00FFF2D2 0C1092                          cmpb    #$92                            ; cursor down ?
771
 00FFF2D4 02600B                          bne             dcx10
772
 00FFF2D6 096110                          lda             CursorRow
773
 00FFF2D8 08101D                          cmpa    #29
774
 00FFF2DA 027FD8                          beq             dcx7
775
 00FFF2DC 04C                             inca
776
 00FFF2DD 097110                          sta             CursorRow
777
 00FFF2DF 020FD3                          bra             dcx7
778
                              dcx10:
779
 00FFF2E1 0C1094                          cmpb    #$94                            ; cursor home ?
780
 00FFF2E3 02600C                          bne             dcx11
781
 00FFF2E5 096111                          lda             CursorCol
782
 00FFF2E7 027004                          beq             dcx12
783
 00FFF2E9 00F111                          clr             CursorCol
784
 00FFF2EB 020FC7                          bra             dcx7
785
                              dcx12:
786
 00FFF2ED 00F110                          clr             CursorRow
787
 00FFF2EF 020FC3                          bra             dcx7
788
                              dcx11:
789
 00FFF2F1 0C1099                          cmpb    #$99                            ; delete ?
790
 00FFF2F3 026008                          bne             dcx13
791
 00FFF2F5 08DF82                          bsr             CalcScreenLoc
792
 00FFF2F7 01F001                          tfr             d,x
793
 00FFF2F9 096111                          lda             CursorCol               ; acc = cursor column
794
 00FFF2FB 02000D                          bra             dcx5
795
                              dcx13
796
 00FFF2FD 0C1008                          cmpb    #CTRLH                  ; backspace ?
797
 00FFF2FF 02601A                          bne             dcx3
798
 00FFF301 096111                          lda             CursorCol
799
 00FFF303 02702A                          beq             dcx4
800
 00FFF305 04A                             deca
801
 00FFF306 097111                          sta             CursorCol
802
 00FFF308 08DF6F                          bsr             CalcScreenLoc
803
                              dcx5:
804
 00FFF30A 0E6001                          ldb             1,x
805
 00FFF30C 0E7801                          stb             ,x++
806
 00FFF30E 04C                             inca
807
 00FFF30F 081038                          cmpa    #56
808
 00FFF311 025FF7                          blo             dcx5
809
 00FFF313 0C6020                          ldb             #' '
810
 00FFF315 0301FF                          leax    -1,x
811
 00FFF317 0E7804                          stb             ,x
812
 00FFF319 03509E                          puls    d,x,dp,pc
813
                              dcx3:
814
 00FFF31B 0C100A                          cmpb    #LF                             ; linefeed ?
815
 00FFF31D 02700E                          beq             dclf
816
 00FFF31F 034004                          pshs    b
817
 00FFF321 08DF56                          bsr     CalcScreenLoc
818
 00FFF323 01F001                          tfr             d,x
819
 00FFF325 035004                          puls    b
820
 00FFF327 0E7804                          stb             ,x
821
                                      ; ToDo character color
822
                              ;       lda             CharColor
823
                              ;       sta             $2000,x
824
 00FFF329 08D006                          bsr             IncCursorPos
825
 00FFF32B 035096                          puls    d,x,pc
826
                              dclf:
827
 00FFF32D 08D011                          bsr             IncCursorRow
828
                              dcx4:
829
 00FFF32F 035096                          puls    d,x,pc
830
 
831
                              ;------------------------------------------------------------------------------
832
                              ; Increment the cursor position, scroll the screen if needed.
833
                              ;
834
                              ; Modifies:
835
                              ;               none
836
                              ;------------------------------------------------------------------------------
837
 
838
                              IncCursorPos:
839
 00FFF331 034016                          pshs    d,x
840
 00FFF333 096111                          lda             CursorCol
841
 00FFF335 04C                             inca
842
 00FFF336 097111                          sta             CursorCol
843
 00FFF338 081038                          cmpa    #56
844
 00FFF33A 025014                          blo             icc1
845
 00FFF33C 00F111                          clr             CursorCol               ; column = 0
846
 00FFF33E 020002                          bra             icr1
847
                              IncCursorRow:
848
 00FFF340 034016                          pshs    d,x
849
                              icr1:
850
 00FFF342 096110                          lda             CursorRow
851
 00FFF344 04C                             inca
852
 00FFF345 097110                          sta             CursorRow
853
 00FFF347 08101D                          cmpa    #29
854
 00FFF349 025005                          blo             icc1
855
 00FFF34B 04A                             deca                                                    ; backup the cursor row, we are scrolling up
856
 00FFF34C 097110                          sta             CursorRow
857
 00FFF34E 08DEAB                          bsr             ScrollUp
858
                              icc1:
859
 00FFF350 08DF06                          bsr             UpdateCursorPos
860
                              icc2:
861
 00FFF352 035096                          puls    d,x,pc
862
 
863
                              ;------------------------------------------------------------------------------
864
                              ; Display a string on the screen.
865
                              ;
866
                              ; Modifies:
867
                              ;               none
868
                              ; Parameters:
869
                              ;               d = pointer to string
870
                              ;------------------------------------------------------------------------------
871
                              ;
872
                              DisplayString:
873
 00FFF354 034016                          pshs    d,x
874
 00FFF356 01F001                          tfr             d,x
875
                              dspj1B:
876
 00FFF358 0E6800                          ldb             ,x+                             ; move string char into acc
877
 00FFF35A 027004                          beq             dsretB          ; is it end of string ?
878
 00FFF35C 08D61E                          bsr             OUTCH                   ; display character
879
 00FFF35E 020FF8                          bra             dspj1B
880
                              dsretB:
881
 00FFF360 035096                          puls    d,x,pc
882
 
883
                              DisplayStringCRLF:
884
 00FFF362 034006                          pshs    d
885
 00FFF364 08DFEE                          bsr             DisplayString
886
 00FFF366 0C600D                          ldb             #CR
887
 00FFF368 08D612                          bsr             OUTCH
888
 00FFF36A 0C600A                          ldb             #LF
889
 00FFF36C 08D60E                          bsr             OUTCH
890
 00FFF36E 035086                          puls    d,pc
891
 
892
                              ;
893
                              ; PRINT CR, LF, STRING
894
                              ;
895
                              PSTRNG
896
 00FFF370 08D002                          BSR             PCRLF
897
 00FFF372 02000D                          BRA             PDATA
898
                              PCRLF
899
 00FFF374 034010                          PSHS    X
900
 00FFF376 08EFFF388                       LDX             #CRLFST
901
 00FFF379 08D006                          BSR             PDATA
902
 00FFF37B 035010                          PULS    X
903
 00FFF37D 039                             RTS
904
 
905
                              PRINT
906
 00FFF37E 0BDFFF97C                       JSR             OUTCH
907
                              PDATA
908
 00FFF381 0E6800                          LDB             ,X+
909
 00FFF383 0C1004                          CMPB    #$04
910
 00FFF385 026FF7                          BNE             PRINT
911
 00FFF387 039                             RTS
912
 
913
                              CRLFST
914
 00FFF388 00D00A004                       fcb     CR,LF,4
915
 
916
                              DispDWordAsHex:
917
 00FFF38B 08D007                          bsr             DispWordAsHex
918
 00FFF38D 01E001                          exg             d,x
919
 00FFF38F 08D003                          bsr             DispWordAsHex
920
 00FFF391 01E001                          exg             d,x
921
 00FFF393 039                             rts
922
 
923
                              DispWordAsHex:
924
 00FFF394 01E089                          exg             a,b
925
 00FFF396 08D005                          bsr             DispByteAsHex
926
 00FFF398 01E089                          exg             a,b
927
 00FFF39A 08D001                          bsr             DispByteAsHex
928
 00FFF39C 039                             rts
929
 
930
                              DispByteAsHex:
931
 00FFF39D 034004                    pshs  b
932
 00FFF39F 054                             lsrb
933
 00FFF3A0 054                             lsrb
934
 00FFF3A1 054                             lsrb
935
 00FFF3A2 054                             lsrb
936
 00FFF3A3 054                             lsrb
937
 00FFF3A4 054                             lsrb
938
 00FFF3A5 054                             lsrb
939
 00FFF3A6 054                             lsrb
940
 00FFF3A7 08D00C                          bsr             DispNyb
941
 00FFF3A9 035004                          puls    b
942
 00FFF3AB 034004                          pshs    b
943
 00FFF3AD 054                             lsrb
944
 00FFF3AE 054                             lsrb
945
 00FFF3AF 054                             lsrb
946
 00FFF3B0 054                             lsrb
947
 00FFF3B1 08D002                          bsr             DispNyb
948
 00FFF3B3 035004                          puls    b
949
 
950
                              DispNyb
951
 00FFF3B5 034004                          pshs    b
952
 00FFF3B7 0C400F                          andb    #$0F
953
 00FFF3B9 0C100A                          cmpb    #10
954
 00FFF3BB 025006                          blo             DispNyb1
955
 00FFF3BD 0CB037                          addb    #'A'-10
956
 00FFF3BF 08D5BB                          bsr             OUTCH
957
 00FFF3C1 035084                          puls    b,pc
958
                              DispNyb1
959
 00FFF3C3 0CB030                          addb    #'0'
960
 00FFF3C5 08D5B5                          bsr             OUTCH
961
 00FFF3C7 035084                          puls    b,pc
962
 
963
                              ;==============================================================================
964
                              ; Keyboard I/O
965
                              ;==============================================================================
966
 
967
                                      ;--------------------------------------------------------------------------
968
                                      ; PS2 scan codes to ascii conversion tables.
969
                                      ;--------------------------------------------------------------------------
970
                                      ;
971
                                      org     (* + 127) & $FFFFFF80
972
 
973
                              unshiftedScanCodes:
974
 00FFF400 02E0A902E0A50A30A10A2           fcb     $2e,$a9,$2e,$a5,$a3,$a1,$a2,$ac
975
 00FFF407 0AC
976
 00FFF408 02E0AA0A80A60A4009060           fcb     $2e,$aa,$a8,$a6,$a4,$09,$60,$2e
977
 00FFF40F 02E
978
 00FFF410 02E02E02E02E02E071031           fcb     $2e,$2e,$2e,$2e,$2e,$71,$31,$2e
979
 00FFF417 02E
980
 00FFF418 02E02E07A073061077032           fcb     $2e,$2e,$7a,$73,$61,$77,$32,$2e
981
 00FFF41F 02E
982
 00FFF420 02E063078064065034033           fcb     $2e,$63,$78,$64,$65,$34,$33,$2e
983
 00FFF427 02E
984
 00FFF428 02E020076066074072035           fcb     $2e,$20,$76,$66,$74,$72,$35,$2e
985
 00FFF42F 02E
986
 00FFF430 02E06E062068067079036           fcb     $2e,$6e,$62,$68,$67,$79,$36,$2e
987
 00FFF437 02E
988
 00FFF438 02E02E06D06A075037038           fcb     $2e,$2e,$6d,$6a,$75,$37,$38,$2e
989
 00FFF43F 02E
990
 00FFF440 02E02C06B06906F030039           fcb     $2e,$2c,$6b,$69,$6f,$30,$39,$2e
991
 00FFF447 02E
992
 00FFF448 02E02E02F06C03B07002D           fcb     $2e,$2e,$2f,$6c,$3b,$70,$2d,$2e
993
 00FFF44F 02E
994
 00FFF450 02E02E02702E05B03D02E           fcb     $2e,$2e,$27,$2e,$5b,$3d,$2e,$2e
995
 00FFF457 02E
996
 00FFF458 0AD02E00D05D02E05C02E           fcb     $ad,$2e,$0d,$5d,$2e,$5c,$2e,$2e
997
 00FFF45F 02E
998
 00FFF460 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
999
 00FFF467 02E
1000
 00FFF468 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1001
 00FFF46F 02E
1002
 00FFF470 09807F09202E09109001B           fcb     $98,$7f,$92,$2e,$91,$90,$1b,$af
1003
 00FFF477 0AF
1004
 00FFF478 0AB02E09702E02E0960AE           fcb     $ab,$2e,$97,$2e,$2e,$96,$ae,$2e
1005
 00FFF47F 02E
1006
 
1007
 00FFF480 02E02E02E0A702E02E02E           fcb     $2e,$2e,$2e,$a7,$2e,$2e,$2e,$2e
1008
 00FFF487 02E
1009
 00FFF488 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1010
 00FFF48F 02E
1011
 00FFF490 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1012
 00FFF497 02E
1013
 00FFF498 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1014
 00FFF49F 02E
1015
 00FFF4A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1016
 00FFF4A7 02E
1017
 00FFF4A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1018
 00FFF4AF 02E
1019
 00FFF4B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1020
 00FFF4B7 02E
1021
 00FFF4B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1022
 00FFF4BF 02E
1023
 00FFF4C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1024
 00FFF4C7 02E
1025
 00FFF4C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1026
 00FFF4CF 02E
1027
 00FFF4D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1028
 00FFF4D7 02E
1029
 00FFF4D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1030
 00FFF4DF 02E
1031
 00FFF4E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1032
 00FFF4E7 02E
1033
 00FFF4E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1034
 00FFF4EF 02E
1035
 00FFF4F0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1036
 00FFF4F7 02E
1037
 00FFF4F8 02E02E0FA02E02E02E02E           fcb     $2e,$2e,$fa,$2e,$2e,$2e,$2e,$2e
1038
 00FFF4FF 02E
1039
 
1040
                              shiftedScanCodes:
1041
 00FFF500 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1042
 00FFF507 02E
1043
 00FFF508 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1044
 00FFF50F 02E
1045
 00FFF510 02E02E02E02E02E051021           fcb     $2e,$2e,$2e,$2e,$2e,$51,$21,$2e
1046
 00FFF517 02E
1047
 00FFF518 02E02E05A053041057040           fcb     $2e,$2e,$5a,$53,$41,$57,$40,$2e
1048
 00FFF51F 02E
1049
 00FFF520 02E043058044045024023           fcb     $2e,$43,$58,$44,$45,$24,$23,$2e
1050
 00FFF527 02E
1051
 00FFF528 02E020056046054052025           fcb     $2e,$20,$56,$46,$54,$52,$25,$2e
1052
 00FFF52F 02E
1053
 00FFF530 02E04E04204804705905E           fcb     $2e,$4e,$42,$48,$47,$59,$5e,$2e
1054
 00FFF537 02E
1055
 00FFF538 02E02E04D04A05502602A           fcb     $2e,$2e,$4d,$4a,$55,$26,$2a,$2e
1056
 00FFF53F 02E
1057
 00FFF540 02E03C04B04904F029028           fcb     $2e,$3c,$4b,$49,$4f,$29,$28,$2e
1058
 00FFF547 02E
1059
 00FFF548 02E03E03F04C03A05005F           fcb     $2e,$3e,$3f,$4c,$3a,$50,$5f,$2e
1060
 00FFF54F 02E
1061
 00FFF550 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1062
 00FFF557 02E
1063
 00FFF558 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1064
 00FFF55F 02E
1065
 00FFF560 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1066
 00FFF567 02E
1067
 00FFF568 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1068
 00FFF56F 02E
1069
 00FFF570 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1070
 00FFF577 02E
1071
 00FFF578 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1072
 00FFF57F 02E
1073
 
1074
 00FFF580 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1075
 00FFF587 02E
1076
 00FFF588 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1077
 00FFF58F 02E
1078
 00FFF590 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1079
 00FFF597 02E
1080
 00FFF598 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1081
 00FFF59F 02E
1082
 00FFF5A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1083
 00FFF5A7 02E
1084
 00FFF5A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1085
 00FFF5AF 02E
1086
 00FFF5B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1087
 00FFF5B7 02E
1088
 00FFF5B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1089
 00FFF5BF 02E
1090
 00FFF5C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1091
 00FFF5C7 02E
1092
 00FFF5C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1093
 00FFF5CF 02E
1094
 00FFF5D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1095
 00FFF5D7 02E
1096
 00FFF5D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1097
 00FFF5DF 02E
1098
 00FFF5E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1099
 00FFF5E7 02E
1100
 00FFF5E8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1101
 00FFF5EF 02E
1102
 00FFF5F0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1103
 00FFF5F7 02E
1104
 00FFF5F8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1105
 00FFF5FF 02E
1106
 
1107
                              ; control
1108
                              keybdControlCodes:
1109
 00FFF600 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1110
 00FFF607 02E
1111
 00FFF608 02E02E02E02E02E00907E           fcb     $2e,$2e,$2e,$2e,$2e,$09,$7e,$2e
1112
 00FFF60F 02E
1113
 00FFF610 02E02E02E02E02E011021           fcb     $2e,$2e,$2e,$2e,$2e,$11,$21,$2e
1114
 00FFF617 02E
1115
 00FFF618 02E02E01A013001017040           fcb     $2e,$2e,$1a,$13,$01,$17,$40,$2e
1116
 00FFF61F 02E
1117
 00FFF620 02E003018004005024023           fcb     $2e,$03,$18,$04,$05,$24,$23,$2e
1118
 00FFF627 02E
1119
 00FFF628 02E020016006014012025           fcb     $2e,$20,$16,$06,$14,$12,$25,$2e
1120
 00FFF62F 02E
1121
 00FFF630 02E00E00200800701905E           fcb     $2e,$0e,$02,$08,$07,$19,$5e,$2e
1122
 00FFF637 02E
1123
 00FFF638 02E02E00D00A01502602A           fcb     $2e,$2e,$0d,$0a,$15,$26,$2a,$2e
1124
 00FFF63F 02E
1125
 00FFF640 02E03C00B00900F029028           fcb     $2e,$3c,$0b,$09,$0f,$29,$28,$2e
1126
 00FFF647 02E
1127
 00FFF648 02E03E03F00C03A01005F           fcb     $2e,$3e,$3f,$0c,$3a,$10,$5f,$2e
1128
 00FFF64F 02E
1129
 00FFF650 02E02E02202E07B02B02E           fcb     $2e,$2e,$22,$2e,$7b,$2b,$2e,$2e
1130
 00FFF657 02E
1131
 00FFF658 02E02E00D07D02E07C02E           fcb     $2e,$2e,$0d,$7d,$2e,$7c,$2e,$2e
1132
 00FFF65F 02E
1133
 00FFF660 02E02E02E02E02E02E008           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$08,$2e
1134
 00FFF667 02E
1135
 00FFF668 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1136
 00FFF66F 02E
1137
 00FFF670 02E07F02E02E02E02E01B           fcb     $2e,$7f,$2e,$2e,$2e,$2e,$1b,$2e
1138
 00FFF677 02E
1139
 00FFF678 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1140
 00FFF67F 02E
1141
 
1142
                              keybdExtendedCodes:
1143
 00FFF680 02E02E02E02E0A30A10A2           fcb     $2e,$2e,$2e,$2e,$a3,$a1,$a2,$2e
1144
 00FFF687 02E
1145
 00FFF688 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1146
 00FFF68F 02E
1147
 00FFF690 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1148
 00FFF697 02E
1149
 00FFF698 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1150
 00FFF69F 02E
1151
 00FFF6A0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1152
 00FFF6A7 02E
1153
 00FFF6A8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1154
 00FFF6AF 02E
1155
 00FFF6B0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1156
 00FFF6B7 02E
1157
 00FFF6B8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1158
 00FFF6BF 02E
1159
 00FFF6C0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1160
 00FFF6C7 02E
1161
 00FFF6C8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1162
 00FFF6CF 02E
1163
 00FFF6D0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1164
 00FFF6D7 02E
1165
 00FFF6D8 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1166
 00FFF6DF 02E
1167
 00FFF6E0 02E02E02E02E02E02E02E           fcb     $2e,$2e,$2e,$2e,$2e,$2e,$2e,$2e
1168
 00FFF6E7 02E
1169
 00FFF6E8 02E09502E09309402E02E           fcb     $2e,$95,$2e,$93,$94,$2e,$2e,$2e
1170
 00FFF6EF 02E
1171
 00FFF6F0 09809909202E09109002E           fcb     $98,$99,$92,$2e,$91,$90,$2e,$2e
1172
 00FFF6F7 02E
1173
 00FFF6F8 02E02E09702E02E09602E           fcb     $2e,$2e,$97,$2e,$2e,$96,$2e,$2e
1174
 00FFF6FF 02E
1175
 
1176
                              ; ============================================================================
1177
                              ;        __
1178
                              ;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
1179
                              ;    \  __ /    All rights reserved.
1180
                              ;     \/_//     robfinch@opencores.org
1181
                              ;       ||
1182
                              ;
1183
                              ;
1184
                              ;       Keyboard driver routines to interface to a PS2 style keyboard
1185
                              ; Converts the scancode to ascii
1186
                              ;
1187
                              ; This source file is free software: you can redistribute it and/or modify
1188
                              ; it under the terms of the GNU Lesser General Public License as published
1189
                              ; by the Free Software Foundation, either version 3 of the License, or
1190
                              ; (at your option) any later version.
1191
                              ;
1192
                              ; This source file is distributed in the hope that it will be useful,
1193
                              ; but WITHOUT ANY WARRANTY; without even the implied warranty of
1194
                              ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1195
                              ; GNU General Public License for more details.
1196
                              ;
1197
                              ; You should have received a copy of the GNU General Public License
1198
                              ; along with this program.  If not, see .
1199
                              ;
1200
                              ; ============================================================================
1201
                              ;
1202
                              SC_F12  EQU     $07
1203
                              SC_C    EQU             $21
1204
                              SC_T    EQU         $2C
1205
                              SC_Z            EQU     $1A
1206
                              SC_DEL  EQU                     $71     ; extend
1207
                              SC_KEYUP        EQU             $F0     ; should be $f0
1208
                              SC_EXTEND EQU     $E0
1209
                              SC_CTRL EQU                     $14
1210
                              SC_RSHIFT               EQU     $59
1211
                              SC_NUMLOCK      EQU     $77
1212
                              SC_SCROLLLOCK           EQU     $7E
1213
                              SC_CAPSLOCK             EQU             $58
1214
                              SC_ALT  EQU                     $11
1215
 
1216
                              ;#define SC_LSHIFT      EQU             $12
1217
                              ;SC_DEL         EQU             $71             ; extend
1218
                              ;SC_LCTRL       EQU             $58
1219
 
1220
                              SC_TAB  EQU     $0D
1221
 
1222
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1223
                              ; Recieve a byte from the keyboard, used after a command is sent to the
1224
                              ; keyboard in order to wait for a response.
1225
                              ;
1226
                              ; Parameters: none
1227
                              ; Returns: accd = recieved byte ($00 to $FF), -1 on timeout
1228
                              ; Modifies: acc
1229
                              ; Stack Space: 2 words
1230
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1231
 
1232
                              KeybdRecvByte:
1233
 00FFF700 034010                          pshs    x
1234
 00FFF702 08E000064                       ldx             #100                                            ; wait up to 1s
1235
                              krb3:
1236
 00FFF705 08D05A                          bsr             KeybdGetStatus  ; wait for response from keyboard
1237
 00FFF707 05D                             tstb
1238
 00FFF708 02B00B                          bmi             krb4                                            ; is input buffer full ? yes, branch
1239
 00FFF70A 08D02D                          bsr             Wait10ms                                ; wait a bit
1240
 00FFF70C 0301FF                          leax    -1,x
1241
 00FFF70E 026FF5                          bne             krb3                                            ; go back and try again
1242
 00FFF710 0CCFFFFFF                       ldd             #-1                                                     ; return -1
1243
 00FFF713 035090                          puls    x,pc
1244
                              krb4:
1245
 00FFF715 08D066                          bsr             KeybdGetScancode
1246
 00FFF717 035090                          puls    x,pc
1247
 
1248
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1249
                              ; Send a byte to the keyboard.
1250
                              ;
1251
                              ; Parameters: accb byte to send
1252
                              ; Returns: none
1253
                              ; Modifies: none
1254
                              ; Stack Space: 0 words
1255
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1256
 
1257
                              KeybdSendByte:
1258
 00FFF719 0150F7FFFE30400                 stb             KEYBD
1259
 00FFF71E 039                             rts
1260
 
1261
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1262
                              ; Wait until the keyboard transmit is complete
1263
                              ;
1264
                              ; Parameters: none
1265
                              ; Returns: r1 = 0 if successful, r1 = -1 timeout
1266
                              ; Modifies: r1
1267
                              ; Stack Space: 3 words
1268
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1269
 
1270
                              KeybdWaitTx:
1271
 00FFF71F 034010                          pshs    x
1272
 00FFF721 08E000064                       ldx             #100                            ; wait a max of 1s
1273
                              kwt1:
1274
 00FFF724 08D03B                          bsr             KeybdGetStatus
1275
 00FFF726 0C4040                          andb    #$40                            ; check for transmit complete bit; branch if bit set
1276
 00FFF728 02600B                          bne             kwt2
1277
 00FFF72A 08D00D                          bsr             Wait10ms                ; delay a little bit
1278
 00FFF72C 0301FF                          leax    -1,x
1279
 00FFF72E 026FF4                          bne             kwt1                            ; go back and try again
1280
 00FFF730 0CCFFFFFF                       ldd             #-1                                     ; timed out, return -1
1281
 00FFF733 035090                          puls    x,pc
1282
                              kwt2:
1283
 00FFF735 04F                             clra                                                    ; wait complete, return 0
1284
 00FFF736 05F                             clrb
1285
 00FFF737 035090                          puls    x,pc
1286
 
1287
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1288
                              ; Wait for 10 ms
1289
                              ;
1290
                              ; Parameters: none
1291
                              ; Returns: none
1292
                              ; Modifies: none
1293
                              ; Stack Space: 2 words
1294
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1295
 
1296
                              Wait10ms:
1297
 00FFF739 034006                          pshs    d
1298
 00FFF73B 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1299
                              W10_0001:
1300
 00FFF740 01F089                          tfr             a,b
1301
 00FFF742 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1302
 00FFF747 0C1FFA                          cmpb    #$FFA
1303
 00FFF749 022FF5                          bhi             W10_0001
1304
 00FFF74B 035086                          puls    d,pc
1305
 
1306
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1307
                              ; Wait for 300 ms (256 ms)
1308
                              ;
1309
                              ; Parameters: none
1310
                              ; Returns: none
1311
                              ; Modifies: none
1312
                              ; Stack Space: 2 words
1313
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1314
 
1315
                              Wait300ms:
1316
 00FFF74D 034006                          pshs    d
1317
 00FFF74F 0150B6FFFFFFFE7                 lda             MSCOUNT+3
1318
                              W300_0001:
1319
 00FFF754 01F089                          tfr             a,b
1320
 00FFF756 0150F0FFFFFFFE7                 subb    MSCOUNT+3
1321
 00FFF75B 0C1F00                          cmpb    #$F00
1322
 00FFF75D 022FF5                          bhi     W300_0001
1323
 00FFF75F 035086                          puls    d,pc
1324
 
1325
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1326
                              ; Get the keyboard status
1327
                              ;
1328
                              ; Parameters: none
1329
                              ; Returns: d = status
1330
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1331
 
1332
                              KeybdGetStatus:
1333
                              kbgs3:
1334
 00FFF761 0150F6FFFE30401                 ldb             KEYBD+1
1335
 00FFF766 0C5080                          bitb    #$80
1336
 00FFF768 02600E                          bne             kbgs1
1337
 00FFF76A 0C5001                          bitb    #$01            ; check parity error flag
1338
 00FFF76C 026002                          bne             kbgs2
1339
 00FFF76E 04F                             clra
1340
 00FFF76F 039                             rts
1341
                              kbgs2:
1342
 00FFF770 0C60FE                          ldb             #$FE            ; request resend
1343
 00FFF772 08DFA5                          bsr             KeybdSendByte
1344
 00FFF774 08DFA9                          bsr             KeybdWaitTx
1345
 00FFF776 020FE9                          bra             kbgs3
1346
                              kbgs1:                                  ; return negative status
1347
 00FFF778 0CAF00                          orb             #$F00
1348
 00FFF77A 086FFF                          lda             #-1
1349
 00FFF77C 039                             rts
1350
 
1351
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1352
                              ; Get the scancode from the keyboard port
1353
                              ;
1354
                              ; Parameters: none
1355
                              ; Returns: acca = scancode
1356
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1357
 
1358
                              KeybdGetScancode:
1359
 00FFF77D 04F                             clra
1360
 00FFF77E 0150F6FFFE30400                 ldb             KEYBD                           ; get the scan code
1361
 00FFF783 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
1362
                                      ; The following useful during debug.
1363
                              ;       lbsr    DispByteAsHex
1364
                              ;       pshs    b
1365
                              ;       ldb             #' '
1366
                              ;       lbsr    OUTCH
1367
                              ;       puls    b
1368
 00FFF788 039                             rts
1369
 
1370
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1371
                              ; Set the LEDs on the keyboard.
1372
                              ;
1373
                              ; Parameters: d LED status to set
1374
                              ; Returns: none
1375
                              ; Modifies: none
1376
                              ; Stack Space: 2 words
1377
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1378
 
1379
                              KeybdSetLED:
1380
 00FFF789 034004                          pshs    b
1381
 00FFF78B 0C60ED                          ldb             #$ED                                            ; set LEDs command
1382
 00FFF78D 08DF8A                          bsr             KeybdSendByte
1383
 00FFF78F 08DF8E                          bsr             KeybdWaitTx
1384
 00FFF791 08DF6D                          bsr             KeybdRecvByte   ; should be an ack
1385
 00FFF793 035004                          puls    b
1386
 00FFF795 08DF82                          bsr             KeybdSendByte
1387
 00FFF797 08DF86                          bsr             KeybdWaitTx
1388
 00FFF799 08DF65                          bsr             KeybdRecvByte   ; should be an ack
1389
 00FFF79B 039                             rts
1390
 
1391
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1392
                              ; Get ID - get the keyboards identifier code.
1393
                              ;
1394
                              ; Parameters: none
1395
                              ; Returns: d = $AB83, $00 on fail
1396
                              ; Modifies: d, KeybdID updated
1397
                              ; Stack Space: 2 words
1398
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1399
 
1400
                              KeybdGetID:
1401
 00FFF79C 0C60F2                          ldb             #$F2
1402
 00FFF79E 08DF79                          bsr             KeybdSendByte
1403
 00FFF7A0 08DF7D                          bsr             KeybdWaitTx
1404
 00FFF7A2 08DF5C                          bsr             KeybdRecvByte
1405
 00FFF7A4 0C5080                          bitb    #$80
1406
 00FFF7A6 026014                          bne             kgnotKbd
1407
 00FFF7A8 0C10AB                          cmpb    #$AB
1408
 00FFF7AA 026010                          bne             kgnotKbd
1409
 00FFF7AC 08DF52                          bsr             KeybdRecvByte
1410
 00FFF7AE 0C5080                          bitb    #$80
1411
 00FFF7B0 02600A                          bne             kgnotKbd
1412
 00FFF7B2 0C1083                          cmpb    #$83
1413
 00FFF7B4 026006                          bne             kgnotKbd
1414
 00FFF7B6 0CC00AB83                       ldd             #$AB83
1415
                              kgid1:
1416
 00FFF7B9 0DD124                          std             KeybdID
1417
 00FFF7BB 039                             rts
1418
                              kgnotKbd:
1419
 00FFF7BC 04F                             clra
1420
 00FFF7BD 05F                             clrb
1421
 00FFF7BE 020FF9                          bra             kgid1
1422
 
1423
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1424
                              ; Initialize the keyboard.
1425
                              ;
1426
                              ; Parameters:
1427
                              ;               none
1428
                              ;       Modifies:
1429
                              ;               none
1430
                              ; Returns:
1431
                              ;               none
1432
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1433
 
1434
                              KeybdInit:
1435
 00FFF7C0 034026                          pshs    d,y
1436
 00FFF7C2 18E000005                       ldy             #5
1437
                              kbdi0002:
1438
 00FFF7C5 08DF72                          bsr             Wait10ms
1439
 00FFF7C7 01507FFFFE30401                 clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
1440
 00FFF7CC 0C6FFF                          ldb             #-1                                     ; send reset code to keyboard
1441
 00FFF7CE 0150F7FFFE30401                 stb             KEYBD+1                 ; write $FF to status reg to clear TX state
1442
 00FFF7D3 08DF44                          bsr             KeybdSendByte   ; now write to transmit register
1443
 00FFF7D5 08DF48                          bsr             KeybdWaitTx             ; wait until no longer busy
1444
 00FFF7D7 08DF27                          bsr             KeybdRecvByte   ; look for an ACK ($FA)
1445
 00FFF7D9 0C10FA                          cmpb    #$FA
1446
 00FFF7DB 026021                          bne             kbdiTryAgain
1447
 00FFF7DD 08DF21                          bsr             KeybdRecvByte   ; look for BAT completion code ($AA)
1448
 00FFF7DF 0C10FC                          cmpb    #$FC                            ; reset error ?
1449
 00FFF7E1 02701B                          beq             kbdiTryAgain
1450
 00FFF7E3 0C10AA                          cmpb    #$AA                            ; reset complete okay ?
1451
 00FFF7E5 026017                          bne             kbdiTryAgain
1452
 
1453
                                      ; After a reset, scan code set #2 should be active
1454
                              .config:
1455
 00FFF7E7 0C60F0                          ldb             #$F0                    ; send scan code select
1456
 00FFF7E9 0150F7FFFE60000                 stb             LEDS
1457
 00FFF7EE 08DF29                          bsr             KeybdSendByte
1458
 00FFF7F0 08DF2D                          bsr             KeybdWaitTx
1459
 00FFF7F2 05D                             tstb
1460
 00FFF7F3 02B009                          bmi             kbdiTryAgain
1461
 00FFF7F5 08DF09                          bsr             KeybdRecvByte   ; wait for response from keyboard
1462
 00FFF7F7 04D                             tsta
1463
 00FFF7F8 02B004                          bmi             kbdiTryAgain
1464
 00FFF7FA 0C10FA                          cmpb    #$FA                                    ; ACK
1465
 00FFF7FC 02700C                          beq             kbdi0004
1466
                              kbdiTryAgain:
1467
 00FFF7FE 0313FF                          dey
1468
 00FFF800 026FC3                          bne       kbdi0002
1469
                              .keybdErr:
1470
 00FFF802 0CCFFF82A                       ldd             #msgBadKeybd
1471
 00FFF805 017FFFB5A                       lbsr    DisplayStringCRLF
1472
*** warning 1: Long branch within short branch range could be optimized
1473
 00FFF808 020014                          bra             ledxit
1474
                              kbdi0004:
1475
 00FFF80A 0C6002                          ldb             #2                      ; select scan code set #2
1476
 00FFF80C 08DF0B                          bsr             KeybdSendByte
1477
 00FFF80E 08DF0F                          bsr             KeybdWaitTx
1478
 00FFF810 05D                             tstb
1479
 00FFF811 02BFEB                          bmi             kbdiTryAgain
1480
 00FFF813 08DEEB                          bsr             KeybdRecvByte   ; wait for response from keyboard
1481
 00FFF815 04D                             tsta
1482
 00FFF816 02BFE6                          bmi             kbdiTryAgain
1483
 00FFF818 0C10FA                          cmpb    #$FA
1484
 00FFF81A 026FE2                          bne             kbdiTryAgain
1485
 00FFF81C 08DF7E                          bsr             KeybdGetID
1486
                              ledxit:
1487
 00FFF81E 0C6007                          ldb             #$07
1488
 00FFF820 08DF67                          bsr             KeybdSetLED
1489
 00FFF822 08DF29                          bsr             Wait300ms
1490
 00FFF824 0C6000                          ldb             #$00
1491
 00FFF826 08DF61                          bsr             KeybdSetLED
1492
 00FFF828 0350A6                          puls    d,y,pc
1493
 
1494
                              msgBadKeybd:
1495
 00FFF82A 04B06507906206F061072           fcb             "Keyboard error",0
1496
 00FFF831 06402006507207206F072
1497
 00FFF838 000
1498
 
1499
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1500
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1501
 
1502
                              DBGCheckForKey:
1503
 00FFF839 020F26                          bra             KeybdGetStatus
1504
 
1505
 
1506
                              ; KeyState2 variable bit meanings
1507
                              ;1176543210
1508
                              ; ||||||||+ = shift
1509
                              ; |||||||+- = alt
1510
                              ; ||||||+-- = control
1511
                              ; |||||+--- = numlock
1512
                              ; ||||+---- = capslock
1513
                              ; |||+----- = scrolllock
1514
                              ; ||+------ = 
1515
                              ; |+------- =    "
1516
                              ; |         =    "
1517
                              ; |         =    "
1518
                              ; |         =    "
1519
                              ; +-------- = extended
1520
 
1521
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1522
                              ; Debug versison of keyboard get routine.
1523
                              ;
1524
                              ; Parameters:
1525
                              ;               b:      0 = non blocking, otherwise blocking
1526
                              ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1527
 
1528
                              DBGGetKey:
1529
 00FFF83B 034010                          pshs    x
1530
                              dbgk2:
1531
 00FFF83D 034004                          pshs    b
1532
 00FFF83F 08DF20                          bsr             KeybdGetStatus
1533
 00FFF841 0C4080                          andb    #$80                                                    ; is key available?
1534
 00FFF843 035004                          puls    b
1535
 00FFF845 026008                          bne             dbgk1                                                   ; branch if key
1536
 00FFF847 05D                             tstb                                                                            ; block?
1537
 00FFF848 026FF3                          bne             dbgk2                                                   ; If no key and blocking - loop
1538
 00FFF84A 0CCFFFFFF                       ldd             #-1                                                             ; return -1 if no block and no key
1539
 00FFF84D 035090                          puls    x,pc
1540
                              dbgk1:
1541
 00FFF84F 08DF2C                          bsr             KeybdGetScancode
1542
                              ;       lbsr    DispByteAsHex
1543
                                      ; Make sure there is a small delay between scancode reads
1544
 00FFF851 08E000014                       ldx             #20
1545
                              dbgk3:
1546
 00FFF854 0301FF                          dex
1547
 00FFF856 026FFC                          bne             dbgk3
1548
                                      ; switch on scan code
1549
 00FFF858 0C10F0                          cmpb    #SC_KEYUP
1550
 00FFF85A 026006                          bne             dbgk4
1551
 00FFF85C 00F120                          clr             KeyState1                                       ; make KeyState1 = -1
1552
 00FFF85E 000120                          neg             KeyState1
1553
 00FFF860 020FDB                          bra             dbgk2                                                   ; loop back
1554
                              dbgk4:
1555
 00FFF862 0C10E0                          cmpb    #SC_EXTEND
1556
 00FFF864 026008                          bne             dbgk5
1557
 00FFF866 096121                          lda             KeyState2
1558
 00FFF868 08A800                          ora             #$800
1559
 00FFF86A 097121                          sta             KeyState2
1560
 00FFF86C 020FCF                          bra             dbgk2
1561
                              dbgk5:
1562
 00FFF86E 0C1014                          cmpb    #SC_CTRL
1563
 00FFF870 026016                          bne             dbgkNotCtrl
1564
 00FFF872 00D120                          tst             KeyState1
1565
 00FFF874 02B008                          bmi             dbgk7
1566
 00FFF876 096121                          lda             KeyState2
1567
 00FFF878 08A004                          ora             #4
1568
 00FFF87A 097121                          sta             KeyState2
1569
 00FFF87C 020006                          bra             dbgk8
1570
                              dbgk7:
1571
 00FFF87E 096121                          lda             KeyState2
1572
 00FFF880 084FFB                          anda    #~4
1573
 00FFF882 097121                          sta             KeyState2
1574
                              dbgk8:
1575
 00FFF884 00F120                          clr             KeyState1
1576
 00FFF886 020FB5                          bra             dbgk2
1577
                              dbgkNotCtrl:
1578
 00FFF888 0C1059                          cmpb    #SC_RSHIFT
1579
 00FFF88A 026016                          bne             dbgkNotRshift
1580
 00FFF88C 00D120                          tst             KeyState1
1581
 00FFF88E 02B008                          bmi             dbgk9
1582
 00FFF890 096121                          lda             KeyState2
1583
 00FFF892 08A001                          ora             #1
1584
 00FFF894 097121                          sta             KeyState2
1585
 00FFF896 020006                          bra             dbgk10
1586
                              dbgk9:
1587
 00FFF898 096121                          lda             KeyState2
1588
 00FFF89A 084FFE                          anda    #~1
1589
 00FFF89C 097121                          sta             KeyState2
1590
                              dbgk10:
1591
 00FFF89E 00F120                          clr             KeyState1
1592
 00FFF8A0 020F9B                          bra             dbgk2
1593
                              dbgkNotRshift:
1594
 00FFF8A2 0C1077                          cmpb    #SC_NUMLOCK
1595
 00FFF8A4 026013                          bne             dbgkNotNumlock
1596
 00FFF8A6 096121                          lda             KeyState2
1597
 00FFF8A8 088010                          eora    #16
1598
 00FFF8AA 097121                          sta             KeyState2
1599
 00FFF8AC 096122                          lda             KeyLED
1600
 00FFF8AE 088002                          eora    #2
1601
 00FFF8B0 097122                          sta             KeyLED
1602
 00FFF8B2 01F089                          tfr             a,b
1603
 00FFF8B4 04F                             clra
1604
 00FFF8B5 08DED2                          bsr             KeybdSetLED
1605
 00FFF8B7 020F84                          bra             dbgk2
1606
                              dbgkNotNumlock:
1607
 00FFF8B9 0C1058                          cmpb    #SC_CAPSLOCK
1608
 00FFF8BB 026013                          bne             dbgkNotCapslock
1609
 00FFF8BD 096121                          lda             KeyState2
1610
 00FFF8BF 088020                          eora    #32
1611
 00FFF8C1 097121                          sta             KeyState2
1612
 00FFF8C3 096122                          lda             KeyLED
1613
 00FFF8C5 088004                          eora    #4
1614
 00FFF8C7 097122                          sta             KeyLED
1615
 00FFF8C9 01F089                          tfr             a,b
1616
 00FFF8CB 04F                             clra
1617
 00FFF8CC 08DEBB                          bsr             KeybdSetLED
1618
 00FFF8CE 020F6D                          bra             dbgk2
1619
                              dbgkNotCapslock:
1620
 00FFF8D0 0C107E                          cmpb    #SC_SCROLLLOCK
1621
 00FFF8D2 026013                          bne             dbgkNotScrolllock
1622
 00FFF8D4 096121                          lda             KeyState2
1623
 00FFF8D6 088040                          eora    #64
1624
 00FFF8D8 097121                          sta             KeyState2
1625
 00FFF8DA 096122                          lda             KeyLED
1626
 00FFF8DC 088001                          eora    #1
1627
 00FFF8DE 097122                          sta             KeyLED
1628
 00FFF8E0 01F089                          tfr             a,b
1629
 00FFF8E2 04F                             clra
1630
 00FFF8E3 08DEA4                          bsr             KeybdSetLED
1631
 00FFF8E5 020F56                          bra             dbgk2
1632
                              dbgkNotScrolllock:
1633
 00FFF8E7 0C1011                          cmpb    #SC_ALT
1634
 00FFF8E9 026016                          bne             dbgkNotAlt
1635
 00FFF8EB 00D120                          tst             KeyState1
1636
 00FFF8ED 02B008                          bmi             dbgk11
1637
 00FFF8EF 096121                          lda             KeyState2
1638
 00FFF8F1 08A002                          ora             #2
1639
 00FFF8F3 097121                          sta             KeyState2
1640
 00FFF8F5 020006                          bra             dbgk12
1641
                              dbgk11:
1642
 00FFF8F7 096121                          lda             KeyState2
1643
 00FFF8F9 084FFD                          anda    #~2
1644
 00FFF8FB 097121                          sta             KeyState2
1645
                              dbgk12:
1646
 00FFF8FD 00F120                          clr             KeyState1
1647
 00FFF8FF 020F3C                          bra             dbgk2
1648
                              dbgkNotAlt:
1649
 00FFF901 00D120                          tst             KeyState1
1650
 00FFF903 027004                          beq             dbgk13
1651
 00FFF905 00F120                          clr             KeyState1
1652
 00FFF907 020F34                          bra             dbgk2
1653
                              dbgk13:
1654
 00FFF909 096121                          lda             KeyState2               ; Check for CTRL-ALT-DEL
1655
 00FFF90B 084006                          anda    #6
1656
 00FFF90D 081006                          cmpa    #6
1657
 00FFF90F 026008                          bne             dbgk14
1658
 00FFF911 0C1071                          cmpb    #SC_DEL
1659
 00FFF913 026004                          bne             dbgk14
1660
 00FFF915 06E90FFFFFFE                    jmp             [$FFFFFE]               ; jump to reset vector
1661
                              dbgk14:
1662
 00FFF919 00D121                          tst             KeyState2               ; extended code?
1663
 00FFF91B 02A00B                          bpl             dbgk15
1664
 00FFF91D 096121                          lda             KeyState2
1665
 00FFF91F 0847FF                          anda    #$7FF
1666
 00FFF921 097121                          sta             KeyState2
1667
 00FFF923 08EFFF680                       ldx             #keybdExtendedCodes
1668
 00FFF926 020017                          bra             dbgk18
1669
                              dbgk15:
1670
 00FFF928 096121                          lda             KeyState2               ; Is CTRL down?
1671
 00FFF92A 085004                          bita    #4
1672
 00FFF92C 027005                          beq             dbgk16
1673
 00FFF92E 08EFFF600                       ldx             #keybdControlCodes
1674
 00FFF931 02000C                          bra             dbgk18
1675
                              dbgk16:
1676
 00FFF933 085001                          bita    #1                                      ; Is shift down?
1677
 00FFF935 027005                          beq             dbgk17
1678
 00FFF937 08EFFF500                       ldx             #shiftedScanCodes
1679
 00FFF93A 020003                          bra             dbgk18
1680
                              dbgk17:
1681
 00FFF93C 08EFFF400                       ldx             #unshiftedScanCodes
1682
                              dbgk18:
1683
 00FFF93F 03A                             abx
1684
 00FFF940 0E6804                          ldb             ,x
1685
 00FFF942 04F                             clra
1686
 00FFF943 035090                          puls    x,pc                            ; and return
1687
 
1688
 
1689
 00FFF945 04B04505904204F041052           fcb             "KEYBOARD"
1690
 00FFF94C 044
1691
 00FFF94D FFF957                          fcw             KeybdOpen
1692
 00FFF94F FFF958                          fcw             KeybdClose
1693
 00FFF951 FFF959                          fcw             KeybdRead
1694
 00FFF953 FFF95A                          fcw             KeybdWrite
1695
 00FFF955 FFF95B                          fcw             KeybdSeek
1696
 
1697
                              ; Keyboard Open:
1698
                              ; Initialize the keyboard buffer head and tail indexes
1699
                              ;
1700
                              KeybdOpen:
1701
 00FFF957 039                             rts
1702
 
1703
                              ; Keyboard Close:
1704
                              ; Nothing to do except maybe clear the keyboard buffer
1705
                              ;
1706
                              KeybdClose:
1707
 00FFF958 039                             rts
1708
                              ;
1709
                              KeybdRead:
1710
 00FFF959 039                             rts
1711
                              ;
1712
                              KeybdWrite:
1713
 00FFF95A 039                             rts
1714
 
1715
                              KeybdSeek:
1716
 00FFF95B 039                             rts
1717
 
1718
                              ;------------------------------------------------------------------------------
1719
                              ; Check if there is a keyboard character available. If so return true (<0)
1720
                              ; otherwise return false (0) in accb.
1721
                              ;------------------------------------------------------------------------------
1722
                              ;
1723
                              KeybdCheckForKeyDirect:
1724
 00FFF95C 020EDB                          bra             DBGCheckForKey
1725
 
1726
                              ;------------------------------------------------------------------------------
1727
                              ;------------------------------------------------------------------------------
1728
                              INCH:
1729
 00FFF95E 0CCFFFFFF                       ldd             #-1                             ; block if no key available
1730
 00FFF961 020ED8                          bra             DBGGetKey
1731
 
1732
                              INCHE:
1733
 00FFF963 08DFF9                          bsr             INCH
1734
 00FFF965 020009                          bra             INCHEK3
1735
 
1736
                              INCHEK:
1737
 00FFF967 08DFF5                          bsr             INCH
1738
 00FFF969 01507DFFFFFCA00                 tst             KeybdEcho
1739
 00FFF96E 02700B                          beq             INCHEK1
1740
                              INCHEK3:
1741
 00FFF970 08100D                          cmpa    #CR
1742
 00FFF972 026005                          bne             INCHEK2
1743
 00FFF974 017FFD75B                       lbsr            CRLF
1744
*** warning 1: Long branch within short branch range could be optimized
1745
 00FFF977 020002                          bra             INCHEK1
1746
                              INCHEK2:
1747
 00FFF979 08D920                          bsr             DisplayChar
1748
                              INCHEK1:
1749
 00FFF97B 039                             rts
1750
 
1751
                              OUTCH:
1752
 00FFF97C 06E90F000800                    jmp             [CharOutVec]
1753
 
1754
                              ;------------------------------------------------------------------------------
1755
                              ; r1 0=echo off, non-zero = echo on
1756
                              ;------------------------------------------------------------------------------
1757
                              ;
1758
                              SetKeyboardEcho:
1759
 00FFF980 0150F7FFFFFCA00                 stb             KeybdEcho
1760
 00FFF985 039                             rts
1761
 
1762
 
1763
                              ;------------------------------------------------------------------------------
1764
                              ; Parameters:
1765
                              ;               x,d     bitmap of sprites to enable
1766
                              ;------------------------------------------------------------------------------
1767
 
1768
                              ShowSprites:
1769
 00FFF986 0150BFFFFE103C0                 stx             SPRITE_CTRL+SPRITE_EN
1770
 00FFF98B 0150FDFFFE103C2                 std             SPRITE_CTRL+SPRITE_EN+2
1771
 00FFF990 039                             rts
1772
 
1773
                              ;==============================================================================
1774
                              ; System Monitor
1775
                              ;==============================================================================
1776
                              ;
1777
                              MonitorStart:
1778
 00FFF991 0CCFFFAEF                       ldd             #HelpMsg
1779
 00FFF994 08D9BE                          bsr             DisplayString
1780
                              Monitor:
1781
 00FFF996 03280F003FFF                    leas    $3FFF                           ; reset stack pointer
1782
 00FFF99A 05F                             clrb                                                    ; turn off keyboard echo
1783
 00FFF99B 08DFE3                          bsr             SetKeyboardEcho
1784
                              ;       jsr             RequestIOFocus
1785
                              PromptLn:
1786
 00FFF99D 017FFD732                       lbsr    CRLF
1787
*** warning 1: Long branch within short branch range could be optimized
1788
 00FFF9A0 0C6024                          ldb             #'$'
1789
 00FFF9A2 08DFD8                          bsr             OUTCH
1790
 
1791
                              ; Get characters until a CR is keyed
1792
 
1793
                              Prompt3:
1794
 00FFF9A4 0CCFFFFFF                       ldd             #-1                                     ; block until key present
1795
 00FFF9A7 08DE92                          bsr             DBGGetKey
1796
 00FFF9A9 0C100D                          cmpb    #CR
1797
 00FFF9AB 027004                          beq             Prompt1
1798
 00FFF9AD 08DFCD                          bsr             OUTCH
1799
 00FFF9AF 020FF3                          bra             Prompt3
1800
 
1801
                              ; Process the screen line that the CR was keyed on
1802
                              ;
1803
                              Prompt1:
1804
 00FFF9B1 0CC005050                       ldd             #$5050
1805
 00FFF9B4 0150FDFFFE60000                 std             LEDS
1806
 00FFF9B9 0F6800000                       ldb             RunningID
1807
 00FFF9BC 0C103D                          cmpb    #61
1808
 00FFF9BE 022FE4                          bhi             Prompt3
1809
 00FFF9C0 0CC005151                       ldd             #$5151
1810
 00FFF9C3 0150FDFFFE60000                 std             LEDS
1811
 00FFF9C8 00F111                          clr             CursorCol                       ; go back to the start of the line
1812
 00FFF9CA 08D8AD                          bsr             CalcScreenLoc   ; calc screen memory location
1813
 00FFF9CC 01F002                          tfr             d,y
1814
 00FFF9CE 0CC005252                       ldd             #$5252
1815
 00FFF9D1 0150FDFFFE60000                 std             LEDS
1816
 00FFF9D6 08D055                          bsr             MonGetNonSpace
1817
 00FFF9D8 0C1024                          cmpb    #'$'
1818
 00FFF9DA 026009                          bne             Prompt2                 ; skip over '$' prompt character
1819
 00FFF9DC 086353                          lda             #$5353
1820
 00FFF9DE 0150FDFFFE60000                 std             LEDS
1821
 00FFF9E3 08D048                          bsr             MonGetNonSpace
1822
 
1823
                              ; Dispatch based on command character
1824
                              ;
1825
                              Prompt2:
1826
 00FFF9E5 0C103F                          cmpb    #'?'                    ; $? - display help
1827
 00FFF9E7 026007                          bne             PromptC
1828
 00FFF9E9 0CCFFFAEF                       ldd             #HelpMsg
1829
 00FFF9EC 08D966                          bsr             DisplayString
1830
 00FFF9EE 020FA6                          bra             Monitor
1831
                              PromptC:
1832
 00FFF9F0 0C1043                          cmpb    #'C'
1833
 00FFF9F2 026007                          bne             PromptD
1834
 00FFF9F4 017FFF7D9                       lbsr            ClearScreen
1835
*** warning 1: Long branch within short branch range could be optimized
1836
 00FFF9F7 08D848                          bsr             HomeCursor
1837
 00FFF9F9 020F9B                          bra             Monitor
1838
                              PromptD:
1839
 00FFF9FB 0C1044                          cmpb    #'D'
1840
 00FFF9FD 026008                          bne             PromptF
1841
 00FFF9FF 08D027                          bsr             MonGetch
1842
 00FFFA01 0C1052                          cmpb    #'R'
1843
 00FFFA03 026F9F                          bne             Prompt3
1844
 00FFFA05 020193                          bra             DumpRegs
1845
                              PromptF:
1846
 00FFFA07 0C1046                          cmpb    #'F'
1847
 00FFFA09 02600F                          bne             PromptJ
1848
 00FFFA0B 08D01B                          bsr             MonGetch
1849
 00FFFA0D 0C1049                          cmpb    #'I'
1850
 00FFFA0F 026F85                          bne             Monitor
1851
 00FFFA11 08D015                          bsr             MonGetch
1852
 00FFFA13 0C1047                          cmpb    #'G'
1853
 00FFFA15 026F7F                          bne             Monitor
1854
 00FFFA17 07EFE0000                       jmp             $FE0000
1855
                              PromptJ:
1856
 00FFFA1A 0C104A                          cmpb    #'J'
1857
 00FFFA1C 1270001BF                       lbeq    jump_to_code
1858
                              PromptR:
1859
 00FFFA1F 0C1052                          cmpb    #'R'
1860
 00FFFA21 026F73                          bne             Monitor
1861
 00FFFA23 017FFE5DA                       lbsr    ramtest
1862
*** warning 1: Long branch within short branch range could be optimized
1863
 00FFFA26 020F6E                          bra             Monitor
1864
 
1865
                              MonGetch:
1866
 00FFFA28 0E6A04                          ldb             ,y
1867
 00FFFA2A 031201                          leay    1,y
1868
 00FFFA2C 039                             rts
1869
 
1870
                              MonGetNonSpace:
1871
 00FFFA2D 08DFF9                          bsr             MonGetCh
1872
 00FFFA2F 0C1020                          cmpb    #' '
1873
 00FFFA31 027FFA                          beq             MonGetNonSpace
1874
 00FFFA33 0C1009                          cmpb    #9              ; tab
1875
 00FFFA35 027FF6                          beq             MonGetNonSpace
1876
 00FFFA37 039                             rts
1877
 
1878
                              ;------------------------------------------------------------------------------
1879
                              ; Ignore blanks in the input
1880
                              ; Y = text pointer
1881
                              ; D destroyed
1882
                              ;------------------------------------------------------------------------------
1883
                              ;
1884
                              ignBlanks:
1885
                              ignBlanks1:
1886
 00FFFA38 08DFEE                          bsr             MonGetch
1887
 00FFFA3A 0C1020                          cmpb    #' '
1888
 00FFFA3C 027FFA                          beq             ignBlanks1
1889
 00FFFA3E 0313FF                          leay    -1,y
1890
 00FFFA40 039                             rts
1891
 
1892
                              ;------------------------------------------------------------------------------
1893
                              ;------------------------------------------------------------------------------
1894
                              GetTwoParams:
1895
 00FFFA41 08DFF5                          bsr             ignBlanks
1896
 00FFFA43 08D02E                          bsr             GetHexNumber    ; get start address of dump
1897
 00FFFA45 0DC910                          ldd             mon_numwka
1898
 00FFFA47 0DD920                          std             mon_r1
1899
 00FFFA49 0DC912                          ldd             mon_numwka+2
1900
 00FFFA4B 0DD922                          std             mon_r1+2
1901
 00FFFA4D 08DFE9                          bsr             ignBlanks
1902
 00FFFA4F 08D022                          bsr             GetHexNumber    ; get end address of dump
1903
 00FFFA51 0DC910                          ldd             mon_numwka
1904
 00FFFA53 0DD922                          std             mon_r2
1905
 00FFFA55 0DC912                          ldd             mon_numwka+2
1906
 00FFFA57 0DD924                          std             mon_r2+2
1907
 00FFFA59 039                             rts
1908
 
1909
                              ;------------------------------------------------------------------------------
1910
                              ; Get a range, the end must be greater or equal to the start.
1911
                              ;------------------------------------------------------------------------------
1912
                              GetRange:
1913
 00FFFA5A 08DFE5                          bsr             GetTwoParams
1914
 00FFFA5C 0DC924                          ldd             mon_r2+2
1915
 00FFFA5E 093922                          subd    mon_r1+2
1916
 00FFFA60 0DC922                          ldd             mon_r2
1917
 00FFFA62 0D2921                          sbcb    mon_r1+1
1918
 00FFFA64 092920                          sbca    mon_r1
1919
 00FFFA66 12500006C                       lbcs    DisplayErr
1920
 00FFFA69 039                             rts
1921
 
1922
                              shl_numwka:
1923
 00FFFA6A 008913                          asl             mon_numwka+3
1924
 00FFFA6C 009912                          rol             mon_numwka+2
1925
 00FFFA6E 009911                          rol             mon_numwka+1
1926
 00FFFA70 009910                          rol             mon_numwka
1927
 00FFFA72 039                             rts
1928
 
1929
                              ;------------------------------------------------------------------------------
1930
                              ; Get a hexidecimal number. Maximum of nine digits.
1931
                              ; Y = text pointer (updated)
1932
                              ; D = number of digits
1933
                              ; mon_numwka contains number
1934
                              ;------------------------------------------------------------------------------
1935
                              ;
1936
                              GetHexNumber:
1937
 00FFFA73 04F05F                          clrd
1938
 00FFFA75 0DD910                          std             mon_numwka
1939
 00FFFA77 0DD912                          std             mon_numwka+2
1940
 00FFFA79 034010                          pshs    x
1941
 00FFFA7B 08E000000                       ldx             #0                                      ; max 9 eight digits
1942
                              gthxn2:
1943
 00FFFA7E 08DFA8                          bsr             MonGetch
1944
 00FFFA80 08D01D                          bsr             AsciiToHexNybble
1945
 00FFFA82 0C1FFF                          cmpb    #-1
1946
 00FFFA84 027015                          beq             gthxn1
1947
 00FFFA86 08DFE2                          bsr             shl_numwka
1948
 00FFFA88 08DFE0                          bsr             shl_numwka
1949
 00FFFA8A 08DFDE                          bsr             shl_numwka
1950
 00FFFA8C 08DFDC                          bsr             shl_numwka
1951
 00FFFA8E 0C400F                          andb    #$0f
1952
 00FFFA90 0DA913                          orb             mon_numwka+3
1953
 00FFFA92 0D7913                          stb             mon_numwka+3
1954
 00FFFA94 030001                          inx
1955
 00FFFA96 08C000009                       cmpx    #9
1956
 00FFFA99 025FE3                          blo             gthxn2
1957
                              gthxn1:
1958
 00FFFA9B 01F010                          tfr             x,d
1959
 00FFFA9D 035090                          puls    x,pc
1960
 
1961
                              ;GetDecNumber:
1962
                              ;       phx
1963
                              ;       push    r4
1964
                              ;       push    r5
1965
                              ;       ldx             #0
1966
                              ;       ld              r4,#10
1967
                              ;       ld              r5,#10
1968
                              ;gtdcn2:
1969
                              ;       jsr             MonGetch
1970
                              ;       jsr             AsciiToDecNybble
1971
                              ;       cmp             #-1
1972
                              ;       beq             gtdcn1
1973
                              ;       mul             r2,r2,r5
1974
                              ;       add             r2,r1
1975
                              ;       dec             r4
1976
                              ;       bne             gtdcn2
1977
                              ;gtdcn1:
1978
                              ;       txa
1979
                              ;       pop             r5
1980
                              ;       pop             r4
1981
                              ;       plx
1982
                              ;       rts
1983
 
1984
                              ;------------------------------------------------------------------------------
1985
                              ; Convert ASCII character in the range '0' to '9', 'a' to 'f' or 'A' to 'F'
1986
                              ; to a hex nybble.
1987
                              ;------------------------------------------------------------------------------
1988
                              ;
1989
                              AsciiToHexNybble:
1990
 00FFFA9F 0C1030                          cmpb    #'0'
1991
 00FFFAA1 024021                          bcc             gthx3
1992
 00FFFAA3 0C103A                          cmpb    #'9'+1
1993
 00FFFAA5 025003                          bcs             gthx5
1994
 00FFFAA7 0C0030                          subb    #'0'
1995
 00FFFAA9 039                             rts
1996
                              gthx5:
1997
 00FFFAAA 0C1041                          cmpb    #'A'
1998
 00FFFAAC 024016                          bcc             gthx3
1999
 00FFFAAE 0C1047                          cmpb    #'F'+1
2000
 00FFFAB0 025005                          bcs             gthx6
2001
 00FFFAB2 0C0041                          subb    #'A'
2002
 00FFFAB4 0CB00A                          addb    #10
2003
 00FFFAB6 039                             rts
2004
                              gthx6:
2005
 00FFFAB7 0C1061                          cmpb    #'a'
2006
 00FFFAB9 024009                          bcc             gthx3
2007
 00FFFABB 0C107B                          cmpb    #'z'+1
2008
 00FFFABD 025005                          bcs             gthx3
2009
 00FFFABF 0C0061                          subb    #'a'
2010
 00FFFAC1 0CB00A                          addb    #10
2011
 00FFFAC3 039                             rts
2012
                              gthx3:
2013
 00FFFAC4 0C6FFF                          ldb             #-1             ; not a hex number
2014
 00FFFAC6 039                             rts
2015
 
2016
                              AsciiToDecNybble:
2017
 00FFFAC7 0C1030                          cmpb    #'0'
2018
 00FFFAC9 024007                          bcc             gtdc3
2019
 00FFFACB 0C103A                          cmpb    #'9'+1
2020
 00FFFACD 025003                          bcs             gtdc3
2021
 00FFFACF 0C0030                          subb    #'0'
2022
 00FFFAD1 039                             rts
2023
                              gtdc3:
2024
 00FFFAD2 0C6FFF                          ldb             #-1
2025
 00FFFAD4 039                             rts
2026
 
2027
                              DisplayErr:
2028
 00FFFAD5 08EFFFAE7                       ldx             #msgErr
2029
 00FFFAD8 04F05F                          clrd
2030
 00FFFADA 08D003                          bsr             DisplayStringDX
2031
 00FFFADC 07EFFF996                       jmp             Monitor
2032
 
2033
                              DisplayStringDX
2034
 00FFFADF 0DD024                          std             Strptr
2035
 00FFFAE1 09F026                          stx             Strptr+2
2036
 00FFFAE3 0BDFFF354                       jsr             DisplayString
2037
 00FFFAE6 039                             rts
2038
 
2039
                              msgErr:
2040
 00FFFAE7 02A02A04507207200D00A           fcb     "**Err",CR,LF,0
2041
 00FFFAEE 000
2042
 
2043
                              HelpMsg:
2044
 00FFFAEF 03F02003D020044069073           fcb             "? = Display help",CR,LF
2045
 00FFFAF6 07006C061079020068065
2046
 00FFFAFD 06C07000D00A
2047
 00FFFB01 04304C05302003D020063           fcb     "CLS = clear screen",CR,LF
2048
 00FFFB08 06C065061072020073063
2049
 00FFFB0F 07206506506E00D00A
2050
                              ;       db      "S = Boot from SD Card",CR,LF
2051
                              ;       db      ": = Edit memory bytes",CR,LF
2052
                              ;       db      "L = Load sector",CR,LF
2053
                              ;       db      "W = Write sector",CR,LF
2054
 00FFFB15 04405202003D020044075           fcb "DR = Dump registers",CR,LF
2055
 00FFFB1C 06D070020072065067069
2056
 00FFFB23 07307406507207300D00A
2057
                              ;       db      "D = Dump memory",CR,LF
2058
                              ;       db      "F = Fill memory",CR,LF
2059
                              ;       db  "FL = Dump I/O Focus List",CR,LF
2060
 00FFFB2A 04604904702003D020073           fcb "FIG = start FIG Forth",CR,LF
2061
 00FFFB31 074061072074020046049
2062
 00FFFB38 04702004606F072074068
2063
 00FFFB3F 00D00A
2064
                              ;       db      "KILL n = kill task #n",CR,LF
2065
                              ;       db      "B = start tiny basic",CR,LF
2066
                              ;       db      "b = start EhBasic 6502",CR,LF
2067
 00FFFB41 04A02003D02004A07506D           fcb     "J = Jump to code",CR,LF
2068
 00FFFB48 07002007406F02006306F
2069
 00FFFB4F 06406500D00A
2070
 00FFFB53 05204104D02003D020074           fcb "RAM = test RAM",CR,LF
2071
 00FFFB5A 06507307402005204104D
2072
 00FFFB61 00D00A
2073
                              ;       db      "R[n] = Set register value",CR,LF
2074
                              ;       db      "r = random lines - test bitmap",CR,LF
2075
                              ;       db      "e = ethernet test",CR,LF
2076
                              ;       db      "T = Dump task list",CR,LF
2077
                              ;       db      "TO = Dump timeout list",CR,LF
2078
                              ;       db      "TI = display date/time",CR,LF
2079
                              ;       db      "TEMP = display temperature",CR,LF
2080
                              ;       db      "P = Piano",CR,LF,0
2081
 00FFFB63 000                             fcb             0
2082
 
2083
                              msgRegHeadings
2084
 00FFFB64 00D00A02004402F041042           fcb     CR,LF," D/AB   X    Y    U    S     PC    DP CCR",CR,LF,0
2085
 00FFFB6B 020020020058020020020
2086
 00FFFB72 020059020020020020055
2087
 00FFFB79 020020020020053020020
2088
 00FFFB80 020020020050043020020
2089
 00FFFB87 020020044050020043043
2090
 00FFFB8E 05200D00A000
2091
 
2092
                              nHEX4:
2093
 00FFFB92 0BDFFD2D2                       jsr             HEX4
2094
 00FFFB95 039                             rts
2095
 
2096
                              nXBLANK:
2097
 00FFFB96 0C6020                          ldb             #' '
2098
 00FFFB98 020DE2                          bra             OUTCH
2099
 
2100
                              DumpRegs
2101
 00FFFB9A 08EFFFB64                       ldx             #msgRegHeadings
2102
 00FFFB9D 0CC0000FF                       ldd             #msgRegHeadings>>16
2103
 00FFFBA0 0BDFFFADF                       jsr             DisplayStringDX
2104
 00FFFBA3 08DFF1                          bsr             nXBLANK
2105
 00FFFBA5 0DC900                          ldd             mon_DSAVE
2106
 00FFFBA7 08DFE9                          bsr             nHEX4
2107
 00FFFBA9 08DFEB                          bsr             nXBLANK
2108
 00FFFBAB 0DC902                          ldd             mon_XSAVE
2109
 00FFFBAD 08DFE3                          bsr             nHEX4
2110
 00FFFBAF 08DFE5                          bsr             nXBLANK
2111
 00FFFBB1 0DC904                          ldd             mon_YSAVE
2112
 00FFFBB3 08DFDD                          bsr             nHEX4
2113
 00FFFBB5 08DFDF                          bsr             nXBLANK
2114
 00FFFBB7 0DC906                          ldd             mon_USAVE
2115
 00FFFBB9 08DFD7                          bsr             nHEX4
2116
 00FFFBBB 08DFD9                          bsr             nXBLANK
2117
 00FFFBBD 0DC908                          ldd             mon_SSAVE
2118
 00FFFBBF 08DFD1                          bsr             nHEX4
2119
 00FFFBC1 08DFD3                          bsr             nXBLANK
2120
 00FFFBC3 0DC90A                          ldd             mon_PCSAVE
2121
 00FFFBC5 08DFCB                          bsr             nHEX4
2122
 00FFFBC7 0DC90C                          ldd             mon_PCSAVE+2
2123
 00FFFBC9 08DFC7                          bsr             nHEX4
2124
 00FFFBCB 08DFC9                          bsr             nXBLANK
2125
 00FFFBCD 0DC90E                          ldd             mon_DPRSAVE
2126
 00FFFBCF 0BDFFD2CE                       jsr             HEX2
2127
 00FFFBD2 08DFC2                          bsr             nXBLANK
2128
 00FFFBD4 09690F                          lda             mon_CCRSAVE
2129
 00FFFBD6 0BDFFD2CE                       jsr             HEX2
2130
 00FFFBD9 08DFBB                          bsr             nXBLANK
2131
 00FFFBDB 07EFFF996                       jmp             Monitor
2132
 
2133
                              ; Jump to code
2134
                              jump_to_code:
2135
 00FFFBDE 08DE93                          bsr             GetHexNumber
2136
 00FFFBE0 01A010                          sei
2137
 00FFFBE2 1DE908                          lds             mon_SSAVE
2138
 00FFFBE4 0CCFFFC11                       ldd             #
2139
 00FFFBE7 034006                          pshs    d
2140
 00FFFBE9 0CC000000                       ldd             #>jtc_exit
2141
 00FFFBEC 034004                          pshs    b
2142
 00FFFBEE 0DC912                          ldd             mon_numwka+2
2143
 00FFFBF0 034006                          pshs    d
2144
 00FFFBF2 0DC910                          ldd             mon_numwka
2145
 00FFFBF4 034006                          pshs    d
2146
 00FFFBF6 0DC906                          ldd             mon_USAVE
2147
 00FFFBF8 034006                          pshs    d
2148
 00FFFBFA 0DC904                          ldd             mon_YSAVE
2149
 00FFFBFC 034006                          pshs    d
2150
 00FFFBFE 0DC902                          ldd             mon_XSAVE
2151
 00FFFC00 034006                          pshs    d
2152
 00FFFC02 09690E                          lda             mon_DPRSave
2153
 00FFFC04 034002                          pshs    a
2154
 00FFFC06 0DC900                          ldd             mon_DSAVE
2155
 00FFFC08 034006                          pshs    d
2156
 00FFFC0A 09690F                          lda             mon_CCRSAVE
2157
 00FFFC0C 034002                          pshs    a
2158
 00FFFC0E 0150350FF                       puls    far ccr,d,dpr,x,y,u,pc
2159
                              jtc_exit:
2160
 00FFFC11 034001                          pshs    ccr
2161
 00FFFC13 0DD900                          std             mon_DSAVE
2162
 00FFFC15 09F902                          stx             mon_XSAVE
2163
 00FFFC17 19F904                          sty             mon_YSAVE
2164
 00FFFC19 0DF906                          stu             mon_USAVE
2165
 00FFFC1B 01F0B8                          tfr             dpr,a
2166
 00FFFC1D 09790E                          sta             mon_DPRSAVE
2167
 00FFFC1F 035002                          puls    a
2168
 00FFFC21 09790F                          sta             mon_CCRSAVE
2169
 00FFFC23 1DF908                          sts             mon_SSAVE
2170
 00FFFC25 1CE003FFF                       lds             #$3FFF
2171
                                      ; todo set according to coreid
2172
 00FFFC28 07EFFFB9A                       jmp             DumpRegs
2173
 
2174
                              ;------------------------------------------------------------------------------
2175
                              ;------------------------------------------------------------------------------
2176
                              swi3_rout:
2177
 00FFFC2B 01A010                          sei
2178
 00FFFC2D 035002                          puls    a
2179
 00FFFC2F 09790F                          sta             mon_CCRSAVE
2180
 00FFFC31 03507E                          puls    D,DPR,X,Y,U
2181
 00FFFC33 0DD900                          std             mon_DSAVE
2182
 00FFFC35 09F902                          stx             mon_XSAVE
2183
 00FFFC37 19F904                          sty             mon_YSAVE
2184
 00FFFC39 0DF906                          stu             mon_USAVE
2185
 00FFFC3B 01F0B8                          tfr             dpr,a
2186
 00FFFC3D 09790E                          sta             mon_DPRSAVE
2187
 00FFFC3F 035006                          puls    D
2188
 00FFFC41 0DD90A                          std             mon_PCSAVE
2189
 00FFFC43 035006                          puls    D
2190
 00FFFC45 0DD90C                          std             mon_PCSAVE+2
2191
 00FFFC47 1DF908                          sts             mon_SSAVE
2192
 00FFFC49 1CE003FFF                       lds             #$3FFF
2193
 00FFFC4C 01C0EF                          cli
2194
 00FFFC4E 07EFFFB9A                       jmp             DumpRegs
2195
                              swi3_exit:
2196
 00FFFC51 01A010                          sei
2197
 00FFFC53 1DE908                          lds             mon_SSAVE
2198
 00FFFC55 0DC90C                          ldd             mon_PCSAVE+2
2199
 00FFFC57 034006                          pshs    d
2200
 00FFFC59 0DC90A                          ldd             mon_PCSAVE
2201
 00FFFC5B 034006                          pshs    d
2202
 00FFFC5D 0DE906                          ldu             mon_USAVE
2203
 00FFFC5F 19E904                          ldy             mon_YSAVE
2204
 00FFFC61 09E902                          ldx             mon_XSAVE
2205
 00FFFC63 034070                          pshs    x,y,u
2206
 00FFFC65 09690E                          lda             mon_DPRSAVE
2207
 00FFFC67 034002                          pshs    a
2208
 00FFFC69 0DC900                          ldd             mon_DSAVE
2209
 00FFFC6B 034006                          pshs    d
2210
 00FFFC6D 09690F                          lda             mon_CCRSAVE
2211
 00FFFC6F 034002                          pshs    a
2212
 00FFFC71 01F08A                          tfr             a,ccr
2213
 00FFFC73 01C0EF                          cli
2214
 00FFFC75 03B                             rti
2215
 
2216
                              ;------------------------------------------------------------------------------
2217
                              ;------------------------------------------------------------------------------
2218
                              irq_rout:
2219
                                      ; Reset the edge sense circuit in the PIC
2220
 00FFFC76 086002                          lda             #2                              ; Timer is IRQ #2
2221
 00FFFC78 0150B7FFFE3F006                 sta             PIC+6                   ; register 6 is edge sense reset reg
2222
 
2223
 00FFFC7D 09779A                          sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
2224
 00FFFC7F 0960DF                          lda             IrqBase                 ; get the IRQ flag byte
2225
 00FFFC81 044                             lsra
2226
 00FFFC82 09A0DF                          ora             IrqBase
2227
 00FFFC84 0840E0                          anda    #$E0
2228
 00FFFC86 0970DF                          sta             IrqBase
2229
 
2230
 00FFFC88 01507CFFFE0006E                 inc             TEXTSCR+110             ; update IRQ live indicator on screen
2231
 
2232
                                      ; flash the cursor
2233
                                      ; only bother to flash the cursor for the task with the IO focus.
2234
 00FFFC8D 0150B6FFFFFFFE0                 lda             COREID
2235
 00FFFC92 091100                          cmpa    IOFocusID
2236
 00FFFC94 026021                          bne             tr1a
2237
 00FFFC96 096114                          lda             CursorFlash             ; test if we want a flashing cursor
2238
 00FFFC98 02701D                          beq             tr1a
2239
 00FFFC9A 017FFF5DC                       lbsr    CalcScreenLoc   ; compute cursor location in memory
2240
*** warning 1: Long branch within short branch range could be optimized
2241
 00FFFC9D 01F002                          tfr             d,y
2242
 00FFFC9F 0A6A09002000                    lda             $2000,y                 ; get color code $2000 higher in memory
2243
 00FFFCA3 0D67C6                          ldb             IRQFlag                 ; get counter
2244
 00FFFCA5 054                             lsrb
2245
 00FFFCA6 044                             lsra
2246
 00FFFCA7 044                             lsra
2247
 00FFFCA8 044                             lsra
2248
 00FFFCA9 044                             lsra
2249
 00FFFCAA 054                             lsrb
2250
 00FFFCAB 049                             rola
2251
 00FFFCAC 054                             lsrb
2252
 00FFFCAD 049                             rola
2253
 00FFFCAE 054                             lsrb
2254
 00FFFCAF 049                             rola
2255
 00FFFCB0 054                             lsrb
2256
 00FFFCB1 049                             rola
2257
 00FFFCB2 0A7A0A000E00000                 sta             $E00000,y               ; store the color code back to memory
2258
                              tr1a
2259
 00FFFCB7 03B                             rti
2260
 
2261
                              ;------------------------------------------------------------------------------
2262
                              ;------------------------------------------------------------------------------
2263
                              nmi_rout:
2264
 00FFFCB8 0150F6FFFFFFFE0                 ldb             COREID
2265
 00FFFCBD 086049                          lda             #'I'
2266
 00FFFCBF 08EE00028                       ldx             #TEXTSCR+40
2267
 00FFFCC2 03A                             abx
2268
 00FFFCC3 0A7804                          sta             ,x
2269
 00FFFCC5 03B                             rti
2270
 
2271
                                      org             $FFFFF0
2272
 00FFFFF0 012                             nop
2273
 00FFFFF1 012                             nop
2274
 00FFFFF2 FFFC2B                          fcw             swi3_rout
2275
 
2276
                                      org             $FFFFF8
2277
 00FFFFF8 FFFC76                          fcw             irq_rout
2278
 00FFFFFA FFF023                          fcw             start                           ; SWI
2279
 00FFFFFC FFFCB8                          fcw             nmi_rout                ; NMI
2280
 00FFFFFE FFF023                          fcw             start                           ; RST
2281
 
2282
8 warning(s) in pass 2.
2283
 
2284
SYMBOL TABLE
2285
 ASCIITODECNYBBLE 02 00FFFAC7 ASCIITOHEXNYBBLE 02 00FFFA9F BIOS_SCREENS 00 17000000 BLANKLINE 02 00FFF216
2286
 BLKCPYDST 00 00000020 BLKCPYSRC 00 0000001C   BLNKLN1 02 00FFF229 CALCSCREENLOC 02 00FFF279
2287
 CHARCOLOR 00 00000112 CHARINVEC 00 00000804 CHAROUTVEC 00 00000800 CHECKPOINT 02 00FFF0E0
2288
 CLEARSCREEN 02 00FFF1D0 CLEARSCREENJMP 02 00FFD300 COLORCODELOCATION 00 00000014 COPYSCREENTOVIRTUALSCREEN 02 00FFF1A0
2289
 COPYVIRTUALSCREENTOSCREEN 02 00FFF178    COREID 00 FFFFFFE0        CR 00 0000000D      CRLF 02 00FFD0D2
2290
     CRLF1 02 00FFD0D2    CRLFST 02 00FFF388       CS1 02 00FFF1DD       CS2 02 00FFF1F3
2291
     CS2V1 02 00FFF1AC       CS3 02 00FFF1F9      CSL1 02 00FFF293     CTRLC 00 00000003
2292
     CTRLH 00 00000008     CTRLI 00 00000009     CTRLJ 00 0000000A     CTRLK 00 0000000B
2293
     CTRLM 00 0000000D     CTRLS 00 00000013     CTRLX 00 00000018 CURSORCOL 00 00000111
2294
 CURSORFLASH 00 00000114 CURSORROW 00 00000110     CV2S1 02 00FFF184 DBGCHECKFORKEY 02 00FFF839
2295
 DBGGETKEY 02 00FFF83B     DBGK1 02 00FFF84F    DBGK10 02 00FFF89E    DBGK11 02 00FFF8F7
2296
    DBGK12 02 00FFF8FD    DBGK13 02 00FFF909    DBGK14 02 00FFF919    DBGK15 02 00FFF928
2297
    DBGK16 02 00FFF933    DBGK17 02 00FFF93C    DBGK18 02 00FFF93F     DBGK2 02 00FFF83D
2298
     DBGK3 02 00FFF854     DBGK4 02 00FFF862     DBGK5 02 00FFF86E     DBGK7 02 00FFF87E
2299
     DBGK8 02 00FFF884     DBGK9 02 00FFF898 DBGKNOTALT 02 00FFF901 DBGKNOTCAPSLOCK 02 00FFF8D0
2300
 DBGKNOTCTRL 02 00FFF888 DBGKNOTNUMLOCK 02 00FFF8B9 DBGKNOTRSHIFT 02 00FFF8A2 DBGKNOTSCROLLLOCK 02 00FFF8E7
2301
      DCCR 02 00FFF2A7      DCLF 02 00FFF32D     DCX10 02 00FFF2E1     DCX11 02 00FFF2F1
2302
     DCX12 02 00FFF2ED     DCX13 02 00FFF2FD     DCX14 02 00FFF2A5      DCX3 02 00FFF31B
2303
      DCX4 02 00FFF32F      DCX5 02 00FFF30A      DCX6 02 00FFF2B8      DCX7 02 00FFF2B4
2304
      DCX8 02 00FFF2C5      DCX9 02 00FFF2D2   DELAY3S 02 00FFF15B DISPBYTEASHEX 02 00FFF39D
2305
 DISPDWORDASHEX 02 00FFF38B DISPLAYCHAR 02 00FFF29B DISPLAYERR 02 00FFFAD5 DISPLAYSTRING 02 00FFF354
2306
 DISPLAYSTRINGCRLF 02 00FFF362 DISPLAYSTRINGDX 02 00FFFADF   DISPNYB 02 00FFF3B5  DISPNYB1 02 00FFF3C3
2307
 DISPWORDASHEX 02 00FFF394    DLY3S1 02 00FFF15E    DLY3S2 02 00FFF162 DRAM_BASE 00 10000000
2308
    DSPJ1B 02 00FFF358    DSRETB 02 00FFF360  DUMPREGS 02 00FFFB9A    DUMRTS 02 00FFF022
2309
 FIRST_CORE 00 00000001   FREEMBX 02 00000002   FREEMSG 02 00000006   FREETCB 00 0000078A
2310
 GETHEXNUMBER 02 00FFFA73  GETRANGE 02 00FFFA5A GETSCREENLOCATION 02 00FFF230 GETTWOPARAMS 02 00FFFA41
2311
      GSL1 02 00FFF23D     GTDC3 02 00FFFAD2     GTHX3 02 00FFFAC4     GTHX5 02 00FFFAAA
2312
     GTHX6 02 00FFFAB7    GTHXN1 02 00FFFA9B    GTHXN2 02 00FFFA7E       HC1 02 00FFF256
2313
   HELPMSG 02 00FFFAEF      HEX2 02 00FFD2CE      HEX4 02 00FFD2D2 HOMECURSOR 02 00FFF241
2314
 HOMECURSORJMP 02 00FFD308      ICC1 02 00FFF350      ICC2 02 00FFF352      ICR1 02 00FFF342
2315
 IGNBLANKS 02 00FFFA38 IGNBLANKS1 02 00FFFA38 INCCURSORPOS 02 00FFF331 INCCURSORROW 02 00FFF340
2316
      INCH 02 00FFF95E     INCHE 02 00FFF963    INCHEK 02 00FFF967   INCHEK1 02 00FFF97B
2317
   INCHEK2 02 00FFF979   INCHEK3 02 00FFF970      INIT 02 00FFF072 IOFOCUSID 00 00000100
2318
 IOFOCUSNDX 00 00000100   IRQBASE 00 000000DF   IRQFLAG 00 000007C6 IRQSOURCE 00 0000079A
2319
  IRQ_ROUT 02 00FFFC76  JTC_EXIT 02 00FFFC11 JUMP_TO_CODE 02 00FFFBDE  KBDI0002 02 00FFF7C5
2320
  KBDI0004 02 00FFF80A KBDITRYAGAIN 02 00FFF7FE     KBGS1 02 00FFF778     KBGS2 02 00FFF770
2321
     KBGS3 02 00FFF761     KEYBD 00 FFE30400  KEYBDACK 00 FFFFCC00  KEYBDBAD 00 FFFFCB00
2322
 KEYBDBUFFER 00 FFFFC000 KEYBDCHECKFORKEYDIRECT 02 00FFF95C KEYBDCLOSE 02 00FFF958  KEYBDCLR 00 FFE30402
2323
 KEYBDCONTROLCODES 02 00FFF600 KEYBDECHO 00 FFFFCA00 KEYBDEXTENDEDCODES 02 00FFF680 KEYBDGETID 02 00FFF79C
2324
 KEYBDGETSCANCODE 02 00FFF77D KEYBDGETSTATUS 02 00FFF761 KEYBDHEAD 00 FFFFC800   KEYBDID 00 00000124
2325
 KEYBDINIT 02 00FFF7C0 KEYBDLOCKS 00 FFFFCD00 KEYBDOPEN 02 00FFF957 KEYBDREAD 02 00FFF959
2326
 KEYBDRECVBYTE 02 00FFF700 KEYBDSEEK 02 00FFF95B KEYBDSENDBYTE 02 00FFF719 KEYBDSETLED 02 00FFF789
2327
 KEYBDTAIL 00 FFFFC900 KEYBDWAITTX 02 00FFF71F KEYBDWRITE 02 00FFF95A    KEYLED 00 00000122
2328
 KEYSTATE1 00 00000120 KEYSTATE2 00 00000121     KGID1 02 00FFF7B9  KGNOTKBD 02 00FFF7BC
2329
      KRB3 02 00FFF705      KRB4 02 00FFF715      KWT1 02 00FFF724      KWT2 02 00FFF735
2330
      LEDS 00 FFE60000    LEDXIT 02 00FFF81E    LETTER 02 00FFD2C1        LF 00 0000000A
2331
 MAX_TASKNO 00 0000003F  MONGETCH 02 00FFFA28 MONGETNONSPACE 02 00FFFA2D   MONITOR 02 00FFF996
2332
 MONITORSTART 02 00FFF991 MON_CCRSAVE 00 0000090F MON_DPRSAVE 00 0000090E MON_DSAVE 00 00000900
2333
 MON_NUMWKA 00 00000910 MON_PCSAVE 00 0000090A    MON_R1 00 00000920    MON_R2 00 00000922
2334
 MON_SSAVE 00 00000908 MON_USAVE 00 00000906 MON_XSAVE 00 00000902 MON_YSAVE 00 00000904
2335
   MSCOUNT 00 FFFFFFE4 MSGBADKEYBD 02 00FFF82A    MSGERR 02 00FFFAE7 MSGREGHEADINGS 02 00FFFB64
2336
 MSGSTARTUP 02 00FFF0BF MULTI_SIEVE 02 00FFF0F6 MULTI_SIEVE1 02 00FFF119 MULTI_SIEVE2 02 00FFF115
2337
 MULTI_SIEVE3 02 00FFF103 MULTI_SIEVE4 02 00FFF12C     NHEX4 02 00FFFB92  NMAILBOX 02 00000004
2338
   NMIBASE 00 000000DC  NMI_ROUT 02 00FFFCB8   NMSGBLK 02 00000008   NXBLANK 02 00FFFB96
2339
    ONEKEY 02 00FFD1DC     OUTCH 02 00FFF97C     PCRLF 02 00FFF374     PDATA 02 00FFF381
2340
       PIC 00 FFE3F000    PICPTR 00 00000028     PRINT 02 00FFF37E   PROMPT1 02 00FFF9B1
2341
   PROMPT2 02 00FFF9E5   PROMPT3 02 00FFF9A4   PROMPTC 02 00FFF9F0   PROMPTD 02 00FFF9FB
2342
   PROMPTF 02 00FFFA07   PROMPTJ 02 00FFFA1A  PROMPTLN 02 00FFF99D   PROMPTR 02 00FFFA1F
2343
    PSTRNG 02 00FFF370     QNDX0 00 00000780     QNDX1 00 00000782     QNDX2 00 00000784
2344
     QNDX3 00 00000786     QNDX4 00 00000788    RAMERR 02 00FFE02C   RAMTEST 02 00FFE000
2345
  RAMTEST1 02 00FFE00D  RAMTEST3 02 00FFE017  ROMTORAM 02 00FFF0E6 ROMTORAM1 02 00FFF0EC
2346
 RUNNINGID 00 00800000 RUNNINGTCB 06 00000000 SCREENCOLOR 00 00000113 SCREENLOCATION 00 00000010
2347
 SCREENLOCATION2 00 00000018  SCROLLUP 02 00FFF1FB    SCRUP1 02 00FFF208    SC_ALT 00 00000011
2348
      SC_C 00 00000021 SC_CAPSLOCK 00 00000058   SC_CTRL 00 00000014    SC_DEL 00 00000071
2349
 SC_EXTEND 00 000000E0    SC_F12 00 00000007  SC_KEYUP 00 000000F0 SC_NUMLOCK 00 00000077
2350
 SC_RSHIFT 00 00000059 SC_SCROLLLOCK 00 0000007E      SC_T 00 0000002C    SC_TAB 00 0000000D
2351
      SC_Z 00 0000001A SETKEYBOARDECHO 02 00FFF980 SHIFTEDSCANCODES 02 00FFF500 SHIFTLEFT5 02 00FFF16D
2352
 SHL_NUMWKA 02 00FFFA6A SHOWSPRITES 02 00FFF986     SIEVE 02 00FFF130    SIEVE1 02 00FFF148
2353
    SIEVE2 02 00FFF144    SIEVE3 02 00FFF135    SIEVE4 02 00FFF157 SKIP_INIT 02 00FFF08C
2354
 SPRITE_CTRL 00 FFE10000 SPRITE_EN 00 000003C0       ST1 02 00FFF079       ST3 02 00FFF069
2355
       ST6 02 00FFF030       ST7 02 00FFF03A       ST8 02 00FFF03A     START 02 00FFF023
2356
    STRPTR 00 00000024 SWI3_EXIT 02 00FFFC51 SWI3_ROUT 02 00FFFC2B       TAB 00 00000009
2357
 TCB_CURSORCOL 00 00000021 TCB_CURSORROW 00 00000020  TCB_HJCB 00 0000001C TCB_HWAITMBX 00 00000022
2358
 TCB_IOF_NEXT 00 0000002C TCB_IOF_PREV 00 00000030 TCB_MBQ_NEXT 00 00000024 TCB_MBQ_PREV 00 00000028
2359
 TCB_MMU_MAP 00 00000038 TCB_MSGPTR_D1 00 00000014 TCB_MSGPTR_D2 00 00000018 TCB_NXTRDY 00 00000000
2360
 TCB_NXTTCB 00 00000008 TCB_PRIORITY 00 00000010 TCB_PRVRDY 00 00000004 TCB_SPSAVE 00 00000034
2361
 TCB_STATUS 00 0000001E TCB_TIMEOUT 00 0000000C TEXTCLOSE 02 00FFF1CC  TEXTOPEN 02 00FFF1CB
2362
  TEXTREAD 02 00FFF1CD   TEXTREG 00 FFE0DF00   TEXTSCR 00 FFE00000  TEXTSEEK 02 00FFF1CF
2363
 TEXTWRITE 02 00FFF1CE TEXT_COLS 00 00000000 TEXT_CURPOS 00 00000022 TEXT_ROWS 00 00000001
2364
 TIMEOUTLIST 00 0000078C      TR1A 02 00FFFCB7      UCP1 02 00FFF277 UNSHIFTEDSCANCODES 02 00FFF400
2365
 UPDATECURSORPOS 02 00FFF258  W10_0001 02 00FFF740 W300_0001 02 00FFF754  WAIT10MS 02 00FFF739
2366
 WAIT300MS 02 00FFF74D    XBLANK 02 00FFD0AF      XOFF 00 00000013       XON 00 00000011
2367
328 SYMBOLS
2368
 
2369
 

powered by: WebSVN 2.1.0

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