graph.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. unit Graph;
  2. { *********************************************************************
  3. Info:
  4. This units mimics some parts of borland's graph unit for
  5. Amiga.
  6. You have to use crt for readln, readkey and stuff like
  7. that for your programs. When the show is over you should
  8. just press a key or hit return to close everything down.
  9. If that doesn't work just flip the screens with left-Amiga n
  10. and activate the shell you started from.
  11. I have compiled and run mandel.pp without any problems.
  12. This version requires Free Pascal 0.99.5c or higher.
  13. It will also use some amigaunits, when the unit gets
  14. better we can remove those units.
  15. Large parts have not yet been implemented or tested.
  16. [email protected] (Nils Sjoholm)
  17. History:
  18. Date Version Who Comments
  19. ---------- -------- ------- -------------------------------------
  20. 27-Nov-98 0.1 nsjoholm Initial version.
  21. License Conditions:
  22. This library is free software; you can redistribute it and/or
  23. modify it under the terms of the GNU Library General Public
  24. License as published by the Free Software Foundation; either
  25. version 2 of the License, or (at your option) any later version.
  26. This library is distributed in the hope that it will be useful,
  27. but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  29. Library General Public License for more details.
  30. You should have received a copy of the GNU Library General Public
  31. License along with this library; if not, write to the Free
  32. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  33. *********************************************************************}
  34. interface
  35. uses Exec, Intuition, Graphics, Utility;
  36. { ---------------------------------------------------------------------
  37. Constants
  38. ---------------------------------------------------------------------}
  39. const
  40. NormalPut = 0;
  41. CopyPut = 0;
  42. XORPut = 1;
  43. ORPut = 2;
  44. ANDPut = 3;
  45. NotPut = 4;
  46. BackPut = 8;
  47. Black = 0;
  48. Blue = 1;
  49. Green = 2;
  50. Cyan = 3;
  51. Red = 4;
  52. Magenta = 5;
  53. Brown = 6;
  54. LightGray = 7;
  55. DarkGray = 8;
  56. LightBlue = 9;
  57. LightGreen = 10;
  58. LightCyan = 11;
  59. LightRed = 12;
  60. LightMagenta = 13;
  61. Yellow = 14;
  62. White = 15;
  63. Border = 16;
  64. SolidLn = 0;
  65. DottedLn = 1;
  66. CenterLn = 2;
  67. DashedLn = 3;
  68. UserBitLn = 4;
  69. EmptyFill = 0;
  70. SolidFill = 1;
  71. LineFill = 2;
  72. LtSlashFill = 3;
  73. SlashFill = 4;
  74. BkSlashFill = 5;
  75. LtBkSlashFill = 6;
  76. HatchFill = 7;
  77. XHatchFill = 8;
  78. InterleaveFill = 9;
  79. WideDotFill = 10;
  80. CloseDotFill = 11;
  81. UserFill = 12;
  82. NormWidth = 1;
  83. ThickWidth = 3;
  84. const
  85. LeftText = 0;
  86. CenterText = 1;
  87. RightText = 2;
  88. BottomText = 0;
  89. TopText = 2;
  90. BaseLine = 3;
  91. LeadLine = 4;
  92. const
  93. { Error codes }
  94. grOK = 0;
  95. grNoInitGraph = -1;
  96. grNotDetected = -2;
  97. grFileNotFound = -3;
  98. grInvalidDriver = -4;
  99. grNoLOadMem = -5;
  100. grNoScanMem = -6;
  101. grNoFloodMem = -7;
  102. grFontNotFound = -8;
  103. grNoFontMem = -9;
  104. grInvalidmode = -10;
  105. grError = -11;
  106. grIOerror = -12;
  107. grInvalidFont = -13;
  108. grInvalidFontNum = -14;
  109. Type
  110. FillPatternType = array[1..8] of byte;
  111. ArcCoordsType = record
  112. x,y : integer;
  113. xstart,ystart : integer;
  114. xend,yend : integer;
  115. end;
  116. RGBColor = record
  117. r,g,b,i : byte;
  118. end;
  119. PaletteType = record
  120. Size : integer;
  121. Colors : array[0..767]of Byte;
  122. end;
  123. LineSettingsType = record
  124. linestyle : word;
  125. pattern : word;
  126. thickness : word;
  127. end;
  128. TextSettingsType = record
  129. font : word;
  130. direction : word;
  131. charsize : word;
  132. horiz : word;
  133. vert : word;
  134. end;
  135. FillSettingsType = record
  136. pattern : word;
  137. color : longint;
  138. end;
  139. PointType = record
  140. x,y : integer;
  141. end;
  142. ViewPortType = record
  143. x1,y1,x2,y2 : integer;
  144. Clip : boolean;
  145. end;
  146. const
  147. fillpattern : array[0..12] of FillPatternType = (
  148. ($00,$00,$00,$00,$00,$00,$00,$00), { Hintergrundfarbe }
  149. ($ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff), { Vordergrundfarbe }
  150. ($ff,$ff,$00,$00,$ff,$ff,$00,$00), { === }
  151. ($01,$02,$04,$08,$10,$20,$40,$80), { /// }
  152. ($07,$0e,$1c,$38,$70,$e0,$c1,$83), { /// als dicke Linien }
  153. ($07,$83,$c1,$e0,$70,$38,$1c,$0e), { \\\ als dicke Linien }
  154. ($5a,$2d,$96,$4b,$a5,$d2,$69,$b4), { \ \\ \ }
  155. ($ff,$88,$88,$88,$ff,$88,$88,$88), { K„stchen }
  156. ($18,$24,$42,$81,$81,$42,$24,$18), { Rauten }
  157. ($cc,$33,$cc,$33,$cc,$33,$cc,$33), { "Mauermuster" }
  158. ($80,$00,$08,$00,$80,$00,$08,$00), { weit auseinanderliegende Punkte }
  159. ($88,$00,$22,$00,$88,$00,$22,$00), { dichte Punkte}
  160. (0,0,0,0,0,0,0,0) { benutzerdefiniert }
  161. );
  162. { ---------------------------------------------------------------------
  163. Function Declarations
  164. ---------------------------------------------------------------------}
  165. { Retrieving coordinates }
  166. function GetX: Integer;
  167. function GetY: Integer;
  168. { Pixel-oriented routines }
  169. procedure PutPixel(X, Y: Integer; Pixel: Word);
  170. function GetPixel(X, Y: Integer): Integer;
  171. { Line-oriented primitives }
  172. procedure LineTo(X, Y: Integer);
  173. procedure LineRel(Dx, Dy: Integer);
  174. procedure MoveTo(X, Y: Integer);
  175. procedure MoveRel(Dx, Dy: Integer);
  176. procedure Line(x1, y1, x2, y2: Integer);
  177. { Linearly bounded primitives }
  178. procedure Rectangle(x1, y1, x2, y2: Integer);
  179. procedure Bar(x1, y1, x2, y2: Integer);
  180. procedure Bar3D(x1, y1, x2, y2: Integer; Depth: Word; Top: Boolean);
  181. procedure FloodFill(X, Y: Integer; Border: Word);
  182. { Nonlinearly bounded primitives }
  183. procedure Arc(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  184. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  185. procedure Circle(X, Y: Integer; Radius: Word);
  186. procedure Ellipse(X, Y: Integer; StAngle, EndAngle: Word; XRadius, YRadius : Word);
  187. procedure FillEllipse(X, Y: Integer; XRadius, YRadius : Word);
  188. procedure SetAspectRatio(Xasp, Yasp: Word);
  189. procedure PieSlice(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  190. procedure Sector(X, Y: Integer; StAngle, EndAngle, XRadius, YRadius: Word);
  191. { Color routines }
  192. procedure SetBkColor(ColorNum: Word);
  193. procedure SetColor(Color: Word);
  194. Function GetBkColor : Word;
  195. Function GetColor : Word;
  196. function GetMaxColor : Word;
  197. function GetMaxX : Integer;
  198. function GetMAxY : Integer;
  199. function GetAspect: Real;
  200. procedure GetAspectRatio(var x,y : Word);
  201. { Graph clipping method }
  202. Procedure ClearViewPort;
  203. function GraphResult: Integer;
  204. { For compatibility }
  205. Procedure InitGraph (Var Driver,Mode : Integer;DriverPath : String);
  206. Procedure CloseGraph;
  207. const
  208. NoGraphics: Boolean = false;
  209. { VGA modes }
  210. GTEXT = 0; { Compatible with VGAlib v1.2 }
  211. G320x200x16 = 1;
  212. G640x200x16 = 2;
  213. G640x350x16 = 3;
  214. G640x480x16 = 4;
  215. G320x200x256 = 5;
  216. G320x240x256 = 6;
  217. G320x400x256 = 7;
  218. G360x480x256 = 8;
  219. G640x480x2 = 9;
  220. G640x480x256 = 10;
  221. G800x600x256 = 11;
  222. G1024x768x256 = 12;
  223. G1280x1024x256 = 13; { Additional modes. }
  224. G320x200x32K = 14;
  225. G320x200x64K = 15;
  226. G320x200x16M = 16;
  227. G640x480x32K = 17;
  228. G640x480x64K = 18;
  229. G640x480x16M = 19;
  230. G800x600x32K = 20;
  231. G800x600x64K = 21;
  232. G800x600x16M = 22;
  233. G1024x768x32K = 23;
  234. G1024x768x64K = 24;
  235. G1024x768x16M = 25;
  236. G1280x1024x32K = 26;
  237. G1280x1024x64K = 27;
  238. G1280x1024x16M = 28;
  239. G800x600x16 = 29;
  240. G1024x768x16 = 30;
  241. G1280x1024x16 = 31;
  242. G720x348x2 = 32; { Hercules emulation mode }
  243. G320x200x16M32 = 33; { 32-bit per pixel modes. }
  244. G640x480x16M32 = 34;
  245. G800x600x16M32 = 35;
  246. G1024x768x16M32 = 36;
  247. G1280x1024x16M32 = 37;
  248. { additional resolutions }
  249. G1152x864x16 = 38;
  250. G1152x864x256 = 39;
  251. G1152x864x32K = 40;
  252. G1152x864x64K = 41;
  253. G1152x864x16M = 42;
  254. G1152x864x16M32 = 43;
  255. G1600x1200x16 = 44;
  256. G1600x1200x256 = 45;
  257. G1600x1200x32K = 46;
  258. G1600x1200x64K = 47;
  259. G1600x1200x16M = 48;
  260. G1600x1200x16M32 = 49;
  261. GLASTMODE = 49;
  262. implementation
  263. {$I tagutils.inc}
  264. { ---------------------------------------------------------------------
  265. Types, constants and variables
  266. ---------------------------------------------------------------------}
  267. VAR GraphScr :pScreen;
  268. GraphWin :pWindow;
  269. CurrentRastPort : pRastPort;
  270. TheAspect : Real;
  271. GraphResultCode : Integer;
  272. Msg :pIntuiMessage;
  273. Ende :Boolean;
  274. var
  275. DrawDelta: TPoint;
  276. CurX, CurY: Integer;
  277. TheColor, TheFillColor: LongInt;
  278. IsVirtual: Boolean;
  279. ColorTable: array[0..15] of LongInt;
  280. TheFillPattern : FillPatternType;
  281. TheLineSettings : LineSettingsType;
  282. ThePalette : PaletteType;
  283. TheTextSettings : TextSettingsType;
  284. TheFillSettings : FillSettingsType;
  285. const
  286. BgiColors: array[0..15] of LongInt
  287. = ($000000, $000080, $008000, $008080,
  288. $800000, $800080, $808000, $C0C0C0,
  289. $808080, $0000FF, $00FF00, $00FFFF,
  290. $FF0000, $FF00FF, $FFFF00, $FFFFFF);
  291. const
  292. DoUseMarker: Boolean = true;
  293. TheMarker: Char = '~';
  294. TextColor: LongInt = 15;
  295. MarkColor: LongInt = 15;
  296. BackColor: LongInt = 0;
  297. FontWidth: Integer = 8;
  298. FontHeight: Integer = 8;
  299. var
  300. sHoriz, sVert: Word;
  301. { initialisierte Variablen }
  302. const
  303. SourcePage: Word = 0;
  304. DestPage: Word = 0;
  305. { Retrieves the capabilities for the current mode }
  306. const
  307. vmcImage = 1;
  308. vmcCopy = 2;
  309. vmcSaveRestore = 4;
  310. vmcBuffer = 8;
  311. vmcBackPut = 16;
  312. { ---------------------------------------------------------------------
  313. Graphics Vision Layer
  314. ---------------------------------------------------------------------}
  315. { Types and constants }
  316. var
  317. SizeX, SizeY: Word;
  318. { Font attributes }
  319. const
  320. ftNormal = 0;
  321. ftBold = 1;
  322. ftThin = 2;
  323. ftItalic = 4;
  324. var
  325. sFont, sColor:Word;
  326. sCharSpace: Integer;
  327. { Not used
  328. sMarker: Char;
  329. sAttr: Word; }
  330. { Bitmap utilities }
  331. type
  332. PBitmap = ^TBitmap;
  333. TBitmap = record
  334. Width, Height: Integer;
  335. Data: record end;
  336. end;
  337. const
  338. pbNone = 0;
  339. pbCopy = 1;
  340. pbClear = 2;
  341. procedure SetColors;
  342. begin
  343. SetRGB4(@GraphScr^.ViewPort, Black , 0,0,0);
  344. SetRGB4(@GraphScr^.ViewPort, Blue , 0,0,15);
  345. SetRGB4(@GraphScr^.ViewPort, Green , 0,15,0);
  346. SetRGB4(@GraphScr^.ViewPort, Cyan , 0,15,15);
  347. SetRGB4(@GraphScr^.ViewPort, Red , 15,0,0);
  348. SetRGB4(@GraphScr^.ViewPort, Magenta , 15,0,15);
  349. SetRGB4(@GraphScr^.ViewPort, Brown , 6,2,0);
  350. SetRGB4(@GraphScr^.ViewPort, LightGray, 13,13,13);
  351. SetRGB4(@GraphScr^.ViewPort, DarkGray , 4,4,4);
  352. SetRGB4(@GraphScr^.ViewPort, LightBlue, 5,5,5);
  353. SetRGB4(@GraphScr^.ViewPort, LightGreen ,9,15,1);
  354. SetRGB4(@GraphScr^.ViewPort, LightRed ,14,5,0);
  355. SetRGB4(@GraphScr^.ViewPort, LightMagenta ,0,15,8);
  356. SetRGB4(@GraphScr^.ViewPort, Yellow ,15,15,0);
  357. SetRGB4(@GraphScr^.ViewPort, White ,15,15,15);
  358. end;
  359. { ---------------------------------------------------------------------
  360. Real graph implementation
  361. ---------------------------------------------------------------------}
  362. function GraphResult: Integer;
  363. begin
  364. GraphResult := GraphResultCode;
  365. end;
  366. Procedure ClearViewPort;
  367. begin
  368. SetRast(CurrentRastPort,Black);
  369. end;
  370. function GetX: Integer;
  371. begin
  372. GetX := CurX;
  373. end;
  374. function GetY: Integer;
  375. begin
  376. GetY := CurY;
  377. end;
  378. function GetAspect: Real;
  379. begin
  380. GetAspect := GetMaxY/GetMaxX;
  381. end;
  382. procedure GetAspectRatio(var x,y : Word);
  383. begin
  384. x := GetMaxX;
  385. y := GetMaxY;
  386. end;
  387. { Pixel-oriented routines }
  388. procedure PutPixel(x,y : Integer; Pixel : Word);
  389. begin
  390. SetAPen(CurrentRastPort,Pixel);
  391. WritePixel(CurrentRastPort,x,y);
  392. CurX := x;
  393. CurY := y;
  394. end;
  395. function GetPixel(X, Y: Integer): Integer;
  396. begin
  397. GetPixel := ReadPixel(CurrentRastPort,X,Y);
  398. end;
  399. { Line-oriented primitives }
  400. procedure LineTo(X, Y: Integer);
  401. begin
  402. Draw(CurrentRastPort,X,Y);
  403. CurX := X;
  404. CurY := Y;
  405. end;
  406. procedure LineRel(Dx, Dy: Integer);
  407. begin
  408. CurX := CurX + Dx;
  409. CurY := CurY + Dy;
  410. Draw(CurrentRastPort, Curx, CurY);
  411. end;
  412. procedure MoveTo(X, Y: Integer);
  413. begin
  414. Move(CurrentRastPort, X , Y);
  415. CurX := X;
  416. CurY := Y;
  417. end;
  418. procedure MoveRel(Dx, Dy: Integer);
  419. begin
  420. CurX := CurX + Dx;
  421. CurY := CurY + Dy;
  422. Move(CurrentRastPort, Curx, CurY);
  423. end;
  424. procedure Line(x1,y1,x2,y2: Integer);
  425. begin
  426. Move(CurrentRastPort,x1,y1);
  427. Draw(CurrentRastPort,x2,y2);
  428. Move(CurrentRastPort,CurX, CurY);
  429. end;
  430. procedure Rectangle(x1, y1, x2, y2: Integer);
  431. begin
  432. Move(CurrentRastPort, x1, y1);
  433. Draw(CurrentRastPort, x2, y1);
  434. Draw(CurrentRastPort, x2, y2);
  435. Draw(CurrentRastPort, x1, y2);
  436. Draw(CurrentRastPort, x1, y1);
  437. CurX := x1;
  438. CurY := y1;
  439. end;
  440. procedure Bar(x1, y1, x2, y2: Integer);
  441. begin
  442. RectFill(CurrentRastPort, x1, y1, x2, y2);
  443. CurX := x1;
  444. CurY := y1;
  445. end;
  446. procedure Bar3D(x1, y1, x2, y2: Integer; Depth: Word; Top: Boolean);
  447. begin
  448. Bar(x1,y1,x2,y2);
  449. Rectangle(x1,y1,x2,y2);
  450. if top then begin
  451. Moveto(x1,y1);
  452. Lineto(x1+depth,y1-depth);
  453. Lineto(x2+depth,y1-depth);
  454. Lineto(x2,y1);
  455. end;
  456. Moveto(x2+depth,y1-depth);
  457. Lineto(x2+depth,y2-depth);
  458. Lineto(x2,y2);
  459. end;
  460. procedure FloodFill(X, Y: Integer; Border: Word);
  461. begin
  462. end;
  463. Var LastArcCoords : ArcCoordsType;
  464. procedure SetArcCoords (X,y,xradius,yradius,Stangle,endangle : integer);
  465. begin
  466. LastArcCoords.X:=X;
  467. LastArccOords.y:=y;
  468. Lastarccoords.xstart:=x+round(xradius*cos(stangle*pi/180));
  469. Lastarccoords.ystart:=y-round(yradius*sin(stangle*pi/180));
  470. LastArccoords.xend:=x+round(xradius*cos(endangle*pi/180));
  471. LastArccoords.yend:=y-round(yradius*sin(endangle*pi/180));
  472. end;
  473. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  474. begin
  475. ArcCoords:=LastArcCoords;
  476. end;
  477. procedure Arc(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  478. begin
  479. Ellipse (X,y,stangle,endangle,Radius,radius);
  480. end;
  481. procedure Circle(X, Y: Integer; Radius: Word);
  482. begin
  483. DrawEllipse(CurrentRastPort, x, y, Round(Radius * TheAspect), Radius);
  484. end;
  485. procedure Ellipse(X, Y: Integer;
  486. StAngle, EndAngle: Word; XRadius, YRadius : Word);
  487. Var I : longint;
  488. tmpang : real;
  489. begin
  490. SetArcCoords (X,Y,xradius,yradius,Stangle,EndAngle);
  491. For i:= StAngle To EndAngle Do
  492. Begin
  493. tmpAng:= i*Pi/180;
  494. curX:= X + Round (xRadius*Cos (tmpAng));
  495. curY:= Y - Round (YRadius*Sin (tmpAng));
  496. PutPixel (curX, curY, TheColor);
  497. End;
  498. end;
  499. procedure FillEllipse(X, Y: Integer; XRadius, YRadius : Word);
  500. Var I,tmpcolor : longint;
  501. tmpang : real;
  502. tmpx,tmpy : Integer;
  503. begin
  504. tmpcolor:=Thecolor;
  505. SetColor(TheFillColor);
  506. For i:= 0 to 180 Do
  507. Begin
  508. tmpAng:= i*Pi/180;
  509. curX:= Round (xRadius*Cos (tmpAng));
  510. curY:= Round (YRadius*Sin (tmpAng));
  511. tmpX:= X - curx;
  512. tmpy:= Y + cury;
  513. curx:=x+curx;
  514. cury:=y-cury;
  515. Line (curX, curY,tmpx,tmpy);
  516. PutPixel (curx,cury,tmpcolor);
  517. PutPixel (tmpx,tmpy,tmpcolor);
  518. End;
  519. SetColor(tmpcolor);
  520. end;
  521. procedure SetAspectRatio(Xasp, Yasp: Word);
  522. begin
  523. //!! Needs implementing.
  524. end;
  525. procedure PieSlice(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  526. Begin
  527. sector (x,y,stangle,endangle,radius,radius);
  528. end;
  529. procedure Sector(X, Y: Integer;
  530. StAngle, EndAngle, XRadius, YRadius: Word);
  531. Var I,tmpcolor : longint;
  532. tmpang : real;
  533. ac : arccoordstype;
  534. begin
  535. tmpcolor:=Thecolor;
  536. SetColor(TheFillColor);
  537. For i:= stangle to endangle Do
  538. Begin
  539. tmpAng:= i*Pi/180;
  540. curX:= x+Round (xRadius*Cos (tmpAng));
  541. curY:= y-Round (YRadius*Sin (tmpAng));
  542. Line (x,y,curX, curY);
  543. PutPixel (curx,cury,tmpcolor);
  544. End;
  545. SetColor(tmpcolor);
  546. getarccoords(ac);
  547. Line (x,y,ac.xstart,ac.ystart);
  548. Line (x,y,ac.xend,ac.yend);
  549. end;
  550. { Color routines
  551. }
  552. procedure SetBkColor(ColorNum: Word);
  553. begin
  554. SetBPen(CurrentRastPort, ColorNum);
  555. BackColor := ColorNum;
  556. end;
  557. Function GetBkColor : Word;
  558. begin
  559. GetBkColor:=BackColor;
  560. end;
  561. Function GetColor : Word;
  562. begin
  563. GetColor:=TheColor;
  564. end;
  565. procedure SetColor(color : Word);
  566. begin
  567. SetAPen(CurrentRastPort,color);
  568. TheColor := color;
  569. end;
  570. function GetMaxColor: word;
  571. begin
  572. GetMaxColor := 15;
  573. end;
  574. function GetMaxX: Integer;
  575. begin
  576. GetMaxX := GraphWin^.Width;
  577. end;
  578. function GetMaxY: Integer;
  579. begin
  580. GetMaxY := GraphWin^.Height;
  581. end;
  582. Procedure InitGraph (Var Driver,Mode : Integer;DriverPath : String);
  583. var
  584. thetags : array[0..3] of tTagItem;
  585. BEGIN
  586. GraphResultCode := grOK;
  587. GfxBase := OpenLibrary(GRAPHICSNAME,0);
  588. if GfxBase = nil then begin
  589. GraphResultCode := grNoInitGraph;
  590. Exit;
  591. end;
  592. GraphScr:=Nil; GraphWin:=Nil;
  593. { Will open an hires interlace screen, if you
  594. want just an hires screen change HIRESLACE_KEY
  595. to HIRES_KEY
  596. }
  597. thetags[0] := TagItem(SA_Depth, 4);
  598. thetags[1] := TagItem(SA_DisplayID, HIRESLACE_KEY);
  599. thetags[2].ti_Tag := TAG_END;
  600. GraphScr := OpenScreenTagList(NIL,@thetags);
  601. If GraphScr=Nil Then begin
  602. GraphResultCode := grNoInitGraph;
  603. Exit;
  604. end;
  605. thetags[0] := TagItem(WA_Flags, WFLG_BORDERLESS);
  606. thetags[1] := TagItem(WA_IDCMP, IDCMP_MOUSEBUTTONS);
  607. thetags[2] := TagItem(WA_CustomScreen, Longint(GraphScr));
  608. thetags[3].ti_Tag := TAG_DONE;
  609. GraphWin:=OpenWindowTagList(Nil, @thetags);
  610. If GraphWin=Nil Then CloseGraph;
  611. CurrentRastPort := GraphWin^.RPort;
  612. SetColors;
  613. TheAspect := GetAspect;
  614. END;
  615. PROCEDURE CloseGraph;
  616. BEGIN
  617. { Ende:=false;
  618. Repeat
  619. Msg:=pIntuiMessage(GetMsg(GraphWin^.UserPort));
  620. If Msg<>Nil Then Begin
  621. ReplyMsg(Pointer(Msg));
  622. Ende:=true;
  623. End;
  624. Until Ende;}
  625. If GraphWin<>Nil Then
  626. CloseWindow(GraphWin);
  627. If (GraphScr<>Nil) then CloseScreen(GraphScr);
  628. if GfxBase <> nil then CloseLibrary(GfxBase);
  629. Halt;
  630. END;
  631. begin
  632. CurX := 0;
  633. CurY := 0;
  634. end.
  635. $Log$
  636. Revision 1.3 2002-09-07 16:01:16 peter
  637. * old logs removed and tabs fixed
  638. }