graph.pp 102 KB

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