Future.Library 3
Copyright © 1999, Future Software. Visit our homepage at http://www.qb45.com.
Created by Michael Rye Sorensen and Jorden Chamid.

SVGA Related

NON-SVGA WAVE Mouse Other
Setting the screen mode You set a mode by calling Set####x#### (BitNumber) where ####x#### is the resolution you want and 'Bitnumber' is the amount of bits the mode should use to represent a color. (i.e. to set a 320x200 resolution with 8 bit colors, you write 'Set320x200 8') The bit number the library supports are 8, 15, 16 and 32 bits. Before exiting you program it is a good idea to call 'ResetScreen', if you don't you will stay in the selected mode after the program stops. This happens because the library don't know when you want to exit the program, so it can't change back to text mode automatically. By calling 'ResetScreen' the screen is set into text mode also known as SCREEN 0. You must call 'ResetScreen' for this to work, do not call SCREEN 0 directly. The function Future.ModeList is used to see which screen mode the video card supports (i.e. Modeinfo$ = Future.ModeList(IndexNumber%). The Indexnumber% indicates where in the mode list to look for a mode. The position of a specific mode in the list can differ from card to card, so you should always search through the hole list until you find the mode you are looking for. If the function returns a null string you have reached the end of the mode list. Also, before any screen mode is set, your should check to see if your video card supports VESA at all, the function IsVESA will return -1 if VESA if supported by the video card.

Some screen mode may not be directly supported by your video card. For these modes to work you will need the UniVBE driver developed by Scitech. The newest version of the driver can be found at www.scitechsoft.com.

SUBs/FUNCTIONs:
SUB Set320x200 (B)
SUB Set320x240 (B)
SUB Set320x400 (B)
SUB Set320x480 (B)
SUB Set400x300 (B)
SUB Set512x384 (B)
SUB Set640x350 (B)
SUB Set640x400 (B)
SUB Set640x480 (B)
SUB Set800x600 (B)
SUB Set1024x768 (B)
SUB Set1152x864 (B)
SUB Set1280x1024 (B)
SUB Set1600x1200 (B)
SUB ReSetScreen
FUNCTION Future.ModeList (I)
FUNCTION IsVESA


Paging If enough video memory is available and paging is supported by video hardware, it is possible to have more than one screen page to work in. Paging is the solution to flicker free animation and by flipping between two pages, while drawing on the page not being displayed, you will remove the flicker. The number of available pages is returned by calling 'Pages' (i.e. NumberOfPages% = Pages%) if 'Pages' return zero paging is not supported in that mode. Viewing a page is done by calling 'ViewPage' (i.e. ViewPage pagenumber). Setting the active page for drawing is done by calling 'SetPage' (i.e. SetPage pagenumber). When setting a screen mode the active page is set to the first page, page zero.

SUBs/FUNCTIONs:
FUNCTION Pages
SUB SetPage (P)
SUB ViewPage (P)


Printing text to the screen You can use 'Future.PRINT' to print text in any of the supported screen modes (i.e. Future.PRINT X, Y, "Hello World", F, B) The last two parameters is the foreground and background color to use. If the color is set to -1 it will be transparent (no color will be used). The first two parameters are a X,Y offset in pixels, from the upper left corner, from where the text is to be printed on the screen. In 320x200 the font size will be 8x8 by default, in any other mode the size will be 8x16 in size. After setting a mode you can change the font size by calling 'Setfont' (i.e. Setfont x) where x is 0 for 8x8 font size, 1 for 8x16 font size and 2 for 8x14 font size.

You can also install your own font type by using Future.LoadFONT. It will load a font file previously saved by the Font Editor. When the file is loaded the font is saved in extended memory and it immediately overrides the SetFont function, only by calling SetFont can the fonts be reset to the default system font type.

SUBs/FUNCTIONs:
SUB Future.PRINT (X, Y, t$, F, B)
SUB SetFont (Mode)
SUB Future.LoadFONT (Filename$)


Graphical (draw) functions A set of basic drawing routines was added to the library for easy generating of graphic. The color format for the drawing routines depends on the color mode that is used. An 8 bit mode uses color values from 0-FF hex (0 to 255 decimal), the color that is displayed in 8 bit modes depend on how the pallete is set up. 15, 16 and 32 bit modes does not use a pallete, they use the actual value C contain when a drawing routine is called. The 15 bit modes use values 0-1fh for the RGB values. In hex that will be 1F1F1Fh for white, blue is 00001Fh, green is 001F00h and red is 1F0000h. In 16 bit modes the red and blue shades also have a max of 1Fh, but green shades goes to 3Fh, so in 16 bit modes white would be 1F3F1Fh. In 32 bit modes the Red, Green and Blue shades go from 0 to FFh, so FFFFFFh is white.
 

SUBs/FUNCTIONs:
SUB Future.PSET (X, Y, C)
SUB Future.LINE (X, Y, X1, Y1, C, BitScan)
SUB Future.FILLCIRCLE (CX, CY, R, C)
SUB Future.CIRCLE (CX, CY, R, C)
SUB Future.CLS (C)
SUB Future.FILLBOX (X, Y, X1, Y1, C)
SUB Future.BOX (X, Y, X1, Y1, C)
FUNCTION Future.POINT (X, Y)
SUB Future.HLINE (Y, X1, X2, C)

NOTE:
When using the Future.LINE routine, note that to draw a normal line the 'BitScan' parameter must be set to -1.


Storing/drawing pictures By using Future.PUT you can easily draw a picture on screen, you just need to define an array to hold the picture information. The array can be of any type as no type checking is done when it is passed to the routine. The first four bytes in the array will hold the width and height of the picture. Future.GET gets a picture from the screen and stores it in the array passed to the routine. A color filter is added to the PUT routine, so it is possible to filter out a color that you do not want to be drawn. To set the color being filtered out call SetMaskColor C where C is the color you want to filter out. If C is negative the filter is disabled. SetMaskColor also effects Future.ROTATE and Future.TRIFILL.

It is also possible to save a screen page to a file. By calling Future.Snapshot the active screen page will be saved as a bmp file on disk.

The Future.GET/PUT functions can only accept one dimensioned arrays, so to get around the problem of using two (or more) dimensioned arrays you have to redefine the two routines. This is simply done by adding these two lines to the top your main module (.bas file):

DECLARE SUB Future.DirectPUT ALIAS "SVGAput" (BYVAL x1%, BYVAL y1%, BYVAL offset%, BYVAL segment%)
DECLARE SUB Future.DirectGET ALIAS "SVGAget" (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL offset%, BYVAL segment%)

After adding the two lines to your program you can call Future.DirectGET/Future.DirectPUT to draw the sprites, but be aware that you now have to give the segment and offset of the picture data you want to draw/or store to.

NOTE:
The GET routine does not check for upper and lower boundary of the array, so make sure you allocate enough memory to hold all the picture information plus four extra bytes.

SUBs/FUNCTIONs:
SUB Future.GET (X, Y, X1, Y1, Array())
SUB Future.PUT (X, Y, Array())
SUB SetMaskColor (C)
SUB Future.Snapshot (filename)


Loading pictures You can now load the default image-formats into your SVGA screen, with just one line of code!

SUBs/FUNCTIONs:
SUB Future.LoadGIF (Filename, XRes, YRes)     (Loads 8 bit, in 8 bit modes only)
SUB Future.LoadBMP (Filename, Xpos, Ypos)    (Loads 4, 8 and 24 bit, in 8, 15, 16 and 32 bit modes )
SUB Future.LoadPCX (Filename, Xpos, Ypos)     (Loads 8 bit in 8 bit modes only)


Loading a WAVE file We have even added some great functions for adding sound to your program(s)! In our tests, we have loaded a 9 MB WAVE file and it played great! If the routines do not play correctly, it may be that the library has not been set up proberly. Use SBSetup to setup the SoundBlaster manualy, if nothing else works.

The SBSetup routine parameters has the following configuations:
 
- SBtype IRQ Hdma Ldma
SB 1.xx 1 5 or 7 *** 0, 1 or 3
SB 2.xx 2 5 or 7 *** 0, 1 or 3
SB pro 3 5 or 7 *** 0, 1 or 3
SB16 4 2, 5, 7 or 10 5, 6 or 7 0, 1 or 3

BasePort is normaly 220h(544) but can have values from 220h to 260h, it depends on the jumper setting on the sound card and card type.

SUBs/FUNCTIONs:
SUB SBSetup (BasePort, Ldma, Hdma, Irq, SBtype)
FUNCTION WavDone ()
SUB LoadWAV (Filename)
SUB StopAndReset ()


