home *** CD-ROM | disk | FTP | other *** search
-
-
- SURPAS-86 SUPPLEMENTARY DOCUMENTATION
- IBM PC Graphics Driver
-
- Copyright (C) 1987
- Tixaku Pty Ltd
-
-
-
- On your SURPAS distribution disk you will find two files called
- GRAPHICS.PAS and GRAPHICS.BIN. They contain a complete set of
- graphic drivers for the IBM Color/Graphics Adapter and enable you
- to use medium and high resolution graphics in your SURPAS Pascal
- programs. The graphic drivers support all three graphic modes:
- 320 x 200 color graphics, 320 x 200 monochrome graphics and 620 x
- 200 monochrome graphics. If your system is not equipped with a
- Color/Graphics Adapter you cannot use the graphic drivers.
-
- To include the graphic drivers in a program, place the following
- compiler directive at the very beginning of the program:
-
- (*$I GRAPHICS*)
-
- This will include the file called GRAPHICS.PAS in the compilation
- of your source text. Alternatively you can copy the entire GRAP-
- HICS.PAS file into your source text. GRAPHICS.PAS contains a list
- of very short procedures, each of which calls an EXTERNAL proce-
- dure called GRAPHICS. The code for the GRAPHICS procedure is read
- from the GRAPHICS.BIN file and it contains the actual drivers.
- The drivers are written in machine code to optimize execution
- speed.
-
- The following procedures and functions are provided by the gra-
- phic driver package:
-
- CRTMODE Set CRT mode.
- WINDOW Define Window Coordinates.
- BCOLOR Set Background Color.
- PCOLOR Set Color Palette.
- FCOLOR Set Foreground Color.
- COLORMAP Define Color Map.
- FILLSCREEN Fill Screen.
- MOVETO Set Current Position.
- MOVEBY Set Current Position Relative.
- LINETO Draw Line.
- LINEBY Draw Line Relative.
- PLOTAT Plot Point.
- PLOTBY Plot Point Relative.
- PAINT Paint Area.
- POINT Read Color Of Dot.
-
- Each routine is described in detail below.
-
- All graphic routines operate within a window. By default the
- window is set to the entire graphic image, i.e. (0,0)-(319,199)
- for medium resolution and (0,0)-(639,199) for high resolution,
- but there are occations when it is handy to use only part of the
- screen, while safeguarding the rest from accidental use. For this
- purpose, the graphic drivers allow you to define any rectangle on
- the screen as the window.
-
- The graphic routines operate on integer coordinates. Thus, the
- coordinate range is -32768..32767. However, coodinates outside
- the window are ignored. When a line is drawn using any of the
- graphic routines, it is automatically clipped so that only the
- portion which lies within the current window is displayed. Points
- whose coordinates are not within the current window, even those
- points that would not be on the screen at all, are legal but
- ignored.
-
- It is possible to mix text and graphics on the screen. In 320 x
- 200 graphics mode the screen can display 40 x 25 characters and
- in 640 x 200 graphics mode it can display 80 x 25 characters. To
- write a text on the graphics screen, use the GOTOXY procedure or
- an Escape-Y sequence to move the cursor (which is not visible in
- graphics mode) to the relevant row/column, and output the text
- using a WRITE statement. Each character cell occupies 8 x 8 dots,
- so the actual X coordinate of the upper left corner of a charac-
- ter cell is the row number times 8, and the actual Y coordinate
- is the column number times 8. Note that the foreground color set
- by FCOLOR does not apply when text is written to the graphics
- screen. The foreground color of text is selected through an
- Escape-b sequence. For further details on this, please refer to
- the IBMPC.DOC Supplementary Documentation file on your distribu-
- tion disk.
-
-
- Function: Set CRT Mode.
-
- Header: PROCEDURE CRTMODE(M: INTEGER);
-
- Remarks: This procedure is used to set the CRT operating mode.
- M is an integer between 0 and 7 which selects an
- operating mode according to the table below:
-
- 0 = 40 x 25 Black and White.
- 1 = 40 x 25 Color.
- 2 = 80 x 25 Black and White.
- 3 = 80 x 25 Color.
- 4 = 320 x 200 Color Graphics.
- 5 = 320 x 200 Monochrome Graphics.
- 6 = 640 x 200 Monochrome Graphics.
- 7 = 80 x 25 Black and White (Monochrome Display).
-
- Mode 7 should only be selected if your IBM PC or XT
- is equipped with a Monochrome Display Adapter. When
- CRTMODE is called, the window is reset to the whole
- screen, the current position becomes (0,0) and the
- foreground color becomes 3 (CRT modes 4 and 5) or 1
- (CRT mode 6). All of the routines described in the
- following operate correctly in modes 4-6 only.
-
-
- Function: Define Window Coordinates.
-
- Header: PROCEDURE WINDOW(X1,Y1,X2,Y2: INTEGER);
-
- Remarks: The window is the area on the screen that may be
- manipulated by the graphic routines. By default the
- window is the whole screen, but through this command
- the boundaries of the window may be changed. Every-
- thing outside the window remains unchanged during all
- graphic operations until it again becomes part of the
- window. (X1,Y1) and (X2,Y2) are the opposite corners
- of the window (no special ordering is required). X
- coordinates must be between 0 and 319 (CRT modes 4
- and 5) or 639 (CRT mode 6) and Y coordinates must be
- between 0 and 199. If one or more of the coordinates
- are out of range, the window is not changed. The
- current position becomes the upper left corner of the
- window. Note that CRTMODE resets the window to the
- entire screen.
-
-
- Function: Set Background Color.
-
- Header: PROCEDURE BCOLOR(C: INTEGER);
-
- Remarks: For 320 x 200 graphics (CRT modes 4 and 5) this
- procedure sets the background color. For 640 x 200
- graphics (CRT mode 6) it sets the color value of the
- foreground color (the background color is always
- black in this mode). C is an integer between 0 to 15
- which selects a color according to the table below:
-
- 0 = Black. 8 = Dark Gray.
- 1 = Blue. 9 = Light Blue.
- 2 = Green. 10 = Light Green.
- 3 = Cyan. 11 = Light Cyan.
- 4 = Red. 12 = Light Red.
- 5 = Magenta. 13 = Light Magenta.
- 6 = Brown. 14 = Yellow.
- 7 = Light Gray. 15 = White.
-
- For 320 x 200 graphics, the background color defaults
- to black (0). For 640 x 200 graphics it defaults to
- white (15), since it is actually the foreground
- color.
-
-
- Function: Set Color Palette.
-
- Header: PROCEDURE PCOLOR(C: INTEGER);
-
- Remarks: This procedure has meaning only for 320 x 200 gra-
- phics (CRT modes 4 and 5). C is an integer between 0
- and 1 which selects the foreground color palette
- according to the table below:
-
- 0 = Green, Red and Yellow foreground colors.
- 1 = Cyan, Magenta and White foreground colors.
-
- The default palette is 1. The screen can only display
- the colors of one palette. Thus, all foreground co-
- lors on the screen change instantly when an new
- palette is selected.
-
-
- Function: Set Foreground Color.
-
- Header: PROCEDURE FCOLOR(C: INTEGER);
-
- Remarks: C is an integer between -1 and 3 (320 x 200 graphics)
- or -1 and 1 (640 x 200 graphics). It selects the
- foreground color, i.e. the color to be used for lines
- and dots drawn by the LINETO, LINEBY, PLOTAT and
- PLOTBY routines. For 320 x 200 graphics, C selects a
- foreground color according to the table below:
-
- -1 = Use color map set by COLORMAP.
- 0 = Background color set by BCOLOR.
- 1 = Green (palette 0) or Cyan (palette 1).
- 2 = Red (palette 0) or Magenta (palette 1).
- 3 = Yellow (palette 0) or White (palette 1).
-
- For 640 x 200 graphics, C selects a foreground color
- according to the table below:
-
- -1 = Use color map set by COLORMAP.
- 0 = Black.
- 1 = Color set by BCOLOR.
-
- For details on color mapping (foreground color -1),
- see the description of the COLORMAP procedure. The
- default foreground color is 3 for 320 x 200 graphics
- and 1 for 640 x 200 graphics. Note that the fore-
- ground color set by FCOLOR does not apply when text
- is written to the graphics screen through write sta-
- tements (use Escape-b instead).
-
-
- Function: Define Color Map.
-
- Header: PROCEDURE COLORMAP(C0,C1,C2,C3: INTEGER);
-
- Remarks: When the foreground color (set by FCOLOR) is -1, the
- graphic routines use a color map to write dots on the
- screen. Essentially the color map is a translation
- table: When a dot is written, its current color value
- is used to determine its new value. C0 defines the
- new color that dots of color 0 should have when they
- are written, C1 defines the new color for color 1,
- etc. For instance, if the color map is (3,2,1,0) and
- the foreground color is -1, LINETO, LINEBY, PLOTAT
- and PLOTBY will complement dots when they are writ-
- ten. A color map of (0,2,2,2) will turn dots of all
- foreground colors into color 2, but it will leave
- dots of the background color unchanged. In 640 x 200
- graphics mode the screen can only show two colors (0
- and 1), so C2 and C3 are ignored in this mode. There
- is no default color map; the COLORMAP procedure must
- be called before foreground color -1 is used.
-
-
- Function: Fill Screen.
-
- Header: PROCEDURE FILLSCREEN(C: INTEGER);
-
- Remarks: FILLSCREEN fills the entire window with the color
- specified by C. C is an integer between -1 and 3 (320
- x 200 graphics) or -1 and 1 (640 x 200 graphics). For
- a definition of the colors associated with the values
- of C please refer to the description of FCOLOR. When
- C is -1, FILLSCREEN uses the color map. This allows
- some dramatic effects. For example, if the color map
- is (3,2,1,0), FILLSCREEN(-1) makes a "negative" of
- the contents of the window. If the color map is
- (0,1,0,3), FILLSCREEN will turn all red or magenta
- dots into the background color.
-
-
- Function: Set Current Position.
-
- Header: PROCEDURE MOVETO(X,Y: INTEGER);
-
- Remarks: The current position becomes (X,Y).
-
-
- Function: Set Current Position Relative.
-
- Header: PROCEDURE MOVEBY(DX,DY: INTEGER);
-
- Remarks: (DX,DY) is added to the current position.
-
-
- Function: Draw Line.
-
- Header: PROCEDURE LINETO(X,Y: INTEGER);
-
- Remarks: Draws a line in the current foreground color from the
- current position to (X,Y). The current position then
- becomes (X,Y).
-
-
- Function: Draw Line Relative.
-
- Header: PROCEDURE LINEBY(DX,DY: INTEGER);
-
- Remarks: Draws a line in the current foreground color from the
- current position to the current position plus
- (DX,DY). (DX,DY) is then added to the current posi-
- tion.
-
-
- Function: Plot Point.
-
- Header: PROCEDURE PLOTAT(X,Y: INTEGER);
-
- Remarks: Plots a point in the current foreground color at
- (X,Y). The current position becomes (X,Y).
-
-
- Function: Plot Point Relative.
-
- Header: PROCEDURE PLOTBY(DX,DY: INTEGER);
-
- Remarks: Plots a point in the current foreground color at the
- current position plus (DX,DY). (DX,DY) is then added
- to the current position.
-
-
- Function: Paint Area.
-
- Header: PROCEDURE PAINT(X,Y,FC,BC: INTEGER);
-
- Remarks: Fills in an area on the screen with the color speci-
- fied by FC. (X,Y) are the coordinates of a point
- within the area to be painted. BC is the boundary
- color, i.e. the color of the edges of the area. PAINT
- has no effect if the starting point already has the
- boundary color. If the shape to be painted is not
- closed, the foreground color will "leak out" and fill
- the entire window. On the other hand, if the shape is
- closed but the starting point is outside it, PAINT
- will fill the surrounding area. PAINT never paints
- beyond the current window. FC and BC must be true
- colors, i.e. 0-3 for 320 x 200 graphics and 0-1 for
- 640 x 200 graphics. Color mapping is not supported by
- PAINT.
-
-
- Function: Return Color Of Dot.
-
- Header: FUNCTION POINT(X,Y: INTEGER): INTEGER;
-
- Remarks: Returns the color of the dot at (X,Y), i.e. 0-3 for
- 320 x 200 graphics and 0-1 for 640 x 200 graphics. If
- (X,Y) is outside the window, POINT returns -1.