2
0

graph.pp 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217
  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 : smallint; { XAspect ratio correction factor }
  469. YAspect : smallint; { YAspect ratio correction factor }
  470. MaxX: smallint; { Max-X row }
  471. MaxY: smallint; { 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 : smallint;
  685. YAspect : smallint;
  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. { check for an ellipse with negligable x and y radius }
  1208. If (xradius <= 1) and (yradius <= 1) then
  1209. begin
  1210. putpixel(x,y,CurrentColor);
  1211. ArcCall.X := X;
  1212. ArcCall.Y := Y;
  1213. ArcCall.XStart := X;
  1214. ArcCall.YStart := Y;
  1215. ArcCall.XEnd := X;
  1216. ArcCall.YEnd := Y;
  1217. exit;
  1218. end;
  1219. { for restoring after PatternLine }
  1220. BackupColor := CurrentColor;
  1221. If xradius = 0 then inc(xradius);
  1222. if yradius = 0 then inc(yradius);
  1223. { check if valid angles }
  1224. stangle := stAngle mod 361;
  1225. EndAngle := EndAngle mod 361;
  1226. { if impossible angles then swap them! }
  1227. if Endangle < StAngle then
  1228. Begin
  1229. TmpAngle:=EndAngle;
  1230. EndAngle:=StAngle;
  1231. Stangle:=TmpAngle;
  1232. end;
  1233. { calculate difference of angle now so we don't always have to calculate it }
  1234. DeltaAngle:= EndAngle-StAngle;
  1235. { approximate the number of pixels required by using the circumference }
  1236. { equation of an ellipse. }
  1237. { Changed this formula a it (trial and error), but the net result is that }
  1238. { less pixels have to be calculated now }
  1239. NumOfPixels:=Round(Sqrt(3)*sqrt(sqr(XRadius)+sqr(YRadius)));
  1240. { Calculate the angle precision required }
  1241. Delta := 90.0 / (NumOfPixels);
  1242. { Adjust for screen aspect ratio }
  1243. XRadius:=(longint(XRadius)*10000) div XAspect;
  1244. YRadius:=(longint(YRadius)*10000) div YAspect;
  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) 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+1) div 8;
  1542. Inc(NrIterations);
  1543. For i:= 0 to NrIterations do
  1544. Begin
  1545. for j:=0 to 7 do
  1546. Begin
  1547. { x1 mod 8 }
  1548. if RevBitArray[x1 and 7] and TmpFillPattern <> 0 then
  1549. DirectPutpixel(x1,y)
  1550. else
  1551. begin
  1552. { According to the TP graph manual, we overwrite everything }
  1553. { which is filled up - checked against VGA and CGA drivers }
  1554. { of TP. }
  1555. OldCurrentColor := CurrentColor;
  1556. CurrentColor := CurrentBkColor;
  1557. DirectPutPixel(x1,y);
  1558. CurrentColor := OldCurrentColor;
  1559. end;
  1560. Inc(x1);
  1561. if x1 > x2 then
  1562. begin
  1563. CurrentWriteMode := OldWriteMode;
  1564. exit;
  1565. end;
  1566. end;
  1567. end;
  1568. end;
  1569. End;
  1570. CurrentWriteMode := OldWriteMode;
  1571. end;
  1572. procedure LineRel(Dx, Dy: smallint);
  1573. Begin
  1574. Line(CurrentX, CurrentY, CurrentX + Dx, CurrentY + Dy);
  1575. CurrentX := CurrentX + Dx;
  1576. CurrentY := CurrentY + Dy;
  1577. end;
  1578. procedure LineTo(x,y : smallint);
  1579. Begin
  1580. Line(CurrentX, CurrentY, X, Y);
  1581. CurrentX := X;
  1582. CurrentY := Y;
  1583. end;
  1584. procedure Rectangle(x1,y1,x2,y2:smallint);
  1585. begin
  1586. { Do not draw the end points }
  1587. Line(x1,y1,x2-1,y1);
  1588. Line(x1,y1+1,x1,y2);
  1589. Line(x2,y1,x2,y2-1);
  1590. Line(x1+1,y2,x2,y2);
  1591. end;
  1592. procedure GetLineSettings(var ActiveLineInfo : LineSettingsType);
  1593. begin
  1594. Activelineinfo:=Lineinfo;
  1595. end;
  1596. procedure SetLineStyle(LineStyle: word; Pattern: word; Thickness: word);
  1597. var
  1598. i: byte;
  1599. j: byte;
  1600. Begin
  1601. if (LineStyle > UserBitLn) or ((Thickness <> Normwidth) and (Thickness <> ThickWidth)) then
  1602. _GraphResult := grError
  1603. else
  1604. begin
  1605. LineInfo.Thickness := Thickness;
  1606. LineInfo.LineStyle := LineStyle;
  1607. case LineStyle of
  1608. UserBitLn: Lineinfo.Pattern := pattern;
  1609. SolidLn: Lineinfo.Pattern := $ffff; { ------- }
  1610. DashedLn : Lineinfo.Pattern := $F8F8; { -- -- --}
  1611. DottedLn: LineInfo.Pattern := $CCCC; { - - - - }
  1612. CenterLn: LineInfo.Pattern := $FC78; { -- - -- }
  1613. end; { end case }
  1614. { setup pattern styles }
  1615. j:=16;
  1616. for i:=0 to 15 do
  1617. Begin
  1618. dec(j);
  1619. { bitwise mask for each bit in the word }
  1620. if (word($01 shl i) AND LineInfo.Pattern) <> 0 then
  1621. LinePatterns[j]:=TRUE
  1622. else
  1623. LinePatterns[j]:=FALSE;
  1624. end;
  1625. end;
  1626. end;
  1627. {--------------------------------------------------------------------------}
  1628. { }
  1629. { VIEWPORT RELATED ROUTINES }
  1630. { }
  1631. {--------------------------------------------------------------------------}
  1632. Procedure ClearViewPortDefault; {$ifndef fpc}far;{$endif fpc}
  1633. var
  1634. j: smallint;
  1635. OldWriteMode, OldCurColor: word;
  1636. LineSets : LineSettingsType;
  1637. Begin
  1638. { CP is always RELATIVE coordinates }
  1639. CurrentX := 0;
  1640. CurrentY := 0;
  1641. { Save all old settings }
  1642. OldCurColor := CurrentColor;
  1643. CurrentColor:=CurrentBkColor;
  1644. OldWriteMode:=CurrentWriteMode;
  1645. GetLineSettings(LineSets);
  1646. { reset to normal line style...}
  1647. SetLineStyle(SolidLn, 0, NormWidth);
  1648. { routines are relative here...}
  1649. for J:=0 to ViewHeight do
  1650. HLine(0, ViewWidth, J);
  1651. { restore old settings...}
  1652. SetLineStyle(LineSets.LineStyle, LineSets.Pattern, LineSets.Thickness);
  1653. CurrentColor := OldCurColor;
  1654. CurrentWriteMode := OldWriteMode;
  1655. end;
  1656. Procedure SetViewPort(X1, Y1, X2, Y2: smallint; Clip: Boolean);
  1657. Begin
  1658. if (X1 > GetMaxX) or (X2 > GetMaxX) or (X1 > X2) or (X1 < 0) then
  1659. Begin
  1660. _GraphResult := grError;
  1661. exit;
  1662. end;
  1663. if (Y1 > GetMaxY) or (Y2 > GetMaxY) or (Y1 > Y2) or (Y1 < 0) then
  1664. Begin
  1665. _GraphResult := grError;
  1666. exit;
  1667. end;
  1668. { CP is always RELATIVE coordinates }
  1669. CurrentX := 0;
  1670. CurrentY := 0;
  1671. StartXViewPort := X1;
  1672. StartYViewPort := Y1;
  1673. ViewWidth := X2-X1;
  1674. ViewHeight:= Y2-Y1;
  1675. ClipPixels := Clip;
  1676. end;
  1677. procedure GetViewSettings(var viewport : ViewPortType);
  1678. begin
  1679. ViewPort.X1 := StartXViewPort;
  1680. ViewPort.Y1 := StartYViewPort;
  1681. ViewPort.X2 := ViewWidth + StartXViewPort;
  1682. ViewPort.Y2 := ViewHeight + StartYViewPort;
  1683. ViewPort.Clip := ClipPixels;
  1684. end;
  1685. procedure ClearDevice;
  1686. var
  1687. ViewPort: ViewPortType;
  1688. begin
  1689. { Reset the CP }
  1690. CurrentX := 0;
  1691. CurrentY := 0;
  1692. { save viewport }
  1693. ViewPort.X1 := StartXviewPort;
  1694. ViewPort.X2 := ViewWidth - StartXViewPort;
  1695. ViewPort.Y1 := StartYViewPort;
  1696. ViewPort.Y2 := ViewHeight - StartYViewPort;
  1697. ViewPort.Clip := ClipPixels;
  1698. { put viewport to full screen }
  1699. StartXViewPort := 0;
  1700. ViewHeight := MaxY;
  1701. StartYViewPort := 0;
  1702. ViewWidth := MaxX;
  1703. ClipPixels := TRUE;
  1704. ClearViewPort;
  1705. { restore old viewport }
  1706. StartXViewPort := ViewPort.X1;
  1707. ViewWidth := ViewPort.X2-ViewPort.X1;
  1708. StartYViewPort := ViewPort.Y1;
  1709. ViewHeight := ViewPort.Y2-ViewPort.Y1;
  1710. ClipPixels := ViewPort.Clip;
  1711. end;
  1712. {--------------------------------------------------------------------------}
  1713. { }
  1714. { BITMAP PUT/GET ROUTINES }
  1715. { }
  1716. {--------------------------------------------------------------------------}
  1717. Procedure GetScanlineDefault (X1, X2, Y : smallint; Var Data); {$ifndef fpc}far;{$endif fpc}
  1718. {**********************************************************}
  1719. { Procedure GetScanLine() }
  1720. {----------------------------------------------------------}
  1721. { Returns the full scanline of the video line of the Y }
  1722. { coordinate. The values are returned in a WORD array }
  1723. { each WORD representing a pixel of the specified scanline }
  1724. { note: we only need the pixels inside the ViewPort! (JM) }
  1725. { note2: extended so you can specify start and end X coord }
  1726. { so it is usable for GetImage too (JM) }
  1727. {**********************************************************}
  1728. Var
  1729. x : smallint;
  1730. Begin
  1731. For x:=X1 to X2 Do
  1732. WordArray(Data)[x-x1]:=GetPixel(x, y);
  1733. End;
  1734. Function DefaultImageSize(X1,Y1,X2,Y2: smallint): longint; {$ifndef fpc}far;{$endif fpc}
  1735. Begin
  1736. { each pixel uses two bytes, to enable modes with colors up to 64K }
  1737. { to work. }
  1738. DefaultImageSize := 12 + (((X2-X1+1)*(Y2-Y1+1))*2);
  1739. end;
  1740. Procedure DefaultPutImage(X,Y: smallint; var Bitmap; BitBlt: Word); {$ifndef fpc}far;{$endif fpc}
  1741. type
  1742. pt = array[0..$fffffff] of word;
  1743. ptw = array[0..2] of longint;
  1744. var
  1745. k: longint;
  1746. oldCurrentColor, color: word;
  1747. oldCurrentWriteMode, i, j, y1, x1, deltaX, deltaX1, deltaY: smallint;
  1748. Begin
  1749. {$ifdef logging}
  1750. LogLn('putImage at ('+strf(x)+','+strf(y)+') with width '+strf(ptw(Bitmap)[0])+
  1751. ' and height '+strf(ptw(Bitmap)[1]));
  1752. deltaY := 0;
  1753. {$endif logging}
  1754. inc(x,startXViewPort);
  1755. inc(y,startYViewPort);
  1756. x1 := ptw(Bitmap)[0]+x; { get width and adjust end coordinate accordingly }
  1757. y1 := ptw(Bitmap)[1]+y; { get height and adjust end coordinate accordingly }
  1758. deltaX := 0;
  1759. deltaX1 := 0;
  1760. k := 3 * sizeOf(Longint) div sizeOf(Word); { Three reserved longs at start of bitmap }
  1761. { check which part of the image is in the viewport }
  1762. if clipPixels then
  1763. begin
  1764. if y < startYViewPort then
  1765. begin
  1766. deltaY := startYViewPort - y;
  1767. inc(k,(x1-x+1)*deltaY);
  1768. y := startYViewPort;
  1769. end;
  1770. if y1 > startYViewPort+viewHeight then
  1771. y1 := startYViewPort+viewHeight;
  1772. if x < startXViewPort then
  1773. begin
  1774. deltaX := startXViewPort-x;
  1775. x := startXViewPort;
  1776. end;
  1777. if x1 > startXViewPort + viewWidth then
  1778. begin
  1779. deltaX1 := x1 - (startXViewPort + viewWidth);
  1780. x1 := startXViewPort + viewWidth;
  1781. end;
  1782. end;
  1783. {$ifdef logging}
  1784. LogLn('deltax: '+strf(deltax)+', deltax1: '+strf(deltax1)+',deltay: '+strf(deltay));
  1785. {$endif logging}
  1786. oldCurrentColor := currentColor;
  1787. oldCurrentWriteMode := currentWriteMode;
  1788. currentWriteMode := bitBlt;
  1789. for j:=Y to Y1 do
  1790. Begin
  1791. inc(k,deltaX);
  1792. for i:=X to X1 do
  1793. begin
  1794. currentColor := pt(bitmap)[k];
  1795. directPutPixel(i,j);
  1796. inc(k);
  1797. end;
  1798. inc(k,deltaX1);
  1799. end;
  1800. currentWriteMode := oldCurrentWriteMode;
  1801. currentColor := oldCurrentColor;
  1802. end;
  1803. Procedure DefaultGetImage(X1,Y1,X2,Y2: smallint; Var Bitmap); {$ifndef fpc}far;{$endif fpc}
  1804. type
  1805. pt = array[0..$fffffff] of word;
  1806. ptw = array[0..2] of longint;
  1807. var
  1808. i,j: smallint;
  1809. k: longint;
  1810. Begin
  1811. k:= 3 * Sizeof(longint) div sizeof(word); { Three reserved longs at start of bitmap }
  1812. i := x2 - x1 + 1;
  1813. for j:=Y1 to Y2 do
  1814. Begin
  1815. GetScanLine(x1,x2,j,pt(Bitmap)[k]);
  1816. inc(k,i);
  1817. end;
  1818. ptw(Bitmap)[0] := X2-X1; { First longint is width }
  1819. ptw(Bitmap)[1] := Y2-Y1; { Second longint is height }
  1820. ptw(bitmap)[2] := 0; { Third longint is reserved}
  1821. end;
  1822. Procedure GetArcCoords(var ArcCoords: ArcCoordsType);
  1823. Begin
  1824. ArcCoords.X := ArcCall.X;
  1825. ArcCoords.Y := ArcCall.Y;
  1826. ArcCoords.XStart := ArcCall.XStart;
  1827. ArcCoords.YStart := ArcCall.YStart;
  1828. ArcCoords.XEnd := ArcCall.XEnd;
  1829. ArcCoords.YEnd := ArcCall.YEnd;
  1830. end;
  1831. procedure SetVisualPageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1832. begin
  1833. end;
  1834. procedure SetActivePageDefault(page : word); {$ifndef fpc}far;{$endif fpc}
  1835. begin
  1836. end;
  1837. procedure DirectPutPixelDefault(X,Y: smallint);
  1838. begin
  1839. RunError(218);
  1840. end;
  1841. function GetPixelDefault(X,Y: smallint): word;
  1842. begin
  1843. RunError(218);
  1844. exit(0); { avoid warning }
  1845. end;
  1846. procedure PutPixelDefault(X,Y: smallint; Color: Word);
  1847. begin
  1848. RunError(218);
  1849. end;
  1850. procedure SetRGBPaletteDefault(ColorNum, RedValue, GreenValue, BlueValue: smallint);
  1851. begin
  1852. RunError(218);
  1853. end;
  1854. procedure GetRGBPaletteDefault(ColorNum: smallint; var
  1855. RedValue, GreenValue, BlueValue: smallint);
  1856. begin
  1857. RunError(218);
  1858. end;
  1859. Procedure DefaultHooks;
  1860. {********************************************************}
  1861. { Procedure DefaultHooks() }
  1862. {--------------------------------------------------------}
  1863. { Resets all hookable routine either to nil for those }
  1864. { which need overrides, and others to defaults. }
  1865. { This is called each time SetGraphMode() is called. }
  1866. {********************************************************}
  1867. Begin
  1868. { All default hooks procedures }
  1869. {$ifdef fpc}
  1870. { required...}
  1871. DirectPutPixel := @DirectPutPixelDefault;
  1872. PutPixel := @PutPixelDefault;
  1873. GetPixel := @GetPixelDefault;
  1874. SetRGBPalette := @SetRGBPaletteDefault;
  1875. GetRGBPalette := @GetRGBPaletteDefault;
  1876. { optional...}
  1877. SetActivePage := @SetActivePageDefault;
  1878. SetVisualPage := @SetVisualPageDefault;
  1879. ClearViewPort := @ClearViewportDefault;
  1880. PutImage := @DefaultPutImage;
  1881. GetImage := @DefaultGetImage;
  1882. ImageSize := @DefaultImageSize;
  1883. {$else fpc}
  1884. { required...}
  1885. DirectPutPixel := DirectPutPixelDefault;
  1886. PutPixel := PutPixelDefault;
  1887. GetPixel := GetPixelDefault;
  1888. SetRGBPalette := SetRGBPaletteDefault;
  1889. GetRGBPalette := GetRGBPaletteDefault;
  1890. { optional...}
  1891. SetActivePage := SetActivePageDefault;
  1892. SetVisualPage := SetVisualPageDefault;
  1893. ClearViewPort := ClearViewportDefault;
  1894. PutImage := DefaultPutImage;
  1895. GetImage := DefaultGetImage;
  1896. ImageSize := DefaultImageSize;
  1897. {$endif fpc}
  1898. GraphFreeMemPtr := nil;
  1899. GraphGetMemPtr := nil;
  1900. {$ifdef fpc}
  1901. GetScanLine := @GetScanLineDefault;
  1902. Line := @LineDefault;
  1903. InternalEllipse := @InternalEllipseDefault;
  1904. PatternLine := @PatternLineDefault;
  1905. HLine := @HLineDefault;
  1906. VLine := @VLineDefault;
  1907. {$else fpc}
  1908. GetScanLine := GetScanLineDefault;
  1909. Line := LineDefault;
  1910. InternalEllipse := InternalEllipseDefault;
  1911. PatternLine := PatternLineDefault;
  1912. HLine := HLineDefault;
  1913. VLine := VLineDefault;
  1914. {$endif fpc}
  1915. end;
  1916. Procedure InitVars;
  1917. {********************************************************}
  1918. { Procedure InitVars() }
  1919. {--------------------------------------------------------}
  1920. { Resets all internal variables, and resets all }
  1921. { overridable routines. }
  1922. {********************************************************}
  1923. Begin
  1924. DirectVideo := TRUE; { By default use fastest access possible }
  1925. ArcCall.X := 0;
  1926. ArcCall.Y := 0;
  1927. ArcCall.XStart := 0;
  1928. ArcCall.YStart := 0;
  1929. ArcCall.XEnd := 0;
  1930. ArcCall.YEnd := 0;
  1931. { Reset to default values }
  1932. IntCurrentMode := 0;
  1933. IntCurrentDriver := 0;
  1934. XAspect := 0;
  1935. YAspect := 0;
  1936. MaxX := 0;
  1937. MaxY := 0;
  1938. MaxColor := 0;
  1939. PaletteSize := 0;
  1940. DirectColor := FALSE;
  1941. HardwarePages := 0;
  1942. DefaultHooks;
  1943. end;
  1944. {$i modes.inc}
  1945. {$i palette.inc}
  1946. {$i graph.inc}
  1947. function InstallUserDriver(Name: string; AutoDetectPtr: Pointer): smallint;
  1948. begin
  1949. _graphResult := grError;
  1950. InstallUserDriver:=grError;
  1951. end;
  1952. function RegisterBGIDriver(driver: pointer): smallint;
  1953. begin
  1954. _graphResult := grError;
  1955. RegisterBGIDriver:=grError;
  1956. end;
  1957. { ----------------------------------------------------------------- }
  1958. Procedure Arc(X,Y : smallint; StAngle,EndAngle,Radius: word);
  1959. { var
  1960. OldWriteMode: word;}
  1961. Begin
  1962. { Only if we are using thickwidths lines do we accept }
  1963. { XORput write modes. }
  1964. { OldWriteMode := CurrentWriteMode;
  1965. if (LineInfo.Thickness = NormWidth) then
  1966. CurrentWriteMode := NormalPut;}
  1967. {$ifdef fpc}
  1968. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,@DummyPatternLine);
  1969. {$else fpc}
  1970. InternalEllipse(X,Y,Radius,Radius,StAngle,Endangle,DummyPatternLine);
  1971. {$endif fpc}
  1972. { CurrentWriteMode := OldWriteMode;}
  1973. end;
  1974. procedure Ellipse(X,Y : smallint; stAngle, EndAngle: word; XRadius,YRadius: word);
  1975. Begin
  1976. {$ifdef fpc}
  1977. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,@DummyPatternLine);
  1978. {$else fpc}
  1979. InternalEllipse(X,Y,XRadius,YRadius,StAngle,Endangle,DummyPatternLine);
  1980. {$endif fpc}
  1981. end;
  1982. procedure FillEllipse(X, Y: smallint; XRadius, YRadius: Word);
  1983. {********************************************************}
  1984. { Procedure FillEllipse() }
  1985. {--------------------------------------------------------}
  1986. { Draws a filled ellipse using (X,Y) as a center point }
  1987. { and XRadius and YRadius as the horizontal and vertical }
  1988. { axes. The ellipse is filled with the current fill color}
  1989. { and fill style, and is bordered with the current color.}
  1990. {********************************************************}
  1991. begin
  1992. InternalEllipse(X,Y,XRadius,YRadius,0,360,PatternLine)
  1993. end;
  1994. procedure Circle(X, Y: smallint; Radius:Word);
  1995. {********************************************************}
  1996. { Draws a circle centered at X,Y with the given Radius. }
  1997. {********************************************************}
  1998. { Important notes: }
  1999. { - Thickwidth circles use the current write mode, while}
  2000. { normal width circles ALWAYS use CopyPut/NormalPut }
  2001. { mode. (Tested against VGA BGI driver -CEC 13/Aug/99 }
  2002. {********************************************************}
  2003. var OriginalArcInfo: ArcCoordsType;
  2004. OldWriteMode: word;
  2005. begin
  2006. if (Radius = 0) then
  2007. Exit;
  2008. if (Radius = 1) then
  2009. begin
  2010. { only normal put mode is supported by a call to PutPixel }
  2011. PutPixel(X, Y, CurrentColor);
  2012. Exit;
  2013. end;
  2014. { save state of arc information }
  2015. { because it is not needed for }
  2016. { a circle call. }
  2017. move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
  2018. if LineInfo.Thickness = Normwidth then
  2019. begin
  2020. OldWriteMode := CurrentWriteMode;
  2021. CurrentWriteMode := CopyPut;
  2022. end;
  2023. {$ifdef fpc}
  2024. InternalEllipse(X,Y,Radius,Radius,0,360,@DummyPatternLine);
  2025. {$else fpc}
  2026. InternalEllipse(X,Y,Radius,Radius,0,360,DummyPatternLine);
  2027. {$endif fpc}
  2028. if LineInfo.Thickness = Normwidth then
  2029. CurrentWriteMode := OldWriteMode;
  2030. { restore arc information }
  2031. move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
  2032. end;
  2033. procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
  2034. var plx1, plx2: smallint;
  2035. {$ifdef sectorpldebug}
  2036. t : text;
  2037. {$endif sectorpldebug}
  2038. begin
  2039. {$ifdef sectorpldebug}
  2040. assign(t,'sector.log');
  2041. append(t);
  2042. writeln(t,'Got here for line ',y);
  2043. close(t);
  2044. {$endif sectorpldebug}
  2045. If (x1 = -maxsmallint) Then
  2046. If (x2 = maxsmallint-1) Then
  2047. { no ellipse points drawn on this line }
  2048. If (((Y < ArcCall.Y) and (Y > ArcCall.YStart)) or
  2049. ((Y > ArcCall.Y) and (Y < ArcCall.YStart))) Then
  2050. { there is a part of the sector at this y coordinate, but no }
  2051. { ellips points are plotted on this line, so draw a patternline }
  2052. { between the lines connecting (arccall.x,arccall.y) with }
  2053. { the start and the end of the arc (JM) }
  2054. { use: y-y1=(y2-y1)/(x2-x1)*(x-x1) => }
  2055. { x = (y-y1)/(y2-y1)*(x2-x1)+x1 }
  2056. Begin
  2057. {$ifdef sectorpldebug}
  2058. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2059. begin
  2060. append(t);
  2061. writeln(t,'bug1');
  2062. close(t);
  2063. runerror(202);
  2064. end;
  2065. {$endif sectorpldebug}
  2066. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2067. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X;
  2068. {$ifdef sectorpldebug}
  2069. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2070. begin
  2071. append(t);
  2072. writeln(t,'bug2');
  2073. close(t);
  2074. runerror(202);
  2075. end;
  2076. {$endif sectorpldebug}
  2077. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2078. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X;
  2079. If plx1 > plx2 then
  2080. begin
  2081. plx1 := plx1 xor plx2;
  2082. plx2 := plx1 xor plx2;
  2083. plx1 := plx1 xor plx2;
  2084. end;
  2085. {$ifdef sectorpldebug}
  2086. append(t);
  2087. writeln(t,'lines: ',plx1,' - ',plx2);
  2088. close(t);
  2089. {$endif sectorpldebug}
  2090. End
  2091. { otherwise two points which have nothing to do with the sector }
  2092. Else exit
  2093. Else
  2094. { the arc is plotted at the right side, but not at the left side, }
  2095. { fill till the line between (ArcCall.X,ArcCall.Y) and }
  2096. { (ArcCall.XStart,ArcCall.YStart) }
  2097. Begin
  2098. If (y < ArcCall.Y) then
  2099. begin
  2100. {$ifdef sectorpldebug}
  2101. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2102. begin
  2103. append(t);
  2104. writeln(t,'bug3');
  2105. close(t);
  2106. runerror(202);
  2107. end;
  2108. {$endif sectorpldebug}
  2109. plx1 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2110. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2111. end
  2112. else if (y > ArcCall.Y) then
  2113. begin
  2114. {$ifdef sectorpldebug}
  2115. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2116. begin
  2117. append(t);
  2118. writeln(t,'bug4');
  2119. close(t);
  2120. runerror(202);
  2121. end;
  2122. {$endif sectorpldebug}
  2123. plx1 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2124. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2125. end
  2126. else plx1 := ArcCall.X;
  2127. plx2 := x2;
  2128. {$ifdef sectorpldebug}
  2129. append(t);
  2130. writeln(t,'right: ',plx1,' - ',plx2);
  2131. close(t);
  2132. {$endif sectorpldebug}
  2133. End
  2134. Else
  2135. If (x2 = maxsmallint-1) Then
  2136. { the arc is plotted at the left side, but not at the rigth side. }
  2137. { the right limit can be either the first or second line. Just take }
  2138. { the closest one, but watch out for division by zero! }
  2139. Begin
  2140. If (y < ArcCall.Y) then
  2141. begin
  2142. {$ifdef sectorpldebug}
  2143. If (ArcCall.YStart-ArcCall.Y) = 0 then
  2144. begin
  2145. append(t);
  2146. writeln(t,'bug5');
  2147. close(t);
  2148. runerror(202);
  2149. end;
  2150. {$endif sectorpldebug}
  2151. plx2 := (y-ArcCall.Y)*(ArcCall.XStart-ArcCall.X)
  2152. div (ArcCall.YStart-ArcCall.Y)+ArcCall.X
  2153. end
  2154. else if (y > ArcCall.Y) then
  2155. begin
  2156. {$ifdef sectorpldebug}
  2157. If (ArcCall.YEnd-ArcCall.Y) = 0 then
  2158. begin
  2159. append(t);
  2160. writeln(t,'bug6');
  2161. close(t);
  2162. runerror(202);
  2163. end;
  2164. {$endif sectorpldebug}
  2165. plx2 := (y-ArcCall.Y)*(ArcCall.XEnd-ArcCall.X)
  2166. div (ArcCall.YEnd-ArcCall.Y)+ArcCall.X
  2167. end
  2168. else plx2 := ArcCall.X;
  2169. plx1 := x1;
  2170. {$ifdef sectorpldebug}
  2171. append(t);
  2172. writeln(t,'left: ',plx1,' - ',plx2);
  2173. close(t);
  2174. {$endif sectorpldebug}
  2175. End
  2176. Else
  2177. { the arc is plotted at both sides }
  2178. Begin
  2179. plx1 := x1;
  2180. plx2 := x2;
  2181. {$ifdef sectorpldebug}
  2182. append(t);
  2183. writeln(t,'normal: ',plx1,' - ',plx2);
  2184. close(t);
  2185. {$endif sectorpldebug}
  2186. End;
  2187. If plx2 > plx1 then
  2188. Begin
  2189. {$ifdef sectorpldebug}
  2190. append(t);
  2191. Writeln(t,'drawing...');
  2192. close(t);
  2193. {$endif sectorpldebug}
  2194. PatternLine(plx1,plx2,y);
  2195. end;
  2196. end;
  2197. procedure Sector(x, y: smallint; StAngle,EndAngle, XRadius, YRadius: Word);
  2198. (* var angle : graph_float;
  2199. writemode : word; *)
  2200. begin
  2201. {$ifdef fpc}
  2202. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, @SectorPL);
  2203. {$else fpc}
  2204. internalellipse(x,y,XRadius, YRadius, StAngle, EndAngle, SectorPL);
  2205. {$endif fpc}
  2206. Line(ArcCall.XStart, ArcCall.YStart, x,y);
  2207. Line(x,y,ArcCall.Xend,ArcCall.YEnd);
  2208. end;
  2209. procedure SetFillStyle(Pattern : word; Color: word);
  2210. begin
  2211. { on invalid input, the current fill setting will be }
  2212. { unchanged. }
  2213. if (Pattern > UserFill) or (Color > GetMaxColor) then
  2214. begin
  2215. _GraphResult := grError;
  2216. exit;
  2217. end;
  2218. FillSettings.Color := Color;
  2219. FillSettings.Pattern := Pattern;
  2220. end;
  2221. procedure SetFillPattern(Pattern: FillPatternType; Color: word);
  2222. {********************************************************}
  2223. { Changes the Current FillPattern to a user defined }
  2224. { pattern and changes also the current fill color. }
  2225. { The FillPattern is saved in the FillPattern array so }
  2226. { it can still be used with SetFillStyle(UserFill,Color) }
  2227. {********************************************************}
  2228. var
  2229. i: smallint;
  2230. begin
  2231. if Color > GetMaxColor then
  2232. begin
  2233. _GraphResult := grError;
  2234. exit;
  2235. end;
  2236. FillSettings.Color := Color;
  2237. FillSettings.Pattern := UserFill;
  2238. { Save the pattern in the buffer }
  2239. For i:=1 to 8 do
  2240. FillPatternTable[UserFill][i] := Pattern[i];
  2241. end;
  2242. procedure Bar(x1,y1,x2,y2:smallint);
  2243. {********************************************************}
  2244. { Important notes for compatibility with BP: }
  2245. { - WriteMode is always CopyPut }
  2246. { - No contour is drawn for the lines }
  2247. {********************************************************}
  2248. var y : smallint;
  2249. origcolor : longint;
  2250. origlinesettings: Linesettingstype;
  2251. origwritemode : smallint;
  2252. begin
  2253. origlinesettings:=lineinfo;
  2254. origcolor:=CurrentColor;
  2255. if y1>y2 then
  2256. begin
  2257. y:=y1;
  2258. y1:=y2;
  2259. y2:=y;
  2260. end;
  2261. { Always copy mode for Bars }
  2262. origwritemode := CurrentWriteMode;
  2263. CurrentWriteMode := CopyPut;
  2264. { All lines used are of this style }
  2265. Lineinfo.linestyle:=solidln;
  2266. Lineinfo.thickness:=normwidth;
  2267. case Fillsettings.pattern of
  2268. EmptyFill :
  2269. begin
  2270. Currentcolor:=CurrentBkColor;
  2271. for y:=y1 to y2 do
  2272. Hline(x1,x2,y);
  2273. end;
  2274. SolidFill :
  2275. begin
  2276. CurrentColor:=FillSettings.color;
  2277. for y:=y1 to y2 do
  2278. Hline(x1,x2,y);
  2279. end;
  2280. else
  2281. Begin
  2282. CurrentColor:=FillSettings.color;
  2283. for y:=y1 to y2 do
  2284. patternline(x1,x2,y);
  2285. end;
  2286. end;
  2287. CurrentColor:= Origcolor;
  2288. LineInfo := OrigLineSettings;
  2289. CurrentWriteMode := OrigWritemode;
  2290. end;
  2291. procedure bar3D(x1, y1, x2, y2 : smallint;depth : word;top : boolean);
  2292. var
  2293. origwritemode : smallint;
  2294. OldX, OldY : smallint;
  2295. begin
  2296. origwritemode := CurrentWriteMode;
  2297. CurrentWriteMode := CopyPut;
  2298. Bar(x1,y1,x2,y2);
  2299. Rectangle(x1,y1,x2,y2);
  2300. { Current CP should not be updated in Bar3D }
  2301. { therefore save it and then restore it on }
  2302. { exit. }
  2303. OldX := CurrentX;
  2304. OldY := CurrentY;
  2305. if top then begin
  2306. Moveto(x1,y1);
  2307. Lineto(x1+depth,y1-depth);
  2308. Lineto(x2+depth,y1-depth);
  2309. Lineto(x2,y1);
  2310. end;
  2311. if Depth <> 0 then
  2312. Begin
  2313. Moveto(x2+depth,y1-depth);
  2314. Lineto(x2+depth,y2-depth);
  2315. Lineto(x2,y2);
  2316. end;
  2317. { restore CP }
  2318. CurrentX := OldX;
  2319. CurrentY := OldY;
  2320. CurrentWriteMode := origwritemode;
  2321. end;
  2322. {--------------------------------------------------------------------------}
  2323. { }
  2324. { COLOR AND PALETTE ROUTINES }
  2325. { }
  2326. {--------------------------------------------------------------------------}
  2327. procedure SetColor(Color: Word);
  2328. Begin
  2329. CurrentColor := Color;
  2330. end;
  2331. function GetColor: Word;
  2332. Begin
  2333. GetColor := CurrentColor;
  2334. end;
  2335. function GetBkColor: Word;
  2336. Begin
  2337. GetBkColor := CurrentBkColor;
  2338. end;
  2339. procedure SetBkColor(ColorNum: Word);
  2340. { Background color means background screen color in this case, and it is }
  2341. { INDEPENDANT of the viewport settings, so we must clear the whole screen }
  2342. { with the color. }
  2343. var
  2344. ViewPort: ViewportType;
  2345. Begin
  2346. GetViewSettings(Viewport);
  2347. SetViewPort(0,0,MaxX,MaxY,FALSE);
  2348. CurrentBkColor := ColorNum;
  2349. {ClearViewPort;}
  2350. if not DirectColor and (ColorNum<256) then
  2351. SetRGBPalette(0,
  2352. DefaultColors[ColorNum].Red,
  2353. DefaultColors[ColorNum].Green,
  2354. DefaultColors[ColorNum].Blue);
  2355. SetViewport(ViewPort.X1,Viewport.Y1,Viewport.X2,Viewport.Y2,Viewport.Clip);
  2356. end;
  2357. function GetMaxColor: word;
  2358. { Checked against TP VGA driver - CEC }
  2359. begin
  2360. GetMaxColor:=MaxColor-1; { based on an index of zero so subtract one }
  2361. end;
  2362. Procedure MoveRel(Dx, Dy: smallint);
  2363. Begin
  2364. CurrentX := CurrentX + Dx;
  2365. CurrentY := CurrentY + Dy;
  2366. end;
  2367. Procedure MoveTo(X,Y: smallint);
  2368. {********************************************************}
  2369. { Procedure MoveTo() }
  2370. {--------------------------------------------------------}
  2371. { Moves the current pointer in VIEWPORT relative }
  2372. { coordinates to the specified X,Y coordinate. }
  2373. {********************************************************}
  2374. Begin
  2375. CurrentX := X;
  2376. CurrentY := Y;
  2377. end;
  2378. function GraphErrorMsg(ErrorCode: smallint): string;
  2379. Begin
  2380. GraphErrorMsg:='';
  2381. case ErrorCode of
  2382. grOk,grFileNotFound,grInvalidDriver: exit;
  2383. grNoInitGraph: GraphErrorMsg:='Graphics driver not installed';
  2384. grNotDetected: GraphErrorMsg:='Graphics hardware not detected';
  2385. grNoLoadMem,grNoScanMem,grNoFloodMem: GraphErrorMsg := 'Not enough memory for graphics';
  2386. grNoFontMem: GraphErrorMsg := 'Not enough memory to load font';
  2387. grFontNotFound: GraphErrorMsg:= 'Font file not found';
  2388. grInvalidMode: GraphErrorMsg := 'Invalid graphics mode';
  2389. grError: GraphErrorMsg:='Graphics error';
  2390. grIoError: GraphErrorMsg:='Graphics I/O error';
  2391. grInvalidFont,grInvalidFontNum: GraphErrorMsg := 'Invalid font';
  2392. grInvalidVersion: GraphErrorMsg:='Invalid driver version';
  2393. end;
  2394. end;
  2395. Function GetMaxX: smallint;
  2396. { Routine checked against VGA driver - CEC }
  2397. Begin
  2398. GetMaxX := MaxX;
  2399. end;
  2400. Function GetMaxY: smallint;
  2401. { Routine checked against VGA driver - CEC }
  2402. Begin
  2403. GetMaxY := MaxY;
  2404. end;
  2405. Function GraphResult: smallint;
  2406. Begin
  2407. GraphResult := _GraphResult;
  2408. _GraphResult := grOk;
  2409. end;
  2410. Function GetX: smallint;
  2411. Begin
  2412. GetX := CurrentX;
  2413. end;
  2414. Function GetY: smallint;
  2415. Begin
  2416. GetY := CurrentY;
  2417. end;
  2418. Function GetDriverName: string;
  2419. begin
  2420. GetDriverName:=DriverName;
  2421. end;
  2422. procedure graphdefaults;
  2423. { PS: GraphDefaults does not ZERO the ArcCall structure }
  2424. { so a call to GetArcCoords will not change even the }
  2425. { returned values even if GraphDefaults is called in }
  2426. { between. }
  2427. var
  2428. i: smallint;
  2429. begin
  2430. lineinfo.linestyle:=solidln;
  2431. lineinfo.thickness:=normwidth;
  2432. { reset line style pattern }
  2433. for i:=0 to 15 do
  2434. LinePatterns[i] := TRUE;
  2435. { By default, according to the TP prog's reference }
  2436. { the default pattern is solid, and the default }
  2437. { color is the maximum color in the palette. }
  2438. fillsettings.color:=GetMaxColor;
  2439. fillsettings.pattern:=solidfill;
  2440. { GraphDefaults resets the User Fill pattern to $ff }
  2441. { checked with VGA BGI driver - CEC }
  2442. for i:=1 to 8 do
  2443. FillPatternTable[UserFill][i] := $ff;
  2444. CurrentColor:=white;
  2445. SetBkColor(Black);
  2446. ClipPixels := TRUE;
  2447. { Reset the viewport }
  2448. StartXViewPort := 0;
  2449. StartYViewPort := 0;
  2450. ViewWidth := MaxX;
  2451. ViewHeight := MaxY;
  2452. { Reset CP }
  2453. CurrentX := 0;
  2454. CurrentY := 0;
  2455. { normal write mode }
  2456. CurrentWriteMode := CopyPut;
  2457. { Schriftart einstellen }
  2458. CurrentTextInfo.font := DefaultFont;
  2459. CurrentTextInfo.direction:=HorizDir;
  2460. CurrentTextInfo.charsize:=1;
  2461. CurrentTextInfo.horiz:=LeftText;
  2462. CurrentTextInfo.vert:=TopText;
  2463. XAspect:=10000; YAspect:=10000;
  2464. end;
  2465. procedure GetAspectRatio(var Xasp,Yasp : word);
  2466. begin
  2467. XAsp:=XAspect;
  2468. YAsp:=YAspect;
  2469. end;
  2470. procedure SetAspectRatio(Xasp, Yasp : word);
  2471. begin
  2472. Xaspect:= XAsp;
  2473. YAspect:= YAsp;
  2474. end;
  2475. procedure SetWriteMode(WriteMode : smallint);
  2476. { TP sets the writemodes according to the following scheme (JM) }
  2477. begin
  2478. Case writemode of
  2479. xorput, andput: CurrentWriteMode := XorPut;
  2480. notput, orput, copyput: CurrentWriteMode := CopyPut;
  2481. End;
  2482. end;
  2483. procedure GetFillSettings(var Fillinfo:Fillsettingstype);
  2484. begin
  2485. Fillinfo:=Fillsettings;
  2486. end;
  2487. procedure GetFillPattern(var FillPattern:FillPatternType);
  2488. begin
  2489. FillPattern:=FillpatternTable[UserFill];
  2490. end;
  2491. procedure DrawPoly(numpoints : word;var polypoints);
  2492. type
  2493. ppointtype = ^pointtype;
  2494. pt = array[0..16000] of pointtype;
  2495. var
  2496. i : longint;
  2497. begin
  2498. if numpoints < 2 then
  2499. begin
  2500. _GraphResult := grError;
  2501. exit;
  2502. end;
  2503. for i:=0 to numpoints-2 do
  2504. line(pt(polypoints)[i].x,
  2505. pt(polypoints)[i].y,
  2506. pt(polypoints)[i+1].x,
  2507. pt(polypoints)[i+1].y);
  2508. end;
  2509. procedure PieSlice(X,Y,stangle,endAngle:smallint;Radius: Word);
  2510. begin
  2511. Sector(x,y,stangle,endangle,radius,radius);
  2512. end;
  2513. {$i fills.inc}
  2514. {$i gtext.inc}
  2515. procedure DetectGraph(var GraphDriver:smallint;var GraphMode:smallint);
  2516. var LoMode, HiMode: smallint;
  2517. CpyMode: smallint;
  2518. CpyDriver: smallint;
  2519. begin
  2520. HiMode := -1;
  2521. LoMode := -1;
  2522. { We start at VGA }
  2523. GraphDriver := VGA;
  2524. CpyMode := 0;
  2525. { search all possible graphic drivers in ascending order...}
  2526. { usually the new driver numbers indicate newest hardware...}
  2527. { Internal driver numbers start at VGA=9 }
  2528. repeat
  2529. GetModeRange(GraphDriver,LoMode,HiMode);
  2530. { save the highest mode possible...}
  2531. {$ifdef logging}
  2532. logln('Found driver '+strf(graphdriver)+' with modes '+
  2533. strf(lomode)+' - '+strf(himode));
  2534. {$endif logging}
  2535. if HiMode = -1 then break;
  2536. CpyMode:=HiMode;
  2537. CpyDriver:=GraphDriver;
  2538. { go to next driver if it exists...}
  2539. Inc(GraphDriver);
  2540. until (CpyMode=-1);
  2541. { If this is equal to -1 then no graph mode possible...}
  2542. if CpyMode = -1 then
  2543. begin
  2544. _GraphResult := grNotDetected;
  2545. exit;
  2546. end;
  2547. _GraphResult := grOK;
  2548. GraphDriver := CpyDriver;
  2549. GraphMode := CpyMode;
  2550. end;
  2551. procedure InitGraph(var GraphDriver:smallint;var GraphMode:smallint;
  2552. const PathToDriver:String);
  2553. begin
  2554. InitVars;
  2555. { path to the fonts (where they will be searched)...}
  2556. bgipath:=PathToDriver;
  2557. if bgipath[length(bgipath)]<>'\' then
  2558. bgipath:=bgipath+'\';
  2559. if not assigned(SaveVideoState) then
  2560. RunError(216);
  2561. DriverName:=InternalDriverName; { DOS Graphics driver }
  2562. if (Graphdriver=Detect) then
  2563. begin
  2564. DetectGraph(GraphDriver,GraphMode);
  2565. If _GraphResult = grNotDetected then Exit;
  2566. { _GraphResult is now already set to grOK by DetectGraph }
  2567. IntCurrentDriver := GraphDriver;
  2568. SaveVideoState;
  2569. { Actually set the graph mode...}
  2570. SetGraphMode(GraphMode);
  2571. end
  2572. else
  2573. begin
  2574. { Search if that graphics modec actually exists...}
  2575. if SearchMode(GraphDriver,GraphMode) = nil then
  2576. begin
  2577. _GraphResult := grInvalidMode;
  2578. exit;
  2579. end
  2580. else
  2581. begin
  2582. _GraphResult := grOK;
  2583. IntCurrentDriver := GraphDriver;
  2584. SaveVideoState;
  2585. {$ifdef logging}
  2586. If _GraphResult <> grOK then
  2587. LogLn('Mode setting failed after savevideostate');
  2588. {$endif logging}
  2589. SetGraphMode(GraphMode);
  2590. end;
  2591. end;
  2592. end;
  2593. procedure SetDirectVideo(DirectAccess: boolean);
  2594. begin
  2595. DirectVideo := DirectAccess;
  2596. end;
  2597. function GetDirectVideo: boolean;
  2598. begin
  2599. GetDirectVideo := DirectVideo;
  2600. end;
  2601. procedure GraphExitProc; {$ifndef fpc} far; {$endif fpc}
  2602. { deallocates all memory allocated by the graph unit }
  2603. var
  2604. list: PModeInfo;
  2605. tmp : PModeInfo;
  2606. c: graph_int;
  2607. begin
  2608. { restore old exitproc! }
  2609. exitproc := exitsave;
  2610. if IsGraphMode and ((errorcode<>0) or (erroraddr<>nil)) then
  2611. CloseGraph;
  2612. {$ifdef testsave}
  2613. restorevideostate;
  2614. {$endif testsave}
  2615. { release memory allocated for fonts }
  2616. for c := 1 to installedfonts do
  2617. with fonts[c] Do
  2618. If assigned(instr) Then
  2619. Freemem(instr,instrlength);
  2620. { release memory allocated for modelist }
  2621. list := ModeList;
  2622. while assigned(list) do
  2623. begin
  2624. tmp := list;
  2625. list:=list^.next;
  2626. dispose(tmp);
  2627. end;
  2628. {$IFDEF DPMI}
  2629. { We had copied the buffer of mode information }
  2630. { and allocated it dynamically... now free it }
  2631. { Warning: if GetVESAInfo returned false, this buffer is not allocated! (JM)}
  2632. If hasVesa then
  2633. Dispose(VESAInfo.ModeList);
  2634. {$ENDIF}
  2635. end;
  2636. begin
  2637. {$ifdef logging}
  2638. assign(debuglog,'grlog.txt');
  2639. rewrite(debuglog);
  2640. close(debuglog);
  2641. {$endif logging}
  2642. isgraphmode := false;
  2643. ModeList := nil;
  2644. SaveVideoState := nil;
  2645. RestoreVideoState := nil;
  2646. SavePtr := Nil;
  2647. {$ifdef oldfont}
  2648. {$ifdef go32v2}
  2649. LoadFont8x8;
  2650. {$endif go32v2}
  2651. {$endif oldfont}
  2652. { This must be called at startup... because GetGraphMode may }
  2653. { be called even when not in graph mode. }
  2654. {$ifdef logging}
  2655. LogLn('Calling QueryAdapterInfo...');
  2656. {$endif logging}
  2657. QueryAdapterInfo;
  2658. { Install standard fonts }
  2659. { This is done BEFORE startup... }
  2660. InstalledFonts := 0;
  2661. InstallUserFont('TRIP');
  2662. InstallUserFont('LITT');
  2663. InstallUserFont('SANS');
  2664. InstallUserFont('GOTH');
  2665. { This installs an exit procedure which cleans up the mode list...}
  2666. ExitSave := ExitProc;
  2667. ExitProc := @GraphExitProc;
  2668. {$ifdef testsave}
  2669. savevideostate;
  2670. {$endif testsave}
  2671. {$ifdef win32}
  2672. charmessagehandler:=nil;
  2673. {$endif win32}
  2674. end.
  2675. SetGraphBufSize
  2676. {
  2677. $Log$
  2678. Revision 1.50 1999-12-21 17:42:17 jonas
  2679. * changed vesa.inc do it doesn't try to use linear modes anymore (doesn't work
  2680. yet!!)
  2681. * fixed mode detection so the low modenumber of a driver doesn't have to be zero
  2682. anymore (so VESA autodetection now works)
  2683. Revision 1.49 1999/12/21 09:16:48 pierre
  2684. + CloseGraph if errors
  2685. Revision 1.48 1999/12/20 11:22:36 peter
  2686. * integer -> smallint to overcome -S2 switch needed for ggi version
  2687. Revision 1.47 1999/12/12 13:34:20 jonas
  2688. * putimage now performs the lipping itself and uses directputpixel
  2689. (note: this REQUIRES or/and/notput support in directputpixel,
  2690. this is not yet the case in the assembler versions!)
  2691. * YOffset addition moved in hlinevesa256 and vlinevesa256
  2692. because it uses still putpixel afterwards
  2693. Revision 1.46 1999/12/11 23:41:38 jonas
  2694. * changed definition of getscanlineproc to "getscanline(x1,x2,y:
  2695. smallint; var data);" so it can be used by getimage too
  2696. * changed getimage so it uses getscanline
  2697. * changed floodfill, getscanline16 and definitions in Linux
  2698. include files so they use this new format
  2699. + getscanlineVESA256 for 256 color VESA modes (banked)
  2700. Revision 1.45 1999/12/10 12:47:41 pierre
  2701. * SetBkColor like BP by changing Palette entry zero
  2702. Revision 1.44 1999/11/30 08:57:46 michael
  2703. + Removed charmessagehandler declaration, it is in graphh.inc
  2704. Revision 1.43 1999/11/28 16:13:55 jonas
  2705. * corrected misplacement of call to initvars in initgraph
  2706. + some extra debugging commands (for -dlogging) in the mode functions
  2707. Revision 1.42 1999/11/28 12:19:59 jonas
  2708. * _GraphResult is now properly set to grOK by DetectGraph and
  2709. InitGraph if there are no errors
  2710. Revision 1.41 1999/11/27 21:48:01 jonas
  2711. * fixed VlineVESA256 and re-enabled it in graph.inc
  2712. * added procedure detectgraph to interface of graph unit
  2713. Revision 1.40 1999/11/25 17:44:14 pierre
  2714. * memory corruption within GetImage removed
  2715. Revision 1.39 1999/11/24 23:42:31 pierre
  2716. * PutImage used an smallint index that became negative !!!!
  2717. * Default needed procedure now genrate a RTE 218 instead of a
  2718. GPF by call to nil pointer !
  2719. Revision 1.38 1999/11/11 17:55:07 florian
  2720. * the size was calculated wrong by imagesize
  2721. Revision 1.37 1999/11/11 14:07:14 florian
  2722. * better looking font
  2723. Revision 1.36 1999/11/08 15:01:38 peter
  2724. * fpcmake support
  2725. Revision 1.35 1999/11/08 11:15:22 peter
  2726. * move graph.inc to the target dir
  2727. Revision 1.34 1999/11/03 20:23:01 florian
  2728. + first release of win32 gui support
  2729. Revision 1.33 1999/10/17 10:20:13 jonas
  2730. * fixed clipping for thickwidth lines (bug 659)
  2731. * fixed the faster internalellipsedefault, but it doesn't plot
  2732. all pixels (there are gaps in the ellipses)
  2733. Revision 1.32 1999/09/28 15:07:46 jonas
  2734. * fix for disposing font data because it can contain #0 chars
  2735. Revision 1.31 1999/09/28 13:56:25 jonas
  2736. * reordered some local variables (first 4 byte vars, then 2 byte vars
  2737. etc)
  2738. * font data is now disposed in exitproc, exitproc is now called
  2739. GraphExitProc (was CleanModes) and resides in graph.pp instead of in
  2740. modes.inc
  2741. Revision 1.30 1999/09/27 23:34:41 peter
  2742. * new graph unit is default for go32v2
  2743. * removed warnings/notes
  2744. Revision 1.29 1999/09/26 13:31:06 jonas
  2745. * changed name of modeinfo variable to vesamodeinfo and fixed
  2746. associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
  2747. of sizeof(TVesamodeinfo) etc)
  2748. * changed several sizeof(type) to sizeof(varname) to avoid similar
  2749. errors in the future
  2750. Revision 1.28 1999/09/25 11:48:43 jonas
  2751. + detectgraph
  2752. * small change to internalellipsedefault so less pixels are
  2753. calculated twice
  2754. * some small corrections to graph.tex
  2755. Revision 1.27 1999/09/24 22:52:38 jonas
  2756. * optimized patternline a bit (always use hline when possible)
  2757. * isgraphmode stuff cleanup
  2758. * vesainfo.modelist now gets disposed in cleanmode instead of in
  2759. closegraph (required moving of some declarations from vesa.inc to
  2760. new vesah.inc)
  2761. * queryadapter gets no longer called from initgraph (is called from
  2762. initialization of graph unit)
  2763. * bugfix for notput in 32k and 64k vesa modes
  2764. * a div replaced by / in fillpoly
  2765. Revision 1.26 1999/09/22 13:13:35 jonas
  2766. * renamed text.inc -> gtext.inc to avoid conflict with system unit
  2767. * fixed textwidth
  2768. * isgraphmode now gets properly updated, so mode restoring works
  2769. again
  2770. Revision 1.25 1999/09/18 22:21:10 jonas
  2771. + hlinevesa256 and vlinevesa256
  2772. + support for not/xor/or/andput in vesamodes with 32k/64k colors
  2773. * lots of changes to avoid warnings under FPC
  2774. Revision 1.24 1999/09/18 16:03:37 jonas
  2775. * graph.pp: removed pieslice and sector from ToDo list
  2776. * closegraph: exits now immidiately if isgraphmode = false (caused
  2777. RTE 204 with VESA enabled if you set exitproc to call closegraph
  2778. and also called closegraph explicitely before exit, like bgidemo)
  2779. Revision 1.23 1999/09/17 13:58:31 jonas
  2780. * another fix for a case where internalellipsedefault went haywire
  2781. * sector() and pieslice() fully implemented!
  2782. * small change to prevent buffer overflow with floodfill
  2783. Revision 1.22 1999/09/15 13:37:50 jonas
  2784. * small change to internalellipsedef to be TP compatible
  2785. * fixed directputpixel for vga 320*200*256
  2786. Revision 1.21 1999/09/13 12:49:08 jonas
  2787. * fixed Arc: internallellipse went into an endless loop if StAngle =
  2788. EndAngle
  2789. * FillEllipse is now much faster: no more floodfill,
  2790. InternalEllipseDefault now draws the patternlines immediatety!
  2791. Revision 1.20 1999/09/12 17:29:00 jonas
  2792. * several changes to internalellipse to make it faster
  2793. and to make sure it updates the ArcCall correctly
  2794. (not yet done for width = 3)
  2795. * Arc mostly works now, only sometimes an endless loop, don't know
  2796. why
  2797. Revision 1.19 1999/09/11 19:43:01 jonas
  2798. * FloodFill: did not take into account current viewport settings
  2799. * GetScanLine: only get line inside viewport, data outside of it
  2800. is not used anyway
  2801. * InternalEllipseDefault: fix for when xradius or yradius = 0 and
  2802. increase xradius and yradius always by one (TP does this too)
  2803. * fixed conlict in vesa.inc from last update
  2804. * some conditionals to avoid range check and overflow errors in
  2805. places where it doesn't matter
  2806. Revision 1.18 1999/07/26 09:38:41 florian
  2807. * bar: y2 can be less y1, fixed
  2808. * settextstyle: charsize can be 0, must be changed into 1
  2809. Revision 1.17 1999/07/18 15:07:20 jonas
  2810. + xor-, and and- orput support for VESA256 modes
  2811. * compile with -dlogging if you wnt some info to be logged to grlog.txt
  2812. Revision 1.16 1999/07/14 18:18:04 florian
  2813. * cosmetic changes
  2814. }