home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MS DOS Archives 1
/
MS-DOS_Archives_Volume_One_Walnut_Creek.iso
/
msdos
/
graphics
/
hgrph101.arc
/
HGRAPH.EPS
< prev
next >
Wrap
Text File
|
1989-02-25
|
76KB
|
2,245 lines
HGRAPH.LIB V1.01 HGRAPH.LIB
HGRAPH.LIB is a collection of subroutines to give Hercules HGRAPH.LIB
graphics capability to MSC and QuickC and are better than MSC's &
QuickC's in that they just have to be linked in. They do not
require a driver to be loaded like with MSC & QC.
This is version 1.01 release of these routines. They have
been compiled and tested only on a Leading Edge Model "D" which
has a hercules clone card in it. The only known difference
between this clone card and a real Hercules card is that this
clone fakes the light pen port (if you try to read its lightpen
port for the graphics state it always returns text mode).
INTRODUCTION INTRODUCTION
The lib includes clearing and non-clearing subroutines to
switch between text and graphics modes. A clear page and show
page for clearing and switching between the two graphics pages.
A pixel routine to read, write, and toggle a pixel. Two line
subroutines one to draw a line in either white or black and one
to toggle a line. And three string writing functions, one that
treats the graphics screen as 43 rows and 90 columns while the
other two let you define the upper left corner of where the
string is to be written. There are also a save screen and a
restore screen, similar to BASIC's BSAVE & BLOAD and a print
screen routine for Epson printers. All the routines that write
to the graphics screen are written in MSC MASM 5.1 for greater
speed. The screen dump routines do their own buffering also for
this reason.
USAGE USAGE
There is now a XHGRAPH.LIB library for each memory model, XHGRAPH.LIB _
where X is the model (S, M, C, L). So you must link with the X S M C L _
library of the same type model as the program was compiled with.
The only restriction in using the libraries is that You must call
hgraph_init() before using any of the other routines. hgraph_init()
i
HGRAPH.LIB V1.01 HGRAPH.LIB
The rest of the documentation is a list of library routines
and what they do. The appendix holds a couple of examples and a
few programing tips. The libraries are release into the public
domain with the following restrictions:
1) That they only be transmitted from one person to
the next in a complete and unmodified form.
2) That the libraries, documentation, and algorithms
remain copy righted to me, Steven P. Murphy.
3) No warranties are expressed or implied. I am not
responsible for the use, misuse, or abuse of these
libraries.
Any comments, suggestions, or bugs should be reported to:
Steven P. Murphy
6581 Bing St.
San Diego, CA 92115-6715
or
murphys@cod.nosc.mil (USENET)
And for those you who really like HGRAPH donations will not
be refused.
ii
HGRAPH.LIB V1.01 HGRAPH.LIB
All the routines treat the graphics screen as a grid of dots
except hwrite and hstr which treat it as a set of rows and ______ ____
columns. For all the routines except hwrite and hstr the screen ______ ____
dimension are as follows:
0 719
0 -----------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
347 -----------------------------------------------
for hwrite and hstr the screen is: ______ ____
0 89
0 -----------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
42 -----------------------------------------------
The conversion from rows & columns to dots is each row is eight
dots height and each column is eight dots wide.
iii
HGRAPH.LIB V1.01 HGRAPH.LIB
TABLE OF CONTENTS TABLE OF CONTENTS
h_get_scrn . . . . . . . . . . . . . . . . . . 1
h_sav_scrn . . . . . . . . . . . . . . . . . . 2
hbox . . . . . . . . . . . . . . . . . . 3
hchar . . . . . . . . . . . . . . . . . . 4
hchar2 . . . . . . . . . . . . . . . . . . 5
hclearpg . . . . . . . . . . . . . . . . . . 6
hellipse . . . . . . . . . . . . . . . . . . 7
herc_there . . . . . . . . . . . . . . . . . . 8
hgmode . . . . . . . . . . . . . . . . . . 9
hgmode_nc . . . . . . . . . . . . . . . . . . 10
hgraph_init . . . . . . . . . . . . . . . . . . 11
hline . . . . . . . . . . . . . . . . . . 12
hpixel . . . . . . . . . . . . . . . . . . 13
hscdump . . . . . . . . . . . . . . . . . . 14
hscdump2 . . . . . . . . . . . . . . . . . . 15
hshowpg . . . . . . . . . . . . . . . . . . 16
hstr . . . . . . . . . . . . . . . . . . 17
htmode . . . . . . . . . . . . . . . . . . 18
htmode_nc . . . . . . . . . . . . . . . . . . 19
hwrite . . . . . . . . . . . . . . . . . . 20
hxchar . . . . . . . . . . . . . . . . . . 21
hxchar2 . . . . . . . . . . . . . . . . . . 22
hxline . . . . . . . . . . . . . . . . . . 23
hxstr . . . . . . . . . . . . . . . . . . 24
Appendix A . . . . . . . . . . . . . . . . . . 25
cornucopia.c . . . . . . . . . . . . . . . . 26
demo1.c . . . . . . . . . . . . . . . . 27
Appendix B . . . . . . . . . . . . . . . . . . 28
programing ideas . . . . . . . . . . . . . . 29
iv
HGRAPH.LIB V1.01 HGRAPH.LIB
H_GET_SCRN H_GET_SCRN
Summary _______
#include <hgraph.h> Contains function prototypes
int h_get_scrn(file_name); h_get_scrn _________
char *file_name /* name of file to get the */ _________
/* image from */
Description ___________
Opens file_name for reading in binary mode and copies _________
32K bytes from file_name to graphics page 0 or 1 _________
according to the current value of HGPAGE (see HGPAGE
hgraph_init).
Return Value ____________
H_get_scrn returns a -1 if it could not successfully H_get_scrn
open file_name other wise it will return a 0. _________
See Also ________
h_sav_scrn
1
HGRAPH.LIB V1.01 HGRAPH.LIB
H_SAV_SCRN H_SAV_SCRN
Summary _______
#include <hgraph.h> Contains function prototypes
int h_sav_scrn(file_name); h_sav_scrn _________
char *file_name /* name of file to store */ _________
/* image in */
Description ___________
Opens file_name for writing in binary mode and copies _________
32K bytes from graphics page 0 or 1 according to the
current value of HGPAGE (see hgraph_init). HGPAGE
Return Value ____________
H_sav_scrn returns a -1 if it could not successfully H_sav_scrn
open file_name other wise it will return a 0. _________
See Also ________
h_get_scrn
2
HGRAPH.LIB V1.01 HGRAPH.LIB
HBOX HBOX
Summary _______
#include <hgraph.h> Contains function prototypes
void hbox(color, trow, lcol, brow, rcol); hbox _____ ____ ____ ____ ____
int color; /* should only be a 1 or 0 */ _____
int trow; /* toprow 0 through 347 */ ____
int lcol; /* left column 0 through 718 */ ____
int brow; /* bottom row 1 through 348 */ ____
int rcol; /* right column 1 through 719 */ ____
Description ___________
Draws a box on page 0 or 1 according to the current
value of HGPAGE (see hgraph_init). Hbox calls hline HGPAGE Hbox hline
four time arranging the arguments each time so that a
box is drawn where (trow, lcol) defines the upper left ____ ____
corner and (brow, rcol) is the lower right. Hbox does Hbox ____ ____
no bounds checking so bad ranges will produce weird
results.
Return Value ____________
There is no return value.
See Also ________
hline
3
HGRAPH.LIB V1.01 HGRAPH.LIB
HCHAR HCHAR
Summary _______
#include <hgraph.h> Contains function prototypes
void hchar(x, y, string, attrib, count); hchar _ _ ______ ______ _____
int x; /* 0 through 719 */ _
int y; /* 0 through 347 */ _
char *string; /* ASCII 0 through 127 */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
Writes the upper left most corner of the string pointed
to by string at the coordinates given after each ______
character has been XORed with attrib. Hchar writes to Hchar ______
the graphics page according to the current value of
HGPAGE (see hgraph_init). There is no bounds checking HGPAGE
done on x and y so numbers outside of range will give _ _
unknown results (probably not good). Hchar uses the Hchar
IBM PC/XT/AT ROM character table. This table only has
ASCII characters 0 through 127, values outside this
range will give garbage. The attrib is xor with the ______
character's bits on each scan line, values other than
HGNORM (normal) and HGINVS (inverse) will just produce HGNORM HGINVS
odd patterns. Count tells hchar how many of string's hchar _____ ______
characters to plot. MSC regular run-time LIB has a
functions strlen() and gcvt(), strlen() will produce a
correct count and gcvt() will convert numbers to a _____
string.
Return Value ____________
There is no return value.
See Also ________
hchar2, hstr, hwrite, hxchar, hxchar2, hxstr
MSC's or QuickC's strlen() and gcvt()
4
HGRAPH.LIB V1.01 HGRAPH.LIB
HCHAR2 HCHAR2
Summary _______
#include <hgraph.h> Contains function prototypes
void hchar2(x, y, string, attrib, count); hchar2 _ _ ______ ______ _____
int x; /* 0 through 719 */ _
int y; /* 0 through 347 */ _
char *string; /* ASCII 0 through 127 */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
Writes the upper left most corner of the string pointed
to by string at the coordinates given after each ______
character has been XORed with attrib. Hchar2 writes to Hchar2 ______
the graphics page according to the current value of
HGPAGE (see hgraph_init). There is no bounds checking HGPAGE
done on x and y so numbers outside of range will give _ _
unknown results (probably not good). Hchar2's Hchar2
character table only has ASCII characters 0 through
127, values outside this range will give garbage. The
attrib is xor with the character's bits on each scan ______
line, values other than HGNORM (normal) and HGINVS HGNORM HGINVS
(inverse) will just produce odd patterns. Count tells _____
hchar2 how many of string's characters to plot. MSC hchar2 ______
regular run-time LIB has a functions strlen() and
gcvt(), strlen() will produce a correct count and _____
gcvt() will convert numbers to a string.
Return Value ____________
There is no return value.
See Also ________
hchar, hstr, hwrite, hxchar, hxchar2, hxstr
MSC's or QuickC's strlen() and gcvt()
5
HGRAPH.LIB V1.01 HGRAPH.LIB
HCLEARPG HCLEARPG
Summary _______
#include <hgraph.h> Contains function prototypes
void hclearpg(void); hclearpg
Description ___________
Clears graphics page 0 or 1 according to the current
value of HGPAGE (see hgraph_init). HGPAGE
Return Value ____________
There is no return value.
See Also ________
hgmode, hgmode_nc
6
HGRAPH.LIB V1.01 HGRAPH.LIB
HELLIPSE HELLIPSE
Summary _______
#include <hgraph.h> Contains function prototypes
void hellipse(color, x, y, r); hellipse
Description ___________
Draws and ellipse on graphics page 0 or 1 according to
the current value of HGPAGE (see hgraph_init) centered HGPAGE
at (x, y) with a radius of r. the ellipse will have an _ _ _
aspect ratio of the current value of (int) HGRATIO. If HGRATIO
the ratio is < 2 the major axis will be vertical, if it
is > 2 the major axis will be horizontal, and if
HGRATIO = 2 hellipse will produces the closes it can to HGRATIO hellipse
a circle. no bounds checking is done if any part of
the ellipse is off the screen weird things may happen.
Return Value ____________
There is no return value
See Also ________
7
HGRAPH.LIB V1.01 HGRAPH.LIB
HERC_THERE HERC_THERE
Summary _______
#include <hgraph.h> Contains function prototypes
int herc_there(void); herc_there
Description ___________
First it tests for a mono display adapter, if there is
one it then watches port 3BA (hex) for a fixed time to
see if bit 7 goes high. If bit 7 does go high it then
pushes a 3 out port 3BF (hex) to turn on the second
page of the herc card. Now it checks for memory in the
second page. If this check is good it's a herc other
wise it's just a funny mono card. Before it returns it
pushes a 0 out port 3BF to return a herc card to
diagonal mode.
Return Value ____________
Herc_there returns a one if both of the above test are Herc_there
true and a zero if either is false. (I have tested
this with my clone card, an EGA, a CGA, and a mono
adapter, it worked correctly in all cases.)
See Also ________
8
HGRAPH.LIB V1.01 HGRAPH.LIB
HGMODE HGMODE
Summary _______
#include <hgraph.h> Contains function prototypes
void hgmode(void); hgmode
Description ___________
Sets graphics mode, clears graphic pages 0 and 1 then
switches to graphics page 0.
Return Value ____________
There is no return value.
See Also ________
hgmode_nc
9
HGRAPH.LIB V1.01 HGRAPH.LIB
HGMODE_NC HGMODE_NC
Summary _______
#include <hgraph.h> Contains function prototypes
void hgmode_nc(void); hgmode_nc
Description ___________
Sets graphics mode, does not clears graphic pages 0 and ________
1 then switches to graphics page 0.
Return Value ____________
There is no return value.
See Also ________
hgmode
10
HGRAPH.LIB V1.01 HGRAPH.LIB
HGRAPH_INIT HGRAPH_INIT
Summary _______
#include <hgraph.h> Contains function prototypes
void hgraph_init(void); hgraph_init
Description ___________
Initializes the necessary global variables for
HGRAPH.LIB. These variables are:
int HGPAGE; /* current graphics page, used by all */ HGPAGE ___
/* the library routines */
char HGATRB; /* character attribute for hwrite */ HGATRB hwrite
int HGRATIO; /* aspect ratio for hellipse */ HGRATIO hellipse
The initial values for are HGPAGE = 1, HGATRB = 0x00, HGPAGE HGATRB
and HGRATIO = 2. HGPAGE should only be 1 or 0 if it is HGRATIO HGPAGE
set to some value other than these two all the routine
will default it to 1. HGATRB should only be HGNORM or HGATRB HGNORM
HGINVS (defined in hgraph.h) other values will just HGINVS
cause the print to look funny. HGRATIO should be a HGRATIO
positive int, 0 will cause it to draw a horizontal
line, and a negative will hellipse to crash.
Return Value ____________
There is no return value.
See Also ________
11
HGRAPH.LIB V1.01 HGRAPH.LIB
HLINE HLINE
Summary _______
#include <hgraph.h> Contains function prototypes
void hline(function, x0, y0, x1, y1); hline ________ __ __ __ __
int function; /* 0 - write pixels in black */ ________
/* 1 - write pixels in white */
int x0; /* 0 through 719 */ __
int y0; /* 0 through 347 */ __
int x1; /* 0 through 719 */ __
int y1; /* 0 through 347 */ __
Description ___________
The default for function is 1, so if hline is called hline ________
with function not equal to those listed you get ________
function 1. The graphics page is set according to the ________
current value of HGPAGE (see hgraph_init). There is no HGPAGE
bounds checking done on x0, x1, y0, or y1 so numbers __ __ __ __
outside of range will give unknown results (probably
not good).
Return Value ____________
There is no return value.
See Also ________
hxline
12
HGRAPH.LIB V1.01 HGRAPH.LIB
HPIXEL HPIXEL
Summary _______
#include <hgraph.h> Contains function prototypes
void hpixel(function, x, y); hpixel ________ _ _
int function; /* 0 - write pixel in black */ ________
/* 1 - write pixel in white */
/* 2 - toggle pixel */
/* 3 - read pixel */
int x; /* 0 through 719 */ _
int y; /* 0 through 347 */ _
Description ___________
The default for function is 2, so if hpixel is called hpixel ________
with function not equal to those listed you get ________
function 2. The pixel is plotted on the graphics page ________
according to the current value of HGPAGE (see HGPAGE
hgraph_init). There is no bounds checking done on x _
and y so numbers outside of range will give unknown _
results (probably not good).
Return Value ____________
The return value is the status the pixel was set to by
any of the four functions. So hpixel while always hpixel ________
return a 0 (for black) or a 1 (for white).
See Also ________
13
HGRAPH.LIB V1.01 HGRAPH.LIB
HSCDUMP HSCDUMP
Summary _______
#include <hgraph.h> Contains function prototypes
void hscdump(void); hscdump
Description ___________
Dumps graphics page 0 or 1, according to the current
value of HGPAGE (see hgraph_init), to an Epson or HGPAGE
compatible printer. Each line is double struck to
improve the clarity.
Return Value ____________
There is no return value.
See Also ________
hscdump2
14
HGRAPH.LIB V1.01 HGRAPH.LIB
HSCDUMP2 HSCDUMP2
Summary _______
#include <hgraph.h> Contains function prototypes
void hscdump2(void); hscdump2
Description ___________
Dumps graphics page 0 or 1, according to the current
value of HGPAGE (see hgraph_init), to an Epson or HGPAGE
compatible printer. Each line is only single struck to
improve the speed.
Return Value ____________
There is no return value.
See Also ________
hscdump
15
HGRAPH.LIB V1.01 HGRAPH.LIB
HSHOWPG HSHOWPG
Summary _______
#include <hgraph.h> Contains function prototypes
void hshowpg(void); hshowpg
Description ___________
Set graphics page 0 or 1, according to the current
value of HGPAGE (see hgraph_init), to the currently HGPAGE
displayed page.
Return Value ____________
There is no return value.
See Also ________
hgmode, hgmode_nc
16
HGRAPH.LIB V1.01 HGRAPH.LIB
HSTR HSTR
Summary _______
#include <hgraph.h> Contains function prototypes
void hstr(column, row, string, attrib, count); hstr ______ ___ ______ ______ _____
int column; /* 0 through 89 */ ______
int row; /* 0 through 42 */ ___
char *string; /* pointer to the string */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
Writes the string pointed to by string at the row and ______ ___
column given after each character has been XORed with ______
attrib. The graphics page written to is set according ______
to the current value of HGPAGE (see hgraph_init). HGPAGE
There is no bounds checking done on column and row so ______ ___
numbers outside of range will give unknown results
(probably not good). Hstr's character table only has Hstr
ASCII characters 0 through 127, values outside this
range will give garbage. The attrib is xor with the ______
character's bits on each scan line, values other than
HGNORM (normal) and HGINVS (inverse) will just produce HGNORM HGINVS
odd patterns. Count tells hstr how many of string's hstr _____ ______
characters to plot. MSC regular run-time LIB has a
functions strlen() and gcvt(), strlen() will produce a
correct count and gcvt() will convert numbers to a _____
string so they can be printed.
Return Value ____________
There is no return value.
See Also ________
hchar, hchar2, hwrite, hxchar, hxchar2, hxstr
MSC's or QuickC's strlen() and gcvt()
Note: _____
This is the fastest of hstr, hchar, and hchar2 for
writing strings because it operates on byte boundaries.
Only if you really need to write at a particular pixel
location should hchar or hchar2 be used and of these
two hchar2 is the better (only because its character
table is internal, the same as hstr, so it is
guaranteed to work on all machines).
17
HGRAPH.LIB V1.01 HGRAPH.LIB
HTMODE HTMODE
Summary _______
#include <hgraph.h> Contains function prototypes
void htmode(void); htmode
Description ___________
Sets text mode, clears graphic pages 0 and 1 then
switches to text page.
Return Value ____________
There is no return value.
See Also ________
htmode_nc
18
HGRAPH.LIB V1.01 HGRAPH.LIB
HTMODE_NC HTMODE_NC
Summary _______
#include <hgraph.h> Contains function prototypes
void htmode_nc(void); htmode_nc
Description ___________
Sets text mode, does not clears graphic pages 0 and 1 ________
then switches to text page.
Return Value ____________
There is no return value.
See Also ________
htmode
19
HGRAPH.LIB V1.01 HGRAPH.LIB
HWRITE HWRITE
Summary _______
#include <hgraph.h> Contains function prototypes
int hwrite(row, col, string); hwrite ___ ___ ______
int row; /* 0 through 42 */ ___
int col; /* 0 through 89 */ ___
char *string; /* pointer to the string */ ______
Description ___________
Write string starting at (row, col) using the attribute ______ ___ ___
value of HGATRB (see hgraph_init). The string is HGATRB
written to the graphics page set according to the
current value of HGPAGE (see hgraph_init). Hwrite HGPAGE Hwrite
checks for bounds on both row and col, if the start of ___ ___
the string is not on the screen the string will not be
written. If the string runs off the right edge it will
just be truncated to avoid errors. MSC regular run-
time LIB has a function gcvt() which will convert
numbers to a string so they can be printed.
Return Value ____________
Hwrite will return a 1 if it wrote any thing on the Hwrite
screen (truncated or not) or a 0 if (row, col) was off ___ ___
the screen (nothing written).
See Also ________
hchar, hchar2, hstr, hxchar, hxchar2, hxstr
MSC's or QuickC's gcvt()
20
HGRAPH.LIB V1.01 HGRAPH.LIB
HXCHAR HXCHAR
Summary _______
#include <hgraph.h> Contains function prototypes
void hxchar(x, y, string, attrib, count); hxchar _ _ ______ ______ _____
int x; /* 0 through 719 */ _
int y; /* 0 through 347 */ _
char *string; /* ASCII 0 through 127 */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
XORs string starting at the upper left most corner of ______
the string pointed to by string at the coordinates ______
given after each character has been XORed with attrib. ______
Hxchar writes to the graphics page set by the current Hxchar
value of HGPAGE (see hgraph_init). There is no bounds HGPAGE
checking done on x and y so numbers outside of range _ _
will give unknown results (probably not good). Hxchar Hxchar
uses the IBM PC/XT/AT ROM character table. This table
only has ASCII characters 0 through 127, values outside
this range will give garbage. The attrib is xor with ______
the character's bits before it is xored to the screen,
values other than HGNORM (normal) and HGINVS (inverse) HGNORM HGINVS
for attrib will just produce odd patterns. Count tells ______ _____
hchar how many of string's characters to plot. MSC hchar ______
regular run-time LIB has a functions strlen() and
gcvt(), strlen() will produce a correct count and _____
gcvt() will convert numbers to a string.
Return Value ____________
There is no return value.
See Also ________
hchar, hchar2, hstr, hwrite, hxchar2, hxstr
MSC's or QuickC's strlen() and gcvt()
21
HGRAPH.LIB V1.01 HGRAPH.LIB
HXCHAR2 HXCHAR2
Summary _______
#include <hgraph.h> Contains function prototypes
void hxchar2(x, y, string, attrib, count); hxchar2 _ _ ______ ______ _____
int x; /* 0 through 719 */ _
int y; /* 0 through 347 */ _
char *string; /* ASCII 0 through 127 */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
XORs string starting at the upper left most corner of ______
the string pointed to by string at the coordinates ______
given after each character has been XORed with attrib. ______
Hxchar2 writes to the graphics page according to the Hxchar2
current value of HGPAGE (see hgraph_init). There is no HGPAGE
bounds checking done on x and y so numbers outside of _ _
range will give unknown results (probably not good).
Hxchar2's character table only has ASCII characters 0 Hxchar2
through 127, values outside this range will give
garbage. The attrib is xor with the character's bits ______
before it is xored to the screen, values other than
HGNORM (normal) and HGINVS (inverse) for attrib will HGNORM HGINVS ______
just produce odd patterns. Count tells hxchar2 how hxchar2 _____
many of string's characters to plot. MSC regular run- ______
time LIB has a functions strlen() and gcvt(), strlen()
will produce a correct count and gcvt() will convert _____
numbers to a string.
Return Value ____________
There is no return value.
See Also ________
hchar, hchar2, hstr, hwrite, hxchar, hxstr
MSC's or QuickC's strlen() and gcvt()
22
HGRAPH.LIB V1.01 HGRAPH.LIB
HXLINE HXLINE
Summary _______
#include <hgraph.h> Contains function prototypes
void hxline(x0, y0, x1, y1); hxline __ __ __ __
int x0; /* 0 through 719 */ __
int y0; /* 0 through 347 */ __
int x1; /* 0 through 719 */ __
int y1; /* 0 through 347 */ __
Description ___________
Toggles the status of all the pixels along the given
line. The graphics page is set according to the
current value of HGPAGE (see hgraph_init). There is no HGPAGE
bounds checking done on x0, x1, y0, or y1 so numbers __ __ __ __
outside of range will give unknown results (probably
not good).
Return Value ____________
There is no return value.
See Also ________
hline
23
HGRAPH.LIB V1.01 HGRAPH.LIB
HXSTR HXSTR
Summary _______
#include <hgraph.h> Contains function prototypes
void hxstr(column, row, string, attrib, count); hxstr ______ ___ ______ ______ _____
int column; /* 0 through 89 */ ______
int row; /* 0 through 42 */ ___
char *string; /* pointer to the string */ ______
char attrib; /* HGNORM or HGINVS */ HGNORM HGINVS ______
int count; /* number of chars in string */ _____ ______
Description ___________
XORs the string pointed to by string at the row and ______ ___
column given after each character has been XORed with ______
attrib. The graphics page written to is set according ______
to the current value of HGPAGE (see hgraph_init). HGPAGE
There is no bounds checking done on column and row so ______ ___
numbers outside of range will give unknown results
(probably not good). Hstr's character table only has Hstr
ASCII characters 0 through 127, values outside this
range will give garbage. The attrib is xor with the ______
character's bits before it is xored to the screen,
values other than HGNORM (normal) and HGINVS (inverse) HGNORM HGINVS
will just produce odd patterns. Count tells hstr how hstr _____
many of string's characters to plot. MSC regular run- ______
time LIB has a functions strlen() and gcvt(), strlen()
will produce a correct count and gcvt() will convert _____
numbers to a string so they can be printed.
Return Value ____________
There is no return value.
See Also ________
hchar, hchar2, hstr, hwrite, hxchar, hxchar2
MSC's or QuickC's strlen() and gcvt()
Note: _____
This is the fastest of hxstr, hxchar, and hxchar2 for
writing strings because it operates on byte boundaries.
Only if you really need to write at a particular pixel
location should hxchar or hxchar2 be used and of these
two hxchar2 is the better (only because its character
table is internal, the same as hxstr, so it is
guaranteed to work on all machines).
24
HGRAPH.LIB V1.01 HGRAPH.LIB
Appendix A Appendix A
(examples)
25
HGRAPH.LIB V1.01 HGRAPH.LIB
/* CORNUCOPIA -- see article on "pseudo-hidden line removal" */
/* IBM-PC Exchange, May-June 1986 */
#include <math.h>
#include <conio.h>
#include <hgraph.h>
main()
{
int d, a0, b0, a1, b1, a, b;
double r, rada, radb;
hgraph_init();
hgmode_nc();
hclearpg();
hshowpg();
hstr(40, 1, " CORNUCOPIA ", 0xff, 12);
for (d = 1; d <= 100; ++d)
{
rada = (float)d;
radb = 0.65 * rada;
a0 = 20 + 4 * d;
b0 = 20 + 2 * d + (int)(radb * 0.6 * sin(d/10.0));
hline(0, a0, b0, a1 = a0, b1 = b0 + (int)radb);
for (r = 0.0; r < 6.3; r += 6.28/40.0)
{
a = a0 + (int)(rada * sin(r));
b = b0 + (int)(radb * cos(r));
hline(1, a1, b1, a, b);
hline(0, a0, b0, a1 = a, b1 = b);
}
}
/* This next section flips back and forth from
* text to graphics three time to show the use of the
* non-clearing hgmode_nc & htmode_nc the user must hit a
* key to cause the flip
*/
hstr(10, 40, "Press any key to continue ... ", 0x00, 30);
getch();
htmode_nc();
puts("Press any key to continue ... ");
getch();
hgmode_nc(); hshowpg();
getch();
htmode_nc();
getch();
hgmode_nc(); hshowpg();
getch();
htmode(); /* this will clear the text screen */
}
26
HGRAPH.LIB V1.01 HGRAPH.LIB
/* DEMO.C - a demo of hgraph.lib's string writing routines */
#include <string.h>
#include <conio.h>
#include <hgraph.h>
char string[40] = "HGRAPH.LIB";
main()
{
int ct;
char c;
ct = strlen(string);
hgraph_init();
hgmode_nc();
hclearpg();
hshowpg();
hstr(40, 1, string, HGINVS, ct);
hstr(20, 10,
"This is a demo of hstr, hchar, and hchar2", HGNORM, 41);
hstr(10, 20,
"This is a sample of hstr with normal attrib", HGNORM,43);
hstr(10, 21,
"This is a sample of hstr with inverse attrib", HGINVS,44);
hchar(80, 200,
"This is a sample of hchar with normal attrib", HGNORM,44);
hchar(80, 209,
"This is a sample of hchar with inverse attrib",HGINVS,45);
hchar2(80, 240,
"This is a sample of hchar2 with normal attrib",HGNORM,45);
hchar2(80, 249,
"This is a sample of hchar2 with inverse attrib",HGINVS,46);
hstr(10, 40,
"Press any key to continue ...", HGNORM, 29);
getch();
htmode_nc();
}
27
HGRAPH.LIB V1.01 HGRAPH.LIB
Appendix B Appendix B
(programing ideas)
28
HGRAPH.LIB V1.01 HGRAPH.LIB
There are three ways to do screen swapping with these
libraries to make it appear that you have a a full screen type
window package. I will start with the easiest and work up to
what I would consider the best. There is one thing to keep in
mind, the text screen uses the same memory as the first half of
graphics page 0. This fact must be consider when using
hgmode_nc() and htmode_nc() because if you have written stuff to
the text screen and then go to graphics page 0 there will be
garbage on the top half of the monitor. The same is true if you
do graphics on page 0 and switch to text with out clearing there
will be trash all over the text screen.
1) If you do all your graphics on page 1 (the
default) you could use C's standard functions (i.e
printf, puts, ...) to write to the text screen
(you don't have to leave graphics mode to do
this). This way you could have graphics displayed
and a help screen written to the text screen so if
the user hit F1 you could call htmode_nc() and the
help screen would appear, and then another key
would call hgmode_nc() and the graphics would
reappear. The only problem with this is a half to
three quarters of a second delay built into both
htmode_nc() and hgmode_nc() this will cause
approximately a one second delay in switching form
one screen to another.
2) There are two undocumented routines in hgraph.lib.
void h_scrn_in( unsigned char *)
void h_scrn_out( unsigned char *)
where unsigned char * is a pointer to a
buffer of at least 32768 bytes.
The first, h_scrn_in reads the screen defined by
HGPAGE and stores it into the buffer it was passed HGPAGE
as an argument. The second, h_scrn_out copies the
first 32767 bytes from the buffer it was passed as
an argument to the screen defined by HGPAGE. So HGPAGE
in the middle of doing graphics the user hits a
key for help, the program would use h_scrn_in to
save a copy of the current screen. Then it would
call hclearpg followed by hwrite to display help
messages. When the user wanted to switch back
just call h_scrn_out and rewrite the image back.
29
HGRAPH.LIB V1.01 HGRAPH.LIB
3) What I feel is the best is to use one graphics
page for graphics and one graphics page for help.
All that would have to be done is to reset HGPAGE HGPAGE
and then call hshowpg to swap between the two.
The code in the library to figure out which page
and to set it is only ten lines in assembly.
30