Dec 222017
 
Graphing routines for Turbo Pascal.
File XGRAPH.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Graphing routines for Turbo Pascal.
File Name File Size Zip Size Zip Type
DOALL.BAT 36 34 deflated
READ.ME 16135 4734 deflated
SMPLXGRF.COM 29683 17826 deflated
SMPLXGRF.PAS 30618 6983 deflated
WEAVER.COM 17319 11885 deflated
WEAVER.PAS 6283 2077 deflated
XGRAPH.EXE 12471 6806 deflated
XGRAPH.PAS 15319 4286 deflated
ZOO2.COM 21888 13642 deflated
ZOO2.PAS 16802 4401 deflated

Download File XGRAPH.ZIP Here

Contents of the READ.ME file


This file describes the other files present on the disk, the functions
supported by the XGRAPH routines (version 02.02) and the parameters needed
by each function.

The XGRAPH routines are a set of functions intended to work on all
IBM video adapters with graphics capabilities. Enough functions are provided
to effectively use the graphic capabilities of the video adapters. The video
adapters currently supported are IBM-CGA, IBM-EGA, and HP-Multimode. The
Hercules and other video adapters can also be used by modifying
the appropiate entries in the tables returned by the function VideoInit.


These routines are released for Non-Commercial use only and the author reserves
all commercial rights and uses. Any sugestions, questions or comments should be
send to the address below:

Abe Achkinazi
6211 Home ave
Bell, CA 90201

I am particularly interested in hearing about any bugs found, possible
extensions to support other video adapters (Hercules, ATT etc) and what other
functions should be implemented.

If you like these routines a donations of $10.00 will help the author to
continue supporting them.

-------------------------------------------------------------------------------

Files included in this release:

Read.me : This file.

Xgraph.exe: Executable file that installs the extended graphic routines.
It installs a stay resident program and takes about 13K of
RAM. The file must be executed only one time before any of the
example programs are executed.

Weaver.com: Example demostrating the rectangle filling capabilities.

Zoo2.com: Example of line drawing capabilities.

SmplXgrf.com: A simple user interface to the XGRAPH's routines. The program
can be used to play with the different built-in functions
without having to write a program.

Xgraph.pas: Include file for those programs written in Turbo-Pascal that
want to use the XGRAPH routines. This file is include in the
source programs below.

Weaver.pas: Source code for Weaver program above.

Zoo2.pas: Source code for Zoo2.com program above.

SmplXgrf.pas: Source code for SmplXgrf.com program above.

DoAll.bat: One batch file to install the XGRAPH functions and execute the
example programs in CGA mode 6. But try other modes on your own.

-------------------------------------------------------------------------------

Remember that XGRAPH.EXE stays around in memory after it is executed and looks
at all the INT 10H functions. If the function is one of those below it will be
handled by XGRAPH, otherwise it is passed to the normal INT 10H handler.

List of functions supported (ordered by function number in AH register and
called by issuing and INT 10H):

0A3H - VidID, returns major and minor version number of XGRAPH routines
installed.

0A4H - VidInit, figure out the raster type and return information
to caller. Initialize internal variables.

0A5H - VidClear, clear the graphics display.

0A6H - VidRectFill, fill rectangular area of the display with a pattern.

0A7H - VidLine, draws line of given pattern and color from
(x1,y1) to (x2,y2).

0A8H - VidPolyFill, draw and fill polygon defined by a set of
vertices.

0A9H - VidBlit, does bitblit from source to destination. Both source
and destination can be anywhere in memory.

0AAH thru 0B2H - Currently they do an immediate interrupt return when called.
Reserved for future use.


Description of Function Parameters:

