Skip to content

Commit 8fd1530

Browse files
committed
Option to use BDA-set KB buffer pointers, fix calculation for light pen mode 6
1 parent c36afca commit 8fd1530

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/GLABIOS.ASM

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ FDC_ZERO_BDA = 0 ; clear FDC FIFO buffer between ops
266266
FDC_ERR_SEC_CT = 0 ; On error, 0=always return 0 sectors
267267
; 1=return partial/successful sector count
268268
KB_HLT_WAIT = 1 ; Halt CPU during KB wait
269+
KB_BUF_READ_BDA = 0 ; 1=use BDA KB st/end ptrs, 0=fixed offsets
269270
MBR_CHECK = 0 ; Verify magic number of DOS MBR at boot
270271
; note: DOS 1.0 does not use MBR, so
271272
; will not boot if this is enabled
@@ -765,6 +766,7 @@ POST_M_UNIT EQU <'MB'> ; MB size
765766
CR EQU 0DH ; Carriage return
766767
LF EQU 0AH ; Line feed
767768
BS EQU 08H ; Backspace ASCII
769+
TAB EQU 09H ; Tab ASCII
768770
BELL EQU 07H ; BELL ASCII
769771
SYN EQU 16H ; SYN C0 control char
770772
VL EQU 0B3H ; vertical line
@@ -2980,7 +2982,7 @@ LPT_TIME DB 4 DUP(?) ; 78H Time-out value for LPT1-4 (in # of 64K LOOPs)
29802982
COM_TIME_B EQU $-_BDA ; Low byte hack to force short sign-extend encoding
29812983
COM_TIME DB 4 DUP(?) ; 7CH Time-out value for COM1-4
29822984
KB_BUF_ST DW ? ; 80H Keyboard buffer start
2983-
DW ? ; 82H Keyboard buffer end
2985+
KB_BUF_EN DW ? ; 82H Keyboard buffer end
29842986
ORG 08BH
29852987
FD_LR DB ? ; 8BH Last diskette data rate selected
29862988
ORG 08FH
@@ -6482,9 +6484,15 @@ KB_WAIT_READ_1:
64826484
JE KB_WAIT_READ ; if so, buffer is empty
64836485
XCHG AX, SI ; SI = tail
64846486
LODSW ; AX = buffer[tail], SI = next
6487+
IF KB_BUF_READ_BDA EQ 1
6488+
CMP SI, KB_BUF_EN ; is next >= end of buffer?
6489+
JB KB_GET_READ ; if not, get tail value
6490+
MOV SI, KB_BUF_ST ; otherwise, wrap next to buffer top
6491+
ELSE
64856492
CMP SI, KB_BUF_END_B ; is next >= end of buffer?
64866493
JB KB_GET_READ ; if not, get tail value
64876494
MOV SI, OFFSET KB_BUF ; otherwise, wrap next to buffer top
6495+
ENDIF
64886496
KB_GET_READ:
64896497
MOV KB_BUF_HD, SI ; head ptr = next
64906498
INT_16_DONE:
@@ -7069,9 +7077,15 @@ KB_INT_IS_PAUSE:
70697077
KB_INT_PUT_BUFFER:
70707078
MOV DI, KB_BUF_TL ; DI = tail ptr
70717079
LEA SI, [DI][2] ; SI = next (maybe)
7080+
IF KB_BUF_READ_BDA EQ 1
7081+
CMP SI, KB_BUF_EN ; is next >= end of buffer?
7082+
JB KB_INT_CHECK_FULL ; if not, check if buffer is full
7083+
MOV SI, KB_BUF_ST ; otherwise, wrap to first address
7084+
ELSE
70727085
CMP SI, KB_BUF_END_B ; is next >= end of buffer?
70737086
JB KB_INT_CHECK_FULL ; if not, check if buffer is full
70747087
MOV SI, OFFSET KB_BUF ; otherwise, wrap to first address
7088+
ENDIF
70757089
KB_INT_CHECK_FULL:
70767090
CMP SI, KB_BUF_HD ; next == head?
70777091
JE INT_KB_MEEP_DONE ; Beep if ZF - buffer is full
@@ -7117,13 +7131,12 @@ CHECK_TOP_ROW_NUM:
71177131
; Note: AH must be preserved
71187132
;
71197133
CHECK_ALT_ON:
7120-
SUB BL, '0' ; ASCII convert and test
7134+
XCHG AX, BX ; AL = input byte, save AX
7135+
SUB AL, '0' ; ASCII convert and test
71217136
JB INT_KB_NOT_ALT_000 ; jump if less than 0
7122-
CMP BL, 9
7137+
CMP AL, 9
71237138
JA INT_KB_NOT_ALT_000 ; jump if above 9
7124-
71257139
INT_KB_IS_ALT_000:
7126-
XCHG AX, BX ; AL = input byte, save AX
71277140
MOV AH, KB_ALT ; AH = partial working byte
71287141
AAD ; AL = AL + ( AH * 10 )
71297142
MOV KB_ALT, AL ; save new working byte to BDA
@@ -7135,6 +7148,7 @@ INT_KB_IS_ALT_000:
71357148
; Uses table INT_KB_ALT_SKIP
71367149
;
71377150
INT_KB_NOT_ALT_000:
7151+
XCHG AX, BX ; restore AX
71387152
MOV DI, OFFSET INT_KB_ALT_SKIP
71397153
MOV CL, 10 ; L_INT_KB_ALT_SKIP
71407154
XCHG AH, AL
@@ -7404,10 +7418,10 @@ KEY_SCAN_TBL LABEL BYTE
74047418
DB 2 DUP(0), 2 DUP(1BH) ; 00-01H None, Escape
74057419
DB '!1@2#3$4%5^6' ; 02- (Top row keys)
74067420
DB '&7*8(9)0_-+=' ; -0DH
7407-
DB 8, 8, 0, 9 ; 0E-0FH Backspace, Tab
7421+
DB BS, BS, 0, TAB ; 0E-0FH Backspace, Tab
74087422
DB 'QqWwEeRrTtYy' ; 10- (Second row keys)
74097423
DB 'UuIiOoPp{[}]' ; 1BH
7410-
DB 2 DUP(0DH) ; 1C Enter
7424+
DB 2 DUP(CR) ; 1C Enter
74117425
DB 2 DUP(01DH OR 80H) ; 1D *Ctrl
74127426
DB 'AaSsDdFfGgHh' ; 1E- (Third row keys)
74137427
DB 'JjKkLl:;"', "'", '~`' ; -29H
@@ -12050,7 +12064,7 @@ INT_10_4_EXIT:
1205012064
;
1205112065
; Input:
1205212066
; AX = calibrated memory offset
12053-
; CL = video mode
12067+
; CL = video mode (4, 5 or 6)
1205412068
; Output:
1205512069
; BX = pixel column (0-319 or 0-639)
1205612070
; CH = raster line (0-199)
@@ -12076,13 +12090,13 @@ INT_10_4_GFX:
1207612090
;----------------------------------------------------------------------------;
1207712091
; Multiply column according to graphics mode
1207812092
;
12079-
CMP CL, 6 ; is 640x200 mode?
12080-
JNE INT_10_4_LOW ; if not, jump
12093+
SHR CL, 1 ; is 640x200 mode 6?
12094+
JNP INT_10_4_LOW ; jump if mode 4 or 5
1208112095
SHL AL, 1 ; DL = col (DL) * 2
1208212096
INT_10_4_LOW:
1208312097
MOV CL, 3 ; shift counter 3 for * 8
1208412098
MOV BX, AX ; BL = DL for pixel column
12085-
CBW ; zero extend BL
12099+
XOR AH, AH ; zero extend to word
1208612100
SHL AX, CL ; BX = DL * 8
1208712101
XCHG AX, BX ; return as BX
1208812102
DEC CX ; shift counter 2 for / 4

0 commit comments

Comments
 (0)