-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrom.asm
3283 lines (3050 loc) · 57.5 KB
/
rom.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;
; Replacement boot ROM for the RC2014 smaller configurations.
;
; (C) 2019-2020 Alan Cox
;
; Font
; Copyright (C) 1999, 2000, 2004 Michael Reinelt <michael@reinelt.co.at>
; Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net
; Slightly tweaked for Fuzix to put back a proper '~' symbol
;
; This ROM is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2, or (at your option)
; any later version.
;
; This ROM is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
;
VERSION equ 0003h
XMTIMER equ 0000h ; cycles of constat before we give up
; reset each valid block
ACK equ 6
EOT equ 4
NAK equ 21
SOH equ 1
org 0
rst0:
di
ld sp,0ffffh
jp start
nop
rst8: ; print char in A, preserve BC-HL
push bc
push de
push hl
ld c,a
jr rst8con
nop
nop
rst10: ; get a char in A, preserve BC-HL
push bc
push de
push hl
call conin
jr poppers
rst18: ; test for input ready, preserve BC-HL
push bc ; on return A = 255 for yes, 0 for no
push de
push hl
call const
jr poppers
rst20:
jp strout
nop
nop
nop
nop
nop
rst28:
nop
nop
nop
nop
nop
nop
nop
nop
rst30:
nop
nop
nop
nop
nop
nop
nop
nop
rst38:
reti
rst8con:
call conout
poppers:
pop hl
pop de
pop bc
ret
start:
ld a,0ffh
out (00h),a ; debug
;
; Start by tring to do UART detection without writing to
; RAM. Get a first letter out any way we can so the user
; has diagnostics
;
;
; We may have to slip in some very early platform detection
; to also support Tom's SBC and the Linc80
;
ld a,040h
defb 0cbh,037h
jp m,is_z80
ld a,0aah
out (00h),a ; debug
;
; Configure the CPU. Assume worst case as we can more
; easily figure out what degree of borked the processor
; is once up and running.
;
ld c,0ffh ; BTIR
; ld l,08ch ; turn on max wait states,turn off mp
ld l,00h ; turn off wait states, turn off mp
; BTIR affect bottom half of address space
defb 0edh, 6eh ; LDCTL (C),HL
ld c,02h ; BTCR
; ld l,0ffh ; max wait sates for everything
ld l,00h ; wait states off
; BTCR affects high memory (8MB+) and I/O
defb 0edh, 6eh ; LDCTL (C),HL
ld c,12h ; CCR
ld l,020h ; cache code only
defb 0edh, 6eh ; LDCTL (C),HL
defb 0edh, 65h ; and flush them
ld c,08h
ld l,0ffh ; control space
defb 0edh, 6eh ; LDCTL (C),HL
xor a
out (0xEB),a ; Turn off DRAM refreshing
;
; Z280 - so use internal UART
;
ld c,08h
ld l,0feh
defb 0edh, 6eh ; LDCTL (C),HL
; Internal UART I/O space
ld a,0c2h ; x16 8bit no parity, ext clock
out (10h),a
ld a,80h
out (12h),a ; transmitter on
out (14h),a ; receiver on
; Say hello
waittx:
in a,(12h)
rra
jr nc,waittx
ld a,'R'
out (18h),a
ld c,08h
ld l,00h
db 0edh,06eh
ld a,0abh
out (00h),a ; debug
ld hl,z280func
ld de,noauxfunc
ld a,4
jp init_ram
z280func:
defw z280out
defw z280in
defw z280poll
defw z280opoll
;
; The I/O bank switching is annoying!
;
z280out:
push bc
push hl
ld c,08h
ld l,0feh
defb 0edh,06eh
ld b,a
waito:
in a,(012h)
rra
jr nc, waito
ld a,b
out (018h),a
ld c,08h
ld l,00h
defb 0edh,06eh
pop hl
pop bc
ret
z280in:
push bc
push hl
ld c,08h
ld l,0feh
defb 0edh,06eh
in a,(016h)
ld c,08h
ld l,00h
defb 0edh,06eh
pop hl
pop bc
ret
z280poll:
push bc
push hl
ld c,08h
ld l,0feh
defb 0edh,06eh
in a,(014h)
ld c,08h
ld l,00h
defb 0edh,06eh
pop hl
pop bc
and 10h
ret
z280opoll:
push bc
push hl
ld c,08h
ld l,0feh
defb 0edh,06eh
in a,(012h)
ld c,08h
ld l,00h
defb 0edh,06eh
pop hl
pop bc
and 01h
ret
is_z80:
ld a,0cch
out (00h),a ; debug
;
; ACIA detection: TX ready will be 1. Reset will force TX
; ready to 0. If that fails it's not an ACIA
in a,(0a0h)
and 2
jr z, not_acia
ld a,03h
out (0a0h),a
in a,(0a0h)
and 2
jr nz, not_acia
ld a,02h
out (0a0h),a
ld a,096h ; RTS low, 8N1, no ints
out (0a0h),a
ld a,'R'
out (0a1h),a ; Start printing early
ld hl, aciafunc
ld de, noauxfunc
ld a,1
jp init_ram
aciafunc:
defw aciaout
defw aciain
defw aciapoll
defw aciaopoll
ret255: ld a,255
ret
noauxfunc:
defw ret255
defw ret255
defw ret255
defw ret255
aciaout:
ld b,a
aciaow:
in a,(0a0h)
and 02h
jr z,aciaow
ld a,b
out (0a1h),a
ret
aciain:
in a,(0a1h)
ret
aciapoll:
in a,(0a0h)
and 01h
ret
aciaopoll:
in a,(0a0h)
and 02h
ret
not_acia:
; 16x50 detection: There are register banks. Set the bank
; for the baud rate divider and set it to AA. If it can't be
; set to AA it's not a 16x50. If it can but switching bank
; back still shows AA it cant be a 16x50
;
in a,(0a3h)
ld e,a
or 080h
ld c,a
out (0a3h),a
in a,(0a1h)
ld d,a
ld a,0aah
out (0a1h),a
in a,(0a1h)
cp 0aah
jp nz, not_16x50
ld a,e
out (0a3h),a
in a,(0a1h)
cp 0aah
jp z, not_16x50
; Switch to the baud rable, set it to 3 (38400), then switch
; back set up 8N1, RTS low and reset the FIFO if present
ld a,c
out (0a3h),a
xor a
out (0a1h),a
ld a,3
out (0a0h),a
out (0a3h),a
dec a
out (0a4h),a
ld a,087h
out (0a2h),a
ld a,'R'
out (0a0h),a
ld hl,ns16x50func
ld de, noauxfunc
; Same again for 0a8h (seems to be cheaper to duplicate than
; mess with modifying c a lot)
in a,(0abh)
ld e,a
or 080h
ld c,a
out (0abh),a
in a,(0a9h)
ld d,a
ld a,0aah
out (0a9h),a
in a,(0a9h)
cp 0aah
ld a,2
jp nz, init_ram
ld a,e
out (0abh),a
in a,(0a9h)
cp 0aah
ld a,2
jp z, init_ram
; Switch to the baud rable, set it to 3 (38400), then switch
; back set up 8N1, RTS low and reset the FIFO if present
ld a,c
out (0abh),a
xor a
out (0a9h),a
ld a,3
out (0a8h),a
out (0abh),a
dec a
out (0ach),a
ld a,087h
out (0aah),a
ld de,ns16x50altfunc
ld a,2
jp init_ram
ns16x50func:
defw ns16x50out
defw ns16x50in
defw ns16x50poll
defw ns16x50opoll
ns16x50out:
ld b,a
ns16x50outw: in a,(0a5h)
and 20h
jr z,ns16x50outw
ld a,b
out (0a0h),a
ret
ns16x50in:
in a,(0a0h)
ret
ns16x50poll:
in a,(0a5h)
and 1
ret
ns16x50opoll:
in a,(0a5h)
and 20h
ret
ns16x50altfunc:
defw ns16x50altout
defw ns16x50altin
defw ns16x50altpoll
defw ns16x50altopoll
ns16x50altout:
ld b,a
ns16x50aoutw: in a,(0adh)
and 20h
jr z,ns16x50aoutw
ld a,b
out (0a8h),a
ret
ns16x50altin:
in a,(0a8h)
ret
ns16x50altpoll:
in a,(0adh)
and 1
ret
ns16x50altopoll:
in a,(0adh)
and 20h
ret
not_16x50:
; TODO: Add SC26C92 and QUART detection ?
; Guess we have an SIO ?
; If we wanted to support Tom's SBC as well we would need
; to check for an SIO and check how it is mapped as Tom's
; SBC has DA DB CA CB whilst RC2014 is CA DA CB DB
ld bc,0A80h ; 10 bytes port 80
ld hl,sio_setup ; load, aim
otir ; fire
ld bc,0A82h ; 10 bytes port 82
ld hl,sio_setup ; load, aim
otir ; fire
ld a,'R'
out (081h),a
ld a,2
ld hl,siofunc
ld de,siobfunc
ld a,3
jp init_ram
siofunc:
defw sioout
defw sioin
defw siopoll
defw sioopoll
siobfunc:
defw siobout
defw siobin
defw siobpoll
defw siobopoll
sioout: ld b,a
siooutw: in a,(080h)
and 4
jr z,siooutw
ld a,b
out (081h),a
ret
sioin:
in a,(081h)
ret
siopoll:
in a,(080h)
and 1
ret
sioopoll:
in a,(080h)
and 4
ret
siobout: ld b,a
sioboutw: in a,(082h)
and 4
jr z,sioboutw
ld a,b
out (083h),a
ret
siobin:
in a,(083h)
ret
siobpoll:
in a,(082h)
and 1
ret
siobopoll:
in a,(082h)
and 4
ret
sio_setup:
defb 000h
defb 018h
defb 004h
defb 0C4h
defb 001h
defb 018h
defb 003h
defb 0E1h
defb 005h
defb 0EAh
;
; Console helpers. These should avoid destroying DE to keep our BIOS
; users happy
;
; These implement the corresponding CP/M BIOS functions.
;
conout:
ld hl,(confunc)
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
ld a,c
jp (hl)
conin:
push ix
ld ix,(confunc)
conin2:
ld l,(ix + 4)
ld h,(ix + 5)
coninw: call jphl
or a
jr z,coninw
ld l,(ix + 2)
ld h,(ix + 3)
pop ix
jp (hl)
const:
push ix
ld ix,(confunc)
conout2:
ld l,(ix + 4)
ld h,(ix + 5)
const2:
call jphl
pop ix
ld a,0
ret z
dec a
ret
conost:
push ix
ld ix,(confunc)
conost2:
ld l,(ix + 6)
ld h,(ix + 7)
jr const2
auxin:
push ix
ld ix,(auxfunc)
jr conin2
auxout:
push ix
ld ix,(auxfunc)
jr conout2
auxist:
push ix
ld ix,(auxfunc)
jr const2
auxost:
push ix
ld ix,(auxfunc)
jr conost2
strout:
push hl
ld hl,(confunc)
ld e,(hl)
inc hl
ld d,(hl)
pop hl
ex (sp),hl
push bc
stroutl:
ld a,(hl)
or a
jr z, strout_done
call jpde
inc hl
jr stroutl
strout_done: pop bc
ex (sp),hl
ret
jpde:
push de
ret
;
; PS/2 Keyboard Interface
;
LALT equ 11h
LSHIFT equ 12h
LCTRL equ 14h
CAPSLOCK equ 58h
RSHIFT equ 59h
RALT equ 91h
RCTRL equ 94h
LWIN equ 9Fh
RWIN equ 0A7h
ps2probe:
ld bc,01000h ; B 16 C 0
probewait1:
push bc
call ps2kbd_get ; Ask for a byte. We should get an FF
pop bc ; if the keyboard is attached and
inc hl ; running
ld a,h
or l
jr z, probe_noreply
bit 7,h
jr nz, probe_err
ld c,1 ; We have seen life
probe_err:
probe_noreply:
pop bc
djnz probewait1
;
; Try a reset
;
ld l,255 ; Send a reset expect an ACK
call ps2kbd_put
ld a,0fah
cp l
jr z, ps2good
call ps2kbd_get
bit 7,h
jr z, ps2good
; Failed
xor a
cp c
ret z ; Definitely a fail (return Z)
ps2good:
; Now program the keyboard to scan code 2. This is the mode
; DOS/Windows use and many keyboards today don't even
; implement the other modes, let alone get them right.
ld l,0f6h
call ps2kbd_put ; Defaults
ld l,0edh
call ps2kbd_put ; LEDs off
ld l,000h
call ps2kbd_put
ld l,0f0h ; Scan code 2
call ps2kbd_put
ld l,002h
call ps2kbd_put
ld l,0f4h
call ps2kbd_put
; Flush any noise
call ps2kbd_get
call ps2kbd_get
call ps2kbd_get
call ps2kbd_get
xor a
inc a
ret ; NZ - found
;
; Try to process a byte from the keyboard. Many codes are multibyte
; sequences so we just keep calling this until it decides itself that
; a character is pending and sets ps2pend.
;
ps2byte:
call ps2kbd_get
; negative returns are error or timeout. If so return to
; the caller
bit 7,h
ret nz
; E0 is a prefix indicating shifted codes
ld a,l
cp 0e0h
jr z, setshifted
; F0 is the keyup code
cp 0f0h
jr z, setkeyup
; If it was not a prefix try and decode it
call keycode
; As we got a non shift all the shifting flags are now
; reset
xor a
ld (keyup),a
ld (keyshifted),a
ret
setshifted:
ld a,080h
ld (keyshifted),a
ret
setkeyup:
ld a,1
ld (keyup),a
ret
;
; Attempt to turn a sequence of PS/2 codes into a character. At this
; point shifts have been accounted for
;
keycode: ; C = code
; Hack for the ugly break key stuff and multimedia keys
; that produce long streams of bytes we ignore
ld a,(keybreak)
or a
jr z,notbrk
dec a
ld (keybreak),a
ret
notbrk:
; 0E1h is the media keys, more long streams to avoid
ld a,c
cp 0e1h
jr nz, not_media
ld a,7
ld (keybreak),a
ret
not_media:
; An ACK - shouldn't have gotten here but ignore it
cp 0aah ; random ack
ret z
; An FF - the keyboard reset or got cross with us. Maybe
; we should take action but for now just cross fingers
cp 0ffh ; error
ret z
; Get the shift state and or it into the code so we fold
; the E0 codes in.
ld de,(keyshifted)
or e ; set top bit if shifted
ld c,a
ld a,(keyup)
or a
jr z,keydown
;
; Shifts into E. Adjust shift key states
;
ld de,(shift_down)
cp LSHIFT
jr nz, noulshift
res 0,e
jr doneups
noulshift:
cp RSHIFT
jr nz, nourshift
res 1,e
jr doneups
nourshift:
cp LCTRL
jr nz, noulctrl
res 2,e
jr doneups
noulctrl:
cp RCTRL
jr nz, nourctrl
res 3,e
jr doneups
nourctrl:
cp LALT
jr nz, noulalt
res 4,e
jr doneups
noulalt:
cp RALT
jr nz, nouralt
res 5,e
doneups:
ld a,e
ld (shift_down),a
nouralt: ret
;
; Key down events. Start by adjusting any shift states
;
keydown:
ld de,(shift_down)
cp LSHIFT
jr nz, nolshift
res 0,e
jr doneups
nolshift:
cp RSHIFT
jr nz, norshift
res 1,e
jr doneups
norshift:
cp LCTRL
jr nz, nolctrl
res 2,e
jr doneups
nolctrl:
cp RCTRL
jr nz, norctrl
res 3,e
jr doneups
norctrl:
cp LALT
jr nz, nolalt
res 4,e
jr doneups
nolalt:
cp RALT
jr nz, noralt
res 5,e
jr doneups
;
; Not a shift key/ Try and convert it using the key map. Allow for
; shift and control effects
;
; Capslock should invert the case if A-Z
; Numlock should invert the shift state if code 68-7D inclusive
;
noralt:
; TODO: capslock
ld b,0
ld hl,keymap
add hl,bc
ld a,(hl)
; TODO: numlock
ld de,(shift_down)
bit 0,e
jr nz, shiftmod
bit 1,e
jr nz, shiftmod
nextmod1:
bit 2,e
jr nz, ctrlmod
bit 3,e
jr nz, ctrlmod
nextmod2:
bit 4,e
jr nz, altmod
bit 5,e
jr nz, altmod
ps2queue:
; If the translation is 0 it's a key that had no meaning
; if not then queue the key
or a
ret z ; no valid key mapping
ld (ps2char),a
ld a,1
ld (ps2pend),a
ret
;
; Shifted. If not special look up in the second table half
; and use that if present
;
; A = key, C = scancode
;
shiftmod:
bit 7,c
jr nz, ps2queue
; Look to see if there is a shifted translation. If not
; keep the original
ld b,0
ld hl,keymap+080h
add hl,bc
ld d,a
ld a,(hl)
or a
jr nz,nextmod1
ld a,d
jr nextmod1
ctrlmod:
; Control just clears the top bits
and 31
jr nextmod2
altmod:
; Not clear what to do with alt. We do the classic meta key
; and set the top bit
or 128
jr ps2queue
;
; Translate the main PS/2 keys into something that kind of goes
; with the ADM 3A emulation. We could map more keys like function keys
; as non ascii; codes if we wanted.
;
; UK keymap
;
keymap:
; 00h
defb 0, 0, 0, 0, 0, 0, 0, 0
defb 0, 0, 0, 0, 0, 9, '`', 0
; 10h
defb 0, 0, 0, 0, 0, 'q', '1', 0
defb 0, 0, 'z', 's', 'a', 'w', '2', 0
; 20h
defb 0, 'c', 'x', 'd', 'e', '4', '3', 0
defb 0, ' ', 'v', 'f', 't', 'r', '5', 0
; 30h
defb 0, 'n', 'b', 'h', 'g', 'y', '6', 0
defb 0, 0, 'm', 'j', 'u', '7', '8', 0
; 40h
defb 0, ',', 'k', 'i', 'o', '0', '9', 0
defb 0, '.', '/', 'l', ';', 'p', '-', 0
; 50h
defb 0, 0, 39, 0, '[', '=', 0, 0 ; 39 is quote
defb 0, 0, 10, ']', 0, '#', 0, 0
; 60h
defb 0, '\', 0, 0, 0, 0, 8, 0
defb 0, '1', 0, '4', '7', 0, 0, 0
; 70h
defb 0, '.', '2', '5', '6', '8', 27, 0
defb 0, '+', '3', '-', '*', '9', 0, 0
; E0 00h shift codes
defb 0, 0, 0, 0, 0, 0, 0, 0
defb 0, 0, 0, 0, 0, 0, 0, 0
; E0 10h
defb 0, 0, 0, 0, 0, 'Q', '!', 0
defb 0, 0, 'Z', 'S', 'A', 'W', '"', 0
; E0 20h
defb 0, 'C', 'X';, 'D', 'E', '$', 0, 0
defb 0, 0, 'V', 'F', 'T', 'R', '%', 0
; E0 30h
defb 0, 'N', 'B', 'H', 'G', 'Y', '^', 0
defb 0, 0, 'M', 'J', 'U', '&', '*', 0
; E0 40h
defb 0, '<', 'K', 'T', 'O', ')', '(', 0
defb 0, '>', '/', 'L', ':', 'P', '_', 0
; E0 50h
defb 0, 0, '@', 0, '{', '+', 0, 0
defb 0, 0, 13, '}', 0, '~', 0
; E0 60h
defb 0, '|', 0, 0, 0, 0, 0, 0
defb 0, 0, 0, 8, 31, 0, 0, 0
; E0 70h
defb 0, 127, 10, 0, 12, 11, 0, 0
defb 0, 0, 0, 0, 0, 0, 0, 0
;
; Read a character from the PS/2 port. This isn't the same as a byte
; from the PS/2 port PS/2 codes can be several bytes long and may not
; be meaningful. We may also already have a character we read when
; the caller used ps2constat and we needed to check for one
;
ps2conin:
ld a,(ps2pend)
or a
call z, ps2char
jr z, ps2conin
ld a,(ps2char)
ret
ps2constat:
ld a,(ps2pend)
or a
jr nz, retff
call ps2char
jr nz, retff
constfail: xor a
ret
retff: ld a,255
ret
;
; Timeout long jump
;
; The caller set up abort_sp earlier. We restore the stack pointer
; return set HL to a timeout error, tell the keyboard to be quiet
; and unwind.
;
timeout:
exx
ld hl,0fffdh
ld sp, (abort_sp)