-------------------------------------------------------------------------------
; VidID:
;
; Identifies the current version number of XGRAPH routines. It will always be
; a number between 01.00 and 99.99.
;
; Inputs - AH = 0A3H
;
; Outputs- BH = Major version number.
; BL = Minor version number.
;
; Registers Altered: BX
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
; VidInit:
;
; Looks at the current video mode and initializes internal variables. It
; returns to the user a pointer to the raster data found.
;
; Inputs - AH = 0A4H
;
; Outputs- ES:DI - Pointer to video description area see VidStruc data
; structure below.
;
; Registers Altered: ES, DI.
;
; Description of data structured returned in ES:DI (The values shown are
; in the case of IBM-CGA mode 4, 320x200 four colors:
;
; VidStruc struc
; GrfDestination dd 0B800:0H ; Address of graphic raster.
; GrfRasterWidth dw 80 ; Width of raster in bytes.
;
; GrfMinX dw 0 ; Next four words define the
; GrfMinY dw 0 ; size of raster in bits (Not Pixels!).
; GrfMaxX dw 639
; GrfMaxY dw 199
;
; GrfRowMask db 1 ; variables to handle raster interleave
; GrfShiftInterleave db 1
; GrfHomeOffset dw 2000H
; GrfBankOffset dw 2000H
;
; GrfPixelsPerByte db 2 ; Variable to handle more that a pixel
; ; per byte. Equals Log2(pixels per byte)
;
; GrfTextAddr dd ????:???? ; Address of Xgraph's built-in
; ; 16 patterns.
; GrfFontAddr dd ????:???? ; Address of Xgraph's built-in
; ; 8x8 font.
; GrfFont2Addr dd ????:???? ; Address of Xgraph's built-in
; ; 8x14 font.
; VidStruc ends
;
; Where:
;
; GrfFontAddr and GrfFont2Addr are pointers to the built-in character font
; descriptors and have the following format:
;
; FontStruc struc
; dd ????:???? ; Address of strike font rectangle
; dw 256 ; width of font in bytes
; dw 0 ; MinX
; dw 0 ; MinY
; dw 2047 ; MaxX
; dw 7 or 13 ; MaxY
; dw 8 ; Individual character width
; dw 8 or 14 ; Individual character height
; FontStruc ends
;
; See the procedure WriteChar in Xgraph.pas file for an example of how to
; write characters using built-in font and VidBitBlit.
;
; GrfTextAddr is a pointer to the built-in patterns. There are 16 patterns
; of sixteen words each stored in order. The following is a short description
; of them:
;
; 0) 1/2 Gray, every other dot on. 1) 2/4 Gray, every two dots on.
; 2) 4/8 Gray, every four dots on. 3) Left to right diagonal lines.
; 4) Right to left diagonal lines. 5) Horizontal lines.
; 6) Vertical lines. 7) Brocade 1.
; 8) Square weave. 9) Brocade 2.
; 10) Crosses and Naughts. 11) Triangular pattern.
; 12) Circular pattern. 13) Braides.
; 14) Fancy Bricks. 15) Wizards.
;
; Execute the Weaver.pas program to see patterns.
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
; VidClear:
;
; Clears the current video screen independant of adapter and mode. All the
; bits inside the rectangle (MinX,MinY) to (MaxX,MaxY) are set to 0. This
; function is faster than VidRectFill or VidBitBlit because it uses STOSW
; instruction.
;
; Inputs - AH = 0A5H
;
; Outputs- None
;
; Registers Altered: None
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
; VidRectFill:
;
; Fill a rectangular region (bit aligned) with the 16x16 pattern passed to the
; function. This function is faster than VidBitBlit because it uses the MOVSW
; instruction.
;
; Inputs - AH = 0A6H, VideoRectFill function
; AL = EGA Map Mask register value.
; CX = X pixel coordinate of upper left hand side.
; DX = Y pixel coordinate of upper left hand side.
; SI = X pixel coordinate of lower right hand side.
; DI = Y pixel coordinate of lower right hand side.
; ES:BX = Pointer to 16 word pattern to be used for filling.
;
; Registers Altered: None
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
; VideoLine:
;
; Draws a line from (x1,y1) to (x2,y2) using the given color and line pattern.
; No clipping is done.
;
; Inputs - AH = 0A7H, VidLine function
; AL = Color to draw line:
; Bit 0..2 Pattern select
; Bit 3..6 EGA Map Mask register values.
; Bit 7 =1 Xor mode, =0 Plot mode.
; CX = X1
; DX = Y1
; SI = X2
; DI = Y2
;
; Registers Altered: None
;
; Where:
;
; Pattern select (AL[0:2]) is used to select 1 out of 8 line patterns:
;
; 0) 1111111111111111 1) 1100110011001100 2) 1111000011110000
; 3) 0110011111100110 4) 0101010101010101 5) 1010101010101010
; 6) 1110111011101110 7) 0000000000000000
;
; EGA Color select (AL[3:6]) is used to select what color planes are enabled
; if the adapter is an EGA type. This value should be '1111' for all others.
;
; Xor mode (AL[7]) selects the type of operation to be performed when drawing
; the line. If this bit is zero the line pattern is or'ed to the screen. If bit
; if 1 the line pattern is xor'ed to with the screen.
;
; (X1,Y1) and (X2,Y2) are the starting and ending pixel coordinates of line.
; No clipping is done so both coordinates must be in the range (MinX,MinY) and
; (MaxX,MaxY) as returned in the VidStruc structure.
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
; VidPolyFill:
;
; If polygon fill is enabled fills the area bounded by the supplied vertices.
; And if border draw is enabled draws the set of lines between the vertices.
; No clipping is done.
;
; Inputs - AH = 0A8H, VidPolyLine function
; AL = Color to draw line (same definition as VideoLine):
; Bit 0..2 Pattern select
; Bit 3..6 EGA Map Mask register value when drawing lines.
; Bit 7 Xor mode.
; CL = EGA Map Mask register value used when filling.
; CH = PolyType:
; Bit 0: Polygon fill,
; 0 = Do not fill polygon.
; 1 = Fill polygon with supplied pattern and
; draw lines between vertices.
; Bit 1: Vertex data type,
; 0 = Each vertex is an absolute screen coordinate
; 1 = The first vertex is the location of polygon.
; Each vertex after that is relative to last
; point plotted.
; Bit 2: Border draw,
; 0 = Draw the polygon border after filling poly.
; 1 = Do not draw border.
; Bits 3 thru 7 are reserved and should be zero.
; DS:SI = Pointer to vertex list with the following format:
; word, word, word, word, word, ... word, word = 2*N + 1 words
; (N ), (X1), (Y1), (X2), (Y2), (Xn), (Yn)
;
; N = Total number of vertices in polygon (1 < N < 16383).
;
; Xi or Yi coordinates should be positive screen coordinates if
; in absolute mode (0 <= Xi <= 32767, 0 <= Yi <= 32767). Or
; a 16 bit 2's complement integer if the coordinate is relative.
; Remember that the first coordinate (X1, Y1) is always an
; absolute number since it gives the location of the polygon.
;
; Currently no clipping is performed on the vectors so be careful
; the polygon fits inside the screen.
;
; ES:BX = Pointer to user supplied polygon pattern.
;
; Registers Altered: None
-------------------------------------------------------------------------------


