Ch2: Basics


Ch2. Basics

Important : To view this page correctly you require Verdana  font . Also I dont accept any liability/responsibility for any damage this page may cause you directly or indirectly.

In this chapter we will cover some basic stuff about FL.
Below
are the declarations of all the subroutines present in FL:

'*** Wave - commands related to sound ***
DECLARE SUB DmaState (StopGo%)
DECLARE FUNCTION WavDone% ()
DECLARE SUB SetStereo (BYVAL OnOff%)
DECLARE SUB SetSurround (BYVAL OnOff%)
DECLARE SUB LoadWAV (FileName$, SampleRate&)
DECLARE SUB StopAndReset ()
DECLARE SUB SpeakerState (OnOff%)
DECLARE SUB SBSetup (BasePort%, Ldma%, Hdma%, Irq%, SBtype%)
DECLARE FUNCTION Lwavedata% ()
DECLARE FUNCTION Rwavedata% ()
DECLARE FUNCTION GetMasterVolL% ()
DECLARE FUNCTION GetMasterVolR% ()
DECLARE SUB SetMasterVolL (BYVAL Vol%)
DECLARE SUB SetMasterVolR (BYVAL Vol%)
DECLARE FUNCTION GetWaveVolL% ()
DECLARE FUNCTION GetWaveVolR% ()
DECLARE SUB SetWaveVolL (BYVAL Vol%)
DECLARE SUB SetWaveVolR (BYVAL Vol%)
DECLARE SUB SetChannel (ChannelNum%, XMShandle%, WavFile$)
DECLARE SUB PlayChannel (BYVAL ChannelNum%)

