home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / SUPER_C.ZIP / VLIB.ASM < prev   
Encoding:
Assembly Source File  |  1980-01-01  |  17.7 KB  |  399 lines

  1. ;               Text Video Library
  2.  
  3. _TEXT   segment byte public 'CODE'      ; Place the code in the code segment
  4.         assume  CS:_TEXT                ; Assume the CS register points to it
  5.  
  6. ; _setMod(mode)
  7. ;
  8. ; Function: Set the display mode to that specified by mode.
  9. ;
  10. ; Algorithm: Call the ROM BIOS set mode function; int 10H, AH = 0.
  11.  
  12.         public  _setMod         ; Routine is available to other modules
  13.  
  14.         mode = 4                ; Offset from BP to parameter mode
  15.  
  16. _setMod proc near               ; NEAR type subroutine
  17.         push    bp              ; Save BP register
  18.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  19.         push    si
  20.         push    di
  21.         mov     al,[bp+mode]    ; Set AL to mode
  22.         mov     ah,0            ; Set AH to 0 (set mode function)
  23.         int     10H             ; Call ROM BIOS video interrupt
  24.         pop     di
  25.         pop     si
  26.         pop     bp              ; Restore the BP register
  27.         ret                     ; Return to calling program
  28. _setMod endp                    ; End of subroutine
  29.  
  30. ; _setCTyp(start,end)
  31. ;
  32. ; Function: Set a new cursor, which starts on scan line start and ends on
  33. ; scan line end.
  34. ;
  35. ; Algorithm: Call the ROM BIOS set cursor type function; int 10H, AH = 1.
  36.  
  37.         public  _setCTyp        ; Routine is available to other modules
  38.  
  39.         start = 4               ; Offset from BP to parameter start
  40.         end = 6                 ; Offset to parameter end
  41.  
  42. _setCTyp proc near              ; NEAR type subroutine
  43.         push    bp              ; Save BP register
  44.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  45.         mov     ch,[bp+start]   ; Set CH to start
  46.         mov     cl,[bp+end]     ; Set CL to end
  47.         mov     ah,1            ; Set AH to 1 (set cursor type function)
  48.         int     10H             ; Call ROM BIOS video interrupt
  49.         pop     bp              ; Restore the BP register
  50.         ret                     ; Return to calling program
  51. _setCTyp endp                   ; End of subroutine
  52.  
  53. ; _setPos(page,row,col)
  54. ;
  55. ; Function: Set the cursor position on the page specified to the row and
  56. ; column specified.
  57. ;
  58. ; Algorithm: Call the ROM BIOS set cursor position function; int 10H, AH = 2.
  59.  
  60.         public  _setPos         ; Routine is available to other modules
  61.  
  62.         page = 4                ; Offset from BP to parameter page
  63.         row = 6                 ; Offset to parameter row
  64.         col = 8                 ; Offset to col
  65.  
  66. _setPos proc near               ; NEAR type subroutine
  67.         push    bp              ; Save BP register
  68.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  69.         push    si
  70.         push    di
  71.         mov     bh,[bp+page]    ; Set BH to the page
  72.         mov     dh,[bp+row]     ; Set DH to the row
  73.         mov     dl,[bp+col]     ; Set DL to the column
  74.         mov     ah,2            ; Set AH to 2 (set cursor position function)
  75.         int     10H             ; Call ROM BIOS video interrupt
  76.         pop     di
  77.         pop     si
  78.         pop     bp              ; Restore the BP register
  79.         ret                     ; Return to calling program
  80. _setPos endp                    ; End of subroutine
  81.  
  82. ; _getPos(page,&rowPtr,&colPtr,&startPtr,&endPtr)
  83. ;
  84. ; Function: Get the current cursor. This includes getting the row and
  85. ; column, as well as the start and end scan lines of the cursor. The
  86. ; page parameter tells which page's cursor to get.
  87. ;
  88. ; Algorithm: Call the ROM BIOS get cursor function; int 10H, AH = 3.
  89.  
  90.         public  _getPos         ; Routine is available to other modules
  91.  
  92.         page = 4                ; Offset from BP to parameter page
  93.         rowPtr = 6              ; Offset to parameter rowPtr
  94.         colPtr = 8              ; Offset to colPtr
  95.         startPtr = 10           ; Offset to startPtr
  96.         endPtr = 12             ; Offset to endPtr
  97.  
  98. _getPos proc near               ; NEAR type subroutine
  99.         push    bp              ; Save BP register
  100.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  101.         mov     bh,[bp+page]    ; Set BH to the page
  102.         mov     ah,3            ; Set AH to 3 (get cursor function)
  103.         int     10H             ; Call ROM BIOS video interrupt
  104.         xor     al,al           ; Zero AL
  105.         mov     bx,[bp+rowPtr]  ; *rowPtr = row number (with top byte zeroed)
  106.         mov     [bx],dh
  107.         mov     [bx+1],al
  108.         mov     bx,[bp+colPtr]  ; *colPtr = column number (with zero top byte)
  109.         mov     [bx],dl
  110.         mov     [bx+1],al
  111.         mov     bx,[bp+startPtr]; *startPtr = cursor scan line start
  112.         mov     [bx],ch
  113.         mov     [bx+1],al
  114.         mov     bx,[bp+endPtr]  ; *endPtr = cursor scan line end
  115.         mov     [bx],cl
  116.         mov     [bx+1],al
  117.         pop     bp              ; Restore the BP register
  118.         ret                     ; Return to calling program
  119. _getPos endp                    ; End of subroutine
  120.  
  121. ; _getLite(&rowPtr,&colPtr,&rasterPtr,&pixColPtr)
  122. ;
  123. ; Function: If the light pen button is not depressed, return FALSE.
  124. ; Otherwise, return TRUE and the location of the press in the locations
  125. ; pointed to by rowPtr, colPtr, rasterPtr, and pixColPtr.
  126. ;
  127. ; Algorithm: Call the ROM BIOS get light pen function; int 10H, AH = 4.
  128.  
  129.         public  _getLite        ; Routine is available to other modules
  130.  
  131.         rowPtr = 4              ; Offset from BP to parameter rowPtr
  132.         colPtr = 6              ; Offset to parameter colPtr
  133.         rasterPtr = 8           ; Offset to rasterPtr
  134.         pixColPtr = 10          ; Offset to pixColPtr
  135.  
  136. _getLite proc near              ; NEAR type subroutine
  137.         push    bp              ; Save BP register
  138.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  139.         mov     ah,4            ; Set AH to 4 (get light pen function)
  140.         int     10H             ; Call ROM BIOS video interrupt
  141.         or      ah,ah           ; Is the button down?
  142.         mov     ax,0            ; Assume not (i.e., return FALSE)
  143.         jz      glDone          ; Branch if it indeed wasn't down
  144.         push    bx              ; Save the BX register (the pixel column)
  145.         mov     bx,[bp+rowPtr]  ; *rowPtr = row number, with top byte zeroed
  146.         mov     [bx],dh
  147.         mov     [bx+1],al
  148.         mov     bx,[bp+colPtr]  ; *colPtr = column number
  149.         mov     [bx],dl
  150.         mov     [bx+1],al
  151.         mov     bx,[bp+rasterPtr] ; *rasterPtr = raster line
  152.         mov     [bx],ch
  153.         mov     [bx+1],al
  154.         pop     ax              ; Restore the pixel column into AX
  155.         mov     bx,[bp+pixColPtr] ; *pixColPtr = pixel column
  156.         mov     [bx],ax
  157.         mov     ax,1            ; Return TRUE
  158.  
  159. glDone: pop     bp              ; Restore the BP register
  160.         ret                     ; Return to calling program
  161. _getLite endp                   ; End of subroutine
  162.  
  163. ; _setPage(page)
  164. ;
  165. ; Function: Set the active display page.
  166. ;
  167. ; Algorithm: Call the ROM BIOS set page function; int 10H, AH = 5.
  168.  
  169.         public  _setPage        ; Routine is available to other modules
  170.  
  171.         page = 4                ; Offset from BP to parameter page
  172.  
  173. _setPage proc near              ; NEAR type subroutine
  174.         push    bp              ; Save BP register
  175.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  176.         mov     al,[bp+page]    ; Set AL to the page number
  177.         mov     ah,5            ; Set AH to 5 (set active page function)
  178.         int     10H             ; Call ROM BIOS video interrupt
  179.         pop     bp              ; Restore the BP register
  180.         ret                     ; Return to calling program
  181. _setPage endp                   ; End of subroutine
  182.  
  183. ; _scrUp(n,ulRow,ulCol,lrRow,lrCol,attr)
  184. ;
  185. ; Function: Scroll a rectangular block of the display up by n lines. The
  186. ; block to scroll has an upper left corner of row ulRow and column ulCol,
  187. ; and a lower right corner of row lrRow and column lrCol. New lines are
  188. ; filled with blanks with attribute attr.
  189. ;
  190. ; Algorithm: Call the ROM BIOS scroll up function; int 10H, AH = 6.
  191.  
  192.         public  _scrUp          ; Routine is available to other modules
  193.  
  194.         n = 4                   ; Offset from BP to parameter n
  195.         ulRow = 6               ; Offset to parameter ulRow
  196.         ulCol = 8               ; Offset to ulCol
  197.         lrRow = 10              ; Offset to lrRow
  198.         lrCol = 12              ; Offset to lrCol
  199.         attr = 14               ; Offset to attr
  200.  
  201. _scrUp  proc near               ; NEAR type subroutine
  202.         push    bp              ; Save BP register
  203.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  204.         mov     al,[bp+n]       ; Set AL to the number of lines to scroll
  205.         mov     ch,[bp+ulRow]   ; Set CH to the upper left row
  206.         mov     cl,[bp+ulCol]   ; Set CH to the upper left column
  207.         mov     dh,[bp+lrRow]   ; Set DH to the lower right row
  208.         mov     dl,[bp+lrCol]   ; Set DL to the lower right column
  209.         mov     bh,[bp+attr]    ; Set BH to the attribute to fill with
  210.         mov     ah,6            ; Set AH to 6 (scroll up function)
  211.         int     10H             ; Call ROM BIOS video interrupt
  212.         pop     bp              ; Restore the BP register
  213.         ret                     ; Return to calling program
  214. _scrUp  endp                    ; End of subroutine
  215.  
  216. ; _scrDn(n,ulRow,ulCol,lrRow,lrCol,attr)
  217. ;
  218. ; Function: Scroll a rectangular block of the display down by n lines. The
  219. ; block to scroll has an upper left corner of row ulRow and column ulCol,
  220. ; and a lower right corner of row lrRow and column lrCol. New lines are
  221. ; filled with blanks with attribute attr.
  222. ;
  223. ; Algorithm: Call the ROM BIOS scroll up function; int 10H, AH = 6.
  224.  
  225.         public  _scrDn          ; Routine is available to other modules
  226.  
  227.         n = 4                   ; Offset from BP to parameter n
  228.         ulRow = 6               ; Offset to parameter ulRow
  229.         ulCol = 8               ; Offset to ulCol
  230.         lrRow = 10              ; Offset to lrRow
  231.         lrCol = 12              ; Offset to lrCol
  232.         attr = 14               ; Offset to attr
  233.  
  234. _scrDn  proc near               ; NEAR type subroutine
  235.         push    bp              ; Save BP register
  236.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  237.         mov     al,[bp+n]       ; Set AL to the number of lines to scroll
  238.         mov     ch,[bp+ulRow]   ; Set CH to the upper left row
  239.         mov     cl,[bp+ulCol]   ; Set CH to the upper left column
  240.         mov     dh,[bp+lrRow]   ; Set DH to the lower right row
  241.         mov     dl,[bp+lrCol]   ; Set DL to the lower right column
  242.         mov     bh,[bp+attr]    ; Set BH to the attribute to fill with
  243.         mov     ah,7            ; Set AH to 7 (scroll down function)
  244.         int     10H             ; Call ROM BIOS video interrupt
  245.         pop     bp              ; Restore the BP register
  246.         ret                     ; Return to calling program
  247. _scrDn  endp                    ; End of subroutine
  248.  
  249. ; _getACh(page,&chPtr,&attrPtr)
  250. ;
  251. ; Function: Get the character and the attributes of the character at the
  252. ; current cursor position in the specified page.
  253. ;
  254. ; Algorithm: Call the ROM BIOS get character/attribute function; int 10H,
  255. ; AH = 8.
  256.  
  257.         public  _getACh         ; Routine is available to other modules
  258.  
  259.         page = 4                ; Offset from BP to parameter page
  260.         chPtr = 6               ; Offset to parameter chPtr
  261.         attrPtr = 8             ; Offset to attrPtr
  262.  
  263. _getACh proc near               ; NEAR type subroutine
  264.         push    bp              ; Save BP register
  265.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  266.         mov     bh,[bp+page]    ; Set BH to the page number
  267.         mov     ah,8            ; Set AH to 8 (get char/attribute function)
  268.         int     10H             ; Call ROM BIOS video interrupt
  269.         mov     bx,[bp+chPtr]   ; *chPtr = character at cursor
  270.         mov     [bx],al
  271.         mov     bx,[bp+attrPtr] ; *attrPtr = attribute at cursor
  272.         mov     [bx],ah
  273.         pop     bp              ; Restore the BP register
  274.         ret                     ; Return to calling program
  275. _getACh endp                    ; End of subroutine
  276.  
  277. ; _putACh(page,char,attr,n)
  278. ;
  279. ; Function: Put n copies of the character and attribute specified at the
  280. ; current cursor position of the specified page.
  281. ;
  282. ; Algorithm: Call the ROM BIOS put character/attribute function; int 10H, 
  283. ; AH = 9.
  284.  
  285.         public  _putACh         ; Routine is available to other modules
  286.  
  287.         page = 4                ; Offset from BP to parameter page
  288.         char = 6                ; Offset to parameter ch
  289.         attr = 8                ; Offset to attr
  290.         n = 10                  ; Offset to n
  291.  
  292. _putACh proc near               ; NEAR type subroutine
  293.         push    bp              ; Save BP register
  294.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  295.         mov     bh,[bp+page]    ; Set BH to the page number
  296.         mov     cx,[bp+n]       ; Set CX to the number of chars to write
  297.         mov     al,[bp+char]    ; Set AL to the character
  298.         mov     bl,[bp+attr]    ; Set BL to the attribute
  299.         mov     ah,9            ; Set AH to 9 (put char/attribute function)
  300.         int     10H             ; Call ROM BIOS video interrupt
  301.         pop     bp              ; Restore the BP register
  302.         ret                     ; Return to calling program
  303. _putACh endp                    ; End of subroutine
  304.  
  305. ; _putOCh(page,char,n)
  306. ;
  307. ; Function: Write n copies of the character char to the current cursor
  308. ; position on the specified page. Leave the attribute as it was.
  309. ;
  310. ; Algorithm: Call the ROM BIOS write character function; int 10H, AH = 10.
  311.  
  312.         public  _putOCh         ; Routine is available to other modules
  313.  
  314.         page = 4                ; Offset from BP to parameter page
  315.         char = 6                ; Offset to parameter ch
  316.         n = 8                   ; Offset to n
  317.  
  318. _putOCh proc near               ; NEAR type subroutine
  319.         push    bp              ; Save BP register
  320.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  321.         mov     bh,[bp+page]    ; Set BH to the page number
  322.         mov     cx,[bp+n]       ; Set CX to the number of chars to write
  323.         mov     al,[bp+char]    ; Set AL to the character to write
  324.         mov     ah,10           ; Set AH to 10 (write character function)
  325.         int     10H             ; Call ROM BIOS video interrupt
  326.         pop     bp              ; Restore the BP register
  327.         ret                     ; Return to calling program
  328. _putOCh endp                    ; End of subroutine
  329.  
  330. ; _putTty(page,char,color)
  331. ;
  332. ; Function: Write the character char to the current cursor position of the
  333. ; page specified; if in graphics mode, write it in the color given. Unlike,
  334. ; the putACh and putOCh functions, this function advances the cursor after
  335. ; writing, and interprets some control codes such as carriage return, line
  336. ; feed, and backspace.
  337. ;
  338. ; Algorithm: Call the ROM BIOS TTY write character function; int 10H, AH = 13.
  339.  
  340.         public  _putTty         ; Routine is available to other modules
  341.  
  342.         page = 4                ; Offset from BP to parameter page
  343.         char = 6                ; Offset to parameter ch
  344.         color = 8               ; Offset to color
  345.  
  346. _putTty proc near               ; NEAR type subroutine
  347.         push    bp              ; Save BP register
  348.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  349.         push    si
  350.         push    di
  351.         mov     bh,[bp+page]    ; Set BH to the page number
  352.         mov     al,[bp+char]    ; Set AL to the character to write
  353.         mov     bl,[bp+color]   ; Set BL to the foreground color to use
  354.         mov     ah,14           ; Set AH to 14 (TTY write char function)
  355.         int     10H             ; Call ROM BIOS video interrupt
  356.         pop     di
  357.         pop     si
  358.         pop     bp              ; Restore the BP register
  359.         ret                     ; Return to calling program
  360. _putTty endp                    ; End of subroutine
  361.  
  362. ; _getSt(&modePtr,&widthPtr,&pagePtr)
  363. ;
  364. ; Function: Get the current display mode, display width (in characters),
  365. ; and the active page number.
  366. ;
  367. ; Algorithm: Call the ROM BIOS get video state function; int 10H, AH = 15.
  368.  
  369.         public  _getSt          ; Routine is available to other modules
  370.  
  371.         modePtr = 4             ; Offset from BP to parameter modePtr
  372.         widthPtr = 6            ; Offset to parameter widthPtr
  373.         pagePtr = 8             ; Offset to pagePtr
  374.  
  375. _getSt  proc near               ; NEAR type subroutine
  376.         push    bp              ; Save BP register
  377.         mov     bp,sp           ; Set BP to SP; easier to get parameters
  378.         mov     ah,15           ; Set AH to 15 (get video state function)
  379.         int     10H             ; Call ROM BIOS video interrupt
  380.         mov     dh,bh           ; Save BH in DH
  381.         mov     bx,[bp+modePtr] ; *modePtr = the current video mode
  382.         mov     [bx],al
  383.         xor     al,al           ; Set AL to zero
  384.         mov     [bx+1],al       ; Zero high byte of *modePtr
  385.         mov     bx,[bp+widthPtr]; *widthPtr = ah (with top byte zero)
  386.         mov     [bx],ah
  387.         mov     [bx+1],al
  388.         mov     bx,[bp+pagePtr] ; *pagePtr = the active page number
  389.         mov     [bx],dh
  390.         mov     [bx+1],al
  391.         pop     bp              ; Restore the BP register
  392.         ret                     ; Return to calling program
  393. _getSt  endp                    ; End of subroutine
  394.  
  395. _TEXT   ends                    ; End of code segment
  396.  
  397.         end                     ; End of assembly code
  398.  
  399.