graph.pp 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  1. unit Graph;
  2. { *********************************************************************
  3. $Id$
  4. Copyright 1997,1998 Matthias K"oppe <[email protected]>
  5. This library is free software in the sense of the GNU Library GPL;
  6. see `License Conditions' below.
  7. Info:
  8. This unit provides the functions of Borland's Graph unit for linux,
  9. it uses the SVGAlib to do the actual work, so you must have svgalib
  10. on your system
  11. This version requires Free Pascal 0.99.5 or higher.
  12. Large parts have not yet been implemented or tested.
  13. History:
  14. Date Version Who Comments
  15. ---------- -------- ------- -------------------------------------
  16. 25-Sep-97 0.1 mkoeppe Initial multi-target version.
  17. 05-Oct-97 0.1.1 mkoeppe Linux: Added mouse use. Improved clipping.
  18. Added bitmap functions.
  19. ??-Oct-97 0.1.2 mkoeppe Fixed screenbuf functions.
  20. 07-Feb-98 0.1.3 mkoeppe Fixed a clipping bug in DOS target.
  21. 12-Apr-98 0.1.4 mkoeppe Linux: Using Michael's re-worked SVGALIB
  22. interface; prepared for FPC 0.99.5; removed
  23. dependencies.
  24. 15-Apr-98 0.1.5 michael Renamed to graph, inserted needed SVGlib
  25. declarations here so it can be used independently
  26. of the svgalib unit. Removed things that are NOT
  27. part of Borland's Graph from the unit interface.
  28. License Conditions:
  29. This library is free software; you can redistribute it and/or
  30. modify it under the terms of the GNU Library General Public
  31. License as published by the Free Software Foundation; either
  32. version 2 of the License, or (at your option) any later version.
  33. This library is distributed in the hope that it will be useful,
  34. but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  36. Library General Public License for more details.
  37. You should have received a copy of the GNU Library General Public
  38. License along with this library; if not, write to the Free
  39. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  40. *********************************************************************}
  41. {
  42. Functions not currently implemented :
  43. -------------------------------------
  44. SetWriteMode
  45. SetLineStyle
  46. SetFillPattern
  47. SetUserCharSize
  48. SetTextStyle
  49. FillPoly
  50. FloodFill
  51. GetArcCoords
  52. Arc
  53. SetAspectRatio
  54. PieSlice
  55. Sector
  56. (please remove what you implement fom this list)
  57. }
  58. interface
  59. { ---------------------------------------------------------------------
  60. Constants
  61. ---------------------------------------------------------------------}
  62. const
  63. NormalPut = 0;
  64. CopyPut = 0;
  65. XORPut = 1;
  66. ORPut = 2;
  67. ANDPut = 3;
  68. NotPut = 4;
  69. BackPut = 8;
  70. Black = 0;
  71. Blue = 1;
  72. Green = 2;
  73. Cyan = 3;
  74. Red = 4;
  75. Magenta = 5;
  76. Brown = 6;
  77. LightGray = 7;
  78. DarkGray = 8;
  79. LightBlue = 9;
  80. LightGreen = 10;
  81. LightCyan = 11;
  82. LightRed = 12;
  83. LightMagenta = 13;
  84. Yellow = 14;
  85. White = 15;
  86. Border = 16;
  87. SolidLn = 0;
  88. DottedLn = 1;
  89. CenterLn = 2;
  90. DashedLn = 3;
  91. UserBitLn = 4;
  92. EmptyFill = 0;
  93. SolidFill = 1;
  94. LineFill = 2;
  95. LtSlashFill = 3;
  96. SlashFill = 4;
  97. BkSlashFill = 5;
  98. LtBkSlashFill = 6;
  99. HatchFill = 7;
  100. XHatchFill = 8;
  101. InterleaveFill = 9;
  102. WideDotFill = 10;
  103. CloseDotFill = 11;
  104. UserFill = 12;
  105. NormWidth = 1;
  106. ThickWidth = 3;
  107. const
  108. LeftText = 0;
  109. CenterText = 1;
  110. RightText = 2;
  111. BottomText = 0;
  112. TopText = 2;
  113. BaseLine = 3;
  114. LeadLine = 4;
  115. { ---------------------------------------------------------------------
  116. Types
  117. ---------------------------------------------------------------------}
  118. Type
  119. FillPatternType = array[1..8] of byte;
  120. ArcCoordsType = record
  121. x,y : integer;
  122. xstart,ystart : integer;
  123. xend,yend : integer;
  124. end;
  125. RGBColor = record
  126. r,g,b,i : byte;
  127. end;
  128. PaletteType = record
  129. Size : integer;
  130. Colors : array[0..767]of Byte;
  131. end;
  132. LineSettingsType = record
  133. linestyle : word;
  134. pattern : word;
  135. thickness : word;
  136. end;
  137. TextSettingsType = record
  138. font : word;
  139. direction : word;
  140. charsize : word;
  141. horiz : word;
  142. vert : word;
  143. end;
  144. FillSettingsType = record
  145. pattern : word;
  146. color : longint;
  147. end;
  148. PointType = record
  149. x,y : integer;
  150. end;
  151. ViewPortType = record
  152. x1,y1,x2,y2 : integer;
  153. Clip : boolean;
  154. end;
  155. const
  156. fillpattern : array[0..12] of FillPatternType = (
  157. ($00,$00,$00,$00,$00,$00,$00,$00), { Hintergrundfarbe }
  158. ($ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff), { Vordergrundfarbe }
  159. ($ff,$ff,$00,$00,$ff,$ff,$00,$00), { === }
  160. ($01,$02,$04,$08,$10,$20,$40,$80), { /// }
  161. ($07,$0e,$1c,$38,$70,$e0,$c1,$83), { /// als dicke Linien }
  162. ($07,$83,$c1,$e0,$70,$38,$1c,$0e), { \\\ als dicke Linien }
  163. ($5a,$2d,$96,$4b,$a5,$d2,$69,$b4), { \ \\ \ }
  164. ($ff,$88,$88,$88,$ff,$88,$88,$88), { K„stchen }
  165. ($18,$24,$42,$81,$81,$42,$24,$18), { Rauten }
  166. ($cc,$33,$cc,$33,$cc,$33,$cc,$33), { "Mauermuster" }
  167. ($80,$00,$08,$00,$80,$00,$08,$00), { weit auseinanderliegende Punkte }
  168. ($88,$00,$22,$00,$88,$00,$22,$00), { dichte Punkte}
  169. (0,0,0,0,0,0,0,0) { benutzerdefiniert }
  170. );
  171. { ---------------------------------------------------------------------
  172. Function Declarations
  173. ---------------------------------------------------------------------}
  174. { Retrieving coordinates }
  175. function GetX: Integer;
  176. function GetY: Integer;
  177. { Pixel-oriented routines }
  178. procedure PutPixel(X, Y: Integer; Pixel: Word);
  179. function GetPixel(X, Y: Integer): Word;
  180. { Line-oriented primitives }
  181. procedure SetWriteMode(WriteMode: Integer);
  182. procedure LineTo(X, Y: Integer);
  183. procedure LineRel(Dx, Dy: Integer);
  184. procedure MoveTo(X, Y: Integer);
  185. procedure MoveRel(Dx, Dy: Integer);
  186. procedure Line(x1, y1, x2, y2: Integer);
  187. procedure SetLineStyle(LineStyle: Word; Pattern: Word; Thickness: Word);
  188. { Linearly bounded primitives }
  189. procedure Rectangle(x1, y1, x2, y2: Integer);
  190. procedure Bar(x1, y1, x2, y2: Integer);
  191. procedure Bar3D(x1, y1, x2, y2: Integer; Depth: Word; Top: Boolean);
  192. procedure DrawPoly(NumPoints: Word; var PolyPoints);
  193. procedure FillPoly(NumPoints: Word; var PolyPoints);
  194. procedure SetFillStyle(Pattern: Word; Color: Word);
  195. procedure SetFillPattern(Pattern: FillPatternType; Color: Word);
  196. procedure FloodFill(X, Y: Integer; Border: Word);
  197. { Nonlinearly bounded primitives }
  198. procedure Arc(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  199. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  200. procedure Circle(X, Y: Integer; Radius: Word);
  201. procedure Ellipse(X, Y: Integer; StAngle, EndAngle: Word; XRadius, YRadius : Word);
  202. procedure FillEllipse(X, Y: Integer; XRadius, YRadius : Word);
  203. procedure SetAspectRatio(Xasp, Yasp: Word);
  204. procedure PieSlice(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  205. procedure Sector(X, Y: Integer; StAngle, EndAngle, XRadius, YRadius: Word);
  206. { Color routines }
  207. procedure SetBkColor(ColorNum: Word);
  208. procedure SetColor(Color: Word);
  209. { Bitmap utilities }
  210. procedure GetImage(x1, y1, x2, y2: Integer; var BitMap);
  211. procedure PutImage(X, Y: Integer; var BitMap; BitBlt: Word);
  212. function ImageSize(x1, y1, x2, y2: Integer): LongInt;
  213. { Text routines}
  214. procedure OutText(TextString: string);
  215. procedure OutTextXY(X, Y: Integer; TextString: string);
  216. procedure SetTextJustify(Horiz, Vert: Word);
  217. procedure SetTextStyle(Font, Direction: Word; CharSize: Word);
  218. procedure SetUserCharSize(MultX, DivX, MultY, DivY: Word);
  219. { Graph clipping method }
  220. procedure SetViewPort(x1, y1, x2, y2: Integer; Clip: Boolean);
  221. { Init/Done }
  222. procedure InitVideo;
  223. procedure DoneVideo;
  224. { Other }
  225. function GetResX: Integer;
  226. function GetResY: Integer;
  227. function GetAspect: Real;
  228. const
  229. NoGraphics: Boolean = false;
  230. implementation
  231. uses Objects, Linux;
  232. { ---------------------------------------------------------------------
  233. SVGA bindings.
  234. ---------------------------------------------------------------------}
  235. { Link with VGA, gl and c libraries }
  236. {$linklib vga}
  237. {$linklib gl}
  238. {$linklib c}
  239. { Constants }
  240. const
  241. { VGA modes }
  242. TEXT = 0; { Compatible with VGAlib v1.2 }
  243. G320x200x16 = 1;
  244. G640x200x16 = 2;
  245. G640x350x16 = 3;
  246. G640x480x16 = 4;
  247. G320x200x256 = 5;
  248. G320x240x256 = 6;
  249. G320x400x256 = 7;
  250. G360x480x256 = 8;
  251. G640x480x2 = 9;
  252. G640x480x256 = 10;
  253. G800x600x256 = 11;
  254. G1024x768x256 = 12;
  255. G1280x1024x256 = 13; { Additional modes. }
  256. G320x200x32K = 14;
  257. G320x200x64K = 15;
  258. G320x200x16M = 16;
  259. G640x480x32K = 17;
  260. G640x480x64K = 18;
  261. G640x480x16M = 19;
  262. G800x600x32K = 20;
  263. G800x600x64K = 21;
  264. G800x600x16M = 22;
  265. G1024x768x32K = 23;
  266. G1024x768x64K = 24;
  267. G1024x768x16M = 25;
  268. G1280x1024x32K = 26;
  269. G1280x1024x64K = 27;
  270. G1280x1024x16M = 28;
  271. G800x600x16 = 29;
  272. G1024x768x16 = 30;
  273. G1280x1024x16 = 31;
  274. G720x348x2 = 32; { Hercules emulation mode }
  275. G320x200x16M32 = 33; { 32-bit per pixel modes. }
  276. G640x480x16M32 = 34;
  277. G800x600x16M32 = 35;
  278. G1024x768x16M32 = 36;
  279. G1280x1024x16M32 = 37;
  280. { additional resolutions }
  281. G1152x864x16 = 38;
  282. G1152x864x256 = 39;
  283. G1152x864x32K = 40;
  284. G1152x864x64K = 41;
  285. G1152x864x16M = 42;
  286. G1152x864x16M32 = 43;
  287. G1600x1200x16 = 44;
  288. G1600x1200x256 = 45;
  289. G1600x1200x32K = 46;
  290. G1600x1200x64K = 47;
  291. G1600x1200x16M = 48;
  292. G1600x1200x16M32 = 49;
  293. GLASTMODE = 49;
  294. { Text }
  295. WRITEMODE_OVERWRITE = 0;
  296. WRITEMODE_MASKED = 1;
  297. FONT_EXPANDED = 0;
  298. FONT_COMPRESSED = 2;
  299. { Types }
  300. type
  301. pvga_modeinfo = ^vga_modeinfo;
  302. vga_modeinfo = record
  303. width,
  304. height,
  305. bytesperpixel,
  306. colors,
  307. linewidth, { scanline width in bytes }
  308. maxlogicalwidth, { maximum logical scanline width }
  309. startaddressrange, { changeable bits set }
  310. maxpixels, { video memory / bytesperpixel }
  311. haveblit, { mask of blit functions available }
  312. flags: Longint; { other flags }
  313. { Extended fields: }
  314. chiptype, { Chiptype detected }
  315. memory, { videomemory in KB }
  316. linewidth_unit: Longint; { Use only a multiple of this as parameter for
  317. set_displaystart }
  318. linear_aperture: PChar; { points to mmap secondary mem aperture of card }
  319. aperture_size: Longint; { size of aperture in KB if size>=videomemory.}
  320. set_aperture_page: procedure (page: Longint);
  321. { if aperture_size<videomemory select a memory page }
  322. extensions: Pointer; { points to copy of eeprom for mach32 }
  323. { depends from actual driver/chiptype.. etc. }
  324. end;
  325. PGraphicsContext = ^TGraphicsContext;
  326. TGraphicsContext = record
  327. ModeType: Byte;
  328. ModeFlags: Byte;
  329. Dummy: Byte;
  330. FlipPage: Byte;
  331. Width: LongInt;
  332. Height: LongInt;
  333. BytesPerPixel: LongInt;
  334. Colors: LongInt;
  335. BitsPerPixel: LongInt;
  336. ByteWidth: LongInt;
  337. VBuf: pointer;
  338. Clip: LongInt;
  339. ClipX1: LongInt;
  340. ClipY1: LongInt;
  341. ClipX2: LongInt;
  342. ClipY2: LongInt;
  343. ff: pointer;
  344. end;
  345. { vga functions }
  346. function vga_init: Longint; Cdecl; External;
  347. function vga_getdefaultmode: Longint; Cdecl; External;
  348. function vga_hasmode(mode: Longint): Boolean; Cdecl; External;
  349. function vga_getmodeinfo(mode: Longint): pvga_modeinfo; Cdecl; External;
  350. function vga_setmode(mode: Longint): Longint; Cdecl; External;
  351. { gl functions }
  352. procedure gl_setpixel(x, y, c: LongInt); Cdecl; External;
  353. function gl_getpixel(x, y: LongInt): LongInt; cdecl; external;
  354. procedure gl_line(x1, y1, x2, y2, c: LongInt); Cdecl; External;
  355. procedure gl_fillbox(x, y, w, h, c: LongInt); Cdecl; External;
  356. procedure gl_circle(x, y, r, c: LongInt ); Cdecl; External;
  357. procedure gl_getbox(x, y, w, h: LongInt; dp: pointer); Cdecl; External;
  358. procedure gl_putbox(x, y, w, h: LongInt; dp: pointer); Cdecl; External;
  359. procedure gl_disableclipping; Cdecl; External;
  360. procedure gl_enableclipping; Cdecl; External;
  361. procedure gl_putboxpart(x, y, w, h, bw, bh: LongInt; b: pointer; xo, yo: LongInt); Cdecl; External;
  362. function gl_rgbcolor(r, g, b: LongInt): LongInt; Cdecl; External;
  363. function gl_setcontextvga(m: LongInt): LongInt; Cdecl; External;
  364. function gl_allocatecontext: PGraphicsContext; Cdecl; External;
  365. procedure gl_getcontext(gc: PGraphicsContext); Cdecl; External;
  366. procedure gl_setrgbpalette; Cdecl; External;
  367. procedure gl_freecontext(gc: PGraphicsContext); Cdecl; External;
  368. procedure gl_setclippingwindow(x1, y1, x2, y2: LongInt); Cdecl; External;
  369. procedure gl_setwritemode(wm: LongInt); Cdecl; External;
  370. procedure gl_setfontcolors(bg, fg: LongInt); Cdecl; External;
  371. procedure gl_writen(x, y, n: LongInt; s: PChar); Cdecl; External;
  372. procedure gl_setfont(fw, fh: LongInt; fdp: pointer); Cdecl; External;
  373. procedure gl_copyboxfromcontext(var gc: TGraphicsContext; x1, y1, w, h, x2, y2: LongInt); Cdecl; External;
  374. procedure gl_setcontext(gc: PGraphicsContext); Cdecl; External;
  375. function gl_setcontextvgavirtual(m: LongInt): LongInt; cdecl; external;
  376. procedure gl_font8x8; Cdecl; External;
  377. { ---------------------------------------------------------------------
  378. Types, constants and variables
  379. ---------------------------------------------------------------------}
  380. var
  381. DrawDelta: TPoint;
  382. CurX, CurY: Integer;
  383. TheColor, TheFillColor: LongInt;
  384. IsVirtual: Boolean;
  385. PhysicalScreen, BackScreen: PGraphicsContext;
  386. ColorTable: array[0..15] of LongInt;
  387. const
  388. BgiColors: array[0..15] of LongInt
  389. = ($000000, $000080, $008000, $008080,
  390. $800000, $800080, $808000, $C0C0C0,
  391. $808080, $0000FF, $00FF00, $00FFFF,
  392. $FF0000, $FF00FF, $FFFF00, $FFFFFF);
  393. const
  394. DoUseMarker: Boolean = true;
  395. TheMarker: Char = '~';
  396. TextColor: LongInt = 15;
  397. MarkColor: LongInt = 15;
  398. BackColor: LongInt = 0;
  399. FontWidth: Integer = 8;
  400. FontHeight: Integer = 8;
  401. var
  402. sHoriz, sVert: Word;
  403. { initialisierte Variablen }
  404. const
  405. SourcePage: Word = 0;
  406. DestPage: Word = 0;
  407. { Retrieves the capabilities for the current mode }
  408. const
  409. vmcImage = 1;
  410. vmcCopy = 2;
  411. vmcSaveRestore = 4;
  412. vmcBuffer = 8;
  413. vmcBackPut = 16;
  414. { ---------------------------------------------------------------------
  415. Graphics Vision Layer
  416. ---------------------------------------------------------------------}
  417. { Types and constants }
  418. var
  419. SizeX, SizeY: Word;
  420. { Draw origin and clipping rectangle }
  421. var
  422. DrawOrigin: TPoint;
  423. ClipRect: TRect;
  424. MetaClipRect: TRect;
  425. MetaOrigin: TPoint;
  426. { Font attributes }
  427. const
  428. ftNormal = 0;
  429. ftBold = 1;
  430. ftThin = 2;
  431. ftItalic = 4;
  432. var
  433. sFont, sColor:Word;
  434. sCharSpace: Integer;
  435. sMarker: Char;
  436. sAttr: Word;
  437. { Windows-style text metric }
  438. type
  439. PTextMetric = ^TTextMetric;
  440. TTextMetric = record
  441. tmHeight: Integer;
  442. tmAscent: Integer;
  443. tmDescent: Integer;
  444. tmInternalLeading: Integer;
  445. tmExternalLeading: Integer;
  446. tmAveCharWidth: Integer;
  447. tmMaxCharWidth: Integer;
  448. tmWeight: Integer;
  449. tmItalic: Byte;
  450. tmUnderlined: Byte;
  451. tmStruckOut: Byte;
  452. tmFirstChar: Byte;
  453. tmLastChar: Byte;
  454. tmDefaultChar: Byte;
  455. tmBreakChar: Byte;
  456. tmPitchAndFamily: Byte;
  457. tmCharSet: Byte;
  458. tmOverhang: Integer;
  459. tmDigitizedAspectX: Integer;
  460. tmDigitizedAspectY: Integer;
  461. end;
  462. { Bitmap utilities }
  463. type
  464. PBitmap = ^TBitmap;
  465. TBitmap = record
  466. Width, Height: Integer;
  467. Data: record end;
  468. end;
  469. { Storing screen regions }
  470. type
  471. TVgaBuf = record
  472. Bounds: TRect;
  473. Mem: Word;
  474. Size: Word;
  475. end;
  476. const
  477. pbNone = 0;
  478. pbCopy = 1;
  479. pbClear = 2;
  480. type
  481. PScreenBuf = ^TScreenBuf;
  482. TScreenBuf = record
  483. Mode: Word;
  484. Rect: TRect;
  485. Size: LongInt;
  486. Info: LongInt
  487. end;
  488. { Procedures and functions }
  489. procedure SetColors;
  490. var
  491. i: Integer;
  492. begin
  493. for i:=0 to 15 do
  494. ColorTable[i] := gl_rgbcolor(BgiColors[i] shr 16,
  495. (BgiColors[i] shr 8) and 255,
  496. BgiColors[i] and 255)
  497. end;
  498. procedure InitVideo;
  499. var
  500. VgaMode: Integer;
  501. ModeInfo: pvga_modeinfo;
  502. begin
  503. if NoGraphics
  504. then begin
  505. SizeX := 640;
  506. SizeY := 480
  507. end
  508. else begin
  509. VgaMode := vga_getdefaultmode;
  510. if (VgaMode = -1) then VgaMode := G320X200X256;
  511. if (not vga_hasmode(VgaMode))
  512. then begin
  513. WriteLn('BGI: Mode not available.');
  514. Halt(1)
  515. end;
  516. ModeInfo := vga_getmodeinfo(VgaMode);
  517. {IsVirtual := (ModeInfo^.colors = 16) or (ModeInfo^.flags and IS_MODEX <> 0);}
  518. IsVirtual := true;
  519. { We always want a back screen (for buffering). }
  520. if IsVirtual
  521. then begin
  522. { Create virtual screen }
  523. gl_setcontextvgavirtual(VgaMode);
  524. BackScreen := gl_allocatecontext;
  525. gl_getcontext(BackScreen)
  526. end;
  527. vga_setmode(VgaMode);
  528. gl_setcontextvga(VgaMode); { Physical screen context. }
  529. PhysicalScreen := gl_allocatecontext;
  530. gl_getcontext(PhysicalScreen);
  531. if (PhysicalScreen^.colors = 256) then gl_setrgbpalette;
  532. SetColors;
  533. SizeX := PhysicalScreen^.Width;
  534. SizeY := PhysicalScreen^.Height
  535. end
  536. end;
  537. procedure DoneVideo;
  538. begin
  539. if not NoGraphics
  540. then begin
  541. if IsVirtual then gl_freecontext(BackScreen);
  542. vga_setmode(TEXT)
  543. end
  544. end;
  545. procedure SetDelta;
  546. begin
  547. if ClipRect.Empty
  548. then begin
  549. DrawDelta.X := 10000;
  550. DrawDelta.Y := 10000;
  551. end
  552. else begin
  553. DrawDelta.X := DrawOrigin.X;
  554. DrawDelta.y := DrawOrigin.y
  555. end
  556. end;
  557. procedure SetDrawOrigin(x, y: Integer);
  558. begin
  559. DrawOrigin.x := x;
  560. DrawOrigin.y := y;
  561. SetDelta;
  562. end;
  563. procedure SetDrawOriginP(var P: TPoint);
  564. begin
  565. SetDrawOrigin(P.x, P.y)
  566. end;
  567. procedure SetClipRect(x1, y1, x2, y2: Integer);
  568. begin
  569. Cliprect.Assign(x1, y1, x2, y2);
  570. if not NoGraphics
  571. then begin
  572. if ClipRect.Empty
  573. then gl_setclippingwindow(0, 0, 0, 0)
  574. else gl_setclippingwindow(x1, y1, x2 - 1, y2 - 1);
  575. {gl_enableclipping(0);}
  576. end;
  577. SetDelta
  578. end;
  579. procedure SetClipRectR(var R: TRect);
  580. begin
  581. SetClipRect(R.A.X, R.A.Y, R.B.X, R.B.Y);
  582. end;
  583. procedure SetMetaOrigin(x, y: Integer);
  584. begin
  585. MetaOrigin.x := x;
  586. MetaOrigin.y := y
  587. end;
  588. procedure SetMetaOriginP(P: TPoint);
  589. begin
  590. SetMetaOrigin(P.x, P.y)
  591. end;
  592. procedure SetMetaClipRect(x1, y1, x2, y2: Integer);
  593. begin
  594. MetaCliprect.Assign(x1, y1, x2, y2)
  595. end;
  596. procedure SetMetaClipRectR(var R: TRect);
  597. begin
  598. MetaCliprect := R
  599. end;
  600. function GetBuffer(Size: Word): pointer;
  601. begin
  602. { No metafiling available. }
  603. GetBuffer := nil
  604. end;
  605. Procedure HoriLine(x1,y1,x2: Integer);
  606. begin
  607. Line(x1, y1, x2, y1)
  608. end;
  609. Procedure VertLine(x1,y1,y2: Integer);
  610. begin
  611. Line(x1, y1, x1, y2)
  612. end;
  613. procedure FillCircle(xm, ym, r: Integer);
  614. begin
  615. FillEllipse(xm, ym, r, r)
  616. end;
  617. { Text routines }
  618. function TextWidth(s: string): Integer;
  619. var
  620. i: Integer;
  621. begin
  622. if DoUseMarker
  623. then begin
  624. For i := Length(s) downto 1 do
  625. If s[i] = TheMarker then Delete(s, i, 1);
  626. If s = ''
  627. then TextWidth := 0
  628. else TextWidth := Length(s) * FontWidth
  629. end
  630. else TextWidth := Length(s) * FontWidth
  631. end;
  632. function TextHeight(s: string): Integer;
  633. begin
  634. TextHeight := FontHeight
  635. end;
  636. procedure OutText(TextString: string);
  637. begin
  638. OutTextXY(GetX, GetY, TextString)
  639. end;
  640. procedure OutTextXY(X, Y: Integer; TextString: string);
  641. var
  642. P, Q: PChar;
  643. i: Integer;
  644. col: Boolean;
  645. begin
  646. if NoGraphics or (TextString='') then Exit;
  647. gl_setwritemode(FONT_COMPRESSED + WRITEMODE_MASKED);
  648. case sHoriz of
  649. CenterText : Dec(x, TextWidth(TextString) div 2);
  650. RightText : Dec(x, TextWidth(TextString));
  651. end; { case }
  652. case sVert of
  653. CenterText : Dec(y, TextHeight(TextString) div 2);
  654. BottomText, BaseLine : Dec(y, TextHeight(TextString));
  655. end; { case }
  656. MoveTo(X, Y);
  657. P := @TextString[1]; Q := P;
  658. col := false;
  659. gl_setfontcolors(BackColor, TextColor);
  660. For i := 1 to Length(TextString) do
  661. begin
  662. If (Q[0] = TheMarker) and DoUseMarker
  663. then begin
  664. If col then gl_setfontcolors(BackColor, MarkColor)
  665. else gl_setfontcolors(BackColor, TextColor);
  666. If Q <> P then begin
  667. gl_writen(CurX, CurY, Q-P, P);
  668. MoveRel(FontWidth * (Q-P), 0)
  669. end;
  670. col := not col;
  671. P := Q + 1
  672. end;
  673. {Inc(Q)} Q := Q + 1
  674. end;
  675. If col then gl_setfontcolors(BackColor, MarkColor)
  676. else gl_setfontcolors(BackColor, TextColor);
  677. If Q <> P then begin
  678. gl_writen(CurX, CurY, Q-P, P);
  679. MoveRel(FontWidth * (Q-P), 0)
  680. end
  681. end;
  682. procedure SetTextJustify(Horiz, Vert: Word);
  683. begin
  684. sHoriz := Horiz; sVert := Vert;
  685. end;
  686. procedure SetTextStyle(Font, Direction: Word; CharSize: Word);
  687. begin
  688. end;
  689. procedure SetUserCharSize(MultX, DivX, MultY, DivY: Word);
  690. begin
  691. end;
  692. procedure SetKern(Enable: Boolean);
  693. begin
  694. end;
  695. procedure SetMarker(Marker: Char);
  696. begin
  697. TheMarker := Marker
  698. end;
  699. procedure SetTextParams(Font: Word; CharSpace: Integer; Color: Word;
  700. UseMarker: Boolean);
  701. type
  702. pp = ^pointer;
  703. function FixCol(Col: Byte): Byte;
  704. { SVGALIB cannot write black characters... }
  705. begin
  706. if Col=0 then FixCol := 1 else FixCol := Col
  707. end; { FixCol }
  708. begin
  709. sColor := Color; sCharSpace := CharSpace; sFont := Font;
  710. if not NoGraphics then begin
  711. TextColor := ColorTable[FixCol(Color and 15)];
  712. MarkColor := ColorTable[FixCol((Color shr 8) and 15)];
  713. DoUseMarker := UseMarker;
  714. gl_setfont(8, 8, (pp(@gl_font8x8))^);
  715. end
  716. end;
  717. function GetResX: Integer;
  718. begin
  719. GetResX := 96;
  720. end; { GetResX }
  721. function GetResY: Integer;
  722. begin
  723. GetResY := 96
  724. end; { GetResY }
  725. function GetAspect: Real;
  726. begin
  727. GetAspect := 1.0
  728. end; { GetAspect }
  729. procedure SetViewPort(x1, y1, x2, y2: Integer; Clip: Boolean);
  730. begin
  731. SetDrawOrigin(x1, y1);
  732. if Clip then SetClipRect(x1, y1, x2+1, y2+1)
  733. else SetClipRect(0, 0, SizeX, SizeY)
  734. end;
  735. { VGAMEM }
  736. type
  737. TImage = record
  738. end;
  739. procedure CopyScreen(x1, y1, x2, y2, x3, y3: Integer);
  740. begin
  741. if not NoGraphics and (x2 > x1) and (y2 > y1)
  742. then gl_copyboxfromcontext(PhysicalScreen^, x1, y1, x2 - x1, y2 - y1, x3, y3);
  743. end;
  744. { BGI-like Image routines
  745. }
  746. function CopyImage(Image: pointer): pointer;
  747. begin
  748. CopyImage := nil
  749. end;
  750. function CutImage(x1, y1, x2, y2: Integer): pointer;
  751. var
  752. Image: PBitmap;
  753. begin
  754. GetMem(Image, ImageSize(x1, y1, x2, y2));
  755. if Image <> nil
  756. then GetImage(x1, y1, x2, y2, Image^);
  757. CutImage := Image;
  758. end;
  759. procedure GetImageExtent(Image: pointer; var Extent: Objects.TPoint);
  760. begin
  761. if Image = nil
  762. then begin
  763. Extent.X := 0;
  764. Extent.Y := 0
  765. end
  766. else begin
  767. Extent.X := PBitmap(Image)^.Width;
  768. Extent.Y := PBitmap(Image)^.Height
  769. end;
  770. end;
  771. procedure FreeImage(Image: pointer);
  772. var
  773. P: TPoint;
  774. begin
  775. if Image <> nil
  776. then begin
  777. GetImageExtent(Image, P);
  778. FreeMem(Image, ImageSize(0, 0, P.x - 1, P.y - 1));
  779. end;
  780. end;
  781. function LoadImage(var S: TStream): pointer;
  782. begin
  783. LoadImage := nil
  784. end;
  785. function MaskedImage(Image: pointer): pointer;
  786. begin
  787. MaskedImage := nil;
  788. end;
  789. procedure PasteImage(X, Y: Integer; Image: pointer; BitBlt: Word);
  790. begin
  791. if Image <> nil then PutImage(X, Y, Image^, BitBlt)
  792. end;
  793. procedure StoreImage(var S: TStream; Image: pointer);
  794. begin
  795. end;
  796. { Storing screen regions }
  797. function PrepBuf(var R: Objects.TRect; Action: Word; var Buf: TVgaBuf): Boolean;
  798. begin
  799. if BackScreen <> nil
  800. then begin
  801. Buf.Bounds := R;
  802. gl_setcontext(BackScreen);
  803. gl_disableclipping;
  804. case Action of
  805. pbCopy : gl_copyboxfromcontext(PhysicalScreen^,
  806. R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y,
  807. R.A.X, R.A.Y);
  808. pbClear : gl_fillbox(R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y, 0);
  809. end;
  810. PrepBuf := true;
  811. SetDrawOrigin(0, 0);
  812. SetClipRectR(R);
  813. end
  814. else PrepBuf := false
  815. end; { PrepBuf }
  816. procedure EndBufDraw;
  817. begin
  818. if not NoGraphics
  819. then gl_setcontext(PhysicalScreen);
  820. end; { EndBufDraw }
  821. procedure ReleaseBuf(var Buf: TVgaBuf);
  822. begin
  823. end; { ReleaseBuf }
  824. procedure PasteRectAt(var R: Objects.TRect; P: Objects.TPoint; var Buf: TVgaBuf);
  825. begin
  826. if not NoGraphics and (BackScreen <> nil)
  827. then gl_copyboxfromcontext(BackScreen^,
  828. R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y,
  829. P.X, P.Y);
  830. end;
  831. procedure PasteRect(var R: Objects.TRect; var Buf: TVgaBuf);
  832. begin
  833. PasteRectAt(R, R.A, Buf);
  834. end; { PasteRect }
  835. function StoreScreen(x1, y1, x2, y2: Integer): PScreenBuf;
  836. var
  837. s: LongInt;
  838. Handle: Word;
  839. p: pointer;
  840. SaveOrigin: TPoint;
  841. function NewScreenBuf(AMode: Word; AnInfo: LongInt): PScreenBuf;
  842. var
  843. p: PScreenBuf;
  844. Begin
  845. New(p);
  846. p^.Mode := AMode;
  847. p^.Size := s;
  848. p^.Rect.Assign(x1, y1, x2, y2);
  849. p^.Info := AnInfo;
  850. NewScreenBuf := p
  851. End;
  852. Begin
  853. { General Images }
  854. s := 0;
  855. SaveOrigin := DrawOrigin;
  856. SetDrawOrigin(0, 0);
  857. p := CutImage(x1, y1, x2-1, y2-1);
  858. SetDrawOriginP(SaveOrigin);
  859. If p <> nil
  860. then StoreScreen := NewScreenBuf(2, LongInt(p))
  861. else StoreScreen := nil
  862. End;
  863. procedure FreeScreenBuf(Buf: PScreenBuf);
  864. Begin
  865. If Buf <> nil then Begin
  866. case Buf^.Mode of
  867. 2 : FreeImage(pointer(Buf^.Info));
  868. end;
  869. Dispose(Buf)
  870. End
  871. End;
  872. procedure DrawScreenBufAt(Buf: PScreenBuf; x3, y3: Integer);
  873. var
  874. SaveOrigin: TPoint;
  875. Begin
  876. If Buf <> nil then
  877. case Buf^.Mode of
  878. 2 :
  879. begin
  880. SaveOrigin := DrawOrigin;
  881. SetDrawOrigin(0, 0);
  882. PasteImage(x3, y3, pointer(Buf^.Info), NormalPut);
  883. SetDrawOriginP(SaveOrigin);
  884. end
  885. end
  886. End;
  887. procedure DrawScreenBuf(Buf: PScreenBuf);
  888. Begin
  889. If Buf <> nil then
  890. DrawScreenBufAt(Buf, Buf^.Rect.A.x, Buf^.Rect.A.y)
  891. End;
  892. function GetVgaMemCaps: Word;
  893. begin
  894. GetVgaMemCaps := vmcCopy
  895. end;
  896. procedure GetTextMetrics(var Metrics: TTextMetric);
  897. begin
  898. with Metrics do
  899. begin
  900. tmHeight := 8;
  901. tmAscent := 8;
  902. tmDescent := 0;
  903. tmInternalLeading := 0;
  904. tmExternalLeading := 0;
  905. tmAveCharWidth := 8;
  906. tmMaxCharWidth := 8;
  907. tmWeight := 700;
  908. tmItalic := 0;
  909. tmUnderlined := 0;
  910. tmStruckOut := 0;
  911. tmFirstChar := 0;
  912. tmLastChar := 255;
  913. tmDefaultChar := 32;
  914. tmBreakChar := 32;
  915. tmPitchAndFamily := 0;
  916. tmCharSet := 0;
  917. tmOverhang := 0;
  918. tmDigitizedAspectX := 100;
  919. tmDigitizedAspectY := 100
  920. end;
  921. end;
  922. { ---------------------------------------------------------------------
  923. Real graph implementation
  924. ---------------------------------------------------------------------}
  925. function GetX: Integer;
  926. begin
  927. GetX := CurX - DrawDelta.X
  928. end;
  929. function GetY: Integer;
  930. begin
  931. GetY := CurY - DrawDelta.Y
  932. end;
  933. { Pixel-oriented routines }
  934. procedure PutPixel(X, Y: Integer; Pixel: Word);
  935. begin
  936. if not NoGraphics
  937. then gl_setpixel(X + DrawDelta.X, Y + DrawDelta.Y, Pixel)
  938. end;
  939. function GetPixel(X, Y: Integer): Word;
  940. begin
  941. if NoGraphics
  942. then GetPixel := 0
  943. else GetPixel := gl_getpixel(X + DrawDelta.X, Y + DrawDelta.Y)
  944. end;
  945. { Line-oriented primitives }
  946. procedure SetWriteMode(WriteMode: Integer);
  947. begin
  948. { Graph.SetWriteMode(WriteMode) }
  949. end;
  950. procedure LineTo(X, Y: Integer);
  951. begin
  952. if not NoGraphics
  953. then gl_line(CurX, CurY, X + DrawDelta.X, Y + DrawDelta.Y, TheColor);
  954. CurX := X + DrawDelta.X;
  955. CurY := Y + DrawDelta.Y
  956. end;
  957. procedure LineRel(Dx, Dy: Integer);
  958. begin
  959. if not NoGraphics
  960. then gl_line(CurX, CurY, CurX + Dx, CurY + Dy, TheColor);
  961. CurX := CurX + Dx;
  962. CurY := CurY + Dy
  963. end;
  964. procedure MoveTo(X, Y: Integer);
  965. begin
  966. CurX := X + DrawDelta.X;
  967. CurY := Y + DrawDelta.Y
  968. end;
  969. procedure MoveRel(Dx, Dy: Integer);
  970. begin
  971. CurX := CurX + Dx;
  972. CurY := CurY + Dy
  973. end;
  974. procedure Line(x1, y1, x2, y2: Integer);
  975. begin
  976. if not NoGraphics
  977. then gl_line(x1 + DrawDelta.X, y1 + DrawDelta.Y,
  978. x2 + DrawDelta.X, y2 + DrawDelta.Y, TheColor)
  979. end;
  980. procedure SetLineStyle(LineStyle: Word; Pattern: Word; Thickness: Word);
  981. begin
  982. end;
  983. procedure SetFillPattern(Pattern: FillPatternType; Color: Word);
  984. begin
  985. end;
  986. { Linearly bounded primitives }
  987. procedure Rectangle(x1, y1, x2, y2: Integer);
  988. begin
  989. MoveTo(x1, y1);
  990. LineTo(x2, y1);
  991. LineTo(x2, y2);
  992. LineTo(x1, y2);
  993. LineTo(x1, y1)
  994. end;
  995. procedure Bar(x1, y1, x2, y2: Integer);
  996. var
  997. R: TRect;
  998. begin
  999. if not NoGraphics
  1000. then begin
  1001. R.Assign(x1 + DrawDelta.X, y1 + DrawDelta.Y,
  1002. x2 + DrawDelta.X + 1, y2 + DrawDelta.Y + 1);
  1003. R.Intersect(ClipRect);
  1004. if not R.Empty
  1005. then gl_fillbox(R.A.X, R.A.Y,
  1006. R.B.X - R.A.X, R.B.Y - R.A.Y, TheFillColor)
  1007. end;
  1008. end;
  1009. procedure Bar3D(x1, y1, x2, y2: Integer; Depth: Word; Top: Boolean);
  1010. begin
  1011. Bar(x1,y1,x2,y2);
  1012. Rectangle(x1,y1,x2,y2);
  1013. if top then begin
  1014. Moveto(x1,y1);
  1015. Lineto(x1+depth,y1-depth);
  1016. Lineto(x2+depth,y1-depth);
  1017. Lineto(x2,y1);
  1018. end;
  1019. Moveto(x2+depth,y1-depth);
  1020. Lineto(x2+depth,y2-depth);
  1021. Lineto(x2,y2);
  1022. end;
  1023. procedure DrawPoly(NumPoints: Word; var PolyPoints);
  1024. type
  1025. ppointtype = ^pointtype;
  1026. var
  1027. i : longint;
  1028. begin
  1029. line(ppointtype(@polypoints)[NumPoints-1].x,
  1030. ppointtype(@polypoints)[NumPoints-1].y,
  1031. ppointtype(@polypoints)[0].x,
  1032. ppointtype(@polypoints)[0].y);
  1033. for i:=0 to NumPoints-2 do
  1034. line(ppointtype(@polypoints)[i].x,
  1035. ppointtype(@polypoints)[i].y,
  1036. ppointtype(@polypoints)[i+1].x,
  1037. ppointtype(@polypoints)[i+1].y);
  1038. end;
  1039. procedure FillPoly(NumPoints: Word; var PolyPoints);
  1040. begin
  1041. end;
  1042. procedure SetFillStyle(Pattern: Word; Color: Word);
  1043. begin
  1044. TheFillColor := ColorTable[Color]
  1045. end;
  1046. procedure FloodFill(X, Y: Integer; Border: Word);
  1047. begin
  1048. end;
  1049. { Nonlinearly bounded primitives
  1050. }
  1051. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  1052. begin
  1053. end;
  1054. procedure Arc(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  1055. begin
  1056. end;
  1057. procedure Circle(X, Y: Integer; Radius: Word);
  1058. begin
  1059. if not NoGraphics
  1060. then gl_circle(X + DrawDelta.X, Y + DrawDelta.Y, Radius, TheColor)
  1061. end;
  1062. procedure Ellipse(X, Y: Integer;
  1063. StAngle, EndAngle: Word; XRadius, YRadius : Word);
  1064. begin
  1065. end;
  1066. procedure FillEllipse(X, Y: Integer; XRadius, YRadius : Word);
  1067. begin
  1068. Bar(X - XRadius, Y - YRadius, X + XRadius, Y + YRadius);
  1069. end;
  1070. procedure SetAspectRatio(Xasp, Yasp: Word);
  1071. begin
  1072. end;
  1073. procedure PieSlice(X, Y: Integer; StAngle, EndAngle, Radius: Word);
  1074. begin
  1075. end;
  1076. procedure Sector(X, Y: Integer;
  1077. StAngle, EndAngle, XRadius, YRadius: Word);
  1078. begin
  1079. end;
  1080. { Color routines
  1081. }
  1082. procedure SetBkColor(ColorNum: Word);
  1083. begin
  1084. BackColor := ColorTable[ColorNum];
  1085. end;
  1086. procedure SetColor(Color: Word);
  1087. begin
  1088. TheColor := ColorTable[Color];
  1089. end;
  1090. procedure GetImage(x1, y1, x2, y2: Integer; var BitMap);
  1091. var
  1092. SaveClipRect: TRect;
  1093. begin
  1094. with TBitmap(Bitmap) do
  1095. begin
  1096. Width := x2 - x1 + 1;
  1097. Height := y2 - y1 + 1;
  1098. if not NoGraphics
  1099. then begin
  1100. {gl_disableclipping(0);}
  1101. SaveClipRect := ClipRect;
  1102. SetClipRect(0, 0, SizeX, SizeY);
  1103. gl_getbox(x1 + DrawDelta.X, y1 + DrawDelta.Y,
  1104. x2 - x1 + 1, y2 - y1 + 1, @Data);
  1105. SetClipRectR(SaveClipRect)
  1106. end;
  1107. end;
  1108. end;
  1109. procedure PutImage(X, Y: Integer; var BitMap; BitBlt: Word);
  1110. var
  1111. R: TRect;
  1112. SaveClipRect: TRect;
  1113. begin
  1114. if not NoGraphics then
  1115. with TBitmap(Bitmap) do
  1116. begin
  1117. {gl_putbox(x + DrawDelta.X, y + DrawDelta.Y, Width, Height, @Data)}
  1118. R.Assign(X + DrawDelta.X, Y + DrawDelta.Y,
  1119. X + DrawDelta.X + Width, Y + DrawDelta.Y + Height);
  1120. R.Intersect(ClipRect);
  1121. if not R.Empty
  1122. then begin
  1123. {gl_disableclipping(0);}
  1124. SaveClipRect := ClipRect;
  1125. SetClipRect(0, 0, SizeX, SizeY);
  1126. gl_putboxpart(R.A.X, R.A.Y,
  1127. R.B.X - R.A.X, R.B.Y - R.A.Y,
  1128. Width, Height,
  1129. @Data,
  1130. R.A.X - X, R.A.Y - Y);
  1131. SetClipRectR(SaveClipRect);
  1132. end;
  1133. end;
  1134. end; { PutImage }
  1135. function ImageSize(x1, y1, x2, y2: Integer): LongInt;
  1136. begin
  1137. if NoGraphics
  1138. then ImageSize := SizeOf(TBitmap)
  1139. else ImageSize := SizeOf(TBitmap)
  1140. + LongInt(x2 - x1 + 1) * LongInt(y2 - y1 + 1) * PhysicalScreen^.BytesPerPixel;
  1141. end;
  1142. begin
  1143. { Give up root permissions if we are root. }
  1144. if geteuid = 0 then vga_init;
  1145. end.
  1146. {
  1147. $Log$
  1148. Revision 1.1 1998-04-15 13:40:11 michael
  1149. + Initial implementation of graph unit
  1150. }