Mouse support Using a mouse in a svga mode is supported, but it is a polling mouse. That means for the mouse to move on screen you have to call 'Future.UpdateMouse' continuously. The mouse pointer size is 16x16x256 and can be changed to any shape by calling 'Future.Mouseshape Shape$' Shape$ is a 256 pixel string passed to the sub. To set a transparent color for the mouse pointer call 'SetMouseMaskColor C' where C is the color to filter out. If C is negative no filtering is done.

SUBs/FUNCTIONs:
SUB Future.UpdateMouse
SUB SetLocation (X, Y)
SUB SetMouseMaskColor (C)
SUB SetMouseRange (X, Y, X1, Y1)
SUB Future.Mouseshape (Shape$)
SUB Future.MouseOff
SUB Future.MouseOn
FUNCTION Future.MouseY
FUNCTION Future.MouseX
FUNCTION Future.MouseB
SUB SetMouseSensitivity (H, V)


Mouse support in normal QB screens
MouseInit MouseHide MousePut MouseRange MouseShow MouseStatus

Scrolling By calling 'SetFrameBuffer X,Y' you can set a page frame that is larger than the screen. You can then use 'Future.ScrollLR S' or 'Future.ScrollUD S' to scroll the screen. If S is positive the screen is scrolled right or down, and if S is negative the screen is scrolled left or up. When changing the page frame size the number of available pages will change and you should call 'Pages%' to see how many pages you have after the change. Calling SetScroll will set an immediate scroll position on the screen, from where to start scrolling. All pages will be effected by the scrolling but you can lock a page from being scrolled by calling lockpage. Unlockpage will make scrolling possible on the specific page again, all pages are unlocked at startup.

SUBs/FUNCTIONs:
SUB SetFrameBuffer X,Y
SUB Future.ScrollLR S
SUB Future.ScrollUD S
SUB LockPage (Page)
SUB UnLockPage (Page)
SUB SetScroll (Xpos, Ypos)
 
 


3D graphics Three routines have been made to ease the pain of 3D programming. Future.TRIFILL will draw a filled triangle with a given color. Future.TRIGOUR will draw a gourauded triangle with three given colors. Future.TRITEXT will draw a textured triangle. The U,V parameters in Future.TRITEXT are the coordinates inside the texture map given by Array(). The first four bytes in the array should hold the X,Y dimension of the texture map, that means you can safely use an array stored by Future.GET.

Future.ROTATE/Future.ROTATEB can be used to rotate and/or to scale a picture that have been stored by Future.GET. The Angle parameter is the degrees (0 to 360) the picture should be rotated counterclockwise. A Scale parameter of zero to one will draw a pictures less the size of the original picture, if Scale is exactly 0.5 the picture length / height will be half the original size, and a Scale of 2 will double it. Future.ROTATEB was made give a more pixel perfect result when rotating, but it cannot draw outside the dimensions of the original picture, pixel that end up outside the picture resolution is clipped.

The Future.TRITEXT function can only accept one dimensioned arrays, so to get around the problem of using two (or more) dimensioned arrays you have to redefine the routine. This is done by adding this line to the top your main module (.bas file):

DECLARE SUB Future.DirectTRITEXT ALIAS "SVGAtritext" (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, BYVAL X3%, BYVAL Y3%, BYVAL U1%, BYVAL V1%, BYVAL U2%, BYVAL V2%, BYVAL U3%, BYVAL V3%, BYVAL Offset%, BYVAL Segment%)

After adding the line to your program you can call Future.DirectTRITEXT to draw the textured triangle, but be aware that you now have to give the segment and offset of the picture data you want to draw.

SUBs/FUNCTIONs:
SUB Future.TRIFILL (X1, Y1, X2, Y2, X3, Y3, Color)
SUB Future.TRIGOUR (X1, Y1, X2, Y2, X3, Y3, Color1, Color2, Color3)
SUB Future.TRITEXT (X1, Y1, X2, Y2, X3, Y3, U1, V1, U2, V2, U3, V3, Array())
SUB Future.ROTATE (X, Y, Angle, Scale, Array())
SUB Future.ROTATEB (X, Y, Angle, Scale, Array())
 
 


Saving/loading NON-SVGA pictures We have got some functions so you can load some of the most used (Windows) by typing a single command. Just use one of the functions below. You can also save the current screen to a 64 KB file, and load it again...you should also save/load the palette.

