home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / bbs / windkw.arc / VLIB.AZT < prev    next >
Text File  |  1985-11-08  |  6KB  |  275 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. ;   3.0 ported to AZTEC C
  14.     include lmacros.h
  15. ;        Calling convention for DeSmet is to push parameters
  16. ;        rightmost first then do an intrasegment call to the
  17. ;        function.
  18.  
  19. ;        Char's, int's and unsigned's are returned in AX.
  20. ;        Long's are returned in DX:AX.
  21.  
  22. ;        CS, DS, SS, SP and BP should be preserved.
  23.  
  24. codeseg segment para public 'CODE'
  25. VIDEO    EQU    16    ;BIOS video interrupt
  26.  
  27.  
  28. ;    get video mode
  29. ; int get_mode();
  30.  
  31.     ;PUBLIC    GET_MODE
  32. ;GET_MODE:
  33. procdef get_mode
  34.     mov    ah,15
  35.     int    VIDEO
  36.     cbw
  37.     pret
  38. pend get_mode
  39.  
  40.  
  41. ;    set video mode
  42. ; set_mode(mode)
  43. ; int    mode;
  44.  
  45.     ;PUBLIC    SET_MODE
  46. ;SET_MODE:
  47. procdef    set_mode <<newmode,word>>
  48.     mov    ax,newmode
  49.     mov    ah,0
  50.     INT    VIDEO
  51.     pret
  52. pend set_mode
  53.  
  54.  
  55. ;    cursor type        
  56. ; curtype(start,end)
  57. ; int    start,end;
  58. ; Note: if start > end then cursor is turned off.
  59.  
  60.     ;PUBLIC    CURTYPE
  61. ;CURTYPE:
  62. procdef curtype <<start,byte>,<_end,byte>>
  63.     mov    ch,start; top line
  64.     mov    cl,_end; bottom line
  65.     mov    ah,1
  66.     INT    VIDEO
  67.     pret
  68. pend curtype
  69.  
  70. ;    gotoxy - set cursor position    
  71. ; gotoxy(x, y, page)
  72. ; int    x,y,page;
  73.  
  74.     ;PUBLIC    GOTOXY
  75. ;GOTOXY:
  76. procdef gotoxy <<x,byte>,<y,byte>,<page1,byte>>
  77.     mov    dl,x        ; DL = x = column
  78.     mov    dh,y        ; DH = y = row
  79.     mov    bh,page1        ; BH = page1
  80.     mov    ah,2
  81.     INT    VIDEO
  82.     pret
  83. pend gotoxy
  84.  
  85. ;    read cursor position
  86. ; getxy(page)
  87. ; int    page;
  88. ; xpos = getxy(page) & 255;
  89. ; ypos = getxy(page) >> 8;
  90.  
  91.     ;PUBLIC    GETXY
  92. ;GETXY:
  93. procdef getxy <<page2,byte>>
  94.     mov    bh,page2    ;BH = page2
  95.     MOV    AH,3
  96.     INT    VIDEO
  97.     MOV    AX,DX        ;return(256*row+column)
  98.     pret
  99. pend getxy
  100.  
  101. ;    get light pen position
  102. ; int gltpen(buff)
  103. ; int    buff[4];
  104. ; Note: Returns 0 if pen was not triggered, 1 if it was.
  105. ;    Stores XY values in integer array at buff.
  106.  
  107.     ;PUBLIC    GLTPEN
  108. ;GLTPEN:
  109. procdef gltpen <<buff,ptr>>
  110.     MOV    AH,4
  111.     INT     VIDEO
  112.     OR    AH,AH        ;check status
  113.     JZ    DOSTAT        ;it was bad
  114.     pushds
  115.     ldptr    si,buff,ds
  116.     MOV    [SI],BX        ;buff[0]=X for graphics
  117.     MOV    2[SI],CH    ;buff[1]=Y
  118.     MOV    4[SI],DL    ;buff[2]=X for text
  119.     MOV    6[SI],DH    ;buff[3]=Y for text
  120.     MOV    AH,1        ;return OK status
  121.     popds
  122. DOSTAT:
  123.     MOV    AL,AH
  124.     CBW
  125.     pret
  126. pend gltpen
  127. ;    select active page    
  128. ; vsetpage(page)
  129. ; int    page;
  130.  
  131.     ;PUBLIC    VSETPAGE
  132. ;VSETPAGE:
  133. procdef    vsetpage <<page3,byte>>
  134.     mov    al,page3    ;page3
  135.     MOV    AH,5
  136.     INT    VIDEO
  137.     pret
  138. pend vsetpage
  139.  
  140. ;    scroll a window up    
  141. ; scrlup(window,count,attrib)
  142. ; int window[4],count,attrib;
  143. ; Note: Window defines the upper-left and lower-right
  144. ;    character positions of an area of the text screen.
  145. ;    A count of 0 clears the window.
  146. ;    The attribute is used on the line(s) blanked.
  147.  
  148.     ;PUBLIC    SCRLUP
  149. ;SCRLUP:
  150. procdef scrlup <<window,ptr>,<count,byte>,<attrib,byte>>
  151.     pushds
  152.     ldptr bx,window,ds
  153.     MOV    CL,[bx]        ;window[0] = U.L. X
  154.     MOV    CH,2[bx]    ;window[1] = U.L. Y
  155.     MOV    DL,4[bx]    ;window[2] = L.R. X
  156.     MOV    DH,6[bx]    ;window[3] = L.R. Y
  157.     mov    al,count    ;AL = count
  158.     mov    bh,attrib    ;BH = attribute
  159.     MOV    AH,6
  160.     INT    VIDEO
  161.     pret
  162. pend    scrlup
  163.  
  164. ;    scroll a window down    
  165. ; scrldn(window,count,attrib)
  166. ; int window[4],count,attrib;
  167. procdef scrldn <<window1,ptr>,<count1,byte>,<attrib1,byte>>
  168.     pushds
  169.     ldptr bx,window1,ds
  170.     MOV    CL,[bx]        ;window1[0] = U.L. X
  171.     MOV    CH,2[bx]    ;window1[1] = U.L. Y
  172.     MOV    DL,4[bx]    ;window1[2] = L.R. X
  173.     MOV    DH,6[bx]    ;window1[3] = L.R. Y
  174.     mov    al,count1    ;AL = count
  175.     mov    bh,attrib1    ;BH = attribute
  176.     MOV    AH,6
  177.     INT    VIDEO
  178.     pret
  179. pend    scrldn
  180.  
  181. ;    read character & attribute under the cursor
  182. ; int vgetc(page)
  183. ; int    page;
  184.  
  185.     ;PUBLIC    VGETC
  186. ;VGETC:
  187. procdef    vgetc <<page4,byte>>
  188.     MOV    BH,page4
  189.     MOV    AH,8
  190.     INT    VIDEO
  191.     pret
  192. pend vgetc
  193.  
  194. ;    write character & attribute at cursor
  195. ; vputca(chr,page,count)
  196. ; int    chr,page,count;
  197. ; Note: Chr contains attribute in hi byte.
  198. ;    Count is the number of times to write the character.
  199. ;    (Good for tops and bottoms of windows or boxes.)
  200.  
  201.     ;PUBLIC    VPUTCA
  202. ;VPUTCA:
  203. procdef vputca <<chr,word>,<page5,byte>,<count3,word>>
  204.     mov    AX,chr;attrib/char
  205.     mov    bh,page5        ;page
  206.     mov    CX,count3    ;count
  207.     MOV    BL,AH        ;attrib to BL
  208.     MOV    AH,9
  209.     INT    VIDEO
  210. pret
  211. pend vputca
  212.  
  213.  
  214. ;    vputc - write character only at cursor    
  215. ; vputc(chr,page,count)
  216. ; int    chr,page,count;
  217. ; Note:    Same as vputca() except uses existing attributes.
  218. procdef vputc <<chr1,word>,<page6,byte>,<count2,word>>
  219.     mov    AX,chr1;attrib/char
  220.     mov    bh,page6        ;page
  221.     mov    CX,count2    ;count
  222.     MOV    AH,9
  223.     INT    VIDEO
  224. pret
  225. pend vputc
  226.  
  227. ;    set background or pallet or alpha border color        
  228. ; pcolor(id,val)
  229. ; int    id,val;
  230. ; Note:    If id == 0 then val is background color.
  231. ;    If id == 1 and mode is graphics then val is pallet.
  232. ;    If id == 1 and mode is text then val is border.
  233.  
  234.     ;PUBLIC    PCOLOR
  235. ;PCOLOR:
  236. procdef pcolor <<id,byte>,<val,byte>>
  237.     mov    bh,id
  238.     mov    bl,val
  239.     MOV    AH,11
  240.     INT    VIDEO
  241.     pret
  242. pend pcolor
  243.  
  244.  
  245. ;    write a graphics dot    
  246. ; plot(color,horz,vert)
  247. ; int    color,horz,vert;
  248.  
  249.     ;PUBLIC    PLOT
  250. ;PLOT:
  251. procdef plot <<color,word>,<horz,word>,<vert,word>>
  252.     mov    AX,color
  253.     mov    CX,horz
  254.     mov    DX,vert
  255.     MOV    AH,12
  256.     INT    VIDEO
  257.     pret
  258. pend plot
  259.  
  260. ;    read a graphic dot color
  261. ; int get_dot(dummy,horz,vert)    
  262. ; int    dummy,horz,vert;
  263. ; Note: the dummy parameter is used so SETDOT can be shared.
  264.  
  265. procdef get_dot <<color1,word>,<horz1,word>,<vert1,word>>
  266.     mov    AX,color1
  267.     mov    CX,horz1
  268.     mov    DX,vert1
  269.     MOV    AH,13
  270.     INT    VIDEO
  271.     cbw
  272.     pret
  273. pend get_dot
  274. codeseg ends
  275.