home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
287_01
/
gradprog.doc
< prev
next >
Wrap
Text File
|
1989-05-25
|
32KB
|
1,233 lines
GRAD Programmers' Reference Manual
Table Of Content
1 Introduction . . . . . . . . . . . . . . . . . . . . . . 1
2 Basic Philosophy . . . . . . . . . . . . . . . . . . . . 2
3 calcaddr and plottype . . . . . . . . . . . . . . . . . 3
3.1 calcaddr . . . . . . . . . . . . . . . . . . . . . . 3
3.2 plottype . . . . . . . . . . . . . . . . . . . . . . 3
4 Frame Table . . . . . . . . . . . . . . . . . . . . . . 4
5 Font Table . . . . . . . . . . . . . . . . . . . . . . . 5
6 HorzLine, VertLine and Line . . . . . . . . . . . . . . 6
6.1 HorzLine . . . . . . . . . . . . . . . . . . . . . . 6
6.2 VertLine . . . . . . . . . . . . . . . . . . . . . . 6
6.3 Line . . . . . . . . . . . . . . . . . . . . . . . . 7
7 Circle, Ellipse and Arc . . . . . . . . . . . . . . . . 9
7.1 Circle . . . . . . . . . . . . . . . . . . . . . . . 9
7.2 Ellipse . . . . . . . . . . . . . . . . . . . . . . 10
7.3 Arc . . . . . . . . . . . . . . . . . . . . . . . . 11
8 Text Writing . . . . . . . . . . . . . . . . . . . . . . 12
9 Region Filling . . . . . . . . . . . . . . . . . . . . . 13
10 Block Copy, Save and Load . . . . . . . . . . . . . . . 15
11 Writing Graphics Display Adapter Driver . . . . . . . . 16
12 Writing Printer Driver . . . . . . . . . . . . . . . . . 17
13 Hints on Porting to Other C Compiler or Other Machine . 18
GRAD Programmers' Reference Manual
1 Introduction
The source code of the GRAD library are coyrighted. However
you are free to modify and re-distribute the source files for
non-commerical use and you indiciate the files are originated
from the GRAD library.
If you find and bugs in the GRAD routines, please inform me.
Your help will be appreciated.
1
GRAD Programmers' Reference Manual
2 Basic Philosophy
The idea of GRAD system come to me about 1 year ago (1986
summer). At that time, I want to write a program that can produce
high quality, high speed full page text and graphics print out
suitable for report on a dot matrix printer.
In order to produce high quality text output, bit mapped
character must be able to be loaded and included in the print out
as graphics data. However printing a full page of bit mapped
graphics data on a dot matrix printer may take 5 to 15 minutes.
So all normal text should be printed in NLQ text mode of the
printer instead of in graphics mode.
Furthermore 2 types of graphics data may be included in the
print out. First type is that the graphics data are already in
bit mapped format. Another type is that the graphics data are in
high level command format such as circles, lines and dots. The
advantages of second type are that the graphics data file size is
relatively small unless the drawing is very complicated. Further-
more and the drawings may be changed easily.
Very quickly, I realized that this program is not that
simple. As the first phase of implementation, a graphics library
is written which is the GRAD system. The sample program MPrint is
a simplified version of my original idea.
In GRAD, you may divide the routines into different layers.
Layer 0 contains routines that directly deal with the hardware
(including memory). Hence layer 0 routines are hardware
dependent. The number of routines in this layer is kept to a
minimum. Layer 1 routines accepts physical coordinates as
parameters. No external GRAD functions are in this layer. Most of
this routines are written in assembly language. GRAD functions
usually spend most of them in this layer of codes. Layer 2
routines handles translation of logical coordinates to physical
coordinates and also clipping of drawings under current defined
window. Most of these routines are written in C. Most of the
layer 2 routines call layer 1 routines to do actual drawings.
However there are some exception cases that layer 2 routines call
layer 0 routines directly. But none of the routines in layer 1
and layer 2 access hardware directly.
There are also some functions that do not requires any
coordinates in the parameter such as PlotType and ResetWin. They
are called system functions and do not belong to any one of the
above layers.
2
GRAD Programmers' Reference Manual
3 calcaddr and plottype
3.1 calcaddr
$calc and downln are the two main routines in the module
calcaddr. There are also some hardware dependent routines such as
settext and setgraph but they would not be discussed in this
manual.
$calc accepts x and y coordinates in register AX and BX.
Segment and offset values are returned in AX and BX respectively.
The return address a far address that means the segment value
should not be changed because the segment value may be a logical
number only and not a actual segment number. The offset value
must be a even number and it must be set up in such a way that
the whole line containing the point x,y can be accessed by
changing the offset value only.
downln accepts the address of a frame in ES:BX and return
the address of the next line with the same number of words from
the beginning of the line. This is used to speed up drawings in
vertical direction such as VertLine.
3.2 plottype
The module plottype contain routines that access the frame
memory using the address returned by $calc and downln. There is
nothing fancy so the comment in the module should be sufficient.
3
GRAD Programmers' Reference Manual
4 Frame Table
In the frame table, it contains all information about a
frame. Information include starting address of the frame, frame
width in byte, horizontal and vertical size, logical origin and
the window defined in that frame.
The number of entries in frame table controls the maximum
number of frame that can be existed in GRAD system. The number of
entry in the frame table is control by the value NFRAME during
compilation time. The default value of NFRAME is 10.
The structure of the frame table may be changed in future
version. So do not make any assumption about the relative order
of the variables inside the structure in your routines.