home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASM / GR110.ZIP / GR110.DOC < prev    next >
Encoding:
Text File  |  1985-08-26  |  12.9 KB  |  289 lines

  1.  
  2.                           Graphics Routines
  3.                             Version 1.1.0
  4.                                8/16/85
  5.  
  6.                         By Michael A. Quinlan
  7.  
  8.  
  9. These routines provide simple graphics support for both the Hercules Graphics
  10. Card and the IBM Color Graphics Adaptor.  The type of adaptor is determined at
  11. run-time, so you don't have to have two versions of your program.  The code
  12. that determines if the Hercules Graphics Card is installed is from
  13.  
  14.     HERC.ASM version 1.11B by Bela Lubkin 3/4/85
  15.     Copyright (C) 1985, Borland International
  16.  
  17. Three "levels" of access are provided.  The lowest level uses screen hardware
  18. coordinates ([0..719] by [0..347] for the HGC and [0..639] by [0..199] for the
  19. CGA).  (0,0) is in the upper left hand corner and (719,347) or (639,199) is
  20. the lower right hand corner.
  21.  
  22. The second level of access is a simple window arrangement, similar to that
  23. available in Turbo Pascal.  You call GrWindow to specify the location of the
  24. window on the screen (using screen coordinates).  Procedures are provided to
  25. draw on the window using window coordinates, where (0,0) is the upper left
  26. hand corner of the window.  The default window is the entire screen.  Some
  27. primitive routines are provided to let you clear, save, and restore windows
  28. areas on the screen.
  29.  
  30. The highest level of access is to specify world coordinates. World coordinates
  31. are real numbers, rather than integers.  You call GrWorld to specify the
  32. world coordinates of the current window.  Procedures are provided to draw on
  33. the window using world coordinates.  The default world is the same as the
  34. window coordinates.
  35.  
  36. Procedures are provided to draw text on the screen.  The ConOutPtr is used
  37. so that you can use Write and WriteLn to write text to the screen.  GotoXY,
  38. WhereX, WhereY, ClrScr, and ClrEol are trapped and handled.  These routines
  39. use the Window level interface to draw the characters in the current window.
  40. Currently text does not scroll in the window.
  41.  
  42.  
  43. Enhancements:
  44. =============
  45.  
  46.   1.1.0 - ReadDot procedures and GrDemo program.
  47.  
  48.  
  49. Limitations:
  50. ============
  51.  
  52.   The IBM CGA is supported in high resolution (640x200) mode only.
  53.   The only foreground color supported is White (really green for the HGC).
  54.   Only simple dot, line, and box graphics are supported.
  55.   Only simple windowing is supported. The "x" screen coordinate of the window
  56.     start must be an integer multiple of 8.
  57.   All text is drawn using an 8x8 grid. The "x" screen coordinate of the text
  58.     must be a multiple of 8. Only characters with values #0 thru #127 are
  59.     supported.
  60.   Clipping only occurs at the window level. If you call the low-level (screen
  61.     coordinate) procedures with invalid X and Y coordinates, "the results are
  62.     not predictible".
  63.   Does not support multiple screen pages.
  64.  
  65.  
  66.                           Graphics Routines
  67.                             Version 1.1.0
  68.                         By Michael A. Quinlan
  69.  
  70.  
  71. Files:
  72. ======
  73.  
  74.   GR.DOC      - This documentation file.
  75.   GR.INC      - Graphics include file. Required.
  76.   GR.COM      - Graphics assembler code; referenced by GR.INC.
  77.   GR.ASM      - Graphics assembler source.
  78.   GRDEMO.PAS  - Demonstration program.
  79.  
  80.  
  81. Global variables, etc:
  82. ======================
  83.  
  84.   Type GrString = String[80];      { general purpose string }
  85.  
  86.   Var ScrMaxX    : integer;        { max X screen coordinate }
  87.       ScrMaxY    : integer;        { max Y screen coordinate }
  88.       ScrAspect  : integer;        { aspect for physical screen }
  89.                                    { 0.75 for HGC; 0.44 for CGA }
  90.  
  91.       WindX1     : integer;        { screen coord for U.L. corner of window }
  92.       WindY1     : integer;
  93.       WindMaxX   : integer;        { max X window coordinate }
  94.       WindMaxY   : integer;        { max Y window coordinate }
  95.       WindMaxRow : integer;        { max window row }
  96.       WindMaxCol : integer;        { max window column }
  97.  
  98.       WorldX1    : real;           { World coord of U.L. corner of window }
  99.       WorldY1    : real;
  100.       WorldXRange: real;           { range of X values; X2-X1 }
  101.       WorldYRange: real;           { range of Y values; Y2-Y1 }
  102.  
  103.  
  104.                           Graphics Routines
  105.                             Version 1.1.0
  106.                         By Michael A. Quinlan
  107.  
  108.  
  109. Procedures Supported:
  110. =====================
  111.  
  112.   GrInit
  113.     No parameters.
  114.     Must be called before anything else. Tests to see which adaptor is
  115.       installed (if neither, writes a message and HALTs). Places the display
  116.       in graphics mode. Initializes constants.
  117.  
  118.   GrTerm
  119.     No parameters.
  120.     Must be called before exiting the program. I recommend that you
  121.       set ErrorPtr to the offset of a procedure that calls this routine.
  122.       Returns the display to text mode.
  123.  
  124.   GrWindow(x1, y1, x2, y2 : integer)
  125.     Pass the screen coordinates of the upper left and lower right corners of
  126.       the window. x1 must be less than x2 and y1 must be less than y2. 0,0 is
  127.       the upper left corner of the screen. x1 and (x2+1) should be integer
  128.       multiples of 8.
  129.     The default window is the entire screen -- (0, 0, ScrMaxX, ScrMaxY).
  130.       GrWindow resets the world coordinates to their default (see GrWorld).
  131.  
  132.   GrWorld(x1, y1, x2, y2 : real)
  133.     Pass the world coordinates of the upper left and lower right corners of
  134.       the window.
  135.     The default world coordinates are the same as the window coordinates --
  136.       (0, 0, WindMaxX, WindMaxY). You can use standard cartesian
  137.       coordinates by specifying y1 > y2, as in GrWorld(-1.0, 1.0, 1.0, -1.0).
  138.  
  139.   GrSaveWindow(var area; x1, y1, x2, y2 : integer)
  140.     Copies from the screen to "area". The window is specified by the screen
  141.       coordinates of the upper left and lower right corners. Area must be at
  142.       least (y2-y1+1) * (x2-x1+1) div 8 bytes long. x1 and (x2+1) must be
  143.       integer multiples of 8.
  144.  
  145.   GrRestoreWindow(x1, y1, x2, y2 : integer; var area)
  146.     Copies data from "area" to the window on the screen. The screen area is
  147.       specified by the screen coordinates of the upper left and lower right
  148.       corners. Area must be at least (y2-y1+1) * (x2-x1+1) div 8 bytes long.
  149.       x1 and (x2+1) must be integer multiples of 8.
  150.  
  151.   GrFillWindow(x1, y1, x2, y2, color : integer)
  152.     Fills the indicated screen area with the color specified. The coordinates
  153.       are the screen coordinates of the upper left and lower right corners.
  154.       The color is 0 (background) or 1 (foreground). x1 and (x2+1) must be
  155.       integer multiples of 8.
  156.  
  157.   GrWriteChar(c : char)
  158.     Write 1 character at the current text row and column and increments the
  159.       column and row as necessary. Uses an 8x8 character, so the IBM CGA
  160.       screen is 25 rows by 80 columns and the HGC screen is 43 rows by 90
  161.       columns. GrInit sets ConOutPtr to the offset of GrWriteChar.
  162.     GrWriteChar calls WindDrawChar to draw the character in the current
  163.       window.
  164.  
  165.  
  166.                           Graphics Routines
  167.                             Version 1.1.0
  168.                         By Michael A. Quinlan
  169.  
  170.  
  171.  
  172.   ScrWriteDot(x, y, color : integer)
  173.     Write a dot at the x and y screen coordinates. 0,0 is the upper left
  174.       corner of the screen. Color is 0 (background) or 1 (foreground).
  175.  
  176.   ScrReadDot(x, y : integer) : integer
  177.     Reads the dot value at the x and y screen coordiantes. 0,0 is the upper
  178.       left corner of the screen. Returns 0 (background) or 1 (foreground).
  179.  
  180.   ScrDrawLine(x1, y1, x2, y2, color : integer)
  181.     Draw a line from (x1, y1) to (x2, y2) using screen coordinates. Color is
  182.       0 (background) or 1 (foreground).
  183.  
  184.   ScrDrawBox(x1, y1, x2, y2, color : integer)
  185.     Draw a rectangle with upper left corner at (x1, y1) and lower right corner
  186.       at (x2, y2), using screen coordinates. Color is 0 (background) or 1
  187.       (foreground).
  188.     To make the box appear to be square, the "y" distance must be ScrAspect
  189.       times the "x" distance.
  190.  
  191.   ScrDrawText(x, y : integer; t : SgrString)
  192.     Draw text characters begining at the given screen coordinate. Uses an 8x8
  193.       character. The coordinate specifies the upper left corner of the
  194.       character. 0,0 is the upper left corner of the screen. x should be
  195.       an integer multiple of 8. Only character values #0 thru #127 are valid.
  196.  
  197.   ScrDrawChar(x, y : integer; c : char)
  198.     Draw a single text character at the given screen coordinate. Uses an 8x8
  199.       character. The coordinate specifies the upper left corner of the
  200.       character. 0,0 is the upper left corner of the screen. x should be
  201.       an integer multiple of 8. Only character values #0 thru #127 are valid.
  202.  
  203.  
  204.                           Graphics Routines
  205.                             Version 1.1.0
  206.                         By Michael A. Quinlan
  207.  
  208.  
  209.  
  210.   WindWriteDot(x, y, color : integer)
  211.     Draws a dot at the x,y window coordinate in the current window. 0,0 is the
  212.       upper left corner of the window. Color is 0 (background) or 1
  213.       (foreground). If x,y is not within the current window, the dot is not
  214.       drawn.
  215.  
  216.   WindReadDot(x, y : integer) : integer
  217.     Reads a dot at the x,y window coordinate in the current window. 0,0 is the
  218.       upper left corner of the window. Returns 0 (background OR x,y is outside
  219.       the current window) or 1 (foreground).
  220.  
  221.   WindDrawLine(x1, y1, x2, y2, color : integer)
  222.     Draws a line from (x1,y1) to (x2,y2) in the current window, using window
  223.       coordinates. 0,0 is the upper left corner of the window. Color is 0
  224.       (background) or 1 (foreground). The line is clipped at the window edges.
  225.  
  226.   WindDrawBox(x1, y1, x2, y2, color : integer)
  227.     Draws a rectangle in the current window with upper left corner (x1,y1)
  228.       and lower right corner (x2,y2), using window coordinates. 0,0 is the
  229.       upper left corner of the window. Color is 0 (background) or 1
  230.       (foreground). The rectangle is clipped at the window edges.
  231.     To make the rectangle appear to be square, the "y" distance must be
  232.       equal to ScrAspect times the "x" distance.
  233.  
  234.   WindDrawText(x, y : integer; t : SgrString)
  235.     Draw text characters beginning at the given window coordinate. Uses an 8x8
  236.       character. The coordinate specifies the upper left corner of the
  237.       character. 0,0 is the upper left corner of the window. x should be an
  238.       integer multiple of 8. Only character values #0 thru #127 are valid.
  239.       If a character will not fully fit in the window, it is not drawn.
  240.  
  241.   WindDrawChar(x, y : integer; c : char)
  242.     Draws a single character at the given window coordinate. Uses and 8x8
  243.       character. The coordinate specifies the upper left corner of the
  244.       character. 0,0 is the upper left corner of the window. x should be an
  245.       integer multiple of 8. Only character values #0 thru #127 are valid.
  246.       If a character will not fully fit in the window, it is not drawn.
  247.  
  248.  
  249.                           Graphics Routines
  250.                             Version 1.1.0
  251.                         By Michael A. Quinlan
  252.  
  253.  
  254.  
  255.   WorldWriteDot(x, y : real; color : integer)
  256.     Draws a dot at the given (x,y) world coordinate in the current window. If
  257.       x,y is not within the current window, the dot is not drawn.
  258.  
  259.   WorldReadDot(x, y : real) : integer
  260.     Reads a dot at the given (x,y) world coordinate in the current window.
  261.       Returns 0 (background OR the x,y coordinates are outside the current
  262.       window) or 1 (foreground).
  263.  
  264.   WorldDrawLine(x1, y1, x2, y2 : real; color : integer)
  265.     Draws a line from (x1, y1) to (x2, y2) using world coordinates in the
  266.       current window. The line is clipped at the window edges.
  267.  
  268.   WorldDrawBox(x1, y1, x2, y2 : real; color : integer)
  269.     Draws a rectangle with upper left corner at (x1, y1) and lower right
  270.       corner at (x2, y2) using world coordinates in the current window. The
  271.       rectangle is clipped at the window edges.
  272.  
  273.   WorldDrawText(x, y : real; t : SgrString)
  274.     Draws text characters beginning at the given world coordinate in the
  275.       current window. Uses an 8 pixel by 8 pixel character. The coordinate
  276.       specifies the upper left corner of the character. The x coordinate is
  277.       adjusted to align the character on an 8-pixel boundary (to simplify the
  278.       code that draws the character). Only character values #0 thru #127 are
  279.       valid. If the character will not fit fully in the window, it is not
  280.       drawn.
  281.  
  282.   WorldDrawChar(x, y : real; c : char)
  283.     Draws the text character at the given world coordinates in the current
  284.       window. Uses an 8 pixel by 8 pixel character. The coordinate specifies
  285.       the upper left corner of the character. The x coordinate is adjusted
  286.       to align the character on an 8-pixel boundary (to simplify the code that
  287.       draws the character). Only character values #0 thru #127 are valid. If
  288.       the character will not fit fully in the window, it is not drawn.
  289.