-------------------------------------------------------------------------------
; VidBlit:
;
; Perform a bitblit from the given source and texture to the destination
; rectangle with clipping. This function is slower than VidClear or VidRectFill
; because it uses the MOVSB instruction.
;
; Inputs - AH = 0A9H, VideoBlit function
; BL = EGA Map Mask Register value (0..16).
; BH = EGA Read Map Select register value (1..4).
; DS:SI = Pointer to blit parameter. See BlitParm structure.
;
; Registers Altered: None.
;
; Where:
;
; BX is only needed when using an EGA specific video mode. BL selects what
; EGA color planes will get data if the screen is the destination rectangle.
; BH selects what EGA plane will be read if the screen is the source rectangle.
; If nonEGA video mode BX should equal 010FH.
;
; DS:SI points to the following data structure:
;
; BlitParm struc
; Dest dd ? ; Address of destination raster structure.
; Source dd ? ; Address of source raster structure.
; Texture dd ? ; Address of 16 word pattern.
; RectOrigenX dw ? ; Origen of destination rectangle in
; RectOrigenY dw ? ; bit coordinates.
; RectCornerX dw ? ; Corner of destination rectangle in
; RectCornerY dw ? ; bit coordinates.
; PointX dw ? ; Position in source where the rectangle
; PointY dw ? ; will be moved from.
; Opcode dw ? ; Blit operation between source and destination.
; TextOp dw ? ; Texture operation between source and pattern.
; BlitParm ends
;
; The complete blit operation consists of three steps:
;
; 1) Clip source and destination rectangles.
;
; 2) Merge source and pattern based on the TextOp:
; 0) R= 0, 1) R= 1, 2) R= S, 3) R= P,
; 4) R= S or P, 5) R= S and P, 6) R= S xor P, 7) R= Not(P),
; 8) R= S or Not(P), 9) R= S and Not(P), 10) R= S xor Not(P),
; 11 thru 15) Not used.
;
; 3) Merge the result of step 2 with the destination rectangle base on the
; Opcode:
; 0) D= 0, 1) D= R and D, 2) D= R and Not(D), 3) D= R,
; 4) D= Not(R) and D, 5) D= D, 6) D= R xor D, 7) D= R or D,
; 8) D= Not(R) and Not(D), 9) D= Not(R) xor D,
; 10) D= Not(D), 11) D= R or Not(D), 12) Not(R),
; 13) D= Not(R) or D, 14) D= Not(R) or Not(D), 15) D= 1.
;
; The raster structures have the following data:
;
; Raster struc
; Address dd ? ; Address of the raster rectangle
; Width dw ? ; width in bytes of each row.
; OrigenX dw ? ; active rectangle within raster.
; OrigenY dw ? ; (OrigenX,OrigenY) is the upper left corner.
; CornerX dw ? ; (CornerX,CornerY) is the lower right corner.
; CornerY dw ?
; Raster ends
;
; Note that the first 7 words of the VidStruc structure is a raster structure
; for the whole video screen. This can be used to blit to/from the screen.
-------------------------------------------------------------------------------


 December 22, 2017  Add comments

Leave a Reply