QB Times Issue #9


Future Library Document

V 1.00
Contents

1Introduction
2 How to Make your library
3 Preparing the library for your program
4 Using the Future Library
4.1 Setting Screenmode -FUNCTION isVesa
-SUB Set####x#### (b)
-SUB ResetScreen
-FUNCTION Future.ModeList(IndexNumber%)
4.2 Paging
-FUNCTION pages
-SUB Setpage(page)
-SUB Viewpage(page)
4.3 Print
-SUB Future.PRINT (X,Y, T$, F, B)
-SUB SetFont (Mode)
-SUB Future.LoadFONT (filename$)

1) =="Introduction"==


This document explains and describes how the functions of the Future Library works. Because people find the html version to briefly. This document is made to make it easier to understand, how to program with this library.

Currently this document is for Future Library Version 3.00

Unlike the HTML document, this program has easier example programs each paragraph mentions the example program so you know what each example program does.

2) =="How to Make your Library"==


Unlike the previous versions, you can now set what you want to be included in the library. The program FLBUILD.EXE is delivered for this job. If this is the first time you run FLBUILD.EXE, you should set up your QB45 dir. You can do that by:

  • Click on PROGRAM
  • hold the mousebutton and move your mouse to PROGRAM
  • release mousebutton.

    A new window pops up and asks you to fill in the drive+dir of your QB45 dir. You can also specify if you want it to create a logfile. After filling in the directory , click on OK.

    Now, to set what you want to be included in the library:

  • Click on PROGRAM
  • hold the mousebutton and move your mouse to LIBRARY
  • release mousebutton

    A window pops up and you can click options what you want to be included. The Standard library should be included. You can also set SUB-componenets, by clicking on the >> button. Click OK if you are satisfied with your options.

    Now its time to MAKE the library.

  • Click on FILE
  • hold mousebutton and move your mouse to MAKE library
  • release mousebutton

    The library will be created and everything should go well if you have specified the location of your QB45 dir correctly.

    Now you have a FUTURE.QLB file , this is our library. If you have your QB45 in your PATH environment, you should copy FUTURE.QLB and FUTURE.BI into your QB45 dir.

    if not, you have to include these files in your program dir.

    3) =="Preparing the library for your program"==


    A handy batch file is delivered to run the basic IDE with your library. Its called QBFuture.bat. But its always handy to know how to include it without using a batch file.

    Syntax:

    qb.exe /L future.qlb /ah
    
    Now the only thing you have to add at the top of your program is:
    '$include:'future.bi'
    
    That's it!

    4) =="Using the Future Library"==


    Now it's time to use the Future Library. Run QBFUTURE.BAT and the IDE should pop up. Type '$include:'future.bi' at the top of your program and we can begin programming with the Future Library!

    4.1) =="Setting Screenmode"==


    Setting Screenmode is easy, but its always handy to know if the current machine does even support VESA. Related functions to set the screen modes are:

  • isVesa
  • Set####x#### (b)
  • ResetScreen
  • Future.ModeList(IndexNumber%)

    ---------------
    FUNCTION IsVesa
    ---------------

    Returns -1 when your videocard supports VESA mode. If it returns 0 then its not supported.

    Example:

    ' Is machine VESA compatible?
    ' by Stefan Hendriks
    '$INCLUDE: 'future.bi'
    
    vesa = IsVESA
    IF vesa = -1 THEN PRINT "Vesa Compatible!" ELSE PRINT "Not Vesa Compatible!"
    
    --------------------
    SUB Set####x#### (b)
    --------------------

    Sets screenmode:

    Example, set mode to 640X480 in 16 Bits mode:

    Set640x480(16)
    
    ---------------
    SUB ResetScreen
    ---------------

    Will reset screenmode to SCREEN 0, you have to call this before you can call SCREEN 0.

    --------------------------------------
    FUNCTION Future.ModeList(IndexNumber%)
    --------------------------------------

    Returns a string, the current videomode that is supported. When string is empty then it has found no more supported vide modes.

    Example:

    ' Search for Supported Video Modes
    ' Example Program
    ' Written by Stefan Hendriks
    
    '$INCLUDE: 'future.bi'
    
    DEFINT A-Z
    CLS             'Clear screen
    
    OPEN "modes.txt" FOR OUTPUT AS #1       'Output file
    PRINT #1, "Current Video Modes are supported:"
    PRINT #1,
    
    FOR I = 0 TO 1024                       'Index NR
    'Print with nice color title, and index we are currently searching in
    COLOR 14: LOCATE 1, 1: PRINT "Supported modes - Searching IndexNR:"; I
    
    'Future.ModeList(Index%) returns what mode is supported
    info$ = Future.ModeList(I)
    
    IF info$ <> "" THEN
    'Print founded mode on screen
    COLOR 7: LOCATE 3 + modes, 1: PRINT info$;
    COLOR 15: LOCATE 3 + modes, 40: PRINT "At IndexNR:"; I
    modes = modes + 1
    PRINT #1, info$                         'Write in file the resolution
    ELSE
    EXIT FOR
    'end of list
    END IF
    
    IF modes > 19 THEN
    'In case we have found so many resolutions that it cannot fit on one
    'screen we pause and wait for a key
    COLOR 10: LOCATE 23, 1: PRINT "Press A Key to search further..."
    COLOR 7: WHILE INKEY$ = "": WEND
    CLS
    modes = 0
    END IF
    
    NEXT
    CLOSE #1
    'End first we wait for a key
    COLOR 10: LOCATE 23, 1: PRINT "Search complete, press a key..."
    WHILE INKEY$ = "": WEND
    COLOR 7: CLS
    PRINT "Done with searching, all supported video modes are written in MODES.TXT"
    PRINT
    
    4.2) =="Paging"==

    Paging will allow you to draw on the screen while its not visible yet. If the current video mode supports more than 1 page, you can do dubble buffering. By drawing everything on page 1 for instance, and at the end you view page 1, then drawing all on page 0 and at the end set view page to 0 etc.

    The Future Software Library has the following subs/functions for you handling paging:

  • FUNCTION Pages
  • SUB SetPage (Page)
  • SUB ViewPage (Page)

    --------------
    FUNCTION Pages
    --------------

    This will return the amount of pages that is supported at the current set videomode.

    Example:

    ' by Stefan Hendriks
    '$INCLUDE: 'future.bi'
    Set640x480 (8)  ' Set screen resolution at 640X480 at 8 bit
    P = Pages       ' Get the amount of pages we can use
    ReSetScreen     ' Go back to text mode
    ' And tell user about the amount of founded pages.
    PRINT "You had"; P; "pages available at 640x480 at 8 bit"
    
    ------------------
    SUB SetPage (Page)
    ------------------

    Page is the page you will draw on from that moment.
    Note: When Page is different than viewing page then you don't see the drawing at that time. So you can draw flicker free!

    Example:

    DECLARE SUB Directdrawing ()
    DECLARE SUB Indirectdrawing ()
    ' BOXMOVE.BAS
    ' by Stefan Hendriks
    '$INCLUDE: 'future.bi'
    
    ' Illustrates drawing immidiatly on viewpage, and then on
    ' an another page for dubble buffering
    DEFINT A-Z
    
    set640x480 (8)
    p = Pages
    
    IF p < 1 THEN
    ResetScreen
    PRINT "This demo cannot be excecuted since we don't have enough pages..."
    END
    END IF
    
    Directdrawing
    Indirectdrawing
    
    ResetScreen
    PRINT "End of Demo"
    
    SUB Directdrawing
    'Draws directly on screen
    setpage 0       'Set draw page on
    viewpage 0
    
    FOR boxx = 640 TO -100 STEP -1
    Future.Fillbox 0, 0, 639, 479, 15       'Fill entire screen with white
    Future.PRINT 0, 0, "Drawing Directly on a page... WITHOUT WAITING FOR RETRACE", 0, 15
    Future.PRINT 0, 20, "Wow, super flickery! Can you read this??", 0, 15
    Future.Fillbox boxx, 190, boxx + 100, 290, 0      'Draw our box
    NEXT boxx
    
    FOR boxx = 640 TO -100 STEP -1
    Future.Fillbox 0, 0, 639, 479, 15       'Fill entire screen with white
    WAIT &H3DA, 8
    WAIT &H3DA, 8, 8
    Future.PRINT 0, 0, "Drawing Directly on a page... WITH WAITING FOR RETRACE", 0, 15
    Future.PRINT 0, 20, "Still lot of flicker...", 0, 15
    Future.Fillbox boxx, 190, boxx + 100, 290, 0      'Draw our box
    NEXT boxx
    
    END SUB
    
    SUB Indirectdrawing
    'Draws directly on screen
    setpage 0       'Set draw page on
    viewpage 0
    
    FOR boxx = 640 TO -100 STEP -1
    p = p XOR 1
    setpage p
    Future.Fillbox 0, 0, 639, 479, 15       'Fill entire screen with white
    Future.PRINT 0, 0, "Drawing using Double Buffer Method... WITHOUT WAITING FOR RETRACE", 0, 15
    Future.PRINT 0, 20, "Still flickery...", 0, 15
    Future.Fillbox boxx, 190, boxx + 100, 290, 0      'Draw our box
    viewpage p
    NEXT boxx
    
    
    FOR boxx = 640 TO -100 STEP -1
    p = p XOR 1
    setpage p
    Future.Fillbox 0, 0, 639, 479, 15       'Fill entire screen with white
    Future.PRINT 0, 0, "Drawing using Double Buffer Method... AND WAITING FOR RETRACE", 0, 15
    Future.PRINT 0, 20, "Flicker Free!", 0, 15
    Future.Fillbox boxx, 190, boxx + 100, 290, 0      'Draw our box
    viewpage p
    WAIT &H3DA, 8
    WAIT &H3DA, 8, 8
    NEXT boxx
    
    END SUB
    
    
    
    -------------------
    SUB ViewPage (Page)
    -------------------

    Page is the page that will be visible on the screen.

    See example of the Setpage SUB.

    4.3) =="Print"==


    Printing stuff on the screen is always handy, you need to use Future Software's PRINT functions to print on any video mode...

    Print functions:

  • SUB Future.PRINT (X,Y, T$, F, B)
  • SUB SetFont (Mode)
  • SUB Future.LoadFONT (filename$)

    --------------------------------
    SUB Future.PRINT (X,Y, T$, F, B)
    --------------------------------

    X : X position Y : Y position T$ : string holding text to be printed F : Text color B : Text's background color

    Will print on position X,Y text (holds T$). If you want to print numbers: text$ = "Number:" + STR$(number)

    It will use the current font. Read SetFont for more information about fonts.

    Note: When F or B are -1 then nothing will be drawn.

    Example:

    ' Example Program PRINTME
    ' by Stefan Hendriks
    
    '$INCLUDE: 'future.bi'
    Set640x480 (8)  ' Just our good old SCREEN 13
    Future.PRINT 0, 15, "Hello world! - very boring, but does the trick...", 7, -1
    WHILE INKEY$ = "": WEND
    ReSetScreen
    
    
    Another example:
    ' Example Program PRINTCL
    ' Nice trick with PRINT
    ' by Stefan Hendriks
    
    '$INCLUDE: 'future.bi'
    DEFINT A-Z
    set640x480 (8)  ' Just our good old SCREEN 13
    
    text$ = "Our string people!"
    
    future.PRINT 0, 0, "Cool trick with PRINT.", 7, -1
    future.PRINT 0, 15, "At first you draw (using Future.LINE) 15 lines at the current length", 7, -1
    future.PRINT 0, 31, "of your string, a character in this mode is standard 16X8 so the we ", 7, -1
    future.PRINT 0, 47, "have LEN(string) * 8.", 7, -1
    FOR i = 0 TO 15
    Future.Line 0, 60 + i, 0 + LEN(text$) * 8 - 1, 60 + i, 16 + i, -1
    NEXT i
    WHILE INKEY$ = "": WEND
    future.PRINT 0, 80, "As above, now, we print the string over that position and set", 7, -1
    future.PRINT 0, 96, "the forground color to -1 and the background to 0", 7, -1
    FOR i = 0 TO 15
    Future.Line 0, 110 + i, 0 + LEN(text$) * 8 - 1, 110 + i, 16 + i, -1
    NEXT i
    WHILE INKEY$ = "": WEND
    future.PRINT 0, 110, text$, -1, 0
    future.PRINT 0, 200, "Cool eh?", 7, -1
    WHILE INKEY$ = "": WEND
    resetscreen
    
    
    ------------------
    SUB SetFont (Mode)
    ------------------

    Mode is the size of your font here, in pixels. Mode can be:
    0 - 8x8
    1 - 8x16
    2 - 8x14

    In 320x200 mode, the font size is by default 8x8 (Mode = 0). Any other screen size will deliver 8x16 (Mode = 1) as default.

    AFTER setting the screenmode, you can use this function.

    Notes:
    You can set the font to default (after loading one from a file) using this SUB

    Example:

    ' Example Program FONT
    ' by Stefan Hendriks
    
    '$INCLUDE: 'future.bi'
    Set640x480 (8)  ' Just our good old SCREEN 13
    Setfont 0
    Future.PRINT 0, 15, "Font 0... 8x8", 7, -1
    Setfont 1
    Future.PRINT 0, 31, "Font 1... 8x16", 7, -1
    Setfont 2
    Future.PRINT 0, 47, "Font 2... 8x14", 7, -1
    WHILE INKEY$ = "": WEND
    ReSetScreen
    
    -------------------------------
    SUB Future.LoadFONT (filename$)
    -------------------------------

    This sub will load the FONT from a file, you can make with the FONT editor. To get the default font back, use Setfont.

    The rest of the article will be in the next issue of the QB Times!
    This article was written by Stefan Hendriks of Future Software


    © Copyright 2000, Marinus Israel & Jorden Chamid