graph.pp 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,99 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Unit Graph;
  12. {-------------------------------------------------------}
  13. { Differences with TP Graph unit: }
  14. { - default putimage and getimage only support a max. }
  15. { of 64K colors on screen, because all pixels are }
  16. { saved as words. }
  17. { - Set RGB Palette is not used, SetPalette must be }
  18. { used instead. }
  19. { - In the TP graph unit, Clipping is always performed }
  20. { on strings written with OutText, and this clipping }
  21. { is done on a character per character basis (for }
  22. { example, if ONE part of a character is outside the }
  23. { viewport , then that character is not written at }
  24. { all to the screen. In FPC Pascal, clipping is done }
  25. { on a PIXEL basis, not a character basis, so part of }
  26. { characters which are not entirely in the viewport }
  27. { may appear on the screen. }
  28. { - SetTextStyle only conforms to the TP version when }
  29. { the correct (and expected) values are used for }
  30. { CharSize for stroked fonts (4 = stroked fonts) }
  31. { - InstallUserDriver is not supported, so always }
  32. { returns an error. }
  33. { - RegisterBGIDriver is not supported, so always }
  34. { returns an error. }
  35. { - DrawPoly XORPut mode is not exactly the same as in }
  36. { the TP graph unit. }
  37. { - Imagesize returns a longint instead of a word }
  38. { - ImageSize cannot return an error value }
  39. {-------------------------------------------------------}
  40. { AUTHORS: }
  41. { Gernot Tenchio - original version }
  42. { Florian Klaempfl - major updates }
  43. { Pierre Mueller - major bugfixes }
  44. { Carl Eric Codere - complete rewrite }
  45. { Thomas Schatzl - optimizations,routines and }
  46. { suggestions. }
  47. { Jonas Maebe - bugfixes and optimizations }
  48. { Credits (external): }
  49. { - Original FloodFill code by }
  50. { Menno Victor van der star }
  51. { (the code has been heavily modified) }
  52. {-------------------------------------------------------}
  53. {-------------------------------------------------------}
  54. { For significant speed improvements , is is recommended }
  55. { that these routines be hooked (otherwise the default, }
  56. { slower routines will be used) : }
  57. { HLine() }
  58. { VLine() }
  59. { PatternLine() }
  60. { ClearViewPort() }
  61. { PutImage() }
  62. { GetImage() - ImageSize() should also be changed }
  63. { InternalEllipse() }
  64. { Line() }
  65. { GetScanLine() }
  66. {--------------------------------------------------------}
  67. { FPC unit requirements: }
  68. { All modes should at least have 1 graphics page to }
  69. { make it possible to create animation on all supported }
  70. { systems , this can be done either by double-buffering }
  71. { yourself in the heap if no hardware is available to do}
  72. { it. }
  73. {--------------------------------------------------------}
  74. { COMPATIBILITY WARNING: Some of the compatibility tests }
  75. { were done using the CGA and other the VGA drivers. }
  76. { Within the BGI drivers themselves the BEHAVIOUR is not }
  77. { the same, so be warned!!! }
  78. {--------------------------------------------------------}
  79. { History log: }
  80. { 15th February 1999: }
  81. { + Added support for system font in vertical mode }
  82. { + system font is now available for all platforms }
  83. { * font support routines now compile }
  84. { * textHeight would not return correct size for system }
  85. { font }
  86. { * Alignment of fonts partly fixed }
  87. { 17th Feb. 1999: }
  88. { + First support for stroked fonts }
  89. { 18th Feb. 1999: }
  90. { * bugfix of line drawing which fixes stroked font }
  91. { displays. }
  92. { 23rd Feb. 1999: }
  93. { + Applied Pierre's patches to font }
  94. { + Added scaling of bitmapped fonts }
  95. { + Vertical stroked fonts }
  96. { 24th Feb. 1999: }
  97. { * Scaling of stroked fonts must be done using FPs }
  98. { to be 100% compatible with turbo pascal }
  99. { + Sped up by 40% stroked font scaling calculations }
  100. { + RegisterBGIFont }
  101. { 9th march 1999: }
  102. { + Starting implementing Fillpoly() }
  103. { 15th march 1999: }
  104. { + SetFillStyle() }
  105. { + patternLine() }
  106. { + Bar() }
  107. { * GraphDefaults would not make the Default color }
  108. { of the fill pattern to the Max. Palette entry. }
  109. { + SetFillPattern() }
  110. { 20th march 1999: }
  111. { * GraphDefaults would not reset to the text system }
  112. { * DefaultFont would write one character too much to }
  113. { the screen }
  114. { + Sloped thick lines in Line() }
  115. { + Sloped patterned lines in Line() }
  116. { * GraphDefaults would not reset the User Fill pattern}
  117. { to $ff }
  118. { + DirectPutPixel takes care of XOR mode writes }
  119. { improves speed by about 30% over old method of }
  120. { GetPixel XOR CurrentColor }
  121. { * Dashed LineStyle exactly like BP version now }
  122. { + Center LineStyle (checked against CGA driver) }
  123. { * GraphDefaults() now resets linepattern array }
  124. { 1st april 1999: }
  125. { + First implementation of FillPoly (incomplete) }
  126. { 2nd april 1999: }
  127. { * FillPoly did not Reset PatternLine index }
  128. { * FillPoly did not use correct color }
  129. { * PatternLine was writing modes in reverse direction }
  130. { * PatternLine would not work with non-rectangular }
  131. { shapes. }
  132. { * PatternLine must fill up the ENTIRE pattern, }
  133. { with either the foreground or background color. }
  134. { * GraphDefaults() would not call SetBkColor() }
  135. { * Fixed some memory leaks in FillPoly() }
  136. { 11th April 1999: }
  137. { * PatternLine() was drawing one pixel less then }
  138. { requested }
  139. { 12th April 1999: }
  140. { + FloodFill - first working implementation }
  141. { Horrbly slow even on very fast cpu's }
  142. { + Some suggestions of Thomas implemented }
  143. { 13th April 1999: }
  144. { * FloodFill() vertical index was off by one pixel }
  145. { * FloodFill() would never draw the last line in the }
  146. { list }
  147. { - Removed ClearViewPort320 which was wrong anyways, }
  148. { will need to be implemented later. }
  149. { * PatternLine() would not always restore write mode }
  150. { + Circle() uses NormalPut always with NormWidth lines}
  151. { + FillEllipse() initial version }
  152. { * InternalEllipse() - 0 to 360 now supported as }
  153. { angles. }
  154. { 14th April 1999: }
  155. { * mod x = and (x-1)(from Thomas Schatzl) gives a }
  156. { significant speed improvement. }
  157. { 15th april 1999: }
  158. { + Arc() ok except for Aspect Ratio, which does not }
  159. { give us the correct ratio on a 320x200 screen. }
  160. { + Added FillPoly() from Thomas Schatzl }
  161. { + More hookable routines }
  162. { 16th april 1999: }
  163. { + Line() checked ok. }
  164. { 17th april 1999: }
  165. { * GraphDefaults() would not reset CP }
  166. { + GetX(), GetY(), MoveTo() checked for viewports }
  167. { * OutTextXY() should not update the CP }
  168. { * ClearViewPort() would not update the CP }
  169. { * ClearDevice() would not update the CP }
  170. { * Sector() would update the CP by calling LineTo }
  171. { * Bar3D() would update the CP }
  172. { * PieSlice() would update the CP }
  173. { 18th april 1999: }
  174. { + Clipping algorithm }
  175. { 19th april 1999: }
  176. { + Adapterinfo structure }
  177. { 20th april 1999: }
  178. { + GetModeName }
  179. { + GetGraphMode }
  180. { + GetModeRange }
  181. {--------------------------------------------------------}
  182. { LEFT TO DO: }
  183. { - optimize scaling of stroked fonts }
  184. { - optimize InternalEllipse() }
  185. { using linear appx. of sine/cosine tables }
  186. { - justification for stroked fonts does not work }
  187. { - On Closegraph deallocate all font pointers }
  188. {--------------------------------------------------------}
  189. { text.inc will crash on aligned requirement machines. }
  190. { (packed record for fontrec) }
  191. {$ifndef fpc}
  192. {$G+}
  193. {$endif}
  194. Interface
  195. {$ifdef win32}
  196. uses
  197. windows;
  198. {$endif win32}
  199. const
  200. { error codes }
  201. grOk = 0;
  202. grNoInitGraph = -1;
  203. grNotDetected = -2;
  204. grFileNotFound = -3;
  205. grInvalidDriver = -4;
  206. grNoLoadMem = -5;
  207. grNoScanMem = -6;
  208. grNoFloodMem = -7;
  209. grFontNotFound = -8;
  210. grNoFontMem = -9;
  211. grInvalidMode = -10;
  212. grError = -11;
  213. grIOerror = -12;
  214. grInvalidFont = -13;
  215. grInvalidFontNum = -14;
  216. grInvalidVersion = -18;
  217. { Color constants for setpalette }
  218. black = 0;
  219. blue = 1;
  220. green = 2;
  221. cyan = 3;
  222. red = 4;
  223. magenta = 5;
  224. brown = 6;
  225. lightgray = 7;
  226. darkgray = 8;
  227. lightblue = 9;
  228. lightgreen = 10;
  229. lightcyan = 11;
  230. lightred = 12;
  231. lightmagenta = 13;
  232. yellow = 14;
  233. white = 15;
  234. EGABlack = 0;
  235. EGABlue = 1;
  236. EGAGreen = 2;
  237. EGACyan = 3;
  238. EGARed = 4;
  239. EGAMagenta = 5;
  240. EGALightgray= 7;
  241. EGABrown = 20;
  242. EGADarkgray = 56;
  243. EGALightblue = 57;
  244. EGALightgreen = 58;
  245. EGALightcyan = 59;
  246. EGALightred = 60;
  247. EGALightmagenta=61;
  248. EGAYellow = 62;
  249. EGAWhite = 63;
  250. { Line styles for GetLineStyle/SetLineStyle }
  251. SolidLn = 0;
  252. DottedLn = 1;
  253. CenterLn = 2;
  254. DashedLn = 3;
  255. UserBitLn = 4;
  256. NormWidth = 1;
  257. ThickWidth = 3;
  258. { Set/GetTextStyle Konstanten: }
  259. DefaultFont = 0;
  260. TriplexFont = 1;
  261. SmallFont = 2;
  262. SansSerifFont = 3;
  263. GothicFont = 4;
  264. ScriptFont = 5;
  265. SimpleFont = 6;
  266. TSCRFont = 7;
  267. LCOMFont = 8;
  268. EuroFont = 9;
  269. BoldFont = 10;
  270. HorizDir = 0;
  271. VertDir = 1;
  272. UserCharSize = 0;
  273. ClipOn = true;
  274. ClipOff = false;
  275. { Bar3D constants }
  276. TopOn = true;
  277. TopOff = false;
  278. { fill pattern for Get/SetFillStyle: }
  279. EmptyFill = 0;
  280. SolidFill = 1;
  281. LineFill = 2;
  282. LtSlashFill = 3;
  283. SlashFill = 4;
  284. BkSlashFill = 5;
  285. LtBkSlashFill = 6;
  286. HatchFill = 7;
  287. XHatchFill = 8;
  288. InterleaveFill = 9;
  289. WideDotFill = 10;
  290. CloseDotFill = 11;
  291. UserFill = 12;
  292. { bitblt operators }
  293. NormalPut = 0;
  294. CopyPut = 0;
  295. XORPut = 1;
  296. OrPut = 2;
  297. AndPut = 3;
  298. NotPut = 4;
  299. { SetTextJustify constants }
  300. LeftText = 0;
  301. CenterText = 1;
  302. RightText = 2;
  303. BottomText = 0;
  304. TopText = 2;
  305. { graphic drivers }
  306. CurrentDriver = -128;
  307. Detect = 0;
  308. LowRes = 1;
  309. HercMono = 7;
  310. VGA = 9;
  311. VESA = 10;
  312. { graph modes }
  313. Default = 0;
  314. { VGA Driver modes }
  315. VGALo = 0;
  316. VGAMed = 1;
  317. VGAHi = 2;
  318. { Hercules mono card }
  319. HercMonoHi = 0;
  320. MaxColors = 255; { Maximum possible colors using a palette }
  321. { otherwise, direct color encoding }
  322. type
  323. RGBRec = packed record
  324. Red: integer;
  325. Green: integer;
  326. Blue : integer;
  327. end;
  328. PaletteType = record
  329. Size : longint;
  330. Colors : array[0..MaxColors] of RGBRec;
  331. end;
  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. {$IFDEF FPC}
  362. graph_int = longint; { platform specific integer used for indexes;
  363. should be 16 bits on TP/BP and 32 bits on every-
  364. thing else for speed reasons }
  365. graph_float = single; { the platform's preferred floating point size }
  366. {$ELSE}
  367. graph_int = integer; { platform specific integer used for indexes;
  368. should be 16 bits on TP/BP and 32 bits on every-
  369. thing else for speed reasons }
  370. graph_float = real; { the platform's preferred floating point size }
  371. {$ENDIF}
  372. const
  373. fillpatternTable : array[0..12] of FillPatternType = (
  374. ($00,$00,$00,$00,$00,$00,$00,$00), { background color }
  375. ($ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff), { foreground color }
  376. ($ff,$ff,$00,$00,$ff,$ff,$00,$00), { horizontal lines }
  377. ($01,$02,$04,$08,$10,$20,$40,$80), { slashes }
  378. ($07,$0e,$1c,$38,$70,$e0,$c1,$83), { thick slashes }
  379. ($07,$83,$c1,$e0,$70,$38,$1c,$0e), { thick backslashes }
  380. ($5a,$2d,$96,$4b,$a5,$d2,$69,$b4), { backslashes }
  381. ($ff,$88,$88,$88,$ff,$88,$88,$88), { small boxes }
  382. ($18,$24,$42,$81,$81,$42,$24,$18), { rhombus }
  383. ($cc,$33,$cc,$33,$cc,$33,$cc,$33), { wall pattern }
  384. ($80,$00,$08,$00,$80,$00,$08,$00), { wide points }
  385. ($88,$00,$22,$00,$88,$00,$22,$00), { dense points }
  386. (0,0,0,0,0,0,0,0) { user defined line style }
  387. );
  388. { ******************** PROCEDURAL VARIABLES ********************* }
  389. { * These are hooks which have device specific stuff in them, * }
  390. { * therefore to add new modes or to redirect these routines * }
  391. { * then declare variables of these types as shown below. * }
  392. {-----------------------------------------------------------------}
  393. TYPE
  394. { This is the standard putpixel routine used by all function }
  395. { drawing routines, it will use the viewport settings, as }
  396. { well as clip, and use the current foreground color to plot }
  397. { the desired pixel. }
  398. defpixelproc = procedure(X,Y: Integer);
  399. { standard plot and get pixel }
  400. getpixelproc = function(X,Y: Integer): word;
  401. putpixelproc = procedure(X,Y: Integer; Color: Word);
  402. { clears the viewport, also used to clear the device }
  403. clrviewproc = procedure;
  404. { putimage procedure, can be hooked to accomplish transparency }
  405. putimageproc = procedure (X,Y: Integer; var Bitmap; BitBlt: Word);
  406. getimageproc = procedure(X1,Y1,X2,Y2: Integer; Var Bitmap);
  407. imagesizeproc= function (X1,Y1,X2,Y2: Integer): longint;
  408. graphfreememprc = procedure (var P: Pointer; size: word);
  409. graphgetmemprc = procedure (var P: pointer; size: word);
  410. { internal routines -- can be hooked for much faster drawing }
  411. { draw filled horizontal lines using current color }
  412. { on entry coordinates are already clipped. }
  413. hlineproc = procedure (x, x2,y : integer);
  414. { on entry coordinates are already clipped. }
  415. { draw filled vertical line using current color }
  416. vlineproc = procedure (x,y,y2: integer);
  417. { this routine is used to draw filled patterns for all routines }
  418. { that require it. (FillPoly, FloodFill, Sector, etc... }
  419. { clipping is verified, uses current Fill settings for drawing }
  420. patternlineproc = procedure (x1,x2,y: integer);
  421. { this routine is used to draw all circles/ellipses/sectors }
  422. { more info... on this later... }
  423. ellipseproc = procedure (X,Y: Integer;XRadius: word;
  424. YRadius:word; stAngle,EndAngle: word; fp: PatternLineProc);
  425. { Line routine - draws lines thick/norm widths with current }
  426. { color and line style - LINE must be clipped here. }
  427. lineproc = procedure (X1, Y1, X2, Y2 : Integer);
  428. { this routine is used for FloodFill - it returns an entire }
  429. { screen scan line with a word for each pixel in the scanline }
  430. getscanlineproc = procedure (Y : integer; var data);
  431. { changes the active display screen where we draw to... }
  432. setactivepageproc = procedure (page: word);
  433. { changes the active display screen which we see ... }
  434. setvisualpageproc = procedure (page: word);
  435. { this routine actually switches to the desired video mode. }
  436. initmodeproc = procedure;
  437. { this routine is called to save the sate just before a mode set }
  438. savestateproc = procedure;
  439. { this routine is called in closegraph to cleanup... }
  440. restorestateproc = procedure;
  441. { This routine is a hook for SetRGBPalette }
  442. setrgbpaletteproc =
  443. procedure(ColorNum, RedValue, GreenValue, BlueValue: Integer);
  444. { This routine is a hook for GetRGBPalette }
  445. getrgbpaletteproc =
  446. procedure(ColorNum: integer; var
  447. RedValue, GreenValue, BlueValue: Integer);
  448. TYPE
  449. {-----------------------------------}
  450. { Linked list for mode information }
  451. { This list is set up by one of the }
  452. { following routines: }
  453. { It lists all available resolutions}
  454. { on this display adapter. }
  455. {-----------------------------------}
  456. { QueryAdapter() }
  457. { DetectGraph() }
  458. { InitGraph() }
  459. {-----------------------------------}
  460. PModeInfo = ^TModeInfo;
  461. TModeInfo = record
  462. DriverNumber: Integer;
  463. ModeNumber: Integer;
  464. MaxColor: Longint; { Maximum colors on screen }
  465. PaletteSize : Longint; { Maximum palette entry we can change }
  466. XAspect : Integer; { XAspect ratio correction factor }
  467. YAspect : Integer; { YAspect ratio correction factor }
  468. MaxX: Integer; { Max-X row }
  469. MaxY: Integer; { Max. column. }
  470. DirectColor: boolean; { Is this a direct color mode?? }
  471. Hardwarepages: byte; { total number of image pages - 1 }
  472. ModeName: String[18];
  473. { necessary hooks ... }
  474. DirectPutPixel : DefPixelProc;
  475. GetPixel : GetPixelProc;
  476. PutPixel : PutPixelProc;
  477. SetRGBPalette : SetRGBPaletteProc;
  478. GetRGBPalette : GetRGBPaletteProc;
  479. { defaults possible ... }
  480. SetVisualPage : SetVisualPageProc;
  481. SetActivePage : SetActivePageProc;
  482. ClearViewPort : ClrViewProc;
  483. PutImage : PutImageProc;
  484. GetImage : GetImageProc;
  485. ImageSize : ImageSizeProc;
  486. GetScanLine : GetScanLineProc;
  487. Line : LineProc;
  488. InternalEllipse: EllipseProc;
  489. PatternLine : PatternLineProc;
  490. HLine : HLineProc;
  491. VLine : VLineProc;
  492. InitMode : InitModeProc;
  493. next: PModeInfo;
  494. end;
  495. VAR
  496. DirectPutPixel : DefPixelProc;
  497. ClearViewPort : ClrViewProc;
  498. PutPixel : PutPixelProc;
  499. PutImage : PutImageProc;
  500. GetImage : GetImageProc;
  501. ImageSize : ImageSizeProc;
  502. GetPixel : GetPixelProc;
  503. SetVisualPage : SetVisualPageProc;
  504. SetActivePage : SetActivePageProc;
  505. SetRGBPalette : SetRGBPaletteProc;
  506. GetRGBPalette : GetRGBPaletteProc;
  507. GraphFreeMemPtr: graphfreememprc;
  508. GraphGetMemPtr : graphgetmemprc;
  509. GetScanLine : GetScanLineProc;
  510. Line : LineProc;
  511. InternalEllipse: EllipseProc;
  512. PatternLine : PatternLineProc;
  513. HLine : HLineProc;
  514. VLine : VLineProc;
  515. SaveVideoState : SaveStateProc;
  516. RestoreVideoState: RestoreStateProc;
  517. ExitSave: pointer;
  518. {$ifdef win32}
  519. { this procedure allows to hook keyboard message of the graph unit window }
  520. charmessagehandler : function(Window: hwnd; AMessage, WParam,
  521. LParam: Longint): Longint;
  522. {$endif win32}
  523. Procedure Closegraph;
  524. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  525. function GraphErrorMsg(ErrorCode: Integer): string;
  526. Function GetMaxX: Integer;
  527. Function GetMaxY: Integer;
  528. Procedure SetViewPort(X1, Y1, X2, Y2: Integer; Clip: Boolean);
  529. Function GraphResult: Integer;
  530. function GetModeName(ModeNumber: integer): string;
  531. procedure SetGraphMode(Mode: Integer);
  532. function GetGraphMode: Integer;
  533. function GetMaxMode: word;
  534. procedure RestoreCrtMode;
  535. procedure GetModeRange(GraphDriver: Integer; var LoMode, HiMode: Integer);
  536. Function GetX: Integer;
  537. Function GetY: Integer;
  538. procedure GraphDefaults;
  539. procedure ClearDevice;
  540. procedure GetViewSettings(var viewport : ViewPortType);
  541. procedure SetWriteMode(WriteMode : integer);
  542. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  543. procedure GetFillPattern(var FillPattern:FillPatternType);
  544. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  545. procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;const PathToDriver:String);
  546. procedure DetectGraph(var GraphDriver:Integer;var GraphMode:Integer);
  547. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): integer;
  548. function RegisterBGIDriver(driver: pointer): integer;
  549. procedure SetFillStyle(Pattern : word; Color: word);
  550. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  551. Function GetDriverName: string;
  552. procedure MoveRel(Dx, Dy: Integer);
  553. procedure MoveTo(X,Y: Integer);
  554. procedure SetDirectVideo(DirectAccess: boolean);
  555. function GetDirectVideo: boolean;
  556. { -------------------- Color/Palette ------------------------------- }
  557. procedure SetBkColor(ColorNum: Word);
  558. function GetColor: Word;
  559. function GetBkColor: Word;
  560. procedure SetColor(Color: Word);
  561. function GetMaxColor: word;
  562. procedure SetAllPalette(var Palette:PaletteType);
  563. procedure SetPalette(ColorNum: word; Color: shortint);
  564. procedure GetPalette(var Palette: PaletteType);
  565. function GetPaletteSize: integer;
  566. procedure GetDefaultPalette(var Palette: PaletteType);
  567. { -------------------- Shapes/Lines -------------------------------- }
  568. procedure Rectangle(x1,y1,x2,y2:integer);
  569. procedure Bar(x1,y1,x2,y2:integer);
  570. procedure Bar3D(x1, y1, x2, y2 : integer;depth : word;top : boolean);
  571. procedure FillPoly(NumPoints: word; Var PolyPoints);
  572. procedure DrawPoly(NumPoints : word;var polypoints);
  573. procedure LineRel(Dx, Dy: Integer);
  574. procedure LineTo(X,Y : Integer);
  575. procedure FloodFill(x : integer; y : integer; Border: word);
  576. { -------------------- Circle related routines --------------------- }
  577. procedure GetAspectRatio(var Xasp,Yasp : word);
  578. procedure SetAspectRatio(Xasp, Yasp : word);
  579. procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  580. procedure Arc(X,Y : Integer; StAngle,EndAngle,Radius: word);
  581. procedure PieSlice(X,Y,stangle,endAngle:integer;Radius: Word);
  582. procedure FillEllipse(X, Y: Integer; XRadius, YRadius: Word);
  583. procedure Circle(X, Y: Integer; Radius:Word);
  584. procedure Sector(x, y: Integer; StAngle,EndAngle, XRadius, YRadius: Word);
  585. procedure Ellipse(X,Y : Integer; stAngle, EndAngle: word; XRadius,
  586. YRadius: word);
  587. { --------------------- Text related routines --------------------- }
  588. function InstallUserFont(const FontFileName : string) : integer;
  589. function RegisterBGIfont(font : pointer) : integer;
  590. procedure GetTextSettings(var TextInfo : TextSettingsType);
  591. function TextHeight(const TextString : string) : word;
  592. function TextWidth(const TextString : string) : word;
  593. procedure SetTextJustify(horiz,vert : word);
  594. procedure SetTextStyle(font,direction : word;charsize : word);
  595. procedure SetUserCharSize(Multx,Divx,Multy,Divy : word);
  596. procedure OutTextXY(x,y : integer;const TextString : string);
  597. procedure OutText(const TextString : string);
  598. { Load extra graph additions per system like mode constants }
  599. {$i graphh.inc}
  600. Implementation
  601. { what a mess ... it would be much better if the graph unit }
  602. { would follow the structure of the FPC system unit: }
  603. { the main file is system depended and the system independend part }
  604. { is included (FK) }
  605. {$ifdef fpc}
  606. {$ifdef go32v2}
  607. {$define dpmi}
  608. uses go32,ports;
  609. Type TDPMIRegisters = go32.registers;
  610. {$endif go32v2}
  611. {$ifdef win32}
  612. uses
  613. strings;
  614. {$endif}
  615. {$else fpc}
  616. {$IFDEF DPMI}
  617. uses WinAPI;
  618. {$ENDIF}
  619. {$endif fpc}
  620. {$ifdef logging}
  621. var debuglog: text;
  622. function strf(l: longint): string;
  623. begin
  624. str(l, strf)
  625. end;
  626. Procedure Log(Const s: String);
  627. Begin
  628. Append(debuglog);
  629. Write(debuglog, s);
  630. Close(debuglog);
  631. End;
  632. Procedure LogLn(Const s: string);
  633. Begin
  634. Append(debuglog);
  635. Writeln(debuglog,s);
  636. Close(debuglog);
  637. End;
  638. {$endif logging}
  639. const
  640. StdBufferSize = 4096; { Buffer size for FloodFill }
  641. type
  642. tinttable = array[0..16383] of integer;
  643. pinttable = ^tinttable;
  644. WordArray = Array [0..StdbufferSize] Of word;
  645. PWordArray = ^WordArray;
  646. const
  647. { Mask for each bit in byte used to determine pattern }
  648. BitArray: Array[0..7] of byte =
  649. ($01,$02,$04,$08,$10,$20,$40,$80);
  650. RevbitArray: Array[0..7] of byte =
  651. ($80,$40,$20,$10,$08,$04,$02,$01);
  652. { pre expanded line patterns }
  653. { 0 = LSB of byte pattern }
  654. { 15 = MSB of byte pattern }
  655. LinePatterns: Array[0..15] of BOOLEAN =
  656. (TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,
  657. TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE);
  658. const
  659. BGIPath : string = '.';
  660. { Default font 8x8 system from IBM PC }
  661. {$i fontdata.inc}
  662. var
  663. CurrentColor: Word;
  664. CurrentBkColor: Word;
  665. CurrentX : Integer; { viewport relative }
  666. CurrentY : Integer; { viewport relative }
  667. ClipPixels: Boolean; { Should cliiping be enabled }
  668. CurrentWriteMode: Integer;
  669. _GraphResult : Integer;
  670. LineInfo : LineSettingsType;
  671. FillSettings: FillSettingsType;
  672. { information for Text Output routines }
  673. CurrentTextInfo : TextSettingsType;
  674. CurrentXRatio, CurrentYRatio: graph_float;
  675. installedfonts: longint; { Number of installed fonts }
  676. StartXViewPort: Integer; { absolute }
  677. StartYViewPort: Integer; { absolute }
  678. ViewWidth : Integer;
  679. ViewHeight: Integer;
  680. IsGraphMode : Boolean; { Indicates if we are in graph mode or not }
  681. ArcCall: ArcCoordsType; { Information on the last call to Arc or Ellipse }
  682. var
  683. { ******************** HARDWARE INFORMATION ********************* }
  684. { Should be set in InitGraph once only. }
  685. IntCurrentMode : Integer;
  686. IntCurrentDriver : Integer; { Currently loaded driver }
  687. XAspect : Integer;
  688. YAspect : Integer;
  689. MaxX : Integer; { Maximum resolution - ABSOLUTE }
  690. MaxY : Integer; { Maximum resolution - ABSOLUTE }
  691. MaxColor : Longint;
  692. PaletteSize : longint; { Maximum palette entry we can set, usually equal}
  693. { maxcolor. }
  694. HardwarePages : byte; { maximum number of hardware visual pages }
  695. DriverName: String;
  696. DirectColor : Boolean ; { Is it a direct color mode? }
  697. ModeList : PModeInfo;
  698. DirectVideo : Boolean; { Direct access to video memory? }
  699. {--------------------------------------------------------------------------}
  700. { }
  701. { LINE AND LINE RELATED ROUTINES }
  702. { }
  703. {--------------------------------------------------------------------------}
  704. {$i clip.inc}
  705. procedure HLineDefault(x,x2,y: integer); {$ifndef fpc}far;{$endif fpc}
  706. var
  707. xtmp: integer;
  708. Begin
  709. { must we swap the values? }
  710. if x >= x2 then
  711. Begin
  712. xtmp := x2;
  713. x2 := x;
  714. x:= xtmp;
  715. end;
  716. { First convert to global coordinates }
  717. X := X + StartXViewPort;
  718. X2 := X2 + StartXViewPort;
  719. Y := Y + StartYViewPort;
  720. if ClipPixels then
  721. Begin
  722. if LineClipped(x,y,x2,y,StartXViewPort,StartYViewPort,
  723. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  724. exit;
  725. end;
  726. for x:= x to x2 do
  727. DirectPutPixel(X,Y);
  728. end;
  729. procedure VLineDefault(x,y,y2: integer); {$ifndef fpc}far;{$endif fpc}
  730. var
  731. ytmp: integer;
  732. Begin
  733. { must we swap the values? }
  734. if y >= y2 then
  735. Begin
  736. ytmp := y2;
  737. y2 := y;
  738. y:= ytmp;
  739. end;
  740. { First convert to global coordinates }
  741. X := X + StartXViewPort;
  742. Y2 := Y2 + StartYViewPort;
  743. Y := Y + StartYViewPort;
  744. if ClipPixels then
  745. Begin
  746. if LineClipped(x,y,x,y2,StartXViewPort,StartYViewPort,
  747. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  748. exit;
  749. end;
  750. for y := y to y2 do Directputpixel(x,y)
  751. End;
  752. Procedure DirectPutPixelClip(x,y: Integer);
  753. { for thickwidth lines, because they may call DirectPutPixel for coords }
  754. { outside the current viewport (bug found by CEC) }
  755. Begin
  756. If (Not ClipPixels) Or
  757. ((X >= StartXViewPort) And (X <= (StartXViewPort + ViewWidth)) And
  758. (Y >= StartYViewPort) And (Y <= (StartYViewPort + ViewHeight))) then
  759. Begin
  760. DirectPutPixel(x,y)
  761. End
  762. End;
  763. procedure LineDefault(X1, Y1, X2, Y2: Integer); {$ifndef fpc}far;{$endif fpc}
  764. var X, Y : Integer;
  765. deltax, deltay : Integer;
  766. d, dinc1, dinc2: Integer;
  767. xinc1 : Integer;
  768. xinc2 : Integer;
  769. yinc1 : Integer;
  770. yinc2 : Integer;
  771. i : Integer;
  772. Flag : Boolean; { determines pixel direction in thick lines }
  773. NumPixels : Integer;
  774. PixelCount : Integer;
  775. OldCurrentColor: Word;
  776. swtmp : integer;
  777. TmpNumPixels : integer;
  778. begin
  779. {******************************************}
  780. { SOLID LINES }
  781. {******************************************}
  782. if lineinfo.LineStyle = SolidLn then
  783. Begin
  784. { we separate normal and thick width for speed }
  785. { and because it would not be 100% compatible }
  786. { with the TP graph unit otherwise }
  787. if y1 = y2 then
  788. Begin
  789. {******************************************}
  790. { SOLID LINES HORIZONTAL }
  791. {******************************************}
  792. if lineinfo.Thickness=NormWidth then
  793. hline(x1,x2,y2)
  794. else
  795. begin
  796. { thick width }
  797. hline(x1,x2,y2-1);
  798. hline(x1,x2,y2);
  799. hline(x2,x2,y2+1);
  800. end;
  801. end
  802. else
  803. if x1 = x2 then
  804. Begin
  805. {******************************************}
  806. { SOLID LINES VERTICAL }
  807. {******************************************}
  808. if lineinfo.Thickness=NormWidth then
  809. vline(x1,y1,y2)
  810. else
  811. begin
  812. { thick width }
  813. vline(x1-1,y1,y2);
  814. vline(x1,y1,y2);
  815. vline(x1+1,y1,y2);
  816. end;
  817. end
  818. else
  819. begin
  820. { Convert to global coordinates. }
  821. x1 := x1 + StartXViewPort;
  822. x2 := x2 + StartXViewPort;
  823. y1 := y1 + StartYViewPort;
  824. y2 := y2 + StartYViewPort;
  825. { if fully clipped then exit... }
  826. if ClipPixels then
  827. begin
  828. if LineClipped(x1,y1,x2,y2,StartXViewPort, StartYViewPort,
  829. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  830. exit;
  831. end;
  832. {******************************************}
  833. { SLOPED SOLID LINES }
  834. {******************************************}
  835. oldCurrentColor :=
  836. CurrentColor;
  837. { Calculate deltax and deltay for initialisation }
  838. deltax := abs(x2 - x1);
  839. deltay := abs(y2 - y1);
  840. { Initialize all vars based on which is the independent variable }
  841. if deltax >= deltay then
  842. begin
  843. Flag := FALSE;
  844. { x is independent variable }
  845. numpixels := deltax + 1;
  846. d := (2 * deltay) - deltax;
  847. dinc1 := deltay Shl 1;
  848. dinc2 := (deltay - deltax) shl 1;
  849. xinc1 := 1;
  850. xinc2 := 1;
  851. yinc1 := 0;
  852. yinc2 := 1;
  853. end
  854. else
  855. begin
  856. Flag := TRUE;
  857. { y is independent variable }
  858. numpixels := deltay + 1;
  859. d := (2 * deltax) - deltay;
  860. dinc1 := deltax Shl 1;
  861. dinc2 := (deltax - deltay) shl 1;
  862. xinc1 := 0;
  863. xinc2 := 1;
  864. yinc1 := 1;
  865. yinc2 := 1;
  866. end;
  867. { Make sure x and y move in the right directions }
  868. if x1 > x2 then
  869. begin
  870. xinc1 := - xinc1;
  871. xinc2 := - xinc2;
  872. end;
  873. if y1 > y2 then
  874. begin
  875. yinc1 := - yinc1;
  876. yinc2 := - yinc2;
  877. end;
  878. { Start drawing at <x1, y1> }
  879. x := x1;
  880. y := y1;
  881. If LineInfo.Thickness=NormWidth then
  882. Begin
  883. { Draw the pixels }
  884. for i := 1 to numpixels do
  885. begin
  886. DirectPutPixel(x, y);
  887. if d < 0 then
  888. begin
  889. d := d + dinc1;
  890. x := x + xinc1;
  891. y := y + yinc1;
  892. end
  893. else
  894. begin
  895. d := d + dinc2;
  896. x := x + xinc2;
  897. y := y + yinc2;
  898. end;
  899. CurrentColor := OldCurrentColor;
  900. end;
  901. end
  902. else
  903. { Thick width lines }
  904. begin
  905. { Draw the pixels }
  906. for i := 1 to numpixels do
  907. begin
  908. { all depending on the slope, we can determine }
  909. { in what direction the extra width pixels will be put }
  910. If Flag then
  911. Begin
  912. DirectPutPixelClip(x-1,y);
  913. DirectPutPixelClip(x,y);
  914. DirectPutPixelClip(x+1,y);
  915. end
  916. else
  917. Begin
  918. DirectPutPixelClip(x, y-1);
  919. DirectPutPixelClip(x, y);
  920. DirectPutPixelClip(x, y+1);
  921. end;
  922. if d < 0 then
  923. begin
  924. d := d + dinc1;
  925. x := x + xinc1;
  926. y := y + yinc1;
  927. end
  928. else
  929. begin
  930. d := d + dinc2;
  931. x := x + xinc2;
  932. y := y + yinc2;
  933. end;
  934. CurrentColor := OldCurrentColor;
  935. end;
  936. end;
  937. end;
  938. end
  939. else
  940. {******************************************}
  941. { begin patterned lines }
  942. {******************************************}
  943. Begin
  944. { Convert to global coordinates. }
  945. x1 := x1 + StartXViewPort;
  946. x2 := x2 + StartXViewPort;
  947. y1 := y1 + StartYViewPort;
  948. y2 := y2 + StartYViewPort;
  949. { if fully clipped then exit... }
  950. if ClipPixels then
  951. begin
  952. if LineClipped(x1,y1,x2,y2,StartXViewPort, StartYViewPort,
  953. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  954. exit;
  955. end;
  956. OldCurrentColor := CurrentColor;
  957. PixelCount:=0;
  958. if y1 = y2 then
  959. Begin
  960. { Check if we must swap }
  961. if x1 >= x2 then
  962. Begin
  963. swtmp := x1;
  964. x1 := x2;
  965. x2 := swtmp;
  966. end;
  967. if LineInfo.Thickness = NormWidth then
  968. Begin
  969. for PixelCount:=x1 to x2 do
  970. { optimization: PixelCount mod 16 }
  971. if LinePatterns[PixelCount and 15] = TRUE then
  972. begin
  973. DirectPutPixel(PixelCount,y2);
  974. end;
  975. end
  976. else
  977. Begin
  978. for i:=-1 to 1 do
  979. Begin
  980. for PixelCount:=x1 to x2 do
  981. { Optimization from Thomas - mod 16 = and 15 }
  982. {this optimization has been performed by the compiler
  983. for while as well (JM)}
  984. if LinePatterns[PixelCount and 15] = TRUE then
  985. begin
  986. DirectPutPixelClip(PixelCount,y2+i);
  987. end;
  988. end;
  989. end;
  990. end
  991. else
  992. if x1 = x2 then
  993. Begin
  994. { Check if we must swap }
  995. if y1 >= y2 then
  996. Begin
  997. swtmp := y1;
  998. y1 := y2;
  999. y2 := swtmp;
  1000. end;
  1001. if LineInfo.Thickness = NormWidth then
  1002. Begin
  1003. for PixelCount:=y1 to y2 do
  1004. { compare if we should plot a pixel here , compare }
  1005. { with predefined line patterns... }
  1006. if LinePatterns[PixelCount and 15] = TRUE then
  1007. begin
  1008. DirectPutPixel(x1,PixelCount);
  1009. end;
  1010. end
  1011. else
  1012. Begin
  1013. for i:=-1 to 1 do
  1014. Begin
  1015. for PixelCount:=y1 to y2 do
  1016. { compare if we should plot a pixel here , compare }
  1017. { with predefined line patterns... }
  1018. if LinePatterns[PixelCount and 15] = TRUE then
  1019. begin
  1020. DirectPutPixelClip(x1+i,PixelCount);
  1021. end;
  1022. end;
  1023. end;
  1024. end
  1025. else
  1026. Begin
  1027. oldCurrentColor := CurrentColor;
  1028. { Calculate deltax and deltay for initialisation }
  1029. deltax := abs(x2 - x1);
  1030. deltay := abs(y2 - y1);
  1031. { Initialize all vars based on which is the independent variable }
  1032. if deltax >= deltay then
  1033. begin
  1034. Flag := FALSE;
  1035. { x is independent variable }
  1036. numpixels := deltax + 1;
  1037. d := (2 * deltay) - deltax;
  1038. dinc1 := deltay Shl 1;
  1039. dinc2 := (deltay - deltax) shl 1;
  1040. xinc1 := 1;
  1041. xinc2 := 1;
  1042. yinc1 := 0;
  1043. yinc2 := 1;
  1044. end
  1045. else
  1046. begin
  1047. Flag := TRUE;
  1048. { y is independent variable }
  1049. numpixels := deltay + 1;
  1050. d := (2 * deltax) - deltay;
  1051. dinc1 := deltax Shl 1;
  1052. dinc2 := (deltax - deltay) shl 1;
  1053. xinc1 := 0;
  1054. xinc2 := 1;
  1055. yinc1 := 1;
  1056. yinc2 := 1;
  1057. end;
  1058. { Make sure x and y move in the right directions }
  1059. if x1 > x2 then
  1060. begin
  1061. xinc1 := - xinc1;
  1062. xinc2 := - xinc2;
  1063. end;
  1064. if y1 > y2 then
  1065. begin
  1066. yinc1 := - yinc1;
  1067. yinc2 := - yinc2;
  1068. end;
  1069. { Start drawing at <x1, y1> }
  1070. x := x1;
  1071. y := y1;
  1072. If LineInfo.Thickness=ThickWidth then
  1073. Begin
  1074. TmpNumPixels := NumPixels-1;
  1075. { Draw the pixels }
  1076. for i := 0 to TmpNumPixels do
  1077. begin
  1078. { all depending on the slope, we can determine }
  1079. { in what direction the extra width pixels will be put }
  1080. If Flag then
  1081. Begin
  1082. { compare if we should plot a pixel here , compare }
  1083. { with predefined line patterns... }
  1084. if LinePatterns[i and 15] = TRUE then
  1085. begin
  1086. DirectPutPixelClip(x-1,y);
  1087. DirectPutPixelClip(x,y);
  1088. DirectPutPixelClip(x+1,y);
  1089. end;
  1090. end
  1091. else
  1092. Begin
  1093. { compare if we should plot a pixel here , compare }
  1094. { with predefined line patterns... }
  1095. if LinePatterns[i and 15] = TRUE then
  1096. begin
  1097. DirectPutPixelClip(x,y-1);
  1098. DirectPutPixelClip(x,y);
  1099. DirectPutPixelClip(x,y+1);
  1100. end;
  1101. end;
  1102. if d < 0 then
  1103. begin
  1104. d := d + dinc1;
  1105. x := x + xinc1;
  1106. y := y + yinc1;
  1107. end
  1108. else
  1109. begin
  1110. d := d + dinc2;
  1111. x := x + xinc2;
  1112. y := y + yinc2;
  1113. end;
  1114. end;
  1115. end
  1116. else
  1117. Begin
  1118. { instead of putting in loop , substract by one now }
  1119. TmpNumPixels := NumPixels-1;
  1120. { NormWidth }
  1121. for i := 0 to TmpNumPixels do
  1122. begin
  1123. if LinePatterns[i and 15] = TRUE then
  1124. begin
  1125. DirectPutPixel(x,y);
  1126. end;
  1127. if d < 0 then
  1128. begin
  1129. d := d + dinc1;
  1130. x := x + xinc1;
  1131. y := y + yinc1;
  1132. end
  1133. else
  1134. begin
  1135. d := d + dinc2;
  1136. x := x + xinc2;
  1137. y := y + yinc2;
  1138. end;
  1139. end;
  1140. end
  1141. end;
  1142. {******************************************}
  1143. { end patterned lines }
  1144. {******************************************}
  1145. { restore color }
  1146. CurrentColor:=OldCurrentColor;
  1147. end;
  1148. end; { Line }
  1149. {********************************************************}
  1150. { Procedure DummyPatternLine() }
  1151. {--------------------------------------------------------}
  1152. { This is suimply an procedure that does nothing which }
  1153. { can be passed as a patternlineproc for non-filled }
  1154. { ellipses }
  1155. {********************************************************}
  1156. Procedure DummyPatternLine(x1, x2, y: integer); {$ifdef tp} far; {$endif tp}
  1157. begin
  1158. end;
  1159. {********************************************************}
  1160. { Procedure InternalEllipse() }
  1161. {--------------------------------------------------------}
  1162. { This routine first calculates all points required to }
  1163. { draw a circle to the screen, and stores the points }
  1164. { to display in a buffer before plotting them. The }
  1165. { aspect ratio of the screen is taken into account when }
  1166. { calculating the values. }
  1167. {--------------------------------------------------------}
  1168. { INPUTS: X,Y : Center coordinates of Ellipse. }
  1169. { XRadius - X-Axis radius of ellipse. }
  1170. { YRadius - Y-Axis radius of ellipse. }
  1171. { stAngle, EndAngle: Start angle and end angles of the }
  1172. { ellipse (used for partial ellipses and circles) }
  1173. { pl: procedure which either draws a patternline (for }
  1174. { FillEllipse) or does nothing (arc etc) }
  1175. {--------------------------------------------------------}
  1176. { NOTE: - }
  1177. { - }
  1178. {********************************************************}
  1179. Procedure InternalEllipseDefault(X,Y: Integer;XRadius: word;
  1180. YRadius:word; stAngle,EndAngle: word; pl: PatternLineProc); {$ifndef fpc}far;{$endif fpc}
  1181. Const ConvFac = Pi/180.0;
  1182. var
  1183. j, Delta, DeltaEnd: graph_float;
  1184. NumOfPixels: longint;
  1185. TempTerm: graph_float;
  1186. xtemp, ytemp, xp, yp, xm, ym, xnext, ynext,
  1187. plxpyp, plxmyp, plxpym, plxmym: integer;
  1188. BackupColor, DeltaAngle, TmpAngle, OldLineWidth: word;
  1189. Begin
  1190. If LineInfo.ThickNess = ThickWidth Then
  1191. { first draw the two outer ellipses using normwidth and no filling (JM) }
  1192. Begin
  1193. OldLineWidth := LineInfo.Thickness;
  1194. LineInfo.Thickness := NormWidth;
  1195. InternalEllipseDefault(x,y,XRadius,YRadius,StAngle,EndAngle,
  1196. {$ifdef fpc}@{$endif fpc}DummyPatternLine);
  1197. InternalEllipseDefault(x,y,XRadius+1,YRadius+1,StAngle,EndAngle,
  1198. {$ifdef fpc}@{$endif fpc}DummyPatternLine);
  1199. If (XRadius <> 0) and (YRadius <> 0) Then
  1200. { draw the smallest ellipse last, since that one will use the }
  1201. { original pl, so it could possibly draw patternlines (JM) }
  1202. Begin
  1203. Dec(XRadius);
  1204. Dec(YRadius);
  1205. End
  1206. Else Exit;
  1207. { restore line thickness }
  1208. LineInfo.Thickness := OldLineWidth;
  1209. End;
  1210. { check for an ellipse with negligable x and y radius }
  1211. If (xradius <= 1) and (yradius <= 1) then
  1212. begin
  1213. putpixel(x,y,CurrentColor);
  1214. ArcCall.X := X;
  1215. ArcCall.Y := Y;
  1216. ArcCall.XStart := X;
  1217. ArcCall.YStart := Y;
  1218. ArcCall.XEnd := X;
  1219. ArcCall.YEnd := Y;
  1220. exit;
  1221. end;
  1222. { for restoring after PatternLine }
  1223. BackupColor := CurrentColor;
  1224. If xradius = 0 then inc(xradius);
  1225. if yradius = 0 then inc(yradius);
  1226. { check if valid angles }
  1227. stangle := stAngle mod 361;
  1228. EndAngle := EndAngle mod 361;
  1229. { if impossible angles then swap them! }
  1230. if Endangle < StAngle then
  1231. Begin
  1232. TmpAngle:=EndAngle;
  1233. EndAngle:=StAngle;
  1234. Stangle:=TmpAngle;
  1235. end;
  1236. { calculate difference of angle now so we don't always have to calculate it }
  1237. DeltaAngle:= EndAngle-StAngle;
  1238. { approximate the number of pixels required by using the circumference }
  1239. { equation of an ellipse. }
  1240. { Changed this formula a it (trial and error), but the net result is that }
  1241. { less pixels have to be calculated now }
  1242. NumOfPixels:=Round(Sqrt(3)*sqrt(sqr(XRadius)+sqr(YRadius)));
  1243. { Calculate the angle precision required }
  1244. Delta := 90.0 / (NumOfPixels);
  1245. { Adjust for screen aspect ratio }
  1246. XRadius:=(longint(XRadius)*10000) div XAspect;
  1247. YRadius:=(longint(YRadius)*10000) div YAspect;
  1248. { removed from inner loop to make faster }
  1249. { store some arccall info }
  1250. ArcCall.X := X;
  1251. ArcCall.Y := Y;
  1252. TempTerm := (StAngle)*ConvFac;
  1253. ArcCall.XStart := round(XRadius*Cos(TempTerm)) + X;
  1254. ArcCall.YStart := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1255. TempTerm := (EndAngle)*ConvFac;
  1256. ArcCall.XEnd := round(XRadius*Cos(TempTerm)) + X;
  1257. ArcCall.YEnd := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1258. { Always just go over the first 90 degrees. Could be optimized a }
  1259. { bit if StAngle and EndAngle lie in the same quadrant, left as an }
  1260. { exercise for the reader :) (JM) }
  1261. j := 0;
  1262. { calculate stop position, go 1 further than 90 because otherwise }
  1263. { 1 pixel is sometimes not drawn (JM) }
  1264. DeltaEnd := 91;
  1265. { Calculate points }
  1266. xnext := XRadius;
  1267. ynext := 0;
  1268. Repeat
  1269. xtemp := xnext;
  1270. ytemp := ynext;
  1271. { this is used by both sin and cos }
  1272. TempTerm := (j+Delta)*ConvFac;
  1273. { Calculate points }
  1274. xnext := round(XRadius*Cos(TempTerm));
  1275. ynext := round(YRadius*Sin(TempTerm+Pi));
  1276. xp := x + xtemp;
  1277. xm := x - xtemp;
  1278. yp := y + ytemp;
  1279. ym := y - ytemp;
  1280. plxpyp := maxint;
  1281. plxmyp := -maxint-1;
  1282. plxpym := maxint;
  1283. plxmym := -maxint-1;
  1284. If (j >= StAngle) and (j <= EndAngle) then
  1285. begin
  1286. plxpyp := xp;
  1287. PutPixel(xp,yp,CurrentColor);
  1288. end;
  1289. If ((180-j) >= StAngle) and ((180-j) <= EndAngle) then
  1290. begin
  1291. plxmyp := xm;
  1292. PutPixel(xm,yp,CurrentColor);
  1293. end;
  1294. If ((j+180) >= StAngle) and ((j+180) <= EndAngle) then
  1295. begin
  1296. plxmym := xm;
  1297. PutPixel(xm,ym,CurrentColor);
  1298. end;
  1299. If ((360-j) >= StAngle) and ((360-j) <= EndAngle) then
  1300. begin
  1301. plxpym := xp;
  1302. PutPixel(xp,ym,CurrentColor);
  1303. end;
  1304. If (ynext <> ytemp) and
  1305. (xp <> xm) then
  1306. begin
  1307. CurrentColor := FillSettings.Color;
  1308. pl(plxmyp+1,plxpyp-1,yp);
  1309. pl(plxmym+1,plxpym-1,ym);
  1310. CurrentColor := BackupColor;
  1311. end;
  1312. j:=j+Delta;
  1313. Until j > (DeltaEnd);
  1314. end;
  1315. {********************************************************}
  1316. { Procedure InternalEllipse() }
  1317. {--------------------------------------------------------}
  1318. { This routine first calculates all points required to }
  1319. { draw a circle to the screen, and stores the points }
  1320. { to display in a buffer before plotting them. The }
  1321. { aspect ratio of the screen is taken into account when }
  1322. { calculating the values. }
  1323. {--------------------------------------------------------}
  1324. { INPUTS: X,Y : Center coordinates of Ellipse. }
  1325. { XRadius - X-Axis radius of ellipse. }
  1326. { YRadius - Y-Axis radius of ellipse. }
  1327. { stAngle, EndAngle: Start angle and end angles of the }
  1328. { ellipse (used for partial ellipses and circles) }
  1329. {--------------------------------------------------------}
  1330. { NOTE: - uses the current write mode. }
  1331. { - Angles must both be between 0 and 360 }
  1332. {********************************************************}
  1333. (*
  1334. Procedure InternalEllipseDefault (x, y : integer;
  1335. xradius, yradius, stAngle, EndAngle : Word; pl: PatternLineProc); {$ifndef fpc} far; {$endif fpc}
  1336. { Draw an ellipse arc. Crude but it works (anyone have a better one?) }
  1337. Var
  1338. aSqr, bSqr, twoaSqr, twobSqr, xa, ya, twoXbSqr, twoYaSqr, error : LongInt;
  1339. Alpha, TempTerm : graph_float;
  1340. BackupColor: Word;
  1341. plxpyp, plxmyp, plxpym, plxmym: integer;
  1342. const
  1343. RadToDeg = 180/Pi;
  1344. Procedure PlotPoints;
  1345. var
  1346. i,j: integer;
  1347. xm, ym: integer;
  1348. xp, yp: integer;
  1349. Begin
  1350. ym := y-ya;
  1351. yp := y+ya;
  1352. xm := x-xa;
  1353. xp := x+xa;
  1354. plxpyp := maxint;
  1355. plxmyp := -maxint-1;
  1356. plxpym := maxint;
  1357. plxmym := -maxint-1;
  1358. if LineInfo.Thickness = Normwidth then
  1359. Begin
  1360. If (Alpha+270>=StAngle) And (Alpha+270<=EndAngle) then
  1361. Begin
  1362. plxmym := xm;
  1363. PutPixel (xm,ym, CurrentColor);
  1364. End;
  1365. If ((180+270)-Alpha>=StAngle) And ((180+270)-Alpha<=EndAngle) then
  1366. Begin
  1367. plxmyp := xm;
  1368. PutPixel (xm,yp, CurrentColor);
  1369. End;
  1370. If ((180+270)+Alpha>=StAngle) And ((180+270)+Alpha<=EndAngle) then
  1371. Begin
  1372. plxpyp := xp;
  1373. PutPixel (xp,yp, CurrentColor);
  1374. End;
  1375. If ((360+270)-Alpha>=StAngle) And ((360+270)-Alpha<=EndAngle) then
  1376. Begin
  1377. plxpym := xp;
  1378. PutPixel (xp,ym, CurrentColor);
  1379. End;
  1380. end
  1381. else
  1382. Begin
  1383. If (Alpha+270>=StAngle) And (Alpha+270<=EndAngle) then
  1384. Begin
  1385. plxmym := xm + 1;
  1386. for i:=-1 to 1 do
  1387. for j:=-1 to 1 do
  1388. PutPixel (xm+i,ym+j, CurrentColor);
  1389. End;
  1390. If ((180+270)-Alpha>=StAngle) And ((180+270)-Alpha<=EndAngle) then
  1391. Begin
  1392. plxmyp := xm + 1;
  1393. for i:=-1 to 1 do
  1394. for j:=-1 to 1 do
  1395. PutPixel (xm+i,yp+j, CurrentColor);
  1396. End;
  1397. If ((180+270)+Alpha>=StAngle) And ((180+270)+Alpha<=EndAngle) then
  1398. Begin
  1399. plxpyp := xp - 1;
  1400. for i:=-1 to 1 do
  1401. for j:=-1 to 1 do
  1402. PutPixel (xp+i,yp+j, CurrentColor);
  1403. End;
  1404. If ((360+270)-Alpha>=StAngle) And ((360+270)-Alpha<=EndAngle) then
  1405. Begin
  1406. plxpym := xp - 1;
  1407. for i:=-1 to 1 do
  1408. for j:=-1 to 1 do
  1409. PutPixel (xp+i,ym+j, CurrentColor);
  1410. End;
  1411. end;
  1412. If (xp <> xm) then
  1413. begin
  1414. CurrentColor := FillSettings.Color;
  1415. pl(plxmyp+1,plxpyp-1,yp);
  1416. pl(plxmym+1,plxpym-1,ym);
  1417. CurrentColor := BackupColor;
  1418. end;
  1419. End;
  1420. Begin
  1421. { check for an ellipse with negligable x and y radius }
  1422. If (xradius <= 1) and (yradius <= 1) then
  1423. begin
  1424. putpixel(x,y,CurrentColor);
  1425. ArcCall.X := X;
  1426. ArcCall.Y := Y;
  1427. ArcCall.XStart := X;
  1428. ArcCall.YStart := Y;
  1429. ArcCall.XEnd := X;
  1430. ArcCall.YEnd := Y;
  1431. exit;
  1432. end;
  1433. { for restoring after PatternLine }
  1434. BackupColor := CurrentColor;
  1435. If xradius = 0 then inc(xradius);
  1436. if yradius = 0 then inc(yradius);
  1437. { store arccall info }
  1438. ArcCall.x := x;
  1439. ArcCall.y := y;
  1440. TempTerm := StAngle*RadToDeg;
  1441. ArcCall.XStart := round(XRadius*Cos(TempTerm)) + X;
  1442. ArcCall.YStart := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1443. TempTerm := EndAngle*RadToDeg;
  1444. ArcCall.XEnd := round(XRadius*Cos(TempTerm)) + X;
  1445. ArcCall.YEnd := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1446. StAngle:=StAngle MOD 361;
  1447. EndAngle:=EndAngle MOD 361;
  1448. StAngle := StAngle + 270;
  1449. EndAngle := EndAngle + 270;
  1450. If StAngle>EndAngle then
  1451. Begin
  1452. StAngle:=StAngle Xor EndAngle; EndAngle:=EndAngle Xor StAngle; StAngle:=EndAngle Xor StAngle;
  1453. End;
  1454. { Adjust for screen aspect ratio }
  1455. XRadius:=(longint(XRadius)*10000) div XAspect;
  1456. YRadius:=(longint(YRadius)*10000) div YAspect;
  1457. aSqr:=LongInt (xradius)*LongInt (xradius);
  1458. bSqr:=LongInt (yradius)*LongInt (yradius);
  1459. twoaSqr:=2*aSqr;
  1460. twobSqr:=2*bSqr;
  1461. xa:=0;
  1462. ya:=yradius;
  1463. twoXbSqr:=0;
  1464. twoYaSqr:=ya*twoaSqr;
  1465. error:=-ya*aSqr;
  1466. While twoXbSqr<=twoYaSqr Do Begin
  1467. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya); { Crude but it works }
  1468. PlotPoints;
  1469. Inc (xa);
  1470. Inc (twoXbSqr,twobSqr);
  1471. Inc (error,twoXbSqr-bSqr);
  1472. If error>=0 then Begin
  1473. Dec (ya);
  1474. Dec (twoYaSqr,twoaSqr);
  1475. Dec (error,twoYaSqr);
  1476. End;
  1477. End;
  1478. xa:=xradius;
  1479. ya:=0;
  1480. twoXbSqr:=xa*twobSqr;
  1481. twoYaSqr:=0;
  1482. error:=-xa*bSqr;
  1483. While twoXbSqr>twoYaSqr Do Begin
  1484. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya);
  1485. PlotPoints;
  1486. Inc (ya);
  1487. Inc (twoYaSqr,twoaSqr);
  1488. Inc (error,twoYaSqr-aSqr);
  1489. If error>=0 then Begin
  1490. Dec (xa);
  1491. Dec (twoXbSqr,twobSqr);
  1492. Dec (error,twoXbSqr);
  1493. End;
  1494. End;
  1495. End;
  1496. *)
  1497. procedure PatternLineDefault(x1,x2,y: integer); {$ifndef fpc}far;{$endif fpc}
  1498. {********************************************************}
  1499. { Draws a horizontal patterned line according to the }
  1500. { current Fill Settings. }
  1501. {********************************************************}
  1502. { Important notes: }
  1503. { - CurrentColor must be set correctly before entering }
  1504. { this routine. }
  1505. {********************************************************}
  1506. var
  1507. NrIterations: Integer;
  1508. i : Integer;
  1509. j : Integer;
  1510. TmpFillPattern : byte;
  1511. OldWriteMode : word;
  1512. OldCurrentColor : word;
  1513. begin
  1514. { convert to global coordinates ... }
  1515. x1 := x1 + StartXViewPort;
  1516. x2 := x2 + StartXViewPort;
  1517. y := y + StartYViewPort;
  1518. { if line was fully clipped then exit...}
  1519. if LineClipped(x1,y,x2,y,StartXViewPort,StartYViewPort,
  1520. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  1521. exit;
  1522. OldWriteMode := CurrentWriteMode;
  1523. CurrentWriteMode := NormalPut;
  1524. { Get the current pattern }
  1525. TmpFillPattern := FillPatternTable
  1526. [FillSettings.Pattern][(y and $7)+1];
  1527. Case TmpFillPattern Of
  1528. 0:
  1529. begin
  1530. OldCurrentColor := CurrentColor;
  1531. CurrentColor := CurrentBkColor;
  1532. { hline converts the coordinates to global ones, but that has been done }
  1533. { already here!!! Convert them back to local ones... (JM) }
  1534. HLine(x1-StartXViewPort,x2-StartXViewPort,y-StartYViewPort);
  1535. CurrentColor := OldCurrentColor;
  1536. end;
  1537. $ff:
  1538. begin
  1539. HLine(x1-StartXViewPort,x2-StartXViewPort,y-StartYViewPort);
  1540. end;
  1541. else
  1542. begin
  1543. { number of times to go throuh the 8x8 pattern }
  1544. NrIterations := abs(x2 - x1+1) div 8;
  1545. Inc(NrIterations);
  1546. For i:= 0 to NrIterations do
  1547. Begin
  1548. for j:=0 to 7 do
  1549. Begin
  1550. { x1 mod 8 }
  1551. if RevBitArray[x1 and 7] and TmpFillPattern <> 0 then
  1552. DirectPutpixel(x1,y)
  1553. else
  1554. begin
  1555. { According to the TP graph manual, we overwrite everything }
  1556. { which is filled up - checked against VGA and CGA drivers }
  1557. { of TP. }
  1558. OldCurrentColor := CurrentColor;
  1559. CurrentColor := CurrentBkColor;
  1560. DirectPutPixel(x1,y);
  1561. CurrentColor := OldCurrentColor;
  1562. end;
  1563. Inc(x1);
  1564. if x1 > x2 then
  1565. begin
  1566. CurrentWriteMode := OldWriteMode;
  1567. exit;
  1568. end;
  1569. end;
  1570. end;
  1571. end;
  1572. End;
  1573. CurrentWriteMode := OldWriteMode;
  1574. end;
  1575. procedure LineRel(Dx, Dy: Integer);
  1576. Begin
  1577. Line(CurrentX, CurrentY, CurrentX + Dx, CurrentY + Dy);
  1578. CurrentX := CurrentX + Dx;
  1579. CurrentY := CurrentY + Dy;
  1580. end;
  1581. procedure LineTo(x,y : Integer);
  1582. Begin
  1583. Line(CurrentX, CurrentY, X, Y);
  1584. CurrentX := X;
  1585. CurrentY := Y;
  1586. end;
  1587. procedure Rectangle(x1,y1,x2,y2:integer);
  1588. begin
  1589. { Do not draw the end points }
  1590. Line(x1,y1,x2-1,y1);
  1591. Line(x1,y1+1,x1,y2);
  1592. Line(x2,y1,x2,y2-1);
  1593. Line(x1+1,y2,x2,y2);
  1594. end;
  1595. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  1596. begin
  1597. Activelineinfo:=Lineinfo;
  1598. end;
  1599. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  1600. var
  1601. i: byte;
  1602. j: byte;
  1603. Begin
  1604. if (LineStyle > UserBitLn) or ((Thickness <> Normwidth) and (Thickness <> ThickWidth)) then
  1605. _GraphResult := grError
  1606. else
  1607. begin
  1608. LineInfo.Thickness := Thickness;
  1609. LineInfo.LineStyle := LineStyle;
  1610. case LineStyle of
  1611. UserBitLn: Lineinfo.Pattern := pattern;
  1612. SolidLn: Lineinfo.Pattern := $ffff; { ------- }
  1613. DashedLn : Lineinfo.Pattern := $F8F8; { -- -- --}
  1614. DottedLn: LineInfo.Pattern := $CCCC; { - - - - }
  1615. CenterLn: LineInfo.Pattern := $FC78; { -- - -- }
  1616. end; { end case }
  1617. { setup pattern styles }
  1618. j:=16;
  1619. for i:=0 to 15 do
  1620. Begin
  1621. dec(j);
  1622. { bitwise mask for each bit in the word }
  1623. if (word($01 shl i) AND LineInfo.Pattern) <> 0 then
  1624. LinePatterns[j]:=TRUE
  1625. else
  1626. LinePatterns[j]:=FALSE;
  1627. end;
  1628. end;
  1629. end;
  1630. {--------------------------------------------------------------------------}
  1631. { }
  1632. { VIEWPORT RELATED ROUTINES }
  1633. { }
  1634. {--------------------------------------------------------------------------}
  1635. Procedure ClearViewPortDefault; {$ifndef fpc}far;{$endif fpc}
  1636. var
  1637. j: integer;
  1638. OldWriteMode, OldCurColor: word;
  1639. LineSets : LineSettingsType;
  1640. Begin
  1641. { CP is always RELATIVE coordinates }
  1642. CurrentX := 0;
  1643. CurrentY := 0;
  1644. { Save all old settings }
  1645. OldCurColor := CurrentColor;
  1646. CurrentColor:=CurrentBkColor;
  1647. OldWriteMode:=CurrentWriteMode;
  1648. GetLineSettings(LineSets);
  1649. { reset to normal line style...}
  1650. SetLineStyle(SolidLn, 0, NormWidth);
  1651. { routines are relative here...}
  1652. for J:=0 to ViewHeight do
  1653. HLine(0, ViewWidth, J);
  1654. { restore old settings...}
  1655. SetLineStyle(LineSets.LineStyle, LineSets.Pattern, LineSets.Thickness);
  1656. CurrentColor := OldCurColor;
  1657. CurrentWriteMode := OldWriteMode;
  1658. end;
  1659. Procedure SetViewPort(X1, Y1, X2, Y2: Integer; Clip: Boolean);
  1660. Begin
  1661. if (X1 > GetMaxX) or (X2 > GetMaxX) or (X1 > X2) or (X1 < 0) then
  1662. Begin
  1663. _GraphResult := grError;
  1664. exit;
  1665. end;
  1666. if (Y1 > GetMaxY) or (Y2 > GetMaxY) or (Y1 > Y2) or (Y1 < 0) then
  1667. Begin
  1668. _GraphResult := grError;
  1669. exit;
  1670. end;
  1671. { CP is always RELATIVE coordinates }
  1672. CurrentX := 0;
  1673. CurrentY := 0;
  1674. StartXViewPort := X1;
  1675. StartYViewPort := Y1;
  1676. ViewWidth := X2-X1;
  1677. ViewHeight:= Y2-Y1;
  1678. ClipPixels := Clip;
  1679. end;
  1680. procedure GetViewSettings(var viewport : ViewPortType);
  1681. begin
  1682. ViewPort.X1 := StartXViewPort;
  1683. ViewPort.Y1 := StartYViewPort;
  1684. ViewPort.X2 := ViewWidth + StartXViewPort;
  1685. ViewPort.Y2 := ViewHeight + StartYViewPort;
  1686. ViewPort.Clip := ClipPixels;
  1687. end;
  1688. procedure ClearDevice;
  1689. var
  1690. ViewPort: ViewPortType;
  1691. begin
  1692. { Reset the CP }
  1693. CurrentX := 0;
  1694. CurrentY := 0;
  1695. { save viewport }
  1696. ViewPort.X1 := StartXviewPort;
  1697. ViewPort.X2 := ViewWidth - StartXViewPort;
  1698. ViewPort.Y1 := StartYViewPort;
  1699. ViewPort.Y2 := ViewHeight - StartYViewPort;
  1700. ViewPort.Clip := ClipPixels;
  1701. { put viewport to full screen }
  1702. StartXViewPort := 0;
  1703. ViewHeight := MaxY;
  1704. StartYViewPort := 0;
  1705. ViewWidth := MaxX;
  1706. ClipPixels := TRUE;
  1707. ClearViewPort;
  1708. { restore old viewport }
  1709. StartXViewPort := ViewPort.X1;
  1710. ViewWidth := ViewPort.X2-ViewPort.X1;
  1711. StartYViewPort := ViewPort.Y1;
  1712. ViewHeight := ViewPort.Y2-ViewPort.Y1;
  1713. ClipPixels := ViewPort.Clip;
  1714. end;
  1715. {--------------------------------------------------------------------------}
  1716. { }
  1717. { BITMAP PUT/GET ROUTINES }
  1718. { }
  1719. {--------------------------------------------------------------------------}
  1720. Procedure GetScanlineDefault (Y : Integer; Var Data); {$ifndef fpc}far;{$endif fpc}
  1721. {**********************************************************}
  1722. { Procedure GetScanLine() }
  1723. {----------------------------------------------------------}
  1724. { Returns the full scanline of the video line of the Y }
  1725. { coordinate. The values are returned in a WORD array }
  1726. { each WORD representing a pixel of the specified scanline }
  1727. { note: we only need the pixels inside the ViewPort! (JM) }
  1728. {**********************************************************}
  1729. Var
  1730. x : Integer;
  1731. Begin
  1732. For x:=0 to ViewWidth Do
  1733. WordArray(Data)[x]:=GetPixel(x, y);
  1734. End;
  1735. Function DefaultImageSize(X1,Y1,X2,Y2: Integer): longint; {$ifndef fpc}far;{$endif fpc}
  1736. Begin
  1737. { each pixel uses two bytes, to enable modes with colors up to 64K }
  1738. { to work. }
  1739. DefaultImageSize := 12 + (((X2-X1+1)*(Y2-Y1+1))*2);
  1740. end;
  1741. Procedure DefaultPutImage(X,Y: Integer; var Bitmap; BitBlt: Word); {$ifndef fpc}far;{$endif fpc}
  1742. type
  1743. pt = array[0..$fffffff] of word;
  1744. ptw = array[0..2] of longint;
  1745. var
  1746. color: word;
  1747. i,j: Integer;
  1748. Y1,X1: Integer;
  1749. k: longint;
  1750. Begin
  1751. X1:= ptw(Bitmap)[0]+X; { get width and adjust end coordinate accordingly }
  1752. Y1:= ptw(Bitmap)[1]+Y; { get height and adjust end coordinate accordingly }
  1753. k:= 3 * Sizeof(longint) div Sizeof(word); { Three reserved longs at start of bitmap }
  1754. for j:=Y to Y1 do
  1755. Begin
  1756. for i:=X to X1 do
  1757. begin
  1758. case BitBlt of
  1759. {$R-}
  1760. CopyPut: color:= pt(Bitmap)[k]; { also = normalput }
  1761. XORPut: color:= pt(Bitmap)[k] XOR GetPixel(i,j);
  1762. OrPut: color:= pt(Bitmap)[k] OR GetPixel(i,j);
  1763. AndPut: color:= pt(Bitmap)[k] AND GetPixel(i,j);
  1764. NotPut: color:= not pt(Bitmap)[k];
  1765. {$ifdef debug}
  1766. {$R+}
  1767. {$endif debug}
  1768. end;
  1769. putpixel(i,j,color);
  1770. Inc(k);
  1771. end;
  1772. end;
  1773. end;
  1774. Procedure DefaultGetImage(X1,Y1,X2,Y2: Integer; Var Bitmap); {$ifndef fpc}far;{$endif fpc}
  1775. type
  1776. pt = array[0..$fffffff] of word;
  1777. ptw = array[0..2] of longint;
  1778. var
  1779. i,j: integer;
  1780. k: longint;
  1781. Begin
  1782. k:= 3 * Sizeof(longint) div Sizeof(word); { Three reserved longs at start of bitmap }
  1783. for j:=Y1 to Y2 do
  1784. Begin
  1785. for i:=X1 to X2 do
  1786. begin
  1787. {$R-}
  1788. pt(Bitmap)[k] :=getpixel(i,j);
  1789. {$ifdef debug}
  1790. {$R+}
  1791. {$endif debug}
  1792. Inc(k);
  1793. end;
  1794. end;
  1795. ptw(Bitmap)[0] := X2-X1; { First longint is width }
  1796. ptw(Bitmap)[1] := Y2-Y1; { Second longint is height }
  1797. ptw(bitmap)[2] := 0; { Third longint is reserved}
  1798. end;
  1799. Procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  1800. Begin
  1801. ArcCoords.X := ArcCall.X;
  1802. ArcCoords.Y := ArcCall.Y;
  1803. ArcCoords.XStart := ArcCall.XStart;
  1804. ArcCoords.YStart := ArcCall.YStart;
  1805. ArcCoords.XEnd := ArcCall.XEnd;
  1806. ArcCoords.YEnd := ArcCall.YEnd;
  1807. end;
  1808. procedure SetVisualPageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1809. begin
  1810. end;
  1811. procedure SetActivePageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1812. begin
  1813. end;
  1814. procedure DirectPutPixelDefault(X,Y: Integer);
  1815. begin
  1816. RunError(218);
  1817. end;
  1818. function GetPixelDefault(X,Y: Integer): word;
  1819. begin
  1820. RunError(218);
  1821. exit(0); { avoid warning }
  1822. end;
  1823. procedure PutPixelDefault(X,Y: Integer; Color: Word);
  1824. begin
  1825. RunError(218);
  1826. end;
  1827. procedure SetRGBPaletteDefault(ColorNum, RedValue, GreenValue, BlueValue: Integer);
  1828. begin
  1829. RunError(218);
  1830. end;
  1831. procedure GetRGBPaletteDefault(ColorNum: integer; var
  1832. RedValue, GreenValue, BlueValue: Integer);
  1833. begin
  1834. RunError(218);
  1835. end;
  1836. Procedure DefaultHooks;
  1837. {********************************************************}
  1838. { Procedure DefaultHooks() }
  1839. {--------------------------------------------------------}
  1840. { Resets all hookable routine either to nil for those }
  1841. { which need overrides, and others to defaults. }
  1842. { This is called each time SetGraphMode() is called. }
  1843. {********************************************************}
  1844. Begin
  1845. { All default hooks procedures }
  1846. {$ifdef fpc}
  1847. { required...}
  1848. DirectPutPixel := @DirectPutPixelDefault;
  1849. PutPixel := @PutPixelDefault;
  1850. GetPixel := @GetPixelDefault;
  1851. SetRGBPalette := @SetRGBPaletteDefault;
  1852. GetRGBPalette := @GetRGBPaletteDefault;
  1853. { optional...}
  1854. SetActivePage := @SetActivePageDefault;
  1855. SetVisualPage := @SetVisualPageDefault;
  1856. ClearViewPort := @ClearViewportDefault;
  1857. PutImage := @DefaultPutImage;
  1858. GetImage := @DefaultGetImage;
  1859. ImageSize := @DefaultImageSize;
  1860. {$else fpc}
  1861. { required...}
  1862. DirectPutPixel := DirectPutPixelDefault;
  1863. PutPixel := PutPixelDefault;
  1864. GetPixel := GetPixelDefault;
  1865. SetRGBPalette := SetRGBPaletteDefault;
  1866. GetRGBPalette := GetRGBPaletteDefault;
  1867. { optional...}
  1868. SetActivePage := SetActivePageDefault;
  1869. SetVisualPage := SetVisualPageDefault;
  1870. ClearViewPort := ClearViewportDefault;
  1871. PutImage := DefaultPutImage;
  1872. GetImage := DefaultGetImage;
  1873. ImageSize := DefaultImageSize;
  1874. {$endif fpc}
  1875. GraphFreeMemPtr := nil;
  1876. GraphGetMemPtr := nil;
  1877. {$ifdef fpc}
  1878. GetScanLine := @GetScanLineDefault;
  1879. Line := @LineDefault;
  1880. InternalEllipse := @InternalEllipseDefault;
  1881. PatternLine := @PatternLineDefault;
  1882. HLine := @HLineDefault;
  1883. VLine := @VLineDefault;
  1884. {$else fpc}
  1885. GetScanLine := GetScanLineDefault;
  1886. Line := LineDefault;
  1887. InternalEllipse := InternalEllipseDefault;
  1888. PatternLine := PatternLineDefault;
  1889. HLine := HLineDefault;
  1890. VLine := VLineDefault;
  1891. {$endif fpc}
  1892. end;
  1893. Procedure InitVars;
  1894. {********************************************************}
  1895. { Procedure InitVars() }
  1896. {--------------------------------------------------------}
  1897. { Resets all internal variables, and resets all }
  1898. { overridable routines. }
  1899. {********************************************************}
  1900. Begin
  1901. DirectVideo := TRUE; { By default use fastest access possible }
  1902. ArcCall.X := 0;
  1903. ArcCall.Y := 0;
  1904. ArcCall.XStart := 0;
  1905. ArcCall.YStart := 0;
  1906. ArcCall.XEnd := 0;
  1907. ArcCall.YEnd := 0;
  1908. { Reset to default values }
  1909. IntCurrentMode := 0;
  1910. IntCurrentDriver := 0;
  1911. XAspect := 0;
  1912. YAspect := 0;
  1913. MaxX := 0;
  1914. MaxY := 0;
  1915. MaxColor := 0;
  1916. PaletteSize := 0;
  1917. DirectColor := FALSE;
  1918. HardwarePages := 0;
  1919. DefaultHooks;
  1920. end;
  1921. {$i modes.inc}
  1922. {$i palette.inc}
  1923. {$i graph.inc}
  1924. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): integer;
  1925. begin
  1926. _graphResult := grError;
  1927. InstallUserDriver:=grError;
  1928. end;
  1929. function RegisterBGIDriver(driver: pointer): integer;
  1930. begin
  1931. _graphResult := grError;
  1932. RegisterBGIDriver:=grError;
  1933. end;
  1934. { ----------------------------------------------------------------- }
  1935. Procedure Arc(X,Y : Integer; StAngle,EndAngle,Radius: word);
  1936. { var
  1937. OldWriteMode: word;}
  1938. Begin
  1939. { Only if we are using thickwidths lines do we accept }
  1940. { XORput write modes. }
  1941. { OldWriteMode := CurrentWriteMode;
  1942. if (LineInfo.Thickness = NormWidth) then
  1943. CurrentWriteMode := NormalPut;}
  1944. {$ifdef fpc}
  1945. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,@DummyPatternLine);
  1946. {$else fpc}
  1947. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,DummyPatternLine);
  1948. {$endif fpc}
  1949. { CurrentWriteMode := OldWriteMode;}
  1950. end;
  1951. procedure Ellipse(X,Y : Integer; stAngle, EndAngle: word; XRadius,YRadius: word);
  1952. Begin
  1953. {$ifdef fpc}
  1954. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,@DummyPatternLine);
  1955. {$else fpc}
  1956. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,DummyPatternLine);
  1957. {$endif fpc}
  1958. end;
  1959. procedure FillEllipse(X, Y: Integer; XRadius, YRadius: Word);
  1960. {********************************************************}
  1961. { Procedure FillEllipse() }
  1962. {--------------------------------------------------------}
  1963. { Draws a filled ellipse using (X,Y) as a center point }
  1964. { and XRadius and YRadius as the horizontal and vertical }
  1965. { axes. The ellipse is filled with the current fill color}
  1966. { and fill style, and is bordered with the current color.}
  1967. {********************************************************}
  1968. begin
  1969. InternalEllipse(X,Y,XRadius,YRadius,0,360,PatternLine)
  1970. end;
  1971. procedure Circle(X, Y: Integer; Radius:Word);
  1972. {********************************************************}
  1973. { Draws a circle centered at X,Y with the given Radius. }
  1974. {********************************************************}
  1975. { Important notes: }
  1976. { - Thickwidth circles use the current write mode, while}
  1977. { normal width circles ALWAYS use CopyPut/NormalPut }
  1978. { mode. (Tested against VGA BGI driver -CEC 13/Aug/99 }
  1979. {********************************************************}
  1980. var OriginalArcInfo: ArcCoordsType;
  1981. OldWriteMode: word;
  1982. begin
  1983. if (Radius = 0) then
  1984. Exit;
  1985. if (Radius = 1) then
  1986. begin
  1987. { only normal put mode is supported by a call to PutPixel }
  1988. PutPixel(X, Y, CurrentColor);
  1989. Exit;
  1990. end;
  1991. { save state of arc information }
  1992. { because it is not needed for }
  1993. { a circle call. }
  1994. move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
  1995. if LineInfo.Thickness = Normwidth then
  1996. begin
  1997. OldWriteMode := CurrentWriteMode;
  1998. CurrentWriteMode := CopyPut;
  1999. end;
  2000. {$ifdef fpc}
  2001. InternalEllipse(X,Y,Radius,Radius,0,360,@DummyPatternLine);
  2002. {$else fpc}
  2003. InternalEllipse(X,Y,Radius,Radius,0,360,DummyPatternLine);
  2004. {$endif fpc}
  2005. if LineInfo.Thickness = Normwidth then
  2006. CurrentWriteMode := OldWriteMode;
  2007. { restore arc information }
  2008. move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
  2009. end;
  2010. procedure SectorPL(x1,x2,y: Integer); {$ifndef fpc}far;{$endif fpc}
  2011. var plx1, plx2: integer;
  2012. {$ifdef sectorpldebug}
  2013. t : text;
  2014. {$endif sectorpldebug}
  2015. begin
  2016. {$ifdef sectorpldebug}
  2017. assign(t,'sector.log');
  2018. append(t);
  2019. writeln(t,'Got here for line ',y);
  2020. close(t);
  2021. {$endif sectorpldebug}
  2022. If (x1 = -maxint) Then
  2023. If (x2 = maxint-1) Then
  2024. { no ellipse points drawn on this line }
  2025. If (((Y < ArcCall.Y) and (Y > ArcCall.YStart)) or
  2026. ((Y > ArcCall.Y) and (Y < ArcCall.YStart))) Then
  2027. { there is a part of the sector at this y coordinate, but no }
  2028. { ellips points are plotted on this line, so draw a patternline }
  2029. { between the lines connecting (arccall.x,arccall.y) with }
  2030. { the start and the end of the arc (JM) }
  2031. { use: y-y1=(y2-y1)/(x2-x1)*(x-x1) => }
  2032. { x = (y-y1)/(y2-y1)*(x2-x1)+x1 }
  2033. Begin
  2034. {$ifdef sectorpldebug}
  2035. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2036. begin
  2037. append(t);
  2038. writeln(t,'bug1');
  2039. close(t);
  2040. runerror(202);
  2041. end;
  2042. {$endif sectorpldebug}
  2043. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2044. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X;
  2045. {$ifdef sectorpldebug}
  2046. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2047. begin
  2048. append(t);
  2049. writeln(t,'bug2');
  2050. close(t);
  2051. runerror(202);
  2052. end;
  2053. {$endif sectorpldebug}
  2054. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2055. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X;
  2056. If plx1 > plx2 then
  2057. begin
  2058. plx1 := plx1 xor plx2;
  2059. plx2 := plx1 xor plx2;
  2060. plx1 := plx1 xor plx2;
  2061. end;
  2062. {$ifdef sectorpldebug}
  2063. append(t);
  2064. writeln(t,'lines: ',plx1,' - ',plx2);
  2065. close(t);
  2066. {$endif sectorpldebug}
  2067. End
  2068. { otherwise two points which have nothing to do with the sector }
  2069. Else exit
  2070. Else
  2071. { the arc is plotted at the right side, but not at the left side, }
  2072. { fill till the line between (ArcCall.X,ArcCall.Y) and }
  2073. { (ArcCall.XStart,ArcCall.YStart) }
  2074. Begin
  2075. If (y < ArcCall.Y) then
  2076. begin
  2077. {$ifdef sectorpldebug}
  2078. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2079. begin
  2080. append(t);
  2081. writeln(t,'bug3');
  2082. close(t);
  2083. runerror(202);
  2084. end;
  2085. {$endif sectorpldebug}
  2086. plx1 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2087. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2088. end
  2089. else if (y > ArcCall.Y) then
  2090. begin
  2091. {$ifdef sectorpldebug}
  2092. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2093. begin
  2094. append(t);
  2095. writeln(t,'bug4');
  2096. close(t);
  2097. runerror(202);
  2098. end;
  2099. {$endif sectorpldebug}
  2100. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2101. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2102. end
  2103. else plx1 := ArcCall.X;
  2104. plx2 := x2;
  2105. {$ifdef sectorpldebug}
  2106. append(t);
  2107. writeln(t,'right: ',plx1,' - ',plx2);
  2108. close(t);
  2109. {$endif sectorpldebug}
  2110. End
  2111. Else
  2112. If (x2 = maxint-1) Then
  2113. { the arc is plotted at the left side, but not at the rigth side. }
  2114. { the right limit can be either the first or second line. Just take }
  2115. { the closest one, but watch out for division by zero! }
  2116. Begin
  2117. If (y < ArcCall.Y) then
  2118. begin
  2119. {$ifdef sectorpldebug}
  2120. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2121. begin
  2122. append(t);
  2123. writeln(t,'bug5');
  2124. close(t);
  2125. runerror(202);
  2126. end;
  2127. {$endif sectorpldebug}
  2128. plx2 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2129. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2130. end
  2131. else if (y > ArcCall.Y) then
  2132. begin
  2133. {$ifdef sectorpldebug}
  2134. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2135. begin
  2136. append(t);
  2137. writeln(t,'bug6');
  2138. close(t);
  2139. runerror(202);
  2140. end;
  2141. {$endif sectorpldebug}
  2142. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2143. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2144. end
  2145. else plx2 := ArcCall.X;
  2146. plx1 := x1;
  2147. {$ifdef sectorpldebug}
  2148. append(t);
  2149. writeln(t,'left: ',plx1,' - ',plx2);
  2150. close(t);
  2151. {$endif sectorpldebug}
  2152. End
  2153. Else
  2154. { the arc is plotted at both sides }
  2155. Begin
  2156. plx1 := x1;
  2157. plx2 := x2;
  2158. {$ifdef sectorpldebug}
  2159. append(t);
  2160. writeln(t,'normal: ',plx1,' - ',plx2);
  2161. close(t);
  2162. {$endif sectorpldebug}
  2163. End;
  2164. If plx2 > plx1 then
  2165. Begin
  2166. {$ifdef sectorpldebug}
  2167. append(t);
  2168. Writeln(t,'drawing...');
  2169. close(t);
  2170. {$endif sectorpldebug}
  2171. PatternLine(plx1,plx2,y);
  2172. end;
  2173. end;
  2174. procedure Sector(x, y: Integer; StAngle,EndAngle, XRadius, YRadius: Word);
  2175. (* var angle : graph_float;
  2176. writemode : word; *)
  2177. begin
  2178. {$ifdef fpc}
  2179. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, @SectorPL);
  2180. {$else fpc}
  2181. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, SectorPL);
  2182. {$endif fpc}
  2183. Line(ArcCall.XStart, ArcCall.YStart, x,y);
  2184. Line(x,y,ArcCall.Xend,ArcCall.YEnd);
  2185. end;
  2186. procedure SetFillStyle(Pattern : word; Color: word);
  2187. begin
  2188. { on invalid input, the current fill setting will be }
  2189. { unchanged. }
  2190. if (Pattern > UserFill) or (Color > GetMaxColor) then
  2191. begin
  2192. _GraphResult := grError;
  2193. exit;
  2194. end;
  2195. FillSettings.Color := Color;
  2196. FillSettings.Pattern := Pattern;
  2197. end;
  2198. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  2199. {********************************************************}
  2200. { Changes the Current FillPattern to a user defined }
  2201. { pattern and changes also the current fill color. }
  2202. { The FillPattern is saved in the FillPattern array so }
  2203. { it can still be used with SetFillStyle(UserFill,Color) }
  2204. {********************************************************}
  2205. var
  2206. i: integer;
  2207. begin
  2208. if Color > GetMaxColor then
  2209. begin
  2210. _GraphResult := grError;
  2211. exit;
  2212. end;
  2213. FillSettings.Color := Color;
  2214. FillSettings.Pattern := UserFill;
  2215. { Save the pattern in the buffer }
  2216. For i:=1 to 8 do
  2217. FillPatternTable[UserFill][i] := Pattern[i];
  2218. end;
  2219. procedure Bar(x1,y1,x2,y2:integer);
  2220. {********************************************************}
  2221. { Important notes for compatibility with BP: }
  2222. { - WriteMode is always CopyPut }
  2223. { - No contour is drawn for the lines }
  2224. {********************************************************}
  2225. var y : Integer;
  2226. origcolor : longint;
  2227. origlinesettings: Linesettingstype;
  2228. origwritemode : Integer;
  2229. begin
  2230. origlinesettings:=lineinfo;
  2231. origcolor:=CurrentColor;
  2232. if y1>y2 then
  2233. begin
  2234. y:=y1;
  2235. y1:=y2;
  2236. y2:=y;
  2237. end;
  2238. { Always copy mode for Bars }
  2239. origwritemode := CurrentWriteMode;
  2240. CurrentWriteMode := CopyPut;
  2241. { All lines used are of this style }
  2242. Lineinfo.linestyle:=solidln;
  2243. Lineinfo.thickness:=normwidth;
  2244. case Fillsettings.pattern of
  2245. EmptyFill :
  2246. begin
  2247. Currentcolor:=CurrentBkColor;
  2248. for y:=y1 to y2 do
  2249. Hline(x1,x2,y);
  2250. end;
  2251. SolidFill :
  2252. begin
  2253. CurrentColor:=FillSettings.color;
  2254. for y:=y1 to y2 do
  2255. Hline(x1,x2,y);
  2256. end;
  2257. else
  2258. Begin
  2259. CurrentColor:=FillSettings.color;
  2260. for y:=y1 to y2 do
  2261. patternline(x1,x2,y);
  2262. end;
  2263. end;
  2264. CurrentColor:= Origcolor;
  2265. LineInfo := OrigLineSettings;
  2266. CurrentWriteMode := OrigWritemode;
  2267. end;
  2268. procedure bar3D(x1, y1, x2, y2 : integer;depth : word;top : boolean);
  2269. var
  2270. origwritemode : integer;
  2271. OldX, OldY : integer;
  2272. begin
  2273. origwritemode := CurrentWriteMode;
  2274. CurrentWriteMode := CopyPut;
  2275. Bar(x1,y1,x2,y2);
  2276. Rectangle(x1,y1,x2,y2);
  2277. { Current CP should not be updated in Bar3D }
  2278. { therefore save it and then restore it on }
  2279. { exit. }
  2280. OldX := CurrentX;
  2281. OldY := CurrentY;
  2282. if top then begin
  2283. Moveto(x1,y1);
  2284. Lineto(x1+depth,y1-depth);
  2285. Lineto(x2+depth,y1-depth);
  2286. Lineto(x2,y1);
  2287. end;
  2288. if Depth <> 0 then
  2289. Begin
  2290. Moveto(x2+depth,y1-depth);
  2291. Lineto(x2+depth,y2-depth);
  2292. Lineto(x2,y2);
  2293. end;
  2294. { restore CP }
  2295. CurrentX := OldX;
  2296. CurrentY := OldY;
  2297. CurrentWriteMode := origwritemode;
  2298. end;
  2299. {--------------------------------------------------------------------------}
  2300. { }
  2301. { COLOR AND PALETTE ROUTINES }
  2302. { }
  2303. {--------------------------------------------------------------------------}
  2304. procedure SetColor(Color: Word);
  2305. Begin
  2306. CurrentColor := Color;
  2307. end;
  2308. function GetColor: Word;
  2309. Begin
  2310. GetColor := CurrentColor;
  2311. end;
  2312. function GetBkColor: Word;
  2313. Begin
  2314. GetBkColor := CurrentBkColor;
  2315. end;
  2316. procedure SetBkColor(ColorNum: Word);
  2317. { Background color means background screen color in this case, and it is }
  2318. { INDEPENDANT of the viewport settings, so we must clear the whole screen }
  2319. { with the color. }
  2320. var
  2321. ViewPort: ViewportType;
  2322. Begin
  2323. GetViewSettings(Viewport);
  2324. SetViewPort(0,0,MaxX,MaxY,FALSE);
  2325. CurrentBkColor := ColorNum;
  2326. ClearViewPort;
  2327. SetViewport(ViewPort.X1,Viewport.Y1,Viewport.X2,Viewport.Y2,Viewport.Clip);
  2328. end;
  2329. function GetMaxColor: word;
  2330. { Checked against TP VGA driver - CEC }
  2331. begin
  2332. GetMaxColor:=MaxColor-1; { based on an index of zero so subtract one }
  2333. end;
  2334. Procedure MoveRel(Dx, Dy: Integer);
  2335. Begin
  2336. CurrentX := CurrentX + Dx;
  2337. CurrentY := CurrentY + Dy;
  2338. end;
  2339. Procedure MoveTo(X,Y: Integer);
  2340. {********************************************************}
  2341. { Procedure MoveTo() }
  2342. {--------------------------------------------------------}
  2343. { Moves the current pointer in VIEWPORT relative }
  2344. { coordinates to the specified X,Y coordinate. }
  2345. {********************************************************}
  2346. Begin
  2347. CurrentX := X;
  2348. CurrentY := Y;
  2349. end;
  2350. function GraphErrorMsg(ErrorCode: Integer): string;
  2351. Begin
  2352. GraphErrorMsg:='';
  2353. case ErrorCode of
  2354. grOk,grFileNotFound,grInvalidDriver: exit;
  2355. grNoInitGraph: GraphErrorMsg:='Graphics driver not installed';
  2356. grNotDetected: GraphErrorMsg:='Graphics hardware not detected';
  2357. grNoLoadMem,grNoScanMem,grNoFloodMem: GraphErrorMsg := 'Not enough memory for graphics';
  2358. grNoFontMem: GraphErrorMsg := 'Not enough memory to load font';
  2359. grFontNotFound: GraphErrorMsg:= 'Font file not found';
  2360. grInvalidMode: GraphErrorMsg := 'Invalid graphics mode';
  2361. grError: GraphErrorMsg:='Graphics error';
  2362. grIoError: GraphErrorMsg:='Graphics I/O error';
  2363. grInvalidFont,grInvalidFontNum: GraphErrorMsg := 'Invalid font';
  2364. grInvalidVersion: GraphErrorMsg:='Invalid driver version';
  2365. end;
  2366. end;
  2367. Function GetMaxX: Integer;
  2368. { Routine checked against VGA driver - CEC }
  2369. Begin
  2370. GetMaxX := MaxX;
  2371. end;
  2372. Function GetMaxY: Integer;
  2373. { Routine checked against VGA driver - CEC }
  2374. Begin
  2375. GetMaxY := MaxY;
  2376. end;
  2377. Function GraphResult: Integer;
  2378. Begin
  2379. GraphResult := _GraphResult;
  2380. _GraphResult := grOk;
  2381. end;
  2382. Function GetX: Integer;
  2383. Begin
  2384. GetX := CurrentX;
  2385. end;
  2386. Function GetY: Integer;
  2387. Begin
  2388. GetY := CurrentY;
  2389. end;
  2390. Function GetDriverName: string;
  2391. begin
  2392. GetDriverName:=DriverName;
  2393. end;
  2394. procedure graphdefaults;
  2395. { PS: GraphDefaults does not ZERO the ArcCall structure }
  2396. { so a call to GetArcCoords will not change even the }
  2397. { returned values even if GraphDefaults is called in }
  2398. { between. }
  2399. var
  2400. i: integer;
  2401. begin
  2402. lineinfo.linestyle:=solidln;
  2403. lineinfo.thickness:=normwidth;
  2404. { reset line style pattern }
  2405. for i:=0 to 15 do
  2406. LinePatterns[i] := TRUE;
  2407. { By default, according to the TP prog's reference }
  2408. { the default pattern is solid, and the default }
  2409. { color is the maximum color in the palette. }
  2410. fillsettings.color:=GetMaxColor;
  2411. fillsettings.pattern:=solidfill;
  2412. { GraphDefaults resets the User Fill pattern to $ff }
  2413. { checked with VGA BGI driver - CEC }
  2414. for i:=1 to 8 do
  2415. FillPatternTable[UserFill][i] := $ff;
  2416. CurrentColor:=white;
  2417. SetBkColor(Black);
  2418. ClipPixels := TRUE;
  2419. { Reset the viewport }
  2420. StartXViewPort := 0;
  2421. StartYViewPort := 0;
  2422. ViewWidth := MaxX;
  2423. ViewHeight := MaxY;
  2424. { Reset CP }
  2425. CurrentX := 0;
  2426. CurrentY := 0;
  2427. { normal write mode }
  2428. CurrentWriteMode := CopyPut;
  2429. { Schriftart einstellen }
  2430. CurrentTextInfo.font := DefaultFont;
  2431. CurrentTextInfo.direction:=HorizDir;
  2432. CurrentTextInfo.charsize:=1;
  2433. CurrentTextInfo.horiz:=LeftText;
  2434. CurrentTextInfo.vert:=TopText;
  2435. XAspect:=10000; YAspect:=10000;
  2436. end;
  2437. procedure GetAspectRatio(var Xasp,Yasp : word);
  2438. begin
  2439. XAsp:=XAspect;
  2440. YAsp:=YAspect;
  2441. end;
  2442. procedure SetAspectRatio(Xasp, Yasp : word);
  2443. begin
  2444. Xaspect:= XAsp;
  2445. YAspect:= YAsp;
  2446. end;
  2447. procedure SetWriteMode(WriteMode : integer);
  2448. { TP sets the writemodes according to the following scheme (JM) }
  2449. begin
  2450. Case writemode of
  2451. xorput, andput: CurrentWriteMode := XorPut;
  2452. notput, orput, copyput: CurrentWriteMode := CopyPut;
  2453. End;
  2454. end;
  2455. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  2456. begin
  2457. Fillinfo:=Fillsettings;
  2458. end;
  2459. procedure GetFillPattern(var FillPattern:FillPatternType);
  2460. begin
  2461. FillPattern:=FillpatternTable[UserFill];
  2462. end;
  2463. procedure DrawPoly(numpoints : word;var polypoints);
  2464. type
  2465. ppointtype = ^pointtype;
  2466. pt = array[0..16000] of pointtype;
  2467. var
  2468. i : longint;
  2469. begin
  2470. if numpoints < 2 then
  2471. begin
  2472. _GraphResult := grError;
  2473. exit;
  2474. end;
  2475. for i:=0 to numpoints-2 do
  2476. line(pt(polypoints)[i].x,
  2477. pt(polypoints)[i].y,
  2478. pt(polypoints)[i+1].x,
  2479. pt(polypoints)[i+1].y);
  2480. end;
  2481. procedure PieSlice(X,Y,stangle,endAngle:integer;Radius: Word);
  2482. begin
  2483. Sector(x,y,stangle,endangle,radius,radius);
  2484. end;
  2485. {$i fills.inc}
  2486. {$i gtext.inc}
  2487. procedure DetectGraph(var GraphDriver:Integer;var GraphMode:Integer);
  2488. var LoMode, HiMode: Integer;
  2489. CpyMode: Integer;
  2490. CpyDriver: Integer;
  2491. begin
  2492. HiMode := -1;
  2493. LoMode := -1;
  2494. { We start at VGA }
  2495. GraphDriver := VGA;
  2496. CpyMode := 0;
  2497. { search all possible graphic drivers in ascending order...}
  2498. { usually the new driver numbers indicate newest hardware...}
  2499. { Internal driver numbers start at VGA=9 }
  2500. repeat
  2501. GetModeRange(GraphDriver,LoMode,HiMode);
  2502. { save the highest mode possible...}
  2503. if HiMode = -1 then break;
  2504. CpyMode:=HiMode;
  2505. CpyDriver:=GraphDriver;
  2506. { go to next driver if it exists...}
  2507. Inc(GraphDriver);
  2508. until (CpyMode=-1);
  2509. { If this is equal to -1 then no graph mode possible...}
  2510. if CpyMode = -1 then
  2511. begin
  2512. _GraphResult := grNotDetected;
  2513. exit;
  2514. end;
  2515. GraphDriver := CpyDriver;
  2516. GraphMode := CpyMode;
  2517. end;
  2518. procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;
  2519. const PathToDriver:String);
  2520. begin
  2521. { path to the fonts (where they will be searched)...}
  2522. bgipath:=PathToDriver;
  2523. if bgipath[length(bgipath)]<>'\' then
  2524. bgipath:=bgipath+'\';
  2525. if not assigned(SaveVideoState) then
  2526. RunError(216);
  2527. {$ifdef logging}
  2528. LogLn('Calling SaveVideoState at '+strf(longint(savevideostate)));
  2529. {$endif logging}
  2530. SaveVideoState;
  2531. InitVars;
  2532. DriverName:=InternalDriverName; { DOS Graphics driver }
  2533. if (Graphdriver=Detect) then
  2534. begin
  2535. DetectGraph(GraphDriver,GraphMode);
  2536. If _GraphResult = grNotDetected then Exit;
  2537. IntCurrentDriver := GraphDriver;
  2538. { Actually set the graph mode...}
  2539. SetGraphMode(GraphMode);
  2540. end
  2541. else
  2542. begin
  2543. { Search if that graphics modec actually exists...}
  2544. if SearchMode(GraphDriver,GraphMode) = nil then
  2545. begin
  2546. _GraphResult := grInvalidMode;
  2547. exit;
  2548. end
  2549. else
  2550. begin
  2551. IntCurrentDriver := GraphDriver;
  2552. SetGraphMode(GraphMode);
  2553. end;
  2554. end;
  2555. end;
  2556. procedure SetDirectVideo(DirectAccess: boolean);
  2557. begin
  2558. DirectVideo := DirectAccess;
  2559. end;
  2560. function GetDirectVideo: boolean;
  2561. begin
  2562. GetDirectVideo := DirectVideo;
  2563. end;
  2564. procedure GraphExitProc; {$ifndef fpc} far; {$endif fpc}
  2565. { deallocates all memory allocated by the graph unit }
  2566. var
  2567. list: PModeInfo;
  2568. tmp : PModeInfo;
  2569. c: graph_int;
  2570. begin
  2571. { restore old exitproc! }
  2572. exitproc := exitsave;
  2573. {$ifdef testsave}
  2574. restorevideostate;
  2575. {$endif testsave}
  2576. { release memory allocated for fonts }
  2577. for c := 1 to installedfonts do
  2578. with fonts[c] Do
  2579. If assigned(instr) Then
  2580. Freemem(instr,instrlength);
  2581. { release memory allocated for modelist }
  2582. list := ModeList;
  2583. while assigned(list) do
  2584. begin
  2585. tmp := list;
  2586. list:=list^.next;
  2587. dispose(tmp);
  2588. end;
  2589. {$IFDEF DPMI}
  2590. { We had copied the buffer of mode information }
  2591. { and allocated it dynamically... now free it }
  2592. { Warning: if GetVESAInfo returned false, this buffer is not allocated! (JM)}
  2593. If hasVesa then
  2594. Dispose(VESAInfo.ModeList);
  2595. {$ENDIF}
  2596. end;
  2597. begin
  2598. {$ifdef logging}
  2599. assign(debuglog,'grlog.txt');
  2600. rewrite(debuglog);
  2601. close(debuglog);
  2602. {$endif logging}
  2603. isgraphmode := false;
  2604. ModeList := nil;
  2605. SaveVideoState := nil;
  2606. RestoreVideoState := nil;
  2607. SavePtr := Nil;
  2608. {$ifdef oldfont}
  2609. {$ifdef go32v2}
  2610. LoadFont8x8;
  2611. {$endif go32v2}
  2612. {$endif oldfont}
  2613. { This must be called at startup... because GetGraphMode may }
  2614. { be called even when not in graph mode. }
  2615. {$ifdef logging}
  2616. LogLn('Calling QueryAdapterInfo...');
  2617. {$endif logging}
  2618. QueryAdapterInfo;
  2619. { Install standard fonts }
  2620. { This is done BEFORE startup... }
  2621. InstalledFonts := 0;
  2622. InstallUserFont('TRIP');
  2623. InstallUserFont('LITT');
  2624. InstallUserFont('SANS');
  2625. InstallUserFont('GOTH');
  2626. { This installs an exit procedure which cleans up the mode list...}
  2627. ExitSave := ExitProc;
  2628. ExitProc := @GraphExitProc;
  2629. {$ifdef testsave}
  2630. savevideostate;
  2631. {$endif testsave}
  2632. {$ifdef win32}
  2633. charmessagehandler:=nil;
  2634. {$endif win32}
  2635. end.
  2636. SetGraphBufSize
  2637. {
  2638. $Log$
  2639. Revision 1.41 1999-11-27 21:48:01 jonas
  2640. * fixed VlineVESA256 and re-enabled it in graph.inc
  2641. * added procedure detectgraph to interface of graph unit
  2642. Revision 1.40 1999/11/25 17:44:14 pierre
  2643. * memory corruption within GetImage removed
  2644. Revision 1.39 1999/11/24 23:42:31 pierre
  2645. * PutImage used an integer index that became negative !!!!
  2646. * Default needed procedure now genrate a RTE 218 instead of a
  2647. GPF by call to nil pointer !
  2648. Revision 1.38 1999/11/11 17:55:07 florian
  2649. * the size was calculated wrong by imagesize
  2650. Revision 1.37 1999/11/11 14:07:14 florian
  2651. * better looking font
  2652. Revision 1.36 1999/11/08 15:01:38 peter
  2653. * fpcmake support
  2654. Revision 1.35 1999/11/08 11:15:22 peter
  2655. * move graph.inc to the target dir
  2656. Revision 1.34 1999/11/03 20:23:01 florian
  2657. + first release of win32 gui support
  2658. Revision 1.33 1999/10/17 10:20:13 jonas
  2659. * fixed clipping for thickwidth lines (bug 659)
  2660. * fixed the faster internalellipsedefault, but it doesn't plot
  2661. all pixels (there are gaps in the ellipses)
  2662. Revision 1.32 1999/09/28 15:07:46 jonas
  2663. * fix for disposing font data because it can contain #0 chars
  2664. Revision 1.31 1999/09/28 13:56:25 jonas
  2665. * reordered some local variables (first 4 byte vars, then 2 byte vars
  2666. etc)
  2667. * font data is now disposed in exitproc, exitproc is now called
  2668. GraphExitProc (was CleanModes) and resides in graph.pp instead of in
  2669. modes.inc
  2670. Revision 1.30 1999/09/27 23:34:41 peter
  2671. * new graph unit is default for go32v2
  2672. * removed warnings/notes
  2673. Revision 1.29 1999/09/26 13:31:06 jonas
  2674. * changed name of modeinfo variable to vesamodeinfo and fixed
  2675. associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
  2676. of sizeof(TVesamodeinfo) etc)
  2677. * changed several sizeof(type) to sizeof(varname) to avoid similar
  2678. errors in the future
  2679. Revision 1.28 1999/09/25 11:48:43 jonas
  2680. + detectgraph
  2681. * small change to internalellipsedefault so less pixels are
  2682. calculated twice
  2683. * some small corrections to graph.tex
  2684. Revision 1.27 1999/09/24 22:52:38 jonas
  2685. * optimized patternline a bit (always use hline when possible)
  2686. * isgraphmode stuff cleanup
  2687. * vesainfo.modelist now gets disposed in cleanmode instead of in
  2688. closegraph (required moving of some declarations from vesa.inc to
  2689. new vesah.inc)
  2690. * queryadapter gets no longer called from initgraph (is called from
  2691. initialization of graph unit)
  2692. * bugfix for notput in 32k and 64k vesa modes
  2693. * a div replaced by / in fillpoly
  2694. Revision 1.26 1999/09/22 13:13:35 jonas
  2695. * renamed text.inc -> gtext.inc to avoid conflict with system unit
  2696. * fixed textwidth
  2697. * isgraphmode now gets properly updated, so mode restoring works
  2698. again
  2699. Revision 1.25 1999/09/18 22:21:10 jonas
  2700. + hlinevesa256 and vlinevesa256
  2701. + support for not/xor/or/andput in vesamodes with 32k/64k colors
  2702. * lots of changes to avoid warnings under FPC
  2703. Revision 1.24 1999/09/18 16:03:37 jonas
  2704. * graph.pp: removed pieslice and sector from ToDo list
  2705. * closegraph: exits now immidiately if isgraphmode = false (caused
  2706. RTE 204 with VESA enabled if you set exitproc to call closegraph
  2707. and also called closegraph explicitely before exit, like bgidemo)
  2708. Revision 1.23 1999/09/17 13:58:31 jonas
  2709. * another fix for a case where internalellipsedefault went haywire
  2710. * sector() and pieslice() fully implemented!
  2711. * small change to prevent buffer overflow with floodfill
  2712. Revision 1.22 1999/09/15 13:37:50 jonas
  2713. * small change to internalellipsedef to be TP compatible
  2714. * fixed directputpixel for vga 320*200*256
  2715. Revision 1.21 1999/09/13 12:49:08 jonas
  2716. * fixed Arc: internallellipse went into an endless loop if StAngle =
  2717. EndAngle
  2718. * FillEllipse is now much faster: no more floodfill,
  2719. InternalEllipseDefault now draws the patternlines immediatety!
  2720. Revision 1.20 1999/09/12 17:29:00 jonas
  2721. * several changes to internalellipse to make it faster
  2722. and to make sure it updates the ArcCall correctly
  2723. (not yet done for width = 3)
  2724. * Arc mostly works now, only sometimes an endless loop, don't know
  2725. why
  2726. Revision 1.19 1999/09/11 19:43:01 jonas
  2727. * FloodFill: did not take into account current viewport settings
  2728. * GetScanLine: only get line inside viewport, data outside of it
  2729. is not used anyway
  2730. * InternalEllipseDefault: fix for when xradius or yradius = 0 and
  2731. increase xradius and yradius always by one (TP does this too)
  2732. * fixed conlict in vesa.inc from last update
  2733. * some conditionals to avoid range check and overflow errors in
  2734. places where it doesn't matter
  2735. Revision 1.18 1999/07/26 09:38:41 florian
  2736. * bar: y2 can be less y1, fixed
  2737. * settextstyle: charsize can be 0, must be changed into 1
  2738. Revision 1.17 1999/07/18 15:07:20 jonas
  2739. + xor-, and and- orput support for VESA256 modes
  2740. * compile with -dlogging if you wnt some info to be logged to grlog.txt
  2741. Revision 1.16 1999/07/14 18:18:04 florian
  2742. * cosmetic changes
  2743. }