home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / GRAPHICS.DEF < prev    next >
Text File  |  1996-11-05  |  9KB  |  173 lines

  1. DEFINITION MODULE Graphics;
  2.  
  3.         (****************************************************************)
  4.         (*                                                              *)
  5.         (*                   Screen graphics output                     *)
  6.         (*                                                              *)
  7.         (*  Programmer:         P. Moylan                               *)
  8.         (*  Last edited:        5 November 1996                         *)
  9.         (*  Status:             OK                                      *)
  10.         (*                                                              *)
  11.         (*      The procedures in this module assume that the caller    *)
  12.         (*      has control of the entire screen.                       *)
  13.         (*      For multi-window graphics, see module GWindows.         *)
  14.         (*                                                              *)
  15.         (****************************************************************)
  16.  
  17. FROM SYSTEM IMPORT
  18.     (* type *)  ADDRESS, CARD8;
  19.  
  20. FROM ScreenGeometry IMPORT
  21.     (* type *)  Rectangle;
  22.  
  23. (************************************************************************)
  24. (*                                                                      *)
  25. (*  The constant BLorigin defined below is to support two different     *)
  26. (*  origin conventions.  When a reference is made to (x,y) coordinates  *)
  27. (*  in this module, the x value is the horizontal coordinate, with 0    *)
  28. (*  at the left of the the screen, and the y value is the vertical      *)
  29. (*  coordinate.  If BLorigin is TRUE then y=0 is at the bottom of the   *)
  30. (*  screen and y values increase upwards.  If BLorigin is FALSE then    *)
  31. (*  y=0 is at the top of the screen and y values increase downwards.    *)
  32. (*  You can choose whichever convention suits you best; the effect on   *)
  33. (*  execution speed is negligible.  Some other PMOS modules assume      *)
  34. (*  that you have selected the TRUE option.                             *)
  35. (*                                                                      *)
  36. (*  You might think that the inclusion of this choice will increase     *)
  37. (*  software overheads, but in fact any reasonable compiler will do     *)
  38. (*  the constant testing at compile time rather than at execution time, *)
  39. (*  eliminating the unreachable code.                                   *)
  40. (*                                                                      *)
  41. (************************************************************************)
  42.  
  43. CONST BLorigin = TRUE;
  44.  
  45. (************************************************************************)
  46.  
  47. TYPE ColourType = CARDINAL;
  48.  
  49. PROCEDURE SetMode (newmode: CARDINAL;  ClearScreen: BOOLEAN);
  50.  
  51.     (* Sets the video mode. *)
  52.  
  53.     (* Warning: the option ClearScreen=FALSE sometimes produces some    *)
  54.     (* strange effects, apparently because of some aspect of the BIOS   *)
  55.     (* that I don't yet understand.                                     *)
  56.  
  57. PROCEDURE SetDefaultMode;
  58.  
  59.     (* Sets the video mode to (our opinion of) the "best" graphics mode *)
  60.     (* supported by the hardware.                                       *)
  61.  
  62. PROCEDURE GraphicsOff (ClearScreen: BOOLEAN);
  63.  
  64.     (* Sets the video mode to a default text mode. *)
  65.  
  66. PROCEDURE GetScreenShape (VAR (*OUT*) xmax, ymax: CARDINAL;
  67.                                 VAR (*OUT*) maxcolour: ColourType;
  68.                                 VAR (*OUT*) CharHeight: CARDINAL);
  69.  
  70.     (* Returns the maximum values permitted by the current mode for     *)
  71.     (* x, y, and colour; and the number of rows in a character.         *)
  72.  
  73. PROCEDURE SetFont (height, width: CARDINAL;  TablePtr: ADDRESS);
  74.  
  75.     (* Specifies the font that will be used from now on (until the      *)
  76.     (* next mode setting) for drawing characters.  The first two        *)
  77.     (* parameters are the character size, and TablePtr points to the    *)
  78.     (* bitmap that defines the font.  This procedure is normally        *)
  79.     (* optional, since SetMode sets up a default font.                  *)
  80.  
  81.     (* Implementation restriction: in the present version the 'width'   *)
  82.     (* parameter is ignored, and all characters are assumed to be       *)
  83.     (* eight pixels wide.                                               *)
  84.  
  85. PROCEDURE SetPaletteColour (Palette_Index, Red, Green, Blue: CARD8);
  86.  
  87.     (* Sets the colour for one palette register.  Applicable only to    *)
  88.     (* VGA or better.  The three colour codes are 6-bit numbers.        *)
  89.  
  90. PROCEDURE PlotDot (x, y: CARDINAL;  colour: ColourType);
  91.  
  92.     (* Writes a dot at screen position (x, y).  *)
  93.  
  94. PROCEDURE PlotMark (x, y: CARDINAL;
  95.                         colour: ColourType;  pointtype: CARDINAL);
  96.  
  97.     (* Writes a mark at screen position (x, y).  Currently, the options *)
  98.     (* for pointtype are:                                               *)
  99.     (*          0       dot                                             *)
  100.     (*          1       X                                               *)
  101.     (*          2       box                                             *)
  102.  
  103. PROCEDURE PlotLine (x0, y0, x1, y1: CARDINAL;  colour: ColourType);
  104.  
  105.     (* Plots a straight line from (x0,y0) to (x1,y1).  It is the        *)
  106.     (* caller's responsibility to ensure that the coordinates are in    *)
  107.     (* range for the current video mode.                                *)
  108.  
  109. PROCEDURE PlotRectangle (R: Rectangle;  colour: ColourType);
  110.  
  111.     (* Plots a rectangle, with clipping if necessary to keep the        *)
  112.     (* points within the screen boundary.                               *)
  113.  
  114. PROCEDURE ClippedLine (x0, y0, x1, y1: CARDINAL;  colour: ColourType;
  115.                         left, right, ymin, ymax: CARDINAL);
  116.  
  117.     (* Like PlotLine, but plots only that part of the line which lies   *)
  118.     (* in the rectangle (left <= x <= right), (ymin <= y <= ymax).      *)
  119.     (* The caller is expected to ensure, by appropriate definition of   *)
  120.     (* the rectangle, that all plotted points are in range for the      *)
  121.     (* current video mode.                                              *)
  122.  
  123. PROCEDURE Fill (x0, y0, x1, y1: CARDINAL;  colour: ColourType);
  124.  
  125.     (* Fills a rectangle with the indicated colour.  The rectangle is   *)
  126.     (* specified by giving two opposite corners (x0,y0) and (x1,y1).    *)
  127.  
  128. PROCEDURE ACopy (xs, ys, width, height: CARDINAL;  dx, dy: INTEGER);
  129.  
  130.     (* Copies a rectangular region by an offset (dx, dy).  The pair     *)
  131.     (* (xs,ys) gives the coordinates of the top left of the source      *)
  132.     (* rectangle.  Restrictions: this procedure is restricted to the    *)
  133.     (* case where distance to move the data is an integral number of    *)
  134.     (* bytes (i.e. if you want it to work for all modes then dx should  *)
  135.     (* be a multiple of 8); and in the case where the source and        *)
  136.     (* destination rectangles overlap then the move has to be upwards   *)
  137.     (* on the screen.  Thus we do not have a completely general "block  *)
  138.     (* copy" operation, but we do have something sufficient to support  *)
  139.     (* "scroll up" and similar operations.                              *)
  140.  
  141. PROCEDURE DrawChar (ch: CHAR;  x, y: CARDINAL;  colour: ColourType);
  142.  
  143.     (* Draws the single character ch.  The coordinates (x,y) are the    *)
  144.     (* location of the bottom left of the character.                    *)
  145.  
  146. PROCEDURE PlotString (VAR (*IN*) text: ARRAY OF CHAR;
  147.                         x, y, length: CARDINAL;  colour: ColourType);
  148.  
  149.     (* Draws a string of "length" characters starting at location (x,y) *)
  150.     (* It is the caller's responsibility to ensure that the string will *)
  151.     (* not run off the screen edges.                                    *)
  152.  
  153. PROCEDURE ClippedString (VAR (*IN*) text: ARRAY OF CHAR;
  154.                         x, y, length: CARDINAL;  colour: ColourType;
  155.                         left, right, ymin, ymax: CARDINAL);
  156.  
  157.     (* Like PlotString, but excludes any points which fall outside the  *)
  158.     (* clip rectangle defined by (left,right,ymin,ymax).                *)
  159.  
  160. PROCEDURE PlotStringUp (VAR (*IN*) text: ARRAY OF CHAR;
  161.                         x, y, length: CARDINAL;  colour: ColourType);
  162.  
  163.     (* Like PlotString, but with text written in the +Y direction       *)
  164.  
  165. PROCEDURE ClippedUpString (VAR (*IN*) text: ARRAY OF CHAR;
  166.                         x, y, length: CARDINAL;  colour: ColourType;
  167.                         left, right, ymin, ymax: CARDINAL);
  168.  
  169.     (* Like ClippedString, but with text written in the +Y direction.   *)
  170.  
  171. END Graphics.
  172. 
  173.