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