graph.pp 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1993,99 by the Free Pascal development team
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. Unit Graph;
  11. {-------------------------------------------------------}
  12. { Differences with TP Graph unit: }
  13. { - default putimage and getimage only support a max. }
  14. { of 64K colors on screen, because all pixels are }
  15. { saved as words. }
  16. { - Set RGB Palette is not used, SetPalette must be }
  17. { used instead. }
  18. { - In the TP graph unit, Clipping is always performed }
  19. { on strings written with OutText, and this clipping }
  20. { is done on a character per character basis (for }
  21. { example, if ONE part of a character is outside the }
  22. { viewport , then that character is not written at }
  23. { all to the screen. In FPC Pascal, clipping is done }
  24. { on a PIXEL basis, not a character basis, so part of }
  25. { characters which are not entirely in the viewport }
  26. { may appear on the screen. }
  27. { - SetTextStyle only conforms to the TP version when }
  28. { the correct (and expected) values are used for }
  29. { CharSize for stroked fonts (4 = stroked fonts) }
  30. { - InstallUserDriver is not supported, so always }
  31. { returns an error. }
  32. { - RegisterBGIDriver is not supported, so always }
  33. { returns an error. }
  34. { - DrawPoly XORPut mode is not exactly the same as in }
  35. { the TP graph unit. }
  36. { - FillEllipse does not support XORPut mode with a }
  37. { bounded FloodFill. Mode is always CopyPut mode. }
  38. { - Imagesize returns a longint instead of a word }
  39. { - ImageSize cannot return an error value }
  40. {-------------------------------------------------------}
  41. { AUTHORS: }
  42. { Gernot Tenchio - original version }
  43. { Florian Klaempfl - major updates }
  44. { Pierre Mueller - major bugfixes }
  45. { Carl Eric Codere - complete rewrite }
  46. { Thomas Schatzl - optimizations,routines and }
  47. { Credits (external): suggestions. }
  48. { - Original FloodFill code by }
  49. { Menno Victor van der star }
  50. { (the code has been heavily modified) }
  51. {-------------------------------------------------------}
  52. {-------------------------------------------------------}
  53. { For significant speed improvements , is is recommended }
  54. { that these routines be hooked (otherwise the default, }
  55. { slower routines will be used) : }
  56. { HLine() }
  57. { VLine() }
  58. { PatternLine() }
  59. { ClearViewPort() }
  60. { PutImage() }
  61. { GetImage() - ImageSize() should also be changed }
  62. { InternalEllipse() }
  63. { Line() }
  64. { GetScanLine() }
  65. {--------------------------------------------------------}
  66. { FPC unit requirements: }
  67. { All modes should at least have 1 graphics page to }
  68. { make it possible to create animation on all supported }
  69. { systems , this can be done either by double-buffering }
  70. { yourself in the heap if no hardware is available to do}
  71. { it. }
  72. {--------------------------------------------------------}
  73. { COMPATIBILITY WARNING: Some of the compatibility tests }
  74. { were done using the CGA and other the VGA drivers. }
  75. { Within the BGI drivers themselves the BEHAVIOUR is not }
  76. { the same, so be warned!!! }
  77. {--------------------------------------------------------}
  78. { History log: }
  79. { 15th February 1999: }
  80. { + Added support for system font in vertical mode }
  81. { + system font is now available for all platforms }
  82. { * font support routines now compile }
  83. { * textHeight would not return correct size for system }
  84. { font }
  85. { * Alignment of fonts partly fixed }
  86. { 17th Feb. 1999: }
  87. { + First support for stroked fonts }
  88. { 18th Feb. 1999: }
  89. { * bugfix of line drawing which fixes stroked font }
  90. { displays. }
  91. { 23rd Feb. 1999: }
  92. { + Applied Pierre's patches to font }
  93. { + Added scaling of bitmapped fonts }
  94. { + Vertical stroked fonts }
  95. { 24th Feb. 1999: }
  96. { * Scaling of stroked fonts must be done using FPs }
  97. { to be 100% compatible with turbo pascal }
  98. { + Sped up by 40% stroked font scaling calculations }
  99. { + RegisterBGIFont }
  100. { 9th march 1999: }
  101. { + Starting implementing Fillpoly() }
  102. { 15th march 1999: }
  103. { + SetFillStyle() }
  104. { + patternLine() }
  105. { + Bar() }
  106. { * GraphDefaults would not make the Default color }
  107. { of the fill pattern to the Max. Palette entry. }
  108. { + SetFillPattern() }
  109. { 20th march 1999: }
  110. { * GraphDefaults would not reset to the text system }
  111. { * DefaultFont would write one character too much to }
  112. { the screen }
  113. { + Sloped thick lines in Line() }
  114. { + Sloped patterned lines in Line() }
  115. { * GraphDefaults would not reset the User Fill pattern}
  116. { to $ff }
  117. { + DirectPutPixel takes care of XOR mode writes }
  118. { improves speed by about 30% over old method of }
  119. { GetPixel XOR CurrentColor }
  120. { * Dashed LineStyle exactly like BP version now }
  121. { + Center LineStyle (checked against CGA driver) }
  122. { * GraphDefaults() now resets linepattern array }
  123. { 1st april 1999: }
  124. { + First implementation of FillPoly (incomplete) }
  125. { 2nd april 1999: }
  126. { * FillPoly did not Reset PatternLine index }
  127. { * FillPoly did not use correct color }
  128. { * PatternLine was writing modes in reverse direction }
  129. { * PatternLine would not work with non-rectangular }
  130. { shapes. }
  131. { * PatternLine must fill up the ENTIRE pattern, }
  132. { with either the foreground or background color. }
  133. { * GraphDefaults() would not call SetBkColor() }
  134. { * Fixed some memory leaks in FillPoly() }
  135. { 11th April 1999: }
  136. { * PatternLine() was drawing one pixel less then }
  137. { requested }
  138. { 12th April 1999: }
  139. { + FloodFill - first working implementation }
  140. { Horrbly slow even on very fast cpu's }
  141. { + Some suggestions of Thomas implemented }
  142. { 13th April 1999: }
  143. { * FloodFill() vertical index was off by one pixel }
  144. { * FloodFill() would never draw the last line in the }
  145. { list }
  146. { - Removed ClearViewPort320 which was wrong anyways, }
  147. { will need to be implemented later. }
  148. { * PatternLine() would not always restore write mode }
  149. { + Circle() uses NormalPut always with NormWidth lines}
  150. { + FillEllipse() initial version }
  151. { * InternalEllipse() - 0 to 360 now supported as }
  152. { angles. }
  153. { 14th April 1999: }
  154. { * mod x = and (x-1)(from Thomas Schatzl) gives a }
  155. { significant speed improvement. }
  156. { 15th april 1999: }
  157. { + Arc() ok except for Aspect Ratio, which does not }
  158. { give us the correct ratio on a 320x200 screen. }
  159. { + Added FillPoly() from Thomas Schatzl }
  160. { + More hookable routines }
  161. { 16th april 1999: }
  162. { + Line() checked ok. }
  163. { 17th april 1999: }
  164. { * GraphDefaults() would not reset CP }
  165. { + GetX(), GetY(), MoveTo() checked for viewports }
  166. { * OutTextXY() should not update the CP }
  167. { * ClearViewPort() would not update the CP }
  168. { * ClearDevice() would not update the CP }
  169. { * Sector() would update the CP by calling LineTo }
  170. { * Bar3D() would update the CP }
  171. { * PieSlice() would update the CP }
  172. { 18th april 1999: }
  173. { + Clipping algorithm }
  174. { 19th april 1999: }
  175. { + Adapterinfo structure }
  176. { 20th april 1999: }
  177. { + GetModeName }
  178. { + GetGraphMode }
  179. { + GetModeRange }
  180. {--------------------------------------------------------}
  181. { LEFT TO DO: }
  182. { - optimize scaling of stroked fonts }
  183. { - optimize InternalEllipse() }
  184. { using linear appx. of sine/cosine tables }
  185. { - justification for stroked fonts does not work }
  186. { - On Closegraph deallocate all font pointers }
  187. {--------------------------------------------------------}
  188. { text.inc will crash on aligned requirement machines. }
  189. { (packed record for fontrec) }
  190. {$G+}
  191. Interface
  192. const
  193. { error codes }
  194. grOk = 0;
  195. grNoInitGraph = -1;
  196. grNotDetected = -2;
  197. grFileNotFound = -3;
  198. grInvalidDriver = -4;
  199. grNoLoadMem = -5;
  200. grNoScanMem = -6;
  201. grNoFloodMem = -7;
  202. grFontNotFound = -8;
  203. grNoFontMem = -9;
  204. grInvalidMode = -10;
  205. grError = -11;
  206. grIOerror = -12;
  207. grInvalidFont = -13;
  208. grInvalidFontNum = -14;
  209. grInvalidVersion = -18;
  210. { Color constants for setpalette }
  211. black = 0;
  212. blue = 1;
  213. green = 2;
  214. cyan = 3;
  215. red = 4;
  216. magenta = 5;
  217. brown = 6;
  218. lightgray = 7;
  219. darkgray = 8;
  220. lightblue = 9;
  221. lightgreen = 10;
  222. lightcyan = 11;
  223. lightred = 12;
  224. lightmagenta = 13;
  225. yellow = 14;
  226. white = 15;
  227. EGABlack = 0;
  228. EGABlue = 1;
  229. EGAGreen = 2;
  230. EGACyan = 3;
  231. EGARed = 4;
  232. EGAMagenta = 5;
  233. EGALightgray= 7;
  234. EGABrown = 20;
  235. EGADarkgray = 56;
  236. EGALightblue = 57;
  237. EGALightgreen = 58;
  238. EGALightcyan = 59;
  239. EGALightred = 60;
  240. EGALightmagenta=61;
  241. EGAYellow = 62;
  242. EGAWhite = 63;
  243. { Line styles for GetLineStyle/SetLineStyle }
  244. SolidLn = 0;
  245. DottedLn = 1;
  246. CenterLn = 2;
  247. DashedLn = 3;
  248. UserBitLn = 4;
  249. NormWidth = 1;
  250. ThickWidth = 3;
  251. { Set/GetTextStyle Konstanten: }
  252. DefaultFont = 0;
  253. TriplexFont = 1;
  254. SmallFont = 2;
  255. SansSerifFont = 3;
  256. GothicFont = 4;
  257. ScriptFont = 5;
  258. SimpleFont = 6;
  259. TSCRFont = 7;
  260. LCOMFont = 8;
  261. EuroFont = 9;
  262. BoldFont = 10;
  263. HorizDir = 0;
  264. VertDir = 1;
  265. UserCharSize = 0;
  266. ClipOn = true;
  267. ClipOff = false;
  268. { Bar3D constants }
  269. TopOn = true;
  270. TopOff = false;
  271. { fill pattern for Get/SetFillStyle: }
  272. EmptyFill = 0;
  273. SolidFill = 1;
  274. LineFill = 2;
  275. LtSlashFill = 3;
  276. SlashFill = 4;
  277. BkSlashFill = 5;
  278. LtBkSlashFill = 6;
  279. HatchFill = 7;
  280. XHatchFill = 8;
  281. InterleaveFill = 9;
  282. WideDotFill = 10;
  283. CloseDotFill = 11;
  284. UserFill = 12;
  285. { bitblt operators }
  286. NormalPut = 0;
  287. CopyPut = 0;
  288. XORPut = 1;
  289. OrPut = 2;
  290. AndPut = 3;
  291. NotPut = 4;
  292. { SetTextJustify constants }
  293. LeftText = 0;
  294. CenterText = 1;
  295. RightText = 2;
  296. BottomText = 0;
  297. TopText = 2;
  298. { graphic drivers }
  299. CurrentDriver = -128;
  300. Detect = 0;
  301. LowRes = 1;
  302. HercMono = 7;
  303. VGA = 9;
  304. VESA = 10;
  305. { graph modes }
  306. Default = 0;
  307. { VGA Driver modes }
  308. VGALo = 0;
  309. VGAMed = 1;
  310. VGAHi = 2;
  311. { Hercules mono card }
  312. HercMonoHi = 0;
  313. MaxColors = 65535; { Maximum possible colors using a palette }
  314. { otherwise, direct color encoding }
  315. type
  316. RGBRec = packed record
  317. Red: integer;
  318. Green: integer;
  319. Blue : integer;
  320. end;
  321. {$ifndef FPC}
  322. PaletteType = record
  323. Size : longint;
  324. Colors : array[0..255] of RGBRec;
  325. end;
  326. {$else}
  327. PaletteType = record
  328. Size : longint;
  329. Colors : array[0..MaxColors] of RGBRec;
  330. end;
  331. {$endif}
  332. LineSettingsType = record
  333. linestyle : word;
  334. pattern : word;
  335. thickness : word;
  336. end;
  337. TextSettingsType = record
  338. font : word;
  339. direction : word;
  340. charsize : word;
  341. horiz : word;
  342. vert : word;
  343. end;
  344. FillSettingsType = record
  345. pattern : word;
  346. color : word;
  347. end;
  348. FillPatternType = array[1..8] of byte;
  349. PointType = record
  350. x,y : integer;
  351. end;
  352. ViewPortType = record
  353. x1,y1,x2,y2 : integer;
  354. Clip : boolean;
  355. end;
  356. ArcCoordsType = record
  357. x,y : integer;
  358. xstart,ystart : integer;
  359. xend,yend : integer;
  360. end;
  361. const
  362. fillpatternTable : array[0..12] of FillPatternType = (
  363. ($00,$00,$00,$00,$00,$00,$00,$00), { background color }
  364. ($ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff), { foreground color }
  365. ($ff,$ff,$00,$00,$ff,$ff,$00,$00), { horizontal lines }
  366. ($01,$02,$04,$08,$10,$20,$40,$80), { slashes }
  367. ($07,$0e,$1c,$38,$70,$e0,$c1,$83), { thick slashes }
  368. ($07,$83,$c1,$e0,$70,$38,$1c,$0e), { thick backslashes }
  369. ($5a,$2d,$96,$4b,$a5,$d2,$69,$b4), { backslashes }
  370. ($ff,$88,$88,$88,$ff,$88,$88,$88), { small boxes }
  371. ($18,$24,$42,$81,$81,$42,$24,$18), { rhombus }
  372. ($cc,$33,$cc,$33,$cc,$33,$cc,$33), { wall pattern }
  373. ($80,$00,$08,$00,$80,$00,$08,$00), { wide points }
  374. ($88,$00,$22,$00,$88,$00,$22,$00), { dense points }
  375. (0,0,0,0,0,0,0,0) { user defined line style }
  376. );
  377. { ******************** PROCEDURAL VARIABLES ********************* }
  378. { * These are hooks which have device specific stuff in them, * }
  379. { * therefore to add new modes or to redirect these routines * }
  380. { * then declare variables of these types as shown below. * }
  381. {-----------------------------------------------------------------}
  382. TYPE
  383. { This is the standard putpixel routine used by all function }
  384. { drawing routines, it will use the viewport settings, as }
  385. { well as clip, and use the current foreground color to plot }
  386. { the desired pixel. }
  387. defpixelproc = procedure(X,Y: Integer);
  388. { standard plot and get pixel }
  389. getpixelproc = function(X,Y: Integer): word;
  390. putpixelproc = procedure(X,Y: Integer; Color: Word);
  391. { clears the viewport, also used to clear the device }
  392. clrviewproc = procedure;
  393. { putimage procedure, can be hooked to accomplish transparency }
  394. putimageproc = procedure (X,Y: Integer; var Bitmap; BitBlt: Word);
  395. getimageproc = procedure(X1,Y1,X2,Y2: Integer; Var Bitmap);
  396. imagesizeproc= function (X1,Y1,X2,Y2: Integer): longint;
  397. graphfreememprc = procedure (var P: Pointer; size: word);
  398. graphgetmemprc = procedure (var P: pointer; size: word);
  399. { internal routines -- can be hooked for much faster drawing }
  400. { draw filled horizontal lines using current color }
  401. { on entry coordinates are already clipped. }
  402. hlineproc = procedure (x, x2,y : integer);
  403. { on entry coordinates are already clipped. }
  404. { draw filled vertical line using current color }
  405. vlineproc = procedure (x,y,y2: integer);
  406. { this routine is used to draw filled patterns for all routines }
  407. { that require it. (FillPoly, FloodFill, Sector, etc... }
  408. { clipping is verified, uses current Fill settings for drawing }
  409. patternlineproc = procedure (x1,x2,y: integer);
  410. { this routine is used to draw all circles/ellipses/sectors }
  411. { more info... on this later... }
  412. ellipseproc = procedure (X,Y: Integer;XRadius: word;
  413. YRadius:word; stAngle,EndAngle: word);
  414. { Line routine - draws lines thick/norm widths with current }
  415. { color and line style - LINE must be clipped here. }
  416. lineproc = procedure (X1, Y1, X2, Y2 : Integer);
  417. { this routine is used for FloodFill - it returns an entire }
  418. { screen scan line with a word for each pixel in the scanline }
  419. getscanlineproc = procedure (Y : integer; var data);
  420. { changes the active display screen where we draw to... }
  421. setactivepageproc = procedure (page: word);
  422. { changes the active display screen which we see ... }
  423. setvisualpageproc = procedure (page: word);
  424. { this routine actually switches to the desired video mode. }
  425. initmodeproc = procedure;
  426. { this routine is called to save the sate just before a mode set }
  427. savestateproc = procedure;
  428. { this routine is called in closegraph to cleanup... }
  429. restorestateproc = procedure;
  430. { This routine is a hook for SetRGBPalette }
  431. setrgbpaletteproc =
  432. procedure(ColorNum, RedValue, GreenValue, BlueValue: Integer);
  433. { This routine is a hook for GetRGBPalette }
  434. getrgbpaletteproc =
  435. procedure(ColorNum, RedValue, GreenValue, BlueValue: Integer);
  436. TYPE
  437. {-----------------------------------}
  438. { Linked list for mode information }
  439. { This list is set up by one of the }
  440. { following routines: }
  441. { It lists all available resolutions}
  442. { on this display adapter. }
  443. {-----------------------------------}
  444. { QueryAdapter() }
  445. { DetectGraph() }
  446. { InitGraph() }
  447. {-----------------------------------}
  448. PModeInfo = ^TModeInfo;
  449. TModeInfo = record
  450. DriverNumber: Integer;
  451. ModeNumber: Integer;
  452. MaxColor: Longint;
  453. PaletteSize : Longint;
  454. XAspect : Integer;
  455. YAspect : Integer;
  456. MaxX: Integer;
  457. MaxY: Integer;
  458. ModeName: String[18];
  459. { necessary hooks ... }
  460. DirectPutPixel : DefPixelProc;
  461. GetPixel : GetPixelProc;
  462. PutPixel : PutPixelProc;
  463. SetRGBPalette : SetRGBPaletteProc;
  464. GetRGBPalette : GetRGBPaletteProc;
  465. { defaults possible ... }
  466. SetVisualPage : SetVisualPageProc;
  467. SetActivePage : SetActivePageProc;
  468. ClearViewPort : ClrViewProc;
  469. PutImage : PutImageProc;
  470. GetImage : GetImageProc;
  471. ImageSize : ImageSizeProc;
  472. GetScanLine : GetScanLineProc;
  473. Line : LineProc;
  474. InternalEllipse: EllipseProc;
  475. PatternLine : PatternLineProc;
  476. HLine : HLineProc;
  477. VLine : VLineProc;
  478. InitMode : InitModeProc;
  479. next: PModeInfo;
  480. end;
  481. VAR
  482. DirectPutPixel : DefPixelProc;
  483. ClearViewPort : ClrViewProc;
  484. PutPixel : PutPixelProc;
  485. PutImage : PutImageProc;
  486. GetImage : GetImageProc;
  487. ImageSize : ImageSizeProc;
  488. GetPixel : GetPixelProc;
  489. SetVisualPage : SetVisualPageProc;
  490. SetActivePage : SetActivePageProc;
  491. SetRGBPalette : SetRGBPaletteProc;
  492. GetRGBPalette : GetRGBPaletteProc;
  493. GraphFreeMemPtr: graphfreememprc;
  494. GraphGetMemPtr : graphgetmemprc;
  495. GetScanLine : GetScanLineProc;
  496. Line : LineProc;
  497. InternalEllipse: EllipseProc;
  498. PatternLine : PatternLineProc;
  499. HLine : HLineProc;
  500. VLine : VLineProc;
  501. SaveVideoState : SaveStateProc;
  502. RestoreVideoState: RestoreStateProc;
  503. Procedure Closegraph;
  504. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  505. function GraphErrorMsg(ErrorCode: Integer): string;
  506. Function GetMaxX: Integer;
  507. Function GetMaxY: Integer;
  508. Procedure SetViewPort(X1, Y1, X2, Y2: Integer; Clip: Boolean);
  509. Function GraphResult: Integer;
  510. function GetModeName(ModeNumber: integer): string;
  511. procedure SetGraphMode(Mode: Integer);
  512. function GetGraphMode: Integer;
  513. function GetMaxMode: word;
  514. procedure RestoreCrtMode;
  515. procedure GetModeRange(GraphDriver: Integer; var LoMode, HiMode: Integer);
  516. Function GetX: Integer;
  517. Function GetY: Integer;
  518. procedure GraphDefaults;
  519. procedure ClearDevice;
  520. procedure GetViewSettings(var viewport : ViewPortType);
  521. procedure SetWriteMode(WriteMode : integer);
  522. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  523. procedure GetFillPattern(var FillPattern:FillPatternType);
  524. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  525. procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;const PathToDriver:String);
  526. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): integer;
  527. function RegisterBGIDriver(driver: pointer): integer;
  528. procedure SetFillStyle(Pattern : word; Color: word);
  529. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  530. procedure MoveRel(Dx, Dy: Integer);
  531. procedure MoveTo(X,Y: Integer);
  532. { -------------------- Color/Palette ------------------------------- }
  533. procedure SetBkColor(ColorNum: Word);
  534. function GetColor: Word;
  535. function GetBkColor: Word;
  536. procedure SetColor(Color: Word);
  537. function GetMaxColor: word;
  538. { -------------------- Shapes/Lines -------------------------------- }
  539. procedure Rectangle(x1,y1,x2,y2:integer);
  540. procedure Bar(x1,y1,x2,y2:integer);
  541. procedure Bar3D(x1, y1, x2, y2 : integer;depth : word;top : boolean);
  542. procedure FillPoly(NumPoints: word; Var PolyPoints);
  543. procedure DrawPoly(NumPoints : word;var polypoints);
  544. procedure LineRel(Dx, Dy: Integer);
  545. procedure LineTo(X,Y : Integer);
  546. procedure FloodFill(x : integer; y : integer; Border: word);
  547. { -------------------- Circle related routines --------------------- }
  548. procedure GetAspectRatio(var Xasp,Yasp : word);
  549. procedure SetAspectRatio(Xasp, Yasp : word);
  550. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  551. procedure Arc(X,Y : Integer; StAngle,EndAngle,Radius: word);
  552. procedure PieSlice(X,Y,stangle,endAngle:integer;Radius: Word);
  553. procedure FillEllipse(X, Y: Integer; XRadius, YRadius: Word);
  554. procedure Circle(X, Y: Integer; Radius:Word);
  555. procedure Sector(x, y: Integer; StAngle,EndAngle, XRadius, YRadius: Word);
  556. procedure Ellipse(X,Y : Integer; stAngle, EndAngle: word; XRadius,
  557. YRadius: word);
  558. { --------------------- Text related routines --------------------- }
  559. function InstallUserFont(const FontFileName : string) : integer;
  560. function RegisterBGIfont(font : pointer) : integer;
  561. procedure GetTextSettings(var TextInfo : TextSettingsType);
  562. function TextHeight(const TextString : string) : word;
  563. function TextWidth(const TextString : string) : word;
  564. procedure SetTextJustify(horiz,vert : word);
  565. procedure SetTextStyle(font,direction : word;charsize : word);
  566. procedure SetUserCharSize(Multx,Divx,Multy,Divy : word);
  567. procedure OutTextXY(x,y : integer;const TextString : string);
  568. procedure OutText(const TextString : string);
  569. Implementation
  570. {$IFDEF DPMI}
  571. uses WinAPI;
  572. {$ENDIF}
  573. const
  574. StdBufferSize = 4096; { Buffer size for FloodFill }
  575. type
  576. tinttable = array[0..8192] of integer;
  577. pinttable = ^tinttable;
  578. WordArray = Array [0..StdbufferSize] Of word;
  579. PWordArray = ^WordArray;
  580. const
  581. { Mask for each bit in byte used to determine pattern }
  582. BitArray: Array[0..7] of byte =
  583. ($01,$02,$04,$08,$10,$20,$40,$80);
  584. RevbitArray: Array[0..7] of byte =
  585. ($80,$40,$20,$10,$08,$04,$02,$01);
  586. { pre expanded line patterns }
  587. { 0 = LSB of byte pattern }
  588. { 15 = MSB of byte pattern }
  589. LinePatterns: Array[0..15] of BOOLEAN =
  590. (TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,
  591. TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE);
  592. const
  593. BGIPath : string = '.';
  594. { Default font 8x8 system from IBM PC }
  595. {$i fontdata.inc}
  596. var
  597. CurrentColor: Word;
  598. CurrentBkColor: Word;
  599. CurrentX : Integer; { viewport relative }
  600. CurrentY : Integer; { viewport relative }
  601. ClipPixels: Boolean; { Should cliiping be enabled }
  602. CurrentWriteMode: Integer;
  603. _GraphResult : Integer;
  604. LineInfo : LineSettingsType;
  605. FillSettings: FillSettingsType;
  606. { information for Text Output routines }
  607. CurrentTextInfo : TextSettingsType;
  608. CurrentXRatio: Real;
  609. CurrentYRatio: Real;
  610. installedfonts: longint; { Number of installed fonts }
  611. StartXViewPort: Integer; { absolute }
  612. StartYViewPort: Integer; { absolute }
  613. ViewWidth : Integer;
  614. ViewHeight: Integer;
  615. IsGraphMode : Boolean; { Indicates if we are in graph mode or not }
  616. ArcCall: ArcCoordsType; { Information on the last call to Arc or Ellipse }
  617. var
  618. { ******************** HARDWARE INFORMATION ********************* }
  619. { Should be set in InitGraph once only. }
  620. IntCurrentMode : Integer;
  621. IntCurrentDriver : Integer; { Currently loaded driver }
  622. XAspect : Integer;
  623. YAspect : Integer;
  624. MaxX : Integer; { Maximum resolution - ABSOLUTE }
  625. MaxY : Integer; { Maximum resolution - ABSOLUTE }
  626. MaxColor : Longint;
  627. PaletteSize : longint; { Maximum palette entry we can set, usually equal}
  628. { maxcolor. }
  629. DriverName: String;
  630. ModeList : PModeInfo;
  631. {--------------------------------------------------------------------------}
  632. { }
  633. { LINE AND LINE RELATED ROUTINES }
  634. { }
  635. {--------------------------------------------------------------------------}
  636. {$i clip.inc}
  637. procedure HLineDefault(x,x2,y: integer);
  638. var
  639. Col: word;
  640. xtmp: integer;
  641. Begin
  642. { must we swap the values? }
  643. if x >= x2 then
  644. Begin
  645. xtmp := x2;
  646. x2 := x;
  647. x:= xtmp;
  648. end;
  649. { First convert to global coordinates }
  650. X := X + StartXViewPort;
  651. X2 := X2 + StartXViewPort;
  652. Y := Y + StartYViewPort;
  653. if ClipPixels then
  654. Begin
  655. if LineClipped(x,y,x2,y,StartXViewPort,StartYViewPort,
  656. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  657. exit;
  658. end;
  659. for x:= x to x2 do
  660. DirectPutPixel(X,Y);
  661. end;
  662. procedure VLineDefault(x,y,y2: integer);
  663. var
  664. Col: word;
  665. ytmp: integer;
  666. Begin
  667. { must we swap the values? }
  668. if y >= y2 then
  669. Begin
  670. ytmp := y2;
  671. y2 := y;
  672. y:= ytmp;
  673. end;
  674. { First convert to global coordinates }
  675. X := X + StartXViewPort;
  676. Y2 := Y2 + StartYViewPort;
  677. Y := Y + StartYViewPort;
  678. if ClipPixels then
  679. Begin
  680. if LineClipped(x,y,x,y2,StartXViewPort,StartYViewPort,
  681. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  682. exit;
  683. end;
  684. for y := y to y2 do Directputpixel(x,y)
  685. End;
  686. procedure LineDefault(X1, Y1, X2, Y2: Integer);
  687. var X, Y : Integer;
  688. deltax, deltay : Integer;
  689. d, dinc1, dinc2: Integer;
  690. xinc1 : Integer;
  691. xinc2 : Integer;
  692. yinc1 : Integer;
  693. yinc2 : Integer;
  694. i, j : Integer;
  695. Flag : Boolean; { determines pixel direction in thick lines }
  696. NumPixels : Integer;
  697. PixelCount : Integer;
  698. OldCurrentColor: Word;
  699. swtmp : integer;
  700. TmpNumPixels : integer;
  701. begin
  702. {******************************************}
  703. { SOLID LINES }
  704. {******************************************}
  705. if lineinfo.LineStyle = SolidLn then
  706. Begin
  707. { we separate normal and thick width for speed }
  708. { and because it would not be 100% compatible }
  709. { with the TP graph unit otherwise }
  710. if y1 = y2 then
  711. Begin
  712. {******************************************}
  713. { SOLID LINES HORIZONTAL }
  714. {******************************************}
  715. if lineinfo.Thickness=NormWidth then
  716. hline(x1,x2,y2)
  717. else
  718. begin
  719. { thick width }
  720. hline(x1,x2,y2-1);
  721. hline(x1,x2,y2);
  722. hline(x2,x2,y2+1);
  723. end;
  724. end
  725. else
  726. if x1 = x2 then
  727. Begin
  728. {******************************************}
  729. { SOLID LINES VERTICAL }
  730. {******************************************}
  731. if lineinfo.Thickness=NormWidth then
  732. vline(x1,y1,y2)
  733. else
  734. begin
  735. { thick width }
  736. vline(x1-1,y1,y2);
  737. vline(x1,y1,y2);
  738. vline(x1+1,y1,y2);
  739. end;
  740. end
  741. else
  742. begin
  743. { Convert to global coordinates. }
  744. x1 := x1 + StartXViewPort;
  745. x2 := x2 + StartXViewPort;
  746. y1 := y1 + StartYViewPort;
  747. y2 := y2 + StartYViewPort;
  748. { if fully clipped then exit... }
  749. if ClipPixels then
  750. begin
  751. if LineClipped(x1,y1,x2,y2,StartXViewPort, StartYViewPort,
  752. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  753. exit;
  754. end;
  755. {******************************************}
  756. { SLOPED SOLID LINES }
  757. {******************************************}
  758. oldCurrentColor := CurrentColor;
  759. { Calculate deltax and deltay for initialisation }
  760. deltax := abs(x2 - x1);
  761. deltay := abs(y2 - y1);
  762. { Initialize all vars based on which is the independent variable }
  763. if deltax >= deltay then
  764. begin
  765. Flag := FALSE;
  766. { x is independent variable }
  767. numpixels := deltax + 1;
  768. d := (2 * deltay) - deltax;
  769. dinc1 := deltay Shl 1;
  770. dinc2 := (deltay - deltax) shl 1;
  771. xinc1 := 1;
  772. xinc2 := 1;
  773. yinc1 := 0;
  774. yinc2 := 1;
  775. end
  776. else
  777. begin
  778. Flag := TRUE;
  779. { y is independent variable }
  780. numpixels := deltay + 1;
  781. d := (2 * deltax) - deltay;
  782. dinc1 := deltax Shl 1;
  783. dinc2 := (deltax - deltay) shl 1;
  784. xinc1 := 0;
  785. xinc2 := 1;
  786. yinc1 := 1;
  787. yinc2 := 1;
  788. end;
  789. { Make sure x and y move in the right directions }
  790. if x1 > x2 then
  791. begin
  792. xinc1 := - xinc1;
  793. xinc2 := - xinc2;
  794. end;
  795. if y1 > y2 then
  796. begin
  797. yinc1 := - yinc1;
  798. yinc2 := - yinc2;
  799. end;
  800. { Start drawing at <x1, y1> }
  801. x := x1;
  802. y := y1;
  803. If LineInfo.Thickness=NormWidth then
  804. Begin
  805. { Draw the pixels }
  806. for i := 1 to numpixels do
  807. begin
  808. DirectPutPixel(x, y);
  809. if d < 0 then
  810. begin
  811. d := d + dinc1;
  812. x := x + xinc1;
  813. y := y + yinc1;
  814. end
  815. else
  816. begin
  817. d := d + dinc2;
  818. x := x + xinc2;
  819. y := y + yinc2;
  820. end;
  821. CurrentColor := OldCurrentColor;
  822. end;
  823. end
  824. else
  825. { Thick width lines }
  826. begin
  827. { Draw the pixels }
  828. for i := 1 to numpixels do
  829. begin
  830. { all depending on the slope, we can determine }
  831. { in what direction the extra width pixels will be put }
  832. If Flag then
  833. Begin
  834. DirectPutPixel(x-1,y);
  835. DirectPutPixel(x,y);
  836. DirectPutPixel(x+1,y);
  837. end
  838. else
  839. Begin
  840. DirectPutPixel(x, y-1);
  841. DirectPutPixel(x, y);
  842. DirectPutPixel(x, y+1);
  843. end;
  844. if d < 0 then
  845. begin
  846. d := d + dinc1;
  847. x := x + xinc1;
  848. y := y + yinc1;
  849. end
  850. else
  851. begin
  852. d := d + dinc2;
  853. x := x + xinc2;
  854. y := y + yinc2;
  855. end;
  856. CurrentColor := OldCurrentColor;
  857. end;
  858. end;
  859. end;
  860. end
  861. else
  862. {******************************************}
  863. { begin patterned lines }
  864. {******************************************}
  865. Begin
  866. { Convert to global coordinates. }
  867. x1 := x1 + StartXViewPort;
  868. x2 := x2 + StartXViewPort;
  869. y1 := y1 + StartYViewPort;
  870. y2 := y2 + StartYViewPort;
  871. { if fully clipped then exit... }
  872. if ClipPixels then
  873. begin
  874. if LineClipped(x1,y1,x2,y2,StartXViewPort, StartYViewPort,
  875. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  876. exit;
  877. end;
  878. OldCurrentColor := CurrentColor;
  879. PixelCount:=0;
  880. if y1 = y2 then
  881. Begin
  882. { Check if we must swap }
  883. if x1 >= x2 then
  884. Begin
  885. swtmp := x1;
  886. x1 := x2;
  887. x2 := swtmp;
  888. end;
  889. if LineInfo.Thickness = NormWidth then
  890. Begin
  891. for PixelCount:=x1 to x2 do
  892. { optimization: PixelCount mod 16 }
  893. if LinePatterns[PixelCount and 15] = TRUE then
  894. begin
  895. DirectPutPixel(PixelCount,y2);
  896. end;
  897. end
  898. else
  899. Begin
  900. for i:=-1 to 1 do
  901. Begin
  902. for PixelCount:=x1 to x2 do
  903. { Optimization from Thomas - mod 16 = and 15 }
  904. if LinePatterns[PixelCount and 15] = TRUE then
  905. begin
  906. DirectPutPixel(PixelCount,y2+i);
  907. end;
  908. end;
  909. end;
  910. end
  911. else
  912. if x1 = x2 then
  913. Begin
  914. { Check if we must swap }
  915. if y1 >= y2 then
  916. Begin
  917. swtmp := y1;
  918. y1 := y2;
  919. y2 := swtmp;
  920. end;
  921. if LineInfo.Thickness = NormWidth then
  922. Begin
  923. for PixelCount:=y1 to y2 do
  924. { compare if we should plot a pixel here , compare }
  925. { with predefined line patterns... }
  926. if LinePatterns[PixelCount and 15] = TRUE then
  927. begin
  928. DirectPutPixel(x1,PixelCount);
  929. end;
  930. end
  931. else
  932. Begin
  933. for i:=-1 to 1 do
  934. Begin
  935. for PixelCount:=y1 to y2 do
  936. { compare if we should plot a pixel here , compare }
  937. { with predefined line patterns... }
  938. if LinePatterns[PixelCount and 15] = TRUE then
  939. begin
  940. DirectPutPixel(x1+i,PixelCount);
  941. end;
  942. end;
  943. end;
  944. end
  945. else
  946. Begin
  947. oldCurrentColor := CurrentColor;
  948. { Calculate deltax and deltay for initialisation }
  949. deltax := abs(x2 - x1);
  950. deltay := abs(y2 - y1);
  951. { Initialize all vars based on which is the independent variable }
  952. if deltax >= deltay then
  953. begin
  954. Flag := FALSE;
  955. { x is independent variable }
  956. numpixels := deltax + 1;
  957. d := (2 * deltay) - deltax;
  958. dinc1 := deltay Shl 1;
  959. dinc2 := (deltay - deltax) shl 1;
  960. xinc1 := 1;
  961. xinc2 := 1;
  962. yinc1 := 0;
  963. yinc2 := 1;
  964. end
  965. else
  966. begin
  967. Flag := TRUE;
  968. { y is independent variable }
  969. numpixels := deltay + 1;
  970. d := (2 * deltax) - deltay;
  971. dinc1 := deltax Shl 1;
  972. dinc2 := (deltax - deltay) shl 1;
  973. xinc1 := 0;
  974. xinc2 := 1;
  975. yinc1 := 1;
  976. yinc2 := 1;
  977. end;
  978. { Make sure x and y move in the right directions }
  979. if x1 > x2 then
  980. begin
  981. xinc1 := - xinc1;
  982. xinc2 := - xinc2;
  983. end;
  984. if y1 > y2 then
  985. begin
  986. yinc1 := - yinc1;
  987. yinc2 := - yinc2;
  988. end;
  989. { Start drawing at <x1, y1> }
  990. x := x1;
  991. y := y1;
  992. If LineInfo.Thickness=ThickWidth then
  993. Begin
  994. TmpNumPixels := NumPixels-1;
  995. { Draw the pixels }
  996. for i := 0 to TmpNumPixels do
  997. begin
  998. { all depending on the slope, we can determine }
  999. { in what direction the extra width pixels will be put }
  1000. If Flag then
  1001. Begin
  1002. { compare if we should plot a pixel here , compare }
  1003. { with predefined line patterns... }
  1004. if LinePatterns[i and 15] = TRUE then
  1005. begin
  1006. DirectPutPixel(x-1,y);
  1007. DirectPutPixel(x,y);
  1008. DirectPutPixel(x+1,y);
  1009. end;
  1010. end
  1011. else
  1012. Begin
  1013. { compare if we should plot a pixel here , compare }
  1014. { with predefined line patterns... }
  1015. if LinePatterns[i and 15] = TRUE then
  1016. begin
  1017. DirectPutPixel(x,y-1);
  1018. DirectPutPixel(x,y);
  1019. DirectPutPixel(x,y+1);
  1020. end;
  1021. end;
  1022. if d < 0 then
  1023. begin
  1024. d := d + dinc1;
  1025. x := x + xinc1;
  1026. y := y + yinc1;
  1027. end
  1028. else
  1029. begin
  1030. d := d + dinc2;
  1031. x := x + xinc2;
  1032. y := y + yinc2;
  1033. end;
  1034. end;
  1035. end
  1036. else
  1037. Begin
  1038. { instead of putting in loop , substract by one now }
  1039. TmpNumPixels := NumPixels-1;
  1040. { NormWidth }
  1041. for i := 0 to TmpNumPixels do
  1042. begin
  1043. if LinePatterns[i and 15] = TRUE then
  1044. begin
  1045. DirectPutPixel(x,y);
  1046. end;
  1047. if d < 0 then
  1048. begin
  1049. d := d + dinc1;
  1050. x := x + xinc1;
  1051. y := y + yinc1;
  1052. end
  1053. else
  1054. begin
  1055. d := d + dinc2;
  1056. x := x + xinc2;
  1057. y := y + yinc2;
  1058. end;
  1059. end;
  1060. end
  1061. end;
  1062. {******************************************}
  1063. { end patterned lines }
  1064. {******************************************}
  1065. { restore color }
  1066. CurrentColor:=OldCurrentColor;
  1067. end;
  1068. end; { Line }
  1069. {********************************************************}
  1070. { Procedure InternalEllipse() }
  1071. {--------------------------------------------------------}
  1072. { This routine first calculates all points required to }
  1073. { draw a circle to the screen, and stores the points }
  1074. { to display in a buffer before plotting them. The }
  1075. { aspect ratio of the screen is taken into account when }
  1076. { calculating the values. }
  1077. {--------------------------------------------------------}
  1078. { INPUTS: X,Y : Center coordinates of Ellipse. }
  1079. { XRadius - X-Axis radius of ellipse. }
  1080. { YRadius - Y-Axis radius of ellipse. }
  1081. { stAngle, EndAngle: Start angle and end angles of the }
  1082. { ellipse (used for partial ellipses and circles) }
  1083. {--------------------------------------------------------}
  1084. { NOTE: - uses the current write mode. }
  1085. { - Angles must both be between 0 and 360 }
  1086. {********************************************************}
  1087. Procedure InternalEllipseDefault(X,Y: Integer;XRadius: word;
  1088. YRadius:word; stAngle,EndAngle: word);
  1089. var
  1090. i:integer;
  1091. xpt: pinttable;
  1092. ypt: pinttable;
  1093. j,Delta:real;
  1094. NumOfPixels: longint;
  1095. NumOfPix: Array[0..2] of longint;
  1096. count: longint;
  1097. ConvFac,TempTerm: real;
  1098. aval,bval: integer;
  1099. OldcurrentColor: word;
  1100. TmpAngle: word;
  1101. DeltaAngle: word;
  1102. Begin
  1103. { check if valid angles }
  1104. stangle := stAngle mod 361;
  1105. EndAngle := EndAngle mod 361;
  1106. { if impossible angles then swap them! }
  1107. if Endangle < StAngle then
  1108. Begin
  1109. TmpAngle:=EndAngle;
  1110. EndAngle:=StAngle;
  1111. Stangle:=TmpAngle;
  1112. end;
  1113. { calculate difference of angle now so we don't always have to calculate it }
  1114. DeltaAngle:= EndAngle-StAngle;
  1115. i:=0;
  1116. if LineInfo.Thickness=NormWidth then
  1117. Begin
  1118. { approximate the number of pixels required by using the circumference }
  1119. { equation of an ellipse. }
  1120. NumOfPixels:=8*Round(2*sqrt((sqr(XRadius)+sqr(YRadius)) div 2));
  1121. GetMem(xpt,NumOfpixels*sizeof(word));
  1122. GetMem(ypt,NumOfPixels*sizeof(word));
  1123. { Calculate the angle precision required }
  1124. Delta := DeltaAngle / (NumOfPixels);
  1125. { Adjust for screen aspect ratio }
  1126. XRadius:=(longint(XRadius)*10000) div XAspect;
  1127. YRadius:=(longint(YRadius)*10000) div YAspect;
  1128. { Initial counter value }
  1129. j:=Delta+StAngle;
  1130. { removed from inner loop to make faster }
  1131. ConvFac:=Pi/180.0;
  1132. Repeat
  1133. { this used by both sin and cos }
  1134. TempTerm := j*ConvFac;
  1135. { Calculate points }
  1136. xpt^[i]:=round(XRadius*Cos(TempTerm));
  1137. { calculate the value of y }
  1138. ypt^[i]:=round(YRadius*Sin(TempTerm+Pi));
  1139. j:=j+Delta;
  1140. inc(i);
  1141. Until j > DeltaAngle;
  1142. end
  1143. else
  1144. {******************************************}
  1145. { CIRCLE OR ELLIPSE WITH THICKNESS=3 }
  1146. {******************************************}
  1147. Begin
  1148. NumOfPix[1]:=8*Round(2*sqrt((sqr(XRadius)+sqr(YRadius)) div 2));
  1149. NumOfPix[0]:=8*Round(2*sqrt((sqr(XRadius-1)+sqr(YRadius-1)) div 2));
  1150. NumOfPix[2]:=8*Round(2*sqrt((sqr(XRadius+1)+sqr(YRadius+1)) div 2));
  1151. GetMem(xpt,(NumOfPix[1]+NumOfPix[2]+NumOfPix[0])*sizeof(word));
  1152. GetMem(ypt,(NumOfPix[1]+NumOfPix[2]+NumOfPix[0])*sizeof(word));
  1153. { removed from inner loop to make faster }
  1154. ConvFac:=Pi/180.0;
  1155. for Count:=0 to 2 do
  1156. Begin
  1157. aval:=XRadius+Count-1;
  1158. bval:=YRadius+Count-1;
  1159. Delta := DeltaAngle / (NumOfPix[Count]);
  1160. aval:= (longint(aval)*10000) div XAspect;
  1161. bval:= (longint(bval)*10000) div YAspect;
  1162. j:=Delta+Stangle;
  1163. Repeat
  1164. { this used by both sin and cos }
  1165. TempTerm := j*ConvFac;
  1166. xpt^[i]:=round((aval)*Cos(TempTerm));
  1167. { calculate the value of y }
  1168. ypt^[i]:=round(bval*Sin(TempTerm+Pi));
  1169. j:=j+Delta;
  1170. inc(i);
  1171. Until j > DeltaAngle;
  1172. end;
  1173. end;
  1174. {******************************************}
  1175. { NOW ALL PIXEL POINTS ARE IN BUFFER }
  1176. { plot them all to the screen }
  1177. {******************************************}
  1178. Count:=0;
  1179. OldcurrentColor:=currentColor;
  1180. Repeat
  1181. PutPixel(xpt^[Count]+X,ypt^[Count]+Y,CurrentColor);
  1182. inc(count);
  1183. until Count>=i;
  1184. { Get End and Start points into the ArcCall information record }
  1185. ArcCall.X := X;
  1186. ArcCall.Y := Y;
  1187. ArcCall.XStart := xpt^[0] + X;
  1188. ArcCall.YStart := ypt^[0] + Y;
  1189. ArcCall.XEnd := xpt^[Count-1] + X;
  1190. ArcCall.YEnd := ypt^[Count-1] + Y;
  1191. CurrentColor:=OldCurrentColor;
  1192. if LineInfo.Thickness=NormWidth then
  1193. Begin
  1194. Freemem(xpt,NumOfPixels*sizeof(word));
  1195. Freemem(ypt,NumOfPixels*sizeof(word));
  1196. end
  1197. else
  1198. Begin
  1199. FreeMem(xpt,(NumOfPix[1]+NumOfPix[2]+NumOfPix[0])*sizeof(word));
  1200. FreeMem(ypt,(NumOfPix[1]+NumOfPix[2]+NumOfPix[0])*sizeof(word));
  1201. end;
  1202. end;
  1203. {********************************************************}
  1204. { Procedure InternalEllipse() }
  1205. {--------------------------------------------------------}
  1206. { This routine first calculates all points required to }
  1207. { draw a circle to the screen, and stores the points }
  1208. { to display in a buffer before plotting them. The }
  1209. { aspect ratio of the screen is taken into account when }
  1210. { calculating the values. }
  1211. {--------------------------------------------------------}
  1212. { INPUTS: X,Y : Center coordinates of Ellipse. }
  1213. { XRadius - X-Axis radius of ellipse. }
  1214. { YRadius - Y-Axis radius of ellipse. }
  1215. { stAngle, EndAngle: Start angle and end angles of the }
  1216. { ellipse (used for partial ellipses and circles) }
  1217. {--------------------------------------------------------}
  1218. { NOTE: - uses the current write mode. }
  1219. { - Angles must both be between 0 and 360 }
  1220. {********************************************************}
  1221. (*
  1222. Procedure InternalEllipseDefault (x, y : integer;
  1223. xradius, yradius, stAngle, EndAngle : Word);
  1224. { Draw an ellipse arc. Crude but it works (anyone have a better one?) }
  1225. Var
  1226. aSqr, bSqr, twoaSqr, twobSqr, xa, ya, twoXbSqr, twoYaSqr, error : LongInt;
  1227. Alpha : Real;
  1228. const
  1229. RadToDeg = 180/Pi;
  1230. Procedure PlotPoints;
  1231. var
  1232. i,j: integer;
  1233. xm, ym: integer;
  1234. xp, yp: integer;
  1235. Begin
  1236. ym := y-ya;
  1237. yp := y+ya;
  1238. xm := x-xa;
  1239. xp := x+xa;
  1240. if LineInfo.Thickness = Normwidth then
  1241. Begin
  1242. If (Alpha>=StAngle) And (Alpha<=EndAngle) then
  1243. PutPixel (xm,ym, CurrentColor);
  1244. If (180-Alpha>=StAngle) And (180-Alpha<=EndAngle) then
  1245. PutPixel (xm,yp, CurrentColor);
  1246. If (180+Alpha>=StAngle) And (180+Alpha<=EndAngle) then
  1247. PutPixel (xp,yp, CurrentColor);
  1248. If (360-Alpha>=StAngle) And (360-Alpha<=EndAngle) then
  1249. PutPixel (xp,ym, CurrentColor);
  1250. end
  1251. else
  1252. Begin
  1253. If (Alpha>=StAngle) And (Alpha<=EndAngle) then
  1254. for i:=-1 to 1 do
  1255. for j:=-1 to 1 do
  1256. PutPixel (xm+i,ym+j, CurrentColor);
  1257. If (180-Alpha>=StAngle) And (180-Alpha<=EndAngle) then
  1258. for i:=-1 to 1 do
  1259. for j:=-1 to 1 do
  1260. PutPixel (xm+i,yp+j, CurrentColor);
  1261. If (180+Alpha>=StAngle) And (180+Alpha<=EndAngle) then
  1262. for i:=-1 to 1 do
  1263. for j:=-1 to 1 do
  1264. PutPixel (xp+i,yp+j, CurrentColor);
  1265. If (360-Alpha>=StAngle) And (360-Alpha<=EndAngle) then
  1266. for i:=-1 to 1 do
  1267. for j:=-1 to 1 do
  1268. PutPixel (xp+i,ym+j, CurrentColor);
  1269. end;
  1270. End;
  1271. Begin
  1272. StAngle:=StAngle MOD 361;
  1273. EndAngle:=EndAngle MOD 361;
  1274. StAngle := StAngle + 270;
  1275. EndAngle := EndAngle + 270;
  1276. If StAngle>EndAngle then
  1277. Begin
  1278. StAngle:=StAngle Xor EndAngle; EndAngle:=EndAngle Xor StAngle; StAngle:=EndAngle Xor StAngle;
  1279. End;
  1280. { Adjust for screen aspect ratio }
  1281. XRadius:=(longint(XRadius)*10000) div XAspect;
  1282. YRadius:=(longint(YRadius)*10000) div YAspect;
  1283. aSqr:=LongInt (xradius)*LongInt (xradius);
  1284. bSqr:=LongInt (yradius)*LongInt (yradius);
  1285. twoaSqr:=2*aSqr;
  1286. twobSqr:=2*bSqr;
  1287. xa:=0;
  1288. ya:=yradius;
  1289. twoXbSqr:=0;
  1290. twoYaSqr:=ya*twoaSqr;
  1291. error:=-ya*aSqr;
  1292. While twoXbSqr<=twoYaSqr Do Begin
  1293. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya); { Crude but it works }
  1294. PlotPoints;
  1295. Inc (xa);
  1296. Inc (twoXbSqr,twobSqr);
  1297. Inc (error,twoXbSqr-bSqr);
  1298. If error>=0 then Begin
  1299. Dec (ya);
  1300. Dec (twoYaSqr,twoaSqr);
  1301. Dec (error,twoYaSqr);
  1302. End;
  1303. End;
  1304. xa:=xradius;
  1305. ya:=0;
  1306. twoXbSqr:=xa*twobSqr;
  1307. twoYaSqr:=0;
  1308. error:=-xa*bSqr;
  1309. While twoXbSqr>twoYaSqr Do Begin
  1310. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya);
  1311. PlotPoints;
  1312. Inc (ya);
  1313. Inc (twoYaSqr,twoaSqr);
  1314. Inc (error,twoYaSqr-aSqr);
  1315. If error>=0 then Begin
  1316. Dec (xa);
  1317. Dec (twoXbSqr,twobSqr);
  1318. Dec (error,twoXbSqr);
  1319. End;
  1320. End;
  1321. End;
  1322. *)
  1323. procedure PatternLineDefault(x1,x2,y: integer);
  1324. {********************************************************}
  1325. { Draws a horizontal patterned line according to the }
  1326. { current Fill Settings. }
  1327. {********************************************************}
  1328. { Important notes: }
  1329. { - CurrentColor must be set correctly before entering }
  1330. { this routine. }
  1331. {********************************************************}
  1332. var
  1333. NrIterations: Integer;
  1334. i : Integer;
  1335. j : Integer;
  1336. TmpFillPattern : byte;
  1337. OldWriteMode : word;
  1338. OldCurrentColor : word;
  1339. begin
  1340. { convert to global coordinates ... }
  1341. x1 := x1 + StartXViewPort;
  1342. x2 := x2 + StartXViewPort;
  1343. y := y + StartYViewPort;
  1344. { if line was fully clipped then exit...}
  1345. if LineClipped(x1,y,x2,y,StartXViewPort,StartYViewPort,
  1346. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  1347. exit;
  1348. OldWriteMode := CurrentWriteMode;
  1349. CurrentWriteMode := NormalPut;
  1350. { number of times to go throuh the 8x8 pattern }
  1351. NrIterations := abs(x2 - x1) div 8;
  1352. Inc(NrIterations);
  1353. { Get the current pattern }
  1354. TmpFillPattern := FillPatternTable
  1355. { [FillSettings.Pattern][(((y+viewport.x1) and $7)+1];}
  1356. [FillSettings.Pattern][(y and $7)+1];
  1357. if FillSettings.Pattern = EmptyFill then
  1358. begin
  1359. OldCurrentColor := CurrentColor;
  1360. CurrentColor := CurrentBkColor;
  1361. HLine(x1,x2,y);
  1362. CurrentColor := OldCurrentColor;
  1363. end
  1364. else
  1365. if FillSettings.Pattern = SolidFill then
  1366. begin
  1367. HLine(x1,x2,y);
  1368. end
  1369. else
  1370. begin
  1371. For i:= 0 to NrIterations do
  1372. Begin
  1373. for j:=0 to 7 do
  1374. Begin
  1375. { x1 mod 8 }
  1376. if RevBitArray[x1 and 7] and TmpFillPattern <> 0 then
  1377. DirectPutpixel(x1,y)
  1378. else
  1379. begin
  1380. { According to the TP graph manual, we overwrite everything }
  1381. { which is filled up - checked against VGA and CGA drivers }
  1382. { of TP. }
  1383. OldCurrentColor := CurrentColor;
  1384. CurrentColor := CurrentBkColor;
  1385. DirectPutPixel(x1,y);
  1386. CurrentColor := OldCurrentColor;
  1387. end;
  1388. Inc(x1);
  1389. if x1 > x2 then
  1390. begin
  1391. CurrentWriteMode := OldWriteMode;
  1392. exit;
  1393. end;
  1394. end;
  1395. end;
  1396. end;
  1397. CurrentWriteMode := OldWriteMode;
  1398. end;
  1399. procedure LineRel(Dx, Dy: Integer);
  1400. Begin
  1401. Line(CurrentX, CurrentY, CurrentX + Dx, CurrentY + Dy);
  1402. CurrentX := CurrentX + Dx;
  1403. CurrentY := CurrentY + Dy;
  1404. end;
  1405. procedure LineTo(x,y : Integer);
  1406. Begin
  1407. Line(CurrentX, CurrentY, X, Y);
  1408. CurrentX := X;
  1409. CurrentY := Y;
  1410. end;
  1411. procedure Rectangle(x1,y1,x2,y2:integer);
  1412. begin
  1413. { Do not draw the end points }
  1414. Line(x1,y1,x2-1,y1);
  1415. Line(x1,y1+1,x1,y2);
  1416. Line(x2,y1,x2,y2-1);
  1417. Line(x1+1,y2,x2,y2);
  1418. end;
  1419. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  1420. begin
  1421. Activelineinfo:=Lineinfo;
  1422. end;
  1423. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  1424. var
  1425. i: byte;
  1426. j: byte;
  1427. Begin
  1428. if (LineStyle > UserBitLn) or ((Thickness <> Normwidth) and (Thickness <> ThickWidth)) then
  1429. _GraphResult := grError
  1430. else
  1431. begin
  1432. LineInfo.Thickness := Thickness;
  1433. LineInfo.LineStyle := LineStyle;
  1434. case LineStyle of
  1435. UserBitLn: Lineinfo.Pattern := pattern;
  1436. SolidLn: Lineinfo.Pattern := $ffff; { ------- }
  1437. DashedLn : Lineinfo.Pattern := $F8F8; { -- -- --}
  1438. DottedLn: LineInfo.Pattern := $CCCC; { - - - - }
  1439. CenterLn: LineInfo.Pattern := $FC78; { -- - -- }
  1440. end; { end case }
  1441. { setup pattern styles }
  1442. j:=15;
  1443. for i:=0 to 15 do
  1444. Begin
  1445. { bitwise mask for each bit in the word }
  1446. if (word($01 shl i) AND LineInfo.Pattern) <> 0 then
  1447. LinePatterns[j]:=TRUE
  1448. else
  1449. LinePatterns[j]:=FALSE;
  1450. Dec(j);
  1451. end;
  1452. end;
  1453. end;
  1454. {--------------------------------------------------------------------------}
  1455. { }
  1456. { VIEWPORT RELATED ROUTINES }
  1457. { }
  1458. {--------------------------------------------------------------------------}
  1459. Procedure ClearViewPortDefault;
  1460. var
  1461. j: integer;
  1462. OldWriteMode, OldCurColor: word;
  1463. LineSets : LineSettingsType;
  1464. Begin
  1465. { CP is always RELATIVE coordinates }
  1466. CurrentX := 0;
  1467. CurrentY := 0;
  1468. { Save all old settings }
  1469. OldCurColor := CurrentColor;
  1470. CurrentColor:=CurrentBkColor;
  1471. OldWriteMode:=CurrentWriteMode;
  1472. GetLineSettings(LineSets);
  1473. { reset to normal line style...}
  1474. SetLineStyle(SolidLn, 0, NormWidth);
  1475. { routines are relative here...}
  1476. for J:=0 to ViewHeight do
  1477. HLine(0, ViewWidth, J);
  1478. { restore old settings...}
  1479. SetLineStyle(LineSets.LineStyle, LineSets.Pattern, LineSets.Thickness);
  1480. CurrentColor := OldCurColor;
  1481. CurrentWriteMode := OldWriteMode;
  1482. end;
  1483. Procedure SetViewPort(X1, Y1, X2, Y2: Integer; Clip: Boolean);
  1484. Begin
  1485. if (X1 > GetMaxX) or (X2 > GetMaxX) or (X1 > X2) or (X1 < 0) then
  1486. Begin
  1487. _GraphResult := grError;
  1488. exit;
  1489. end;
  1490. if (Y1 > GetMaxY) or (Y2 > GetMaxY) or (Y1 > Y2) or (Y1 < 0) then
  1491. Begin
  1492. _GraphResult := grError;
  1493. exit;
  1494. end;
  1495. { CP is always RELATIVE coordinates }
  1496. CurrentX := 0;
  1497. CurrentY := 0;
  1498. StartXViewPort := X1;
  1499. StartYViewPort := Y1;
  1500. ViewWidth := X2-X1;
  1501. ViewHeight:= Y2-Y1;
  1502. ClipPixels := Clip;
  1503. end;
  1504. procedure GetViewSettings(var viewport : ViewPortType);
  1505. begin
  1506. ViewPort.X1 := StartXViewPort;
  1507. ViewPort.Y1 := StartYViewPort;
  1508. ViewPort.X2 := ViewWidth + StartXViewPort;
  1509. ViewPort.Y2 := ViewHeight + StartYViewPort;
  1510. ViewPort.Clip := ClipPixels;
  1511. end;
  1512. procedure ClearDevice;
  1513. var
  1514. ViewPort: ViewPortType;
  1515. begin
  1516. { Reset the CP }
  1517. CurrentX := 0;
  1518. CurrentY := 0;
  1519. { save viewport }
  1520. ViewPort.X1 := StartXviewPort;
  1521. ViewPort.X2 := ViewWidth - StartXViewPort;
  1522. ViewPort.Y1 := StartYViewPort;
  1523. ViewPort.Y2 := ViewHeight - StartYViewPort;
  1524. ViewPort.Clip := ClipPixels;
  1525. { put viewport to full screen }
  1526. StartXViewPort := 0;
  1527. ViewHeight := MaxY;
  1528. StartYViewPort := 0;
  1529. ViewWidth := MaxX;
  1530. ClipPixels := TRUE;
  1531. ClearViewPort;
  1532. { restore old viewport }
  1533. StartXViewPort := ViewPort.X1;
  1534. ViewWidth := ViewPort.X2-ViewPort.X1;
  1535. StartYViewPort := ViewPort.Y1;
  1536. ViewHeight := ViewPort.Y2-ViewPort.Y1;
  1537. ClipPixels := ViewPort.Clip;
  1538. end;
  1539. {--------------------------------------------------------------------------}
  1540. { }
  1541. { BITMAP PUT/GET ROUTINES }
  1542. { }
  1543. {--------------------------------------------------------------------------}
  1544. Procedure GetScanlineDefault (Y : Integer; Var Data);
  1545. {********************************************************}
  1546. { Procedure GetScanLine() }
  1547. {--------------------------------------------------------}
  1548. { Returns the full scanline of the video line of the Y }
  1549. { coordinate. The values are returned in a WORD array }
  1550. { each WORD representing a pixel of the specified scanline}
  1551. {********************************************************}
  1552. Var
  1553. Offset, x : Integer;
  1554. Begin
  1555. For x:=0 to MaxX Do Begin
  1556. WordArray(Data)[x]:=GetPixel(x, y);
  1557. End;
  1558. End;
  1559. Function DefaultImageSize(X1,Y1,X2,Y2: Integer): longint;
  1560. Begin
  1561. { each pixel uses two bytes, to enable modes with colors up to 64K }
  1562. { to work. }
  1563. DefaultImageSize := 12 + (((X2-X1)*(Y2-Y1))*2);
  1564. end;
  1565. Procedure DefaultPutImage(X,Y: Integer; var Bitmap; BitBlt: Word);
  1566. type
  1567. pt = array[0..32000] of word;
  1568. ptw = array[0..3] of longint;
  1569. var
  1570. color: word;
  1571. i,j: Integer;
  1572. Y1,X1: Integer;
  1573. k: integer;
  1574. Begin
  1575. X1:= ptw(Bitmap)[0]+X; { get width and adjust end coordinate accordingly }
  1576. Y1:= ptw(Bitmap)[1]+Y; { get height and adjust end coordinate accordingly }
  1577. k:= 12; { Three reserved longs at start of bitmap }
  1578. for j:=Y to Y1 do
  1579. Begin
  1580. for i:=X to X1 do
  1581. begin
  1582. case BitBlt of
  1583. {$R-}
  1584. CopyPut: color:= pt(Bitmap)[k]; { also = normalput }
  1585. XORPut: color:= pt(Bitmap)[k] XOR GetPixel(i,j);
  1586. OrPut: color:= pt(Bitmap)[k] OR GetPixel(i,j);
  1587. AndPut: color:= pt(Bitmap)[k] AND GetPixel(i,j);
  1588. NotPut: color:= not pt(Bitmap)[k];
  1589. {$R+}
  1590. end;
  1591. putpixel(i,j,color);
  1592. Inc(k);
  1593. end;
  1594. end;
  1595. end;
  1596. Procedure DefaultGetImage(X1,Y1,X2,Y2: Integer; Var Bitmap);
  1597. type
  1598. pt = array[0..32000] of word;
  1599. ptw = array[0..3] of longint;
  1600. var
  1601. i,j: integer;
  1602. k: longint;
  1603. Begin
  1604. k:= 12; { Three reserved longs at start of bitmap }
  1605. for j:=Y1 to Y2 do
  1606. Begin
  1607. for i:=X1 to X2 do
  1608. begin
  1609. {$R-}
  1610. pt(Bitmap)[k] :=getpixel(i,j);
  1611. {$R+}
  1612. Inc(k);
  1613. end;
  1614. end;
  1615. ptw(Bitmap)[0] := X2-X1; { First longint is width }
  1616. ptw(Bitmap)[1] := Y2-Y1; { Second longint is height }
  1617. ptw(bitmap)[2] := 0; { Third longint is reserved}
  1618. end;
  1619. Procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  1620. Begin
  1621. ArcCoords.X := ArcCall.X;
  1622. ArcCoords.Y := ArcCall.Y;
  1623. ArcCoords.XStart := ArcCall.XStart;
  1624. ArcCoords.YStart := ArcCall.YStart;
  1625. ArcCoords.XEnd := ArcCall.XEnd;
  1626. ArcCoords.YEnd := ArcCall.YEnd;
  1627. end;
  1628. procedure SetVisualPageDefault(page : word);
  1629. begin
  1630. end;
  1631. procedure SetActivePageDefault(page : word);
  1632. begin
  1633. end;
  1634. Procedure DefaultHooks;
  1635. {********************************************************}
  1636. { Procedure DefaultHooks() }
  1637. {--------------------------------------------------------}
  1638. { Resets all hookable routine either to nil for those }
  1639. { which need overrides, and others to defaults. }
  1640. { This is called each time SetGraphMode() is called. }
  1641. {********************************************************}
  1642. Begin
  1643. { All default hooks procedures }
  1644. { required...}
  1645. DirectPutPixel := nil;
  1646. PutPixel := nil;
  1647. GetPixel := nil;
  1648. SetRGBPalette := nil;
  1649. GetRGBPalette := nil;
  1650. { optional...}
  1651. SetActivePage := SetActivePageDefault;
  1652. SetVisualPage := SetVisualPageDefault;
  1653. ClearViewPort := ClearViewportDefault;
  1654. PutImage := DefaultPutImage;
  1655. GetImage := DefaultGetImage;
  1656. ImageSize := DefaultImageSize;
  1657. GraphFreeMemPtr := nil;
  1658. GraphGetMemPtr := nil;
  1659. GetScanLine := GetScanLineDefault;
  1660. Line := LineDefault;
  1661. InternalEllipse := InternalEllipseDefault;
  1662. PatternLine := PatternLineDefault;
  1663. HLine := HLineDefault;
  1664. VLine := VLineDefault;
  1665. end;
  1666. Procedure InitVars;
  1667. {********************************************************}
  1668. { Procedure InitVars() }
  1669. {--------------------------------------------------------}
  1670. { Resets all internal variables, and resets all }
  1671. { overridable routines. }
  1672. {********************************************************}
  1673. Begin
  1674. InstalledFonts := 0;
  1675. { Install standard fonts }
  1676. InstallUserFont('TRIP');
  1677. InstallUserFont('LITT');
  1678. InstallUserFont('SANS');
  1679. InstallUserFont('GOTH');
  1680. ArcCall.X := 0;
  1681. ArcCall.Y := 0;
  1682. ArcCall.XStart := 0;
  1683. ArcCall.YStart := 0;
  1684. ArcCall.XEnd := 0;
  1685. ArcCall.YEnd := 0;
  1686. { Reset to default values }
  1687. IntCurrentMode := 0;
  1688. IntCurrentDriver := 0;
  1689. XAspect := 0;
  1690. YAspect := 0;
  1691. MaxX := 0;
  1692. MaxY := 0;
  1693. MaxColor := 0;
  1694. PaletteSize := 0;
  1695. DefaultHooks;
  1696. end;
  1697. {$i modes.inc}
  1698. {$i graph.inc}
  1699. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): integer;
  1700. begin
  1701. _graphResult := grError;
  1702. end;
  1703. function RegisterBGIDriver(driver: pointer): integer;
  1704. begin
  1705. _graphResult := grError;
  1706. end;
  1707. { ----------------------------------------------------------------- }
  1708. Procedure Arc(X,Y : Integer; StAngle,EndAngle,Radius: word);
  1709. var
  1710. OldWriteMode: word;
  1711. Begin
  1712. if (Radius = 0) then
  1713. Exit;
  1714. if (Radius = 1) then
  1715. begin
  1716. { must use clipping ... }
  1717. { don't need to explicitly set NormalPut mode }
  1718. { because PutPixel only supports normal put }
  1719. PutPixel(X, Y,CurrentColor);
  1720. Exit;
  1721. end;
  1722. { Only if we are using thickwidths lines do we accept }
  1723. { XORput write modes. }
  1724. OldWriteMode := CurrentWriteMode;
  1725. if (LineInfo.Thickness = NormWidth) then
  1726. CurrentWriteMode := NormalPut;
  1727. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle);
  1728. CurrentWriteMode := OldWriteMode;
  1729. end;
  1730. procedure Ellipse(X,Y : Integer; stAngle, EndAngle: word; XRadius,YRadius: word);
  1731. Begin
  1732. InternalEllipse(X,Y,XRadius,YRadius,stAngle,EndAngle);
  1733. end;
  1734. procedure FillEllipse(X, Y: Integer; XRadius, YRadius: Word);
  1735. {********************************************************}
  1736. { Procedure FillEllipse() }
  1737. {--------------------------------------------------------}
  1738. { Draws a filled ellipse using (X,Y) as a center point }
  1739. { and XRadius and YRadius as the horizontal and vertical }
  1740. { axes. The ellipse is filled with the current fill color}
  1741. { and fill style, and is bordered with the current color.}
  1742. {--------------------------------------------------------}
  1743. { Important notes: }
  1744. { - CONTRRARY to VGA BGI - SetWriteMode DOES not }
  1745. { affect the contour of the ellipses. BGI mode }
  1746. { supports XORPut but the FloodFill() is still bounded}
  1747. { by the ellipse. In OUR case, XOR Mode is simply }
  1748. { not supported. }
  1749. {********************************************************}
  1750. var
  1751. OldWriteMode: Word;
  1752. begin
  1753. { only normal put supported }
  1754. OldWriteMode := CurrentWriteMode;
  1755. CurrentWriteMode := NormalPut;
  1756. InternalEllipse(X,Y,XRadius,YRadius,0,360);
  1757. FloodFill(X,Y,CurrentColor);
  1758. { restore old write mode }
  1759. CurrentWriteMode := OldWriteMode;
  1760. end;
  1761. procedure Circle(X, Y: Integer; Radius:Word);
  1762. {********************************************************}
  1763. { Draws a circle centered at X,Y with the given Radius. }
  1764. {********************************************************}
  1765. { Important notes: }
  1766. { - Thickwidth circles use the current write mode, while}
  1767. { normal width circles ALWAYS use CopyPut/NormalPut }
  1768. { mode. (Tested against VGA BGI driver -CEC 13/Aug/99 }
  1769. {********************************************************}
  1770. var OriginalArcInfo: ArcCoordsType;
  1771. OldWriteMode: word;
  1772. begin
  1773. if (Radius = 0) then
  1774. Exit;
  1775. if (Radius = 1) then
  1776. begin
  1777. { only normal put mode is supported by a call to PutPixel }
  1778. PutPixel(X, Y, CurrentColor);
  1779. Exit;
  1780. end;
  1781. { save state of arc information }
  1782. { because it is not needed for }
  1783. { a circle call. }
  1784. move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
  1785. if LineInfo.Thickness = Normwidth then
  1786. begin
  1787. OldWriteMode := CurrentWriteMode;
  1788. CurrentWriteMode := CopyPut;
  1789. end;
  1790. InternalEllipse(X,Y,Radius,Radius,0,360);
  1791. if LineInfo.Thickness = Normwidth then
  1792. CurrentWriteMode := OldWriteMode;
  1793. { restore arc information }
  1794. move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
  1795. end;
  1796. procedure Sector(x, y: Integer; StAngle,EndAngle, XRadius, YRadius: Word);
  1797. var angle : real;
  1798. writemode : word;
  1799. begin
  1800. Ellipse(x,y,stAngle,endAngle,XRadius,YRadius);
  1801. { As in the TP graph unit - the line settings are used to }
  1802. { define the outline of the sector. }
  1803. writemode:=Currentwritemode;
  1804. Currentwritemode:=normalput;
  1805. Line(ArcCall.XStart, ArcCall.YStart, x,y);
  1806. Line(x,y,ArcCall.Xend,ArcCall.YEnd);
  1807. { we must take care of clipping so we call PutPixel instead }
  1808. { of DirectPutPixel... }
  1809. PutPixel(ArcCall.xstart,ArcCall.ystart,CurrentColor);
  1810. PutPixel(x,y,CurrentColor);
  1811. PutPixel(ArcCall.xend,ArcCall.yend,CurrentColor);
  1812. stangle:=Stangle mod 360; EndAngle:=Endangle mod 360;
  1813. if stAngle<=Endangle then
  1814. Angle:=(stAngle+EndAngle)/2
  1815. else
  1816. angle:=(stAngle-360+EndAngle)/2;
  1817. { fill from the point in the middle of the slice }
  1818. XRadius:=(longint(XRadius)*10000) div XAspect;
  1819. YRadius:=(longint(YRadius)*10000) div YAspect;
  1820. { avoid rounding errors }
  1821. if abs(ArcCall.xstart-ArcCall.xend)
  1822. +abs(ArcCall.ystart-ArcCall.yend)>2 then
  1823. FloodFill(x+round(sin((angle+90)*Pi/180)*XRadius/2),
  1824. y+round(cos((angle+90)*Pi/180)*YRadius/2),CurrentColor);
  1825. CurrentWriteMode := writemode;
  1826. end;
  1827. procedure SetFillStyle(Pattern : word; Color: word);
  1828. begin
  1829. { on invalid input, the current fill setting will be }
  1830. { unchanged. }
  1831. if (Pattern > UserFill) or (Color > GetMaxColor) then
  1832. begin
  1833. _GraphResult := grError;
  1834. exit;
  1835. end;
  1836. FillSettings.Color := Color;
  1837. FillSettings.Pattern := Pattern;
  1838. end;
  1839. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  1840. {********************************************************}
  1841. { Changes the Current FillPattern to a user defined }
  1842. { pattern and changes also the current fill color. }
  1843. { The FillPattern is saved in the FillPattern array so }
  1844. { it can still be used with SetFillStyle(UserFill,Color) }
  1845. {********************************************************}
  1846. var
  1847. i: integer;
  1848. begin
  1849. if Color > GetMaxColor then
  1850. begin
  1851. _GraphResult := grError;
  1852. exit;
  1853. end;
  1854. FillSettings.Color := Color;
  1855. FillSettings.Pattern := UserFill;
  1856. { Save the pattern in the buffer }
  1857. For i:=1 to 8 do
  1858. FillPatternTable[UserFill][i] := Pattern[i];
  1859. end;
  1860. procedure Bar(x1,y1,x2,y2:integer);
  1861. {********************************************************}
  1862. { Important notes for compatibility with BP: }
  1863. { - WriteMode is always CopyPut }
  1864. { - No contour is drawn for the lines }
  1865. {********************************************************}
  1866. var y : Integer;
  1867. origcolor : longint;
  1868. origlinesettings: Linesettingstype;
  1869. origwritemode : Integer;
  1870. begin
  1871. origlinesettings:=lineinfo;
  1872. origcolor:=CurrentColor;
  1873. { Always copy mode for Bars }
  1874. origwritemode := CurrentWriteMode;
  1875. CurrentWriteMode := CopyPut;
  1876. { All lines used are of this style }
  1877. Lineinfo.linestyle:=solidln;
  1878. Lineinfo.thickness:=normwidth;
  1879. case Fillsettings.pattern of
  1880. EmptyFill :
  1881. begin
  1882. Currentcolor:=CurrentBkColor;
  1883. for y:=y1 to y2 do
  1884. Hline(x1,x2,y);
  1885. end;
  1886. SolidFill :
  1887. begin
  1888. CurrentColor:=FillSettings.color;
  1889. for y:=y1 to y2 do
  1890. Hline(x1,x2,y);
  1891. end;
  1892. else
  1893. Begin
  1894. CurrentColor:=FillSettings.color;
  1895. for y:=y1 to y2 do
  1896. patternline(x1,x2,y);
  1897. end;
  1898. end;
  1899. CurrentColor:= Origcolor;
  1900. LineInfo := OrigLineSettings;
  1901. CurrentWriteMode := OrigWritemode;
  1902. end;
  1903. procedure bar3D(x1, y1, x2, y2 : integer;depth : word;top : boolean);
  1904. var
  1905. origwritemode : integer;
  1906. OldX, OldY : integer;
  1907. begin
  1908. origwritemode := CurrentWriteMode;
  1909. CurrentWriteMode := CopyPut;
  1910. Bar(x1,y1,x2,y2);
  1911. Rectangle(x1,y1,x2,y2);
  1912. { Current CP should not be updated in Bar3D }
  1913. { therefore save it and then restore it on }
  1914. { exit. }
  1915. OldX := CurrentX;
  1916. OldY := CurrentY;
  1917. if top then begin
  1918. Moveto(x1,y1);
  1919. Lineto(x1+depth,y1-depth);
  1920. Lineto(x2+depth,y1-depth);
  1921. Lineto(x2,y1);
  1922. end;
  1923. if Depth <> 0 then
  1924. Begin
  1925. Moveto(x2+depth,y1-depth);
  1926. Lineto(x2+depth,y2-depth);
  1927. Lineto(x2,y2);
  1928. end;
  1929. { restore CP }
  1930. CurrentX := OldX;
  1931. CurrentY := OldY;
  1932. CurrentWriteMode := origwritemode;
  1933. end;
  1934. {--------------------------------------------------------------------------}
  1935. { }
  1936. { COLOR AND PALETTE ROUTINES }
  1937. { }
  1938. {--------------------------------------------------------------------------}
  1939. {$i palette.inc}
  1940. procedure SetColor(Color: Word);
  1941. Begin
  1942. CurrentColor := Color;
  1943. end;
  1944. function GetColor: Word;
  1945. Begin
  1946. GetColor := CurrentColor;
  1947. end;
  1948. function GetBkColor: Word;
  1949. Begin
  1950. GetBkColor := CurrentBkColor;
  1951. end;
  1952. procedure SetBkColor(ColorNum: Word);
  1953. { Background color means background screen color in this case, and it is }
  1954. { INDEPENDANT of the viewport settings, so we must clear the whole screen }
  1955. { with the color. }
  1956. var
  1957. ViewPort: ViewportType;
  1958. Begin
  1959. GetViewSettings(Viewport);
  1960. SetViewPort(0,0,MaxX,MaxY,FALSE);
  1961. CurrentBkColor := ColorNum;
  1962. ClearViewPort;
  1963. SetViewport(ViewPort.X1,Viewport.Y1,Viewport.X2,Viewport.Y2,Viewport.Clip);
  1964. end;
  1965. function GetMaxColor: word;
  1966. { Checked against TP VGA driver - CEC }
  1967. begin
  1968. GetMaxColor:=MaxColor-1; { based on an index of zero so subtract one }
  1969. end;
  1970. Procedure MoveRel(Dx, Dy: Integer);
  1971. Begin
  1972. CurrentX := CurrentX + Dx;
  1973. CurrentY := CurrentY + Dy;
  1974. end;
  1975. Procedure MoveTo(X,Y: Integer);
  1976. {********************************************************}
  1977. { Procedure MoveTo() }
  1978. {--------------------------------------------------------}
  1979. { Moves the current pointer in VIEWPORT relative }
  1980. { coordinates to the specified X,Y coordinate. }
  1981. {********************************************************}
  1982. Begin
  1983. CurrentX := X;
  1984. CurrentY := Y;
  1985. end;
  1986. function GraphErrorMsg(ErrorCode: Integer): string;
  1987. Begin
  1988. GraphErrorMsg:='';
  1989. case ErrorCode of
  1990. grOk,grFileNotFound,grInvalidDriver: exit;
  1991. grNoInitGraph: GraphErrorMsg:='Graphics driver not installed';
  1992. grNotDetected: GraphErrorMsg:='Graphics hardware not detected';
  1993. grNoLoadMem,grNoScanMem,grNoFloodMem: GraphErrorMsg := 'Not enough memory for graphics';
  1994. grNoFontMem: GraphErrorMsg := 'Not enough memory to load font';
  1995. grFontNotFound: GraphErrorMsg:= 'Font file not found';
  1996. grInvalidMode: GraphErrorMsg := 'Invalid graphics mode';
  1997. grError: GraphErrorMsg:='Graphics error';
  1998. grIoError: GraphErrorMsg:='Graphics I/O error';
  1999. grInvalidFont,grInvalidFontNum: GraphErrorMsg := 'Invalid font';
  2000. grInvalidVersion: GraphErrorMsg:='Invalid driver version';
  2001. end;
  2002. end;
  2003. Function GetMaxX: Integer;
  2004. { Routine checked against VGA driver - CEC }
  2005. Begin
  2006. GetMaxX := MaxX;
  2007. end;
  2008. Function GetMaxY: Integer;
  2009. { Routine checked against VGA driver - CEC }
  2010. Begin
  2011. GetMaxY := MaxY;
  2012. end;
  2013. Function GraphResult: Integer;
  2014. Begin
  2015. GraphResult := _GraphResult;
  2016. _GraphResult := grOk;
  2017. end;
  2018. Function GetX: Integer;
  2019. Begin
  2020. GetX := CurrentX;
  2021. end;
  2022. Function GetY: Integer;
  2023. Begin
  2024. GetY := CurrentY;
  2025. end;
  2026. Function GetDriverName: string;
  2027. var
  2028. mode: PModeInfo;
  2029. begin
  2030. GetDriverName:=DriverName;
  2031. end;
  2032. procedure graphdefaults;
  2033. { PS: GraphDefaults does not ZERO the ArcCall structure }
  2034. { so a call to GetArcCoords will not change even the }
  2035. { returned values even if GraphDefaults is called in }
  2036. { between. }
  2037. var
  2038. i: integer;
  2039. begin
  2040. lineinfo.linestyle:=solidln;
  2041. lineinfo.thickness:=normwidth;
  2042. { reset line style pattern }
  2043. for i:=0 to 15 do
  2044. LinePatterns[i] := TRUE;
  2045. { By default, according to the TP prog's reference }
  2046. { the default pattern is solid, and the default }
  2047. { color is the maximum color in the palette. }
  2048. fillsettings.color:=GetMaxColor;
  2049. fillsettings.pattern:=solidfill;
  2050. { GraphDefaults resets the User Fill pattern to $ff }
  2051. { checked with VGA BGI driver - CEC }
  2052. for i:=1 to 8 do
  2053. FillPatternTable[UserFill][i] := $ff;
  2054. CurrentColor:=white;
  2055. SetBkColor(Black);
  2056. ClipPixels := TRUE;
  2057. { Reset the viewport }
  2058. StartXViewPort := 0;
  2059. StartYViewPort := 0;
  2060. ViewWidth := MaxX;
  2061. ViewHeight := MaxY;
  2062. { Reset CP }
  2063. CurrentX := 0;
  2064. CurrentY := 0;
  2065. { normal write mode }
  2066. CurrentWriteMode := CopyPut;
  2067. { Schriftart einstellen }
  2068. CurrentTextInfo.font := DefaultFont;
  2069. CurrentTextInfo.direction:=HorizDir;
  2070. CurrentTextInfo.charsize:=1;
  2071. CurrentTextInfo.horiz:=LeftText;
  2072. CurrentTextInfo.vert:=TopText;
  2073. XAspect:=10000; YAspect:=10000;
  2074. end;
  2075. procedure GetAspectRatio(var Xasp,Yasp : word);
  2076. begin
  2077. XAsp:=XAspect;
  2078. YAsp:=YAspect;
  2079. end;
  2080. procedure SetAspectRatio(Xasp, Yasp : word);
  2081. begin
  2082. Xaspect:= XAsp;
  2083. YAspect:= YAsp;
  2084. end;
  2085. procedure SetWriteMode(WriteMode : integer);
  2086. begin
  2087. if (writemode<>xorput) and (writemode<>CopyPut) then
  2088. exit;
  2089. CurrentWriteMode := WriteMode;
  2090. end;
  2091. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  2092. begin
  2093. Fillinfo:=Fillsettings;
  2094. end;
  2095. procedure GetFillPattern(var FillPattern:FillPatternType);
  2096. begin
  2097. FillPattern:=FillpatternTable[UserFill];
  2098. end;
  2099. procedure DrawPoly(numpoints : word;var polypoints);
  2100. type
  2101. ppointtype = ^pointtype;
  2102. pt = array[0..16000] of pointtype;
  2103. var
  2104. i : longint;
  2105. begin
  2106. if numpoints < 2 then
  2107. begin
  2108. _GraphResult := grError;
  2109. exit;
  2110. end;
  2111. for i:=0 to numpoints-2 do
  2112. line(pt(polypoints)[i].x,
  2113. pt(polypoints)[i].y,
  2114. pt(polypoints)[i+1].x,
  2115. pt(polypoints)[i+1].y);
  2116. end;
  2117. procedure PieSlice(X,Y,stangle,endAngle:integer;Radius: Word);
  2118. var angle : real;
  2119. XRadius, YRadius : word;
  2120. writemode : word;
  2121. begin
  2122. Arc(x,y,StAngle,EndAngle,Radius);
  2123. Line(ArcCall.XStart, ArcCall.YStart, x,y);
  2124. Line(x,y, ArcCall.XEnd, ArcCall.YEnd);
  2125. { must use PutPixel() instead of DirectPutPixel because we need }
  2126. { clipping... }
  2127. PutPixel(ArcCall.xstart,ArcCall.ystart,CurrentColor);
  2128. PutPixel(x,y,CurrentColor);
  2129. PutPixel(ArcCall.xend,ArcCall.yend,CurrentColor);
  2130. Stangle:=stAngle mod 360; EndAngle:=Endangle mod 360;
  2131. if Stangle<=Endangle then
  2132. angle:=(StAngle+EndAngle)/2
  2133. else
  2134. angle:=(Stangle-360+Endangle)/2;
  2135. { fill from the point in the middle of the slice }
  2136. XRadius:=(longint(Radius)*10000) div XAspect;
  2137. YRadius:=(longint(Radius)*10000) div YAspect;
  2138. { avoid rounding errors }
  2139. if abs(ArcCall.xstart-ArcCall.xend)
  2140. +abs(ArcCall.ystart-ArcCall.yend)>2 then
  2141. { FloodFill(x+round(sin((angle+90)*Pi/180)*XRadius/2),
  2142. y+round(cos((angle+90)*Pi/180)*YRadius/2),truecolor);}
  2143. CurrentWriteMode := writemode;
  2144. end;
  2145. {$i fills.inc}
  2146. {$i text.inc}
  2147. procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;
  2148. const PathToDriver:String);
  2149. var i,index:Integer;
  2150. LoMode, HiMode: Integer;
  2151. CpyMode: Integer;
  2152. CpyDriver: Integer;
  2153. begin
  2154. { path to the fonts (where they will be searched)...}
  2155. bgipath:=PathToDriver;
  2156. if bgipath[length(bgipath)]<>'\' then
  2157. bgipath:=bgipath+'\';
  2158. { make sure our driver list is setup...}
  2159. QueryAdapterInfo;
  2160. if not assigned(SaveVideoState) then
  2161. RunError(216);
  2162. SaveVideoState;
  2163. InitVars;
  2164. DriverName:=InternalDriverName; { DOS Graphics driver }
  2165. if (Graphdriver=Detect) then
  2166. begin
  2167. HiMode := -1;
  2168. LoMode := -1;
  2169. { We start at VGA-1 }
  2170. GraphDriver := VGA;
  2171. CpyMode := 0;
  2172. { search all possible graphic drivers in ascending order...}
  2173. { usually the new driver numbers indicate newest hardware...}
  2174. { Internal driver numbers start at VGA=9 }
  2175. repeat
  2176. GetModeRange(GraphDriver,LoMode,HiMode);
  2177. { save the highest mode possible...}
  2178. if HiMode = -1 then break;
  2179. CpyMode:=HiMode;
  2180. CpyDriver:=GraphDriver;
  2181. { go to next driver if it exists...}
  2182. Inc(GraphDriver);
  2183. until (CpyMode=-1);
  2184. IntCurrentDriver := CpyDriver;
  2185. { If this is equal to -1 then no graph mode possible...}
  2186. if CpyMode = -1 then
  2187. begin
  2188. _GraphResult := grNotDetected;
  2189. exit;
  2190. end;
  2191. { Actually set the graph mode...}
  2192. SetGraphMode(CpyMode);
  2193. end
  2194. else
  2195. begin
  2196. { Search if that graphics modec actually exists...}
  2197. if SearchMode(GraphDriver,GraphMode) = nil then
  2198. begin
  2199. _GraphResult := grInvalidMode;
  2200. exit;
  2201. end
  2202. else
  2203. begin
  2204. IntCurrentDriver := GraphDriver;
  2205. SetGraphMode(GraphMode);
  2206. end;
  2207. end;
  2208. end;
  2209. var
  2210. ExitSave: pointer;
  2211. begin
  2212. ModeList := nil;
  2213. SaveVideoState := nil;
  2214. RestoreVideoState := nil;
  2215. { This must be called at startup... because GetGraphMode may }
  2216. { be called even when not in graph mode. }
  2217. QueryAdapterInfo;
  2218. { This installs an exit procedure which cleans up the mode list...}
  2219. ExitSave := ExitProc;
  2220. ExitProc := @CleanMode;
  2221. end.
  2222. PieSlice
  2223. Sector
  2224. SetGraphBufSize
  2225. SetBkColor
  2226. DetectGraph
  2227. { DetectGraph() }
  2228. { SetBkColor() }