SUBs/FUNCTIONs:
SUB LoadScreen (Filename)
SUB SaveScreen (Filename)
SUB LoadGIF (a)
SUB LoadPCX (a)
SUB LoadBMP (a)


A font that doesn't erase the background Unlike the normal QB-print function, this font doesn't erase the background, it only draws the letters.

SUBs/FUNCTIONs:
SUB Font (X%, Y%, Text$, Col%)


EMS Support It is possible to save large screen data into memory. Calling 'AllExpMem' (i.e. handle% = AllExpMem%(&h100000)'get 1 megabyte of memory) will give you access to all the memory you need. 'AllExpMem' returns the handle you need to access the memory. Future.EMSPut/Future.EMSGet works the same way the normal Future.GET/Future.PUT work, the only difference is that you use a handle instead of an array. Remember to deallocate the memory before you exit your program, calling 'DeallExpMem handle' will deallocate the memory.

Before you use the ems routines it is a good idea to check if a ems driver is installed. You do this by checking if IsEMMInstalled returns -1, if IsEMMInstalled returns zero no ems driver is installed and you should not use the routines. If a driver is found you can safely use the routines. PageFrameAddr will return the address where the ems segment window is located (e000h or d000h on most computers). And MapLogicalPages will map the allocated expanded memory into the segment window. The segment window is divided into four 16kb chunks so a maximum of 64kb can be mapped at one time. The physicalpage and logicalpage parameter in MapLogicalPages is a number that indicate which part of the allocated memory should be mapped into the segment windows. Below is a table that shows how the mapping can be done.
 
 
Physical page(0k-64k) Logical page(0k-64k) Logical page(64k-128k) Logical page(128k-192k) Logical page(192k-256k)
0 0 4 8 12
1 1 5 9 13
2 2 6 10 14
3 3 7 11 15

DefineEMSbufferSize and SetEMSpage is part of a new system that allows you to create screen buffers stored in expanded memory. The screen buffers can be defined as any size from 1x1 to 16384x16384 and will be working just like drawing to a normal screen buffer.
 

Sample program showing the use of an ems offscreen buffer:

handle% = AllExpMem(256000)' get enough memory for a 640x400 buffer
DefineEMSbufferSize handle%, 640, 400, 0 'define the buffer and assign a page number to it

Set640x400 'set a mode

SetEMSpage 0 'turn on the ems buffer
FOR i% = 0 to 100
Future.LINE RND*640, RND*400, RND*400, RND*640, RND*255, -1 'just draw some lines on the ems page
NEXT

SetPage 0 ' turn the ems buffer off and enable drawing to the first screen page
Future.EMSPut 0, 0, handle% 'draw the buffer on the screen

SLEEP 'wait for a key press
ResetScreen 'reset screen to text mode
END ' exit program

Future.EMSGetx is used to fill an area in ems, defined by Sx, Sy, Sx1, Sy1, with data from the screen. The location on the screen from which to start taking the data is defined by Tx,Ty. The ems map must be previously defined by DefineEMSbufferSize or EMSGet. Future.EMSPutx works the same way, but Sx, Sy, Sx1, Sy1 defines the area on the screen to be filled with data from an previously defined ems map, Tx,Ty is the location in the ems map. That way you can easily use an ems map to store/draw smaller sprites.
 

SUBs/FUNCTIONs:
FUNCTION IsEMMInstalled
FUNCTION AllExpMem (Bytes)
SUB DeallExpMem (handle)
SUB Future.EMSPut (X, Y, handle)
SUB Future.EMSGet (X, Y, X1, Y1, handle)
FUNCTION GetEMMVersion! ()
SUB MapLogicalPages (handle, physicalpage, logicalpage)
FUNCTION PageFrameAddr
FUNCTION TotalPages
FUNCTION UnallocatedPages
SUB DefineEMSbufferSize (handle, Xsize, Ysize, EMSPageNumber)
SUB SetEMSpage (EMSPageNumber)
SUB Future.EMSPutx Tx, Ty, handle, Sx, Sy, Sx1, Sy1)
SUB Future.EMSGetx Tx, Ty, handle, Sx, Sy, Sx1, Sy1)
 
 


