November 1999



SECOND ARTICLE:

USING ZSVGA

INTRODUCTION

Zephyr's SVGA Lib is a full-featured lib for QuickBasic with great SVGA functions. Though it has good capabilities, it isn't well used much by QB programmers. Sure it's slow and buggy at times, however the lib has potential. Through a series of articles I'll be explaining how to use various functions of ZSVGA. In this first article, I'll explain how to install and use the basic functions of this lib. You can pick up this lib at:

http://neozones.quickbasic.com/basfiles/svgaqb25.zip

GETTING ZSVGA IN YOUR PROGRAMS

First off, the ZSVGA lib doesn't come in a Quick Library form, so you have to compile in manually. To compile to a QLB file simply enter:

LINK /QU SVGAQB.LIB, SVGAQB.QLB, NUL, BQLB45.LIB

Then, to start the QB IDE using the library, type QB /L SVGAQB

To use ZSVGA in your programs you must use a specific header. At the top of all ZSVGA programs enter:

DEFINT A-Z
'$INCLUDE: 'SVGABC.BI'

There ya go, your now ready to use ZSVGA functions in your programs.

START USING SVGA MODES

ZSVGA requires a 386+ CPU, so you may want to use the WHICHCPU function to check for a 386 or higher. I'm not going to bother going into that since I doubt you'd try to run your prog on less than a 386. =] Now, before you can use any SVGA functions you must first call the WHICHVGA function. This will detect and ready your video card. For example:

IF WHICHVGA THEN 
 PRINT "SVGA Video Card Detected!"
ELSE
 PRINT "SVGA Video Card Not Detected!": END
END IF

Now let's get into hi res modes! Yippee! =]

For most of these articles I will be using 640x480 modes, you should have at least 1 meg of video ram which can be checked via WHICHMEM. To enter a video mode simply use:

IF Res640 = 0 THEN PRINT "Could not enter 640x480 mode!": END

PUTTING PIXELS

Now you should be in 640x480 256 colors mode! Yay! Now let's begin taking advantage of this mode by plotting pixels.

To plot a single pixel you can simply use the DrwPoint function. The syntax goes like this:

DrwPoint (Mode%, Color%, X%, Y%)

Simple, eh? =]

You may wonder what Mode% is. Well, it's nothing but the pixel write mode. You don't really have to worry about it at this point (Pardon the pun), just set it to 1 for now. =] In case your interested the pixel write modes go like this:

1 = SET
2 = XOR
3 = OR
4 = AND

Now, let's plot da pixels! Here is some example code:

RANDOMIZE TIMER 'Seed the random number generator
FOR i = 1 TO 250 'Begin our FOR loop
x = INT(RND * 639) + 1 'Randomize the x axis position
y = INT(RND * 479) + 1 'Randomize the y axis position
c = INT(RND * 255) + 1 'Randomize the pixel color
DrwPoint 1, c, x, y 'Plot the pixel!
NEXT i 'End our loop

PUTTING LINES

That should plot some wonderful pixels on the screen. Yummy =] Now let's elevate the next level, into...LINES! To plot lines onto the video page simply use the DrwLine function (Duh =p). Its syntax goes like this:

DrwLine (Mode%, Color%, X1%, Y1%, X2%, Y2%)

Like, the point function this is pretty much self-explanatory. Like the DrwPoint function, set Mode% to 1 for now. Here's some more example code:

RANDOMIZE TIMER 'Seed the random number generator
FOR i = 1 TO 100 'Begin our FOR loop
x1 = INT(RND * 639) + 1 '\
y1 = INT(RND * 479) + 1 '|Randomize all the points!
x2 = INT(RND * 639) + 1 '|
y2 = INT(RND * 479) + 1 '/
c = INT(RND * 255) + 1 'Randomize the color
DrwLine 1, c, x1, y1, x2, y2
NEXT i 'End our loop

CLOSING

When you're finished with SVGA be sure to use ResText before ending your program. Like this:

Null = ResText

That's it for this article of ZSVGA. It's short, due to time constraints, but the next one should be bigger. In the next article I'll explain more graphic functions including using page flipping for smooth animation. Until then, be sure to explore SVGABC25.TXT to learn about other functions. Signing off...

CONTACTING ME

Here's some ways to annoy me:

ICQ: 18050607
Email: DigitalDude@BizzareCreations.com
IM: BBTMG512
You can usually find me on IRC in #quickbasic, on Efnet. I use the nick DigitlDud.

By Digital Dude

Back 2 Top