graph.pp 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  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. { Not used
  436. sMarker: Char;
  437. sAttr: Word; }
  438. { Windows-style text metric }
  439. type
  440. PTextMetric = ^TTextMetric;
  441. TTextMetric = record
  442. tmHeight: Integer;
  443. tmAscent: Integer;
  444. tmDescent: Integer;
  445. tmInternalLeading: Integer;
  446. tmExternalLeading: Integer;
  447. tmAveCharWidth: Integer;
  448. tmMaxCharWidth: Integer;
  449. tmWeight: Integer;
  450. tmItalic: Byte;
  451. tmUnderlined: Byte;
  452. tmStruckOut: Byte;
  453. tmFirstChar: Byte;
  454. tmLastChar: Byte;
  455. tmDefaultChar: Byte;
  456. tmBreakChar: Byte;
  457. tmPitchAndFamily: Byte;
  458. tmCharSet: Byte;
  459. tmOverhang: Integer;
  460. tmDigitizedAspectX: Integer;
  461. tmDigitizedAspectY: Integer;
  462. end;
  463. { Bitmap utilities }
  464. type
  465. PBitmap = ^TBitmap;
  466. TBitmap = record
  467. Width, Height: Integer;
  468. Data: record end;
  469. end;
  470. { Storing screen regions }
  471. type
  472. TVgaBuf = record
  473. Bounds: TRect;
  474. Mem: Word;
  475. Size: Word;
  476. end;
  477. const
  478. pbNone = 0;
  479. pbCopy = 1;
  480. pbClear = 2;
  481. type
  482. PScreenBuf = ^TScreenBuf;
  483. TScreenBuf = record
  484. Mode: Word;
  485. Rect: TRect;
  486. Size: LongInt;
  487. Info: LongInt
  488. end;
  489. { Procedures and functions }
  490. procedure SetColors;
  491. var
  492. i: Integer;
  493. begin
  494. for i:=0 to 15 do
  495. ColorTable[i] := gl_rgbcolor(BgiColors[i] shr 16,
  496. (BgiColors[i] shr 8) and 255,
  497. BgiColors[i] and 255)
  498. end;
  499. procedure InitVideo;
  500. var
  501. VgaMode: Integer;
  502. ModeInfo: pvga_modeinfo;
  503. begin
  504. if NoGraphics
  505. then begin
  506. SizeX := 640;
  507. SizeY := 480
  508. end
  509. else begin
  510. VgaMode := vga_getdefaultmode;
  511. if (VgaMode = -1) then VgaMode := G320X200X256;
  512. if (not vga_hasmode(VgaMode))
  513. then begin
  514. WriteLn('BGI: Mode not available.');
  515. Halt(1)
  516. end;
  517. ModeInfo := vga_getmodeinfo(VgaMode);
  518. {IsVirtual := (ModeInfo^.colors = 16) or (ModeInfo^.flags and IS_MODEX <> 0);}
  519. IsVirtual := true;
  520. { We always want a back screen (for buffering). }
  521. if IsVirtual
  522. then begin
  523. { Create virtual screen }
  524. gl_setcontextvgavirtual(VgaMode);
  525. BackScreen := gl_allocatecontext;
  526. gl_getcontext(BackScreen)
  527. end;
  528. vga_setmode(VgaMode);
  529. gl_setcontextvga(VgaMode); { Physical screen context. }
  530. PhysicalScreen := gl_allocatecontext;
  531. gl_getcontext(PhysicalScreen);
  532. if (PhysicalScreen^.colors = 256) then gl_setrgbpalette;
  533. SetColors;
  534. SizeX := PhysicalScreen^.Width;
  535. SizeY := PhysicalScreen^.Height
  536. end
  537. end;
  538. procedure DoneVideo;
  539. begin
  540. if not NoGraphics
  541. then begin
  542. if IsVirtual then gl_freecontext(BackScreen);
  543. vga_setmode(TEXT)
  544. end
  545. end;
  546. procedure SetDelta;
  547. begin
  548. if ClipRect.Empty
  549. then begin
  550. DrawDelta.X := 10000;
  551. DrawDelta.Y := 10000;
  552. end
  553. else begin
  554. DrawDelta.X := DrawOrigin.X;
  555. DrawDelta.y := DrawOrigin.y
  556. end
  557. end;
  558. procedure SetDrawOrigin(x, y: Integer);
  559. begin
  560. DrawOrigin.x := x;
  561. DrawOrigin.y := y;
  562. SetDelta;
  563. end;
  564. procedure SetDrawOriginP(var P: TPoint);
  565. begin
  566. SetDrawOrigin(P.x, P.y)
  567. end;
  568. procedure SetClipRect(x1, y1, x2, y2: Integer);
  569. begin
  570. Cliprect.Assign(x1, y1, x2, y2);
  571. if not NoGraphics
  572. then begin
  573. if ClipRect.Empty
  574. then gl_setclippingwindow(0, 0, 0, 0)
  575. else gl_setclippingwindow(x1, y1, x2 - 1, y2 - 1);
  576. {gl_enableclipping(0);}
  577. end;
  578. SetDelta
  579. end;
  580. procedure SetClipRectR(var R: TRect);
  581. begin
  582. SetClipRect(R.A.X, R.A.Y, R.B.X, R.B.Y);
  583. end;
  584. procedure SetMetaOrigin(x, y: Integer);
  585. begin
  586. MetaOrigin.x := x;
  587. MetaOrigin.y := y
  588. end;
  589. procedure SetMetaOriginP(P: TPoint);
  590. begin
  591. SetMetaOrigin(P.x, P.y)
  592. end;
  593. procedure SetMetaClipRect(x1, y1, x2, y2: Integer);
  594. begin
  595. MetaCliprect.Assign(x1, y1, x2, y2)
  596. end;
  597. procedure SetMetaClipRectR(var R: TRect);
  598. begin
  599. MetaCliprect := R
  600. end;
  601. function GetBuffer(Size: Word): pointer;
  602. begin
  603. { No metafiling available. }
  604. GetBuffer := nil
  605. end;
  606. Procedure HoriLine(x1,y1,x2: Integer);
  607. begin
  608. Line(x1, y1, x2, y1)
  609. end;
  610. Procedure VertLine(x1,y1,y2: Integer);
  611. begin
  612. Line(x1, y1, x1, y2)
  613. end;
  614. procedure FillCircle(xm, ym, r: Integer);
  615. begin
  616. FillEllipse(xm, ym, r, r)
  617. end;
  618. { Text routines }
  619. function TextWidth(s: string): Integer;
  620. var
  621. i: Integer;
  622. begin
  623. if DoUseMarker
  624. then begin
  625. For i := Length(s) downto 1 do
  626. If s[i] = TheMarker then Delete(s, i, 1);
  627. If s = ''
  628. then TextWidth := 0
  629. else TextWidth := Length(s) * FontWidth
  630. end
  631. else TextWidth := Length(s) * FontWidth
  632. end;
  633. function TextHeight(s: string): Integer;
  634. begin
  635. TextHeight := FontHeight
  636. end;
  637. procedure OutText(TextString: string);
  638. begin
  639. OutTextXY(GetX, GetY, TextString)
  640. end;
  641. procedure OutTextXY(X, Y: Integer; TextString: string);
  642. var
  643. P, Q: PChar;
  644. i: Integer;
  645. col: Boolean;
  646. begin
  647. if NoGraphics or (TextString='') then Exit;
  648. gl_setwritemode(FONT_COMPRESSED + WRITEMODE_MASKED);
  649. case sHoriz of
  650. CenterText : Dec(x, TextWidth(TextString) div 2);
  651. RightText : Dec(x, TextWidth(TextString));
  652. end; { case }
  653. case sVert of
  654. CenterText : Dec(y, TextHeight(TextString) div 2);
  655. BottomText, BaseLine : Dec(y, TextHeight(TextString));
  656. end; { case }
  657. MoveTo(X, Y);
  658. P := @TextString[1]; Q := P;
  659. col := false;
  660. gl_setfontcolors(BackColor, TextColor);
  661. For i := 1 to Length(TextString) do
  662. begin
  663. If (Q[0] = TheMarker) and DoUseMarker
  664. then begin
  665. If col then gl_setfontcolors(BackColor, MarkColor)
  666. else gl_setfontcolors(BackColor, TextColor);
  667. If Q <> P then begin
  668. gl_writen(CurX, CurY, Q-P, P);
  669. MoveRel(FontWidth * (Q-P), 0)
  670. end;
  671. col := not col;
  672. P := Q + 1
  673. end;
  674. {Inc(Q)} Q := Q + 1
  675. end;
  676. If col then gl_setfontcolors(BackColor, MarkColor)
  677. else gl_setfontcolors(BackColor, TextColor);
  678. If Q <> P then begin
  679. gl_writen(CurX, CurY, Q-P, P);
  680. MoveRel(FontWidth * (Q-P), 0)
  681. end
  682. end;
  683. procedure SetTextJustify(Horiz, Vert: Word);
  684. begin
  685. sHoriz := Horiz; sVert := Vert;
  686. end;
  687. procedure SetTextStyle(Font, Direction: Word; CharSize: Word);
  688. begin
  689. end;
  690. procedure SetUserCharSize(MultX, DivX, MultY, DivY: Word);
  691. begin
  692. end;
  693. procedure SetKern(Enable: Boolean);
  694. begin
  695. end;
  696. procedure SetMarker(Marker: Char);
  697. begin
  698. TheMarker := Marker
  699. end;
  700. procedure SetTextParams(Font: Word; CharSpace: Integer; Color: Word;
  701. UseMarker: Boolean);
  702. type
  703. pp = ^pointer;
  704. function FixCol(Col: Byte): Byte;
  705. { SVGALIB cannot write black characters... }
  706. begin
  707. if Col=0 then FixCol := 1 else FixCol := Col
  708. end; { FixCol }
  709. begin
  710. sColor := Color; sCharSpace := CharSpace; sFont := Font;
  711. if not NoGraphics then begin
  712. TextColor := ColorTable[FixCol(Color and 15)];
  713. MarkColor := ColorTable[FixCol((Color shr 8) and 15)];
  714. DoUseMarker := UseMarker;
  715. gl_setfont(8, 8, (pp(@gl_font8x8))^);
  716. end
  717. end;
  718. function GetResX: Integer;
  719. begin
  720. GetResX := 96;
  721. end; { GetResX }
  722. function GetResY: Integer;
  723. begin
  724. GetResY := 96
  725. end; { GetResY }
  726. function GetAspect: Real;
  727. begin
  728. GetAspect := 1.0
  729. end; { GetAspect }
  730. procedure SetViewPort(x1, y1, x2, y2: Integer; Clip: Boolean);
  731. begin
  732. SetDrawOrigin(x1, y1);
  733. if Clip then SetClipRect(x1, y1, x2+1, y2+1)
  734. else SetClipRect(0, 0, SizeX, SizeY)
  735. end;
  736. { VGAMEM }
  737. type
  738. TImage = record
  739. end;
  740. procedure CopyScreen(x1, y1, x2, y2, x3, y3: Integer);
  741. begin
  742. if not NoGraphics and (x2 > x1) and (y2 > y1)
  743. then gl_copyboxfromcontext(PhysicalScreen^, x1, y1, x2 - x1, y2 - y1, x3, y3);
  744. end;
  745. { BGI-like Image routines
  746. }
  747. function CopyImage(Image: pointer): pointer;
  748. begin
  749. CopyImage := nil
  750. end;
  751. function CutImage(x1, y1, x2, y2: Integer): pointer;
  752. var
  753. Image: PBitmap;
  754. begin
  755. GetMem(Image, ImageSize(x1, y1, x2, y2));
  756. if Image <> nil
  757. then GetImage(x1, y1, x2, y2, Image^);
  758. CutImage := Image;
  759. end;
  760. procedure GetImageExtent(Image: pointer; var Extent: Objects.TPoint);
  761. begin
  762. if Image = nil
  763. then begin
  764. Extent.X := 0;
  765. Extent.Y := 0
  766. end
  767. else begin
  768. Extent.X := PBitmap(Image)^.Width;
  769. Extent.Y := PBitmap(Image)^.Height
  770. end;
  771. end;
  772. procedure FreeImage(Image: pointer);
  773. var
  774. P: TPoint;
  775. begin
  776. if Image <> nil
  777. then begin
  778. GetImageExtent(Image, P);
  779. FreeMem(Image, ImageSize(0, 0, P.x - 1, P.y - 1));
  780. end;
  781. end;
  782. function LoadImage(var S: TStream): pointer;
  783. begin
  784. LoadImage := nil
  785. end;
  786. function MaskedImage(Image: pointer): pointer;
  787. begin
  788. MaskedImage := nil;
  789. end;
  790. procedure PasteImage(X, Y: Integer; Image: pointer; BitBlt: Word);
  791. begin
  792. if Image <> nil then PutImage(X, Y, Image^, BitBlt)
  793. end;
  794. procedure StoreImage(var S: TStream; Image: pointer);
  795. begin
  796. end;
  797. { Storing screen regions }
  798. function PrepBuf(var R: Objects.TRect; Action: Word; var Buf: TVgaBuf): Boolean;
  799. begin
  800. if BackScreen <> nil
  801. then begin
  802. Buf.Bounds := R;
  803. gl_setcontext(BackScreen);
  804. gl_disableclipping;
  805. case Action of
  806. pbCopy : gl_copyboxfromcontext(PhysicalScreen^,
  807. R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y,
  808. R.A.X, R.A.Y);
  809. pbClear : gl_fillbox(R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y, 0);
  810. end;
  811. PrepBuf := true;
  812. SetDrawOrigin(0, 0);
  813. SetClipRectR(R);
  814. end
  815. else PrepBuf := false
  816. end; { PrepBuf }
  817. procedure EndBufDraw;
  818. begin
  819. if not NoGraphics
  820. then gl_setcontext(PhysicalScreen);
  821. end; { EndBufDraw }
  822. procedure ReleaseBuf(var Buf: TVgaBuf);
  823. begin
  824. end; { ReleaseBuf }
  825. procedure PasteRectAt(var R: Objects.TRect; P: Objects.TPoint; var Buf: TVgaBuf);
  826. begin
  827. if not NoGraphics and (BackScreen <> nil)
  828. then gl_copyboxfromcontext(BackScreen^,
  829. R.A.X, R.A.Y, R.B.X - R.A.X, R.B.Y - R.A.Y,
  830. P.X, P.Y);
  831. end;
  832. procedure PasteRect(var R: Objects.TRect; var Buf: TVgaBuf);
  833. begin
  834. PasteRectAt(R, R.A, Buf);
  835. end; { PasteRect }
  836. function StoreScreen(x1, y1, x2, y2: Integer): PScreenBuf;
  837. var
  838. s: LongInt;
  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.2 1998-05-12 10:42:47 peter
  1149. * moved getopts to inc/, all supported OS's need argc,argv exported
  1150. + strpas, strlen are now exported in the systemunit
  1151. * removed logs
  1152. * removed $ifdef ver_above
  1153. Revision 1.1 1998/04/15 13:40:11 michael
  1154. + Initial implementation of graph unit
  1155. }