Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Vesa Graphics for PB/DOS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Vesa Graphics for PB/DOS

    I've messed with this a little. Removed ellipse, fillellipse, ttyprint,
    etc..., fixed some bugs, added some demo code and docs. The previous posting
    was not really that good. This is a little better.

    Code:
    '--------------------------------------------------------------------------
    ' Save this as PBVESA.BAS or change the $INCLUDE line in the demo file
    '
    $IF 0
      Vesa video library, all of the vesa modes I know of are as follows.
          PB/Vesa     Mode#     Resolution     Color     bits/     tele
          Support     (hex)     horz  vert     depth     pixel     type
          ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
            Yes        100       640   400       256        8     (80x25)*
            Yes        101       640   480       256        8     (80x30)*
            Yes        102       800   600        16        4    (100x37)*
            Yes        103       800   600       256        8    (100x37)*
            Yes        104      1024   768        16        4    (128x48)*
            Yes        105      1024   768       256        8    (128x48)*
            Yes        106      1280  1024        16        4    (160x64)*
            Yes        107      1280  1024       256        8    (160x64)*
           #Yes        108        80    60         ?      n/a        #
           #Yes        109       132    25         ?      n/a        #
           #Yes        10A       132    43         ?      n/a        #
           #Yes        10B       132    50         ?      n/a        #
           #Yes        10C       132    60         ?      n/a        #
              @        10D       320   200     32767       15        @
              @        10E       320   200     65536       16        @
              @        10F       320   200     16.8M       24        @
            Yes        110       640   480     32767       15        !
            Yes        111       640   480     65536       16        !
            Yes        112       640   480     16.8M       24        !
            Yes        113       800   600     32767       15        !
            Yes        114       800   600     65536       16        !
            Yes        115       800   600     16.8M       24        !
            Yes        116      1024   768     32767       15        !
            Yes        117      1024   768     65536       16        !
            Yes        118      1024   768     16.8M       24        !
            Yes        119      1280  1024     32767       15        !
            Yes        11A      1280  1024     65536       16        !
            Yes        11B      1280  1024     16.8M       24        !
            Yes        11C       640   400     65536       16        !
            Yes        11D       640   480     16.8M       32        !
            Yes        11E       800   600     16.8M       32        !
            Yes        11F      1024   768     16.8M       32        !
            Yes        120      1600  1200       256        8        !
              @        121      1600  1200     32767       15        @
              @        122      1600  1200     65536       16        @
    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
     @ = mode not supported by my card, so I could not test it.
     * = works on my card, but may vary by card.
     ! = does not work on my card, but may vary by card.
     # = Text Modes - text modes have not been fully tested yet, but seem to
         work just fine(using bios to print).
     Not all cards will support all modes. Use the detectvesa function to find
     the necessary mode support info to satisfy your specific needs.
    
     The 16 color(4bit/pix) modes use the bios so they are sloooow. I still have
     to figure out direct screen writes in 16 color mode.
    
     24 bit modes are a bear. Hence most of these routines do not work in 24 bit
     mode. I'll work on that. vPut does not work in 24 or 32 bit mode.
    
     32 bit colors are effectively the same as 24 bit colors. The card simply
     ignores the high byte on each 32 bit pixel. If the high byte is used for
     anything, I have no idea what. The only reason I can see for 32 bit modes to
     exist is because 32 bit values are easier to deal with than 24 bit values.
     (see SUB VPset to see what I mean.)
    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    $ENDIF
    
    $CPU 80386                ' program works on 386+ CPU
    $OPTIMIZE SPEED           ' make fastest possible executable
    $COMPILE EXE              ' compile to an EXE
    $LIB ALL OFF              ' turn off all PowerBASIC Libraries.
    $ERROR ALL OFF            ' turn off bounds checking
    $COM    0                 ' set communications buffer to nothing
    $STRING 32                ' set largest string size at 32k
    $STACK  2048              ' let's use a 2k stack
    $SOUND  1                 ' smallest music buffer possible
    '$DIM ALL                  ' force all variables to be pre-dimensioned before
                              ' they can be used
    $DYNAMIC                  ' all arrays will be dynamic by default
    $OPTION CNTLBREAK OFF     ' don't allow Ctrl-Break to exit program
    DEFINT A-Z                ' default all variables to integers for maximum
                              ' speed and minimum size
    
    %preset = 1 : %pset = 0 : %xor = 2 : %or = 3 : %and = 4 : %trans = 5
    %AX = 1 : %BX = 2 : %CX = 3 : %DX = 4
    %SI = 5 : %DI = 6 : %BP = 7 : %DS = 8
    %ES = 9 : %FLAGS = 0 : %B = 1 : %BF = 2
    %FALSE = 0
    %TRUE = NOT %FALSE
    
    DECLARE FUNCTION DetectVESA(VData AS STRING) AS INTEGER
    DECLARE FUNCTION fDeg2Rad (SEG Degree AS SINGLE) AS SINGLE
    DECLARE FUNCTION InfoOnMode(BYVAL Mode AS INTEGER, MData AS STRING) AS INTEGER
    DECLARE FUNCTION VOffset(BYVAL x AS INTEGER, BYVAL y AS INTEGER) AS LONG
    
    DECLARE SUB DoPut(BYVAL xSize AS WORD, BYVAL ySize AS WORD, BYVAL x AS INTEGER, BYVAL y AS INTEGER, LinArr() AS WORD)
    DECLARE SUB FillArry(Xarray() AS BYTE, BYVAL clr AS DWORD)
    DECLARE SUB InitFont()
    DECLARE SUB LineTo(BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, BYVAL y2 AS INTEGER, BYVAL clr AS DWORD)
    DECLARE SUB VAPage(BYVAL page AS INTEGER)
    DECLARE SUB VBank(BYVAL bank AS INTEGER)
    DECLARE SUB VHLine(BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, aSprite() AS WORD, BYVAL El AS LONG)
    DECLARE SUB VVPage(BYVAL page AS INTEGER)
    
    ' I have tried to make these commands act as much like their Powerbasic
    ' counterparts as possible given my limited programming abilities.
    DECLARE SUB vCircle (BYVAL Xcen   AS INTEGER , BYVAL Ycen   AS INTEGER , _
                         BYVAL Radius AS INTEGER , BYVAL Colour AS DWORD , _
                         BYVAL Sdeg   AS INTEGER , BYVAL Edeg   AS INTEGER , _
                         BYVAL Aspect AS SINGLE)
    DECLARE SUB VCLS()
    DECLARE SUB VColor(BYVAL fg AS DWORD, BYVAL bg AS DWORD)
    DECLARE SUB VGet(BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, BYVAL y2 AS INTEGER, Xarray() AS WORD)
    DECLARE SUB VLine(BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, BYVAL y2 AS INTEGER, BYVAL clr AS DWORD, BYVAL Style AS INTEGER)
    DECLARE SUB VLocate(BYVAL Row AS INTEGER, BYVAL Column AS INTEGER)
    DECLARE FUNCTION VPoint(BYVAL x AS INTEGER, BYVAL y AS INTEGER) AS WORD
    DECLARE SUB VPrint(Tex AS STRING)
    DECLARE SUB VPSet(BYVAL x AS INTEGER, BYVAL y AS INTEGER, BYVAL clr AS DWORD)
    DECLARE SUB VPut(BYVAL x AS INTEGER, BYVAL y AS INTEGER, Xarray() AS WORD, BYVAL style AS INTEGER)
    DECLARE SUB VScreen(BYVAL mode AS INTEGER, BYVAL apage AS INTEGER, BYVAL vpage AS INTEGER)
    
    DIM vCursor1 AS SHARED BYTE
    DIM vCursor2 AS SHARED BYTE
    DIM vCursorVis AS SHARED BYTE
    DIM vScrnApage AS SHARED BYTE
    DIM vScrnBuff AS SHARED DWORD
    DIM vScrnCols AS SHARED BYTE
    DIM vCsrlin AS SHARED WORD
    DIM vScrnMode AS SHARED WORD
    DIM vScrnRows AS SHARED BYTE
    DIM vPos AS SHARED WORD
    DIM vScrnPxlAttr AS SHARED DWORD
    DIM vScrnTxtFG AS SHARED DWORD
    DIM vScrnTxtBG AS SHARED DWORD
    DIM vScrnVpage AS SHARED BYTE
    DIM vVTxtX1 AS SHARED BYTE
    DIM vVTxtX2 AS SHARED BYTE
    DIM vVTxtY1 AS SHARED BYTE
    DIM vVTxtY2 AS SHARED BYTE
    
    DIM FONT1(255, 5) AS SHARED BYTE
    DIM CurBank AS SHARED WORD
    DIM Bpp AS SHARED SINGLE
    DIM yOffset AS SHARED DWORD
    DIM VidFunc AS SHARED DWORD
    DIM xRes AS SHARED INTEGER
    DIM yRes AS SHARED INTEGER
    DIM wingran AS SHARED INTEGER
    DIM Bpsl AS SHARED INTEGER
    DIM CRLF AS SHARED STRING
    CRLF = CHR$(13, 10)
    
    '
    '****************************************************************************
    ' Set a Pixel to the specified color.(Similar to PSet)
    SUB VPSet (BYVAL x AS INTEGER, BYVAL y AS INTEGER, BYVAL clr AS DWORD) PUBLIC
    DIM offset AS STATIC LONG
    DIM c AS STATIC DWORD
    DIM b AS STATIC WORD
    DIM bank AS STATIC WORD
       c = clr
       b = Bpp
       IF (x < 0) OR (x > xRes) OR (y < 0) OR (y > yRes) THEN EXIT SUB
       offset = VOffset (x, y)
       ! mov ax, &HA000  ; move video segment
       ! mov es, ax      ; into ES
       ! mov di, offset  ; pixel location into DI
       ! DB &H66         ; <-allows 32-bit regs in PB/DOS
       ! mov ax, c       ; color into EAX
       ! mov cx, b       ; simulate select case b
       ! cmp cx, 3
       ! je case3
       ! jg case4
       ! mov cx, b       ; one more time
       ! cmp cx, 1
       ! jl case0
       ! je case1
       ! jg case2
    case0:               ' 4 bit color mode
       ! MOV AH, &H0C
       ! MOV AL, c
       ! MOV BH, vScrnApage
       ! MOV BL, 0
       ! MOV CX, X       ; Column
       ! MOV DX, Y       ; Row
       ! INT &H10        ; uses bios(VERY SLOW!!!)
       ! jmp endselect
    case1:               ' 8 bit color mode
       ! stosb           ; Send byte to video
       ! jmp endselect
    case2:               ' 16 bit color mode
       ! stosw           ; Send word to video
       ! jmp endselect
    case4:               ' 32 bit color mode
       ! DB &H66         ; Use EAX to send
       ! stosw           ; DWORD value to video
       ! jmp endselect
    case3:               ' 24 bit color mode
       ! mov cx, offset
       ! sub cx, 65535   ; only one byte left in bank?
       ! jcxz hardend    ; yes
       ! stosw           ; put low word to video mem first?
       ! cmp offset, 65535 ; any bytes left in bank?
       ! jb easyend      ; yes
       INCR bank         ' no
       VBank bank        ' next bank
       ! mov ax, &HA000  ; re-load the regs
       ! mov es, ax
       ! mov di, 0
       ! DB &H66         ; 32 bit
       ! mov ax, c
    easyend:
       ! mov cl, 16      ; set up 16 bit shift
       ! DB &H66         ; 32-bit reg
       ! sar ax, cl      ; shift the high word into position
       ! stosb           ; send the stray byte to video
       ! jmp endselect
    hardend:
       ! stosb           ; send the first byte
       INCR bank
       VBank bank        ' next bank
       ! mov ax, &HA000  ; re-load the regs
       ! mov es, ax
       ! mov di, 0
       ! DB &H66         ; 32 bit
       ! mov ax, c
       ! mov cl, 8       ; set up 8 bit shift
       ! DB &H66         ; 32 bit
       ! sar ax, cl      ; rotate first byte off
       ! stosw           ; send the other two
    endselect:           ' WASN'T THAT FUN?
    END SUB
    '
    '****************************************************************************
    ' Like basic Get. Doesn't work in 24 bit modes.
    SUB VGet (BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, _
              BYVAL y2 AS INTEGER, asprit () AS WORD) PUBLIC
    DIM y AS STATIC INTEGER
    DIM offset AS STATIC LONG
    DIM bank AS STATIC WORD
    DIM zx AS STATIC WORD
    DIM xSize AS STATIC WORD
    DIM ySize AS STATIC WORD
    DIM DestSeg AS STATIC LONG
    DIM DestOfs AS STATIC LONG
    DIM DestAbs AS STATIC LONG
    DIM SourceAbs AS STATIC LONG
    DIM Elems AS STATIC LONG
    DIM ArrayLen AS STATIC LONG
       xSize = x2 - x1 : ySize = y2 - y1
       IF x2 < x1 THEN SWAP x2, x1
       IF y2 < y1 THEN SWAP y2, y1
       IF x1 + xSize > xRes THEN zx = xRes + 1 - x1 ELSE zx = xSize
       zx = zx * Bpp
       Elems = (xSize + 1) * (ySize + 1) + 2
       IF UBOUND(asprit) < elems THEN ERROR (5)
       asprit (0) = xSize : asprit (1) = ySize
       Elems = 2
       DEF SEG = 0
       FOR y = y1 TO y2
          IF y > yRes THEN ITERATE FOR
          offset = VOffset (x1, y)
          DestSeg& = VARSEG(aSprit(Elems))
          DestOfs& = VARPTR(aSprit(Elems))
          DestAbs& = DestSeg& * 16 + DestOfs&
          SourceAbs& = &HA000 * 16 + offset
          IF offset + (zx) > 65535 THEN
             ArrayLen& = 65536 - offset
             POKE$ DestAbs&, PEEK$(SourceAbs&, ArrayLen&)
             DestAbs& = DestAbs& + ArrayLen&
             ArrayLen& = (zx) - ArrayLen&
             SourceAbs& = &HA000 * 16
             bank = curBank + 1
             VBank bank
          ELSE
             ArrayLen& = (zx)
          END IF
          POKE$ DestAbs&, PEEK$(SourceAbs&, ArrayLen&)
          INCR Elems, xSize + 1
       NEXT y
       DEF SEG
    END SUB
    '
    '****************************************************************************
    ' A little Like basic Put. style 0 is much faster than the others.
    ' absolutely does not work in 24 or 32 bit modes.
    '
    SUB VPut (BYVAL x AS INTEGER, BYVAL y AS INTEGER, aSprite() AS WORD, _
              BYVAL style AS INTEGER) PUBLIC
    DIM I AS STATIC INTEGER
    DIM xSize AS STATIC WORD
    DIM ySize AS STATIC WORD
    DIM ArrayLen AS STATIC LONG
    DIM bSprite(0) AS LOCAL WORD
       xSize = aSprite(0) : ySize = aSprite(1)
       IF style > 0 THEN
          REDIM bSprite((xSize+1)*(ySize+1)+2)
          VGet x, y, x+xSize, y+ySize, bSprite()
          FOR I = 2 TO UBOUND(bSprite)
             IF aSprite(I) > 0 THEN   'Color 0 is transparent unless style = 0
                SELECT CASE style
                   CASE 2 : bSprite(I) = aSprite(I) XOR bSprite(I)  'xor
                   CASE 3 : bSprite(I) = aSprite(I) OR bSprite(I)   'or
                   CASE 4 : bSprite(I) = aSprite(I) AND bSprite(I)  'and
                   CASE ELSE : bSprite(I) = aSprite(I)              'no change
                END SELECT
             END IF
          NEXT I
          DoPut xSize, ySize, x, y, bSprite()
          REDIM bSprite(0)
       ELSE                                           'Color 0 is black
          DoPut xSize, ySize, x, y, aSprite()
       END IF
    END SUB
    '
    '****************************************************************************
    'used by vput
    SUB DoPut(BYVAL xSize AS WORD, BYVAL ySize AS WORD, BYVAL x AS INTEGER, _
              BYVAL y AS INTEGER, LinArr() AS WORD)
    DIM Elems AS STATIC LONG
    DIM sY AS STATIC INTEGER
       Elems = 2
       INCR xSize
       FOR sY = y TO y + ySize
          IF sY > yRes THEN ITERATE FOR
          VHLine x, sY, LinArr(), Elems
          INCR Elems, xSize
       NEXT sY
    END SUB
    '
    '****************************************************************************
    ' Clears the screen to the background color (active video memory page only).
    ' pretty fast. (Doesn't work in all modes)
    SUB VCls () PUBLIC
    DIM last AS STATIC WORD
    DIM bank AS STATIC WORD
    DIM clr AS STATIC DWORD
       IF Bpp < 1 THEN
          VLine 0, 0, xRes, yRes, vScrnTxtBG, %BF
          EXIT SUB
       ELSEIF Bpp = 1 THEN
          clr = (vScrnTxtBG * &H100) + vScrnTxtBG
       ELSE
          clr = vScrnTxtBG
       END IF
       bank = yOffset\&H10000                     ' find beginning
       last = ((yRes * Bpsl) + yOffset) \ &H10000 ' of active page
       DO
          VBank bank
          ! mov ax, &HA000    ; vid seg
          ! mov di, 0         ; start at beginning
          ! mov es, ax
          ! mov ax, clr       ; clear to this color
          ! mov cx, 32768
          ! rep stosw         ; move 64k real fast
          INCR bank
       LOOP UNTIL bank = last ' last bank is done below
    '
       ' This is to prevent the color from bleeding onto the next page??
       ' Pages don't always end on 64K borders
       last = ((yRes * Bpsl) + yOffset) MOD &H10000
       VBank bank
       ! mov ax, &HA000
       ! mov di, 0
       ! mov es, ax
       ! mov ax, clr
       ! mov cx, last
       ! rep stosw            ; finish it
    END SUB
    '
    ' -------------------------------------------------------------------------
    ' -------- see CIRCLE help for parameter details
    ' -------------------------------------------------------------------------
    SUB vCircle (BYVAL Xcen   AS INTEGER , BYVAL Ycen   AS INTEGER , _
                 BYVAL Radius AS INTEGER , BYVAL Colour AS DWORD , _
                 BYVAL Sdeg   AS INTEGER , BYVAL Edeg   AS INTEGER , _
                 BYVAL Aspect AS SINGLE) LOCAL PUBLIC
    
      DIM Erdn  AS LOCAL SINGLE
      DIM Rdn   AS LOCAL SINGLE
      DIM Srdn  AS LOCAL SINGLE
      DIM Steep AS LOCAL SINGLE
      DIM X1    AS LOCAL INTEGER
      DIM Xrad  AS LOCAL SINGLE
      DIM Xo    AS LOCAL INTEGER
      DIM Y1    AS LOCAL INTEGER
      DIM Yrad  AS LOCAL SINGLE
      DIM Yo    AS LOCAL INTEGER
    
      IF Aspect! < 0 THEN
          Xrad! = ABS(Aspect!) * Radius%
          Yrad! = Radius%
        ELSE
          Xrad! = Radius%
          Yrad! = Aspect! * Radius%
      END IF
      Srdn! = fDeg2Rad!( ABS(Sdeg%) )
      Erdn! = fDeg2Rad!( ABS(Edeg%) )
      IF Erdn! => Srdn! THEN INCR Srdn!, 6.28
    
      Xo% = -1
      Yo% = -1
    
      FOR Rdn! = Srdn! TO Erdn! STEP -.003
        X1% = ( Xrad! * COS(Rdn!) )
        Y1% = ( Yrad! * SIN(Rdn!) )
        IF ( X1% <> Xo% )   OR _
           ( Y1% <> Yo% ) THEN
          Xo% = X1%
          Yo% = Y1%
          X1% = Xcen% + X1%
          Y1% = Ycen% - Y1%
          VPSET X1%, Y1%, Colour
        END IF
      NEXT
    
      IF ( Sdeg% < 0 )   OR _
         ( Edeg% < 0 ) THEN
        X1% = ( Xrad! * COS(Srdn!) )
        Y1% = ( Yrad! * SIN(Srdn!) )
        X1% = Xcen% + X1%
        Y1% = Ycen% - Y1%
        VLINE Xcen%, Ycen%, X1%, Y1%, Colour, 0
    
        X1% = ( Xrad! * COS(Erdn!) )
        Y1% = ( Yrad! * SIN(Erdn!) )
        X1% = Xcen% + X1%
        Y1% = Ycen% - Y1%
        VLINE Xcen%, Ycen%, X1%, Y1%, Colour, 0
      END IF
    
    END SUB
    '
    ' -------------------------------------------------------------------------
    ' Used by circle
    FUNCTION fDeg2Rad(SEG Degree AS SINGLE) LOCAL PUBLIC AS SINGLE
    
      DIM F AS LOCAL SINGLE
      'DIM pPi AS STATIC SINGLE
      'pPi! = (4 * ATN(1))
    
      IF Degree! > 89 THEN F! = 2.5 ELSE F! = 0.5
      fDeg2Rad! = (F! * 180) - Degree! + 0.0001
      '(F! * pPi!) - (( pPi! / 180 ) * Degree!) + 0.0001
    
    END FUNCTION
    
    '****************************************************************************
    ' Draws a line, box or filled box.
    SUB VLine (BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, _
               BYVAL y2 AS INTEGER, BYVAL clr AS DWORD, BYVAL Style AS INTEGER) PUBLIC
    DIM sY AS STATIC LONG
    DIM zx AS STATIC WORD
    DIM I AS STATIC LONG
    DIM xSize AS STATIC WORD
    DIM ySize AS STATIC WORD
    DIM bSprite(0) AS LOCAL WORD
       SELECT CASE Style
          CASE 0                         'draw a line
             LineTo X1, Y1, X2, Y2, CLR
          CASE %B                        'Draw a box
             LineTo X1, Y1, X2, Y1, CLR  'TOP
             LineTo X1, Y1, X1, Y2, CLR  'LEFT
             LineTo X1, Y2, X2, Y2, CLR  'BOTTOM
             LineTo X2, Y1, X2, Y2, CLR  'RIGHT
          CASE %BF                               'draw a Filled box
             IF Bpp = 2 THEN
                xSize = X2 - X1+1 : ySize = Y2 - Y1
                IF x1 + xSize > xRes THEN zx = xRes + 1 - x1 ELSE zx = xSize
                REDIM bSprite(zx+2)
                bSprite(0) = zx : bSprite(1) = ySize
                FOR I = 2 TO zx + 2
                   bSprite(I) = clr
                NEXT I
                FOR I = Y1 TO Y2                 ' i'm trying to
                   IF I > yRes THEN ITERATE FOR  ' adapt my vcls
                   VHLine X1, I, bSprite(), 2    ' routine to do
                NEXT I                           ' this.
                REDIM bSprite(0)
             ELSE
                FOR I = Y1 TO Y2                 ' This is a slow way
                   IF I > yRes THEN ITERATE FOR  ' to do this.
                   LineTo X1, I, X2, I, clr
                NEXT I
             END IF
       END SELECT
    END SUB
    '
    '****************************************************************************
    ' Draws a line.(used by line and other graphics statements)
    SUB LineTo (BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, BYVAL x2 AS INTEGER, _
               BYVAL y2 AS INTEGER, BYVAL clr AS DWORD) PUBLIC
    DIM xLength AS STATIC INTEGER
    DIM yLength AS STATIC INTEGER
    DIM xLen AS STATIC INTEGER
    DIM yLen AS STATIC INTEGER
    DIM d1X AS STATIC INTEGER
    DIM d1Y AS STATIC INTEGER
    DIM d2X AS STATIC INTEGER
    DIM d2Y AS STATIC INTEGER
    DIM s AS STATIC INTEGER
    DIM x AS STATIC INTEGER
    DIM y AS STATIC INTEGER
    DIM i AS STATIC INTEGER
       xLength = x2 - x1
       yLength = y2 - y1
       d1X = SGN(xLength)
       d1Y = SGN(yLength)
       d2X = SGN(xLength)
       d2Y = 0
       xLen = ABS(xLength)
       yLen = ABS(yLength)
       IF xLen <= yLen THEN
          d2X = 0
          d2Y = SGN(yLength)
          xLen = ABS(yLength)
          yLen = ABS(xLength)
       END IF
       s = xLen \ 2
       x = x1: y = y1
       FOR i = 0 TO xLen
          VPSet x, y, clr
          s = s + yLen
          IF s >= xLen THEN
             s = s - xLen
             x = x + d1X
             y = y + d1Y
          ELSE
             x = x + d2X
             y = y + d2Y
          END IF
       NEXT i
    END SUB
    '
    '****************************************************************************
    ' Draws a horizontol line. Fast, but does not work well.
    SUB VHLine (BYVAL x1 AS INTEGER, BYVAL y1 AS INTEGER, aSprite() AS WORD, BYVAL El AS LONG)
    DIM zx AS STATIC WORD
    DIM offset AS STATIC LONG
    DIM bank AS STATIC WORD
    DIM xSize AS STATIC WORD
    DIM SourceSeg AS STATIC LONG
    DIM SourceOfs AS STATIC LONG
    DIM SourceAbs AS STATIC LONG
    DIM DestAbs AS STATIC LONG
    DIM ArrayLen AS STATIC LONG
       zx = aSprite(0)
       IF zx + x1 > xRes THEN zx = xRes + 1 - x1
       zx=zx*Bpp
       'INCR zx, zx
       offset = VOffset(x1, y1)
       SourceSeg& = VARSEG(aSprite(El))
       SourceOfs& = VARPTR(aSprite(El))
       SourceAbs& = SourceSeg& * 16 + sourceOfs&
       DestAbs = &HA0000 + offset
       DEF SEG = 0
       IF offset + zx < 65536 THEN
          ArrayLen& = zx
       ELSE
          ArrayLen& = 65536 - offset
          POKE$ DestAbs, PEEK$(SourceAbs&, ArrayLen&)
          SourceAbs& = SourceAbs& + ArrayLen&
          ArrayLen& = zx - ArrayLen&
          bank = curBank + 1
          VBank bank
          DestAbs = &HA0000
       END IF
       POKE$ DestAbs, PEEK$(SourceAbs&, ArrayLen&)
       DEF SEG
    END SUB
    '
    '****************************************************************************
    ' This calculates the offset of a point and switches to the proper bank
    FUNCTION VOffset (BYVAL x AS INTEGER, BYVAL y AS INTEGER) AS LONG
    DIM offset AS STATIC LONG
    DIM bank AS STATIC WORD
    DIM lx AS STATIC LONG
    DIM ly AS STATIC LONG
       lx = x : ly = y
       offset = (Bpsl * ly) + (lx * Bpp) + yOffset
       bank = (offset \ &H10000)
       offset = offset - &H10000 * bank
       !  mov cx, bank        ; is the new bank
       !  sub cx, curBank     ; the same as current bank
       !  jcxz nobnk          ; if yes just leave
       !  mov ax, bank
       !  mov curBank, ax     ; curbank = bank
       !  mul wingran         ; compensate if bank size < 64k
       !  mov dx, ax
       !  mov ax, &H4F05
       !  mov bx, &H0000
       !  call dword VidFunc  ; switch to required bank
    nobnk:
       FUNCTION = offset      ' return position within bank
    END FUNCTION
    
    '****************************************************************************
    ' Just switches the bank
    SUB VBank (BYVAL bank AS INTEGER)
       !  mov cx, bank        ; is bank same
       !  sub cx, curBank     ; as curbank
       !  jcxz nobnk9         ; if yes don't waste time
       !  mov ax, bank
       !  mov curBank, ax     ; set curbank = bank
       !  mul wingran         ; compensate for granularity
       !  mov dx, ax
       !  mov ax, &H4F05
       !  mov bx, &H0000
       !  call dword VidFunc  ; switch to required bank
    nobnk9:
    END SUB
    '
    '****************************************************************************
    ' Sets active video page. it just adds to video memory offset. doesn't verify
    ' if there is enough video memory available for second page though.
    SUB VAPage (BYVAL page AS INTEGER)
       yOffset = ((yRes+1) * Bpsl) * page
       vScrnApage = page
    END SUB
    '
    '****************************************************************************
    ' Set the visible video memory page. also fails to check memory availability.
    SUB VVPage (BYVAL page AS INTEGER)
       vScrnVpage = page
       REG %ax, &H4F07
       REG %bx, 0
       REG %cx, 0
       REG %dx, page * (yRes+1)
       CALL INTERRUPT &H10
    END SUB
    '
    '****************************************************************************
    ' Return the color of a pixel. (kinda like point)
    FUNCTION VPoint (BYVAL x AS INTEGER, BYVAL y AS INTEGER) PUBLIC AS WORD
    DIM offset AS STATIC LONG
    DIM px AS STATIC LONG
    DIM py AS STATIC LONG
    DIM c AS STATIC LONG
       px& = x: py& = y
       IF (px& < 0) OR (px& > xRes) OR (py& < 0) OR (py& > yRes) THEN _
          FUNCTION = 0 : _
          EXIT FUNCTION
    '  END IF
       offset = VOffset(px, py) ' set bank and get offset
       ! push ds         ; save ds for PB
       ! mov ax, &HA000  ; Video segment
       ! mov si, offset  ; Offset in si
       ! mov ds, ax      ; seg into ds
       ! lodsw           ; get pixel value
       ! pop ds          ; restore ds
       ! mov c, ax
       FUNCTION = c      ' return pixel color
    END FUNCTION
    
    '****************************************************************************
    ' Sets the screen to one of the SVGA modes:
    ' "VScreen 0" returns to 80 x 25 text mode. "SCREEN 0" Doesn't work in vesa
    ' modes. Error 5 is generated on failure.
    SUB VScreen (BYVAL mode AS INTEGER, BYVAL apge AS INTEGER, BYVAL vpge AS INTEGER) PUBLIC
    DIM MData AS STRING
       MData = "VBE2" + STRING$(508, 32)         'the default for vbe 2.0 info
       IF mode <> vScrnMode THEN
          IF mode = 0 THEN                       'Easy return to mode zero
             REG %AX, &H3
             CALL INTERRUPT &H10
          ELSEIF DetectVESA(MData) = %FALSE THEN 'Check for VESA
             ERROR 5                             'No VESA
          ELSEIF InfoOnMode(Mode, MData) = %TRUE THEN  'The actual vesa mode routine
             xRes = CVWRD(MData, 19) - 1
             yRes = CVWRD(MData, 21) - 1
             winGran = CVWRD(MData, 5)
             IF winGran > 0 THEN                 'don't ever divide by zero
                winGran = 64 \ winGran           'Get # of banks per 64k
             ELSE
                winGran = 1                      'this may work??
             END IF
             Bpsl = CVWRD(MData, 17)             'BytesPerScanLine
             VidFunc = CVDWD(MData, 13)          'WinFuncPtr
             Bpp = CVBYT(MData, 26) / 8          'Convert bits/pixel to bytes/pixel
             vScrnMode = mode
             REG %AX, &H4F02                     'This call
             REG %BX, mode                       'changes the
             CALL INTERRUPT &H10                 'svga video mode
             IF REG(%AX) <> &H4F THEN ERROR 5    'See if successful
             curBank = 0
             yOffset = 0
             MData = ""                          'recover some memory
          ELSE                                   'Mode not available
             ERROR 5                             'Let user know of failure
          END IF
       END IF
       IF vpge > -1 THEN VVPage vpge             'Added page flipping
       IF apge > -1 THEN VAPage apge             'for compatability
    END SUB
    '
    '****************************************************************************
    FUNCTION InfoOnMode(BYVAL Mode AS INTEGER, MData AS STRING) AS INTEGER
       FUNCTION = %FALSE
       MData = STRING$(512, 65)
       REG %AX, &H4F01		' function 01h, Get Mode Information
       REG %CX, Mode
       REG %ES, STRSEG(MData)	' es:[di] points to Mode Information
       REG %DI, STRPTR(MData)
       CALL INTERRUPT &H10
       ' verify mode has been changed
       IF REG(%AX) = &H4F THEN FUNCTION = %TRUE
    END FUNCTION
    
    '****************************************************************************
    ' see if VESA VBE compatible graphics is available.
    ' Returns 1 if successful, 0 if failed.
    FUNCTION DetectVESA(MData AS STRING) AS INTEGER
       FUNCTION = %FALSE
       REG %AX, &H4F00
       REG %ES, STRSEG(MData)
       REG %DI, STRPTR(MData)
       CALL INTERRUPT &H10
       IF REG(%AX) = &H4F THEN FUNCTION = %TRUE
    END FUNCTION
    
    '****************************************************************************
    SUB VLocate (BYVAL Row AS INTEGER, BYVAL Column AS INTEGER) PUBLIC
       IF Column > xRes\6 THEN
          ERROR 5
       ELSEIF Row > yRes\8 THEN
          ERROR 5
       ELSE
          VPos = Column
          VCsrlin = Row
       END IF
    END SUB
    '
    '****************************************************************************
    SUB VColor (BYVAL fg AS DWORD, BYVAL bg AS DWORD) PUBLIC
       vScrnPxlAttr = fg
       vScrnTxtFG = fg
       vScrnTxtBG = bg
    END SUB
    '
    '****************************************************************************
    ' InitFont - Loads a font from a file (I have included the font array in data
    ' statements at the end of the program.)
    '
    SUB InitFont ()
    DIM X AS STATIC INTEGER
    DIM Y AS STATIC INTEGER
    '   OPEN "NEWFont.DAT" FOR BINARY AS #1         ' to read from file
       RESTORE FontData                      ' to read from data statements
       FOR X = 0 TO 127                             ' can go to 255
          FOR Y = 0 TO 5
    '         GET #1, , FONT1?(X, Y)                ' to read from file
             READ FONT1?(X, Y)               ' to read from data statements
          NEXT Y
       NEXT X
    '   CLOSE #1                                    ' to read from file
       vScrnTxtFG = &HFFFF
       vScrnTxtBG = 0
       vScrnRows = yRes\8
       vScrnCols = xRes\6
    END SUB
    '
    '===========================================================================
    ' VPrint - Prints a text string at row, col in the current font, with the
    '          fg, bg colors.
    SUB VPrint(Tex AS STRING) PUBLIC
    DIM X AS STATIC INTEGER
    DIM A AS STATIC INTEGER
    DIM B AS STATIC INTEGER
    DIM TEMP AS STATIC STRING
    DIM TMP1 AS STATIC BYTE
    DIM COL AS STATIC WORD
    DIM ROW AS STATIC WORD
    DIM CLR AS STATIC DWORD
      ROW = vCsrlin * 8
      COL = vPos * 6
      ' print the text
      FOR X = 1 TO LEN(TEX)
         TEMP = MID$(TEX, X, 1)
         TMP1 = ASC(TEMP)
         IF TEMP = CHR$(13) THEN INCR ROW, 8 : ITERATE FOR
         IF TEMP = CHR$(10) THEN COL = 0 : ITERATE FOR
         IF TMP1 < 0 OR TMP1 > 255 THEN EXIT SUB
         FOR A = 0 TO 5
           FOR B = 0 TO 7
             IF BIT(FONT1(TMP1, A), B) = 1 THEN CLR = vScrnTxtFG ELSE CLR = vScrnTxtBG
             VPSet COL+A, ROW+B+3, CLR
           NEXT B
         NEXT A
         INCR COL, 6
         IF COL > xRes - 6 THEN EXIT FOR
      NEXT X
      vCsrlin = ROW \ 8
      vPos = COL \ 6
    END SUB
    '
    '****************************************************************************
    ' just trying an idea
    SUB vStdOut(text1 as string)
       IF CONSOUT THEN
          vPrint text1
       ELSE
          STDOUT text1
       END IF
    END SUB
    '
    FontData:
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 127,62,28,8,8,0,8,8,28,62,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,120,126,120,96,0,6,30,126,30,6,0
    DATA 0,0,0,0,0,0,0,6,95,6,0,0,7,3,0,7,3,0,36,126,36,126,36,0,36,43,106,18,0,0,99,19,8,100,99,0,54,73,86,32,80,0,0,7,3,0,0,0
    DATA 0,62,65,0,0,0,0,65,62,0,0,0,8,62,28,62,8,0,8,8,62,8,8,0,0,224,96,0,0,0,8,8,8,8,8,0,0,96,96,0,0,0,32,16,8,4,2,0
    DATA 62,81,73,69,62,0,0,66,127,64,0,0,98,81,73,73,70,0,34,73,73,73,54,0,24,20,18,127,16,0,47,73,73,73,49,0,60,74,73,73,48,0,1,113,9,5,3,0
    DATA 54,73,73,73,54,0,6,73,73,41,30,0,0,108,108,0,0,0,0,236,108,0,0,0,8,20,34,65,0,0,36,36,36,36,36,0,0,65,34,20,8,0,2,1,89,9,6,0
    DATA 62,65,93,85,30,0,126,17,17,17,126,0,127,73,73,73,54,0,62,65,65,65,34,0,127,65,65,65,62,0,127,73,73,73,65,0,127,9,9,9,1,0,62,65,73,73,122,0
    DATA 127,8,8,8,127,0,0,65,127,65,0,0,48,64,64,64,63,0,127,8,20,34,65,0,127,64,64,64,64,0,127,2,4,2,127,0,127,2,4,8,127,0,62,65,65,65,62,0
    DATA 127,9,9,9,6,0,62,65,81,33,94,0,127,9,9,25,102,0,38,73,73,73,50,0,1,1,127,1,1,0,63,64,64,64,63,0,31,32,64,32,31,0,63,64,60,64,63,0
    DATA 99,20,8,20,99,0,7,8,112,8,7,0,113,73,69,67,0,0,0,127,65,65,0,0,2,4,8,16,32,0,0,65,65,127,0,0,4,2,1,2,4,0,128,128,128,128,128,128
    DATA 0,3,7,0,0,0,32,84,84,84,120,0,127,68,68,68,56,0,56,68,68,68,40,0,56,68,68,68,127,0,56,84,84,84,8,0,8,126,9,9,0,0,24,164,164,164,124,0
    DATA 127,4,4,120,0,0,0,0,125,64,0,0,64,128,132,125,0,0,127,16,40,68,0,0,0,0,127,64,0,0,124,4,24,4,120,0,124,4,4,120,0,0,56,68,68,68,56,0
    DATA 252,68,68,68,56,0,56,68,68,68,252,0,68,120,68,4,8,0,8,84,84,84,32,0,4,62,68,36,0,0,60,64,32,124,0,0,28,32,64,32,28,0,60,96,48,96,60,0
    DATA 108,16,16,108,0,0,156,160,96,60,0,0,100,84,84,76,0,0,8,62,65,65,0,0,0,0,119,0,0,0,0,65,65,62,8,0,2,1,2,1,0,0,96,80,72,80,96,0
    DATA 60,66,66,196,38,0,56,66,64,58,64,0,56,84,86,9,0,0,32,86,85,86,120,0,32,85,84,85,120,0,32,85,86,84,56,0,32,84,86,84,56,0,56,68,196,68,40,0
    DATA 56,86,85,86,8,0,56,86,84,86,8,0,62,73,85,85,65,62,0,0,0,0,0,0,127,127,62,28,8,0,8,28,62,127,127,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,8,8,8,8,14,0,16,16,16,16,112,0,32,23,8,212,178,0,32,23,104,68,226,0,81,53,31,104,68,226,8,20,34,8,20,34,34,20,8,34,20,8
    DATA 17,68,17,68,17,68,85,170,85,170,85,170,255,255,255,255,255,255,0,0,0,255,0,0,8,8,8,255,0,0,36,36,36,255,0,0,8,255,0,0,255,0,8,248,8,8,248,0
    DATA 36,36,36,252,0,0,36,231,0,0,255,0,0,255,0,0,255,0,36,228,4,4,252,0,36,39,32,32,63,0,8,15,8,8,15,0,36,36,36,63,0,0,8,8,8,248,0,0
    DATA 0,0,0,15,8,8,8,8,8,15,8,8,8,8,8,248,8,8,0,0,0,255,8,8,8,8,8,8,8,8,8,8,8,255,8,8,0,0,0,255,36,36,0,255,0,0,255,8
    DATA 0,63,32,32,39,36,0,252,4,4,228,36,36,39,32,32,39,36,36,228,4,4,228,36,0,255,0,0,231,36,36,36,36,36,36,36,36,231,0,0,231,36,36,36,36,39,36,36
    DATA 8,15,8,8,15,8,36,36,36,228,36,36,8,248,8,8,248,8,0,15,8,8,15,8,0,0,0,63,36,36,0,0,0,252,36,36,0,248,8,8,248,8,8,255,8,8,255,8
    DATA 36,36,36,255,36,36,8,8,8,15,0,0,0,0,0,248,8,8,255,255,255,255,255,255,240,240,240,240,240,240,255,255,255,0,0,0,0,0,0,255,255,255,15,15,15,15,15,15
    DATA 127,65,73,93,73,127,127,65,73,73,73,127,127,65,73,221,73,127,127,65,73,201,73,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,22,124,22,21,0,64,56,84,56,4,0,40,84,68,32,0,0,120,4,4,4,120,0
    DATA 42,42,42,42,42,0,68,68,95,68,68,0,81,81,74,68,0,0,68,74,81,81,0,0,0,0,126,1,0,0,0,0,64,63,0,0,8,8,42,8,8,0,36,18,18,36,18,0
    DATA 0,8,20,8,0,0,0,16,56,16,0,0,0,0,8,0,0,0,16,48,64,48,14,1,0,15,2,1,14,0,0,0,13,11,0,0,0,60,60,60,60,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


    ------------------

  • #2

    Code:
    ' Save this as "DEMO.BAS" or whatever turns you on.
    '
    ' this demo will NOT work in 24 or 32 bit color mode, unless you comment
    ' out all of the calls to vPut (vPut needs a lot of work)
    '
    ' this code sample demonstrates the libs line, circle and pixel drawing
    ' capabilities. It also does some page flipping and has a little mouse
    ' routine that I threw together for fun. Most of the mouse subs are the
    ' ones that came with PB (just slightly altered).
    '
    $INCLUDE "PBVESA.BAS"   'Include the lib code
    '
    '-=-=-=-=-=-=-=-=-=-=-=-=-=-DEMO CODE STARTS HERE-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DIM UseMouse AS SHARED INTEGER
    DIM arrow(1024) AS SHARED WORD
    DIM MsRid(1024) AS SHARED WORD
    '
    ON ERROR GOTO KILLME  ' set up minimal error handling
    '
    InitFont              ' must load font to use vPrint
    SCREEN 12             ' Mouse driver doesn't work right unless you do this??
    %TstMode = &H117          ' use this equate to set the mode in order
    '                         ' to keep in sync with page flip routines.
    vScreen %TstMode, -1, -1  ' Set screen mode. not all modes
    '                         ' are valid on all machines.
    '
    '--------------------------------------------------------------------------
    ' Get the mouse ready to go
      IF MsThere THEN                     'is mouse even there?
         MsSetWindow 0, 0, yRes, xRes     'yes set resolution to match mode
         MsSetRatio 100, 100, 100         'speed it up a little
         LoadCsr arrow()                  'load demo cursor
         vColor 0, &H3500
         Mouse = %TRUE
      ELSE                                'no mouse
         vPrint "mouse not there"         'inform user
         DELAY 3                          'let them read it
         'GOTO KILLME
      END IF
    
      vCls
    '
    '---------------------------------------------------------------------------
    ' Use vline and vcircle to draw some stuff
    '
       vLine 0, 0, 1023, 767, &HFFFF, %B
       vLine 10, 10, 512, 384, &HFFEE, %B
       vLine 360, 300, 670, 548, &HFEFE, %BF
       vCircle 720, 600, 180, &H99FE, 1, 1, 1
       vCircle 220, 280, 180, &H1C1E, 1, 1, 1.2
       vCircle 512, 384, 480, &HFFCC, 1, 1, .8
       vLine 500, 100, 840, 380, &H55E123, %B
       vLine 500, 100, 840, 380, &H55456B, 0
    '
       vColor &H2222, &HFEFE
       vLocate 48, 70
       vPrint "1024 x 768 x 65536 mode"
       vLocate 58, 70
       vPrint "Press any key to continue"
    '
    '---------------------------------------------------------------------------
    ' this mouse demo was much harder than it looks
    '
       vLine 360, 300, 670, 548, &HFEFE, %BF
       vLocate 50, 70
       vPrint "Don't forget to try the Mouse!"
       vLocate 52, 70
       vPrint "Button Row Column"
       MsStatus Button, Row, Column                 'find the mouse
       vGet Column, Row, Column+16, Row+20, MsRid() 'save the spot
       OldRow = Row
       OldCol = Column
       vPut Column, Row, arrow(), 1                 'draw the cursor
       vLocate 53, 70
       vPrint STR$(Button) + SPACE$(4) + STR$(Row) + SPACE$(2) + STR$(Column) + SPACE$(3)
       vLocate 58, 70
       vPrint "Press any key to continue"
       DO
          MsStatus Button, Row, Column                    'find the mouse
          IF Row <> OldRow OR _
             Column <> OldCol OR _
             Button <> OldButton THEN                     'if mouse moved
             vPut OldCol, OldRow, MsRid(), 0              'restore the old spot
             vLocate 53, 70 : vPrint STR$(Button) + SPACE$(14)
             vLocate 53, 76 : vPrint STR$(Row)
             vLocate 53, 81 : vPrint STR$(Column)
             vGet Column, Row, Column+16, Row+20, MsRid() 'save the new spot
             vPut Column, Row, arrow(), 1                 'draw cursor
             OldRow = Row : OldCol = Column : OldButton = Button
          END IF
       LOOP WHILE INKEY$ = ""
    '
    '---------------------------------------------------------------------------
    '
       vScreen %TstMode, 1, 1        'Draw on another video page
    '
    '---------------------------------------------------------------------------
    'use vpset to draw a nice pattern
    '
       FOR I = 1 TO 768
          FOR J = 1 TO 1024
             vPset J-1, I-1, I*J
          NEXT J
       NEXT I
    '
    '---------------------------------------------------------------------------
    ' Demo of page flipping
    '
       x = 0
       DO
          VScreen %TstMode, -1, x    'now flip the page
          x = 1 - x                  'back and forth
          DELAY .5                    'slow it down a lot
       LOOP WHILE INKEY$ = ""        'until you press a key
       vScreen %TstMode, 0, 0        'clean up the mess
    '
    '--------------------------------------------------------------------------
    ' this looks pretty cool on a fast machine
    '
       vLine 360, 300, 670, 548, &HFEFE, %BF
       vLocate 50, 70
       vPrint "Press any key to start the last demo"
       vLocate 52, 70
       vPrint "Just press any key again to end the demo"
       DO : LOOP WHILE INKEY$ = ""
       vColor &HFEFE, 0
       vCls
       Mstfi                                  'one last demo
    '
    '--------------------------------------------------------------------------
    ' this just gets things back to normal
    '
    KILLME:
       VScreen 0, -1, -1                      'Back to text mode
       DEF SEG
       IF ERR THEN
          PRINT "ERROR#", ERR                 'Display the error number
          PRINT "ERROR ADDRESS", ERADR        'and the error address
       END IF
    END                                       'Shut down
    '
    '------------------------------------------------------------------------
    SUB Mstfi()
     DIM MAXCOLOR AS LOCAL DWORD
     DIM WX(4, 15) AS LOCAL INTEGER
     DIM WY(4, 15) AS LOCAL INTEGER
     DIM WXX(4, 15) AS LOCAL INTEGER
     DIM WYY(4, 15) AS LOCAL INTEGER
     DIM STAPX(4) AS LOCAL INTEGER
     DIM STAPY(4) AS LOCAL INTEGER
     DIM STAPXX(4) AS LOCAL INTEGER
     DIM STAPYY(4) AS LOCAL INTEGER
     DIM X(4) AS LOCAL INTEGER
     DIM Y(4) AS LOCAL INTEGER
     DIM XX(4) AS LOCAL INTEGER
     DIM YY(4) AS LOCAL INTEGER
     DIM COLOR1 AS LOCAL DWORD
     DIM COLOR2 AS LOCAL DWORD
     DIM Z AS LOCAL INTEGER
     DIM ZZ AS LOCAL INTEGER
     DIM R AS LOCAL INTEGER
     DIM RR AS LOCAL INTEGER
     DIM MAX1 AS LOCAL INTEGER
     DIM MAX2 AS LOCAL INTEGER
     DIM HOLDIT AS LOCAL INTEGER
     DIM W AS LOCAL INTEGER
     DIM WW AS LOCAL INTEGER
     DIM J AS LOCAL INTEGER
     DIM I AS LOCAL INTEGER
     DIM XZ AS LOCAL INTEGER
     DIM COUNTER1 AS LOCAL INTEGER
     DIM COUNTER2 AS LOCAL INTEGER
     DIM XI AS LOCAL STRING
     SELECT CASE Bpp
        CASE 1 : MAXCOLOR = &HFF
        CASE 2 : MAXCOLOR = &HFFFF
        CASE 3 : MAXCOLOR = &HFFFFFF
        CASE 4 : MAXCOLOR = &HFFFFFFFF
        CASE ELSE : MAXCOLOR = &HF
     END SELECT
     ' set screen, set random, dimension wipe-pointsvariables -----------------
      RANDOMIZE TIMER
     ' set various variables --------------------------------------------------
      R = 5
      RR = 4
      Z = 2
      ZZ = 3
      MAX1 = INT(RND * 50) + 50
      MAX2 = INT(RND * 75) + 75
      COLOR1 = INT(RND * 7) + 9
      COLOR2 = INT(RND * 7) + 9
      HOLDIT = 0
            W = 15             'set number of lines in polygon 1 (max 15)
           WW = 15             'set number of lines in polygon 2 (max 15)
     REM calculate vert. & horz. steps for all cornerpoints -------------------
     FOR I = 1 TO 4
    	STAPX(I) = INT(RND * R) + Z
    	STAPY(I) = INT(RND * R) + Z
    	X(I) = INT(RND * 320)
    	Y(I) = INT(RND * 200)
    	STAPXX(I) = INT(RND * RR) + ZZ
    	STAPYY(I) = INT(RND * RR) + ZZ
    	XX(I) = INT(RND * 320)
    	YY(I) = INT(RND * 200)
     NEXT
     MAINLOOP: '--------------------------------------------------------------
            'WAIT &H3DA, 8                   ' these two lines slow it down
            'WAIT &H3DA, 8, 8                ' on fast machines
    	VLine X(1), Y(1), X(2), Y(2), COLOR1, 0
    	VLine X(2), Y(2), X(3), Y(3), COLOR1, 0
    	VLine X(3), Y(3), X(4), Y(4), COLOR1, 0
    	VLine X(4), Y(4), X(1), Y(1), COLOR1, 0
    	VLine XX(1), YY(1), XX(2), YY(2), COLOR2, 0
    	VLine XX(2), YY(2), XX(3), YY(3), COLOR2, 0
    	VLine XX(3), YY(3), XX(4), YY(4), COLOR2, 0
    	VLine XX(4), YY(4), XX(1), YY(1), COLOR2, 0
    	' swap all cornerpoints 1 step forward ---------------------------
    	FOR J = 1 TO 4
    		FOR I = 15 TO 2 STEP -1
    			WX(J, I) = WX(J, I - 1)
    			WY(J, I) = WY(J, I - 1)
    			WXX(J, I) = WXX(J, I - 1)
    			WYY(J, I) = WYY(J, I - 1)
    		NEXT
    		' pick new corners for polygon 1 -------------------------
    		WX(J, 1) = X(J)
                    X(J) = X(J) + STAPX(J)
    		IF X(J) > (xRes) THEN STAPX(J) = -(INT(RND * R) + Z)
    		IF X(J) < 5 THEN STAPX(J) = INT(RND * R) + Z
    		WY(J, 1) = Y(J)
                    Y(J) = Y(J) + STAPY(J)
    		IF Y(J) > (yRes) THEN STAPY(J) = -(INT(RND * R) + Z)
    		IF Y(J) < 1 THEN STAPY(J) = INT(RND * R) + Z
    		' pick new corners for polygon 2 -------------------------
    		WXX(J, 1) = XX(J)
    		XX(J) = XX(J) + STAPXX(J)
    		IF XX(J) > (xRes) THEN STAPXX(J) = -(INT(RND * RR) + XZ)
    		IF XX(J) < 5 THEN STAPXX(J) = INT(RND * RR) + ZZ
    		WYY(J, 1) = YY(J)
    		YY(J) = YY(J) + STAPYY(J)
    		IF YY(J) > (yRes) THEN STAPYY(J) = -(INT(RND * RR) + ZZ)
    		IF YY(J) < 1 THEN STAPYY(J) = INT(RND * RR) + ZZ
    	NEXT
    	' wipe last polygon 1 --------------------------------------------
    	VLine WX(1, W), WY(1, W), WX(2, W), WY(2, W), 0, 0
    	VLine WX(2, W), WY(2, W), WX(3, W), WY(3, W), 0, 0
    	VLine WX(3, W), WY(3, W), WX(4, W), WY(4, W), 0, 0
    	VLine WX(4, W), WY(4, W), WX(1, W), WY(1, W), 0, 0
    	' wipe last polygon 2 --------------------------------------------
    	VLine WXX(1, WW), WYY(1, WW), WXX(2, WW), WYY(2, WW), 0, 0
    	VLine WXX(2, WW), WYY(2, WW), WXX(3, WW), WYY(3, WW), 0, 0
    	VLine WXX(3, WW), WYY(3, WW), WXX(4, WW), WYY(4, WW), 0, 0
    	VLine WXX(4, WW), WYY(4, WW), WXX(1, WW), WYY(1, WW), 0, 0
    	GOSUB COUNTER
     GOTO MAINLOOP
     COUNTER: '---------------------------------------------------------------
    	COUNTER1 = COUNTER1 + 1
            IF COUNTER1 = MAX1 THEN GOSUB SETCOLOR1
    	COUNTER2 = COUNTER2 + 1
            IF COUNTER2 = MAX2 THEN GOSUB SETCOLOR2
    	XI$ = INKEY$
            IF XI$ <> "" THEN EXIT SUB
     RETURN
     SETCOLOR1: '-------------------------------------------------------------
    	COLOR1 = (RND * MAXCOLOR) + 1
    	IF COLOR1 = 0 THEN GOTO SETCOLOR1
    	MAX1 = INT(RND * 50) + 50
    	COUNTER1 = 1
     RETURN
     SETCOLOR2: '-------------------------------------------------------------
    	COLOR2 = RND * MAXCOLOR
    	IF COLOR2 = 0 THEN GOTO SETCOLOR2
    	MAX2 = INT(RND * 75) + 75
    	COUNTER2 = 1
     RETURN
    END SUB
    
    '===========================================================================
    ' MsStatus - Return button(s) pressed, row and column of cursor.
    '
    ' Button = Current button(s) pressed.  Left button - 1, Right button - 2,
    '          Middle button - 4 (combined buttons are added to each other)
    ' Row    = Current mouse cursor row
    ' Column = Current mouse cursor column
    '
    SUB MsStatus(Button AS INTEGER, Row AS INTEGER, Column AS INTEGER) PUBLIC
      IF UseMouse THEN
        ! push DS                ; save DS for PowerBASIC
        ! mov  AX, &H03          ; function 03h, get mouse status
        ! int  &H33              ; call mouse interrupt
        ! les  DI, Button        ; point ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I to Button
        ! mov  ES:[DI], BX       ; put active button(s) in variable
        ! les  DI, Row           ; point ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I to Row
        ! mov  ES:[DI], DX       ; put mouse row in variable
        ! les  DI, Column        ; point ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I to Column
        ! mov  ES:[DI], CX       ; put mouse column in variable
        ! pop  DS                ; restore DS for PowerBASIC
      END IF
    END SUB
    
    
    '===========================================================================
    ' MsThere - Returns true if mouse driver is present.
    '
    FUNCTION MsThere PUBLIC AS INTEGER
      ! push DS                 ; save DS for PowerBASIC
      ! xor  AX, AX             ; clear AX
      ! int  &H33               ; call mouse driver
      ! xor  BX, BX             ; clear BX, assume no mouse present
      ! or   AX, AX             ; does AX = 0?
      ! jz   MsThereDone        ; yes, we're done
      ! dec  BX                 ; no, make it -1
    MsThereDone:
      ! mov  SS: UseMouse, BX   ; set flag for other mouse routines
      ! mov  FUNCTION, BX       ; put BX in RetVal variable
      ! pop  DS                 ; restore DS
    END FUNCTION
    
    '===========================================================================
    ' MsSetRatio - Set the mickeys-per-pixel mouse cursor movement ratio.
    '
    SUB MsSetRatio (Horiz%, Vert%, Sense%)
      IF UseMouse THEN
        REG 1, &H1A           ' mouse driver function F, Set Mouse movement Ratio
        REG 2, Horiz%         ' horizontal mickeys (1 - 32,767; default = 8)
        REG 3, Vert%          ' vertical mickeys (1 - 32,767; default = 16)
        REG 4, Sense%
        CALL INTERRUPT  &H33  ' call driver
      END IF
    END SUB
    
    
    '===========================================================================
    ' MsSetWindow - Defines window for mouse cursor.  The mouse cursor will not
    '               be allowed outside of this defined area.
    '
    ' Row  = Top row for mouse window boundary
    ' Col  = Left column for mouse window boundary
    ' Rows = Total rows for mouse window boundary
    ' Cols = Total columns for mouse window boundary
    '
    SUB MsSetWindow(BYVAL Row  AS INTEGER, BYVAL Col  AS INTEGER,_
                    BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER) PUBLIC
      IF UseMouse THEN
        ! push DS                ; save DS for PowerBASIC
        ! mov  CX, Row           ; put start row in CX
        ! mov  DX, Rows          ; put end row in DX
        ! mov  AX, &H08          ; function 08h, set vertical limit
        ! int  &H33              ; call mouse interrupt
        ! mov  CX, Col           ; put start column in CX
        ! mov  DX, Cols          ; put end column in DX
        ! mov  AX, &H07          ; function 07h, set horizontal limit
        ! int  &H33              ; call mouse interrupt
        ! pop  DS                ; restore DS for PowerBASIC
        MsLocate Row, Col        ' move mouse cursor to upper left corner
      END IF
    END SUB
    
    
    '===========================================================================
    ' MsLocate - Locates the mouse cursor at Row, Column.
    '
    ' Row    = New mouse cursor row
    ' Column = New mouse cursor column
    '
    SUB MsLocate(BYVAL Row AS INTEGER, BYVAL Column AS INTEGER) PUBLIC
      IF UseMouse THEN
        ! push DS                ; save DS for PowerBASIC
        ! mov  AX, &H04          ; function 04h, set mouse location
        ! mov  CX, Column        ; put column in CX
        ! mov  DX, Row           ; put row in DX
        ! int  &H33              ; call mouse interrupt
        ! pop  DS                ; restore DS for PowerBASIC
      END IF
    END SUB
    
    
    '===========================================================================
    ' LoadCsr just reads in mouse cursor data
    '
    SUB LoadCsr(MseAry??())
       RESTORE MouseCursor                       'set read point
       FOR I = 0 TO 19
          FOR J = 0 TO 15
             READ X?                             'get the data
             SELECT CASE X?                      'display the data
                CASE 0 : vPset J, I, 0
                CASE 1 : vPset J, I, &HFFFF
                CASE 2 : vPset J, I, 2
             END SELECT
          NEXT J
       NEXT I
      VGet 0, 0, 15, 19, MseAry??()     'Grab a sprite
      FOR I = 0 TO 19                   'get rid of the evidence
         FOR J = 0 TO 15
            vPset J, I, 0
         NEXT J
      NEXT I
    END SUB
    
    'Below is the cursor data(if you look closely you can see it)
    MouseCursor:
    DATA 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 2,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 2,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0
    DATA 2,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0
    DATA 2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,1,2,0,0,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,1,1,2,0,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,1,1,1,2,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,2,2,2,2,0,0,0,0,0,0
    DATA 2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0
    DATA 2,1,2,2,1,1,2,0,0,0,0,0,0,0,0,0
    DATA 2,2,0,0,2,1,1,2,0,0,0,0,0,0,0,0
    DATA 2,0,0,0,2,1,1,2,0,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,2,1,1,2,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,2,1,1,2,0,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,2,1,1,2,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,2,1,2,2,0,0,0,0,0,0
    DATA 0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0

    ------------------

    Comment


    • #3

      Let's not forget the docs, such as they are.

      Vesa Graphics Library for the PowerBASIC/DOS compiler.

      This table represents the sum total of my knowledge of the Vesa screen modes.
      Code:
            PB/Vesa     Mode#     Resolution     Color     bits/     tele
            Support     (hex)     horz  vert     depth     pixel     type
            ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
              Yes        100       640   400       256        8     (80x25)*
              Yes        101       640   480       256        8     (80x30)*
              Yes        102       800   600        16        4    (100x37)*
              Yes        103       800   600       256        8    (100x37)*
              Yes        104      1024   768        16        4    (128x48)*
              Yes        105      1024   768       256        8    (128x48)*
              Yes        106      1280  1024        16        4    (160x64)*
              Yes        107      1280  1024       256        8    (160x64)*
             #Yes        108        80    60         ?      n/a        #
             #Yes        109       132    25         ?      n/a        #
             #Yes        10A       132    43         ?      n/a        #
             #Yes        10B       132    50         ?      n/a        #
             #Yes        10C       132    60         ?      n/a        #
                @        10D       320   200     32767       15        @
                @        10E       320   200     65536       16        @
                @        10F       320   200     16.8M       24        @
              Yes        110       640   480     32767       15        !
              Yes        111       640   480     65536       16        !
              Yes        112       640   480     16.8M       24        !
              Yes        113       800   600     32767       15        !
              Yes        114       800   600     65536       16        !
              Yes        115       800   600     16.8M       24        !
              Yes        116      1024   768     32767       15        !
              Yes        117      1024   768     65536       16        !
              Yes        118      1024   768     16.8M       24        !
              Yes        119      1280  1024     32767       15        !
              Yes        11A      1280  1024     65536       16        !
              Yes        11B      1280  1024     16.8M       24        !
              Yes        11C       640   400     65536       16        !
              Yes        11D       640   480     16.8M       32        !
              Yes        11E       800   600     16.8M       32        !
              Yes        11F      1024   768     16.8M       32        !
              Yes        120      1600  1200       256        8        !
                @        121      1600  1200     32767       15        @
                @        122      1600  1200     65536       16        @
      ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
      @ = mode not supported by my card, so I could not test it.
      * = works on my card, but may vary by card.
      ! = does not work on my card, but may vary by card.
      # = Text Modes - text modes have not been fully tested yet, but seem to
      work just fine(using bios to print).
      Not all cards will support all modes. Use the detectvesa function to find
      the necessary mode support info to satisfy your specific needs.

      The 16 color(4bit/pix) modes use the bios so they are sloooow. I still have
      to figure out direct screen writes in 16 color mode.

      24 bit modes are a bear. Hence most of these routines do not work in 24 bit
      mode. I'll work on that. vPut does not work in 24 or 32 bit mode.

      32 bit colors are effectively the same as 24 bit colors. The card simply
      ignores the high byte on each 32 bit pixel. If the high byte is used for
      anything, I have no idea what. The only reason I can see for 32 bit modes to
      exist is because 32 bit values are easier to deal with than 24 bit values.
      (see SUB VPset to see what I mean.)
      ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

      I created this library of vesa graphics commands for several reasons, primary
      of which were:

      1. I wanted a Vesa graphics lib that was free(because I'm broke)

      2. I needed it to work in real mode(I couldn't always have DPMI available)

      3. I wanted the source code(so I could change it if it didn't work right)

      4. I needed it to work with my flakey video card(uses 16k bank switching)

      5. I wanted the commands to work as much like their basic counterparts as
      possible (why learn a whole new syntax when I already know one)

      Although most Vesa libs met 2 or 3 of these criteria, none seemed to meet all
      of my needs, so I had to create one of my own. Even with the constraints of
      time, and my own limited programming abilities, I was able to come up with a
      set of routines that satisfied most of my needs. But enough about me.

      Most of the routines kind of resemble their basic counterparts, if you don't
      examine them too closely. So if you know basic you should be able to figure
      them out without too much trouble. So I'll just try to explain each command in
      a useful way.


      vCircle
      ===========================================================================
      Purpose:
      vCircle draws a circle or part of a circle on the VESA Graphics screen.

      Syntax:
      vCircle x, y, Radius, Color, Start, End, Aspect

      Remarks:
      I've tried to imitate the Basic circle statement to the best of my ability,
      but many differences are still apparent. First of all "Step" is not supported
      at all(but I'm working on it). Also Optional parameters are not yet implemented
      (working on that too), So you will have to include color, start, End, and
      Aspect for now. For Start, End and Aspect, "1" is a good default.


      vCls
      ===========================================================================
      Purpose:
      Clears the screen to the background color.

      Syntax:
      vCls

      Remarks:
      This just clears the active screen to the background color, nothing fancy.


      vColor
      ===========================================================================
      Purpose:
      Sets the foreground and background colors for displaying text.

      Syntax:
      vColor Foreground, Background

      Remarks:
      Should be able to use any colors supported by the current screen mode.
      Different screen modes support extremely different color depths. You have to
      program specifically for the mode your using and it's hard to make old code or
      graphics look just right(need a good conversion algo).


      vCsrLin
      ===========================================================================
      Purpose:
      Returns the screen row that the cursor is currently located on.

      Syntax:
      row = vCsrLin

      Remarks:
      Currently vCsrLin is just a variable that tracks the current row to be used
      by vPrint.


      vGet
      ===========================================================================
      Purpose:
      Copies part of a graphics screen into an array.

      Syntax:
      vGet x1, y1, x2, y2, array

      Remarks:
      Works similar to PB's Get statement(when it works at all!). Currently very
      few vesa modes are supported(mostly the 16 bit modes, I think? 24 bit modes
      cause the code to crash).


      vLine
      ===========================================================================
      Purpose:
      Draws a straight line, a box, or a filled box on the screen.

      Syntax:
      vLine x1, y1, x2, y2, color, style

      Remarks:
      x1, y1, x2, y2 specify the coordinates(in pixels) of the ends of the line
      or of diagonally opposite corners of a box. Coordinates must be absolute.Color
      is a Dword value describing any color supported by the current screen mode.
      Style 0 draws a line, 1 (or %B predefined equate) draws a box, 2 (or %BF
      predefined equate) draws a filled box.


      vLocate
      ===========================================================================
      Purpose:
      Sets position of next text character.

      Syntax:
      Locate row, column

      Remarks:
      Use before vPrint to control where the output will appear on screen. Vprint
      updates the column, but does not change the row, ever.


      vPoint
      ===========================================================================
      Purpose:
      Returns the color of a screen pixel.

      Syntax:
      color = vPoint(row, column)

      Remarks:
      Returns the color of the pixel at (row, column).


      vPos
      ===========================================================================
      Purpose:
      Returns the screen column that the cursor is currently located in.

      Syntax:
      column = vPos

      Remarks:
      Currently vPos is just a variable that tracks the current column to be used
      by vPrint. VPrint updates the column.


      vPrint
      ===========================================================================
      Purpose:
      Display text on screen.

      Syntax:
      vPrint text$

      Remarks:
      Just plops the text down on the screen at the current row, column as set by
      vLocate. also advances the column pointer to first character position after the
      text printed.


      vPset
      ===========================================================================
      Purpose:
      Plots a point on the graphic screen.

      Syntax:
      vPset x, y, color

      Remarks:
      x, y are the coordinates of the point to plot on the screen. Color is a
      Dword value describing any color supported by the current screen mode.


      vPut
      ===========================================================================
      Purpose:
      Copies the contents of an array to the graphics screen.

      Syntax:
      vPut x, y, array, style

      Remarks:
      A little like the Basic "Put" graphics statement(when it works).
      x, y are coordinates of upper left corner of area where array will beplaced.
      Array is generally produced by vGet statement. Style = 0, 1, 2, 3 or 4(equates
      %pset = 0, %preset = 1, %xor = 2, %or = 3, %and = 4). style 0 is fastest
      because it skips all processing. vPut does not work well in all screen modes
      (I'm trying to fix it though). Does not work at all in 24 bit or 32 bit color
      modes. Some portions of the vPut code may not work in any mode.


      vScreen
      ===========================================================================
      Purpose:
      Sets the screen display mode.

      Syntax:
      vScreen mode, apage, vpage

      Remarks:
      Much like basic screen statement, but "mode" must be a vesa screen mode or
      0 to return to text mode. apage and vpage added for compatability, should be -1
      when not being changed.


      vStdOut
      ===========================================================================
      Purpose:
      Write data to standard output device.

      Syntax:
      vStdOut text$

      Remarks:
      Allows screen printing to be redirected to a printer or a file using DOS
      redirection syntax on the command line.


      ----------------------------------------------------------------------------
      Wish list:
      These are some of the other Basic statements/functions that I hope to add
      versions of to the VESA lib in the future(if I have time to code them).

      Paint - A "must have" utility function.
      Pcopy - May be way too slow in real mode
      Pmap - May be needed with window statement?
      View - This may require modifications to most of the other commands.
      Window - Hard one, lots of math(my math skills are weak).

      These are some of the screen related statements/functions that will most
      likely never even be attempted.

      Draw - Too complex, draw is like a mini programming language by itself.
      Palette - Most people seem to use their own palette routines anyway.
      Preset - Identical to Pset except for default color(which reqires use
      of optional parameters which I haven't figured out yet...).
      Screen Function - I have never used this one, anyway.
      Print Using - Just format text with USING$ like this:
      vPrint USING$(fmt$, text$)
      Spc - Use SPACE$: vPrint SPACE$(num) + text$.
      Tab - Wouldn't even know where to begin.
      Width - Would need scalable fonts or something?
      Write - Too much like print.



      ------------------

      Comment


      • #4
        Originally posted by Buck Huffman:
        I've messed with this a little. Removed ellipse, fillellipse, ttyprint,
        etc..., fixed some bugs, added some demo code and docs. The previous posting
        was not really that good. This is a little better.'
        Gives error 427 "integer constant expected" in line 198:
        ! DB &H66
        when compiled with PB32.

        Any help?

        Best Regards,

        Arthur.

        Post your replay in PB/DOS forum - same topic!

        ------------------


        [This message has been edited by Arthur Gomide (edited August 31, 2006).]
        "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

        Comment

        Working...
        X