home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / tplib21.zip / INSTALL.EXE / CRTVDU.ASM < prev    next >
Assembly Source File  |  1993-06-24  |  8KB  |  227 lines

  1. ;               TURBO PASCAL LIBRARY 2.1
  2. ;               Display control module
  3.  
  4.                 TITLE   UNIT ENHCON: Display control module
  5.                 PAGE    66,132
  6.                 %BIN    12
  7.  
  8. BIOS_VIDEO      MACRO   SERVICE                 ; Call BIOS video service
  9.                 IFNB    <SERVICE>
  10.                 MOV     AH,&SERVICE
  11.                 ENDIF
  12.                 INT     10H
  13.                 ENDM
  14.  
  15.  
  16.                 EXTRN   CGACURSOR: BYTE
  17.  
  18. CODE            SEGMENT WORD
  19.                 ASSUME  CS:CODE
  20.                 LOCALS
  21.                 PUBLIC  GACHECK,COLORDISPLAY,MAXCURSORSIZE,SETABSCRSR,GETCURSOR
  22.                 PUBLIC  HIDECURSOR,CURSORHIDDEN,GETDISPLAYPAGE
  23.                 PUBLIC  READDISPLAY,WRITEDISPLAY
  24.  
  25.  
  26. ;               FUNCTION GAcheck: BYTE;
  27. ;               Checks what type of graphics adapter is installed.
  28. ;               Returns 2 if EGA, 1 if VGA, 0 otherwise.
  29. ;               If VGA present, turns on CGA cursor emulation
  30.  
  31. GACHECK         PROC    NEAR
  32.                 PUSH    BP
  33.                 MOV     AX,1A00H                ; Call display code service
  34.                 BIOS_VIDEO                      ; DCC only on VGA and PS/2
  35.                 CMP     AL,1AH
  36.                 JNE     @@L1                    ; Jump if DCC not supported
  37.                 CMP     BL,07H                  ; Code for VGA monochrome
  38.                 JE      @@VGA
  39.                 CMP     BL,08H                  ; Code for VGA color
  40.                 JE      @@VGA
  41.                 CMP     BL,04H                  ; Code for EGA color
  42.                 JE      @@EGA
  43.                 CMP     BL,05H                  ; Code for EGA monochrome
  44.                 JE      @@EGA
  45. @@L1:           MOV     BX,0FF10H
  46.                 BIOS_VIDEO  12H                 ; Get EGA config.
  47.                 AND     BH,0FEH
  48.                 JZ      @@EGA                   ; EGA present
  49.                 XOR     AL,AL                   ; EGA not present; return zero
  50.                 JMP     SHORT @@L2
  51. @@VGA:          MOV     BL,34H
  52.                 MOV     AX,1200H
  53.                 BIOS_VIDEO                      ; Enable CGA cursor emulation
  54.                 MOV     AL,01H                  ; Return code for VGA
  55.                 JMP     SHORT @@L2
  56. @@EGA:          MOV     AL,02H                  ; Return code for EGA
  57. @@L2:           POP     BP
  58.                 RET
  59. GACHECK         ENDP
  60.  
  61.                 PAGE
  62.  
  63.  
  64. ;               FUNCTION ColorDisplay: BOOLEAN;
  65. ;               Check current video mode and return true if color
  66.  
  67. COLORDISPLAY    PROC    FAR
  68.                 PUSH    BP
  69.                 BIOS_VIDEO  0FH                 ; Get video mode in AL
  70.                 POP     BP
  71.                 XOR     AL,07H
  72.                 JZ      @@L1                    ; Jump if mode 7 (mono text)
  73.                 MOV     AL,01H                  ; Return true if color
  74. @@L1:           RET
  75. COLORDISPLAY    ENDP
  76.  
  77.  
  78.  
  79. ;               FUNCTION  MaxCursorSize: BYTE;
  80. ;               Return maximum scan line for current video mode's cursor
  81.  
  82. MAXCURSORSIZE   PROC    FAR
  83.                 MOV     AL,07H                  ; CGA setting
  84.                 MOV     AH,[CGACURSOR]
  85.                 AND     AH,AH
  86.                 JNZ     @@L1
  87.                 MOV     AL,0DH                  ; Adjust to MDA/EGA setting
  88. @@L1:           RET
  89. MAXCURSORSIZE   ENDP
  90.  
  91.                 PAGE
  92.  
  93.  
  94. ;               PROCEDURE SetAbsCursor (size: WORD);
  95. ;               Call BIOS to adjust cursor size
  96.  
  97. SETABSCRSR      PROC    NEAR
  98.                 PUSH    BP
  99.                 BIOS_VIDEO  0FH                 ; Get current display page
  100.                 BIOS_VIDEO  03H                 ; Read cursor service
  101.                 POP     BP
  102.                 MOV     AL,CH
  103.                 AND     AL,20H                  ; Isolate cursor-hide bit
  104.                 POP     DX                      ; Keep return address
  105.                 POP     CX                      ; Get new cursor size
  106.                 PUSH    DX                      ; Replace return address
  107.                 AND     CH,0DFH                 ; Remove hide bit from size
  108.                 OR      CH,AL                   ; Add current hide status
  109.                 PUSH    BP
  110.                 BIOS_VIDEO  01H                 ; Call set-cursor service
  111.                 POP     BP
  112.                 RET
  113. SETABSCRSR      ENDP
  114.  
  115.  
  116.  
  117. ;               FUNCTION GetCursor: WORD;
  118. ;               Return current cursor size
  119.  
  120. GETCURSOR       PROC    FAR
  121.                 PUSH    BP
  122.                 BIOS_VIDEO  0FH                 ; Get current mode/page number
  123.                 PUSH    AX                      ; Save video mode
  124.                 BIOS_VIDEO  03H                 ; Read-cursor service
  125.                 AND     CH,0DFH                 ; Remove hide bit
  126.                 MOV     AX,CX
  127.                 POP     CX
  128.                 CMP     CL,07H                  ; Check for monochrome mode
  129.                 JNE     @@L1
  130.                 CMP     AX,0607H                ; If monochrome & cursor=0607H
  131.                 JNE     @@L1
  132.                 MOV     AX,0B0CH                ; Correct BIOS bug
  133. @@L1:           POP     BP
  134.                 RET
  135. GETCURSOR       ENDP
  136.  
  137.                 PAGE
  138.  
  139.  
  140. ;               PROCEDURE HideCursor (hide: BOOLEAN);
  141. ;               Set/clear cursor disable bit
  142.  
  143. HIDECURSOR      PROC    FAR
  144.                 POP     BX                      ; Get return address off stack
  145.                 POP     CX
  146.                 POP     AX                      ; Get hide flag
  147.                 PUSH    CX                      ; Restore return addr. to stack
  148.                 PUSH    BX
  149.                 PUSH    BP
  150.                 MOV     CL,5
  151.                 SHL     AL,CL                   ; Adjust boolean flag
  152.                 PUSH    AX                      ; Save flag
  153.                 BIOS_VIDEO  0FH                 ; Get video mode & display page
  154.                 BIOS_VIDEO  03H                 ; Read cursor service
  155.                 POP     AX                      ; Get hide flag
  156.                 AND     CH,0DFH                 ; Clear disable bit
  157.                 OR      CH,AL                   ; Add adjusted hide flag
  158.                 BIOS_VIDEO  01H                 ; Set cursor service
  159.                 POP     BP
  160.                 RET
  161. HIDECURSOR      ENDP
  162.  
  163.  
  164.  
  165. ;               FUNCTION  CursorHidden: BOOLEAN;
  166. ;               Return true if cursor hidden, false if enabled
  167.  
  168. CURSORHIDDEN    PROC    FAR
  169.                 PUSH    BP
  170.                 BIOS_VIDEO  0FH                 ; Get current display page no.
  171.                 BIOS_VIDEO  03H                 ; Read-cursor service
  172.                 POP     BP
  173.                 MOV     AL,CH
  174.                 AND     AL,20H                  ; Leave cursor-hide bit
  175.                 MOV     CL,05H
  176.                 SHR     AL,CL                   ; Shift into bit 0 of AL
  177.                 RET
  178. CURSORHIDDEN    ENDP
  179.  
  180.                 PAGE
  181.  
  182.  
  183. ;               FUNCTION GetDisplayPage: BYTE;
  184. ;               Returns current display page number
  185.  
  186. GETDISPLAYPAGE  PROC    FAR
  187.                 PUSH    BP
  188.                 BIOS_VIDEO  0FH
  189.                 POP     BP
  190.                 MOV     AL,BH
  191.                 RET
  192. GETDISPLAYPAGE  ENDP
  193.  
  194.  
  195.  
  196. ;               FUNCTION ReadDisplay: WORD;
  197. ;               Reads character/attribute at cursor
  198.  
  199. READDISPLAY     PROC    NEAR
  200.                 PUSH    BP
  201.                 BIOS_VIDEO  0FH                 ; Get current display page
  202.                 BIOS_VIDEO  08H                 ; Read display store
  203.                 POP     BP
  204.                 RET
  205. READDISPLAY     ENDP
  206.  
  207.  
  208. ;               PROCEDURE WriteDisplay (CharAttr: WORD);
  209. ;               Write character/attribute to display at cursor
  210.  
  211. WRITEDISPLAY    PROC    NEAR
  212.                 PUSH    BP
  213.                 BIOS_VIDEO  0FH                 ; Get current display page
  214.                 MOV     BP,SP                   ; Set up stack frame pointer
  215.                 MOV     AX,[BP+4];              ; Get character & attribute
  216.                 MOV     BL,AH
  217.                 MOV     CX,0001H
  218.                 BIOS_VIDEO  09H                 ; Write to display store
  219.                 POP     BP
  220.                 RET     2
  221. WRITEDISPLAY    ENDP
  222.  
  223. CODE            ENDS
  224.  
  225.                 END
  226.  
  227.