home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / windc86.zip / VLIB.ASM next >
Assembly Source File  |  1989-03-20  |  6KB  |  305 lines

  1.  
  2. ;    module:        vlib
  3. ;    programmer:    Ray L. McVay
  4. ;    started:    10 Oct 82
  5. ;    version:    2.01, 3 Aug 84
  6. ;
  7. ;    A library of c bios video functions originally written to
  8. ;    replace the int10() function of small-c:PC.
  9.  
  10. ;    history:
  11. ;    1.0    small-c:PC version
  12. ;    2.0    ported to DeSmet c
  13.  
  14. ;        Calling convention for DeSmet is to push parameters
  15. ;        rightmost first then do an intrasegment call to the
  16. ;        function.
  17.  
  18. ;        Char's, int's and unsigned's are returned in AX.
  19. ;        Long's are returned in DX:AX.
  20.  
  21. ;        CS, DS, SS, SP and BP should be preserved.
  22.  
  23. ;     Dec 84    ported to CI C86 by Mike Elkins
  24.  
  25. VIDEO    EQU    16    ;BIOS video interrupt
  26.         include model.h
  27.         include prologue.h
  28.  
  29. ;    get video mode
  30. ; int get_mode_();
  31.  
  32.     PUBLIC    GET_MODE_
  33. GET_MODE_  proc near
  34.     mov    ah,15
  35.     int    VIDEO
  36.     cbw
  37.     ret
  38. GET_MODE_   endp
  39.  
  40. ;    set video mode
  41. ; set_mode_(mode)
  42. ; int    mode;
  43.  
  44.     PUBLIC    SET_MODE_
  45. SET_MODE_  proc near
  46.     push    bp
  47.     mov    bp,sp
  48.     mov    al,[bp+4]
  49.     mov    ah,0
  50.     INT    VIDEO
  51.     pop    bp
  52.     RET
  53. SET_MODE_  endp
  54.  
  55. ;    set cursor type        
  56. ; set_curtyp_(start,end)
  57. ; int    start,end;
  58. ; Note: if start > end then cursor is turned off.
  59.  
  60.     PUBLIC    SET_CURTYP_
  61. SET_CURTYP_  proc near
  62.     push    bp
  63.     mov    bp,sp
  64.     mov    ch,[bp+4]    ; top line
  65.     mov    cl,[bp+6]    ; bottom line
  66.     mov    ah,1
  67.     INT    VIDEO
  68.     pop    bp
  69.     RET
  70. SET_CURTYP_  endp
  71.  
  72. ;    gotoxy - set cursor position    
  73. ; gotoxy_(x, y, page)
  74. ; int    x,y,page;
  75.  
  76.     PUBLIC    GOTOXY_
  77. GOTOXY_  proc near
  78.     push    bp
  79.     mov    bp,sp
  80.     mov    dl,[bp+4]    ; DL = x = column
  81.     mov    dh,[bp+6]    ; DH = y = row
  82.     mov    bh,[bp+8]    ; BH = page
  83.     mov    ah,2
  84.     INT    VIDEO
  85.     pop    bp
  86.     RET
  87. GOTOXY_  endp
  88.  
  89. ;    read cursor position
  90. ; getxy_(page)
  91. ; int    page;
  92. ; xpos = getxy(page) & 255;
  93. ; ypos = getxy(page) >> 8;
  94.  
  95.     PUBLIC    GETXY_
  96. GETXY_  proc near
  97.     push    bp
  98.     mov    bp,sp
  99.     mov    bh,[bp+4]    ;BH = page
  100.     MOV    AH,3
  101.     INT    VIDEO
  102.     MOV    AX,DX        ;return(256*row+column)
  103.     pop    bp
  104.     RET
  105. GETXY_  endp
  106.  
  107. ;    get light pen position
  108. ; int gltpen_(buff)
  109. ; int    buff[4];
  110. ; Note: Returns 0 if pen was not triggered, 1 if it was.
  111. ;    Stores XY values in integer array at buff.
  112.  
  113.     PUBLIC    GLTPEN_
  114. GLTPEN_  proc near
  115.     push    bp
  116.     mov    bp,sp
  117.     MOV    AH,4
  118.     INT     VIDEO
  119.     OR    AH,AH        ;check status
  120.     JZ    DOSTAT        ;it was bad
  121.     mov    si,[bp+4]    ;get addres of buffer
  122.     MOV    [SI],BX        ;buff[0]=X for graphics
  123.     MOV    [SI]+2,CH    ;buff[1]=Y
  124.     MOV    [SI]+4,DL    ;buff[2]=X for text
  125.     MOV    [SI]+6,DH    ;buff[3]=Y for text
  126.     MOV    AH,1        ;return OK status
  127. DOSTAT  LABEL NEAR
  128.     MOV    AL,AH
  129.     CBW
  130.     pop    bp
  131.     RET
  132. GLTPEN_  endp
  133.  
  134. ;    select active page    
  135. ; setpage_(page)
  136. ; int    page;
  137.  
  138.     PUBLIC    SETPAGE_
  139. SETPAGE_  proc near
  140.     push    bp
  141.     mov    bp,sp
  142.     mov    al,[bp+4]    ;page
  143.     MOV    AH,5
  144.     INT    VIDEO
  145.     pop    bp
  146.     RET
  147. SETPAGE_  endp
  148.  
  149. ;    scroll a window up    
  150. ; scrlup_(window,count,attrib)
  151. ; int window[4],count,attrib;
  152. ; Note: Window defines the upper-left and lower-right
  153. ;    character positions of an area of the text screen.
  154. ;    A count of 0 clears the window.
  155. ;    The attribute is used on the line(s) blanked.
  156.  
  157.     PUBLIC    SCRLUP_
  158. SCRLUP_  proc near
  159.     push    bp
  160.     CALL    SCRL1
  161.     MOV    AH,6
  162.     INT    VIDEO
  163.     pop    bp
  164.     RET
  165.  
  166. SCRL1     LABEL NEAR
  167.     mov    bp,sp
  168.     mov    bx,[bp+6]    ;get base of window array
  169.     MOV    CL,[bx]        ;window[0] = U.L. X
  170.     MOV    CH,[bx]+2    ;window[1] = U.L. Y
  171.     MOV    DL,[bx]+4    ;window[2] = L.R. X
  172.     MOV    DH,[bx]+6    ;window[3] = L.R. Y
  173.     mov    al,[bp+8]    ;AL = count
  174.     mov    bh,[bp+10]    ;BH = attribute
  175.     RET
  176. SCRLUP_  endp
  177.  
  178. ;    scroll a window down    
  179. ; scrldn_(window,count,attrib)
  180. ; int window[4],count,attrib;
  181.  
  182.     PUBLIC    SCRLDN_
  183. SCRLDN_  proc near
  184.     push    bp
  185.     CALL    SCRL1
  186.     MOV    AH,7
  187.     INT    VIDEO
  188.     pop    bp
  189.     RET
  190. SCRLDN_  endp
  191.  
  192. ;    read character & attribute under the cursor
  193. ; int vgetc_(page)
  194. ; int    page;
  195.  
  196.     PUBLIC    VGETC_
  197. VGETC_  proc near
  198.     push    bp
  199.     mov    bp,sp
  200.     MOV    BH,[bp+4]
  201.     MOV    AH,8
  202.     INT    VIDEO
  203.     pop    bp
  204.     RET
  205. VGETC_  endp
  206.  
  207. ;    write character & attribute at cursor
  208. ; vputca_(chr,page,count)
  209. ; int    chr,page,count;
  210. ; Note: Chr contains attribute in hi byte.
  211. ;    Count is the number of times to write the character.
  212. ;    (Good for tops and bottoms of windows or boxes.)
  213.  
  214.     PUBLIC    VPUTCA_
  215. VPUTCA_  proc near
  216.     push    bp
  217.     CALL    VPUT1
  218.     MOV    AH,9
  219.     INT    VIDEO
  220.     pop    bp
  221.     RET
  222.  
  223. VPUT1     LABEL NEAR
  224.     mov    bp,sp
  225.     mov    AX,[bp+6]    ;attrib/char
  226.     mov    bh,[bp+8]    ;page
  227.     mov    CX,[bp+10]    ;count
  228.     MOV    BL,AH        ;attrib to BL
  229.     RET
  230. VPUTCA_  endp
  231.  
  232. ;    vputc - write character only at cursor    
  233. ; vputc_(chr,page,count)
  234. ; int    chr,page,count;
  235. ; Note:    Same as vputca() except uses existing attributes.
  236.  
  237.     PUBLIC    VPUTC_
  238. VPUTC_  proc near
  239.     push    bp
  240.     CALL    VPUT1
  241.     MOV    AH,10
  242.     INT    VIDEO
  243.     pop    bp
  244.     RET
  245. VPUTC_  endp
  246.  
  247. ;    set background or pallet or alpha border color        
  248. ; pcolor_(id,val)
  249. ; int    id,val;
  250. ; Note:    If id == 0 then val is background color.
  251. ;    If id == 1 and mode is graphics then val is pallet.
  252. ;    If id == 1 and mode is text then val is border.
  253.  
  254.     PUBLIC    PCOLOR_
  255. PCOLOR_  proc near
  256.     push    bp
  257.     mov    bp,sp
  258.     mov    bh,[bp+4]    ;id
  259.     mov    bl,[bp+6]    ;val
  260.     MOV    AH,11
  261.     INT    VIDEO
  262.     pop    bp
  263.     RET
  264. PCOLOR_  endp
  265.  
  266. ;    write a graphics dot    
  267. ; plot_(color,horz,vert)
  268. ; int    color,horz,vert;
  269.  
  270.     PUBLIC    PLOT_
  271. PLOT_  proc near
  272.     push    bp
  273.     CALL    SETDOT
  274.     MOV    AH,12
  275.     INT    VIDEO
  276.     pop    bp
  277.     RET
  278.  
  279. SETDOT  LABEL NEAR
  280.     mov    bp,sp
  281.     mov    AX,[bp+6]    ;color
  282.     mov    CX,[bp+8]    ;horiz
  283.     mov    DX,[bp+10]    ;vert
  284.     RET
  285. PLOT_  endp
  286.  
  287. ;    read a graphic dot color
  288. ; int get_dot_(dummy,horz,vert)    
  289. ; int    dummy,horz,vert;
  290. ; Note: the dummy parameter is used so SETDOT can be shared.
  291.  
  292.     PUBLIC    GET_DOT_
  293. GET_DOT_  proc near
  294.     push    bp
  295.     CALL    SETDOT        ; set up the registers
  296.     MOV    AH,13
  297.     INT    VIDEO
  298.     cbw
  299.     pop    bp
  300.     RET            ; AX = dot color
  301. GET_DOT_  endp
  302.  
  303.         include epilogue.h
  304.     END
  305.