home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
maj
/
436
/
graphics.doc
< prev
next >
Wrap
Text File
|
1994-06-15
|
76KB
|
1,932 lines
************************ QLIB GRAPHICS ***********************************
QLIB's graphics subroutines were written initially to provide Hercules
graphics functions without using QB's QBHERC.COM or MSHERC.COM memory-
resident drivers, and to provide added capabilities. Most of these
subroutines now work in additional graphics modes. QLIB automatically
configures itself for the graphics mode in use.
Locations on Graphics screens are defined by coordinate pairs such as (x,y).
X-coordinates are the horizontal dimensions of the screen, and Y-coordinates
are the vertical coordinates. X = 0 is the at the left edge of the screen,
and X = 719 is the right edge of a Hercules screen, while Y = 0 is the top
edge of the screen and Y = 347 is the bottom (Hercules). Thus, the
coordinate (719,0) is the upper right corner of a Hercules screen. Maximum
coordinate values for supported modes are shown on the next page.
You may also use your own coordinate system with QLIB graphics, similar
to using WINDOW with BASIC's graphics functions. See QWindow at the
end of this file.
QLIB graphics modes are:
Mode Maximum x Maximum y Colors Equipment
HGraph 719 347 2 Hercules
HGraph 719 347 16 Hercules InColor
SCREEN 1 319 199 4 CGA, EGA, MCGA, VGA
SCREEN 2 639 199 2 CGA, EGA, MCGA, VGA
SCREEN 3 (1) 719 347 2 Hercules
SCREEN 4 639 399 2 ATT 6300 (5)
SCREEN 7 319 199 16 EGA, VGA
SCREEN 8 639 199 16 EGA, VGA
SCREEN 9 639 349 16 EGA, VGA (2)
SCREEN 10 639 349 4 EGA, VGA (3)
SCREEN 11 639 479 2 MCGA, VGA
SCREEN 12 639 479 16 VGA
SCREEN 13 319 199 256 MCGA, VGA
VESA6A 799 599 16 (4)
XMode16 up to 799 up to 599 16 Super EGA/VGA
VGA13X 319 or 359 199 to 479 256 VGA
SVGA16 up to 1024 up to 768 16 Super VGA
SVGA256 up to 1024 up to 768 256 Super VGA
(1) Requires MSHERC.COM or QBHERC.COM
(2) EGA with 128k or more memory
(3) monochrome monitor only
(4) VESA6A is supported by many Super VGA cards with multi-frequency
monitors. See ScreenMode.
(5) untested mode; should work with any subroutine which supports
SCREEN 2. Your feedback, please!
Registered QLIB users may use QLIB's EGAVGA.obj and NOSVGA.obj
stub files to reduce the size of their .EXE files. QLIB's stub files
are similar to the NOEM.obj and NOCOM.obj files supplied by Microsoft
with QuickBASIC. EGAVGA eliminates code and data required for monochrome,
CGA and InColor graphics modes, while NOSVGA eliminates code for Super VGA
modes. You must link with the /NOE option when using these stub files.
Example: I want MYPROG.EXE to support only EGA or VGA 16-color modes
compile: BC MYPROG /O;
link: LINK /EX /NOE MYPROG+EGAVGA+NOSVGA,,,QLIB;
linking with EGAVGA.obj reduces .EXE file size by up to 2,630 bytes;
linking with NOSVGA.obj reduces .EXE size by up to 3,152 bytes.
The style% parameter used in many QLIB Graphics subroutines follows these
general rules:
style% = 0 XORs the text/pixel/line/whatever with the pre-existing
screen: if a pixel (x,y) is XORed to the screen, the pixel
will be turned on if previously off, or will be turned off
if previously on;
style% = 1 is normal; lines are drawn, pixels are turned on, text is
foreground-on-background, and the previous screen content
is ignored or obliterated;
style% = 2 similar to style% 1, but foreground color only is updated
style% = 3 ORs the line or block with the existing screen; this means
that the new stuff is added to the old.
style% = 4 ANDs a block (or fillbox) with the existing screen; within
the block's limits, only those pixels where both the
previous screen and the pattern in the block have ON pixels
will there be a resulting ON pixel;
style% = -3 similar to style% 3, but reverses the foreground and
background before combining it with the screen
style% = -2 similar to style% 2, but reverses the foreground and
background before combining it with the screen
style% = -1 like style% 1, but uses background color. In monochrome
modes, pixels are erased, text is black with a bright
background.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: Bezier(s%, addr%, n%, style%)
object files: bezier.obj (drawline.obj)
Draws a Bezier curve on the screen. Data for the curve must
be in a BezierData data structure (see example in QLIB.BI).
Data required by Bezier:
(x0, y0) = first endpoint
(x1, y1) = first control point
(x2, y2) = second control point
(x3, y3) = second endpoint
n% = number of points to draw (0 < n% < 32768)
in most cases, n% = 50 will provide a smooth curve
the control points act as "magnets", pulling the curve away from
a straight line. Style% = 0 is not recommended.
Example:
REM $INCLUDE: 'qlib.bi' ' has BezierData definition
DIM bz AS BezierData ' standard structure for Bezier curve data
bz.x0 = 140 ' 1st endpoint: (140, 200)
bz.y0 = 200
bz.x1 = 0 ' 1st control point
bz.y1 = 50
bz.x2 = 600 ' 2nd control point
bz.y2 = 0
bz.x3 = 600 ' 2nd endpoint: (600, 300)
bz.y3 = 300
n% = 200
SCREEN 9
' show where the endpoints and control points are
CALL graphcolor(1)
CALL DrawLine(bz.x0, bz.y0, bz.x1, bz.y1, 1)
CALL DrawLine(bz.x1, bz.y1, bz.x2, bz.y2, 1)
CALL DrawLine(bz.x2, bz.y2, bz.x3, bz.y3, 1)
CALL DrawLine(bz.x3, bz.y3, bz.x0, bz.y0, 1)
CALL graphcolor(15) ' bright white for the curve
s% = VARSEG(bz) ' get data structure address
a% = VARPTR(bz)
CALL Bezier(s%, a%, n%, 1)
IF GetKey THEN SCREEN 0 ' look at it for a while
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: BitBlockSave(seg%, x0%, y0%, x1%, y1%)
Subroutine: BitBlockRestore(seg%, x%, y%, style%)
object files: bitblock.obj ($graph.obj, bb02.obj, bb04.obj, bb06.obj,
bb08.obj, bb10.obj, bb12.obj, bb14.obj)
Function: bytes% = BitBlockBytes(x0%, y0%, x1%, y1%)
object files: bbbytes.obj ($graph.obj)
Modes supported: All
BitBlockSave copies a section of the graphics screen to system memory
in order to copy the block back to the screen later with BitBlockRestore.
BitBlockBytes returns the number of bytes of memory required store
the entire pixel block. Bytes% = 0 if the block is too big. After
calculating the bytes required, you may use AllocMem(bytes) to
allocate the memory space required. See AllocMem in DATA.DOC.
Note that bit block memory requirements can be large; the huge model
library QLIBH.LIB is required for large bitblocks in 16-color and
256-color modes.
style% values supported by BitBlockRestore are:
SCREEN 13, VGA13X, SVGA256:
1 = replace existing screen area with bit block
2 = replace existing screen with non-zero pixels in bit block
HGraph (InColor):
4 = AND the bit block with the existing screen
3 = OR the bit block with the existing screen
1,2 = replace existing screen area with bit block
0 = XOR the bit block with the existing image
-1,-2 = replace existing screen area with inverse bit block
16-color EGA/VGA-type modes including SVGA16, and SCREEN 10:
same as InColor, plus:
-3 = OR the inverse bit block with the existing screen
-4 = AND the inverse bit block with the existing screen
SCREEN 1, 2, 3, 11, and HGraph (mono):
2 = combine non-zero pixels in the bit block with the
pre-existing image
1 = replace the existing screen image with un-altered
bit block
0 = XOR the bit block with the existing image
-1 = replace existing screen image with inverse bit block
-2 = combine non-zero pixel in the inverse bit block with
the previous screen image
See example on next page.
BIT BLOCK EXAMPLE:
REM This example calculates the array size required,
REM dimensions the array, saves a portion of the screen and
REM restores it later.
REM $INCLUDE: 'qlib.bi'
REM start in the desired graphics mode
.
.
.
x0 = 100: y0 = 0: x1 = 400: y1 = 347
bytes% = BitBlockBytes(x0%, y0%, x1%, y1%)
REM Note that huge model BitBlockBytes returns a LONG integer
bbseg% = AllocMem(bytes%)
CALL BitBlockSave(bbseg%, x0%, y0%, x1%, y1%)
.
.
.
REM now we'll copy the block back to the screen
CALL BitBlockRestore(bbseg%, x2%, y2%, style%)
REM x2% and y2% may be any coordinates on the screen
REM also release the memory block
CALL FreeMem(bbseg%)
If you do not intend to support all QLIB graphics modes, you can
call mode-specific BitBlock subroutines to reduce .EXE size.
These subroutines use the same calling parameters as BitBlockSave
and BitBlockRestore:
(save bit block)
getbb02: SCREEN 1-4, SCREEN 11, HGraph (mono and InColor)
getbb06: SCREEN 7-10, SCREEN 12, SVGA16(0), XMODE16
getbb08: SCREEN 13
getbb10: VGA13X
getbb12: SVGA16
getbb14: SVGA256
(restore bit block)
putbb02: SCREEN 1-4, SCREEN 11, HGraph (mono only)
putbb04: HGraph (InColor only)
putbb06: SCREEN 7-10, SCREEN 12, SVGA16(0), XMODE16
putbb08: SCREEN 13
putbb10: VGA13X
putbb12: SVGA16
putbb14: SVGA256
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: BitPlaneSave(seg%, x0%, y0%, x1%, y1%, plane%)
Subroutine: BitPlaneRestore(seg%, x0%, y0%, style%, plane%)
object files: same as BitBlockRestore and BitBlockSave
Function: bytes% = BitPlaneBytes(x0%, y0%, x1%, y1%)
object files: bbbytes.obj ($graph.obj)
Modes supported: HGraph (InColor)
SCREEN 7,8,12
SCREEN 9 (requires 128k+ EGA memory)
VESA6A, XMode16
SCREEN 10 (planes 0 and 2)
BitPlaneSave subroutines copy a section of the graphics screen to a
memory buffer in order to copy that block back to the screen with
BitPlaneRestore. This is similar to the BitBlockSave/BitBlockRestore
subroutines, except that BitPlane subroutines copy to or from only one
of the four "planes" of memory in 16-color modes. This is handy when
the area you want to copy is too big to fit in one array, or when you
want to move or modify only one plane at a time. The exact color
represented by each plane is determined by PALETTE or COLOR statements.
BitPlaneBytes calculates the number of bytes of memory required to save
the desired portion of the plane. All style% values work with
BitPlaneRestore. You may use AllocMem(bytes%) to allocate memory
space for the bit plane.
Example:
REM $INCLUDE: 'qlib.bi'
REM calculate the array size required, allocate the memory,
REM save a portion of one plane of the screen and restores it later.
REM note that valid plane numbers are 0 - 3
REM First I need to establish graphics mode
CALL Xmode16(xmode%, maxX%, maxY%)
.
.
x0 = 100: y0 = 0: x1 = 400: y1 = 347
bytes% = BitPlaneBytes(x0%, y0%, x1%, y1%)
seg% = AllocMem(bytes%): plane% = 0
CALL BitPlaneSave(seg%, x0%, y0%, x1%, y1%, plane%)
.
.
REM now we'll copy the plane back to the screen
CALL BitPlaneRestore(seg%, x2%, y2%, style%, plane%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: ClearView
object files: clrview.obj ($graph.obj, $horiz.obj)
Modes supported: All
ClearView erases everything within the active viewport. In
color modes, the background color set by GraphColor is used. Use
SetView to establish the active viewport.
Example:
CALL ClearView
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: colorvalue% = Color16(red%, green%, blue%)
object file: color16.obj
supports EGA and VGA 16-color modes
Color16 calculates a color value from individual red, green and
blue intensities, for changing the color palette in 16-color modes
(text or graphics). Used with Palette16. Red%, green% and blue%
range from 0 (off) to 3 (highest intensity).
Example: see Palette16
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: colorvalue& = Color256&(red%, green%, blue%)
object file: color256.obj
Supports all VGA and SVGA 256-color modes
Color256& returns a LONG INTEGER color value from individual
red% green% and blue% components for changing palette colors in
256-color modes. Color256& changes the actual color associated
with a particular color attribute. With Color256&, red, green and
blue color intensitites may range from 0 (off) to 63 (highest intensity).
Example: see Palette256
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: DrawBox(x0%, y0%, x1%. y1%, style%)
object file: drawbox.obj ($graph.obj, $horiz.obj, $vert.obj)
Modes supported: All
DrawBox draws a box with corners at (x0%, y0%), (x0%, y1%),
(x1%, y0%), (x1%, y1%). Legal style% parameters are -1, 0, and 1.
If any part of the box lies outside the active graphics viewport,
that part of the box will not be drawn. See also LinePattern.
Example:
CALL HGraph
x0% = 10: y0% = 10: x1% = 79: y1% = 38: style% = 0
CALL DrawBox(x0%, y0%, x1%, y1%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: DrawCircle(xc%, yc%, Xradius%, style%)
Subroutine: CircleAspect(numerator%, denominator%)
object files: drawcirc.obj ($graph.obj, $putdot.obj)
Modes supported: All
DrawCircle draws a circle on a graphics screen centered at xc%, yc%,
with x-radius Xradius%. The circle's aspect ratio may be changed with
CircleAspect. Legal style% parameters are -1, 0 and 1 with monochrome
modes. In color modes, style% parameters 2, -2, 3 and -3 are also
supported. Only the part of the circle which lies within the viewport
defined by SetView will be drawn.
CircleAspect changes the aspect ratio of the circle; using CircleAspect,
you can make the circle look like a flattened ellipse or a tall ellipse.
CircleAspect changes the Y-dimension of the circle; the X-dimension is
controlled with Xradius%. QLIB's default is an aspect ratio of 1:1.
CAUTION: extreme aspect ratios are not supported by DrawCircle.
With numerator% = 1, a maximum usable denominator% is 5, or else a
"divide by zero" error will occur. With denominator% = 1, a high
numerator will cause unpredictable results.
Example:
CALL DrawCircle(xc%, yc%, Xradius%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: DrawLine(x0%, y0%, x1%, y1%, style%)
object files: drawline.obj ($graph.obj, $horiz.obj, $vert.obj
$loslope.obj, $hislope.obj)
Modes supported: All
DrawLine draws a line from x0%, y0% to x1%, y1%. Legal style
parameters are -4 through 4. See also LinePattern.
Example:
x0% = 0: y0% = 0: x1% = 719: y1% = 348: style% = -1
CALL DrawLine(x0%, y0%, x1%, y1%, style%)
REM this erases a diagonal line across the screen
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: FillArea(x%, y%, reserved%)
object files: fillarea.obj ($graph.obj, $horiz.obj, fpattern.obj)
Modes supported: All
FillArea fills irregularly-shaped areas enclosed by solid lines.
FillArea works best with SIMPLE areas; holes in the area or areas with
"inside" corners dividing horizontal lines may not be filled properly.
Further development is planned, but FillArea in its present form is
useful in many circumstances. FillArea works by starting at the seed
pixel (x%, y%) and looking left and right for non-black region boundaries,
then filling horizontal lines between the boundaries. FillArea works
upward until the top of the area has been reached, then returns to the
seed pixel and works downward. Reserved% is reserved for QLIB's style%
parameter. FillArea presently assumes style% = 1. If you want to fill
rectangular areas, FillBox is much faster than FillArea.
Example:
CALL HGraph
.
.
.
CALL GraphColor(attr%) ' for color modes
CALL FillPattern(pattern$) ' optional fill pattern
CALL FillArea(x%, y%, reserved%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: FillBox(x0%, y0%, x1%. y1%, style%)
object files: fillbox.obj ($graph.obj, $horiz.obj)
Modes supported: All
Similar to DrawBox, FillBox uses the same coordinates and style
variable, but fills the box instead of drawing the sides. If
style% = 1 or 2, an optional pattern may be used to fill the box
(except SCREEN 1). See FillPattern.
Example:
CALL HGraph
x0% = 10: y0% = 10: x1% = 79: y1% = 38: style% = 0
CALL FillBox(x0%, y0%, x1%, y1%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: FillPattern(pattern$)
object files: fpattern.obj ($horiz.obj, $graph.obj)
Modes supported: HGraph (mono annd InColor)
VESA6A, XMode16, SVGA16
SCREEN 2,3,7,8,9,10,11,12
FillPattern defines an optional pattern used by FillBox if
style% >= 1, or by FillArea (which assumes style% = 1). The bit
patterns in the first 8 characters of pattern$ are used to modify the
fill in the box or area. FillPattern must be called before each call
to FillBox or FillArea. See Examples. FillBox will replace box borders.
If you want the box to have a solid outline, call DrawBox with style% = 1
after using FillBox with a pattern. Using style% = 1, the pattern will
completely replace whatever was in the box. 16-color modes use
style% = 2. BIT2INT in DATA.DOC is useful for establishing patterns.
Sample patterns, and what they produce:
pattern$ = CHR$(255) + STRING$(5,32) ' produces a pattern of squares
pattern$ = STRING$(8,32) ' produces vertical lines
pattern$ = CHR$(255) + STRING$(5,0) ' produces horizontal lines
pattern$ = STRING$(8,0): k% = 1
FOR i% = 1 TO 8
MID$(pattern$, i%) = CHR$(k%)
CALL ShiftINT(k%, 1)
NEXT i% ' produces diagonal lines, from
' upper right to lower left
pattern$ = STRING$(8,0):k% = 128
FOR i% = 1 TO 8
MID$(pattern$, i%) = CHR$(k%)
CALL ShiftINT(k%, -1)
NEXT i% ' produces diagonal lines, from
' upper left to lower right
Example:
x0% = 10: y0% = 10: x1% = 79: y1% = 38: style% = 1
pattern$ = CHR$(255) + STRING$(5,32) ' pattern for squares
CALL FillPattern(pattern$)
CALL FillBox(x0%, y0%, x1%, y1%, style%) ' fill box with pattern
CALL DrawBox(x0%, y0%, x1%, y1%, style%) ' draw solid box outline
CALL FillArea(x%, y%, reserved%) ' no pattern used
' because FillPattern
' was not called before
' FillArea
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: FontWidth(pixels%)
object files: fwidth.obj (f8x14.obj)
Modes supported: All
GPrint subroutines' default character width is 8 pixels. FontWidth
changes the number of pixels per character, permitting compressed
or expanded GPRINTing. When using fonts less than 8 pixels wide,
FontWidth can be used to make GPRINT to space the characters properly.
GPRINT prints 8-pixel wide characters no matter what FontWidth is;
FontWidth changes the spacing from the left side of one character to
the left side of the next.
Example:
DEFINT A-Z
CALL GPrint("normal character spacing",10,10,1)
CALL FontWidth(10)
CALL GPrint(" 10-pixel character spacing",10,30,1)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GBaseSeg (s%)
object files: gbaseseg.obj ($graph.obj)
Modes supported: HGraph (monochrome only)
SCREEN 1,2,3,4,11,13
GBaseSeg re-directs QLIB's Graphics subroutines to an alternate buffer.
This may be used to duplicate the effect of multiple screen pages.
GBaseSeg works only with non-planar, non-bank switched modes.
S% is the segment base address of the alternate buffer. QLIB assumes
that the buffer begins at the start of the segment. If you call
GBaseSeg with s% = 0, the default video buffer becomes active again.
Note that GBaseSeg will not work if you change graphics modes after
calling GBaseSeg.
When operating under a multi-tasking enviornment, such as DesqView,
GBaseSeg may also work with any mode supported by the multi-task
control program. Feedback, please!
Example on next page
REM GBaseSeg example
REM $INCLUDE: 'qlib.bi'
' load existing screen image to RAM buffer
gpd = fload("screen13.gph")
' switch to graphics mode
SCREEN 13
' after switching to graphics mode, tell QLIB
' where the off-screen buffer is
CALL gbaseseg(gpd)
' modify the off-screen image as desired
CALL GraphColor(10)
CALL DrawLine(0, 199, 319, 0, 1)
CALL gprint("this was printed to an off-screen buffer", 0, 60, 2)
' switch back to video buffer and print a message
CALL gbaseseg(0)
CALL gprint("press any key...", 0, 0, 1)
a = getkey
' copy the modified alternate buffer to the video buffer
' NOTE: Video buffer address and size vary depending on graphics mode:
'
' mode address size (bytes)
'
' SCREEN 1 &HB800 16384
' SCREEN 2 &HB800 16384
' SCREEN 3 &HB000 32768
' HGraph &HB000 32768
' SCREEN 4 &HB800 32768
' SCREEN 11 &HA000 38400
' SCREEN 13 &HA000 64000
bytes& = 64000
CALL CopyMem(gpd, 0, &HA000, 0, bytes&, 0)
' release the alternate buffer 'cuz I'm all done with it
' then wait for a keypress and exit
CALL freemem(gpd)
IF getkey THEN SCREEN 0
END
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GCopy(frompage%, topage%, oops%)
object files: gcopy.obj ($graph.obj)
Modes supported: HGraph (mono and InColor)
VGA13X (0 - 2)
SCREEN 3,7,8,9,10
Similar to BASIC's PCOPY command, GCopy copies one page of
graphics memory to another, but returns an error flag instead of
requiring ON ERROR to trap errors. GCopy also works with many VGA13X
modes. oops% = 0 if no error, or -1 if GCopy is not supported or
if either frompage% or topage% is too large.
Example:
frompage% = 0: topage% = 1
CALL GCopy(frompage%, topage%, oops%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GetDot(x%, y%, value%)
(formerly GetPixel)
object file: getdot.obj ($graph.obj, $getdot.obj)
Modes supported: All
Determines the color of the pixel located at (x%, y%).
Returns value% = -1 if (x%,y%) falls outside the active graphics
viewport.
Example:
x% = 0: y% = 0
CALL GetDot(x%, y%, value%)
REM This will determine the color of the pixel at the upper left
REM corner of the screen.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GraphColor(attr%)
object files: gcolor.obj ($graph.obj)
Modes supported: HGraph (InColor)
VESA6A, XMode16, VGA13X, SVGA16, SVGA256
SCREEN 1,7,8,9,10,12,13
Sets the color attribute to be used when QLIB subroutines are
used in color modes. Color attributes for 16-color modes may be
calculated with ColorAttr (See VIDEO.DOC).
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GCursor(x%, y%)
Subroutine: GUCursor(x%, y%)
object file: gcursor.obj ($graph.obj, $putdot.obj)
Modes supported: All
GCursor subroutines put a text cursor on graphics screens
at the character box with upper left coordinates at x%, y%.
GCursor and GUCursor subroutines are similar to QLIB's text-mode
CursorON and UCursorON subroutines, except that GCursor waits until
a key has been pressed before returning to QuickBASIC. The key
pressed may be determined with QLIB's input subroutines, or with
QB's INKEY$ function. In HGraph, SCREEN 9, 10, or 12, GCursor
subroutines work with either normal text or QLIB's small text. To use
GCursor with text printed by BASIC, see example 2.
Example 1:
CALL HGraph
a$ = "I want a cursor at the 'I' at the start of this line"
x% = 5: y% = 3: style% = 1
CALL GPrint(a$, x%, y%, style%)
CALL GCursor(x%, y%)
Example 2:
SCREEN 3 ' uses QBHERC.COM or MSHERC.COM
CALL StdText ' make sure the BIOS data area
' has been updated
row% = 10: column% = 3
LOCATE row%, column%: PRINT a$ ' use QB to print text
x% = (column% - 1) * 9 ' this example is for a
y% = (row% - 1) * 14 ' QBHERC 9x14 character box
CALL GCursor(x%, y%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GMouse
object files: gmouse.obj (mousedat.obj, $graph.obj)
GMouse initializes the alternate graphics mouse cursor driver.
After calling GMouse, QLIB's alternate mouse cursor may be used in
any graphics mode supported by QLIB. This is nessesary because most
mouse drivers do not recognize modes other than those supported by
IBM-brand equipment (such as Hercules, InColor, ATT, VGA13X, SVGA,
xmode16).
The GMouse cursor has some limitations: it wraps around to the left
side of the screen if it gets within 13 bytes of the right edge, it
does not (yet) respond to QLIB's MouseLimit subroutine, and it must
first be hidden with HideGMouse before using MousePos. GMouse works
with these QLIB mouse subroutines:
MouseStatus KeyOrButton HideGMouse ShowGMouse MousePos
Any time you change graphics modes, you must re-initialize GMouse.
Turn GMouse off with HideGMouse before you switch back to text mode.
Example:
REM $INCLUDE: 'qlib.bi' ; has declaration for IsMouse
' enter desired graphics mode before calling GMouse
svgaOK = SVGA256(3)
IF IsMouse THEN CALL GMouse: CALL ShowGMouse
.
.
.
' move the mouse cursor to new location
CALL HideGMouse
CALL MousePos(x%, y%)
CALL ShowGMouse
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutines: HGraph, HGraph0
object files: hgraph.obj (q$herc.obj, hmode.obj)
Subroutine: HText
object files: hmode.obj (q$herc.obj)
Requires Hercules (mono or InColor)
These subroutines change modes on the Hercules graphics card,
without using QBHERC.COM. If you use HGraph to set graphics mode,
QuickBASIC video input/output functions will not work, and you must use
HText to restore text mode. QB2/QB3/QB87 users MUST use HGraph to use
Hercules graphics. HText resets the active page to 0. (See UseTPage in
VIDEO.DOC). HGraph clears the entire video buffer; HGraph0 clears only
page 0.
With HGraph0, anything in graph page 1 is undisturbed. A graph may
be stored in page 1, the system can be switched back to text mode for a
while, and if text page 8 - 15 are not used, the graph may be restored
by calling HGraph0 and GCopy(1, 0, oops%).
HGraph0 can also be used if text screens are stored in pages 8 - 15.
As long as graph page 1 is not used, the text screens will not be
disturbed and can be restored with HText and TCopy.
If you are using Hercules graphics in a 2-monitor system, use HGraph0.
HGraph0 and HText will make the Monochrome monitor the default; to
use the color monitor, call ModeColor (See VIDEO.DOC).
Example:
CALL HGraph ' establishes Hercules Graphics mode
' QLIB graphics subroutines will work properly
CALL HText ' returns Hercules system to text mode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GCenter(st$, y%, style%)
object files: gcenter.obj ($graph.obj, gprint.obj, $gp.obj, f8x14.obj)
GCenter prints text on a graphics screen, centered horizontally.
This subroutine calculates the correct x-coordinate, then calls
GPrint. GCenter supports all style% parameters and graphics
modes supported by GPrint.
Example:
REM I want to center a graph title at the top of the screen
y% = 0 ' top of screen
style% = 1: title$ = "Graph Title"
CALL GCenter(title$, y%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GCenterX(st$, y%, style%)
object files: gcenterx.obj ($graph.obj, gprintx.obj, $gp.obj, f8x14.obj)
GCenterX prints double-width text on a graphics screen, centered
horizontally. This subroutine calculates the correct x-coordinate,
then calls GPrintX. GCenterX supports all style% parameters and
graphics modes supported by GPrintX.
Example:
REM I want to center a graph title at the top of the screen
y% = 0 ' top of screen
style% = 1
title$ = "Graph Title"
CALL GCenterX(title$, y%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GLineEdit(st$, x%, y%, style%, options%, keycode%)
object files: gedit.obj (q$edit.obj, gcursor.obj, gprint.obj)
Modes supported: All
GLineEdit works like LineEdit (see INPUT.DOC), but is usable in
graphics modes. GLineEdit uses all LineEdit options except 8 (BIOS
display) and -32768 (alternate cursor). All LineEdit editing commands,
as well as StartEdit and LastEdit, work properly with GLineEdit.
GLineEdit also works fine with SmallText. See LineEdit for examples.
Style% 1 and -1 work best.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GLoad(filename$, oops%)
Subroutine: GSave(filename$, oops%)
object files: gsave.obj ($graph.obj, $asciiz.obj, $gbytes.obj)
Modes supported: All
GLoad loads a Graphics screen from a file to the screen. The file
must have been previously saved by GSave. GLoad and GSave load to or
save from the active graphics page. If no error occurred, oops% = 0.
Oops% will be an MS-DOS error code if a file handling error occurs.
See the introductory remarks in DISK.DOC for MS-DOS error codes.
NOTE: files created by GSave eat lots of disk space:
HGraph (mono) 32,768 bytes
HGraph (InColor) 131,072 bytes
VGA13X(0) 64,000 bytes
VGA13X(1) 76,800 bytes
VGA13X(2) 128,000 bytes
VGA13X(3) 172,800 bytes
XMode16 up to 240,000 bytes
VESA6A, SVGA16(0) 240,000 bytes
SVGA16(1) 393,216 bytes
SVGA256(0) 256,000 bytes
SVGA256(1) 307,200 bytes
SVGA256(2) 480,000 bytes
SVGA256(3) 786,432 bytes
SCREEN 1, 2 16,384 bytes
SCREEN 3, 4 32,768 bytes
SCREEN 7 32,000 bytes
SCREEN 8 64,000 bytes
SCREEN 9 112,000 bytes
SCREEN 10 56,000 bytes
SCREEN 11 38,400 bytes
SCREEN 12 153,600 bytes
SCREEN 13 64,000 bytes
Example:
filename$ = "BARGRAPH.HGC"
CALL GSave(filename$, oops%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GLoadEMS(handle%)
Function: handle% = GSaveEMS
object files: gsaveems.obj ($graph.obj, $emspage.obj, ems.obj,
$gbytes.obj, banks.obj)
Modes supported: All
Similar to GLoad and GSave; GSaveEMS saves a Graphics screen in
EMS memory, and GLoadEMS copies from EMS to the screen. These
subroutines assume that EMS memory is installed; see IsEMS in EMSXMS.DOC
to detect EMS memory. GSaveEMS allocates a block of EMS memory, copies
the screen to EMS, and returns a handle for subsequent access to the
memory block. Multiple screens may be stored if sufficient EMS memory
is available. When you are done using the stored screen, call
FreeEMS(handle%) to release the EMS memory. If you do not release the
EMS block before your program ends, that memory will not be available
to other programs. See FreeEMS in EMSXMS.DOC. GSaveEMS and GLoadEMS
return EMS error status in EMSError (see EMSXMS.DOC).
Example:
REM $INCLUDE: 'qlib.bi'
.
.
.
REM assume system in graphics mode
IF IsEMS THEN
handle% = GSaveEMS
IF EMSError GOTO UseFile
SavedInEMS = 1 ' turn program's EMS flag on
SavedAsFile = 0 ' turn program's file flag off
ELSE
UseFile:
REM save the screen to disk file if EMS not available
filename$ = "BARGRAPH.HGC"
CALL GSave(filename$, oops%)
SavedAsFile = 1: SavedAsEMS = 0
ENDIF
.
.
.
.
REM later ...
IF SavedAsEMS THEN
CALL GLoadEMS(handle%)
IF NOT EMSError THEN CALL FreeEMS(handle%)
ELSE
CALL GLoad(filename$, oops%)
IF NOT oops% THEN CALL KillFile(filename$, oops%)
ENDIF
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GPage(page%, oops%)
object files: gpage.obj ($graph.obj, q$herc.obj)
Modes supported: HGraph (mono and InColor)
VGA13X(0 - 2)
SCREEN 7,8
SCREEN 9,10 (256k EGA memory)
GPage combines the function of UseGPage and ShowGPage; see UseGPage
and ShowGPage for further information.
Example:
CALL GPage(page%, oops%)
REM this is equivalent to
REM CALL UseGPage(page%, oops%)
REM CALL ShowGPage(page%, oops%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GPrint(st$, x%, y%, style%)
object files: gprint.obj ($graph.obj, $gp.obj, f8x14.obj)
Modes supported: All (SCREEN 1, style% 1 and -1 only)
GPrint offers much more flexibility than BASIC's PRINT command when
printing text on a graphics screen, and it's the only way to put text
on a Hercules graphics screen if MSHERC is not loaded. GPrint prints
a string of text anywhere on the screen in normal, reverse video, XOR
or "foreground only" modes. GPrint is also much faster than QB's PRINT
command in graphics modes.
The size of each character and the number of characters across the
screen depends on the graphics mode:
mode standard character size columns
HGraph & SCREEN 3 8 x 14 90
SCREEN 1, 7, 13 8 x 8 40
SCREEN 2, 8 8 x 8 80
SCREEN 4, 9,10,11,12 8 x 14 80
VGA13X(0-2) 8 x 14 40
VGA13X(3) 8 x 14 45
VESA6A, SVGA16(0) 8 x 14 100
XMode16 8 x 14 varies
SVGA16(1), SVGA256(3) 8 x 14 128
SVGA256(0 or 1) 8 x 14 80
SVGA256(2) 8 x 14 100
All ASCII characters may be used. x% and y% are the PIXEL locations of
the upper left corner of the first character. SmallText, below, allows
GPrint to use the smaller 8 x 8 character in Hercules, VESA6A, XMode16,
SCREEN 9-12 and SVGA modes. Legal style% values are -2, -1, 0, 1 and 2.
In modes with 8 x 8 characters, you must call SmallText sometime
before calling GPrint if you use characters greater than CHR$(127).
To calculate how many rows of text a graphics screen can display,
divide maximum Y by pixel rows (i.e., a Hercules screen can display
347/8 = 43 rows of text in SmallText mode).
Example:
st$ = "This is an example of text in graphics mode"
x% = 10: y% = 20: CALL GPrint(st$, x%, y%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GPrintDOWN(st$, x%, y%, style%)
Subroutine: GPrintUP(st$, x%, y%, style%)
object files: gprint.obj (q$graph.obj, $gp.obj, f8x14.obj)
Modes supported: same as GPrint
GPrintUP rotates the string so that text reads from the bottom of
the screen to the top. This is useful for labeling the vertical axis of
a graph, among other things. GPrintDOWN reads from the top of the
screen to the bottom. These subroutines use SmallText's 8 x 8 character
box, allowing up to 43 characters from the bottom of the screen to the
top in Hercules mode. If you are going to use characters greater than
CHR$(127), you must call SmallText some time in your program before
calling GPrintDOWN/UP. However, QLIB does not need to be in SmallText
mode when you call GPrintDOWN or GPrintUP. All GPrint style% values are
valid.
Example:
DEFINT a - z
CALL HGraph
CALL SmallText ' let GPrintUP know where to find
. ' character definitions > CHR$(127)
.
.
CALL GPrintUP(text$, x%, y%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: GPrintX(st$, x%, y%, style%)
Subroutine: GPrint2X(st$, x%, y%, style%)
Subroutine: GPrintDOWNX(st$, x%, y%, style%)
Subroutine: GPrintDOWN2X(st$, x%, y%, style%)
Subroutine: GPrintUPX(st$, x%, y%, style%)
Subroutine: GPrintUP2X(st$, x%, y%, style%)
object files: gprintx.obj (q$graph.obj, $gp.obj, f8x8.obj)
Modes supported: same as GPrint
GPrintX subroutines are similar to GPrint, GPrintUP and GPrintDOWN,
except each character in st$ is expanded to twice its normal horizontal
size before printing it on the screen; this is handy for graph headings.
GPrint2X subroutines expand each character horizontally and vertically;
All graphics modes and styles supported by GPrint work fine with these
expanded character subroutines. See GPrint for example.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: LinePattern(pattern$)
object files: fpattern.obj (drawline.obj)
LinePattern passes a string of characters of up to 8 bytes to QLIB's
DrawLine and DrawBox subroutines. The pattern of bits in pattern$ modify
lines so that they are drawn as a series of dots and/or dashes instead of
as a solid line. Lines drawn with a pattern will be slower than those
drawn without a pattern. In order to use pattern$, style% must be greater
than zero. On monochrome screens, only style% 1 and 2 are useful.
LinePattern must be called before each call to DrawLine or DrawBox if
it is to work.
Modes supported: All
Style% parameters have the following effects:
style% 1 = both foreground and background colors are
drawn, obliterating underlying pixels
style% 2 = foreground only replaces pre-existing pixels.
style% 3 = foreground is ORed with pre-existing pixels
style% 4 = foreground is ANDed with pre-existing pixels.
Example:
pattern$ = SPACE$(8)
CALL LinePattern(pattern$)
CALL DrawBox(x0, y0, x1, y1, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: LoadPCX(filename$)
object files: loadpcx.obj (fload.obj, $plane.obj. $graph.obj)
Reads and decodes .PCX-format file, copying to screen.
LoadPCX assumes that the screen mode is appropriate for the image;
for example, LoadPCX assumes that a 16-color .PCX image is loaded
to a 16-color screen, or a 256-color .PCX image is loaded to a 256-
color screen. See also PCXInfo. Returns with DOSError <> 0 if a
file error occurred.
Example:
DEFINT A-Z
DECLARE FUNCTION GetKey()
TYPE pcxdata
horiz AS INTEGER
vert AS INTEGER
colors AS INTEGER
planes AS INTEGER
xpixels AS INTEGER
ypixels AS INTEGER
END TYPE
' pcxdata.horiz is the horizontal resolution of the screen
' this is 640 for many EGA/VGA 16-color modes
' pcxdata.vert is the vertical resolution of the screen
' this is 350 for SCREEN 10 and 480 for SCREEN 12
' pcxdata.colors is the number of colors encoded in the .PCX file
' pcxdata.planes = 1 for SCREEN 1, 2 & 13, 4 for all 16-color modes
' pcxdata.xpixels is the number of horizontal pixels in the image
' pcxdata.ypixels is the number of vertical pixels in the image
DIM a AS pcxdata
p = VARPTR(a)
name$ = "\pcx\demo.pcx"
CALL PCXInfo(name$, p)
b = &H12 ; assume VGA 640 x 480
IF a.ypixels <= 350 THEN b = &H10 ; use 640 x 350 if smaller image
IF a.colors = 256 then b = &H13 ; SCREEN 13 if 256 colors
CALL screenmode(b)
CALL LoadPCX(name$)
IF GetKey THEN CALL screenmode(3)
END
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: ScreenMode(mode%)
object files: scrmode.obj (hgraph.obj, hmode.obj)
ScreenMode allows graphics or text mode to be set, bypassing
QuickBASIC's SCREEN command. If your program uses QLIB's graphics
subroutines instead of QuickBASIC's graphics commands, you can reduce
your program's size significantly by using ScreenMode instead of
SCREEN. ScreenMode also allows you to use VESA mode &H6A, which
is supported by QLIB's graphics (or use SVGA16 for high-resolution
16-color modes).
The mode% parameter is the BIOS mode number for the screen mode
(except Hercules - QLIB uses the Microsoft convention of mode 8
for Hercules since no BIOS mode number exists for Hercules).
BIOS mode numbers and the equivalent QuickBASIC SCREEN numbers are:
BIOS number equipment SCREEN number
&H3 CGA, MCGA, EGA, VGA SCREEN 0 (text mode)
&H4 CGA, MCGA, EGA, VGA SCREEN 1
&H5 CGA, MCGA, EGA, VGA SCREEN 1
&H6 CGA, MCGA, EGA, VGA SCREEN 2
&H7 Monochrome, Hercules SCREEN 0 (text mode)
EGA Monochrome
&H8 Hercules, InColor SCREEN 3
&H40 ATT 6300 SCREEN 4
&HD EGA, VGA SCREEN 7
&HE EGA, VGA SCREEN 8
&HF EGA, VGA (monochrome) SCREEN 10 128k+ memory
&H10 EGA, VGA SCREEN 9 128k+ memory
&H11 MCGA, VGA SCREEN 11
&H12 VGA SCREEN 12
&H13 MCGA, VGA SCREEN 13
&H6A VESA SVGA
NOTE: ScreenMode is NOT intended for switching between a color
monitor and a monochrome monitor. Use ModeColor and ModeMono for
monitor switching.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: Palette16(attribute%, colorvalue%)
object file: palet16.obj
supports: EGA and VGA 16-color modes
Palette16 changes the actual color associated with a particular
color attribute. If you call Palette16 with attribute% and
colorvalue% both equal to -1, the default colors will be restored.
Palette16 works in EGA and VGA 16-color modes, except where an EGA
card is driving a CGA monitor. See also Color16.
Example:
REM $INCLUDE: 'qlib.bi'
REM I want to use a color with low-intensity red
REM and high-intensity blue
red% = 1: blue% = 3: green% = 0
colorvalue% = Color16(red%, green%, blue%)
REM I'll use color attribute 8 for this color
CALL Palette16(8, colorvalue%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: Palette256(attribute%, colorvalue&)
object file: palet256.obj
supports: 256-color modes
Similar to Palette16, Palette256 changes the actual color
displayed by a specified color attribute. Colorvalue& may be
calculated from individual red, green and blue intensities using
Color256.
Example:
REM $INCLUDE: 'qlib.bi'
red% = 63 ' brightest red
green% = 10 ' not much green
blue% = 32 ' medium blue intensity
colorvalue& = Color256(red%, green%, blue%)
REM I'll use color attribute 48 for this color
CALL Palette256(48, colorvalue%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: PCXInfo(filename$, dataptr%)
object files: pcxinfo.obj ($graph.obj)
Reads vital data from the header of a .PCX-format file. From this
data you may determine whether you can use the image or what screen
mode will work best. PCXInfo also updates the DOSError flag if an
error occurred reading the file header.
Example: see LoadPCX
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: PutDot(x%, y%, style%)
(formerly SetPixel)
object files: putdot.obj ($graph.obj, $putdot.obj, $herc16,obj,
$ega16.obj, $vga256.obj)
Modes supported: All
Sets the pixel at (x%, y%) according to the specified style% and
current GraphColor. In monochrome modes, legal style% values are
-1, 0, and 1. Color modes may use style% -4 through 4. Coordinates
outside the active graphics viewport are ignored.
Example:
x% = 10: y% = 10: style% = 0
CALL PutDot(x%, y%, style%)
REM In this example, the pixel will be turned off if it had been
REM on, and will be turned on if it had been off.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: Restore256(s%)
object file: save256.obj (q$alloc.obj)
supports: 256-color modes
Restores palette registers saved by Save256. See Save256, below.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: s% = Save256
object file: save256.obj (q$alloc.obj)
supports: 256-color modes
Saves all color palettes in a block of RAM, so you can restore
the color registers at a later time with Restore256. Save256 allocates
a block of RAM large enough to save the registers, and returns the
segment address of the block. After you are done with the saved
color registers, you may release the memory block with FreeMem(s%).
Example:
REM $INCLUDE: 'qlib.bi'
SCREEN 13
.
.
.
REM I've changed several of the color registers and I want to
REM save this particular set of colors
s% = Save256
IF s% = 0 THEN ... 'oops- not enough RAM available
.
.
.
REM now I want to restore this set of colors
CALL Restore256(S%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: ScreenDump(oops%)
object files: scrndump.obj (q$graph.obj)
Modes supported: HGraph (mono) not yet tested with InColor
SCREEN 3
Prints the active graphics screen on a graphics printer (Epson MX,
FX, RX; IBM Graphics Printer, IBM ProPrinter, and compatibles).
ScreenDump can be stopped with the ESC key. If this occurs, oops% = 27
is returned (27 is the ASCII character code for the ESC key). If the
computer is not in Hercules graphics mode, oops% = -1. If all went
well, oops% = 0. Use PrinterReady (EQUIP.DOC) to see if the printer is
ready.
Example:
CALL ScreenDump(oops%)
oops$ = ""
IF oops% = -1 THEN oops$ = "Not Hercules mode"
IF oops% = 27 THEN oops$ = "Printing stopped"
IF LEN(oops$) THEN PRINT oops$
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: ShowGPage(gpage%, oops%)
object files: gpage.obj ($graph.obj)
Modes supported: HGraph (mono and InColor) pages 0 and 1
SCREEN 3 pages 0 and 1
SCREEN 7 pages 0 through 7 (depends on EGA memory)
SCREEN 8 pages 0 through 3 (depends on EGA memory)
SCREEN 9 pages 0 and 1 (256k EGA memory)
SCREEN 10 pages 0 and 1 (256k EGA memory)
VGA13X(0) pages 0 through 3
VGA13X(1) pages 0 through 2
VGA13X(2) pages 0 and 1
ShowGPage changes the graph page visible on the screen.
This can be handy for animation or for storing one graph while another
is displayed. If gpage% is too large for the default mode, oops% = -1.
See also GPage.
Example:
CALL HGraph ' establish Hercules graphics mode
CALL Use64k ' allow 2 pages in graphics mode
.
. ' display graph 0
.
gpage% = 1
CALL UseGPage(gpage%, oops%)
' now put a graph in the second page
.
.
.
CALL ShowGPage(gpage%, oops%)
' let's look at graph 1 now that it's
. ' complete
.
.
gpage% = 0
CALL GPage(gpage%, oops%) ' restore default output page
' and look at graph 0
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: ShowGraphPlane(plane%, oops)
object files: gplane.obj ($graph.obj)
Modes supported: VESA6A, XMode16, SVGA16
SCREEN 7,8,12
SCREEN 9 (128k or more EGA memory)
SCREEN 10 (planes 0 and 2, 128k or more EGA memory)
EGA and VGA memory in 16-color modes is arranged in 4 parallel
"planes". The 16 colors available when all planes are visible result
from a combination of the data bits in each plane at each data address.
The planes, numbered 0, 1, 2 and 3, each control a single color. With
the default palette, plane 0 is blue, plane 1 is green, plane 2 is red
and plane 3 is "intensity". A pixel that appears bright blue in the
screen represents pixels at identical locations in the Blue and Intensity
planes. (Note that the actual colors each plane represents may change
depending on the use of QuickBASIC's COLOR and PALETTE statements).
The plane% parameters are:
plane 0 plane% = 1
plane 1 plane% = 2
plane 2 plane% = 4
plane 3 plane% = 8
Use BASIC's OR operator to show more than one plane; i.e., to
show only planes 0 and 3, plane% = 1 OR 8. To restore normal output,
plane% = 1 OR 2 OR 4 OR 8.
Example:
CALL ShowGraphPlane(plane%, oops)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: SetView(x0%, y0%, x1%, y1%)
Subroutine: GetView(x0%, y0%, x1%, y1%)
object files: view.obj ($graph.obj)
Modes supported: All
SetView establishes the active viewport on the active graphics
page. Most QLIB graphics subroutines limit their output to the
active viewport. GetView returns the viewport coordinates
presently active. QLIB's default viewport is the entire graphics
screen. If SetView is called with coordinates outside legal bounds
(for example, if x1% = 1000), SetView limits the coordinates to the
bounds for the active graphics mode (or to Hercules bounds if the
system is either not in graphics mode or in an unsupported mode).
This is NOT like QuickBASIC, which calls the out-of-bounds coordinate
an illegal function call. This SetView feature is handy for clearing
out old view data or for establishing the entire screen as the
viewport when the exact limits are variable or unknown (such as
with XMode16).
Example:
CALL SetView(x0%, y0%, x1%, y1%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: SmallText
Subroutine: StdText
object files: smalltxt.obj (gprint.obj, q$graph.obj, f8x8.obj)
Modes supported: HGraph (mono and InColor)
VESA6A, XMode16, SVGA16, SVGA256
SCREEN 3,9,10,12
GPrint and GLineEdit may be set to use a smaller 8 x 8 character,
which allows up to 43 rows of text in Hercules graphics mode, where
StdText (QLIB's default) results in a maximum 25 rows of text. Once
SmallText is called, GPrint and GLineEdit will print 8 x 8 text until
the 8 x 14 character is restored with StdText. 8x8 and 8x14 text
may be mixed on one screen.
Example:
CALL HGraph ' establish Hercules graphics mode
CALL SmallText ' sets GPrint to use small text
CALL GPrint(a$, x0%, y0%, style%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: VGA13X(modenumber%)
object files: vga13x.obj ($graph.obj)
Requires VGA
Provides extended VGA 256-color modes. I have used these modes
on PS/2 computers and with a variety of other VGA cards; it should be
compatible with most VGA systems. VGA13X modes provide up to twice the
resolution of SCREEN 13, or up to 4 pages with resolution identical
to SCREEN 13.
VGA13X modes are:
horizontal pixels vertical pixels pages
VGA13X(0) 320 200 0, 1, 2, 3
VGA13X(1) 320 240 0, 1, 2
VGA13X(2) 320 400 0, 1
VGA13X(3) 360 480 0
Example:
CALL GetCRT(crt)
IF crt = 3 THEN
CALL VGA13X(2) ' 2-page mode
ELSE
PRINT "VGA modes not available"
END IF
.
.
.
REM all done with graphics, go back to text mode
CALL ModeColor ' 80 x 25 text mode
CALL XModeClear ' clear QLIB's internal flags
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: goodmode% = SVGA16(i%)
object file: svga16.obj ($svga.obj, $graph.obj, $banks.obj)
SVGA16 sets most super VGA boards in either a 1024x768 16-color mode
(i% = 1) or an 800x600 16-color mode (i% = 0). Boards supported are:
Ahead Technologies
ATI
Chips & Technologies
Everex
Genoa GVGA
NCR
Oak Technologies
Paradise (Western Digital)
Trident
Trident 8900
Tseng (Genoa, Orchid, Willow)
Tseng 4000
VESA standard
Video 7
SVGA16() returns goodmode = 0 if the requested mode is not available
on your equipment, goodmode = -1 if successful.
Most QLIB subroutines may be used with SVGA16 modes. See documentation
for each subroutine.
QLIB's SVGA subroutines are derived from John Bridges' public domain
VGAKIT board identification and bank switching code.
Example:
REM $INCLUDE: 'qlib.bi' ' has function declaration for SVGA16()
REM Use SVGA mode if available, mode &H12 otherwise
IF NOT SVGA16(1) THEN CALL ScreenMode(&H12)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Function: goodmode% = SVGA256(i%)
object file: svga256.obj ($svga.obj, $graph.obj, $banks.obj)
SVGA256 is similar to SVGA16, but sets one of several 256-color modes.
Modes available are:
i% = 3: 1024x768
i% = 2: 800x600
i% = 1: 640x480
i% = 0: 640x400
Equipment supported is listed under SVGA16, plus:
Compaq (640x480 only)
!! DO NOT USE ANY I% VALUES OTHER THAN 0, 1, 2 & 3 !!
SVGA256() returns goodmode = 0 if the requested mode is not available
on your equipment, goodmode = -1 if successful.
Most QLIB subroutines may be used with SVGA16 modes. See documentation
for each subroutine.
QLIB's SVGA subroutines are derived from John Bridges' public domain
VGAKIT board identification and bank switching code.
Example:
REM $INCLUDE: 'qlib.bi' ' has function declaration for SVGA256()
REM Use SVGA mode if available, VGA13X mode otherwise
IF NOT SVGA256(3) THEN CALL VGA13X(3)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: Use32k
Subroutine: Use64k
object file: q$herc.obj
Requires Hercules (mono or InColor)
Use32k masks the second 32k block of Hercules memory out of the
memory map. If the second 32k is included in the memory map, QLIB's
video routines can use all Hercules screen pages. The second 32k of
Hercules video memory conflicts with most color monitors' address space,
so Use32k should be used to mask the second 32k out of the memory map
for two-monitor systems. Use64k allows the second block. QLIB's
default is Use32k. You MUST call Use64k if you want to use graphics
page 1 with Hercules systems.
Example:
CALL GetCRT(crt%)
IF crt% >= 128 THEN CALL Use64k
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: UseFont (fseg%, fptr%, points%, bytes%)
object files: usefont.obj, f8x14.obj
Supports: all graphics modes with ymax% > 200
UseFont permits use of non-standard fonts with GPrint, GPrintX, GCenter
and GCenterX. The font you wish to use must be somewhere in memory,
either "hardwired" into your program or loaded from a disk file.
Parameters used when calling UseFont are:
fseg% = segment address of character definition data
fptr% = offset address of character definition data
points% = height of each character on screen (in pixel rows)
bytes% = byte interval from the start of one character definition
to the next
QLIB's GPrint subroutines assume that each character in the font is
8 pixels wide.
To use character widths other than 8 pixels, use FontWidth.
This can be used not only to print properly spaced characters in a
font less than 8 bits wide, but may also be used to add extra space
between characters in a string. Note that the character definition
data still needs to be 8 bits wide; FontWith's pixel width parameter
tells GPRINT how much space to leave between characters.
Example:
REM $INCLUDE: 'C:\QB4\QLIB.BI'
REM I want to use the italic font supplied by Hercules with the
REM InColor Card and Graphics Card Plus. All Hercules font files
REM have a byte interval of 16, even for those fonts which are
REM less than 16 points high.
filename$ = "C:\RAMFONT\ITALICS.FNT"
fseg% = FLoad (filename$) ' load font file into far memory
fptr% = 0 ' Hercules font definitions begin
' at the start of the file
points% = 14: bytes% = 16 ' 14-point font
CALL UseFont (fseg%, fptr%, points%, bytes%)
CALL FontWidth(10) ' add extra space
REM GPrint will now use italics font until SmallText or StdText is
REM is called, or until UseFont is called with another font definition
REM Once you are done with the font, release the far memory with
REM CALL FreeMem (fseg%)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: UseHercules
Subroutine: UseDefault
object file: q$graph.obj
UseHercules forces QLIB's graphics subroutines to use Hercules-
mode algorithms. This is handy when you want to create a virtual
graphics screen (for ScreenDump, as an example) while the computer
is displaying a graph in another graphics mode. UseDefault causes
QLIB to use the algorithms for the system's active graphics mode.
UseHercules is NOT required if the system is in Hercules mode.
Example:
CALL UseHercules
.
.
.
CALL UseDefault
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: UseGPage(gpage%, oops%)
object files: gpage.obj ($graph.obj)
Modes supported: HGraph (mono and InColor) pages 0 and 1
SCREEN 3 pages 0 and 1
SCREEN 7 pages 0 through 7 (with 265k EGA)
SCREEN 8 pages 0 through 3 (with 265k EGA)
SCREEN 9 pages 0 and 1 (256k EGA memory)
SCREEN 10 pages 0 and 1 (256k EGA memory)
VGA13X(0) pages 0 through 3
VGA13X(1) pages 0 through 2
VGA13X(2) pages 0 and 1
UseGPage changes the default screen page for QLIB's graphics
subroutines. QLIB's default gpage% is 0. If multiple pages are not
available for the current mode, or gpage% is too big, oops% = -1.
Example:
CALL HGraph ' establish Hercules graphics mode
' HGraph calls Use64k
gpage% = 1
CALL UseGPage(gpage%, oops%)
' QLIB's graphics subroutines use page 1 now
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: XMode16(m%, maxX%, maxY%)
Subroutine: XMode16A(m0%, m1%, maxX%, maxY%)
object file: xmode.obj ($graph.obj)
Subroutine: XModeClear
Subroutine: ModeColor
XMode16 subroutines allow the use of many extended EGA and VGA
graphics cards at higher resolutions than IBM's products allow, in
16-color modes. Depending on the graphics card/monitor combination
in use, resolutions up to 800 pixels horizontal and 600 pixels vertical
are possible. The manual supplied with your extended EGA or VGA card
contains the information you need to put the high-resolution modes to
work. A multi-frequency monitor is generally required (see the graphics
card manual for specific requirements).
You must have the required equipment and use the correct mode number;
hardware damage may result from improper use of XMode16. I cannot be
held responsible for damage resulting from use of XMode16.
When using XMode16, the parameters required are:
m% = mode number (from graphics card manual, for 8086 register AL)
maxX% = maximum horizontal dimension
maxY% = maximum vertical dimension
If 800 horizontal pixels are available, maxX% should be 799. Similarly,
if 600 vertical pixels are possible, maxY% should be 599.
If your graphics card requires two mode parameters in the 8086's
AL and BL registers, use XMode16A instead, where
m0% = mode number for AL register
m1% = mode number for BL register
maxX% = maximum horizontal dimension
maxY% = maximum vertical dimension
Any QLIB subroutines compatible with XMode16 will work equally well
with XMode16A.
Your graphics card manual lists mode numbers, equipment requirements,
and the number of horizontal and vertical pixels corresponding to the
mode. Mode numbers are usually in hex format. Some modes and
corresponding mode numbers are listed on the next page:
Equipment mode mode number Example
Orchid ProDesigner 800x600 &H29 CALL XMode16(&H29, 799%, 599%)
STB EM/16
Genoa
Sigma X16
Everex MED EGA 640X480 &H70, &H00
(Micro Enhancer Deluxe) CALL XMode16a(&H70, &H00, 639%, 479%)
752x410 &H70, &H01
CALL XMode16a(&H70, &H01, 751%, 409%)
ATI VGA Wonder 800x600 &H54 CALL XMode16(&H54, 799%, 599%)
ATI VIP 800x560 &H53 CALL XMode16(&H53, 799%, 559%)
Paradise Plus-16 800x600 &H58 CALL XMode16(&H58, 799%, 599%)
Paradise Professional
Video 7 Fastwrite 800x600 &H62 CALL XMode16(&H62, 799%, 599%)
Video 7 VRAM
If any of this information conflicts with the specifications in your
video card's instruction manual, the manual's recommendation is a safer
bet. Note that all the above modes require a multi-frequency monitor.
When you're all done with Graphics mode, CALL ModeColor to return to
80x25 text mode, and CALL XModeClear to reset QLIB's internal XMode flags.
REM All done with graphics for now, go back to 80 x 25 text mode
CALL ModeColor
REM also clear QLIB's internal flags
CALL XModeClear
***************** QWINDOW USER-DEFINED COORDINATE SUBSYSTEM ****************
The QLIB QWindow user-defined coordinate subsystem for QLIB graphics is
intended as a replacement for BASIC's WINDOW command. The QWindow system
permits the programmer to specify custom coordinates for any QLIB graphics
mode, and changes the direction of increasing y-coordinates from the
default top-to-bottom to the more familiar bottom-to-top orientation.
QWindow subroutines are listed at the end of this file.
For each QWindow graphics subroutine, the usage and calling parameters are
identical to the primary QLIB graphics subroutine. For example,
to use QWBitBlockBytes, see the documentation for BitBlockBytes, but
call QWBitBlockBytes with QWindow coordinates.
If you have defined your own coordinates, you may still use QLIB's primary
graphics subroutines with the absolute coordinates at the beginning of
this file. If your program repeatedly calls QLIB graphics subroutines
with the same coordinates, your program will run a bit faster if you
convert QWindow coordinates to QLIB's native absolute coordinates and
use the non-QWindow subroutine. See QW2Abs.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: QW2Abs(x%, y%)
object file: qw2abs.obj, qwindow.obj
QW2Abs converts QWindow coordinates to QLIB's native absolute
coordinates. This is handy if you will be repeatedly calling QLIB
graphics subroutines with the same coordinates; convertng to absolute
coordinates and calling the non-QWindow subroutine will make your
program run a bit faster.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: QWindow(x0%, y0%, x1%, y1%)
object file: qwindow.obj ($graph.obj)
QWindow establishes the user-defined coordinate system. The
coordinate at (x0%, y0%) is the lower left corner of the working area
and the coordinate at (x1, y1) is the upper right corner of the area.
The working area can be either the entire screen or QLIB's active view
area (see QWScreen and QWView). If x0% is less than 0, the origin
of the horizontal axis will be shifted right. If y0% is less than 0,
the origin of the vertical axis will be shifted up. Maximum values
for all coordinates is 32,767; minimum is -32,768.
Example:
DEFINT A-Z
REM my data series has a minimum y-value of -32 and a maximum
REM y-value of 181, while the x-values range from -10 to 75
CALL ScreenMode(&H10) ' EGA 640x350 mode
CALL QWScreen ' coordinates relative
' to entire screen
CALL QWindow(-10, -32, 75, 181) ' user-defined graph coordinates
CALL QWLine(0, -32, 0, 181, 1) ' draw vertical axis
CALL QWLine(-10, 0, 75, 0, 1) ' draw horizontal axis
REM put dots on the screen for a X vs. Y chart
FOR i = 0 to 100
CALL QWPutDot(x%(i), y%(i), style%)
NEXT i
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Subroutine: QWScreen
Subroutine: QWView
object file: qwindow.obj ($graph.obj)
These subroutines allow you to define your coordinate system
relative to the entire screen (QWScreen) or relative to QLIB's active
View area.
Example:
DEFINT A-Z
REM I want to use 90% of the screen dimensions for a plot with
REM coordinates from -100 to +100
REM start with View equal to entire screen area
CALL ResetView
REM next, define the coordinate system, relative to entire screen
CALL QWindow(-100, -100, 100, 100)
CALL QWScreen
REM now get the absolute coordinates for 90% of the screen dimensions
x0% = -90: y0% = -90
x1% = 90: y0% = 90
CALL QW2Abs(x0%, y0%) ' convert first coordinate
CALL QW2Abs(x1%, y1%) ' convert second coordinate
REM use absolute coordinates to set QLIB view area
CALL SetView(x0%, y0%, x1%, y1%)
REM make QWindow coordinates relative to active view area
CALL QWView
REM ready to go!
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
QWindow subroutines, the comparable QLIB subroutine and QWindow
object files are listed below:
QWindow subroutine QLIB subroutine object file
QWLine DrawLine qwline.obj
QWBox DrawBox qwline.obj
QWFillBox FillBox qwline.obj
QWFill FillArea qwfill.obj
QWGCenter GCenter qwcenter.obj
QWGCenterX GCenterX qwcentrx.obj
QWCircle DrawCircle qwcircle.obj
QWGLineEdit GLineEdit qwgedit.obj
QWGPrint GPrint qwgprint.obj
QWGPrintUP GPrintUP qwgprint.obj
QWGPrintDOWN GPrintDOWN qwgprint.obj
QWBitBlockBytes BitBlockBytes qwblock.obj
QWBitBlockSave BitBlockSave qwblock.obj
QWBitBlockRestore BitBlockRestore qwblock.obj
QWBitPlaneBytes BitPlaneBytes qwplane.obj
QWBitPlaneSave BitPlaneSave qwplane.obj
QWBitPlaneRestore BitPlaneRestore qwplane.obj
QWGetDot GetDot qwgetdot.obj
QWPutDot PutDot qwputdot.obj
QWGPrintX GPrintX qwprintx.obj
QWGPrint2X GPrint2X qwprintx.obj
QWGPrintUPX GPrintUPX qwprintx.obj
QWGPrintDOWNX GPrintDOWNX qwprintx.obj
QWGPrintUP2X GPrintUP2X qwprintx.obj
QWGPrintDOWN2X GPrintDOWN2X qwprintx.obj
QWGCursor GCursor qwcursor.obj
QWGUCursor GUCursor qwcursor.obj
In all cases, QWindow subroutines are called from your BASIC program
with the same parameters, except that screen coordinates are QWindow
coordinates instead of QLIB's native absolute pixel locations.