home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / CRT6.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  7KB  |  250 lines

  1.     page    66,132
  2. ;******************************** CRT6.ASM   *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     extrn    lib_info:byte
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  16. GET_ANSI_COLOR - get color attribute used by ANSI driver.
  17. ;
  18. ; inputs:    none
  19. ; output:    AH = color attribute
  20. ;* * * * * * * * * * * * * *
  21. 
  22.     public    get_ansi_color
  23. GET_ANSI_COLOR    PROC    FAR
  24.     APUSH   BP,BX,CX,DX
  25.     XOR     BH,BH
  26.     MOV     AH,03
  27.     INT     10h            ;get cursor position (dx) and size (cx)
  28.     PUSH    DX            ;save origional cursor position
  29.     CALL    read_cursor_at_0
  30.     PUSH    AX            ;save char. read using bios
  31. ;
  32. ; setup to write char. using dos call
  33. ;    
  34.     PUSH    DS            ;save our segment
  35.     MOV     AX,CS        ;set segment
  36.     MOV     DS,AX        ;  to -cs:-
  37.     MOV     BX,0001        ;select stdout
  38.     
  39.     CALL    GAC_1        ;put address on stack
  40. GAC_1:
  41.     POP     DX            ;set dx= offset l_21b2
  42.     MOV     CX,0001
  43.     MOV     AH,40h
  44.     INT     21h            ;write stdout(bx) 1 byte(cx) data at ds:dx
  45.     CALL    read_cursor_at_0
  46.     POP     DS            ;restore data segment
  47.     MOV     BP,AX        ;save char. read using dos
  48.     XOR     BH,BH
  49.     POP     AX            ;restore char. read using bios
  50.     MOV     BL,AH        ;move bios color to -> bl
  51.     MOV     AH,09
  52.     MOV     CX,0001
  53.     PUSH    BP            ;save char. read using dos
  54.     INT     10h            ;write char.(al) bl=bios color bh=page cx=repeat
  55.     POP     BP            ;restore char. read using dos
  56.     POP     DX            ;restore origional cursor position
  57.     MOV     AH,02        ;
  58.     PUSH    BP            ;save char. read using dos
  59.     INT     10h            ;restore origional cursor posn
  60. ;                first pop of -ax- restores char read using DOS
  61.     APOP    AX,DX,CX,BX,BP
  62.     RETF
  63. GET_ANSI_COLOR    ENDP
  64.  
  65. ;----------------------    
  66. ; read_cursor_at 0 - read character at cursor position
  67. ;  inputs: none
  68. ;  output: ax = character
  69. ;
  70. read_cursor_at_0:    
  71.     MOV     AH,02
  72.     XOR     DX,DX         ;set cursor address -> 0
  73.     XOR     BH,BH        ;select page 0
  74.     INT     10h            ;set cursor position from -dx- bh=page
  75.     MOV     AH,08
  76.     INT     10h            ;read character & color at cursor -> ax
  77.     RET
  78. comment 
  79. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  80. CURSOR_ - Move cursor and set size to standard underscore.
  81. ;
  82. ; inputs:    DH = row
  83. ;            DL = column
  84. ;            
  85. ; outputs:   register -ax- is modified
  86. ;* * * * * * * * * * * * * *
  87. 
  88.     public    cursor_
  89. CURSOR_    PROC    FAR
  90.     mov    al,0
  91.     jmp    cursor_entry
  92. CURSOR_    ENDP
  93. comment 
  94. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  95. SHOW_CURSOR - move cursor to (row, col) and update cursor shape
  96. ;
  97. ; inputs:    DH = row offset from top of screen
  98. ;            DL = column offset from left side
  99. ;
  100. ; outputs:   register -ax- modified
  101. ;
  102. ; notes:     Cursor shape is underscore if INSERT is off, large block
  103. ;            if INSERT is on.
  104. ;* * * * * * * * * * * * * *
  105. 
  106.     public    SHOW_CURSOR
  107. SHOW_CURSOR    PROC    FAR
  108.      mov     al,80h
  109. cursor_entry:
  110.     pushf
  111.     APUSH   BP,BX,CX,DX,SI,ES
  112.     MOV     AH,0Fh
  113.     INT     10h            ;get video mode -> al=mode bh=page ah=pixels
  114.     MOV     AH,02
  115.     INT     10h            ;set cursor position -> -dx-
  116.     XOR     AH,AH
  117.  
  118.     mov     al,cs:lib_info.crt_rows
  119.     mov     bx,cs:lib_info.crt_seg
  120.  
  121.     mov     cx,0
  122.     mov     es,cx
  123.     MOV     CX,0507h
  124.     MOV     DX,WORD PTR ES:[0463h] ;get crt port address  mono=3b4 color=3d4
  125.     CMP     DX,03B4h        ;check if mono display
  126.     JNZ     c_color        ; jmp if color display
  127.     CMP     AL,1Dh        ;check if rows = 29
  128.     JGE     c_color        ; jmp if 29 rows or more
  129.     MOV     CX,0C0Dh
  130.     MOV     AL,2Ah
  131. c_color:
  132.     AND     BL,BYTE PTR ES:[0417h] ;
  133.     JZ      c_skip
  134.     SHR     CH,1
  135. c_skip:
  136.     CMP     AL,1Dh
  137.     JB      c_bios_set
  138.     CMP     AL,2Dh    ; '-'
  139.     JB      c_wrt_port
  140. c_bios_set:
  141.     MOV     AH,01
  142.     INT     10h            ;set text mode cursor size (cx)
  143.     JMP     c_exit
  144. c_wrt_port:
  145.     MOV     AL,0Ah
  146.     MOV     AH,CH
  147.     OUT     DX,AX
  148.     INC     AL
  149.     MOV     AH,CL
  150.     OUT     DX,AX
  151.     MOV     WORD PTR ES:[0460h],CX
  152. c_exit:
  153.     APOP    ES,SI,DX,CX,BX,BP
  154.     POPF
  155.     RETF
  156. SHOW_CURSOR    ENDP
  157. comment 
  158. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  159. HIDE_CURSOR - make hardware cursor invisible at present location
  160. ;
  161. ; inputs:    none
  162. ; outputs:   none
  163. ;
  164. ;* * * * * * * * * * * * * *
  165. 
  166.     public    HIDE_CURSOR
  167. HIDE_CURSOR    PROC    FAR
  168.     APUSH   AX,CX
  169.     MOV     CX,2020h
  170.     MOV     AH,01
  171.     PUSH    BP
  172.     INT     10h
  173.     POP     BP
  174.     APOP    CX,AX
  175.     RETF
  176. HIDE_CURSOR    ENDP
  177. comment 
  178. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  179. BLINK_ON:  enable blinking attriutes
  180. ;
  181. ; inputs: none
  182. ; output: none
  183. ;
  184. ; notes:  The opposite of blink is intenisified colors.  The normal default
  185. ;         is blink on.
  186. ;* * * * * * * * * * * * * *
  187. 
  188.     public    BLINK_ON
  189. BLINK_ON        PROC    FAR
  190.     PUSH    BX
  191.     MOV     BX,0001
  192.     JMP     blink_entry
  193. BLINK_ON ENDP
  194. comment 
  195. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  196. BLINK_OFF:  disable blinking attriutes
  197. ;
  198. ; inputs: none
  199. ; output: none
  200. ;
  201. ; note: Blink off turns intensified color selection on.  The default at
  202. ;       boot time is blink on.
  203. ;* * * * * * * * * * * * * *
  204. 
  205.     public    BLINK_OFF
  206. BLINK_OFF    PROC    FAR
  207.     PUSH    BX
  208.     MOV     BX,0000
  209. blink_entry:
  210.     APUSH   AX,DX,ES
  211.     SUB     AX,AX
  212.     MOV     ES,AX
  213.     MOV     AL,BYTE PTR ES:[0487h]    ;get ega/vga control flag
  214.     OR      AL,AL
  215.     JNZ     ega_vga_blink            ;jmp if flag seems active
  216. ;
  217. ; program mono/cga controller directly
  218. ;     
  219.     MOV     DX,WORD PTR ES:[0463h]    ;get crt port address
  220.     ADD     DL,04
  221.     MOV     AL,BYTE PTR ES:[0465h]    ;current mode select register setting
  222.     OR      BX,BX            ;bx=0(BLINK_OFF)  bx=1(BLINK_ON)
  223.     JZ      cga_mono_boff        ;jmp if blink off request
  224.     OR      AL,20h
  225.     JMP     cga_mono_bon
  226. ;
  227. ; blink off
  228. ;    
  229. cga_mono_boff:
  230.     AND     AL,0DFH            ;disable blink bit
  231. cga_mono_bon:
  232.     OUT     DX,AL
  233.     MOV     BYTE PTR ES:[0465h],AL    ;set new mode select reg data
  234.     JMP     blink_exit
  235. ;
  236. ; ega/vga blink setting
  237. ;    
  238. ega_vga_blink:
  239.     MOV     AX,1003h
  240.     INT     10h                ;bx=0(BLINK_OFF)  bx=1(BLINK_ON)
  241. blink_exit:
  242.     APOP    ES,DX,AX
  243.     POP     BX
  244.     RETF
  245. BLINK_OFF    ENDP
  246.  
  247. LIBSEG    ENDS
  248.     end
  249.