home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / msdos / graphics / window.arc / VLIB.A < prev    next >
Text File  |  1985-09-26  |  5KB  |  300 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. CSEG
  24. VIDEO    EQU    16    ;BIOS video interrupt
  25.  
  26.  
  27. ;    get video mode
  28. ; int get_mode();
  29.  
  30.     PUBLIC    GET_MODE_
  31. GET_MODE_:
  32.     mov    ah,15
  33.     int    VIDEO
  34.     cbw
  35.     ret
  36.  
  37.  
  38. ;    set video mode
  39. ; set_mode(mode)
  40. ; int    mode;
  41.  
  42.     PUBLIC    SET_MODE_
  43. SET_MODE_:
  44.     push    bp
  45.     mov    bp,sp
  46.     mov    al,[bp+4]
  47.     mov    ah,0
  48.     INT    VIDEO
  49.     pop    bp
  50.     RET
  51.  
  52.  
  53. ;    set cursor type        
  54. ; set_curtyp(start,end)
  55. ; int    start,end;
  56. ; Note: if start > end then cursor is turned off.
  57.  
  58.     PUBLIC    SET_CURTYP_
  59. SET_CURTYP_:
  60.     push    bp
  61.     mov    bp,sp
  62.     mov    ch,[bp+4]    ; top line
  63.     mov    cl,[bp+6]    ; bottom line
  64.     mov    ah,1
  65.     INT    VIDEO
  66.     pop    bp
  67.     RET
  68.  
  69.  
  70. ;    gotoxy - set cursor position    
  71. ; gotoxy(x, y, page)
  72. ; int    x,y,page;
  73.  
  74.     PUBLIC    GOTOXY_
  75. GOTOXY_:
  76.     push    bp
  77.     mov    bp,sp
  78.     mov    dl,[bp+4]    ; DL = x = column
  79.     mov    dh,[bp+6]    ; DH = y = row
  80.     mov    bh,[bp+8]    ; BH = page
  81.     mov    ah,2
  82.     INT    VIDEO
  83.     pop    bp
  84.     RET
  85.  
  86.  
  87. ;    read cursor position
  88. ; getxy(page)
  89. ; int    page;
  90. ; xpos = getxy(page) & 255;
  91. ; ypos = getxy(page) >> 8;
  92.  
  93.     PUBLIC    GETXY_
  94. GETXY_:
  95.     push    bp
  96.     mov    bp,sp
  97.     mov    bh,[bp+4]    ;BH = page
  98.     MOV    AH,3
  99.     INT    VIDEO
  100.     MOV    AX,DX        ;return(256*row+column)
  101.     pop    bp
  102.     RET
  103.  
  104.  
  105. ;    get light pen position
  106. ; int gltpen(buff)
  107. ; int    buff[4];
  108. ; Note: Returns 0 if pen was not triggered, 1 if it was.
  109. ;    Stores XY values in integer array at buff.
  110.  
  111.     PUBLIC    GLTPEN_
  112. GLTPEN_:
  113.     push    bp
  114.     mov    bp,sp
  115.     MOV    AH,4
  116.     INT     VIDEO
  117.     OR    AH,AH        ;check status
  118.     JZ    DOSTAT        ;it was bad
  119.     mov    si,[bp+4]    ;get addres of buffer
  120.     MOV    [SI],BX        ;buff[0]=X for graphics
  121.     MOV    [SI]+2,CH    ;buff[1]=Y
  122.     MOV    [SI]+4,DL    ;buff[2]=X for text
  123.     MOV    [SI]+6,DH    ;buff[3]=Y for text
  124.     MOV    AH,1        ;return OK status
  125. DOSTAT:
  126.     MOV    AL,AH
  127.     CBW
  128.     pop    bp
  129.     RET
  130.  
  131.  
  132. ;    select active page    
  133. ; setpage(page)
  134. ; int    page;
  135.  
  136.     PUBLIC    SETPAGE_
  137. SETPAGE_:
  138.     push    bp
  139.     mov    bp,sp
  140.     mov    al,[bp+4]    ;page
  141.     MOV    AH,5
  142.     INT    VIDEO
  143.     pop    bp
  144.     RET
  145.  
  146.  
  147. ;    scroll a window up    
  148. ; scrlup(window,count,attrib)
  149. ; int window[4],count,attrib;
  150. ; Note: Window defines the upper-left and lower-right
  151. ;    character positions of an area of the text screen.
  152. ;    A count of 0 clears the window.
  153. ;    The attribute is used on the line(s) blanked.
  154.  
  155.     PUBLIC    SCRLUP_
  156. SCRLUP_:
  157.     push    bp
  158.     CALL    SCRL1
  159.     MOV    AH,6
  160.     INT    VIDEO
  161.     pop    bp
  162.     RET
  163.  
  164. SCRL1:    mov    bp,sp
  165.     mov    bx,[bp+6]    ;get base of window array
  166.     MOV    CL,[bx]        ;window[0] = U.L. X
  167.     MOV    CH,[bx]+2    ;window[1] = U.L. Y
  168.     MOV    DL,[bx]+4    ;window[2] = L.R. X
  169.     MOV    DH,[bx]+6    ;window[3] = L.R. Y
  170.     mov    al,[bp+8]    ;AL = count
  171.     mov    bh,[bp+10]    ;BH = attribute
  172.     RET
  173.  
  174.  
  175. ;    scroll a window down    
  176. ; scrldn(window,count,attrib)
  177. ; int window[4],count,attrib;
  178.  
  179.     PUBLIC    SCRLDN_
  180. SCRLDN_:
  181.     push    bp
  182.     CALL    SCRL1
  183.     MOV    AH,7
  184.     INT    VIDEO
  185.     pop    bp
  186.     RET
  187.  
  188.  
  189. ;    read character & attribute under the cursor
  190. ; int vgetc(page)
  191. ; int    page;
  192.  
  193.     PUBLIC    VGETC_
  194. VGETC_:
  195.     push    bp
  196.     mov    bp,sp
  197.     MOV    BH,[bp+4]
  198.     MOV    AH,8
  199.     INT    VIDEO
  200.     pop    bp
  201.     RET
  202.  
  203.  
  204. ;    write character & attribute at cursor
  205. ; vputca(chr,page,count)
  206. ; int    chr,page,count;
  207. ; Note: Chr contains attribute in hi byte.
  208. ;    Count is the number of times to write the character.
  209. ;    (Good for tops and bottoms of windows or boxes.)
  210.  
  211.     PUBLIC    VPUTCA_
  212. VPUTCA_:
  213.     push    bp
  214.     CALL    VPUT1
  215.     MOV    AH,9
  216.     INT    VIDEO
  217.     pop    bp
  218.     RET
  219.  
  220. VPUT1:    
  221.     mov    bp,sp
  222.     mov    AX,[bp+6]    ;attrib/char
  223.     mov    bh,[bp+8]    ;page
  224.     mov    CX,[bp+10]    ;count
  225.     MOV    BL,AH        ;attrib to BL
  226.     RET
  227.  
  228.  
  229. ;    vputc - write character only at cursor    
  230. ; vputc(chr,page,count)
  231. ; int    chr,page,count;
  232. ; Note:    Same as vputca() except uses existing attributes.
  233.  
  234.     PUBLIC    VPUTC_
  235. VPUTC_:
  236.     push    bp
  237.     CALL    VPUT1
  238.     MOV    AH,10
  239.     INT    VIDEO
  240.     pop    bp
  241.     RET
  242.  
  243.  
  244. ;    set background or pallet or alpha border color        
  245. ; pcolor(id,val)
  246. ; int    id,val;
  247. ; Note:    If id == 0 then val is background color.
  248. ;    If id == 1 and mode is graphics then val is pallet.
  249. ;    If id == 1 and mode is text then val is border.
  250.  
  251.     PUBLIC    PCOLOR_
  252. PCOLOR_:
  253.     push    bp
  254.     mov    bp,sp
  255.     mov    bh,[bp+4]    ;id
  256.     mov    bl,[bp+6]    ;val
  257.     MOV    AH,11
  258.     INT    VIDEO
  259.     pop    bp
  260.     RET
  261.  
  262.  
  263. ;    write a graphics dot    
  264. ; plot(color,horz,vert)
  265. ; int    color,horz,vert;
  266.  
  267.     PUBLIC    PLOT_
  268. PLOT_:
  269.     push    bp
  270.     CALL    SETDOT
  271.     MOV    AH,12
  272.     INT    VIDEO
  273.     pop    bp
  274.     RET
  275.  
  276. SETDOT:
  277.     mov    bp,sp
  278.     mov    AX,[bp+6]    ;color
  279.     mov    CX,[bp+8]    ;horiz
  280.     mov    DX,[bp+10]    ;vert
  281.     RET
  282.  
  283.  
  284. ;    read a graphic dot color
  285. ; int get_dot(dummy,horz,vert)    
  286. ; int    dummy,horz,vert;
  287. ; Note: the dummy parameter is used so SETDOT can be shared.
  288.  
  289.     PUBLIC    GET_DOT_
  290. GET_DOT_:
  291.     push    bp
  292.     CALL    SETDOT        ; set up the registers
  293.     MOV    AH,13
  294.     INT    VIDEO
  295.     cbw
  296.     pop    bp
  297.     RET            ; AX = dot color
  298.  
  299.     END
  300.