home *** CD-ROM | disk | FTP | other *** search
-
- Graphics Routines
- Version 1.1.0
- 8/16/85
-
- By Michael A. Quinlan
-
-
- These routines provide simple graphics support for both the Hercules Graphics
- Card and the IBM Color Graphics Adaptor. The type of adaptor is determined at
- run-time, so you don't have to have two versions of your program. The code
- that determines if the Hercules Graphics Card is installed is from
-
- HERC.ASM version 1.11B by Bela Lubkin 3/4/85
- Copyright (C) 1985, Borland International
-
- Three "levels" of access are provided. The lowest level uses screen hardware
- coordinates ([0..719] by [0..347] for the HGC and [0..639] by [0..199] for the
- CGA). (0,0) is in the upper left hand corner and (719,347) or (639,199) is
- the lower right hand corner.
-
- The second level of access is a simple window arrangement, similar to that
- available in Turbo Pascal. You call GrWindow to specify the location of the
- window on the screen (using screen coordinates). Procedures are provided to
- draw on the window using window coordinates, where (0,0) is the upper left
- hand corner of the window. The default window is the entire screen. Some
- primitive routines are provided to let you clear, save, and restore windows
- areas on the screen.
-
- The highest level of access is to specify world coordinates. World coordinates
- are real numbers, rather than integers. You call GrWorld to specify the
- world coordinates of the current window. Procedures are provided to draw on
- the window using world coordinates. The default world is the same as the
- window coordinates.
-
- Procedures are provided to draw text on the screen. The ConOutPtr is used
- so that you can use Write and WriteLn to write text to the screen. GotoXY,
- WhereX, WhereY, ClrScr, and ClrEol are trapped and handled. These routines
- use the Window level interface to draw the characters in the current window.
- Currently text does not scroll in the window.
-
-
- Enhancements:
- =============
-
- 1.1.0 - ReadDot procedures and GrDemo program.
-
-
- Limitations:
- ============
-
- The IBM CGA is supported in high resolution (640x200) mode only.
- The only foreground color supported is White (really green for the HGC).
- Only simple dot, line, and box graphics are supported.
- Only simple windowing is supported. The "x" screen coordinate of the window
- start must be an integer multiple of 8.
- All text is drawn using an 8x8 grid. The "x" screen coordinate of the text
- must be a multiple of 8. Only characters with values #0 thru #127 are
- supported.
- Clipping only occurs at the window level. If you call the low-level (screen
- coordinate) procedures with invalid X and Y coordinates, "the results are
- not predictible".
- Does not support multiple screen pages.
-
-
- Graphics Routines
- Version 1.1.0
- By Michael A. Quinlan
-
-
- Files:
- ======
-
- GR.DOC - This documentation file.
- GR.INC - Graphics include file. Required.
- GR.COM - Graphics assembler code; referenced by GR.INC.
- GR.ASM - Graphics assembler source.
- GRDEMO.PAS - Demonstration program.
-
-
- Global variables, etc:
- ======================
-
- Type GrString = String[80]; { general purpose string }
-
- Var ScrMaxX : integer; { max X screen coordinate }
- ScrMaxY : integer; { max Y screen coordinate }
- ScrAspect : integer; { aspect for physical screen }
- { 0.75 for HGC; 0.44 for CGA }
-
- WindX1 : integer; { screen coord for U.L. corner of window }
- WindY1 : integer;
- WindMaxX : integer; { max X window coordinate }
- WindMaxY : integer; { max Y window coordinate }
- WindMaxRow : integer; { max window row }
- WindMaxCol : integer; { max window column }
-
- WorldX1 : real; { World coord of U.L. corner of window }
- WorldY1 : real;
- WorldXRange: real; { range of X values; X2-X1 }
- WorldYRange: real; { range of Y values; Y2-Y1 }
-
-
- Graphics Routines
- Version 1.1.0
- By Michael A. Quinlan
-
-
- Procedures Supported:
- =====================
-
- GrInit
- No parameters.
- Must be called before anything else. Tests to see which adaptor is
- installed (if neither, writes a message and HALTs). Places the display
- in graphics mode. Initializes constants.
-
- GrTerm
- No parameters.
- Must be called before exiting the program. I recommend that you
- set ErrorPtr to the offset of a procedure that calls this routine.
- Returns the display to text mode.
-
- GrWindow(x1, y1, x2, y2 : integer)
- Pass the screen coordinates of the upper left and lower right corners of
- the window. x1 must be less than x2 and y1 must be less than y2. 0,0 is
- the upper left corner of the screen. x1 and (x2+1) should be integer
- multiples of 8.
- The default window is the entire screen -- (0, 0, ScrMaxX, ScrMaxY).
- GrWindow resets the world coordinates to their default (see GrWorld).
-
- GrWorld(x1, y1, x2, y2 : real)
- Pass the world coordinates of the upper left and lower right corners of
- the window.
- The default world coordinates are the same as the window coordinates --
- (0, 0, WindMaxX, WindMaxY). You can use standard cartesian
- coordinates by specifying y1 > y2, as in GrWorld(-1.0, 1.0, 1.0, -1.0).
-
- GrSaveWindow(var area; x1, y1, x2, y2 : integer)
- Copies from the screen to "area". The window is specified by the screen
- coordinates of the upper left and lower right corners. Area must be at
- least (y2-y1+1) * (x2-x1+1) div 8 bytes long. x1 and (x2+1) must be
- integer multiples of 8.
-
- GrRestoreWindow(x1, y1, x2, y2 : integer; var area)
- Copies data from "area" to the window on the screen. The screen area is
- specified by the screen coordinates of the upper left and lower right
- corners. Area must be at least (y2-y1+1) * (x2-x1+1) div 8 bytes long.
- x1 and (x2+1) must be integer multiples of 8.
-
- GrFillWindow(x1, y1, x2, y2, color : integer)
- Fills the indicated screen area with the color specified. The coordinates
- are the screen coordinates of the upper left and lower right corners.
- The color is 0 (background) or 1 (foreground). x1 and (x2+1) must be
- integer multiples of 8.
-
- GrWriteChar(c : char)
- Write 1 character at the current text row and column and increments the
- column and row as necessary. Uses an 8x8 character, so the IBM CGA
- screen is 25 rows by 80 columns and the HGC screen is 43 rows by 90
- columns. GrInit sets ConOutPtr to the offset of GrWriteChar.
- GrWriteChar calls WindDrawChar to draw the character in the current
- window.
-
-
- Graphics Routines
- Version 1.1.0
- By Michael A. Quinlan
-
-
-
- ScrWriteDot(x, y, color : integer)
- Write a dot at the x and y screen coordinates. 0,0 is the upper left
- corner of the screen. Color is 0 (background) or 1 (foreground).
-
- ScrReadDot(x, y : integer) : integer
- Reads the dot value at the x and y screen coordiantes. 0,0 is the upper
- left corner of the screen. Returns 0 (background) or 1 (foreground).
-
- ScrDrawLine(x1, y1, x2, y2, color : integer)
- Draw a line from (x1, y1) to (x2, y2) using screen coordinates. Color is
- 0 (background) or 1 (foreground).
-
- ScrDrawBox(x1, y1, x2, y2, color : integer)
- Draw a rectangle with upper left corner at (x1, y1) and lower right corner
- at (x2, y2), using screen coordinates. Color is 0 (background) or 1
- (foreground).
- To make the box appear to be square, the "y" distance must be ScrAspect
- times the "x" distance.
-
- ScrDrawText(x, y : integer; t : SgrString)
- Draw text characters begining at the given screen coordinate. Uses an 8x8
- character. The coordinate specifies the upper left corner of the
- character. 0,0 is the upper left corner of the screen. x should be
- an integer multiple of 8. Only character values #0 thru #127 are valid.
-
- ScrDrawChar(x, y : integer; c : char)
- Draw a single text character at the given screen coordinate. Uses an 8x8
- character. The coordinate specifies the upper left corner of the
- character. 0,0 is the upper left corner of the screen. x should be
- an integer multiple of 8. Only character values #0 thru #127 are valid.
-
-
- Graphics Routines
- Version 1.1.0
- By Michael A. Quinlan
-
-
-
- WindWriteDot(x, y, color : integer)
- Draws a dot at the x,y window coordinate in the current window. 0,0 is the
- upper left corner of the window. Color is 0 (background) or 1
- (foreground). If x,y is not within the current window, the dot is not
- drawn.
-
- WindReadDot(x, y : integer) : integer
- Reads a dot at the x,y window coordinate in the current window. 0,0 is the
- upper left corner of the window. Returns 0 (background OR x,y is outside
- the current window) or 1 (foreground).
-
- WindDrawLine(x1, y1, x2, y2, color : integer)
- Draws a line from (x1,y1) to (x2,y2) in the current window, using window
- coordinates. 0,0 is the upper left corner of the window. Color is 0
- (background) or 1 (foreground). The line is clipped at the window edges.
-
- WindDrawBox(x1, y1, x2, y2, color : integer)
- Draws a rectangle in the current window with upper left corner (x1,y1)
- and lower right corner (x2,y2), using window coordinates. 0,0 is the
- upper left corner of the window. Color is 0 (background) or 1
- (foreground). The rectangle is clipped at the window edges.
- To make the rectangle appear to be square, the "y" distance must be
- equal to ScrAspect times the "x" distance.
-
- WindDrawText(x, y : integer; t : SgrString)
- Draw text characters beginning at the given window coordinate. Uses an 8x8
- character. The coordinate specifies the upper left corner of the
- character. 0,0 is the upper left corner of the window. x should be an
- integer multiple of 8. Only character values #0 thru #127 are valid.
- If a character will not fully fit in the window, it is not drawn.
-
- WindDrawChar(x, y : integer; c : char)
- Draws a single character at the given window coordinate. Uses and 8x8
- character. The coordinate specifies the upper left corner of the
- character. 0,0 is the upper left corner of the window. x should be an
- integer multiple of 8. Only character values #0 thru #127 are valid.
- If a character will not fully fit in the window, it is not drawn.
-
-
- Graphics Routines
- Version 1.1.0
- By Michael A. Quinlan
-
-
-
- WorldWriteDot(x, y : real; color : integer)
- Draws a dot at the given (x,y) world coordinate in the current window. If
- x,y is not within the current window, the dot is not drawn.
-
- WorldReadDot(x, y : real) : integer
- Reads a dot at the given (x,y) world coordinate in the current window.
- Returns 0 (background OR the x,y coordinates are outside the current
- window) or 1 (foreground).
-
- WorldDrawLine(x1, y1, x2, y2 : real; color : integer)
- Draws a line from (x1, y1) to (x2, y2) using world coordinates in the
- current window. The line is clipped at the window edges.
-
- WorldDrawBox(x1, y1, x2, y2 : real; color : integer)
- Draws a rectangle with upper left corner at (x1, y1) and lower right
- corner at (x2, y2) using world coordinates in the current window. The
- rectangle is clipped at the window edges.
-
- WorldDrawText(x, y : real; t : SgrString)
- Draws text characters beginning at the given world coordinate in the
- current window. Uses an 8 pixel by 8 pixel character. The coordinate
- specifies the upper left corner of the character. The x coordinate is
- adjusted to align the character on an 8-pixel boundary (to simplify the
- code that draws the character). Only character values #0 thru #127 are
- valid. If the character will not fit fully in the window, it is not
- drawn.
-
- WorldDrawChar(x, y : real; c : char)
- Draws the text character at the given world coordinates in the current
- window. Uses an 8 pixel by 8 pixel character. The coordinate specifies
- the upper left corner of the character. The x coordinate is adjusted
- to align the character on an 8-pixel boundary (to simplify the code that
- draws the character). Only character values #0 thru #127 are valid. If
- the character will not fit fully in the window, it is not drawn.