GRAPH.DEF 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * GRAPH.DEF - Modula-2 graphics *
  5. * *
  6. * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. (*# call(o_a_copy => off) *)
  11. (*%T _fcall *)
  12. (*# call (seg_name=>GRAPHICS) *)
  13. (*%E *)
  14. (*# module(implementation=>off) *)
  15. (*%F _fdata *)
  16. (*# data(seg_name => null) *)
  17. (*%E *)
  18. DEFINITION MODULE Graph; (* Basic graphics routines *)
  19. IMPORT CoreGraph;
  20. (*
  21. TYPE
  22. VideoConfig = RECORD
  23. numxpixels: CARDINAL; (* number of pixels on X axis *)
  24. numypixels: CARDINAL; (* number of pixels on Y axis *)
  25. numtextcols: CARDINAL; (* number of text columns available *)
  26. numtextrows: CARDINAL; (* number of text rows available *)
  27. numcolors: CARDINAL; (* number of actual colors *)
  28. bitsperpixel: CARDINAL; (* number of bits per pixel *)
  29. numvideopages: CARDINAL; (* number of available video pages *)
  30. mode: CARDINAL; (* current video mode *)
  31. adapter: CARDINAL; (* active display adapter *)
  32. monitor: CARDINAL; (* active display monitor *)
  33. memory: CARDINAL; (* adapter video memory in K bytes *)
  34. END;
  35. GraphCoords = RECORD
  36. xcoord, ycoord: INTEGER;
  37. END;
  38. TextCoords = RECORD
  39. row, col: INTEGER;
  40. END;
  41. *)
  42. CONST
  43. AutoDetect = TRUE;
  44. CONST
  45. FillMaskType ::= CoreGraph.FillMaskType;
  46. PROCEDURE GraphMode;
  47. PROCEDURE TextMode;
  48. PROCEDURE Plot(x,y: CARDINAL; Color: CARDINAL);
  49. (* set a single pixel to given color *)
  50. PROCEDURE Point(x,y: CARDINAL) : CARDINAL;
  51. (* read a pixel of the screen *)
  52. PROCEDURE HLine(x,y,x2: CARDINAL; FillColor: CARDINAL);
  53. (* draw a horizontal line of given color (used for filling) *)
  54. (* End of device dependant routines *)
  55. (* Device independant routines *)
  56. PROCEDURE Line(x1,y1,x2,y2: CARDINAL; Color: CARDINAL);
  57. (* draw an arbitrary line in given color *)
  58. PROCEDURE Circle(x0,y0,r: CARDINAL; c: CARDINAL);
  59. (* centre x0,y0; radius r *)
  60. PROCEDURE Disc(x0,y0,r : CARDINAL; FillColor: CARDINAL);
  61. (* filled circle, centre x0,y0; radius r *)
  62. PROCEDURE TrueCircle(x0,y0,r: CARDINAL; c: CARDINAL);
  63. (* centre x0,y0; radius r , adjusted to be "round" for display *)
  64. PROCEDURE TrueDisc(x0,y0,r : CARDINAL; FillColor: CARDINAL);
  65. (* filled circle, centre x0,y0; radius r, adjusted to be "round" for display *)
  66. PROCEDURE Ellipse ( x0,y0 : CARDINAL ; (* center *)
  67. a0,b0 : CARDINAL ; (* semi-axes *)
  68. c : CARDINAL ; (* color *)
  69. fill : BOOLEAN ) ; (* wether filled *)
  70. PROCEDURE Polygon(n: CARDINAL; px,py: ARRAY OF CARDINAL; FillColor: CARDINAL);
  71. (* filled polygon of n points *)
  72. (*
  73. Initialization routines.
  74. Called to setup display output type.
  75. *)
  76. PROCEDURE InitCGA();
  77. PROCEDURE InitEGA();
  78. PROCEDURE InitVGA();
  79. PROCEDURE InitHerc();
  80. PROCEDURE InitGraph();
  81. (*
  82. procedure variables for device dependant routines
  83. *)
  84. (*
  85. Device specific constants and routines
  86. equivalent to the variables Width, Depth and NumColors
  87. *)
  88. CONST
  89. CGAWidth = 320 ;
  90. CGADepth = 200 ;
  91. CGANumColor = 4 ;
  92. EGAWidth = 640 ;
  93. EGADepth = 350 ;
  94. VGAWidth = 640 ;
  95. VGADepth = 480 ;
  96. EGANumColor = 16 ;
  97. VGA256Width = 320 ;
  98. VGA256Depth = 200 ;
  99. VGANumColor = 16 ;
  100. CONST
  101. HercWidth = 720 ;
  102. HercDepth = 348 ;
  103. HercNumColor = 2 ;
  104. VAR
  105. Width : CARDINAL ; (* x values are 0..Width-1 *)
  106. Depth : CARDINAL ; (* y values are 0..Depth-1 *)
  107. NumColor : CARDINAL ; (* Colors are 0..NumColor-1 *)
  108. (* MSDOS Extensions *)
  109. VAR
  110. FillState: BOOLEAN;
  111. CONST
  112. VideoConfig ::= CoreGraph.VideoConfig;
  113. TextCoords ::= CoreGraph.TextCoords;
  114. GraphCoords ::= CoreGraph.GraphCoords;
  115. _DEFAULTMODE = MAX(CARDINAL); (* restore screen to original mode *)
  116. _TEXTBW40 = 0; (* 40 x 25 text, 16 grey *)
  117. _TEXTC40 = 1; (* 40 x 25 text, 16/8 color *)
  118. _TEXTBW80 = 2; (* 80 x 25 text, 16 grey *)
  119. _TEXTC80 = 3; (* 80 x 25 text, 16/8 color *)
  120. _MRES4COLOR = 4; (* 320 x 200, 4 color *)
  121. _MRESNOCOLOR = 5; (* 320 x 200, 4 grey *)
  122. _HRESBW = 6; (* 640 x 200, BW *)
  123. _TEXTMONO = 7; (* 80 x 25 text, BW *)
  124. _HERCMONO = 8; (* 720 x 348, BW for HGC *)
  125. _MRES16COLOR = 13; (* 320 x 200, 16 color *)
  126. _HRES16COLOR = 14; (* 640 x 200, 16 color *)
  127. _ERESNOCOLOR = 15; (* 640 x 350, BW *)
  128. _ERESCOLOR = 16; (* 640 x 350, 4 or 16 color *)
  129. _VRES2COLOR = 17; (* 640 x 480, BW *)
  130. _VRES16COLOR = 18; (* 640 x 480, 16 color *)
  131. _MRES256COLOR = 19; (* 320 x 200, 256 color *)
  132. _MDPA = 0001H; (* Monochrome Display Adapter (MDPA) *)
  133. _CGA = 0002H; (* Color Graphics Adapter (CGA) *)
  134. _EGA = 0004H; (* Enhanced Graphics Adapter (EGA) *)
  135. _VGA = 0008H; (* Video Graphics Array (VGA) *)
  136. _MCGA = 0010H; (* MultiColor Graphics Array (MCGA) *)
  137. _HGC = 0020H; (* Hercules Graphics Card (HGC) *)
  138. _MONO = 0001H; (* Monochrome *)
  139. _COLOR = 0002H; (* Color (or Enhanced emulating color) *)
  140. _ENHCOLOR = 0004H; (* Enhanced Color *)
  141. _ANALOG = 0018H; (* Analog *)
  142. _GBORDER = FALSE; (* draw outline only *)
  143. _GFILLINTERIOR = TRUE; (* fill using current fill mask *)
  144. _GTOP = TRUE;
  145. _GNOTOP = FALSE;
  146. _GCLEARSCREEN = 0;
  147. _GVIEWPORT = 1;
  148. _GWINDOW = 2;
  149. _GCURSOROFF = FALSE;
  150. _GCURSORON = TRUE;
  151. _GWRAPOFF = FALSE;
  152. _GWRAPON = TRUE;
  153. _GPSET = 3;
  154. _GPRESET = 2;
  155. _GAND = 1;
  156. _GOR = 0;
  157. _GXOR = 4;
  158. _BLACK = 0000000H;
  159. _BLUE = 02A0000H;
  160. _GREEN = 0002A00H;
  161. _CYAN = 02A2A00H;
  162. _RED = 000002AH;
  163. _MAGENTA = 02A002AH;
  164. _BROWN = 000152AH;
  165. _WHITE = 02A2A2AH;
  166. _GRAY = 0151515H;
  167. _LIGHTBLUE = 03F1515H;
  168. _LIGHTGREEN = 0153F15H;
  169. _LIGHTCYAN = 03F3F15H;
  170. _LIGHTRED = 015153FH;
  171. _LIGHTMAGENTA = 03F153FH;
  172. _LIGHTYELLOW = 0153F3FH;
  173. _BRIGHTWHITE = 03F3F3FH;
  174. PROCEDURE GetVideoConfig(VAR V: VideoConfig);
  175. PROCEDURE SetClipRgn(x1, y1, x2, y2: CARDINAL);
  176. PROCEDURE GetBkColor(): LONGCARD;
  177. PROCEDURE GetFillMask(VAR Mask: CoreGraph.FillMaskType);
  178. PROCEDURE GetLinestyle(): CARDINAL;
  179. PROCEDURE SetBkColor(Color: LONGCARD): LONGCARD;
  180. PROCEDURE SetFillMask(Mask: CoreGraph.FillMaskType);
  181. PROCEDURE SetLinestyle(Mask: CARDINAL);
  182. PROCEDURE DisplayCursor(Toggle: BOOLEAN): BOOLEAN;
  183. PROCEDURE GetTextColor(): CARDINAL;
  184. PROCEDURE GetTextPosition(): TextCoords;
  185. PROCEDURE SetTextColor(Color: CARDINAL): CARDINAL;
  186. PROCEDURE SetTextPosition(row, col: CARDINAL): TextCoords;
  187. PROCEDURE SetTextWindow(r1, c1, r2, c2: CARDINAL);
  188. PROCEDURE Wrapon(Opt: BOOLEAN): BOOLEAN;
  189. PROCEDURE OutText(Text: ARRAY OF CHAR);
  190. PROCEDURE SetVideoMode(Mode: CARDINAL): BOOLEAN;
  191. PROCEDURE SetActivePage(Page: CARDINAL): CARDINAL;
  192. PROCEDURE SetVisualPage(Page: CARDINAL): CARDINAL;
  193. PROCEDURE ClearScreen(Area: CARDINAL);
  194. PROCEDURE Rectangle(x1, y1, x2, y2: CARDINAL; Color: CARDINAL;Fill: BOOLEAN);
  195. PROCEDURE Arc(x1, y1, x2, y2, x3, y3, x4, y4: CARDINAL; Color: CARDINAL);
  196. PROCEDURE Pie(x1, y1, x2, y2, x3, y3, x4, y4: CARDINAL; Colr: CARDINAL; Fill: BOOLEAN);
  197. PROCEDURE FloodFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  198. PROCEDURE StackFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  199. PROCEDURE RemapPalette(Pixel: CARDINAL; Color: LONGCARD): LONGCARD;
  200. PROCEDURE RemapAllPalette(Colarray: ARRAY OF LONGCARD): CARDINAL;
  201. PROCEDURE SelectPalette(Palnum: CARDINAL): CARDINAL;
  202. PROCEDURE GetImage(x1, y1, x2, y2: CARDINAL; Buffer: ADDRESS);
  203. PROCEDURE PutImage(x, y: CARDINAL; Buffer: ADDRESS; Action: CARDINAL);
  204. PROCEDURE ImageSize(x1, y1, x2, y2: CARDINAL): LONGCARD;
  205. PROCEDURE Cube(top: BOOLEAN; x1, y1, x2, y2, depth: CARDINAL; Color: CARDINAL; Fill: BOOLEAN);
  206. TYPE A1=ARRAY [0..0] OF SHORTCARD;
  207. (*# save,
  208. call( reg_param=>(dx,ax),
  209. reg_saved=>(dx,ax,bx,cx,si,di,es,ds,st1,st2),
  210. inline=>on )
  211. *)
  212. INLINE PROCEDURE Out (p:CARDINAL;v:SHORTCARD)=A1(0EEH);
  213. (*# restore *)
  214. END Graph.
  215.