home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
tplib21.zip
/
INSTALL.EXE
/
CRTVDU.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-06-24
|
8KB
|
227 lines
; TURBO PASCAL LIBRARY 2.1
; Display control module
TITLE UNIT ENHCON: Display control module
PAGE 66,132
%BIN 12
BIOS_VIDEO MACRO SERVICE ; Call BIOS video service
IFNB <SERVICE>
MOV AH,&SERVICE
ENDIF
INT 10H
ENDM
EXTRN CGACURSOR: BYTE
CODE SEGMENT WORD
ASSUME CS:CODE
LOCALS
PUBLIC GACHECK,COLORDISPLAY,MAXCURSORSIZE,SETABSCRSR,GETCURSOR
PUBLIC HIDECURSOR,CURSORHIDDEN,GETDISPLAYPAGE
PUBLIC READDISPLAY,WRITEDISPLAY
; FUNCTION GAcheck: BYTE;
; Checks what type of graphics adapter is installed.
; Returns 2 if EGA, 1 if VGA, 0 otherwise.
; If VGA present, turns on CGA cursor emulation
GACHECK PROC NEAR
PUSH BP
MOV AX,1A00H ; Call display code service
BIOS_VIDEO ; DCC only on VGA and PS/2
CMP AL,1AH
JNE @@L1 ; Jump if DCC not supported
CMP BL,07H ; Code for VGA monochrome
JE @@VGA
CMP BL,08H ; Code for VGA color
JE @@VGA
CMP BL,04H ; Code for EGA color
JE @@EGA
CMP BL,05H ; Code for EGA monochrome
JE @@EGA
@@L1: MOV BX,0FF10H
BIOS_VIDEO 12H ; Get EGA config.
AND BH,0FEH
JZ @@EGA ; EGA present
XOR AL,AL ; EGA not present; return zero
JMP SHORT @@L2
@@VGA: MOV BL,34H
MOV AX,1200H
BIOS_VIDEO ; Enable CGA cursor emulation
MOV AL,01H ; Return code for VGA
JMP SHORT @@L2
@@EGA: MOV AL,02H ; Return code for EGA
@@L2: POP BP
RET
GACHECK ENDP
PAGE
; FUNCTION ColorDisplay: BOOLEAN;
; Check current video mode and return true if color
COLORDISPLAY PROC FAR
PUSH BP
BIOS_VIDEO 0FH ; Get video mode in AL
POP BP
XOR AL,07H
JZ @@L1 ; Jump if mode 7 (mono text)
MOV AL,01H ; Return true if color
@@L1: RET
COLORDISPLAY ENDP
; FUNCTION MaxCursorSize: BYTE;
; Return maximum scan line for current video mode's cursor
MAXCURSORSIZE PROC FAR
MOV AL,07H ; CGA setting
MOV AH,[CGACURSOR]
AND AH,AH
JNZ @@L1
MOV AL,0DH ; Adjust to MDA/EGA setting
@@L1: RET
MAXCURSORSIZE ENDP
PAGE
; PROCEDURE SetAbsCursor (size: WORD);
; Call BIOS to adjust cursor size
SETABSCRSR PROC NEAR
PUSH BP
BIOS_VIDEO 0FH ; Get current display page
BIOS_VIDEO 03H ; Read cursor service
POP BP
MOV AL,CH
AND AL,20H ; Isolate cursor-hide bit
POP DX ; Keep return address
POP CX ; Get new cursor size
PUSH DX ; Replace return address
AND CH,0DFH ; Remove hide bit from size
OR CH,AL ; Add current hide status
PUSH BP
BIOS_VIDEO 01H ; Call set-cursor service
POP BP
RET
SETABSCRSR ENDP
; FUNCTION GetCursor: WORD;
; Return current cursor size
GETCURSOR PROC FAR
PUSH BP
BIOS_VIDEO 0FH ; Get current mode/page number
PUSH AX ; Save video mode
BIOS_VIDEO 03H ; Read-cursor service
AND CH,0DFH ; Remove hide bit
MOV AX,CX
POP CX
CMP CL,07H ; Check for monochrome mode
JNE @@L1
CMP AX,0607H ; If monochrome & cursor=0607H
JNE @@L1
MOV AX,0B0CH ; Correct BIOS bug
@@L1: POP BP
RET
GETCURSOR ENDP
PAGE
; PROCEDURE HideCursor (hide: BOOLEAN);
; Set/clear cursor disable bit
HIDECURSOR PROC FAR
POP BX ; Get return address off stack
POP CX
POP AX ; Get hide flag
PUSH CX ; Restore return addr. to stack
PUSH BX
PUSH BP
MOV CL,5
SHL AL,CL ; Adjust boolean flag
PUSH AX ; Save flag
BIOS_VIDEO 0FH ; Get video mode & display page
BIOS_VIDEO 03H ; Read cursor service
POP AX ; Get hide flag
AND CH,0DFH ; Clear disable bit
OR CH,AL ; Add adjusted hide flag
BIOS_VIDEO 01H ; Set cursor service
POP BP
RET
HIDECURSOR ENDP
; FUNCTION CursorHidden: BOOLEAN;
; Return true if cursor hidden, false if enabled
CURSORHIDDEN PROC FAR
PUSH BP
BIOS_VIDEO 0FH ; Get current display page no.
BIOS_VIDEO 03H ; Read-cursor service
POP BP
MOV AL,CH
AND AL,20H ; Leave cursor-hide bit
MOV CL,05H
SHR AL,CL ; Shift into bit 0 of AL
RET
CURSORHIDDEN ENDP
PAGE
; FUNCTION GetDisplayPage: BYTE;
; Returns current display page number
GETDISPLAYPAGE PROC FAR
PUSH BP
BIOS_VIDEO 0FH
POP BP
MOV AL,BH
RET
GETDISPLAYPAGE ENDP
; FUNCTION ReadDisplay: WORD;
; Reads character/attribute at cursor
READDISPLAY PROC NEAR
PUSH BP
BIOS_VIDEO 0FH ; Get current display page
BIOS_VIDEO 08H ; Read display store
POP BP
RET
READDISPLAY ENDP
; PROCEDURE WriteDisplay (CharAttr: WORD);
; Write character/attribute to display at cursor
WRITEDISPLAY PROC NEAR
PUSH BP
BIOS_VIDEO 0FH ; Get current display page
MOV BP,SP ; Set up stack frame pointer
MOV AX,[BP+4]; ; Get character & attribute
MOV BL,AH
MOV CX,0001H
BIOS_VIDEO 09H ; Write to display store
POP BP
RET 2
WRITEDISPLAY ENDP
CODE ENDS
END