XMS Support The XMS driver gives access to memory above the first megabyte. It it recommended that you use XMS to store data instead of EMS and since EMS memory is handled much slower than XMS memory, it would be preferable to do so. Before you use the XMS routines you should always call IsXMSInstalled, because the library needs to find and hook to the XMS driver. If you use the routines without calling IsXMSInstalled your computer is likely to crash. IsXMSInstalled returns -1 if the driver is installed and zero if not. AllocateXMS will allocate the memory you need, and DeallocateXMS will return the memory to the free memory pool. FreeXMSmemory will give you the amount of memory available in the memory pool. MoveToXMS/MoveFromXMS does the memory transfer, either from lower memory to extended memory or from extended memory to lower memory. Segment:Offset is the position in lower memory and XMSOffset is the start position in extended memory, e.i. If you have allocated 1Mb of extended memory, XMSOffset range is 0 to 1048575 bytes.

SUBs/FUNCTIONs:
FUNCTION IsXMSInstalled ()
FUNCTION AllocateXMS (Bytes)
SUB DeallocateXMS (handle)
FUNCTION FreeXMSmemory ()
SUB MoveXMS (SourceHandle, SourceOffset, DestHandle, DestOffset, Bytes)
SUB MoveToXMS (handle, Segment, Offset, Bytes, XMSOffset)
SUB MoveFromXMS (handle, Segment, Offset, Bytes, XMSOffset)
SUB Future.XMSget (X, Y, X1, Y1, XMShandle)
SUB Future.XMSput (X, Y, XMShandle)
 
 


Changing Palette Changing the palette works in both the normal QB screen modes, and in SVGA.
We have some functions to let you save the current palette, load it again, fade it out, or fade it in (after fading it out).

SUBs/FUNCTIONs:
SUB SavePal (Filename)
SUB LoadPal (Filename)
SUB Palette.FadeOut
SUB Palette.FadeIn
SUB ChangePal (Color2Change, R, G, B)


Keyboard functions
ClearKeyBuffer DisableBreak LockKeys GetKey

Joystick functions Get the joystick-status.
StickStatus JoyX, JoyY, Button1, Button2, Button3
(JoyX = JoyStick X, JoyY = JoyStick Y)

Two graphical effects:
SUBs/FUNCTIONs:
SUB Melt ()
SUB Shake (Duration)


Timer We have an (experimental) Timer function, that works faster than the normal QB-timer.

SUBs/FUNCTIONs:
FUNCTION Timer2&


How to use Future.Library in your program Load QB with QB /l Future or run QBFUTURE.BAT
In your program use REM $INCLUDE: 'FUTURE.BI' or '$INCLUDE: 'FUTURE.BI'
From now on, you can use the functions of the Future.Library!


Latest updates What's new with the Future.Library:
December 27, 1999:
- Added TrueColor Modes
- Used more string memory                          (you may run into memory problems)
- Updated all subs and functions for truecolor (excluding Future.TRIGOUR)
- Speeded up Future.EMSput/Future.EMSputx
- New Future.XMSget/Future.XMSput
- Fixed bug in AllocateXMS
- Added MoveXMS
- Added support for loading 24 bit BMPs in 15, 16 and 32 bit modes
- Added support for loading 4 and 8 bit BMPs in all modes
- Changed the color format from 16 bit integer to a 32 bit integer
  (this affects all drawing functions)
November 05, 1999:
- Added full access to XMS
- Userfonts are now stored in xms
- Reduced memory use.
- Fixed bug in Future.FONTLOAD
- Fixed bug in Future.EMSget
- New Future.EMSputx/Future.EMSgetx
- Fixed bug in scrolling routines
 (scrolling only worked on the first page)
- New SetScroll
- New LockPage/UnlockPage
- New Future.RotateB
- New SBsetup
- New SetMouseSensitivity
September 27, 1999:
- Added full access to EMS
 (new routines are added)
- Reduced the use of string space
- Added user defined fonts (+beta version font editor)
- New Future.ROTATE
- Fixed Future.MouseX
 (it only returned even numbers)
- Fixed the screen setting routine
 (a screen allready set will not be cleared if set again)
- New Future.LOADFONT
- New Future.Modelist
- Fixed bugs in Future.LOADPCX and Future.LOADBMP
- Fixed bug in Future.EMSget/put
- Added VBE 2.0/3.0 low res modes
- Added support for loading 16 color BMPs
- Added ems screen buffers
August 8, 1999:
- Future.POINT is now working
- fixed Future.MouseOff Bug
- Speeded up Futere.TRIFILL
- Speeded up Futere.TRIGOUR
- New Futere.TRITEXT
- Added one demo program (rotate.bas)