📄 hsa_graf.doc
字号:
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
H S A _ G R A F
H S A _ G R A F
Multi-Adapter Graphics Library for C
by
Hardwood Software Associates
13-Jul-87 Page 1
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
Hardwood Software Associates
____________________________
HSA_GRAF is copyrighted by Hardwood Software Associates. You are granted
a limited license to use HSA_GRAF. You may also copy and distribute it,
provided that the following conditions are met:
1. No fee may be charged for such copying and distribution.
2. HSA_GRAF may ONLY be distributed in its original, unmodified state.
Any voluntary contributions for the use of this program will be
appreciated, and should be sent to:
Hardwood Software Associates
364 Benson Road
Northbridge, Ma 01534
A contribution of $15 will require that you accept a floppy disk
containing the source code for HSA_GRAF.
The author, Richard "Spike" Evans may be reached on CompuServe at
[75026,3604].
All comments and suggestions are welcome. We love to get mail.
Please be advised that all the usual non-warranty warranties apply to
HSA_GRAF. Hardwood Software Associates does not guarantee that HSA_GRAF
will do any thing useful at all; although it has for us. Nor does
Hardwood Software Associates warrant that HSA_GRAF will not do anything
harmful; although it has not for us.
Trademarks
__________
Hercules Graphics Crad is a trademark of Hercules Computer Technology
IBM P.C. is a trademark of International Business Machines
Lattice is a trademark of Lattice, Inc.
Microsoft C is a trademark of Microsoft Corporation
13-Jul-87 Page 2
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
INTRODUCTION
____________
HSA_GRAF is a library of C functions that provide direct, fast ability to
create graphics on any one of the three major graphics boards available
for the IBM P.C. (Color Graphics Adapter (CGA), Enhanced Graphics Adapter
(EGA), and the Hercules Graphics Board). A single setup call establishes
the board in use, all functions used to create the actual graphics are
device independent. The functions have been developed and tested for
the Microsoft versions 3.00 and 4.00 and Lattice version 3.10
compilers. This library has two divisions. All basic graphics functions
begin with the prefix "gr_". The other division, prefixed with "gs_"
allows for creating scaled graphics. These modules are:
GR_STAT - Status functions
GR_STR - String display functions
GR_FILL - Area fill functions
GR_MISC - Miscellaneous functions
GR_ATTR - Functions to control screen attributes
GR_DRAW - Functions to draw points and lines
GR_SCALE - Function to perform screen scaling
GR_ARC - Functions to draw arcs and circles
GR_EGA - EGA support functions
GR_HERC - Hercules support functions
GR_GETS - Graphics get a string function
This distribution contains two object library files:
S_MS_HSA.LIB - Small memory model library (Microsoft)
S_LC_HSA.LIB - Small memory model library (Lattice)
13-Jul-87 Page 3
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
GENERAL
_______
The "gr" functions are a set of low level functions that get you fast
efficient control of the text screen. These functions keep track of two
next sequential screen locations (x and y); one for lines and points,
the other for string display. These locations are referred to as the
current location.
The X axis is the horizontal axis, with 0 at the left, positive direction
to the right. The Y axis is the vertical axis with 0 optionally at the
top or the bottom, positive direction down or up. The X and Y coordinates
passed to all functions are 0 based. If the X or Y coordinate passed to
any function is equal to -1 the current X or Y location coordinate is
used.
The header file hsa_gr.h defines all functions included in the HSA_GRAF
function library. Also included in hsa_gr.h are several useful
constants, macros, and structures.
The current implementation supports the following graphics modes:
Hercules Monochrome (720x348)
CGA - two color (640x200)
EGA - 16 color (640x350)
AT&T - two color (640x400)
Refer to MSC_DEMO.BAT and LC_DEMO.BAT for information on how to compile
and link for the Microsoft and Lattice compilers.
13-Jul-87 Page 4
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
GR_STAT - Status Functions
__________________________
NAME: G_STATE - Returns current video state
G_STATE
SYNOPSIS: g_state ();
DESCRIPTION: Calls BIOS INT 10 with function code 15 to get
current video state.
RETURNS: Text modes:
0 = 40x25 Black and white
1 = 40x25 Color
2 = 80x25 Black and white
3 = 80x25 Color
Graphics modes:
4 = 320x200 Color
5 = 320x200 Black and white
6 = 640x200 Black and white
7 = Monochrome
D = 320x200 on color monitor (EGA)
E = 640x200 (EGA)
F = 640x350 on monochrome (EGA)
10 = 640x350 on EGA monitor (EGA)
64 = 640x400 Black and white (AT&T)
CAUTIONS: Mode must be 7 for Hercules graphics routines
NAME: G_HERC - Use Hercules monochrome graphics board
G_HERC
SYNOPSIS: g_herc ();
DESCRIPTION: Use the Hercules monochrome graphics board. This is
the default mode.
NAME: G_CGA_HR - Use IBM CGA in high resolution (640x200)
G_CGA_HR
mode
SYNOPSIS: g_cga_hr ();
DESCRIPTION: Use the IBM color graphics adapter in high
resolution mode.
NAME: G_EGA_HR_CO - Use IBM EGA in high resolution
G_EGA_HR_CO
(640x350) mode
SYNOPSIS: g_ega_hr_co ();
DESCRIPTION: Use the IBM EGA in high resolution (640x350) color
mode.
NAME: G_OTHER - Use another variety of graphics adapter
G_OTHER
SYNOPSIS: g_other (X,Y,interlace,segment,mode);
int x,y; Number of pixels in each
direction
int interlace; Interlace factor
(always a power of 2)
For example:
2 - IBM color (non interlaces
13-Jul-87 Page 5
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
200 rows)
4 - 400 rows interlaced (AT&T 64)
unsigned int segment; Segment for graphics memory
int mode; BIOS graphics mode to use
DESCRIPTION: CRT controller is another type. All mode switching
is done via BIOS calls.
NAME: G_DELAY - Set delay for screen switching
G_DELAY
SYNOPSIS: g_delay(delay);
int delay;
DESCRIPTION: Set the delay before turning screen on when
switching between graphics and text modes on
Hercules boards. In order to prevent screen jump,
and sometimes garbage appearing on the screen, it is
necessary to delay for a while before turning on the
screen. The delay loop count is set by this
routine. The default delay loop is 7000.
CAUTIONS: Delays <=0 are ignored.
NAME: DISP_GRAPH - Set the display to graphics mode
DISP_GRAPH
SYNOPSIS: disp_graph ();
DESCRIPTION: The board is set to the graphics mode, displaying
the currently active graphics page. Before turning
on the screen a delay loop controlled by "g_delay"
is executed to prevent screen bounce. If not in the
Hercules mode the BIOS equipment flag is retrieved
and saved before switching it to the color crt mode.
RETURNS: 0 - All OK
1 - Error (not in video mode 7 for Hercules)
NAME: DISP_TEXT - Set the board to the text mode
DISP_TEXT
SYNOPSIS: disp_text(mode);
int mode; Text mode to use (non
Hercules only)
For IBM: 0 thru 3 OK
DESCRIPTION: The board is set to the text mode. Before turning
on the screen a delay loop controlled by "g_delay"
is executed to prevent screen bounce. If in the
BIOS mode the old equipment flag is restored.
NAME: G_LOC - Return current location
G_LOC
SYNOPSIS: g_loc (x,y);
int *x; X coordinate
(0 <= x <= max X)
int *y; Y coordinate
(0 <= y <= max Y)
DESCRIPTION: Return the location of the current point unscaled.
NAME: G_R_ORIGIN - Return the current origin location
G_R_ORIGIN
SYNOPSIS: g_r_origin();
DESCRIPTION: Return the current origin location.
RETURNS: 0 - Upper left corner of screen
13-Jul-87 Page 6
Hardwood Software Associates
HSA_GRAF - Screen Graphics Library (V1.01)
HSA_GRAF - Screen Graphics Library (V1.01)
1 - Lower left corner of screen
NAME: G_R_POINT - Return the color of the specified point
G_R_POINT
SYNOPSIS: g_r_point(x,y);
int x; X coordinate
(0 <= x <= max X)
int y; Y coordinate
(0 <= y <= max Y)
DESCRIPTION: Return the color of the specified point.
RETURNS: The color of the specified point.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -