home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / video1.inc < prev    next >
Text File  |  1988-08-28  |  6KB  |  198 lines

  1. ;*********************************************************
  2. ;* Show87 - (C) Copyright 1988 by Borland International  *
  3. ;* VIDEO1.INC - Include module for Show87                *
  4. ;*********************************************************
  5. ;
  6. ;=============================================================================
  7. ; Low Level Video Routines
  8. ;
  9. ; These are routines to display text and control the screen. All code is BIOS
  10. ; compatible. All registers are preserved except those used to return
  11. ; parameters. All parameters are passed through registers. VIDEO_INIT must be
  12. ; called before the other routines. It is assumed that DS = ES = CS.
  13.  
  14. ;================================================
  15. ; Global data.
  16.  
  17. Video_Mode      db ?         ;present mode
  18. Video_Page      db ?         ;active page
  19. Video_Cols      db ?         ;screen columns
  20.  
  21. ;================================================
  22. ; Execute the video interrupt 10H. Preserves the
  23. ; extraneous registers not explicitly preserved
  24. ; by the interrupt.
  25. ;
  26. ; Passes all registers back and forth
  27. ; tranparently, except for DI, SI, and BP.
  28. ;==================================================
  29. ;
  30. Video_Int10 proc near
  31.         push    di
  32.         push    si
  33.         push    bp
  34.         int     10h                     ;call video
  35.         pop     bp
  36.         pop     si
  37.         pop     di
  38.         ret
  39.  endp           ;Video_Int10
  40.  
  41. ;================================================
  42. ; Initialize the video parameters.
  43. ;================================================
  44. ;
  45. Video_Init proc near
  46.          push   ax
  47.          push   bx
  48.          mov    ah, 15                  ;function
  49.          call   Video_Int10             ;interrupt 10H
  50.          mov    Video_Mode, al          ;save mode
  51.          mov    Video_Cols, ah          ;save columns
  52.          mov    Video_Page, bh          ;save page
  53.          pop    bx
  54.          pop    ax
  55.          ret
  56.  endp           ;Video_Init
  57.  
  58. ;================================================
  59. ; Read the cursor position.
  60. ;
  61. ; Out: DH= row; DL= column.
  62. ;=================================================
  63. ;
  64. Video_Cget proc near
  65.          push   ax
  66.          push   bx
  67.          push   cx
  68.          mov    ah, 3                   ;function
  69.          mov    bh, Video_Page          ;page
  70.          call   Video_Int10             ;interrupt 10H
  71.          pop    cx
  72.          pop    bx
  73.          pop    ax
  74.          ret
  75.  endp           ;Video_Cget
  76.  
  77. ;================================================
  78. ; Set the cursor position.
  79. ;
  80. ; In: DH= row; DL= column.
  81. ;=================================================
  82. ;
  83.  
  84. Video_Cset proc near
  85.          push   ax
  86.          push   bx
  87.          mov    ah, 2                   ;function
  88.          mov    bh, Video_Page          ;page
  89.          call   Video_Int10             ;interrupt 10H
  90.          pop    bx
  91.          pop    ax
  92.          ret
  93.  endp           ;Video_Cset
  94.  
  95. ;================================================
  96. ; Advance the cursor some number of columns. Does
  97. ; NOT wrap around. When the last column is
  98. ; reached, the cursor is not moved any further.
  99. ;
  100. ; In: CL= columns to advance.
  101.  
  102. Video_Cadv proc near
  103.          push   ax
  104.          push   cx
  105.          push   dx
  106.  
  107.          call   Video_Cget              ;get cursor location
  108.          mov    al, Video_Cols          ;get the screen columns
  109.          dec    al                      ;last screen column
  110.          cmp    al, dl                  ;check if at end
  111.          jae    Vidcad1
  112.          sub    al, dl                  ;get available columns for move
  113.          cmp    cl, al                  ;check if past end
  114.          jbe    Vidcad2
  115.          mov    cl, al                  ;set to maximum
  116.  
  117. Vidcad1 :
  118.          add    dl, cl                  ;new column
  119.          call   Video_Cset              ;move to new location
  120.  
  121. Vidcad2 :
  122.          pop    dx
  123.          pop    cx
  124.          pop    ax
  125.          ret
  126.  endp           ;Video_Cadv
  127.  
  128. ;================================================
  129. ; Write multiple characters with an attribute to
  130. ; the present cursor location.
  131. ;
  132. ; In: al= character; BL= attribute; CX= count.
  133. ;=================================================
  134. ;
  135. Video_Wchrs proc near
  136.          or     cx, cx                  ;check if none
  137.          jz     Vidwch1
  138.  
  139.          push   ax
  140.          push   bx
  141.          mov    ah, 9                   ;function
  142.          mov    bh, Video_Page          ;page
  143.          call   Video_Int10             ;interrupt 10H
  144.          call   Video_Cadv              ;advance cursor
  145.          pop    bx
  146.          pop    ax
  147.  
  148. Vidwch1  :
  149.         ret
  150.  endp           ;Video_Wchrs
  151.  
  152. ;================================================
  153. ; Write a single character and attribute to the
  154. ; present cursor location.
  155. ;
  156. ; In: AL= character; BL= attribute.
  157. ;=================================================
  158. Video_Wchr proc near
  159.          push   cx
  160.          mov    cx, 1                   ;count
  161.          call   Video_Wchrs             ;write character
  162.          pop    cx
  163.          ret
  164.  endp           ;Video_Wchr
  165.  
  166. ;================================================
  167. ; Scroll a portion of the screen up.
  168. ;
  169. ; In: DH= upper left hand row; DL= upper left
  170. ; hand column; CH= lower left hand row; cl= lower
  171. ; left hand column; AL= lines to scroll (0 means
  172. ; clear instead of scroll); BL= attribute to use.
  173. ;=================================================
  174. ;
  175. Video_Spag proc near
  176.          push   ax
  177.          mov    ah, 6                   ;function
  178.          call   Video_Int10             ;interrupt 10H
  179.          pop    ax
  180.          ret
  181.  endp           ;Video_Spag
  182.  
  183. ;================================================
  184. ; Clear a portion of the screen.
  185. ;
  186. ; In: DH= upper left hand row; DL= upper left
  187. ; hand column; CH= lower left hand row; cl= lower
  188. ; left hand column; BL= attribute to use.
  189. ;================================================
  190. ;
  191. Video_Cpag proc near
  192.          push   ax
  193.          sub    al, al                  ;scroll lines zero
  194.          call   Video_Spag              ;clear screen
  195.          pop    ax
  196.          ret
  197.  endp           ;Video_Cpag
  198.