'*** Mouse - commands related to non SVGA mouse ***
(Basically you can use these commands in normal QB's Text/CGA/EGA/VGA modes)

DECLARE SUB MouseShow ()
DECLARE SUB MouseDriver (ax%, bx%, CX%, dx%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePut (X%, Y%)
DECLARE SUB MouseRange (X1%, Y1%, x2%, y2%)
DECLARE SUB MouseStatus (Lb%, Rb%, XMouse%, Ymouse%)
DECLARE FUNCTION MouseInit% ()

'*** Mouse - commands related to mouse in SVGA modes ***
(You can use these commands only in FL's SVGA modes)

DECLARE SUB Future.UpdateMouse ALIAS "SVGAupdatemouse" ()
DECLARE SUB SetMouseRange (BYVAL X1%, BYVAL Y1%, BYVAL x2%, BYVAL y2%)
DECLARE SUB SetLocation (BYVAL X%, BYVAL Y%)
DECLARE SUB SetMouseMaskColor ALIAS "SVGAmousemask" (BYVAL C&)
DECLARE SUB Future.MouseShape ALIAS "SVGAmouseShape" (BYVAL Offset%, BYVAL Segment%)
DECLARE SUB Future.ResetMouseShape ALIAS "MouseCursorGenerator" ()
DECLARE SUB Future.MouseOff ALIAS "SVGAmouseoff" ()
DECLARE SUB Future.MouseOn ALIAS "SVGAmouseon" ()
DECLARE FUNCTION Future.MouseB% ALIAS "SVGAmouseB" ()
DECLARE FUNCTION Future.MouseY% ALIAS "SVGAmouseY" ()
DECLARE FUNCTION Future.MouseX% ALIAS "SVGAmouseX" ()
DECLARE SUB SetMouseSensitivity (BYVAL H%, BYVAL V%)

'*** Graphics - commands related to setting SVGA modes ***
DECLARE SUB Set320x200 (B%)
DECLARE SUB Set320x240 (B%)
DECLARE SUB Set320x400 (B%)
DECLARE SUB Set320x480 (B%)
DECLARE SUB Set400x300 (B%)
DECLARE SUB Set512x384 (B%)
DECLARE SUB Set640x350 (B%)
DECLARE SUB Set640x400 (B%)
DECLARE SUB Set640x480 (B%)
DECLARE SUB Set720x480 (B%)
DECLARE SUB Set720x576 (B%)
DECLARE SUB Set800x600 (B%)
DECLARE SUB Set1024x768 (B%)
DECLARE SUB Set1152x864 (B%)
DECLARE SUB Set1280x960 (B%)
DECLARE SUB Set1280x1024 (B%)
DECLARE SUB Set1600x1200 (B%)
DECLARE SUB Set1920x1080 (B%)
DECLARE SUB Set1920x1200 (B%)
DECLARE SUB Set1920x1440 (B%)
DECLARE SUB Set2048x1536 (B%)
DECLARE SUB SetScreenMode (XRes%, YRes%, Bits%)

DECLARE SUB ReSetScreen
DECLARE FUNCTION Pages% ()
DECLARE FUNCTION IsVESA%
DECLARE FUNCTION VideoMemory&
DECLARE SUB ViewPage (BYVAL P%)
DECLARE SUB SetFrameBuffer ALIAS "SVGAframesize" (BYVAL X%, BYVAL Y%)
DECLARE SUB SetMaskColor (BYVAL C&)
DECLARE SUB SetPage (BYVAL P%)
DECLARE SUB SetViewPort ALIAS "SVGAviewport" (BYVAL X1%, BYVAL Y1%, BYVAL x2%, BYVAL y2%)
DECLARE SUB LockPage ALIAS "SVGAlockpage" (BYVAL Page%)
DECLARE SUB UnLockPage ALIAS "SVGAunlockpage" (BYVAL Page%)
DECLARE SUB SetScroll ALIAS "SVGAscroll" (BYVAL Xpos%, BYVAL Ypos%)
DECLARE SUB SetTextureWrap (BYVAL OnOff%)
DECLARE FUNCTION RGB2Color& (BYVAL R%, BYVAL G%, BYVAL B%)
DECLARE SUB Color2RGB (BYVAL C&, R%, G%, B%)
DECLARE FUNCTION Future.Version$ ()
DECLARE FUNCTION SizeOf& ALIAS "SVGAsizeof" (BYVAL X%, BYVAL Y%)
DECLARE FUNCTION Future.ModeList$ (I%)
DECLARE FUNCTION Future.POINT& ALIAS "SVGApoint" (BYVAL X%, BYVAL Y%)
DECLARE SUB Future.ScrollUD ALIAS "SVGAscrollud" (BYVAL pixels%)
DECLARE SUB Future.ScrollLR ALIAS "SVGAscrolllr" (BYVAL pixels%)
DECLARE SUB Future.PSET ALIAS "SVGApset" (BYVAL X%, BYVAL Y%, BYVAL C&)
DECLARE SUB Future.CLS ALIAS "SVGAcls" (BYVAL C&)
DECLARE SUB Future.FILLBOX ALIAS "SVGAfillbox" (BYVAL X%, BYVAL Y%, BYVAL X1%, BYVAL Y1%, BYVAL C&)
DECLARE SUB Future.BOX ALIAS "SVGAbox" (BYVAL X%, BYVAL Y%, BYVAL X1%, BYVAL Y1%, BYVAL C&)
DECLARE SUB Future.LINE ALIAS "SVGAline" (BYVAL X%, BYVAL Y%, BYVAL X1%, BYVAL Y1%, BYVAL C&, BYVAL Bitscan%)
DECLARE SUB Future.CIRCLE ALIAS "SVGAcircle" (BYVAL CX%, BYVAL CY%, BYVAL Radius%, BYVAL C&)
DECLARE SUB Future.FILLCIRCLE ALIAS "SVGAfillcircle" (BYVAL CX%, BYVAL CY%, BYVAL Radius%, BYVAL C&)
DECLARE SUB Future.HLINE ALIAS "SVGAhline" (BYVAL Y%, BYVAL X1%, BYVAL x2%, BYVAL C&)

DECLARE SUB Future.TRIFILL ALIAS "SVGAtrifill" (BYVAL X1%, BYVAL Y1%, BYVAL x2%, BYVAL y2%, BYVAL X3%, BYVAL Y3%, BYVAL C&)
DECLARE SUB Future.TRIGOUR ALIAS "SVGAtrigour" (BYVAL X1%, BYVAL Y1%, BYVAL x2%, BYVAL y2%, BYVAL X3%, BYVAL Y3%, BYVAL C1&, BYVAL C2&, BYVAL C3&)
DECLARE SUB Future.TRITEXT (X1%, Y1%, x2%, y2%, X3%, Y3%, U1%, V1%, U2%, V2%, U3%, V3%, Array() AS ANY)
DECLARE SUB Future.ROTATE (X%, Y%, Angle%, Scale!, Array() AS ANY)
DECLARE SUB Future.ROTATEB (X%, Y%, Angle%, Scale!, Array() AS ANY)
DECLARE SUB Future.SNAPSHOT (FileName$)
DECLARE SUB Future.GET (X%, Y%, X1%, Y1%, Array() AS ANY)
DECLARE SUB Future.PUT (X%, Y%, Array() AS ANY)
DECLARE SUB Future.PRINT (X%, Y%, t$, C&, B&)
DECLARE SUB Future.LoadGIF (FileName$, Xpos%, Ypos%)
TYPE TGIFInfo
    Filehandle      AS INTEGER
    X               AS INTEGER
    Y               AS INTEGER
    BackgroundColor AS INTEGER
    Pal             AS INTEGER
    NColor          AS INTEGER
    GlobalCLUT      AS STRING * 768
    loopit          AS INTEGER
    StartFramePos   AS LONG
    FramePos        AS LONG
    EOFile          AS INTEGER
END TYPE
DECLARE SUB Future.OpenAGif (FileName$, GifHandle AS TGIFInfo)
DECLARE SUB Future.CloseAGif (GifHandle AS TGIFInfo)
DECLARE SUB Future.putAGif (Xpos%, Ypos%, GifHandle AS TGIFInfo)
DECLARE SUB Future.LoadBMP (FileName$, Xpos%, Ypos%)
DECLARE SUB Future.LoadPCX (FileName$, Xpos%, Ypos%)
DECLARE SUB Future.LoadFONT (FileName$)
DECLARE SUB SetFont ALIAS "SVGAsetfont" (BYVAL Mode%)
DECLARE FUNCTION IsMMX% ()
DECLARE SUB SetMMX (BYVAL OnOff%)
DECLARE SUB SetBlender (BYVAL OnOff%)
DECLARE SUB SetBMapColor (BYVAL FColor%, BYVAL BColor%, BYVAL OutColor%)
DECLARE SUB Font (X%, Y%, Text$, Col%)
DECLARE SUB LoadGIF (a$)
DECLARE SUB LoadPCX (a$)
DECLARE SUB LoadBMP (a$)
DECLARE SUB Melt ()
DECLARE SUB Palette.FadeIn
DECLARE SUB Palette.FadeOut
DECLARE SUB LoadPal (FileName$)
DECLARE SUB SavePal (FileName$)
DECLARE SUB Shake (Duration)
DECLARE SUB ChangePal (Color2Change%, R%, G%, B%)
DECLARE SUB LoadScreen (FileName$)
DECLARE SUB SaveScreen (FileName$)

'*** Key handling - keyboard and joystick input ***
DECLARE SUB StickStatus (JoyX%, JoyY%, But1%, But2%, But3%)
DECLARE SUB LockKeys (Nr%, State%)
DECLARE SUB DisableBreak

DECLARE SUB ClearKeyBuffer
DECLARE FUNCTION GetKey% (BYVAL KeyCode%)
DECLARE SUB KBHon ()
DECLARE SUB KBHoff ()

'*** Miscellaneous commands ***
DECLARE FUNCTION Timer2& ()
DECLARE SUB StartTIMER ()
DECLARE SUB StopTIMER ()
DECLARE SUB SetTIMERspeed (BYVAL Frequency%)
DECLARE SUB ResetCounter ()
DECLARE FUNCTION ReadCounter& ()
DECLARE SUB StartSubTIMER (BYVAL TimerNr%)
DECLARE SUB StopSubTIMER (BYVAL TimerNr%)
DECLARE SUB SetSubTIMERspeed (BYVAL Frequency%, BYVAL TimerNr%)
DECLARE SUB ResetSubCounter (BYVAL TimerNr%)
DECLARE FUNCTION ReadSubCounter& (BYVAL TimerNr%)

'*** EMS(Expanded Memory System) ***
DECLARE SUB Future.EMSPut (X%, Y%, handle%)
DECLARE SUB Future.EMSGet (X%, Y%, X1%, Y1%, handle%)
DECLARE SUB Future.EMSPutx (Tx%, Ty%, handle%, Sx%, Sy%, Sx1%, Sy1%)
DECLARE SUB Future.EMSGetx (Tx%, Ty%, handle%, Sx%, Sy%, Sx1%, Sy1%)
DECLARE SUB Future.EMSTRITEXT ALIAS "emsSVGAtritext" (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 EMShandle%)
DECLARE SUB Future.EMSROTATE (X%, Y%, Angle%, Scale!, handle%)
DECLARE SUB Future.EMSROTATEB (X%, Y%, Angle%, Scale!, handle%)
DECLARE SUB Future.DefineEMSArray (X%, Y%, handle%)
DECLARE SUB Future.EMSArrayGet (X%, Y%, handle%, Index%)
DECLARE SUB Future.EMSArrayPut (X%, Y%, handle%, Index%)
DECLARE SUB Future.EMStoFile (FileName$, handle%, fileStartpos&, EMSStartpos&, BytesTomove&)
DECLARE SUB Future.FiletoEMS (FileName$, handle%, fileStartpos&, EMSStartpos&, BytesTomove&)
DECLARE FUNCTION GetEMMVersion! ()
DECLARE SUB MapLogicalPages (handle%, physicalpage%, logicalpage%)
DECLARE FUNCTION AllExpMem% (Bytes&)
DECLARE SUB DeallExpMem (handle%)
DECLARE SUB FreeAllExpMem ()
DECLARE FUNCTION PageFrameAddr% ()
DECLARE FUNCTION TotalPages% ()
DECLARE FUNCTION UnallocatedPages% ()
DECLARE FUNCTION IsEMMInstalled% ()
DECLARE SUB DefineEMSbufferSize (BYVAL handle%, BYVAL Xsize%, BYVAL Ysize%, BYVAL EMSPageNumber%)
DECLARE SUB SetEMSpage (BYVAL EMSPageNumber%)
DECLARE SUB CopyEMSpage (BYVAL tEMSPageNumber%, BYVAL sEMSPageNumber%)

'*** XMS(eXtended Memory System) ***
DECLARE SUB Future.XMSget (X%, Y%, X1%, Y1%, XMShandle%)
DECLARE SUB Future.XMSput (X%, Y%, XMShandle%)
DECLARE FUNCTION IsXMSInstalled% ()
DECLARE FUNCTION AllocateXMS% (BYVAL Bytes&)
DECLARE SUB DeallocateXMS (BYVAL handle%)
DECLARE FUNCTION FreeXMSmemory& ()
DECLARE SUB MoveXMS (BYVAL SourceHandle%, BYVAL SourceOffset&, BYVAL DestHandle%, BYVAL DestOffset&, BYVAL Bytes&)
DECLARE SUB MoveToXMS (BYVAL handle%, BYVAL Segment%, BYVAL Offset%, BYVAL Bytes&, BYVAL XMSOffset&)
DECLARE SUB MoveFromXMS (BYVAL handle%, BYVAL Segment%, BYVAL Offset%, BYVAL Bytes&, BYVAL XMSOffset&)
DECLARE SUB Future.DefineXMSArray (X%, Y%, XMShandle%)
DECLARE SUB Future.XMSArrayGet (X%, Y%, XMShandle%, Index%)
DECLARE SUB Future.XMSArrayPut (X%, Y%, XMShandle%, Index%)

After understanding what all these declarations are for we move to the actual programming part.

Note: Once you set an SVGA mode all the graphics commands in QB will become totally useless! And if you try using any of them your program will crash giving you a And if you try using any of them your program will crash giving you a "Far Heap Corrupt" or "String Space Corrupt" or some other error! So my advice is that you stay away from any graphics commands of QB or rather any command dealing with the output/input from the screen!

Keeping the above note in mind we start with our first SVGA program!

'$INCLUDE: 'future.bi' 'Include the future.bi file

Set800x600 16 'Set 800x600 mode in 16bit mode

Future.Box 0, 0, 799, 599, RGB2Color&(255, 255, 255)
Future.Line 0, 0, 799, 599, RGB2Color&(255, 0, 0), -1
Future.Circle 400, 299, 298, RGB2Color&(0, 255, 0)
Future.Line 799, 0, 0, 599, RGB2Color&(0, 0, 255), -1

SLEEP

ResetScreen ' VERY IMPORTANT! Resets the screen to original parameters

This is a really simple prog which makes use of all the basic drawing commands. The FillBox, FillCircle counterparts draw filled shapes.

The Future.Line command is a bit different from that of QB's. Here you need to specify the bitscan%(the -1 parameter that I have supplied). Bitscan% accepts an integer - this is useful when you want to draw a dotted line. Try replacing -1 by &HAAAA or &HCCCC or &H9999. You will get different patterns.

The RGB2Color&(r%, g%, b%) command is used to pass a color to the drawing command. It accepts the Red, Green and Blue values and displays the appropriate color. It is mandatory to use this command at any place you want to display a color except in 8bit graphic modes where you can specify directly 0 to 255. 

The Color2RGB(clr&, r%, g%, b%) command will do exactly the opposite. It will split  the given color into its Red, Green and Blue values. This is especially useful when you want to modify an existing color. An example is given below: 

'$INCLUDE: 'future.bi' 'Include the future.bi file
XRes% = 800
YRes% = 600
Bits% = 16

SetScreenMode XRes%, YRes%, Bits% 'Set 800x600 mode in 16bit mode

Future.Cls RGB2Color&(255, 0, 0) 'Clears the screen

Future.Print 360, 259, "Hello World!", RGB2Color&(255, 255, 0), -1
Future.Print 360, 279, "Hello World!", RGB2Color&(255, 255, 0), RGB2Color&(0, 0, 0)
Future.HLine 0, 0, 799, 599, RGB2Color&(255, 0, 0), -1

SLEEP

Future.FillBox 0, 0, 799, 599, RGB2Color&(255, 255, 255)
Future.Line 0, 0, 799, 599, RGB2Color&(255, 0, 0), -1
Future.FillCircle 400, 299, 298, RGB2Color&(0, 255, 0)
Future.Line 799, 0, 0, 599, RGB2Color&(0, 0, 255), -1

ScreenClr& = Future.POINT&(100, 100) 'Get the color of pixel at 100, 100
Color2RGB ScreenClr&, ScrRed%, ScrGreen%, ScrBlue%
Future.Print 270, 279, "R =" + STR$(ScrRed%) + " G =" + STR$(ScrGreen%) + " B =" + STR$(ScrBlue%), RGB2Color&(255, 0, 0), -1

SLEEP

ResetScreen ' VERY IMPORTANT! Resets the screen to original parameters

Now you can see that Color2RGB is a statement which accepts the color you want to split. This has to be a LONG integer. Also it requires 3 variables in which it will return the R, G, and B values of the color.

Future.Point& is again a function which accepts X, Y co-ordinates where you want to check the color of the pixel. It returns a LONG. You can resolve the color into its RGB values by the Color2RGB command. It is the command corresponding to POINT function in QB.

Future.PSET is  a command which will plot a pixel with the given color at the given coordinates. It accepts the X, Y co-ordinates and color(which is specified using the RGB2Color& command). It is the command corresponding to PSET command in QB.

Future.PRINT command prints the given text at the specified X, Y position(Note: Here X, Y are in pixels and not in terms of Rows and Columns) with the given foreground and background color. It is the command corresponding to "PRINT and LOCATE fused into one" command in QB.

Future.CLS command clears the screen with the given color.

SetScreenMode command accepts the Xres, Yres and Bits(all integers) and sets the screen with these parameters. This command is useful when you want to set the screen at runtime rather than at compile time (i.e. you may want to determine the best resolution when the program is actually executed and not keep it fixed).

Future.HLine command will draw a horizontal line. Thus it accepts the x1, x2, y, and color parameters. This command is useful when you want to plot horizontal lines.

<< Back    Next >>