home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / asm / wasm / video1.inc < prev    next >
Text File  |  1988-03-02  |  4KB  |  185 lines

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