home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
WGT_TC21.ZIP
/
WGT.DOC
< prev
next >
Wrap
Text File
|
1992-07-16
|
30KB
|
998 lines
WordUp Graphics Toolkit
Command Summary
Turbo C Version
All procedures are meant for use in the Large memory model.
Initialization:
~~~~~~~~~~~~~~~
vga256 procedure
------------------------------------------------------------------------------
Function Initializes the 256 color graphics mode.
Declaration vga256()
Remarks This command must be called before any other WGT commands
are called or they WILL NOT work.
Drawing Operations:
~~~~~~~~~~~~~~~~~~~
wcls procedure
------------------------------------------------------------------------------
Function Clears the currently selected graphics page with a specified
color number.
Declaration wcls(int color)
Remarks This command behaves like the BGI ClearDevice procedure except
that it allows you to use a certain "clearing" color and it
supports WGT's multiple graphics pages.
Restrictions Clears entire page ignoring clipping.
See also wsetscreen,wnormscreen
wclip procedure
------------------------------------------------------------------------------
Function Sets the current clipping area for all graphics pages.
Declaration wclip(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the clipping area,
and (x2,y2) define the lower right. Designated WGT drawing
commands will only draw within this boundary.
Set coordinates to (0,0,319,199) to disable clipping.
Restrictions See EXTRA.DOC for information concerning which commands are
supported by this function.
wgetpixel function
-------------------------------------------------------------------------------
Function Gets the pixel value at X,Y. Uses current graphics page.
Declaration wgetpixel(int x,int y);
Result Type integer
See also wputpixel
wputpixel procedure
-------------------------------------------------------------------------------
Function Plots a pixel at X,Y. Operates on current graphics page.
Declaration wputpixel(int x,int y)
Remarks Plots a point in the current drawing color (set by wsetcolor)
at (x,y).
See also wgetpixel
wline Procedure
------------------------------------------------------------------------------
Function Draws a line on the current graphics page from (x1,y1) to
(x2,y2). Operates on current color and graphics page.
Declaration wline(int x1,int y1,int x2,int y2)
Remarks Replaces all needs for BGI's line command except where a
line style other than SolidLn is required. Horizontal lines
are significantly faster than BGI's.
Restrictions Does not allow for different line styles or thicknesses.
See also wsetcolor
wcircle procedure
------------------------------------------------------------------------------
Function Draws a circle using (x,y) as the center point.
Operates on current color and graphics page.
Declaration wcircle(int x,int y,int radius)
Remarks The circle is drawn using the current color set by wsetcolor.
Aspect ratios are not used, therefore results may be slightly
different than the BGI counterpart.
See also wsetcolor, wfill_circle
wfill_circle procedure
------------------------------------------------------------------------------
Function Draws a filled circle using (x,y) as the center point.
Declaration wfill_circle(int x,int y,int radius)
Remarks See wcircle
wrectangle procedure
------------------------------------------------------------------------------
Function Draws a rectangle using the current color and graphics page.
Declaration wrectangle(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the rectangle, and
(x2,y2) define the lower right. Faster than BGI equivalent.
See also wsetcolor, wbar
wbar procedure
------------------------------------------------------------------------------
Function Draws a filled rectangle with current color on active graphics
page.
Declaration wbar(int x1,int y1,int x2,int y2)
Remarks See wrectangle.
wbutt procedure
------------------------------------------------------------------------------
Function Draws a 3-Dimensional button using the current colors and
graphics page.
Declaration wbutt(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the button, and
(x2,y2) define the lower right.
This uses automatically uses the color 253,254,and 255.
253 should be the lightest, and 255 should be darkest.
See also wsetcolor, wbar
wregionfill procedure
------------------------------------------------------------------------------
Function Fills an area of the screen bounded by any color other than
that located at (x,y).
Declaration wregionfill(int x,int y)
Remarks Much more useful than the BGI FloodFill routine. It allows
multiple colors to be used as the border color. You must make
sure the stack size is large enough to handle complex fills.
If you get a stack overflow error, put this line at the
start of your program:
_stklen= (a number of bytes for the stack, biggest is 64000)
See example program 8 (wgt08.c) for an example of this.
See also wsetcolor
Color Manipulation:
~~~~~~~~~~~~~~~~~~~
wsetcolor procedure
------------------------------------------------------------------------------
Function Sets the current drawing color using the palette.
Declaration wsetcolor(int color)
Remarks Color may be in the range (0..255). All drawing procedures
used after setting this will use the color you choose.
See also wsetrgb,wsetpalette,wloadpalette,wsavepalette
wsetpalette procedure
------------------------------------------------------------------------------
Function Sets a group of colors from a specified palette variable.
Declaration wsetpalette(int start,int finish, color *palette)
Remarks Colors from Start to Finish are set using the values stored
in the Palette variable. The variable type PALETTE is
specific to WGT and may not be used elsewhere. It is
defined as follows:
typedef struct {
unsigned char r,g,b;
} color;
To define a palette, you must make an array of colors like
this:
color palette[256];
The Red,Green, and Blue values are in the range (0..63)
giving a total of 256000 color combinations possible.
See also wsetrgb, wloadpalette, wsavepalette, wsetcolor
wsetrgb procedure
------------------------------------------------------------------------------
Function Sets a color's red, green, and blue values.
Declaration wsetrgb(int color,int red,int green, int blue, color *palette)
Remarks Color can range from 0 to 255.
The Red,Green, and Blue values are in the range (0..63)
giving a total of 256000 color combinations possible.
The colors do NOT change until you give a wsetpalette
command. This way you can change a number of colors
and change them at the same time.
Since the palette is stored as an array, not a pointer, you
must use the & sign when you pass the palette. EG:
color palette[256]; // palette defined
wsetrgb(1,63,63,63,&palette); // sets color 1 to white
See also wsetpalette, wloadpalette, wsavepalette, wsetcolor
wcolrotate procedure
------------------------------------------------------------------------------
Function Cycles the colors within a specified group from a palette
variable.
Declaration wcolrotate(int start,int finish,int direction,color palette[255])
Remarks This routine takes the colors from Start to Finish and shifts
them one in the direction specified by direction. Direction
can either be 0 for up, or 1 for down. This effect can
be used to simulate animation.
See also wsetrgb, wfade_in, wfade_out
wfade_in Procedure
------------------------------------------------------------------------------
Function Gradually fades in a group of colors from a palette variable
(using a specified speed).
Declaration wfade_in(int start,int finish,int speed, color palette[255]);
Remarks The colors from Start to Finish are faded in starting from
black. The speed may range from (0..255), and is similar to
using the DELAY command between each change of the colors.
See also wfade_out, wsetrgb, wsetpalette
wfade_out procedure
------------------------------------------------------------------------------
Function Gradually fades out a group of colors from a palette variable
(using a specified speed).
Declaration wfade_out(int start,int finish,int speed,color palette[255]);
Remarks Same as wfade_in except colors fade from palette to black.
See also wfade_in, wsetrgb, wsetpalette
wloadpalette procedure
------------------------------------------------------------------------------
Function Load a 768 byte palette file from disk into a palette
variable.
Declaration wloadpalette(char filename[12],color *palette)
Remarks Palette files created by WGT or popular graphics programs may
be loaded into the variable specified by palette. Changes are not
made to the currently displayed palette. A good example of
compatibility would be the AutoDesk Animator. It's .COL files
are of this type. Many commercial games use these files as
well.
The filename has space for an 8 character name, a period, and
a 3 character extension.
See also wsavepalette, wsetpalette, wsetrgb
wsavepalette procedure
------------------------------------------------------------------------------
Function Save a palette variable's contents to a disk file.
Declaration wsavepalette(char filename[12], color *palette);
Remarks Creates a 768 byte palette file to disk from a variable
specified by palette. This is useful for storing different
palettes for games and their various screens.
See also wloadpalette, wsetpalette, wsetrgb
Block Manipulation:
~~~~~~~~~~~~~~~~~~~
wnewblock procedure
------------------------------------------------------------------------------
Function Stores a section of the screen in memory at a location pointed
to by a pointer variable.
Declaration block wnewblock(int x1,int y1,int x2,int y2)
Remarks Dynamic memory is used to automatically calculate the size of
the data, and to store it in a format compatible with BGI's
GETIMAGE. This procedure replaces the need for the combination
of IMAGESIZE, GETMEM, and GETIMAGE used in the BGI (although
all of WGT's block commands may be used interchangeably with
the BGI versions). Simply define a block at the beginning of
your program and call this routine.
example:
block something;
void main(void)
{
...
something=wnewblock(50,50,60,60);
...
}
See also wgetblockwidth, wgetblockheight, wflipblock, wputblock,
wresizeblock, wfreeblock, wloadblock, wsaveblock, wloadpak,
wsavepak
wgetblockwidth function
------------------------------------------------------------------------------
Function Returns width of a previously stored block.
Declaration int wgetblockwidth(block blockname);
Result Type Integer
wgetblockheight function
------------------------------------------------------------------------------
Function Returns height of a previously stored block.
Declaration wgetblockheight(block blockname);
Result Type Integer;
wflipblock procedure
------------------------------------------------------------------------------
Function Flips a block in one of two directions (block is physically
changed in memory, not on screen).
Declaration wflipblock(block blockname, int direction);
Remarks This procedure will flip a previously stored image either
vertically or horizontally. The stored image is physically
changed, and therefore the results will not be seen until
the block is displayed.
direction is defined as the following:
#define vertical 0;
#define horizontal 1;
See also wputblock, wnewblock, wresizeblock, wfreeblock
wputblock procedure
------------------------------------------------------------------------------
Function Plots a previously stored image on the current graphics page.
Declaration wputblock(int x,int y, block blockname, int mode)
Remarks This is similar to the BGI PUTIMAGE. It displays an image
starting from the upper left corner at (x,y). Two modes are
supported for the method. They are:
0 = Normal
1 = XRay
The XRayPut uses the current transluscent color as a sort of
"see-through" color. Any occurence of this color is not
drawn on the screen. This is useful for drawing sprites
which overlay a background screen.
See also wsettransluscent, wgettransluscent, wnewblock
wresizeblock procedure
------------------------------------------------------------------------------
Function Draws a previously stored image on the screen to fit within a
given boundary.
Declaration wresizeblock(int x1,int y1,int x2,int y1, block blockname);
Remarks A very fast shrink/expand routine for blocks. It will redraw
an image to fit perfectly within the area defined by
(x1,y1,x2,y2). In this manner, entire screens can be shrunk
down as icons, or small images can "explode". Image in memory
is not affected.
wfreeblock procedure
------------------------------------------------------------------------------
Function Releases memory used to store an image.
Declaration wfreeblock(block blockname)
Remarks Used when a program is finished with a stored image. This is
similar to the BGI FREEMEM. You must use this to free memory
from all blocks previously allocated by wnewblock or other
block loading procedures before you exit your program,
or you will encounter memory errors.
See also wnewblock
wloadblock procedure
------------------------------------------------------------------------------
Function Loads a previously saved image from disk into a pointer.
Declaration block wloadblock(char *filename)
Remarks wloadblock automatically initializes the appropriate amount
of memory and loads the data. There is no need for a call
to wnewblock (in fact, don't do it or this won't work).
Returns: Pointer to the loaded block. If the block could not be
found on disk, it returns NULL.
See also wsaveblock
wsaveblock procedure
------------------------------------------------------------------------------
Function Saves a previously stored image to a file on disk.
Declaration int wsaveblock(char *filename, block blockname)
Remarks A file is created which holds the data stored at the pointer
given by BLOCKNAME. This allows your programs to load in
images for use later.
Returns: 0 if succesful, 1 if it could not save the file
See also wloadblock, wnewblock, wfreeblock
wloadpak procedure
------------------------------------------------------------------------------
Function Loads a previously stored image from disk in compressed
format.
Declaration block wloadpak(char *filename)
Remarks This is similar to wloadblock except that the image is
in a file which was created by wsavepak. The compression used
is "similar" to PCX format (sometimes better). The more
simplistic the image, the smaller the file.
Returns: Pointer to the loaded block. If the block could not be
found on disk, it returns NULL.
See also wsavepak, wloadblock
wsavepak procedure
------------------------------------------------------------------------------
Function Saves a block to disk in compressed format.
Declaration int wsavepak(char *filename,block blockname)
Remarks This is similar to wsaveblock except that the image is
in a file which is compressed. The compression used
is "similar" to PCX format (sometimes better). The more
simplistic the image, the smaller the file.
Returns: 0 if succesful, 1 if it could not save the file
See also wloadpak, wloadblock
wloadpcx256 procedure
------------------------------------------------------------------------------
Function Loads a PCX file (320*200*256 only) onto the current graphics
page.
Declaration wloadpcx256(char *filename, color *palette);
Remarks The file MUST be a full screen and be in 256 color mode.
New version looks for the palette at the end of the PCX file.
Mouse Functions:
~~~~~~~~~~~~~~~~
minit procedure
------------------------------------------------------------------------------
Function Initializes the mouse.
Declaration int minit();
Remarks Simply starts up the mouse. You should use this first if you
want to use the mouse. Returns the number of buttons the mouse
has if it is installed.
See also mon,moff,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
msetbounds procedure
------------------------------------------------------------------------------
Function Sets the area to confine the mouse cursor to.
Declaration msetbounds(int minx,int miny,int maxx,int maxy)
Remarks The cursor will be restricted movement within the specified
region after this routine is called.
See also minit,mon,moff,mread,noclick,mouseshape,msetspeed,
msetthreshhold
mon procedure
------------------------------------------------------------------------------
Function Displays the mouse cursor.
Declaration mon()
Remarks If the mouse is displayed while you are using some drawing
procedures, it will mess up the screen if you move it over
the area being updated. Turn it off during all drawing
procedures.
See also minit,moff,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
moff procedure
------------------------------------------------------------------------------
Function Turns off display of the mouse cursor.
Declaration moff()
Remarks See mon.
See also minit,mon,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
mread procedure
------------------------------------------------------------------------------
Function Returns the current button pressed, as well as X and Y
coordinates.
Declaration mread()
Remarks Three global variables are updated when you call this
procedure. mx and my are the mouse coordinates, and
but is the button state.
Buttons are commonly returned as 1 for left, 2 for right,
and 4 for the middle button of a 3 button mouse. 0 is returned
if none are pressed.
See also minit,mon,moff,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
noclick procedure
------------------------------------------------------------------------------
Function Waits until all buttons are released.
Declaration noclick()
Remarks This is useful if you want the user to click on a button,
update something, and wait for another button click.
Without this command, the user could hold down the button
and the program will think you pressed it a bunch of times.
Put this command in after you have found the user pressed
a button. Example:
mread();
if (but==1)
{
noclick();
ctr++;
}
See also minit,mon,mread,msetbounds,mouseshape,msetspeed,
msetthreshhold
mouseshape procedure
------------------------------------------------------------------------------
Function Sets the bitmap and hotspot of the mouse cursor.
Declaration mouseshape(int rowhot,int colhot, void far *bitmap)
Remarks This procedure sets the cursor hotspot as defined by the
variables ROWHOT and COLHOT. Each are in the range (0..15).
The actual bitmap information is stored in an array of
integers called bitmap. It is defined as follows:
The first 16 words are used to set the cursor shape, while the
last 16 words set the mask. Several shareware programs are
available to create the data required for these cursors if
you are unfamiliar with bit operations.
See also minit,mon,moff,mread,noclick,msetbounds,msetspeed,
msetthreshhold
msetspeed procedure
------------------------------------------------------------------------------
Function Sets the speed of the mouse.
Declaration msetspeed(int x_speed,int y_speed)
Remarks Sets the speed of the mouse in each direction. 10 is about
average for both values. 1 is fast, 40 is slower.
In other words, if you set the speed to be 40 for the x, and
1 for the y, you will have to move the mouse a greater
distance horizontally to move the cursor one pixel. On the
other hand, you can move the cursor very quickly up and down.
See also minit,mon,moff,mread,noclick,msetbounds,mouseshape,
msetthreshhold
msetthreshhold procedure
------------------------------------------------------------------------------
Function Sets the speed the mouse must be before it doubles its
movements.
Declaration msetthreshhold(int speed)
Remarks See mon.
See also minit,mon,moff,mread,noclick,msetbounds,mouseshape,msetspeed
Screen Operations:
~~~~~~~~~~~~~~~~~~
wsetscreen procedure
------------------------------------------------------------------------------
Function Makes all drawing procedures use a different video page
Declaration wsetscreen(block screenname)
Remarks The screen must be first initialized by using wnewblock
with coords 0,0 to 319,199.
See also wnewblock,wfreeblock
wnormscreen procedure
------------------------------------------------------------------------------
Function Sets the active page back to the original visual page
Declaration wnormscreen()
Remarks This is used to return all drawing operations to the normal
screen.
See also wnewblock,wfreeblock
wcopyscreen procedure
------------------------------------------------------------------------------
Function Copies a section of one screen onto a different WGT page.
Declaration wcopyscreen(int x1,int y1,int x2,int y2,block source,
int dx,int dy, block dest)
Remarks This command can seem confusing, but is very powerful, and
necessary when using multiple graphics pages. A second page
must be initialized by getting a block with dimensions
320 by 200 before this command can be used.
The area defined by (x1,y1,x2,y2) is copied from the screen
described by SOURCE, and is placed with the upper left corner
at (dx,dy) on the screen referred to by DEST. For example,
to copy screen SECOND(entirely) to the screen FIRST, type
wcopyscreen(0,0,319,199,SECOND,0,0,FIRST). The visual page
can be accesed by replacing the destination or source with
NULL.
For example to copy FIRST to the visual page:
wcopyscreen(0,0,319,199,FIRST,0,0,NULL);
or the other way around:
wcopyscreen(0,0,319,199,NULL,0,0,FIRST);
wfade procedure
------------------------------------------------------------------------------
Function Dissolves a screen of memory onto the active screen.
Declaration wfade(block sourcescreen, int *pattern, int speed)
Remarks The screen described by SOURCESCREEN is dissolved onto the
active screen set by wsetscreen using the pattern specified
by pattern. Pattern is an array of integer. It can be
defined by the program called dissolve.exe, included with
WGT. After saving a pattern with this program, include the
code generated with your program, and pass it the array to
this procedure.
The speed is a DELAY command after each pixel is copied.
wwipe procedure
------------------------------------------------------------------------------
Function Draws a line but uses colours from another virtual screen.
Declaration wwipe(int x1,int y1, int x2,iny y2,block screen)
Remarks This special effect allows you to draw a line on the screen,
but instead of using one colour, each pixel drawn is the
colour of the pixel at the same location on the block
screen. You can created impressive wipes and make your
programs look very professional. You will want to make
one or more 'for' statements that copy the whole screen over
since this only does it one at a time. The lines don't have
to be horizontal or vertical, so you can create complex
patterns with the lines.
Text functions:
~~~~~~~~~~~~~~~
wouttextxy procedure
------------------------------------------------------------------------------
Function Outputs a string of text on the graphics page at (x,y).
Declaration wouttextxy(int x,int y, char *string)
Remarks Same as BGI version except it works on any graphics page.
X/Y coordinate system may be 40*25 or 320*200 (see the
wtextgrid procedure).
See also wtextcolor, wtextbackground, wtextgrid, wtexttransparent,
wtextcursor, wstring
wtextbackground procedure
------------------------------------------------------------------------------
Function Sets the background text color.
Declaration wtextbackground(unsigned char color)
Remarks Color is in the range (0..255). Background may be turned off
for output by using wtexttransparent.
See also wouttextxy,wtextcolor, wtextgrid,
wtexttransparent, wtextcursor, wstring
wtextcolor procedure
------------------------------------------------------------------------------
Function Selects the foreground character color.
Declaration wtextcolor(unsigned char color)
Remarks Color is in the range (0..255). Foreground may be turned off
during output by setting wtexttransparent.
See also wouttextxy, wtextbackground, wtextgrid,
wtexttransparent, wtextcursor, wstring
wsetcursor procedure
------------------------------------------------------------------------------
Function Sets the shape of the text cursor.
Declaration wsetcursor(int y,int y2)
Remarks Y and Y2 coordinates are the coordinates for the upper and
lower lines for a box 8 pixels wide. The X coordinates are
fixed to 8 pixels wide. The cursor is not the hardware text
cursor, but rather a software simulation which flashes during
text input. A solid box would be (0,7).
See Also wstring
wtextgrid procedure
------------------------------------------------------------------------------
Function Switches the text addressing system from 320*200 to 40*25.
Declaration wtextgrid(int state)
Remarks Text may be output in regular graphics coordinates (320*200) or
a text mode system of 40*25. If STATE is set to 1, all input
and output values for WGT text functions are expected to be
in the 40*25 range. Characters will be 'snapped' to the grid as
if it were a text mode. 0 will use regular graphics system
coordinates.
See Also wouttextxy, wstring
wstring procedure
------------------------------------------------------------------------------
Function Reads in a string of text from the keyboard and displays
both the text and a simulated cursor on the graphics page.
Declaration int wstring(int x,int y, char *instring, char *legal, int num)
Remarks X and Y are the coordinates to read the string in from.
This procedure uses the flashing cursor while you input the
string. Any characters you wish to be able to type in must
be included in LEGAL. For example, if you want a yes or
no answer only, make LEGAL="YNyn". NUM is the maximum number
of letters in the string.
INSTRING must be a pointer to char, example
char *filename;
Along with legal:
char *legal_chars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz1234567890_.";
Then, you must allocate memory for the string, like this:
filename = (char *) malloc (13);
Add 1 to the length for the null terminator.
Call the string procedure:
wstring(10,22,filename,legal_chars,12);
After you're done with the string, free the memory by
free(filenameout);
INSERT,DELETE,HOME,END and the arrow keys are functional,
backspace is destructive.
If you press insert, the cursor shape changes and toggles
between insert and overwrite modes.
See Also wtextcolor, wtextbackground, wtextgrid, wtexttransparent
wtexttransparent procedure
------------------------------------------------------------------------------
Function Sets text output to supress display of foreground or
background.
Declaration wtexttransparent(int mode)
Remarks This will turn off the display of either the foreground or the
background, or set it to show both.
The values possible are:
0: Background turned off
1: Foreground turned off
2: Both turned on
wflashcursor procedure
------------------------------------------------------------------------------
Function Flash the cursor using the values set by wsetcursor and
the global variable curspeed.
Declaration wflashcursor()
Remarks Uses the cursor coordinates set by the global variables
xc and yc. Curspeed is another global variable which can
be set to change the flashing speed.
Sprite Procedures:
~~~~~~~~~~~~~~~~~~
All sprite procedures have been moved into wspr.lib. Please
see the documentation for that library.
Misc:
~~~~~
wretrace procedure
------------------------------------------------------------------------------
Function Waits for the vertical retrace.
Declaration wretrace()
Remarks Use when you get flickering graphics.