home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
egaf02.zip
/
EGAF.ASM
next >
Wrap
Assembly Source File
|
1989-11-11
|
58KB
|
2,138 lines
PAGE 60,75
TITLE DRIVERS.ASM
; Modified DRIVERS module - Jim Kyle, 11-08-89
; Based on EGA.OBJ which was in turn based on CLIPPER.LIB
; Supports all CRT layouts for UltraVision (r), VGA, EGA
;
; Does NOT change CRT layout at all; must be set before entry
;
; Adds new functions __HOME and __BRC; HOME puts cursor at
; 0,0 while BRC puts it in bottom right corner of screen. No
; value is returned from either.
;
; Also adds functions _SET25, _SET28, _SET43, and _SET50 which reset
; the CRT controllers for EGA/VGA cards to the corresponding
; numbers of lines. CALL _SET43, for example, to set 43 lines
; ---------------
; rmb - 11-10-89:
; on the EGA or the VGA, and _SET50 for 50 lines on the VGA.
; ---------------
; These three functions all use video BIOS calls (1114, 1111,
; and 1112, respectively) to assign new fonts and change the
; screen size. DO NOT USE THESE if you are also using UltraVision;
; they will fight each other!
_DATA SEGMENT WORD PUBLIC 'DATA'
_DATA ENDS
DRIVERS_TEXT SEGMENT BYTE PUBLIC 'CODE'
DRIVERS_TEXT ENDS
DGROUP GROUP _DATA
PUBLIC __COLORD, __NO_SNOW
PUBLIC __ROWOFF, __COLOFF, __MAXROW, __MAXCOL
PUBLIC __SFORE, __SBACK, __EFORE, __EBACK
PUBLIC __XFORE, __XBACK, __BORDER, __BACK
PUBLIC __SCRSIZE
PUBLIC __FKEYCNT, __IKEY, __LKEY, __IMODE
PUBLIC __X121X, __PERROR, NROWS, NCOLS
PUBLIC __SINIT, __SEND, __SHANDLE, __SETDPTR, __SETWIN
PUBLIC __COUT, __SOUT, __SETCURS, __GETCURS
PUBLIC __SETCTYP, __GETCTYP,__SCROLL, __SBOX
PUBLIC __SETSTD, __SETENH, __SETUNS, __SETATTR
PUBLIC __CLREOL, __CLREOS, __CLRALL
PUBLIC __SCRSAVE, __SCRREST, __WINSAVE, __WINREST
PUBLIC __KINIT, __KEND, __KHANDLE, __SETFKEY
PUBLIC __SET_TA, __CCLR, __CSTAT, __CIN, __BRKSTAT
PUBLIC __PINIT, __PEND, __PHANDLE, __POUT, __HOME, __BRC
PUBLIC _SET25, _SET28, _SET43, _SET50
PAGE
_DATA SEGMENT
assume CS : _DATA
assume DS : DGROUP
__COLORD dw 0 ; NZ if color card present
__NO_SNOW dw 0 ; NZ for nosnow actions
__ROWOFF dw 0 ; start of window
__COLOFF dw 0
__MAXROW dw 42 ; end of window
__MAXCOL dw 79
__SFORE dw 080h ; color codes
__SBACK dw 040h
__EFORE dw 100h
__EBACK dw 040h
__XFORE dw 100h
__XBACK dw 040h
__BORDER dw 040h
__BACK dw 040h
__SCRSIZE dw 2*25*80 ; regen buffer size in bytes
DspHdl dw 1 ; for redirecting input
CurRow dw 0 ; current cursor position
CurCol dw 0
CurSor dw 1 ; flag, 0 = cursor OFF, else ON
dw 0
VidBase dw 0 ; for direct write, not used
dw 0,0
CurAtr db 0 ; video attribute in force
__FKEYCNT dw 40
__IKEY dw 0 ; current keystroke
__LKEY dw 0 ; LASTKEY() value
__IMODE dw 0 ; debugging flag???
KbdHdl dw 0 ; DOS handle for STDIN
StrLen dw 0 ; len+far ptr to string for FKEY
StrPtr dd 0
KBfrSz dw 0 ; size of KB Buffer
KBfrPt dd 0 ; far pointer to KB Buffer
KBGetP dw 0 ; offsets within KB buffer
KBPutP dw 0
XTable dw DGROUP:Mode07 ; pointers to Xlate tables
dw DGROUP:KeyVals ; (calc from __IMODE value)
dw DGROUP:Mode168
dw DGROUP:KeyVals
dw DGROUP:Mode168
dw DGROUP:KeyVals
dw DGROUP:Mode168 ; menu mode ?
dw DGROUP:KeyVals
dw DGROUP:Mode168
dw DGROUP:KeyVals
dw DGROUP:Mode168
dw DGROUP:KeyVals
dw DGROUP:Mode168
dw DGROUP:KeyVals
dw DGROUP:Mode07
dw DGROUP:KeyVals
dw DGROUP:Mode168
dw DGROUP:KeyVals
Mode07 db 1
dw 0002 ; default return if not in table
db 2
dw 0013h, 0081h ; Ctl-S
db 2
dw 0120h, 0083h ; Alt-D
db 2
dw 012eh, 0080h ; Alt-C
db 0cdh ; force default return
Mode168 db 1 ; action codes for keys...
dw 0001 ; default return (ignore)
db 2
dw 0001h, 000Ch ; Ctl-A field left
db 2
dw 0002h, 0024h ; Ctl-B
db 2
dw 0003h, 0021h ; Ctl-C
db 2
dw 0004h, 0008h ; Ctl-D cursor right
db 2
dw 0005h, 000Fh ; Ctl-E cursor up
db 2
dw 0006h, 000Dh ; Ctl-F field right
db 2
dw 0007h, 0004h ; Ctl-G
db 2
dw 0008h, 0003h ; BkSpc
db 2
dw 0009h, 0025h ; Tab
db 2
dw 000ah, 0010h ; LF cursor down
db 2
dw 000dh, 0006h ; CR
db 2
dw 0012h, 0020h ; Ctl-R
db 2
dw 0013h, 0007h ; Ctl-S cursor left
db 2
dw 0014h, 000Bh ; Ctl-T
db 2
dw 0015h, 0005h ; Ctl-U
db 2
dw 0016h, 0015h ; Ctl-V toggle INS
db 2
dw 0017h, 0013h ; Ctl-W
db 2
dw 0018h, 0010h ; Ctl-X cursor down
db 2
dw 0019h, 000Eh ; Ctl-Y
db 2
dw 001bh, 0014h ; Esc
db 3
dw 0020h, 00ffh, 0002h ; normal chars (use)
db 2
dw 0120h, 0083 ; Alt-D
db 2
dw 012eh, 0080 ; Alt-C
db 4
dw 013bh, 0144h, 0ff4eh ; F1-F10
db 4
dw 0154h, 0171h, 0ff3fh ; F11-F40
db 2
dw 0147h, 0009h ; Home
db 2
dw 0148h, 000Fh ; Up
db 2
dw 0149h, 0020h ; PgUp
db 2
dw 014bh, 0007h ; Left
db 2
dw 014dh, 0008h ; Right
db 2
dw 014fh, 000Ah ; End
db 2
dw 0150h, 0010h ; Down
db 2
dw 0151h, 0021h ; PgDn
db 2
dw 0152h, 0015h ; Ins
db 2
dw 0153h, 0004h ; Del
db 2
dw 0173h, 000Ch ; C-Left
db 2
dw 0174h, 000Dh ; C-Right
db 2
dw 0175h, 0012h ; C-End
db 2
dw 0176h, 0023h ; C-PgDn
db 2
dw 0177h, 0011h ; C-Home
db 2
dw 0184h, 0022h ; C-PgUp
db 0cdh
KeyVals db 2
dw 013bh, 001ch ; F1 28
db 5
dw 013ch, 0144h, 0ffffh ; F2-F10 -1 -9
db 5
dw 0154h, 0171h, 0fff6h ; F11-F40 -10 -39
db 2
dw 0147h, 0001h ; Home 1
db 2
dw 0148h, 0005h ; Up 5
db 2
dw 0149h, 0012h ; PgUp 18
db 2
dw 014bh, 0013h ; Left 19
db 2
dw 014dh, 0004h ; Right 4
db 2
dw 014fh, 0006h ; End 6
db 2
dw 0150h, 0018h ; Down 24
db 2
dw 0151h, 0003h ; PgDn 3
db 2
dw 0152h, 0016h ; Ins 22
db 2
dw 0153h, 0007h ; Del 7
db 2
dw 0173h, 001ah ; C-Left 26
db 2
dw 0174h, 0002h ; C-Right 2
db 2
dw 0175h, 0017h ; C-End 23
db 2
dw 0176h, 001eh ; C-PgDn 30
db 2
dw 0177h, 001dh ; C-Home 29
db 2
dw 0184h, 001fh ; C-PgUp 31
db 0cdh
__X121X dw 0
__PERROR dw 0
PrtHdl dw 4
PrtDev dw 1
nRows db 25 ; added jk - abs max rows
nCols db 80 ; added jk - abs max cols
_DATA ENDS
PAGE
DRIVERS_TEXT SEGMENT
assume CS : DRIVERS_TEXT
assume DS : DGROUP
SetMode proc near ; used only by __SINIT
push bp
mov al,003h ; set text mode
int 010h
; mov ax,01112h ; set 8x8 ROM font (43-line)
; mov bl,000h
; int 010h
pop bp
ret
SetMode endp
PutChar proc near
push es
push si
push ax
push bx
push cx
push dx
mov bl,byte ptr CurAtr
xor bh,bh ; display page 0
mov cx,00001h ; one character
mov ah,009h ; write C+A via BIOS
int 010h
pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
PutChar endp
AdvCrsr proc near
push ax
push bx
push cx
push dx
mov dh,byte ptr CurRow
mov dl,byte ptr CurCol
inc dl
cmp dl,byte ptr __MAXCOL
jna $L13
xor dl,dl
inc dh
cmp dh,byte ptr __MAXROW
jna $L13
call ScrolUp
mov dh,byte ptr __MAXROW
$L13: mov byte ptr CurRow,dh
mov byte ptr CurCol,dl
add dh,byte ptr __ROWOFF
add dl,byte ptr __COLOFF
xor bx,bx
mov ah,002h ; update cursor via BIOS
int 010h
pop dx
pop cx
pop bx
pop ax
ret
AdvCrsr endp
DoChar proc near ; output char and step cursor
call PutChar
call AdvCrsr
ret
DoChar endp
Beep proc near ; sound the bell via BIOS
push es
push si
push cx
mov al,007h
mov ah,00Eh
int 010h
pop cx
pop si
pop es
ret
Beep endp
BkSp proc near ; backspace unless at top
push es
push si
push ax
push bx
push cx
push dx
mov dh,byte ptr CurRow ; check position
mov dl,byte ptr CurCol
test dx,0FFFFh
jz BKSpNo ; at top, ignore
dec dl
jns BksRow ; not at front
mov dl,byte ptr __MAXCOL ; at front, wrap
dec dh ; to line above
BksRow: mov byte ptr CurRow,dh
mov byte ptr CurCol,dl
call PutCur
mov al,' ' ; blank out char
call PutChar
BKSpNo: pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
BkSp endp
LnFd: push es
push si
push ax
push bx
push cx
push dx
mov dh,byte ptr CurRow
mov dl,byte ptr CurCol
inc dh
cmp dh,byte ptr __MAXROW
jna LnFdOK
call ScrolUp
mov dh,byte ptr __MAXROW
LnFdOK: mov byte ptr CurRow,dh
add dh,byte ptr __ROWOFF
add dl,byte ptr __COLOFF
xor bx,bx
mov ah,002h
int 010h
pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
CaRt: push es
push si
push ax
push bx
push cx
push dx
mov word ptr CurCol,00000h
mov dh,byte ptr CurRow
mov dl,byte ptr CurCol
add dh,byte ptr __ROWOFF
add dl,byte ptr __COLOFF
xor bx,bx
mov ah,002h
int 010h
pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
ChkLim proc near ; check CX against DX and MaxLim
cmp ch,nRows ; return CY if out of range
jnc NoGo ; DX = window limit
cmp cl,nCols ; CX = trial cursor r,c
jnc NoGo
cmp dh,nRows
jnc NoGo
cmp dl,nCols
jnc NoGo
cmp ch,dh
jnc NoGo
cmp cl,dl
NoGo: cmc
ret
ChkLim endp
AddBot: push es
push si
push ax
push bx
push cx
push dx
call ChkLim ; test for validity
jc $L24 ; out of bounds, ignore
mov al,001h ; in bounds, scroll up by 1
mov bh,byte ptr CurAtr
mov bl,bh
mov ah,006h
int 010h
$L24: pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
AddTop: push es
push si
push ax
push bx
push cx
push dx
call ChkLim
jc $L25
mov al,001h
mov bh,byte ptr CurAtr
mov bl,bh
mov ah,007h
int 010h
$L25: pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
AddNew: push es
push si
push ax
push bx
push cx
push dx
call ChkLim
jc $L26
mov al,nRows ; for faster clearing - jk
mov bh,byte ptr CurAtr
mov bl,bh
mov ah,006h
int 010h
$L26: pop dx
pop cx
pop bx
pop ax
pop si
pop es
ret
GetLim: mov ch,byte ptr __ROWOFF ; TLC of window
mov cl,byte ptr __COLOFF
mov dh,byte ptr __MAXROW ; BRC rel to window
mov dl,byte ptr __MAXCOL
add dh,ch
add dl,cl
ret ; DX = real BRC
ScrolUp proc near
push cx
push dx
call GetLim
call AddBot
pop dx
pop cx
ret
ScrolUp endp
ScrolDn proc near ; not called!
push cx
push dx
call GetLim
call AddTop
pop dx
pop cx
ret
ScrolDn endp
ClrScr proc near
push cx
push dx
call GetLim
call AddNew
pop dx
pop cx
ret
ClrScr endp
OutStr: push es
push si
push ax
push bx
push dx
mov si,__MAXROW
mov di,__MAXCOL
mov bx,cx
$L33: mov dh,byte ptr CurRow
add dh,byte ptr __ROWOFF
mov dl,byte ptr CurCol
add dl,byte ptr __COLOFF
mov cx,di
sub cx,CurCol
inc cx
cmp cx,bx
jnc $L31
sub bx,cx
push bx
push ax
xor bx,bx
mov ah,002h
int 010h
mov bl,byte ptr CurAtr
xor bh,bh
pop ax
push ax
mov ah,009h
int 010h
pop ax
pop bx
mov CurCol,00000h
cmp CurRow,si
jnc OTSEnd
inc CurRow
jmp short $L33
$L31: mov cx,bx
add CurCol,cx
push ax
xor bx,bx
mov ah,002h
int 010h
mov bl,byte ptr CurAtr
xor bh,bh
pop ax
mov ah,009h
int 010h
cmp CurCol,di ; current col past limit?
jna OTSEnd ; no
mov CurCol,00000h ; yes, do CR
cmp CurRow,si ; on last row?
jnc OTSEnd ; yes, just wrap, no scroll
inc CurRow ; no, move to next
OTSEnd: mov dh,byte ptr CurRow ; update cursor position
mov dl,byte ptr CurCol
call PutCur
pop dx
pop bx
pop ax
pop si
pop es
ret
__SINIT proc far
push bp
push si
push di
mov bp,sp
int 011h
mov __COLORD,0
mov bx,0B000h
and ax,30h
cmp ax,30h
je init1
mov __COLORD,1
mov bx,0B800h
; call SetMode ; set BIOS mode to 3 for text if color
init1: mov VidBase,bx
; xor bx,bx ; get cursor position, not needed
; mov ah,003h
; int 010h
xor ax,ax ; set cursor to HOME position
mov bx,ax
; mov al,dh
; mov bl,dl
mov CurRow,ax
mov CurCol,bx
call FAR PTR __SETSTD
mov ax,1130h ; now get row, col max values
xor dx,dx
int 10h
or dl,dl
jnz init2
mov dl,24
init2: mov byte ptr __MAXROW,dl
inc dl
mov nrows,dl
push dx
mov ah,0fh
int 10h
mov ncols,ah
mov al,ah
dec ah
mov byte ptr __MAXCOL,ah
pop bx
mul bl ; calc buffer size
add ax,ax
mov __SCRSIZE,ax
pop di
pop si
pop bp
ret
__SINIT endp
__SEND proc far ; jk 11-01-89
ret
__SEND endp
__SHANDLE proc far
push bp
push si
push di
mov bp,sp
mov ax,word ptr [bp+00Ah]
mov DspHdl,ax
pop di
pop si
pop bp
ret
__SHANDLE endp
__SETDPTR proc far
ret ; jk 11-01-89
__SETDPTR endp
__SETWIN proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr [bp+00Ah]
mov cl,byte ptr [bp+00Ch]
mov dh,byte ptr [bp+00Eh]
mov dl,byte ptr [bp+010h]
mov ax,cx
or ax,dx
jnz $L38
mov dh,nRows ; default to entire screen
mov dl,nCols
sub dx,0101h
$L38: call ChkLim
jc $L39 ; bigger than screen, ignore
sub dh,ch
sub dl,cl
mov ax,CurRow
mov bx,CurCol
add ax,__ROWOFF
add bx,__COLOFF
mov byte ptr __ROWOFF,ch
mov byte ptr __COLOFF,cl
mov byte ptr __MAXROW,dh
mov byte ptr __MAXCOL,dl
sub ax,__ROWOFF
js $L40
sub bx,__COLOFF
js $L40
cmp ax,__MAXROW
ja $L40
cmp bx,__MAXCOL
ja $L40
mov CurRow,ax
mov CurCol,bx
jmp short $L39
$L40: push ax
mov ax,00000h
push bp
mov bp,sp
xchg ax,word ptr [bp+002h]
pop bp
push ax
mov ax,00000h
push bp
mov bp,sp
xchg ax,word ptr [bp+002h]
pop bp
call FAR PTR __SETCURS
add sp,+004h
$L39: pop di
pop si
pop bp
ret
__SETWIN endp
__COUT proc far
push bp
push si
push di
mov bp,sp
mov cx,word ptr [bp+00Eh] ; length of string
jcxz $L41
les si,[bp+00Ah] ; far pointer to string
$L44: push cx
lods byte ptr es:[si]
cmp al,020h ; Ctrl char?
ja $L49 ; no, send it out
cmp al,008h ; yes, test for actions
jne $L46
call BkSp
jmp short $L51 ; then close the loop
$L46: cmp al,00Dh
jne $L47
call CaRt
jmp short $L51
$L47: cmp al,00Ah
jne $L48
call LnFd
jmp short $L51
$L48: cmp al,007h
jne $L49
call Beep
jmp short $L51
$L49: call DoChar ; send the character
$L51: pop cx
loop $L44
$L41: pop di
pop si
pop bp
ret
__COUT endp
__SOUT proc far
push bp
push si
push di
mov bp,sp
mov cx,[bp+00Eh] ; count
jcxz $L55
les si,[bp+00Ah] ; pointer to string
mov bx,__MAXCOL
mov dx,__MAXROW
$L57: lods byte ptr es:[si]
call PutChar
cmp CurCol,bx
jc $L56
cmp CurRow,dx
jnc $L55
$L56: call AdvCrsr
loop $L57
$L55: pop di
pop si
pop bp
ret
__SOUT endp
__SETCURS proc far ; CALL __setcurs WITH row, col
push bp
push si
push di
mov bp,sp
mov ax,[bp+00Ah] ; get new row value
cmp ax,__MAXROW ; test against window
ja $L58 ; out of range, ignore
mov bx,[bp+00Ch] ; get new col value
cmp bx,__MAXCOL ; test against window
ja $L58 ; out of range, ignore
mov CurRow,ax ; in range, set as current
mov CurCol,bx
add ax,__ROWOFF ; adjust to real values
add bx,__COLOFF
mov dh,al ; set up for BIOS call
mov dl,bl
xor bx,bx
mov ah,002h ; and put it there
int 010h
$L58: pop di
pop si
pop bp
ret
__SETCURS endp
__GETCURS proc far
push bp
push si
push di
mov bp,sp
mov ah,byte ptr CurRow
mov al,byte ptr CurCol
pop di
pop si
pop bp
ret
__GETCURS endp
__SETCTYP proc far
push bp
push si
push di
mov bp,sp
mov ax,word ptr [bp+00Ah]
mov word ptr CurSor,ax
mov cx,02607h
test word ptr [bp+00Ah],0FFFFh
jz $L60
mov cx,00B0Ch
test word ptr __COLORD,0FFFFh
jz $L60
mov cx,00607h
$L60: mov ah,001h
int 010h
pop di
pop si
pop bp
ret
__SETCTYP endp
__GETCTYP proc far
push bp
push si
push di
mov bp,sp
mov ax,word ptr CurSor
pop di
pop si
pop bp
ret
__GETCTYP endp
__SCROLL proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr [bp+00Ah] ; top
mov cl,byte ptr [bp+00Ch] ; left
mov dh,byte ptr [bp+00Eh] ; bottom
mov dl,byte ptr [bp+010h] ; right
add ch,byte ptr __ROWOFF
add dh,byte ptr __ROWOFF
add cl,byte ptr __COLOFF
add dl,byte ptr __COLOFF
mov ax,[bp+012h] ; number of rows
test ax,ax
jz $L61
jns $L62
neg ax
$L63: call AddTop
dec ax
jnz $L63
jmp short $L64
$L62: call AddBot
dec ax
jnz $L62
jmp short $L64
$L61: call AddNew
$L64: pop di
pop si
pop bp
ret
__SCROLL endp
PutCur: push es
push si
push dx
push cx
push bx
push ax
mov al,dh
xor dh,dh
push dx
push ax
call __SETCURS
add sp,+004h
pop ax
pop bx
pop cx
pop dx
pop si
pop es
ret
GtBxCh: lods byte ptr es:[si]
or al,al
jnz $L67
dec si
or bl,bl
jnz $L66
mov al,' ' ; default to blank
jmp short $L67
$L66: cmp bh,008h
jnc $L67
mov al,byte ptr es:[si-001h]
$L67: inc bh
ret
__SBOX proc far
push bp
push si
push di
mov bp,sp
cld
mov ax,[bp+00Eh]
cmp ax,__MAXROW
ja $L68 ; bottom is out of bounds
mov ax,[bp+010h]
cmp ax,__MAXCOL
ja $L68 ; right is out of bounds
mov ax,[bp+00Ah]
cmp ax,[bp+00Eh]
ja $L68 ; top below bottom
mov ax,[bp+00Ch]
cmp ax,[bp+010h]
jna $L69 ; left to left of right
$L68: jmp $S70
$L69: les si,[bp+012h] ; get ptr to string
xor bx,bx
$L72: cmp byte ptr es:[bx+si],000h
jz $L71 ; end of string
inc bl ; count string length
jmp $L72
$L71: mov dh,byte ptr [bp+00Ah] ; position to top
mov dl,byte ptr [bp+00Ch] ; and left
mov byte ptr CurRow,dh
mov byte ptr CurCol,dl
call PutCur
mov cx,[bp+010h] ; get right
sub cl,dl ; calc width
dec cx
call GtBxCh ; get first box char
push ax
mov ax,[bp+00Ah]
cmp ax,[bp+00Eh]
pop ax
jnz $L74 ; top <> bottom
inc cx ; were same, skip top
inc cx
jmp short $L75
$L74: push ax ; save top
mov ax,[bp+010h] ; compare cols
cmp ax,[bp+00Ch]
pop ax
jz $L75 ; right == left
push cx
mov cx,00001h
call OutStr ; put TLC char
pop cx
$L75: call GtBxCh ; get top line char
or cx,cx
jng $L77
call OutStr ; put top line
$L77: call GtBxCh ; get third char
or cx,cx
mov cx,[bp+00Eh]
jl $L78
cmp cx,[bp+00Ah]
jnz $L79
jmp $S80 ; don't draw
$L79: push cx
mov cx,00001h
call OutStr ; put TRC char
pop cx
$L78: mov dh,byte ptr [bp+00Ah] ; calc right side size
mov dl,byte ptr [bp+010h]
sub cx,[bp+00Ah]
dec cx
call GtBxCh ; get the char
push ax
mov ax,[bp+010h]
cmp ax,[bp+00Ch]
pop ax
jnz $L81 ; right <> left
inc cx
push cx
mov cx,00001h
call OutStr
pop cx
$L81: jcxz $L82 ; no count
$L83: inc dh ; draw vertical line
inc CurRow
dec CurCol
call PutCur
push cx
mov cx,00001h
call OutStr
pop cx
loop $L83
$L82: inc dh ; now do bottom
inc CurRow
call GtBxCh
push ax
mov ax,[bp+010h]
cmp ax,[bp+00Ch]
pop ax
ja $L84 ; ??????
jmp $S80
$L84: dec CurCol
call PutCur
mov cx,00001h
call OutStr
call GtBxCh
mov cx,[bp+010h]
sub cx,[bp+00Ch]
mov dl,byte ptr [bp+00Ch]
inc dl
mov byte ptr CurCol,dl
call PutCur
dec cx
jcxz $L85
call OutStr
$L85: call GtBxCh
dec dl
mov byte ptr CurCol,dl
call PutCur
mov cx,00001h
call OutStr
call GtBxCh
mov cx,[bp+00Eh]
sub cx,[bp+00Ah]
dec cx
jcxz $L86
$L87: dec dh ; do left vertical
dec CurRow
dec CurCol
call PutCur
push cx
mov cx,00001h
call OutStr
pop cx
loop $L87
$L86: call GtBxCh ; fill interior
or al,al
jz $S80
mov bx,[bp+00Eh]
sub bx,[bp+00Ah]
dec bx
or bx,bx
jz $S80
mov cx,[bp+010h]
sub cx,[bp+00Ch]
dec cx
jcxz $S80
inc dl
$L88: push cx
call OutStr
inc dh
inc CurRow
call PutCur
pop cx
dec bx
jnz $L88
$S80: mov dh,byte ptr [bp+00Ah] ; set cursor to TLC
inc dh
mov byte ptr CurRow,dh
mov dl,byte ptr [bp+00Ch]
inc dl
mov byte ptr CurCol,dl
call PutCur
$S70: pop di
pop si
pop bp
ret
__SBOX endp
DoColr: xor dl,dl
mov cx,ax
or cx,bx
test cx,08000h
jnz $L89
test cx,00010h
jz $L90
or dl,080h
$L90: test cx,00008h
jz $L91
or dl,008h
$L91: test __COLORD,0FFFFh
jnz $L92
test cx,00020h
jz $L92
or dl,001h
$L92: test ax,00080h
jz $L93
or ax,00007h
$L93: test bx,00080h
jz $L94
or bx,+007h
$L94: test cx,00100h
jz $L95
test bx,00007h
jnz $L95
or bx,+007h
$L95: test cx,00200h
jz $L89
xor ax,ax
mov bx,ax
mov dl,al
$L89: mov cl,004h
shl bl,CL
or dl,bl
and al,00Fh
or dl,al
mov byte ptr CurAtr,dl
test __COLORD,0FFFFh
jz $L96
mov ax,__BORDER
test ax,00080h
jz $L97
or ax,00007h
$L97: and ax,0000Fh
mov dx,003D9h
out dx,al
$L96: ret
__SETSTD proc far
push bp
push si
push di
mov bp,sp
mov ax,__SFORE
mov bx,__SBACK
call DoColr
pop di
pop si
pop bp
ret
__SETSTD endp
__SETENH proc far
push bp
push si
push di
mov bp,sp
mov ax,__EFORE
mov bx,__EBACK
call DoColr
pop di
pop si
pop bp
ret
__SETENH endp
__SETUNS proc far
push bp
push si
push di
mov bp,sp
mov ax,__XFORE
mov bx,__XBACK
call DoColr
pop di
pop si
pop bp
ret
__SETUNS endp
__SETATTR proc far
push bp
push si
push di
mov bp,sp
mov ax,[bp+00Ah]
or ax,[bp+00Ch]
or ax,[bp+00Eh]
or ax,[bp+010h]
or ax,[bp+012h]
or ax,[bp+014h]
or ax,[bp+016h]
or ax,[bp+018h]
jnz $L99
mov ax,00080h
mov __SFORE,ax
mov ax,00040h
mov __SBACK,ax
mov ax,00100h
mov __EFORE,ax
mov ax,00040h
mov __EBACK,ax
mov ax,00100h
mov __XFORE,ax
mov ax,00040h
mov __XBACK,ax
mov ax,00040h
mov __BORDER,ax
mov ax,00040h
mov __BACK,ax
jmp short $L100
$L99: mov ax,[bp+00Ah]
or ax,[bp+00Ch]
jz $L101
mov ax,[bp+00Ah]
mov __SFORE,ax
mov ax,[bp+00Ch]
mov __SBACK,ax
$L101: mov ax,[bp+00Eh]
or ax,[bp+010h]
jz $L102
mov ax,[bp+00Eh]
mov __EFORE,ax
mov ax,[bp+010h]
mov __EBACK,ax
$L102: mov ax,[bp+012h]
or ax,[bp+014h]
jz $L103
mov ax,[bp+012h]
mov __XFORE,ax
mov ax,[bp+014h]
mov __XBACK,ax
$L103: mov ax,[bp+016h]
or ax,ax
jz $L104
mov __BORDER,ax
$L104: mov ax,[bp+018h]
or ax,ax
jz $L100
mov __BACK,ax
$L100: call __SETSTD
pop di
pop si
pop bp
ret
__SETATTR endp
__CLREOL proc far
push bp
push si
push di
mov bp,sp
push cx
push CurCol
push CurRow
mov cx,__MAXCOL
sub cx,CurCol
inc cx
mov al,020h
call OutStr
pop CurRow
pop CurCol
mov dl,byte ptr CurCol
mov dh,byte ptr CurRow
call PutCur
pop cx
pop di
pop si
pop bp
ret
__CLREOL endp
__CLREOS proc far
push bp
push si
push di
mov bp,sp
mov ax,CurRow
push ax
mov bx,CurCol
push bx
mov cx,__MAXROW
sub cx,ax
inc cx
$L106: push cx
call __CLREOL
pop cx
dec cx
jz $L105
push cx
call LnFd
pop cx
jmp short $L106
$L105: pop CurCol
pop CurRow
mov dl,byte ptr CurCol
mov dh,byte ptr CurRow
call PutCur
pop di
pop si
pop bp
ret
__CLREOS endp
__CLRALL proc far
push bp
push si
push di
mov bp,sp
call ClrScr
mov CurRow,00000h
mov CurCol,00000h
xor dx,dx
call PutCur
pop di
pop si
pop bp
ret
__CLRALL endp
WinSav: call ChkLim
jc $L108
push CurSor
push cx
push cx
push dx
push es
push di
push ax
mov ax,00000h
push bp
mov bp,sp
xchg ax,[bp+002h]
pop bp
call __SETCTYP
add sp,+002h
pop di
pop es
pop dx
pop cx
sub dh,ch
inc dh
sub dl,cl
inc dl
mov cl,dl
xor ch,ch
mov bl,dh
xor bh,bh
pop dx
mov ax,dx
cld
$L110: push ax
push bx
push cx
$L109: push cx
push dx
push di
xor bx,bx
mov ah,002h
int 010h
xor bx,bx
mov ah,008h
int 010h
pop di
pop dx
pop cx
stosw
inc dl
loop $L109
pop cx
pop bx
pop ax
mov dl,al
inc dh
dec bx
jnz $L110
mov dh,byte ptr CurRow
mov dl,byte ptr CurCol
call PutCur
pop CurSor
push CurSor
call __SETCTYP
add sp,+002h
$L108: ret
WinRst: call ChkLim
jnc WR_OK
jmp WREnd
WR_OK: push CurSor ; save for later restore
push cx
push cx
push dx
push es
push di
push ax
mov ax,00000h
push bp
mov bp,sp
xchg ax,[bp+002h]
pop bp
call __SETCTYP ; hide the cursor
add sp,+002h
pop di
pop es
pop dx
pop cx
sub dh,ch
inc dh
sub dl,cl
inc dl
mov cl,dl
xor ch,ch
mov bl,dh
xor bh,bh
pop dx
mov ax,dx
push ds
push es
pop ds
mov si,di
cld
WRRow: push ax ; copy each row
push bx
push cx
WRChr: push cx ; copy each char
push dx
push si
xor bx,bx
mov ah,002h ; position cursor for write
int 010h
pop si
lodsw ; get from saved buffer
push si
mov bl,ah
xor bh,bh
mov cx,00001h
mov ah,009h ; write the character
int 010h
pop si
pop dx
pop cx
inc dl ; advance cursor position
loop WRChr
pop cx ; restore row count
pop bx
pop ax
mov dl,al
inc dh ; advance cursor row
dec bx ; tally row count
jnz WRRow
pop ds
mov dh,byte ptr CurRow ; restore cursor location
mov dl,byte ptr CurCol
call PutCur
pop CurSor
push CurSor
call __SETCTYP ; and un-hide it
add sp,+002h
WREnd: ret
__SCRSAVE proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr __ROWOFF
mov cl,byte ptr __COLOFF
mov dh,byte ptr __MAXROW
mov dl,byte ptr __MAXCOL
add dh,ch
add dl,cl
les di,[bp+00Ah]
call WinSav
pop di
pop si
pop bp
ret
__SCRSAVE endp
__SCRREST proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr __ROWOFF
mov cl,byte ptr __COLOFF
mov dh,byte ptr __MAXROW
mov dl,byte ptr __MAXCOL
add dh,ch
add dl,cl
les di,[bp+00Ah]
call WinRst
pop di
pop si
pop bp
ret
__SCRREST endp
__WINSAVE proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr [bp+00Ah]
mov cl,byte ptr [bp+00Ch]
mov dh,byte ptr [bp+00Eh]
mov dl,byte ptr [bp+010h]
add ch,byte ptr __ROWOFF
add cl,byte ptr __COLOFF
add dh,byte ptr __ROWOFF
add dl,byte ptr __COLOFF
les di,[bp+012h]
call WinSav
pop di
pop si
pop bp
ret
__WINSAVE endp
__WINREST proc far
push bp
push si
push di
mov bp,sp
mov ch,byte ptr [bp+00Ah]
mov cl,byte ptr [bp+00Ch]
mov dh,byte ptr [bp+00Eh]
mov dl,byte ptr [bp+010h]
add ch,byte ptr __ROWOFF
add cl,byte ptr __COLOFF
add dh,byte ptr __ROWOFF
add dl,byte ptr __COLOFF
les di,[bp+012h]
call WinRst
pop di
pop si
pop bp
ret
__WINREST endp
XltKey: cld
mov cx,ax ; save for compare
mov dx,ax ; and for default retval
$L123: lodsb
cmp al,001h
jne $L118
lodsw ; get default retval
mov dx,ax
jmp $L123 ; and go again
$L118: cmp al,002h
jne $L119
lodsw ; match for entry
cmp cx,ax
jne Skip1 ; no, try next
lodsw
jmp short $L122 ; yes, get out
$L119: cmp al,003h
jne $L120
lodsw ; check for range
cmp cx,ax
jl Skip2
lodsw
cmp cx,ax
jg Skip1 ; nope, try again
lodsw
jmp short $L122 ; yes, get out
$L120: cmp al,004h
jne $L121
lodsw
cmp cx,ax
jl Skip2
lodsw
cmp cx,ax
jg Skip1
lodsw
add ax,cx
jmp short $L122
$L121: cmp al,005h
jne $L117
lodsw
cmp cx,ax
jl Skip2
cmp cx,word ptr [si]
jg Skip2
sub cx,ax
add si,+002h
lodsw
sub ax,cx
jmp short $L122
$L117: mov ax,dx
jmp short $L122
Skip2: add si,+002h
Skip1: add si,+002h
jmp $L123
$L122: ret
KeyXlt: mov si,__IMODE ; mode index
shl si,1
shl si,1
push si ; save for action code
push ax
add si,+002h ; get second one first
mov si,XTable[si] ; from KeyVals table
call XltKey
mov __IKEY,ax ; and save key value
pop ax
pop si
mov si,XTable[si] ; then get action code
call XltKey ; from MODExx table
ret
KBWait: mov dl,0FFh
mov ah,006h
int 021h
mov ah,000h
jz KBWait ; wait for a key
cmp al,000h
jnz $L128 ; not extended
mov ah,006h
int 021h
mov ah,000h
add ax,00100h ; extended, scancode+100h
$L128: call KeyXlt
ret
StrbKB: mov ah,00Bh ; check KB status
int 021h
mov ah,000h
test ax,ax
jz $L130 ; no key
mov ax,00002h ; have keystroke
mov __IKEY,00000h
$L130: ret
BmpKbP: inc bx ; step by 2
inc bx
cmp bx,KBfrSz ; past end of ring?
jc $L132 ; no, okay
xor bx,bx ; yes, set to start
$L132: ret
GetKey: mov dl,0FFh
mov ah,006h ; get key from DOS
int 021h
mov ah,000h
jz GK2 ; no key available, out
cmp al,0
jne GK1 ; not extended, use it
mov ah,006h ; get next from DOS
int 021h
mov ah,000h
add ax,0100h ; flag as scancode
GK1: push ax
call KeyXlt ; translate it
sub ax,00080h
cmp ax,00007h
pop ax
jna $L133
mov KBGetP,00000h ; flush the buffer
mov KBPutP,00000h
$L133: mov bx,KBPutP ; get PUT offset
mov si,bx
call BmpKbP ; step to free spot
cmp bx,KBGetP ; buffer full?
jnz $L137 ; no, put it down
jmp GetKey ; yes, ignore this one
$L137: mov KBPutP,bx ; first update offset
push es
les bx,KBfrPt ; then get base
mov es:[bx+si],ax ; and store the keystroke
pop es
jmp GetKey ; now close the loop
GK2: ret
__KINIT proc far ; initialize keyboard
push bp
push si
push di
mov bp,sp
push ds
mov dx,cs ; disable Ctrl-C interrupt
mov ds,dx
mov dx,offset I23Vec
mov al,023h
mov ah,025h
int 021h
pop ds
pop di
pop si
pop bp
ret
__KINIT endp
__KEND proc far
ret ; jk 11-01-89
__KEND endp
__KHANDLE proc far
push bp
push si
push di
mov bp,sp
mov ax,[bp+00Ah]
mov KbdHdl,ax
pop di
pop si
pop bp
ret
__KHANDLE endp
__SETFKEY proc far
push bp
push si
push di
mov bp,sp
les si,[bp+00Ah]
mov word ptr StrPtr+2,es
mov word ptr StrPtr,si
mov si,[bp+00Eh]
mov StrLen,si
pop di
pop si
pop bp
ret
__SETFKEY endp
TstKey proc near
test StrLen,0FFFFh
jz $L145
les si,StrPtr
xor ah,ah
lodsb
cmp al,';' ; check for pseudo-CR
jnz $L146
mov al,00Dh
$L146: call KeyXlt
or bx,+001h
$L145: ret
TstKey endp
TakKey proc near
test StrLen,0FFFFh
jz $L147
xor ah,ah
les si,StrPtr
cld
lodsb
mov word ptr es:StrPtr,si
dec StrLen
cmp al,';'
jnz $L148
mov al,00Dh
$L148: call KeyXlt
or bx,+001h
$L147: ret
TakKey endp
TstBKy proc near
mov bx,KBGetP
cmp bx,KBPutP
jz $L149
push es
les si,KBfrPt
mov ax,es:[bx+si]
pop es
call KeyXlt
or bx,+001h
$L149: ret
TstBKy endp
GetBKy proc near
mov bx,KBGetP
cmp bx,KBPutP
jz $L150
push es
les si,KBfrPt
mov ax,es:[bx+si]
pop es
call BmpKbP
mov KBGetP,bx
call KeyXlt
or bx,+001h
$L150: ret
GetBKy endp
__SET_TA proc far
push bp
push si
push di
mov bp,sp
mov ax,[bp+00Ah]
mov word ptr KBfrPt,ax
mov ax,[bp+00Ch]
mov word ptr KBfrPt+2,ax
mov ax,[bp+00Eh]
mov KBfrSz,ax
xor ax,ax
mov KBGetP,ax
mov KBPutP,ax
pop di
pop si
pop bp
ret
__SET_TA endp
__CCLR proc far
push bp
push si
push di
mov bp,sp
call GetKey
xor ax,ax
mov KBGetP,ax
mov KBPutP,ax
mov StrLen,ax
pop di
pop si
pop bp
ret
__CCLR endp
__CSTAT proc far
push bp
push si
push di
mov bp,sp
test KBfrSz,0FFFFh
jz $L152
call GetKey
call TstKey
jnz $L154
call TstBKy
jnz $L154
xor ax,ax
$L154: jmp short $L156
$L152: call TstKey
jnz $L154
call StrbKB
$L156: pop di
pop si
pop bp
ret
__CSTAT endp
__CIN proc far
push bp
push si
push di
mov bp,sp
test KBfrSz,0FFFFh
jz $L158
$L162: call GetKey
call TakKey
jnz $L160
call GetBKy
jnz $L160
jmp $L162
$L158: call TakKey
jnz $L160
call KBWait
$L160: mov bx, __IKEY
mov __LKEY,bx
pop di
pop si
pop bp
ret
__CIN endp
__BRKSTAT proc far
push bp
push si
push di
mov bp,sp
mov ah,001h
int 016h
mov ax,00000h
jz $L164
call __CSTAT
$L164: pop di
pop si
pop bp
ret
__BRKSTAT endp
I23Vec: iret
__PINIT proc far
push bp
push si
push di
mov bp,sp
push ax
mov ax,00004h
push bp
mov bp,sp
xchg ax,[bp+002h]
pop bp
call FAR PTR __PHANDLE
add sp,+002h
mov __X121X,00000h
pop di
pop si
pop bp
ret
__PINIT endp
__PEND proc far
ret
__PEND endp
__PHANDLE proc far
push bp
push si
push di
mov bp,sp
mov bx,[bp+00Ah]
mov PrtHdl,bx
mov al,000h
mov ah,044h
int 021h
and dx,00080h
mov PrtDev,dx
pop di
pop si
pop bp
ret
__PHANDLE endp
__POUT proc far
push bp
push si
push di
mov bp,sp
mov __PERROR,00000h
mov cx,[bp+00Eh]
jcxz $L167
mov bx,PrtHdl
test PrtDev,0FFFFh
jz $L168
$L170: push cx
push ds
mov cx,00001h
lds dx,[bp+00Ah]
mov ah,040h
int 021h
pop ds
pop cx
jc $L169
inc word ptr [bp+00Ah]
loop $L170
cmp byte ptr [bp+00Ah],00Ah
jz $L171
add __X121X,cx
jmp short $L172
nop
$L171: mov __X121X,00000h
$L172: mov ax,00000h
$L169: mov __PERROR,ax
mov ax,[bp+00Eh]
sub ax,cx
jmp short $L167
nop
$L168: push ds
lds dx,[bp+00Ah]
mov ah,040h
int 021h
pop ds
jnc $L167
mov __PERROR,ax
mov ax,00000h
$L167: pop di
pop si
pop bp
ret
__POUT endp
__HOME proc far
push bp
xor dx,dx
mov CurRow,dx
mov CurCol,dx
call PutCur
pop bp
ret
__HOME endp
__VGATST proc near
mov ax,1a00h
int 10h
cmp al,1ah
je Have_VGA
xor ah,ah
mov al,0
jmp VGA_RET
Have_VGA:
xor ah,ah
mov al,bl
VGA_RET:
ret
__VGATST endp
__Scan200 proc near
push bp
mov ah,12h
mov bl,30h
mov al,0
int 10h
pop bp
ret
__Scan200 endp
__Scan350 proc near
push bp
mov ah,12h
mov bl,30h
mov al,1
int 10h
pop bp
ret
__Scan350 endp
__Scan400 proc near
push bp
mov ah,12h
mov bl,30h
mov al,2
int 10h
pop bp
ret
__Scan400 endp
__BRC proc far
push bp
mov dh,nRows
mov dl,nCols
sub dx,0101h
mov byte ptr CurRow,dh
mov byte ptr CurCol,dl
call PutCur
pop bp
ret
__BRC endp
_SET25 proc far
push bp
call __VGATST
cmp al,7
jl Cont_Set_25
call __Scan400
Cont_Set_25:
mov ax,1114h ; reprogram the CRTC
mov bx,0
int 10h
call __SINIT ; re-do screen sizes
pop bp
ret
_SET25 endp
_SET28 proc far
push bp
call __VGATST
cmp al,7
jl Cont_Set_28
call __Scan400
Cont_Set_28:
mov ax,1111h ; reprogram the CRTC
mov bx,0
int 10h
call __SINIT ; re-do screen sizes
pop bp
ret
_SET28 endp
_SET43 proc far
push bp
call __VGATST
cmp al,7
jl Cont_Set_43
call __Scan350
Cont_Set_43:
mov ax,1112h ; reprogram the CRTC
mov bx,0
int 10h
call __SINIT ; re-do screen sizes
pop bp
ret
_SET43 endp
_SET50 proc far
push bp
call __VGATST
cmp al,7
jl Cont_Set_50
call __Scan400
Cont_Set_50:
mov ax,1112h ; reprogram the CRTC
mov bx,0
int 10h
call __SINIT ; re-do screen sizes
pop bp
ret
_SET50 endp
DRIVERS_TEXT ENDS
END