graph.pp 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,99 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Unit Graph;
  12. {-------------------------------------------------------}
  13. { Differences with TP Graph unit: }
  14. { - default putimage and getimage only support a max. }
  15. { of 64K colors on screen, because all pixels are }
  16. { saved as words. }
  17. { - Set RGB Palette is not used, SetPalette must be }
  18. { used instead. }
  19. { - In the TP graph unit, Clipping is always performed }
  20. { on strings written with OutText, and this clipping }
  21. { is done on a character per character basis (for }
  22. { example, if ONE part of a character is outside the }
  23. { viewport , then that character is not written at }
  24. { all to the screen. In FPC Pascal, clipping is done }
  25. { on a PIXEL basis, not a character basis, so part of }
  26. { characters which are not entirely in the viewport }
  27. { may appear on the screen. }
  28. { - SetTextStyle only conforms to the TP version when }
  29. { the correct (and expected) values are used for }
  30. { CharSize for stroked fonts (4 = stroked fonts) }
  31. { - InstallUserDriver is not supported, so always }
  32. { returns an error. }
  33. { - RegisterBGIDriver is not supported, so always }
  34. { returns an error. }
  35. { - DrawPoly XORPut mode is not exactly the same as in }
  36. { the TP graph unit. }
  37. { - Imagesize returns a longint instead of a word }
  38. { - ImageSize cannot return an error value }
  39. {-------------------------------------------------------}
  40. { AUTHORS: }
  41. { Gernot Tenchio - original version }
  42. { Florian Klaempfl - major updates }
  43. { Pierre Mueller - major bugfixes }
  44. { Carl Eric Codere - complete rewrite }
  45. { Thomas Schatzl - optimizations,routines and }
  46. { suggestions. }
  47. { Jonas Maebe - bugfixes and optimizations }
  48. { Credits (external): }
  49. { - Original FloodFill code by }
  50. { Menno Victor van der star }
  51. { (the code has been heavily modified) }
  52. {-------------------------------------------------------}
  53. {-------------------------------------------------------}
  54. { For significant speed improvements , is is recommended }
  55. { that these routines be hooked (otherwise the default, }
  56. { slower routines will be used) : }
  57. { HLine() }
  58. { VLine() }
  59. { PatternLine() }
  60. { ClearViewPort() }
  61. { PutImage() }
  62. { GetImage() - ImageSize() should also be changed }
  63. { InternalEllipse() }
  64. { Line() }
  65. { GetScanLine() }
  66. {--------------------------------------------------------}
  67. { FPC unit requirements: }
  68. { All modes should at least have 1 graphics page to }
  69. { make it possible to create animation on all supported }
  70. { systems , this can be done either by double-buffering }
  71. { yourself in the heap if no hardware is available to do}
  72. { it. }
  73. {--------------------------------------------------------}
  74. { COMPATIBILITY WARNING: Some of the compatibility tests }
  75. { were done using the CGA and other the VGA drivers. }
  76. { Within the BGI drivers themselves the BEHAVIOUR is not }
  77. { the same, so be warned!!! }
  78. {--------------------------------------------------------}
  79. { History log: }
  80. { 15th February 1999: }
  81. { + Added support for system font in vertical mode }
  82. { + system font is now available for all platforms }
  83. { * font support routines now compile }
  84. { * textHeight would not return correct size for system }
  85. { font }
  86. { * Alignment of fonts partly fixed }
  87. { 17th Feb. 1999: }
  88. { + First support for stroked fonts }
  89. { 18th Feb. 1999: }
  90. { * bugfix of line drawing which fixes stroked font }
  91. { displays. }
  92. { 23rd Feb. 1999: }
  93. { + Applied Pierre's patches to font }
  94. { + Added scaling of bitmapped fonts }
  95. { + Vertical stroked fonts }
  96. { 24th Feb. 1999: }
  97. { * Scaling of stroked fonts must be done using FPs }
  98. { to be 100% compatible with turbo pascal }
  99. { + Sped up by 40% stroked font scaling calculations }
  100. { + RegisterBGIFont }
  101. { 9th march 1999: }
  102. { + Starting implementing Fillpoly() }
  103. { 15th march 1999: }
  104. { + SetFillStyle() }
  105. { + patternLine() }
  106. { + Bar() }
  107. { * GraphDefaults would not make the Default color }
  108. { of the fill pattern to the Max. Palette entry. }
  109. { + SetFillPattern() }
  110. { 20th march 1999: }
  111. { * GraphDefaults would not reset to the text system }
  112. { * DefaultFont would write one character too much to }
  113. { the screen }
  114. { + Sloped thick lines in Line() }
  115. { + Sloped patterned lines in Line() }
  116. { * GraphDefaults would not reset the User Fill pattern}
  117. { to $ff }
  118. { + DirectPutPixel takes care of XOR mode writes }
  119. { improves speed by about 30% over old method of }
  120. { GetPixel XOR CurrentColor }
  121. { * Dashed LineStyle exactly like BP version now }
  122. { + Center LineStyle (checked against CGA driver) }
  123. { * GraphDefaults() now resets linepattern array }
  124. { 1st april 1999: }
  125. { + First implementation of FillPoly (incomplete) }
  126. { 2nd april 1999: }
  127. { * FillPoly did not Reset PatternLine index }
  128. { * FillPoly did not use correct color }
  129. { * PatternLine was writing modes in reverse direction }
  130. { * PatternLine would not work with non-rectangular }
  131. { shapes. }
  132. { * PatternLine must fill up the ENTIRE pattern, }
  133. { with either the foreground or background color. }
  134. { * GraphDefaults() would not call SetBkColor() }
  135. { * Fixed some memory leaks in FillPoly() }
  136. { 11th April 1999: }
  137. { * PatternLine() was drawing one pixel less then }
  138. { requested }
  139. { 12th April 1999: }
  140. { + FloodFill - first working implementation }
  141. { Horrbly slow even on very fast cpu's }
  142. { + Some suggestions of Thomas implemented }
  143. { 13th April 1999: }
  144. { * FloodFill() vertical index was off by one pixel }
  145. { * FloodFill() would never draw the last line in the }
  146. { list }
  147. { - Removed ClearViewPort320 which was wrong anyways, }
  148. { will need to be implemented later. }
  149. { * PatternLine() would not always restore write mode }
  150. { + Circle() uses NormalPut always with NormWidth lines}
  151. { + FillEllipse() initial version }
  152. { * InternalEllipse() - 0 to 360 now supported as }
  153. { angles. }
  154. { 14th April 1999: }
  155. { * mod x = and (x-1)(from Thomas Schatzl) gives a }
  156. { significant speed improvement. }
  157. { 15th april 1999: }
  158. { + Arc() ok except for Aspect Ratio, which does not }
  159. { give us the correct ratio on a 320x200 screen. }
  160. { + Added FillPoly() from Thomas Schatzl }
  161. { + More hookable routines }
  162. { 16th april 1999: }
  163. { + Line() checked ok. }
  164. { 17th april 1999: }
  165. { * GraphDefaults() would not reset CP }
  166. { + GetX(), GetY(), MoveTo() checked for viewports }
  167. { * OutTextXY() should not update the CP }
  168. { * ClearViewPort() would not update the CP }
  169. { * ClearDevice() would not update the CP }
  170. { * Sector() would update the CP by calling LineTo }
  171. { * Bar3D() would update the CP }
  172. { * PieSlice() would update the CP }
  173. { 18th april 1999: }
  174. { + Clipping algorithm }
  175. { 19th april 1999: }
  176. { + Adapterinfo structure }
  177. { 20th april 1999: }
  178. { + GetModeName }
  179. { + GetGraphMode }
  180. { + GetModeRange }
  181. {--------------------------------------------------------}
  182. { LEFT TO DO: }
  183. { - optimize scaling of stroked fonts }
  184. { - optimize InternalEllipse() }
  185. { using linear appx. of sine/cosine tables }
  186. { - justification for stroked fonts does not work }
  187. {--------------------------------------------------------}
  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, DeltaAngle, 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. { calculate difference of angle now so we don't always have to calculate it }
  1235. DeltaAngle:= EndAngle-StAngle;
  1236. { approximate the number of pixels required by using the circumference }
  1237. { equation of an ellipse. }
  1238. { Changed this formula a it (trial and error), but the net result is that }
  1239. { less pixels have to be calculated now }
  1240. NumOfPixels:=Round(Sqrt(3)*sqrt(sqr(XRadius)+sqr(YRadius)));
  1241. { Calculate the angle precision required }
  1242. Delta := 90.0 / NumOfPixels;
  1243. { for restoring after PatternLine }
  1244. BackupColor := CurrentColor;
  1245. { removed from inner loop to make faster }
  1246. { store some arccall info }
  1247. ArcCall.X := X;
  1248. ArcCall.Y := Y;
  1249. TempTerm := (StAngle)*ConvFac;
  1250. ArcCall.XStart := round(XRadius*Cos(TempTerm)) + X;
  1251. ArcCall.YStart := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1252. TempTerm := (EndAngle)*ConvFac;
  1253. ArcCall.XEnd := round(XRadius*Cos(TempTerm)) + X;
  1254. ArcCall.YEnd := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1255. { Always just go over the first 90 degrees. Could be optimized a }
  1256. { bit if StAngle and EndAngle lie in the same quadrant, left as an }
  1257. { exercise for the reader :) (JM) }
  1258. j := 0;
  1259. { calculate stop position, go 1 further than 90 because otherwise }
  1260. { 1 pixel is sometimes not drawn (JM) }
  1261. DeltaEnd := 91;
  1262. { Calculate points }
  1263. xnext := XRadius;
  1264. ynext := 0;
  1265. Repeat
  1266. xtemp := xnext;
  1267. ytemp := ynext;
  1268. { this is used by both sin and cos }
  1269. TempTerm := (j+Delta)*ConvFac;
  1270. { Calculate points }
  1271. xnext := round(XRadius*Cos(TempTerm));
  1272. ynext := round(YRadius*Sin(TempTerm+Pi));
  1273. xp := x + xtemp;
  1274. xm := x - xtemp;
  1275. yp := y + ytemp;
  1276. ym := y - ytemp;
  1277. plxpyp := maxsmallint;
  1278. plxmyp := -maxsmallint-1;
  1279. plxpym := maxsmallint;
  1280. plxmym := -maxsmallint-1;
  1281. If (j >= StAngle) and (j <= EndAngle) then
  1282. begin
  1283. plxpyp := xp;
  1284. PutPixel(xp,yp,CurrentColor);
  1285. end;
  1286. If ((180-j) >= StAngle) and ((180-j) <= EndAngle) then
  1287. begin
  1288. plxmyp := xm;
  1289. PutPixel(xm,yp,CurrentColor);
  1290. end;
  1291. If ((j+180) >= StAngle) and ((j+180) <= EndAngle) then
  1292. begin
  1293. plxmym := xm;
  1294. PutPixel(xm,ym,CurrentColor);
  1295. end;
  1296. If ((360-j) >= StAngle) and ((360-j) <= EndAngle) then
  1297. begin
  1298. plxpym := xp;
  1299. PutPixel(xp,ym,CurrentColor);
  1300. end;
  1301. If (ynext <> ytemp) and
  1302. (xp - xm >= 1) then
  1303. begin
  1304. CurrentColor := FillSettings.Color;
  1305. pl(plxmyp+1,plxpyp-1,yp);
  1306. pl(plxmym+1,plxpym-1,ym);
  1307. CurrentColor := BackupColor;
  1308. end;
  1309. j:=j+Delta;
  1310. Until j > (DeltaEnd);
  1311. end;
  1312. {********************************************************}
  1313. { Procedure InternalEllipse() }
  1314. {--------------------------------------------------------}
  1315. { This routine first calculates all points required to }
  1316. { draw a circle to the screen, and stores the points }
  1317. { to display in a buffer before plotting them. The }
  1318. { aspect ratio of the screen is taken into account when }
  1319. { calculating the values. }
  1320. {--------------------------------------------------------}
  1321. { INPUTS: X,Y : Center coordinates of Ellipse. }
  1322. { XRadius - X-Axis radius of ellipse. }
  1323. { YRadius - Y-Axis radius of ellipse. }
  1324. { stAngle, EndAngle: Start angle and end angles of the }
  1325. { ellipse (used for partial ellipses and circles) }
  1326. {--------------------------------------------------------}
  1327. { NOTE: - uses the current write mode. }
  1328. { - Angles must both be between 0 and 360 }
  1329. {********************************************************}
  1330. (*
  1331. Procedure InternalEllipseDefault (x, y : smallint;
  1332. xradius, yradius, stAngle, EndAngle : Word; pl: PatternLineProc); {$ifndef fpc} far; {$endif fpc}
  1333. { Draw an ellipse arc. Crude but it works (anyone have a better one?) }
  1334. Var
  1335. aSqr, bSqr, twoaSqr, twobSqr, xa, ya, twoXbSqr, twoYaSqr, error : LongInt;
  1336. Alpha, TempTerm : graph_float;
  1337. BackupColor: Word;
  1338. plxpyp, plxmyp, plxpym, plxmym: smallint;
  1339. const
  1340. RadToDeg = 180/Pi;
  1341. Procedure PlotPoints;
  1342. var
  1343. i,j: smallint;
  1344. xm, ym: smallint;
  1345. xp, yp: smallint;
  1346. Begin
  1347. ym := y-ya;
  1348. yp := y+ya;
  1349. xm := x-xa;
  1350. xp := x+xa;
  1351. plxpyp := maxsmallint;
  1352. plxmyp := -maxsmallint-1;
  1353. plxpym := maxsmallint;
  1354. plxmym := -maxsmallint-1;
  1355. if LineInfo.Thickness = Normwidth then
  1356. Begin
  1357. If (Alpha+270>=StAngle) And (Alpha+270<=EndAngle) then
  1358. Begin
  1359. plxmym := xm;
  1360. PutPixel (xm,ym, CurrentColor);
  1361. End;
  1362. If ((180+270)-Alpha>=StAngle) And ((180+270)-Alpha<=EndAngle) then
  1363. Begin
  1364. plxmyp := xm;
  1365. PutPixel (xm,yp, CurrentColor);
  1366. End;
  1367. If ((180+270)+Alpha>=StAngle) And ((180+270)+Alpha<=EndAngle) then
  1368. Begin
  1369. plxpyp := xp;
  1370. PutPixel (xp,yp, CurrentColor);
  1371. End;
  1372. If ((360+270)-Alpha>=StAngle) And ((360+270)-Alpha<=EndAngle) then
  1373. Begin
  1374. plxpym := xp;
  1375. PutPixel (xp,ym, CurrentColor);
  1376. End;
  1377. end
  1378. else
  1379. Begin
  1380. If (Alpha+270>=StAngle) And (Alpha+270<=EndAngle) then
  1381. Begin
  1382. plxmym := xm + 1;
  1383. for i:=-1 to 1 do
  1384. for j:=-1 to 1 do
  1385. PutPixel (xm+i,ym+j, CurrentColor);
  1386. End;
  1387. If ((180+270)-Alpha>=StAngle) And ((180+270)-Alpha<=EndAngle) then
  1388. Begin
  1389. plxmyp := xm + 1;
  1390. for i:=-1 to 1 do
  1391. for j:=-1 to 1 do
  1392. PutPixel (xm+i,yp+j, CurrentColor);
  1393. End;
  1394. If ((180+270)+Alpha>=StAngle) And ((180+270)+Alpha<=EndAngle) then
  1395. Begin
  1396. plxpyp := xp - 1;
  1397. for i:=-1 to 1 do
  1398. for j:=-1 to 1 do
  1399. PutPixel (xp+i,yp+j, CurrentColor);
  1400. End;
  1401. If ((360+270)-Alpha>=StAngle) And ((360+270)-Alpha<=EndAngle) then
  1402. Begin
  1403. plxpym := xp - 1;
  1404. for i:=-1 to 1 do
  1405. for j:=-1 to 1 do
  1406. PutPixel (xp+i,ym+j, CurrentColor);
  1407. End;
  1408. end;
  1409. If (xp <> xm) then
  1410. begin
  1411. CurrentColor := FillSettings.Color;
  1412. pl(plxmyp+1,plxpyp-1,yp);
  1413. pl(plxmym+1,plxpym-1,ym);
  1414. CurrentColor := BackupColor;
  1415. end;
  1416. End;
  1417. Begin
  1418. { check for an ellipse with negligable x and y radius }
  1419. If (xradius <= 1) and (yradius <= 1) then
  1420. begin
  1421. putpixel(x,y,CurrentColor);
  1422. ArcCall.X := X;
  1423. ArcCall.Y := Y;
  1424. ArcCall.XStart := X;
  1425. ArcCall.YStart := Y;
  1426. ArcCall.XEnd := X;
  1427. ArcCall.YEnd := Y;
  1428. exit;
  1429. end;
  1430. { for restoring after PatternLine }
  1431. BackupColor := CurrentColor;
  1432. If xradius = 0 then inc(xradius);
  1433. if yradius = 0 then inc(yradius);
  1434. { store arccall info }
  1435. ArcCall.x := x;
  1436. ArcCall.y := y;
  1437. TempTerm := StAngle*RadToDeg;
  1438. ArcCall.XStart := round(XRadius*Cos(TempTerm)) + X;
  1439. ArcCall.YStart := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1440. TempTerm := EndAngle*RadToDeg;
  1441. ArcCall.XEnd := round(XRadius*Cos(TempTerm)) + X;
  1442. ArcCall.YEnd := round(YRadius*Sin(TempTerm+Pi)) + Y;
  1443. StAngle:=StAngle MOD 361;
  1444. EndAngle:=EndAngle MOD 361;
  1445. StAngle := StAngle + 270;
  1446. EndAngle := EndAngle + 270;
  1447. If StAngle>EndAngle then
  1448. Begin
  1449. StAngle:=StAngle Xor EndAngle; EndAngle:=EndAngle Xor StAngle; StAngle:=EndAngle Xor StAngle;
  1450. End;
  1451. { Adjust for screen aspect ratio }
  1452. XRadius:=(longint(XRadius)*10000) div XAspect;
  1453. YRadius:=(longint(YRadius)*10000) div YAspect;
  1454. aSqr:=LongInt (xradius)*LongInt (xradius);
  1455. bSqr:=LongInt (yradius)*LongInt (yradius);
  1456. twoaSqr:=2*aSqr;
  1457. twobSqr:=2*bSqr;
  1458. xa:=0;
  1459. ya:=yradius;
  1460. twoXbSqr:=0;
  1461. twoYaSqr:=ya*twoaSqr;
  1462. error:=-ya*aSqr;
  1463. While twoXbSqr<=twoYaSqr Do Begin
  1464. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya); { Crude but it works }
  1465. PlotPoints;
  1466. Inc (xa);
  1467. Inc (twoXbSqr,twobSqr);
  1468. Inc (error,twoXbSqr-bSqr);
  1469. If error>=0 then Begin
  1470. Dec (ya);
  1471. Dec (twoYaSqr,twoaSqr);
  1472. Dec (error,twoYaSqr);
  1473. End;
  1474. End;
  1475. xa:=xradius;
  1476. ya:=0;
  1477. twoXbSqr:=xa*twobSqr;
  1478. twoYaSqr:=0;
  1479. error:=-xa*bSqr;
  1480. While twoXbSqr>twoYaSqr Do Begin
  1481. If ya=0 then Alpha:=90 Else Alpha:=RadToDeg*Arctan (xa/ya);
  1482. PlotPoints;
  1483. Inc (ya);
  1484. Inc (twoYaSqr,twoaSqr);
  1485. Inc (error,twoYaSqr-aSqr);
  1486. If error>=0 then Begin
  1487. Dec (xa);
  1488. Dec (twoXbSqr,twobSqr);
  1489. Dec (error,twoXbSqr);
  1490. End;
  1491. End;
  1492. End;
  1493. *)
  1494. procedure PatternLineDefault(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
  1495. {********************************************************}
  1496. { Draws a horizontal patterned line according to the }
  1497. { current Fill Settings. }
  1498. {********************************************************}
  1499. { Important notes: }
  1500. { - CurrentColor must be set correctly before entering }
  1501. { this routine. }
  1502. {********************************************************}
  1503. var
  1504. NrIterations: smallint;
  1505. i : smallint;
  1506. j : smallint;
  1507. TmpFillPattern : byte;
  1508. OldWriteMode : word;
  1509. OldCurrentColor : word;
  1510. begin
  1511. { convert to global coordinates ... }
  1512. x1 := x1 + StartXViewPort;
  1513. x2 := x2 + StartXViewPort;
  1514. y := y + StartYViewPort;
  1515. { if line was fully clipped then exit...}
  1516. if LineClipped(x1,y,x2,y,StartXViewPort,StartYViewPort,
  1517. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  1518. exit;
  1519. OldWriteMode := CurrentWriteMode;
  1520. CurrentWriteMode := NormalPut;
  1521. { Get the current pattern }
  1522. TmpFillPattern := FillPatternTable
  1523. [FillSettings.Pattern][(y and $7)+1];
  1524. Case TmpFillPattern Of
  1525. 0:
  1526. begin
  1527. OldCurrentColor := CurrentColor;
  1528. CurrentColor := CurrentBkColor;
  1529. { hline converts the coordinates to global ones, but that has been done }
  1530. { already here!!! Convert them back to local ones... (JM) }
  1531. HLine(x1-StartXViewPort,x2-StartXViewPort,y-StartYViewPort);
  1532. CurrentColor := OldCurrentColor;
  1533. end;
  1534. $ff:
  1535. begin
  1536. HLine(x1-StartXViewPort,x2-StartXViewPort,y-StartYViewPort);
  1537. end;
  1538. else
  1539. begin
  1540. { number of times to go throuh the 8x8 pattern }
  1541. NrIterations := abs(x2 - x1+8) div 8;
  1542. For i:= 0 to NrIterations do
  1543. Begin
  1544. for j:=0 to 7 do
  1545. Begin
  1546. { x1 mod 8 }
  1547. if RevBitArray[x1 and 7] and TmpFillPattern <> 0 then
  1548. DirectPutpixel(x1,y)
  1549. else
  1550. begin
  1551. { According to the TP graph manual, we overwrite everything }
  1552. { which is filled up - checked against VGA and CGA drivers }
  1553. { of TP. }
  1554. OldCurrentColor := CurrentColor;
  1555. CurrentColor := CurrentBkColor;
  1556. DirectPutPixel(x1,y);
  1557. CurrentColor := OldCurrentColor;
  1558. end;
  1559. Inc(x1);
  1560. if x1 > x2 then
  1561. begin
  1562. CurrentWriteMode := OldWriteMode;
  1563. exit;
  1564. end;
  1565. end;
  1566. end;
  1567. end;
  1568. End;
  1569. CurrentWriteMode := OldWriteMode;
  1570. end;
  1571. procedure LineRel(Dx, Dy: smallint);
  1572. Begin
  1573. Line(CurrentX, CurrentY, CurrentX + Dx, CurrentY + Dy);
  1574. CurrentX := CurrentX + Dx;
  1575. CurrentY := CurrentY + Dy;
  1576. end;
  1577. procedure LineTo(x,y : smallint);
  1578. Begin
  1579. Line(CurrentX, CurrentY, X, Y);
  1580. CurrentX := X;
  1581. CurrentY := Y;
  1582. end;
  1583. procedure Rectangle(x1,y1,x2,y2:smallint);
  1584. begin
  1585. { Do not draw the end points }
  1586. Line(x1,y1,x2-1,y1);
  1587. Line(x1,y1+1,x1,y2);
  1588. Line(x2,y1,x2,y2-1);
  1589. Line(x1+1,y2,x2,y2);
  1590. end;
  1591. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  1592. begin
  1593. Activelineinfo:=Lineinfo;
  1594. end;
  1595. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  1596. var
  1597. i: byte;
  1598. j: byte;
  1599. Begin
  1600. if (LineStyle > UserBitLn) or ((Thickness <> Normwidth) and (Thickness <> ThickWidth)) then
  1601. _GraphResult := grError
  1602. else
  1603. begin
  1604. LineInfo.Thickness := Thickness;
  1605. LineInfo.LineStyle := LineStyle;
  1606. case LineStyle of
  1607. UserBitLn: Lineinfo.Pattern := pattern;
  1608. SolidLn: Lineinfo.Pattern := $ffff; { ------- }
  1609. DashedLn : Lineinfo.Pattern := $F8F8; { -- -- --}
  1610. DottedLn: LineInfo.Pattern := $CCCC; { - - - - }
  1611. CenterLn: LineInfo.Pattern := $FC78; { -- - -- }
  1612. end; { end case }
  1613. { setup pattern styles }
  1614. j:=16;
  1615. for i:=0 to 15 do
  1616. Begin
  1617. dec(j);
  1618. { bitwise mask for each bit in the word }
  1619. if (word($01 shl i) AND LineInfo.Pattern) <> 0 then
  1620. LinePatterns[j]:=TRUE
  1621. else
  1622. LinePatterns[j]:=FALSE;
  1623. end;
  1624. end;
  1625. end;
  1626. {--------------------------------------------------------------------------}
  1627. { }
  1628. { VIEWPORT RELATED ROUTINES }
  1629. { }
  1630. {--------------------------------------------------------------------------}
  1631. Procedure ClearViewPortDefault; {$ifndef fpc}far;{$endif fpc}
  1632. var
  1633. j: smallint;
  1634. OldWriteMode, OldCurColor: word;
  1635. LineSets : LineSettingsType;
  1636. Begin
  1637. { CP is always RELATIVE coordinates }
  1638. CurrentX := 0;
  1639. CurrentY := 0;
  1640. { Save all old settings }
  1641. OldCurColor := CurrentColor;
  1642. CurrentColor:=CurrentBkColor;
  1643. OldWriteMode:=CurrentWriteMode;
  1644. GetLineSettings(LineSets);
  1645. { reset to normal line style...}
  1646. SetLineStyle(SolidLn, 0, NormWidth);
  1647. { routines are relative here...}
  1648. for J:=0 to ViewHeight do
  1649. HLine(0, ViewWidth, J);
  1650. { restore old settings...}
  1651. SetLineStyle(LineSets.LineStyle, LineSets.Pattern, LineSets.Thickness);
  1652. CurrentColor := OldCurColor;
  1653. CurrentWriteMode := OldWriteMode;
  1654. end;
  1655. Procedure SetViewPort(X1, Y1, X2, Y2: smallint; Clip: Boolean);
  1656. Begin
  1657. if (X1 > GetMaxX) or (X2 > GetMaxX) or (X1 > X2) or (X1 < 0) then
  1658. Begin
  1659. _GraphResult := grError;
  1660. exit;
  1661. end;
  1662. if (Y1 > GetMaxY) or (Y2 > GetMaxY) or (Y1 > Y2) or (Y1 < 0) then
  1663. Begin
  1664. _GraphResult := grError;
  1665. exit;
  1666. end;
  1667. { CP is always RELATIVE coordinates }
  1668. CurrentX := 0;
  1669. CurrentY := 0;
  1670. StartXViewPort := X1;
  1671. StartYViewPort := Y1;
  1672. ViewWidth := X2-X1;
  1673. ViewHeight:= Y2-Y1;
  1674. ClipPixels := Clip;
  1675. end;
  1676. procedure GetViewSettings(var viewport : ViewPortType);
  1677. begin
  1678. ViewPort.X1 := StartXViewPort;
  1679. ViewPort.Y1 := StartYViewPort;
  1680. ViewPort.X2 := ViewWidth + StartXViewPort;
  1681. ViewPort.Y2 := ViewHeight + StartYViewPort;
  1682. ViewPort.Clip := ClipPixels;
  1683. end;
  1684. procedure ClearDevice;
  1685. var
  1686. ViewPort: ViewPortType;
  1687. begin
  1688. { Reset the CP }
  1689. CurrentX := 0;
  1690. CurrentY := 0;
  1691. { save viewport }
  1692. ViewPort.X1 := StartXviewPort;
  1693. ViewPort.X2 := ViewWidth - StartXViewPort;
  1694. ViewPort.Y1 := StartYViewPort;
  1695. ViewPort.Y2 := ViewHeight - StartYViewPort;
  1696. ViewPort.Clip := ClipPixels;
  1697. { put viewport to full screen }
  1698. StartXViewPort := 0;
  1699. ViewHeight := MaxY;
  1700. StartYViewPort := 0;
  1701. ViewWidth := MaxX;
  1702. ClipPixels := TRUE;
  1703. ClearViewPort;
  1704. { restore old viewport }
  1705. StartXViewPort := ViewPort.X1;
  1706. ViewWidth := ViewPort.X2-ViewPort.X1;
  1707. StartYViewPort := ViewPort.Y1;
  1708. ViewHeight := ViewPort.Y2-ViewPort.Y1;
  1709. ClipPixels := ViewPort.Clip;
  1710. end;
  1711. {--------------------------------------------------------------------------}
  1712. { }
  1713. { BITMAP PUT/GET ROUTINES }
  1714. { }
  1715. {--------------------------------------------------------------------------}
  1716. Procedure GetScanlineDefault (X1, X2, Y : smallint; Var Data); {$ifndef fpc}far;{$endif fpc}
  1717. {**********************************************************}
  1718. { Procedure GetScanLine() }
  1719. {----------------------------------------------------------}
  1720. { Returns the full scanline of the video line of the Y }
  1721. { coordinate. The values are returned in a WORD array }
  1722. { each WORD representing a pixel of the specified scanline }
  1723. { note: we only need the pixels inside the ViewPort! (JM) }
  1724. { note2: extended so you can specify start and end X coord }
  1725. { so it is usable for GetImage too (JM) }
  1726. {**********************************************************}
  1727. Var
  1728. x : smallint;
  1729. Begin
  1730. For x:=X1 to X2 Do
  1731. WordArray(Data)[x-x1]:=GetPixel(x, y);
  1732. End;
  1733. Function DefaultImageSize(X1,Y1,X2,Y2: smallint): longint; {$ifndef fpc}far;{$endif fpc}
  1734. Begin
  1735. { each pixel uses two bytes, to enable modes with colors up to 64K }
  1736. { to work. }
  1737. DefaultImageSize := 12 + (((X2-X1+1)*(Y2-Y1+1))*2);
  1738. end;
  1739. Procedure DefaultPutImage(X,Y: smallint; var Bitmap; BitBlt: Word); {$ifndef fpc}far;{$endif fpc}
  1740. type
  1741. pt = array[0..$fffffff] of word;
  1742. ptw = array[0..2] of longint;
  1743. var
  1744. k: longint;
  1745. oldCurrentColor, color: word;
  1746. oldCurrentWriteMode, i, j, y1, x1, deltaX, deltaX1, deltaY: smallint;
  1747. Begin
  1748. {$ifdef logging}
  1749. LogLn('putImage at ('+strf(x)+','+strf(y)+') with width '+strf(ptw(Bitmap)[0])+
  1750. ' and height '+strf(ptw(Bitmap)[1]));
  1751. deltaY := 0;
  1752. {$endif logging}
  1753. inc(x,startXViewPort);
  1754. inc(y,startYViewPort);
  1755. x1 := ptw(Bitmap)[0]+x; { get width and adjust end coordinate accordingly }
  1756. y1 := ptw(Bitmap)[1]+y; { get height and adjust end coordinate accordingly }
  1757. deltaX := 0;
  1758. deltaX1 := 0;
  1759. k := 3 * sizeOf(Longint) div sizeOf(Word); { Three reserved longs at start of bitmap }
  1760. { check which part of the image is in the viewport }
  1761. if clipPixels then
  1762. begin
  1763. if y < startYViewPort then
  1764. begin
  1765. deltaY := startYViewPort - y;
  1766. inc(k,(x1-x+1)*deltaY);
  1767. y := startYViewPort;
  1768. end;
  1769. if y1 > startYViewPort+viewHeight then
  1770. y1 := startYViewPort+viewHeight;
  1771. if x < startXViewPort then
  1772. begin
  1773. deltaX := startXViewPort-x;
  1774. x := startXViewPort;
  1775. end;
  1776. if x1 > startXViewPort + viewWidth then
  1777. begin
  1778. deltaX1 := x1 - (startXViewPort + viewWidth);
  1779. x1 := startXViewPort + viewWidth;
  1780. end;
  1781. end;
  1782. {$ifdef logging}
  1783. LogLn('deltax: '+strf(deltax)+', deltax1: '+strf(deltax1)+',deltay: '+strf(deltay));
  1784. {$endif logging}
  1785. oldCurrentColor := currentColor;
  1786. oldCurrentWriteMode := currentWriteMode;
  1787. currentWriteMode := bitBlt;
  1788. for j:=Y to Y1 do
  1789. Begin
  1790. inc(k,deltaX);
  1791. for i:=X to X1 do
  1792. begin
  1793. currentColor := pt(bitmap)[k];
  1794. directPutPixel(i,j);
  1795. inc(k);
  1796. end;
  1797. inc(k,deltaX1);
  1798. end;
  1799. currentWriteMode := oldCurrentWriteMode;
  1800. currentColor := oldCurrentColor;
  1801. end;
  1802. Procedure DefaultGetImage(X1,Y1,X2,Y2: smallint; Var Bitmap); {$ifndef fpc}far;{$endif fpc}
  1803. type
  1804. pt = array[0..$fffffff] of word;
  1805. ptw = array[0..2] of longint;
  1806. var
  1807. i,j: smallint;
  1808. k: longint;
  1809. Begin
  1810. k:= 3 * Sizeof(longint) div sizeof(word); { Three reserved longs at start of bitmap }
  1811. i := x2 - x1 + 1;
  1812. for j:=Y1 to Y2 do
  1813. Begin
  1814. GetScanLine(x1,x2,j,pt(Bitmap)[k]);
  1815. inc(k,i);
  1816. end;
  1817. ptw(Bitmap)[0] := X2-X1; { First longint is width }
  1818. ptw(Bitmap)[1] := Y2-Y1; { Second longint is height }
  1819. ptw(bitmap)[2] := 0; { Third longint is reserved}
  1820. end;
  1821. Procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  1822. Begin
  1823. ArcCoords.X := ArcCall.X;
  1824. ArcCoords.Y := ArcCall.Y;
  1825. ArcCoords.XStart := ArcCall.XStart;
  1826. ArcCoords.YStart := ArcCall.YStart;
  1827. ArcCoords.XEnd := ArcCall.XEnd;
  1828. ArcCoords.YEnd := ArcCall.YEnd;
  1829. end;
  1830. procedure SetVisualPageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1831. begin
  1832. end;
  1833. procedure SetActivePageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1834. begin
  1835. end;
  1836. procedure DirectPutPixelDefault(X,Y: smallint);
  1837. begin
  1838. RunError(218);
  1839. end;
  1840. function GetPixelDefault(X,Y: smallint): word;
  1841. begin
  1842. RunError(218);
  1843. exit(0); { avoid warning }
  1844. end;
  1845. procedure PutPixelDefault(X,Y: smallint; Color: Word);
  1846. begin
  1847. RunError(218);
  1848. end;
  1849. procedure SetRGBPaletteDefault(ColorNum, RedValue, GreenValue, BlueValue: smallint);
  1850. begin
  1851. RunError(218);
  1852. end;
  1853. procedure GetRGBPaletteDefault(ColorNum: smallint; var
  1854. RedValue, GreenValue, BlueValue: smallint);
  1855. begin
  1856. RunError(218);
  1857. end;
  1858. Procedure DefaultHooks;
  1859. {********************************************************}
  1860. { Procedure DefaultHooks() }
  1861. {--------------------------------------------------------}
  1862. { Resets all hookable routine either to nil for those }
  1863. { which need overrides, and others to defaults. }
  1864. { This is called each time SetGraphMode() is called. }
  1865. {********************************************************}
  1866. Begin
  1867. { All default hooks procedures }
  1868. {$ifdef fpc}
  1869. { required...}
  1870. DirectPutPixel := @DirectPutPixelDefault;
  1871. PutPixel := @PutPixelDefault;
  1872. GetPixel := @GetPixelDefault;
  1873. SetRGBPalette := @SetRGBPaletteDefault;
  1874. GetRGBPalette := @GetRGBPaletteDefault;
  1875. { optional...}
  1876. SetActivePage := @SetActivePageDefault;
  1877. SetVisualPage := @SetVisualPageDefault;
  1878. ClearViewPort := @ClearViewportDefault;
  1879. PutImage := @DefaultPutImage;
  1880. GetImage := @DefaultGetImage;
  1881. ImageSize := @DefaultImageSize;
  1882. {$else fpc}
  1883. { required...}
  1884. DirectPutPixel := DirectPutPixelDefault;
  1885. PutPixel := PutPixelDefault;
  1886. GetPixel := GetPixelDefault;
  1887. SetRGBPalette := SetRGBPaletteDefault;
  1888. GetRGBPalette := GetRGBPaletteDefault;
  1889. { optional...}
  1890. SetActivePage := SetActivePageDefault;
  1891. SetVisualPage := SetVisualPageDefault;
  1892. ClearViewPort := ClearViewportDefault;
  1893. PutImage := DefaultPutImage;
  1894. GetImage := DefaultGetImage;
  1895. ImageSize := DefaultImageSize;
  1896. {$endif fpc}
  1897. GraphFreeMemPtr := nil;
  1898. GraphGetMemPtr := nil;
  1899. {$ifdef fpc}
  1900. GetScanLine := @GetScanLineDefault;
  1901. Line := @LineDefault;
  1902. InternalEllipse := @InternalEllipseDefault;
  1903. PatternLine := @PatternLineDefault;
  1904. HLine := @HLineDefault;
  1905. VLine := @VLineDefault;
  1906. {$else fpc}
  1907. GetScanLine := GetScanLineDefault;
  1908. Line := LineDefault;
  1909. InternalEllipse := InternalEllipseDefault;
  1910. PatternLine := PatternLineDefault;
  1911. HLine := HLineDefault;
  1912. VLine := VLineDefault;
  1913. {$endif fpc}
  1914. end;
  1915. Procedure InitVars;
  1916. {********************************************************}
  1917. { Procedure InitVars() }
  1918. {--------------------------------------------------------}
  1919. { Resets all internal variables, and resets all }
  1920. { overridable routines. }
  1921. {********************************************************}
  1922. Begin
  1923. DirectVideo := TRUE; { By default use fastest access possible }
  1924. ArcCall.X := 0;
  1925. ArcCall.Y := 0;
  1926. ArcCall.XStart := 0;
  1927. ArcCall.YStart := 0;
  1928. ArcCall.XEnd := 0;
  1929. ArcCall.YEnd := 0;
  1930. { Reset to default values }
  1931. IntCurrentMode := 0;
  1932. IntCurrentDriver := 0;
  1933. XAspect := 0;
  1934. YAspect := 0;
  1935. MaxX := 0;
  1936. MaxY := 0;
  1937. MaxColor := 0;
  1938. PaletteSize := 0;
  1939. DirectColor := FALSE;
  1940. HardwarePages := 0;
  1941. DefaultHooks;
  1942. end;
  1943. {$i modes.inc}
  1944. {$i palette.inc}
  1945. {$i graph.inc}
  1946. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): smallint;
  1947. begin
  1948. _graphResult := grError;
  1949. InstallUserDriver:=grError;
  1950. end;
  1951. function RegisterBGIDriver(driver: pointer): smallint;
  1952. begin
  1953. _graphResult := grError;
  1954. RegisterBGIDriver:=grError;
  1955. end;
  1956. { ----------------------------------------------------------------- }
  1957. Procedure Arc(X,Y : smallint; StAngle,EndAngle,Radius: word);
  1958. { var
  1959. OldWriteMode: word;}
  1960. Begin
  1961. { Only if we are using thickwidths lines do we accept }
  1962. { XORput write modes. }
  1963. { OldWriteMode := CurrentWriteMode;
  1964. if (LineInfo.Thickness = NormWidth) then
  1965. CurrentWriteMode := NormalPut;}
  1966. {$ifdef fpc}
  1967. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,@DummyPatternLine);
  1968. {$else fpc}
  1969. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,DummyPatternLine);
  1970. {$endif fpc}
  1971. { CurrentWriteMode := OldWriteMode;}
  1972. end;
  1973. procedure Ellipse(X,Y : smallint; stAngle, EndAngle: word; XRadius,YRadius: word);
  1974. Begin
  1975. {$ifdef fpc}
  1976. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,@DummyPatternLine);
  1977. {$else fpc}
  1978. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,DummyPatternLine);
  1979. {$endif fpc}
  1980. end;
  1981. procedure FillEllipse(X, Y: smallint; XRadius, YRadius: Word);
  1982. {********************************************************}
  1983. { Procedure FillEllipse() }
  1984. {--------------------------------------------------------}
  1985. { Draws a filled ellipse using (X,Y) as a center point }
  1986. { and XRadius and YRadius as the horizontal and vertical }
  1987. { axes. The ellipse is filled with the current fill color}
  1988. { and fill style, and is bordered with the current color.}
  1989. {********************************************************}
  1990. begin
  1991. InternalEllipse(X,Y,XRadius,YRadius,0,360,PatternLine)
  1992. end;
  1993. procedure Circle(X, Y: smallint; Radius:Word);
  1994. {********************************************************}
  1995. { Draws a circle centered at X,Y with the given Radius. }
  1996. {********************************************************}
  1997. { Important notes: }
  1998. { - Thickwidth circles use the current write mode, while}
  1999. { normal width circles ALWAYS use CopyPut/NormalPut }
  2000. { mode. (Tested against VGA BGI driver -CEC 13/Aug/99 }
  2001. {********************************************************}
  2002. var OriginalArcInfo: ArcCoordsType;
  2003. OldWriteMode: word;
  2004. begin
  2005. if (Radius = 0) then
  2006. Exit;
  2007. if (Radius = 1) then
  2008. begin
  2009. { only normal put mode is supported by a call to PutPixel }
  2010. PutPixel(X, Y, CurrentColor);
  2011. Exit;
  2012. end;
  2013. { save state of arc information }
  2014. { because it is not needed for }
  2015. { a circle call. }
  2016. move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
  2017. if LineInfo.Thickness = Normwidth then
  2018. begin
  2019. OldWriteMode := CurrentWriteMode;
  2020. CurrentWriteMode := CopyPut;
  2021. end;
  2022. {$ifdef fpc}
  2023. InternalEllipse(X,Y,Radius,Radius,0,360,@DummyPatternLine);
  2024. {$else fpc}
  2025. InternalEllipse(X,Y,Radius,Radius,0,360,DummyPatternLine);
  2026. {$endif fpc}
  2027. if LineInfo.Thickness = Normwidth then
  2028. CurrentWriteMode := OldWriteMode;
  2029. { restore arc information }
  2030. move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
  2031. end;
  2032. procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
  2033. var plx1, plx2: smallint;
  2034. {$ifdef sectorpldebug}
  2035. t : text;
  2036. {$endif sectorpldebug}
  2037. begin
  2038. {$ifdef sectorpldebug}
  2039. assign(t,'sector.log');
  2040. append(t);
  2041. writeln(t,'Got here for line ',y);
  2042. close(t);
  2043. {$endif sectorpldebug}
  2044. If (x1 = -maxsmallint) Then
  2045. If (x2 = maxsmallint-1) Then
  2046. { no ellipse points drawn on this line }
  2047. If (((Y < ArcCall.Y) and (Y > ArcCall.YStart)) or
  2048. ((Y > ArcCall.Y) and (Y < ArcCall.YStart))) Then
  2049. { there is a part of the sector at this y coordinate, but no }
  2050. { ellips points are plotted on this line, so draw a patternline }
  2051. { between the lines connecting (arccall.x,arccall.y) with }
  2052. { the start and the end of the arc (JM) }
  2053. { use: y-y1=(y2-y1)/(x2-x1)*(x-x1) => }
  2054. { x = (y-y1)/(y2-y1)*(x2-x1)+x1 }
  2055. Begin
  2056. {$ifdef sectorpldebug}
  2057. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2058. begin
  2059. append(t);
  2060. writeln(t,'bug1');
  2061. close(t);
  2062. runerror(202);
  2063. end;
  2064. {$endif sectorpldebug}
  2065. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2066. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X;
  2067. {$ifdef sectorpldebug}
  2068. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2069. begin
  2070. append(t);
  2071. writeln(t,'bug2');
  2072. close(t);
  2073. runerror(202);
  2074. end;
  2075. {$endif sectorpldebug}
  2076. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2077. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X;
  2078. If plx1 > plx2 then
  2079. begin
  2080. plx1 := plx1 xor plx2;
  2081. plx2 := plx1 xor plx2;
  2082. plx1 := plx1 xor plx2;
  2083. end;
  2084. {$ifdef sectorpldebug}
  2085. append(t);
  2086. writeln(t,'lines: ',plx1,' - ',plx2);
  2087. close(t);
  2088. {$endif sectorpldebug}
  2089. End
  2090. { otherwise two points which have nothing to do with the sector }
  2091. Else exit
  2092. Else
  2093. { the arc is plotted at the right side, but not at the left side, }
  2094. { fill till the line between (ArcCall.X,ArcCall.Y) and }
  2095. { (ArcCall.XStart,ArcCall.YStart) }
  2096. Begin
  2097. If (y < ArcCall.Y) then
  2098. begin
  2099. {$ifdef sectorpldebug}
  2100. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2101. begin
  2102. append(t);
  2103. writeln(t,'bug3');
  2104. close(t);
  2105. runerror(202);
  2106. end;
  2107. {$endif sectorpldebug}
  2108. plx1 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2109. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2110. end
  2111. else if (y > ArcCall.Y) then
  2112. begin
  2113. {$ifdef sectorpldebug}
  2114. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2115. begin
  2116. append(t);
  2117. writeln(t,'bug4');
  2118. close(t);
  2119. runerror(202);
  2120. end;
  2121. {$endif sectorpldebug}
  2122. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2123. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2124. end
  2125. else plx1 := ArcCall.X;
  2126. plx2 := x2;
  2127. {$ifdef sectorpldebug}
  2128. append(t);
  2129. writeln(t,'right: ',plx1,' - ',plx2);
  2130. close(t);
  2131. {$endif sectorpldebug}
  2132. End
  2133. Else
  2134. If (x2 = maxsmallint-1) Then
  2135. { the arc is plotted at the left side, but not at the rigth side. }
  2136. { the right limit can be either the first or second line. Just take }
  2137. { the closest one, but watch out for division by zero! }
  2138. Begin
  2139. If (y < ArcCall.Y) then
  2140. begin
  2141. {$ifdef sectorpldebug}
  2142. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2143. begin
  2144. append(t);
  2145. writeln(t,'bug5');
  2146. close(t);
  2147. runerror(202);
  2148. end;
  2149. {$endif sectorpldebug}
  2150. plx2 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2151. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2152. end
  2153. else if (y > ArcCall.Y) then
  2154. begin
  2155. {$ifdef sectorpldebug}
  2156. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2157. begin
  2158. append(t);
  2159. writeln(t,'bug6');
  2160. close(t);
  2161. runerror(202);
  2162. end;
  2163. {$endif sectorpldebug}
  2164. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2165. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2166. end
  2167. else plx2 := ArcCall.X;
  2168. plx1 := x1;
  2169. {$ifdef sectorpldebug}
  2170. append(t);
  2171. writeln(t,'left: ',plx1,' - ',plx2);
  2172. close(t);
  2173. {$endif sectorpldebug}
  2174. End
  2175. Else
  2176. { the arc is plotted at both sides }
  2177. Begin
  2178. plx1 := x1;
  2179. plx2 := x2;
  2180. {$ifdef sectorpldebug}
  2181. append(t);
  2182. writeln(t,'normal: ',plx1,' - ',plx2);
  2183. close(t);
  2184. {$endif sectorpldebug}
  2185. End;
  2186. If plx2 > plx1 then
  2187. Begin
  2188. {$ifdef sectorpldebug}
  2189. append(t);
  2190. Writeln(t,'drawing...');
  2191. close(t);
  2192. {$endif sectorpldebug}
  2193. PatternLine(plx1,plx2,y);
  2194. end;
  2195. end;
  2196. procedure Sector(x, y: smallint; StAngle,EndAngle, XRadius, YRadius: Word);
  2197. (* var angle : graph_float;
  2198. writemode : word; *)
  2199. begin
  2200. {$ifdef fpc}
  2201. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, @SectorPL);
  2202. {$else fpc}
  2203. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, SectorPL);
  2204. {$endif fpc}
  2205. Line(ArcCall.XStart, ArcCall.YStart, x,y);
  2206. Line(x,y,ArcCall.Xend,ArcCall.YEnd);
  2207. end;
  2208. procedure SetFillStyle(Pattern : word; Color: word);
  2209. begin
  2210. { on invalid input, the current fill setting will be }
  2211. { unchanged. }
  2212. if (Pattern > UserFill) or (Color > GetMaxColor) then
  2213. begin
  2214. _GraphResult := grError;
  2215. exit;
  2216. end;
  2217. FillSettings.Color := Color;
  2218. FillSettings.Pattern := Pattern;
  2219. end;
  2220. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  2221. {********************************************************}
  2222. { Changes the Current FillPattern to a user defined }
  2223. { pattern and changes also the current fill color. }
  2224. { The FillPattern is saved in the FillPattern array so }
  2225. { it can still be used with SetFillStyle(UserFill,Color) }
  2226. {********************************************************}
  2227. var
  2228. i: smallint;
  2229. begin
  2230. if Color > GetMaxColor then
  2231. begin
  2232. _GraphResult := grError;
  2233. exit;
  2234. end;
  2235. FillSettings.Color := Color;
  2236. FillSettings.Pattern := UserFill;
  2237. { Save the pattern in the buffer }
  2238. For i:=1 to 8 do
  2239. FillPatternTable[UserFill][i] := Pattern[i];
  2240. end;
  2241. procedure Bar(x1,y1,x2,y2:smallint);
  2242. {********************************************************}
  2243. { Important notes for compatibility with BP: }
  2244. { - WriteMode is always CopyPut }
  2245. { - No contour is drawn for the lines }
  2246. {********************************************************}
  2247. var y : smallint;
  2248. origcolor : longint;
  2249. origlinesettings: Linesettingstype;
  2250. origwritemode : smallint;
  2251. begin
  2252. origlinesettings:=lineinfo;
  2253. origcolor:=CurrentColor;
  2254. if y1>y2 then
  2255. begin
  2256. y:=y1;
  2257. y1:=y2;
  2258. y2:=y;
  2259. end;
  2260. { Always copy mode for Bars }
  2261. origwritemode := CurrentWriteMode;
  2262. CurrentWriteMode := CopyPut;
  2263. { All lines used are of this style }
  2264. Lineinfo.linestyle:=solidln;
  2265. Lineinfo.thickness:=normwidth;
  2266. case Fillsettings.pattern of
  2267. EmptyFill :
  2268. begin
  2269. Currentcolor:=CurrentBkColor;
  2270. for y:=y1 to y2 do
  2271. Hline(x1,x2,y);
  2272. end;
  2273. SolidFill :
  2274. begin
  2275. CurrentColor:=FillSettings.color;
  2276. for y:=y1 to y2 do
  2277. Hline(x1,x2,y);
  2278. end;
  2279. else
  2280. Begin
  2281. CurrentColor:=FillSettings.color;
  2282. for y:=y1 to y2 do
  2283. patternline(x1,x2,y);
  2284. end;
  2285. end;
  2286. CurrentColor:= Origcolor;
  2287. LineInfo := OrigLineSettings;
  2288. CurrentWriteMode := OrigWritemode;
  2289. end;
  2290. procedure bar3D(x1, y1, x2, y2 : smallint;depth : word;top : boolean);
  2291. var
  2292. origwritemode : smallint;
  2293. OldX, OldY : smallint;
  2294. begin
  2295. origwritemode := CurrentWriteMode;
  2296. CurrentWriteMode := CopyPut;
  2297. Bar(x1,y1,x2,y2);
  2298. Rectangle(x1,y1,x2,y2);
  2299. { Current CP should not be updated in Bar3D }
  2300. { therefore save it and then restore it on }
  2301. { exit. }
  2302. OldX := CurrentX;
  2303. OldY := CurrentY;
  2304. if top then begin
  2305. Moveto(x1,y1);
  2306. Lineto(x1+depth,y1-depth);
  2307. Lineto(x2+depth,y1-depth);
  2308. Lineto(x2,y1);
  2309. end;
  2310. if Depth <> 0 then
  2311. Begin
  2312. Moveto(x2+depth,y1-depth);
  2313. Lineto(x2+depth,y2-depth);
  2314. Lineto(x2,y2);
  2315. end;
  2316. { restore CP }
  2317. CurrentX := OldX;
  2318. CurrentY := OldY;
  2319. CurrentWriteMode := origwritemode;
  2320. end;
  2321. {--------------------------------------------------------------------------}
  2322. { }
  2323. { COLOR AND PALETTE ROUTINES }
  2324. { }
  2325. {--------------------------------------------------------------------------}
  2326. procedure SetColor(Color: Word);
  2327. Begin
  2328. CurrentColor := Color;
  2329. end;
  2330. function GetColor: Word;
  2331. Begin
  2332. GetColor := CurrentColor;
  2333. end;
  2334. function GetBkColor: Word;
  2335. Begin
  2336. GetBkColor := CurrentBkColor;
  2337. end;
  2338. procedure SetBkColor(ColorNum: Word);
  2339. { Background color means background screen color in this case, and it is }
  2340. { INDEPENDANT of the viewport settings, so we must clear the whole screen }
  2341. { with the color. }
  2342. var
  2343. ViewPort: ViewportType;
  2344. Begin
  2345. GetViewSettings(Viewport);
  2346. SetViewPort(0,0,MaxX,MaxY,FALSE);
  2347. CurrentBkColor := ColorNum;
  2348. {ClearViewPort;}
  2349. if not DirectColor and (ColorNum<256) then
  2350. SetRGBPalette(0,
  2351. DefaultColors[ColorNum].Red,
  2352. DefaultColors[ColorNum].Green,
  2353. DefaultColors[ColorNum].Blue);
  2354. SetViewport(ViewPort.X1,Viewport.Y1,Viewport.X2,Viewport.Y2,Viewport.Clip);
  2355. end;
  2356. function GetMaxColor: word;
  2357. { Checked against TP VGA driver - CEC }
  2358. begin
  2359. GetMaxColor:=MaxColor-1; { based on an index of zero so subtract one }
  2360. end;
  2361. Procedure MoveRel(Dx, Dy: smallint);
  2362. Begin
  2363. CurrentX := CurrentX + Dx;
  2364. CurrentY := CurrentY + Dy;
  2365. end;
  2366. Procedure MoveTo(X,Y: smallint);
  2367. {********************************************************}
  2368. { Procedure MoveTo() }
  2369. {--------------------------------------------------------}
  2370. { Moves the current pointer in VIEWPORT relative }
  2371. { coordinates to the specified X,Y coordinate. }
  2372. {********************************************************}
  2373. Begin
  2374. CurrentX := X;
  2375. CurrentY := Y;
  2376. end;
  2377. function GraphErrorMsg(ErrorCode: smallint): string;
  2378. Begin
  2379. GraphErrorMsg:='';
  2380. case ErrorCode of
  2381. grOk,grFileNotFound,grInvalidDriver: exit;
  2382. grNoInitGraph: GraphErrorMsg:='Graphics driver not installed';
  2383. grNotDetected: GraphErrorMsg:='Graphics hardware not detected';
  2384. grNoLoadMem,grNoScanMem,grNoFloodMem: GraphErrorMsg := 'Not enough memory for graphics';
  2385. grNoFontMem: GraphErrorMsg := 'Not enough memory to load font';
  2386. grFontNotFound: GraphErrorMsg:= 'Font file not found';
  2387. grInvalidMode: GraphErrorMsg := 'Invalid graphics mode';
  2388. grError: GraphErrorMsg:='Graphics error';
  2389. grIoError: GraphErrorMsg:='Graphics I/O error';
  2390. grInvalidFont,grInvalidFontNum: GraphErrorMsg := 'Invalid font';
  2391. grInvalidVersion: GraphErrorMsg:='Invalid driver version';
  2392. end;
  2393. end;
  2394. Function GetMaxX: smallint;
  2395. { Routine checked against VGA driver - CEC }
  2396. Begin
  2397. GetMaxX := MaxX;
  2398. end;
  2399. Function GetMaxY: smallint;
  2400. { Routine checked against VGA driver - CEC }
  2401. Begin
  2402. GetMaxY := MaxY;
  2403. end;
  2404. Function GraphResult: smallint;
  2405. Begin
  2406. GraphResult := _GraphResult;
  2407. _GraphResult := grOk;
  2408. end;
  2409. Function GetX: smallint;
  2410. Begin
  2411. GetX := CurrentX;
  2412. end;
  2413. Function GetY: smallint;
  2414. Begin
  2415. GetY := CurrentY;
  2416. end;
  2417. Function GetDriverName: string;
  2418. begin
  2419. GetDriverName:=DriverName;
  2420. end;
  2421. procedure graphdefaults;
  2422. { PS: GraphDefaults does not ZERO the ArcCall structure }
  2423. { so a call to GetArcCoords will not change even the }
  2424. { returned values even if GraphDefaults is called in }
  2425. { between. }
  2426. var
  2427. i: smallint;
  2428. begin
  2429. lineinfo.linestyle:=solidln;
  2430. lineinfo.thickness:=normwidth;
  2431. { reset line style pattern }
  2432. for i:=0 to 15 do
  2433. LinePatterns[i] := TRUE;
  2434. { By default, according to the TP prog's reference }
  2435. { the default pattern is solid, and the default }
  2436. { color is the maximum color in the palette. }
  2437. fillsettings.color:=GetMaxColor;
  2438. fillsettings.pattern:=solidfill;
  2439. { GraphDefaults resets the User Fill pattern to $ff }
  2440. { checked with VGA BGI driver - CEC }
  2441. for i:=1 to 8 do
  2442. FillPatternTable[UserFill][i] := $ff;
  2443. CurrentColor:=white;
  2444. SetBkColor(Black);
  2445. ClipPixels := TRUE;
  2446. { Reset the viewport }
  2447. StartXViewPort := 0;
  2448. StartYViewPort := 0;
  2449. ViewWidth := MaxX;
  2450. ViewHeight := MaxY;
  2451. { Reset CP }
  2452. CurrentX := 0;
  2453. CurrentY := 0;
  2454. { normal write mode }
  2455. CurrentWriteMode := CopyPut;
  2456. { Schriftart einstellen }
  2457. CurrentTextInfo.font := DefaultFont;
  2458. CurrentTextInfo.direction:=HorizDir;
  2459. CurrentTextInfo.charsize:=1;
  2460. CurrentTextInfo.horiz:=LeftText;
  2461. CurrentTextInfo.vert:=TopText;
  2462. XAspect:=10000; YAspect:=10000;
  2463. end;
  2464. procedure GetAspectRatio(var Xasp,Yasp : word);
  2465. begin
  2466. XAsp:=XAspect;
  2467. YAsp:=YAspect;
  2468. end;
  2469. procedure SetAspectRatio(Xasp, Yasp : word);
  2470. begin
  2471. Xaspect:= XAsp;
  2472. YAspect:= YAsp;
  2473. end;
  2474. procedure SetWriteMode(WriteMode : smallint);
  2475. { TP sets the writemodes according to the following scheme (JM) }
  2476. begin
  2477. Case writemode of
  2478. xorput, andput: CurrentWriteMode := XorPut;
  2479. notput, orput, copyput: CurrentWriteMode := CopyPut;
  2480. End;
  2481. end;
  2482. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  2483. begin
  2484. Fillinfo:=Fillsettings;
  2485. end;
  2486. procedure GetFillPattern(var FillPattern:FillPatternType);
  2487. begin
  2488. FillPattern:=FillpatternTable[UserFill];
  2489. end;
  2490. procedure DrawPoly(numpoints : word;var polypoints);
  2491. type
  2492. ppointtype = ^pointtype;
  2493. pt = array[0..16000] of pointtype;
  2494. var
  2495. i : longint;
  2496. begin
  2497. if numpoints < 2 then
  2498. begin
  2499. _GraphResult := grError;
  2500. exit;
  2501. end;
  2502. for i:=0 to numpoints-2 do
  2503. line(pt(polypoints)[i].x,
  2504. pt(polypoints)[i].y,
  2505. pt(polypoints)[i+1].x,
  2506. pt(polypoints)[i+1].y);
  2507. end;
  2508. procedure PieSlice(X,Y,stangle,endAngle:smallint;Radius: Word);
  2509. begin
  2510. Sector(x,y,stangle,endangle,radius,radius);
  2511. end;
  2512. {$i fills.inc}
  2513. {$i gtext.inc}
  2514. procedure DetectGraph(var GraphDriver:smallint;var GraphMode:smallint);
  2515. var LoMode, HiMode: smallint;
  2516. CpyMode: smallint;
  2517. CpyDriver: smallint;
  2518. begin
  2519. HiMode := -1;
  2520. LoMode := -1;
  2521. { We start at VGA }
  2522. GraphDriver := VGA;
  2523. CpyMode := 0;
  2524. { search all possible graphic drivers in ascending order...}
  2525. { usually the new driver numbers indicate newest hardware...}
  2526. { Internal driver numbers start at VGA=9 }
  2527. repeat
  2528. GetModeRange(GraphDriver,LoMode,HiMode);
  2529. { save the highest mode possible...}
  2530. {$ifdef logging}
  2531. logln('Found driver '+strf(graphdriver)+' with modes '+
  2532. strf(lomode)+' - '+strf(himode));
  2533. {$endif logging}
  2534. if HiMode = -1 then break;
  2535. CpyMode:=HiMode;
  2536. CpyDriver:=GraphDriver;
  2537. { go to next driver if it exists...}
  2538. Inc(GraphDriver);
  2539. until (CpyMode=-1);
  2540. { If this is equal to -1 then no graph mode possible...}
  2541. if CpyMode = -1 then
  2542. begin
  2543. _GraphResult := grNotDetected;
  2544. exit;
  2545. end;
  2546. _GraphResult := grOK;
  2547. GraphDriver := CpyDriver;
  2548. GraphMode := CpyMode;
  2549. end;
  2550. procedure InitGraph(var GraphDriver:smallint;var GraphMode:smallint;
  2551. const PathToDriver:String);
  2552. begin
  2553. InitVars;
  2554. { path to the fonts (where they will be searched)...}
  2555. bgipath:=PathToDriver;
  2556. if bgipath[length(bgipath)]<>'\' then
  2557. bgipath:=bgipath+'\';
  2558. if not assigned(SaveVideoState) then
  2559. RunError(216);
  2560. DriverName:=InternalDriverName; { DOS Graphics driver }
  2561. if (Graphdriver=Detect) then
  2562. begin
  2563. DetectGraph(GraphDriver,GraphMode);
  2564. If _GraphResult = grNotDetected then Exit;
  2565. { _GraphResult is now already set to grOK by DetectGraph }
  2566. IntCurrentDriver := GraphDriver;
  2567. SaveVideoState;
  2568. { Actually set the graph mode...}
  2569. SetGraphMode(GraphMode);
  2570. end
  2571. else
  2572. begin
  2573. { Search if that graphics modec actually exists...}
  2574. if SearchMode(GraphDriver,GraphMode) = nil then
  2575. begin
  2576. _GraphResult := grInvalidMode;
  2577. exit;
  2578. end
  2579. else
  2580. begin
  2581. _GraphResult := grOK;
  2582. IntCurrentDriver := GraphDriver;
  2583. SaveVideoState;
  2584. {$ifdef logging}
  2585. If _GraphResult <> grOK then
  2586. LogLn('Mode setting failed after savevideostate');
  2587. {$endif logging}
  2588. SetGraphMode(GraphMode);
  2589. end;
  2590. end;
  2591. end;
  2592. procedure SetDirectVideo(DirectAccess: boolean);
  2593. begin
  2594. DirectVideo := DirectAccess;
  2595. end;
  2596. function GetDirectVideo: boolean;
  2597. begin
  2598. GetDirectVideo := DirectVideo;
  2599. end;
  2600. procedure GraphExitProc; {$ifndef fpc} far; {$endif fpc}
  2601. { deallocates all memory allocated by the graph unit }
  2602. var
  2603. list: PModeInfo;
  2604. tmp : PModeInfo;
  2605. c: graph_int;
  2606. begin
  2607. { restore old exitproc! }
  2608. exitproc := exitsave;
  2609. if IsGraphMode and ((errorcode<>0) or (erroraddr<>nil)) then
  2610. CloseGraph;
  2611. {$ifdef testsave}
  2612. restorevideostate;
  2613. {$endif testsave}
  2614. { release memory allocated for fonts }
  2615. for c := 1 to installedfonts do
  2616. with fonts[c] Do
  2617. If assigned(instr) Then
  2618. Freemem(instr,instrlength);
  2619. { release memory allocated for modelist }
  2620. list := ModeList;
  2621. while assigned(list) do
  2622. begin
  2623. tmp := list;
  2624. list:=list^.next;
  2625. dispose(tmp);
  2626. end;
  2627. {$IFDEF DPMI}
  2628. { We had copied the buffer of mode information }
  2629. { and allocated it dynamically... now free it }
  2630. { Warning: if GetVESAInfo returned false, this buffer is not allocated! (JM)}
  2631. If hasVesa then
  2632. Dispose(VESAInfo.ModeList);
  2633. {$ENDIF}
  2634. end;
  2635. begin
  2636. {$ifdef logging}
  2637. assign(debuglog,'grlog.txt');
  2638. rewrite(debuglog);
  2639. close(debuglog);
  2640. {$endif logging}
  2641. isgraphmode := false;
  2642. ModeList := nil;
  2643. SaveVideoState := nil;
  2644. RestoreVideoState := nil;
  2645. SavePtr := Nil;
  2646. {$ifdef oldfont}
  2647. {$ifdef go32v2}
  2648. LoadFont8x8;
  2649. {$endif go32v2}
  2650. {$endif oldfont}
  2651. { This must be called at startup... because GetGraphMode may }
  2652. { be called even when not in graph mode. }
  2653. {$ifdef logging}
  2654. LogLn('Calling QueryAdapterInfo...');
  2655. {$endif logging}
  2656. QueryAdapterInfo;
  2657. { Install standard fonts }
  2658. { This is done BEFORE startup... }
  2659. InstalledFonts := 0;
  2660. InstallUserFont('TRIP');
  2661. InstallUserFont('LITT');
  2662. InstallUserFont('SANS');
  2663. InstallUserFont('GOTH');
  2664. { This installs an exit procedure which cleans up the mode list...}
  2665. ExitSave := ExitProc;
  2666. ExitProc := @GraphExitProc;
  2667. {$ifdef testsave}
  2668. savevideostate;
  2669. {$endif testsave}
  2670. {$ifdef win32}
  2671. charmessagehandler:=nil;
  2672. {$endif win32}
  2673. end.
  2674. SetGraphBufSize
  2675. {
  2676. $Log$
  2677. Revision 1.51 1999-12-26 10:33:06 jonas
  2678. * XAspect and YAspect are now words instead of smallints, they
  2679. overflowed for resolutions > 640x480 otherwise
  2680. * the number of pixels required for an ellipse in internalellipsedef
  2681. is now calculated after the aspectratios have been taken into
  2682. account
  2683. Revision 1.50 1999/12/21 17:42:17 jonas
  2684. * changed vesa.inc do it doesn't try to use linear modes anymore (doesn't work
  2685. yet!!)
  2686. * fixed mode detection so the low modenumber of a driver doesn't have to be zero
  2687. anymore (so VESA autodetection now works)
  2688. Revision 1.49 1999/12/21 09:16:48 pierre
  2689. + CloseGraph if errors
  2690. Revision 1.48 1999/12/20 11:22:36 peter
  2691. * integer -> smallint to overcome -S2 switch needed for ggi version
  2692. Revision 1.47 1999/12/12 13:34:20 jonas
  2693. * putimage now performs the lipping itself and uses directputpixel
  2694. (note: this REQUIRES or/and/notput support in directputpixel,
  2695. this is not yet the case in the assembler versions!)
  2696. * YOffset addition moved in hlinevesa256 and vlinevesa256
  2697. because it uses still putpixel afterwards
  2698. Revision 1.46 1999/12/11 23:41:38 jonas
  2699. * changed definition of getscanlineproc to "getscanline(x1,x2,y:
  2700. smallint; var data);" so it can be used by getimage too
  2701. * changed getimage so it uses getscanline
  2702. * changed floodfill, getscanline16 and definitions in Linux
  2703. include files so they use this new format
  2704. + getscanlineVESA256 for 256 color VESA modes (banked)
  2705. Revision 1.45 1999/12/10 12:47:41 pierre
  2706. * SetBkColor like BP by changing Palette entry zero
  2707. Revision 1.44 1999/11/30 08:57:46 michael
  2708. + Removed charmessagehandler declaration, it is in graphh.inc
  2709. Revision 1.43 1999/11/28 16:13:55 jonas
  2710. * corrected misplacement of call to initvars in initgraph
  2711. + some extra debugging commands (for -dlogging) in the mode functions
  2712. Revision 1.42 1999/11/28 12:19:59 jonas
  2713. * _GraphResult is now properly set to grOK by DetectGraph and
  2714. InitGraph if there are no errors
  2715. Revision 1.41 1999/11/27 21:48:01 jonas
  2716. * fixed VlineVESA256 and re-enabled it in graph.inc
  2717. * added procedure detectgraph to interface of graph unit
  2718. Revision 1.40 1999/11/25 17:44:14 pierre
  2719. * memory corruption within GetImage removed
  2720. Revision 1.39 1999/11/24 23:42:31 pierre
  2721. * PutImage used an smallint index that became negative !!!!
  2722. * Default needed procedure now genrate a RTE 218 instead of a
  2723. GPF by call to nil pointer !
  2724. Revision 1.38 1999/11/11 17:55:07 florian
  2725. * the size was calculated wrong by imagesize
  2726. Revision 1.37 1999/11/11 14:07:14 florian
  2727. * better looking font
  2728. Revision 1.36 1999/11/08 15:01:38 peter
  2729. * fpcmake support
  2730. Revision 1.35 1999/11/08 11:15:22 peter
  2731. * move graph.inc to the target dir
  2732. Revision 1.34 1999/11/03 20:23:01 florian
  2733. + first release of win32 gui support
  2734. Revision 1.33 1999/10/17 10:20:13 jonas
  2735. * fixed clipping for thickwidth lines (bug 659)
  2736. * fixed the faster internalellipsedefault, but it doesn't plot
  2737. all pixels (there are gaps in the ellipses)
  2738. Revision 1.32 1999/09/28 15:07:46 jonas
  2739. * fix for disposing font data because it can contain #0 chars
  2740. Revision 1.31 1999/09/28 13:56:25 jonas
  2741. * reordered some local variables (first 4 byte vars, then 2 byte vars
  2742. etc)
  2743. * font data is now disposed in exitproc, exitproc is now called
  2744. GraphExitProc (was CleanModes) and resides in graph.pp instead of in
  2745. modes.inc
  2746. Revision 1.30 1999/09/27 23:34:41 peter
  2747. * new graph unit is default for go32v2
  2748. * removed warnings/notes
  2749. Revision 1.29 1999/09/26 13:31:06 jonas
  2750. * changed name of modeinfo variable to vesamodeinfo and fixed
  2751. associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
  2752. of sizeof(TVesamodeinfo) etc)
  2753. * changed several sizeof(type) to sizeof(varname) to avoid similar
  2754. errors in the future
  2755. Revision 1.28 1999/09/25 11:48:43 jonas
  2756. + detectgraph
  2757. * small change to internalellipsedefault so less pixels are
  2758. calculated twice
  2759. * some small corrections to graph.tex
  2760. Revision 1.27 1999/09/24 22:52:38 jonas
  2761. * optimized patternline a bit (always use hline when possible)
  2762. * isgraphmode stuff cleanup
  2763. * vesainfo.modelist now gets disposed in cleanmode instead of in
  2764. closegraph (required moving of some declarations from vesa.inc to
  2765. new vesah.inc)
  2766. * queryadapter gets no longer called from initgraph (is called from
  2767. initialization of graph unit)
  2768. * bugfix for notput in 32k and 64k vesa modes
  2769. * a div replaced by / in fillpoly
  2770. Revision 1.26 1999/09/22 13:13:35 jonas
  2771. * renamed text.inc -> gtext.inc to avoid conflict with system unit
  2772. * fixed textwidth
  2773. * isgraphmode now gets properly updated, so mode restoring works
  2774. again
  2775. Revision 1.25 1999/09/18 22:21:10 jonas
  2776. + hlinevesa256 and vlinevesa256
  2777. + support for not/xor/or/andput in vesamodes with 32k/64k colors
  2778. * lots of changes to avoid warnings under FPC
  2779. Revision 1.24 1999/09/18 16:03:37 jonas
  2780. * graph.pp: removed pieslice and sector from ToDo list
  2781. * closegraph: exits now immidiately if isgraphmode = false (caused
  2782. RTE 204 with VESA enabled if you set exitproc to call closegraph
  2783. and also called closegraph explicitely before exit, like bgidemo)
  2784. Revision 1.23 1999/09/17 13:58:31 jonas
  2785. * another fix for a case where internalellipsedefault went haywire
  2786. * sector() and pieslice() fully implemented!
  2787. * small change to prevent buffer overflow with floodfill
  2788. Revision 1.22 1999/09/15 13:37:50 jonas
  2789. * small change to internalellipsedef to be TP compatible
  2790. * fixed directputpixel for vga 320*200*256
  2791. Revision 1.21 1999/09/13 12:49:08 jonas
  2792. * fixed Arc: internallellipse went into an endless loop if StAngle =
  2793. EndAngle
  2794. * FillEllipse is now much faster: no more floodfill,
  2795. InternalEllipseDefault now draws the patternlines immediatety!
  2796. Revision 1.20 1999/09/12 17:29:00 jonas
  2797. * several changes to internalellipse to make it faster
  2798. and to make sure it updates the ArcCall correctly
  2799. (not yet done for width = 3)
  2800. * Arc mostly works now, only sometimes an endless loop, don't know
  2801. why
  2802. Revision 1.19 1999/09/11 19:43:01 jonas
  2803. * FloodFill: did not take into account current viewport settings
  2804. * GetScanLine: only get line inside viewport, data outside of it
  2805. is not used anyway
  2806. * InternalEllipseDefault: fix for when xradius or yradius = 0 and
  2807. increase xradius and yradius always by one (TP does this too)
  2808. * fixed conlict in vesa.inc from last update
  2809. * some conditionals to avoid range check and overflow errors in
  2810. places where it doesn't matter
  2811. Revision 1.18 1999/07/26 09:38:41 florian
  2812. * bar: y2 can be less y1, fixed
  2813. * settextstyle: charsize can be 0, must be changed into 1
  2814. Revision 1.17 1999/07/18 15:07:20 jonas
  2815. + xor-, and and- orput support for VESA256 modes
  2816. * compile with -dlogging if you wnt some info to be logged to grlog.txt
  2817. Revision 1.16 1999/07/14 18:18:04 florian
  2818. * cosmetic changes
  2819. }