GRAPH.MOD 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * GRAPH.MOD - Graphics functions *
  5. * *
  6. * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. (*# call(o_a_copy => off) *)
  11. (*%T _fcall *)
  12. (*# call(seg_name => GRAPHICS) *)
  13. (*%E *)
  14. (*# module(implementation=>off) *)
  15. (*%F _fdata *)
  16. (*# data(seg_name => null) *)
  17. (*%E *)
  18. (*# check(stack=>off,
  19. index=>off,
  20. range=>off,
  21. overflow=>off,
  22. nil_ptr=>off) *)
  23. IMPLEMENTATION MODULE Graph;
  24. IMPORT Str,Lib,SYSTEM,Storage;
  25. (*%T _XTD *)
  26. IMPORT IO,TSXLIB;
  27. FROM TSXLIB IMPORT SEL_A000H,SEL_B000H,SEL_B800H;
  28. CONST _XTDDOS = TRUE;
  29. (*%E*)
  30. (*%F _XTD *)
  31. (*%F _OS2 *)
  32. IMPORT IO;
  33. CONST _XTDDOS = TRUE;
  34. (*%E *)
  35. (*%T _OS2 *)
  36. (*%F _fcall *)
  37. IMPORT IO;
  38. (*%E *)
  39. IMPORT Dos,Vio,GraphI,CoreGraph,CoreSig;
  40. FROM Storage IMPORT ALLOCATE,DEALLOCATE;
  41. CONST _XTDDOS = FALSE;
  42. (*%E _OS2 *)
  43. (*%E _XTD *)
  44. (*%T _XTDDOS *)
  45. (*%F _XTD *)
  46. CONST
  47. SEL_A000H = 0A000H;
  48. SEL_B000H = 0B000H;
  49. SEL_B800H = 0B800H;
  50. (*%E*)
  51. (*****************************************************************************)
  52. (* Constant Definitions. *)
  53. (*****************************************************************************)
  54. CONST
  55. HEADER_SIZE = 4;
  56. FILL_MASK_SIZE = 8;
  57. GRAPHICS = 1;
  58. TEXT = 0;
  59. LEFT = -1;
  60. RIGHT = 1;
  61. UP = -1;
  62. DOWN = 1;
  63. MAXMODE = _MRES256COLOR;
  64. CGA320Width = 320;
  65. CGA640Width = 640;
  66. EGA640Width = 640;
  67. EGA320Width = 320;
  68. EGA200Depth = 200;
  69. EGA350Depth = 350;
  70. EGA480Depth = 480;
  71. TYPE
  72. ArcQuadrant = ARRAY [0..3] OF SHORTCARD;
  73. CONST
  74. _Q_CLEAR = 5;
  75. _Q_1SEG = 4; (* one section in quadrant *)
  76. _Q_2SEG = 3; (* two sections in quadrant *)
  77. _Q_STEST = 2; (* start vector in quadrant *)
  78. _Q_ETEST = 1; (* end vector in quadrant *)
  79. _Q_NULL = 0;
  80. (*****************************************************************************)
  81. (* type and function definitions. *)
  82. (*****************************************************************************)
  83. TYPE
  84. InterSect = RECORD
  85. x,y : INTEGER;
  86. END; (*InterSect*)
  87. FloodStart = RECORD
  88. best_quad : INTEGER;
  89. quad_type : INTEGER;
  90. flag : INTEGER;
  91. END; (*FloodStart*)
  92. tinyint = [0..7];
  93. bs = SET OF tinyint;
  94. bp = POINTER TO bs;
  95. (*# save,data(near_ptr=>off) *)
  96. HercMapType = ARRAY[0..(HercDepth DIV 4)-1] OF ARRAY[0..(HercWidth DIV 8)-1] OF bs;
  97. CGAPointer = POINTER TO SHORTCARD;
  98. VGAPointer = POINTER TO SHORTCARD;
  99. (*# restore *)
  100. VAR
  101. (*# save,data(near_ptr=>off) *)
  102. HercBitMap : ARRAY [0..1] OF ARRAY [0..3] OF POINTER TO HercMapType;
  103. (*# restore *)
  104. StaticMode : CARDINAL;
  105. (*****************************************************************************)
  106. (* Data Definitions and Declarations. *)
  107. (*****************************************************************************)
  108. TYPE
  109. ColTableType = ARRAY [0..15] OF LONGCARD;
  110. EGATableType = ARRAY [0..15] OF CARDINAL;
  111. CONST
  112. ColTable = ColTableType( _BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN,
  113. _WHITE, _GRAY, _LIGHTBLUE, _LIGHTGREEN, _LIGHTCYAN,
  114. _LIGHTRED, _LIGHTMAGENTA, _LIGHTYELLOW, _BRIGHTWHITE);
  115. VAR
  116. EGATable: EGATableType;
  117. ModeChanged: BOOLEAN;
  118. (*****************************************************************************)
  119. (* Function definitions - low level plotting and drawing. *)
  120. (*****************************************************************************)
  121. (*# save *)
  122. (*# call(near_call=>on) *)
  123. PROCEDURE EllipsePlot(x, y: INTEGER);
  124. BEGIN
  125. IF ((x <= CoreGraph._clip_br.xcoord) AND (x >= CoreGraph._clip_tl.xcoord)
  126. AND (y <= CoreGraph._clip_br.ycoord) AND (y >= CoreGraph._clip_tl.ycoord)) THEN
  127. CoreGraph._plot(x, y, CoreGraph._fgcolor);
  128. END;
  129. RETURN;
  130. END EllipsePlot;
  131. PROCEDURE GetFillStart(VAR x, y: INTEGER; ox, oy, startx, starty,
  132. endx, endy: INTEGER): BOOLEAN;
  133. VAR
  134. fx, fy: INTEGER;
  135. BEGIN
  136. IF CoreGraph._fstart.flag = 0 THEN
  137. RETURN FALSE;
  138. END;
  139. IF((startx = endx) AND (starty = endy)) THEN
  140. RETURN FALSE;
  141. END;
  142. IF CoreGraph._fstart.quad_type = _Q_CLEAR THEN
  143. CASE CoreGraph._fstart.best_quad OF
  144. | 0:
  145. fx:=ox+1;
  146. fy:=oy+1;
  147. | 1:
  148. fx:=ox+1;
  149. fy:=oy-1;
  150. | 2:
  151. fx:=ox-1;
  152. fy:=oy-1;
  153. | 3:
  154. fx:=ox-1;
  155. fy:=oy+1;
  156. END;
  157. ELSIF (CoreGraph._fstart.quad_type = _Q_STEST) THEN
  158. CASE CoreGraph._fstart.best_quad OF
  159. | 0:
  160. fx:=ox+(((startx-ox+1)>>1)+1);
  161. fy:=oy+(((starty-oy)>>1)-1);
  162. | 1:
  163. fx:=ox+(((startx-ox)>>1)-1);
  164. fy:=starty+(((oy-starty)>>1)-1);
  165. | 2:
  166. fx:=startx+(((ox-startx)>>1)-1);
  167. fy:=starty+(((oy-starty+1)>>1)+1);
  168. | 3:
  169. fx:=startx+(((ox-startx+1)>>1)+1);
  170. fy:=oy+(((starty-oy+1)>>1)+1);
  171. END;
  172. ELSE (* _Q_1SEG *)
  173. CASE CoreGraph._fstart.best_quad OF
  174. | 0:
  175. fx:=startx+((endx-startx)>>1)-1;
  176. fy:=endy+((starty-endy)>>1)-1;
  177. | 1:
  178. fx:=endx+((startx-endx)>>1)-1;
  179. fy:=endy+((starty-endy)>>1)+1;
  180. | 2:
  181. fx:=endx+((startx-endx)>>1)+1;
  182. fy:=starty+((endy-starty)>>1)+1;
  183. | 3:
  184. fx:=startx+((endx-startx)>>1)+1;
  185. fy:=starty+((endy-starty)>>1)-1;
  186. END;
  187. END;
  188. x:=fx;
  189. y:=fy;
  190. RETURN TRUE;
  191. END GetFillStart;
  192. PROCEDURE SetFillStart(quadrant: ArcQuadrant);
  193. VAR
  194. q: INTEGER;
  195. BEGIN
  196. q:=0;
  197. CoreGraph._fstart.flag:=1;
  198. WHILE q < 4 DO
  199. CASE quadrant[q] OF
  200. | _Q_CLEAR:
  201. CoreGraph._fstart.best_quad:=q;
  202. CoreGraph._fstart.quad_type:=_Q_CLEAR;
  203. RETURN;
  204. | _Q_1SEG:
  205. CoreGraph._fstart.best_quad:=q;
  206. CoreGraph._fstart.quad_type:=_Q_1SEG;
  207. RETURN;
  208. | _Q_STEST:
  209. CoreGraph._fstart.best_quad:=q;
  210. CoreGraph._fstart.quad_type:=_Q_STEST;
  211. END;
  212. INC(q);
  213. END;
  214. RETURN;
  215. END SetFillStart;
  216. PROCEDURE ArcPlot(quadrant: INTEGER; flag: SHORTCARD; noclip: BOOLEAN; xp, yp, startx, endx, starty, endy: INTEGER);
  217. VAR
  218. ok_to_plot: BOOLEAN;
  219. BEGIN
  220. IF flag = SHORTCARD(_Q_NULL) THEN
  221. RETURN ;
  222. END;
  223. ok_to_plot:=FALSE;
  224. IF((noclip) OR (((xp <= CoreGraph._clip_br.xcoord) AND (xp >= CoreGraph._clip_tl.xcoord))
  225. AND((yp <= CoreGraph._clip_br.ycoord) AND (yp >= CoreGraph._clip_tl.ycoord)))) THEN
  226. IF flag = SHORTCARD(_Q_CLEAR) THEN
  227. ok_to_plot:=TRUE;
  228. ELSE
  229. CASE quadrant OF
  230. | 0:
  231. CASE flag OF
  232. | _Q_1SEG:
  233. IF((xp >= startx) AND (xp <= endx)
  234. AND (yp <= starty) AND (yp >= endy)) THEN
  235. ok_to_plot:=TRUE;
  236. END;
  237. | _Q_2SEG:
  238. IF(((xp >= startx) AND (yp <= starty))
  239. OR ((xp <= endx) AND (yp >= endy))) THEN
  240. ok_to_plot:=TRUE;
  241. END;
  242. | _Q_ETEST:
  243. IF((xp <= endx) AND (yp >= endy)) THEN
  244. ok_to_plot:=TRUE;
  245. END;
  246. ELSE
  247. IF((xp >= startx) AND (yp <= starty)) THEN
  248. ok_to_plot:=TRUE;
  249. END;
  250. END;
  251. | 3:
  252. CASE flag OF
  253. | _Q_1SEG:
  254. IF((xp >= startx) AND (xp <= endx)
  255. AND (yp >= starty) AND (yp <= endy)) THEN
  256. ok_to_plot:=TRUE;
  257. END;
  258. | _Q_2SEG:
  259. IF(((xp >= startx) AND (yp >= starty))
  260. OR ((xp <= endx) AND (yp <= endy))) THEN
  261. ok_to_plot:=TRUE;
  262. END;
  263. | _Q_ETEST:
  264. IF((xp <= endx) AND (yp <= endy)) THEN
  265. ok_to_plot:=TRUE;
  266. END;
  267. ELSE
  268. IF((xp >= startx) AND (yp >= starty)) THEN
  269. ok_to_plot:=TRUE;
  270. END;
  271. END;
  272. | 2:
  273. CASE flag OF
  274. | _Q_1SEG:
  275. IF((xp <= startx) AND (xp >= endx)
  276. AND (yp >= starty) AND (yp <= endy)) THEN
  277. ok_to_plot:=TRUE;
  278. END;
  279. | _Q_2SEG:
  280. IF(((xp <= startx) AND (yp >= starty))
  281. OR ((xp >= endx) AND (yp <= endy))) THEN
  282. ok_to_plot:=TRUE;
  283. END;
  284. | _Q_ETEST:
  285. IF((xp >= endx) AND (yp <= endy)) THEN
  286. ok_to_plot:=TRUE;
  287. END;
  288. ELSE
  289. IF((xp <= startx) AND (yp >= starty)) THEN
  290. ok_to_plot:=TRUE;
  291. END;
  292. END;
  293. ELSE (* quadrant := 1 *)
  294. CASE flag OF
  295. | _Q_1SEG:
  296. IF((xp <= startx) AND (xp >= endx)
  297. AND (yp <= starty) AND (yp >= endy)) THEN
  298. ok_to_plot:=TRUE;
  299. END;
  300. | _Q_2SEG:
  301. IF(((xp <= startx) AND (yp <= starty))
  302. OR ((xp >= endx) AND (yp >= endy))) THEN
  303. ok_to_plot:=TRUE;
  304. END;
  305. | _Q_ETEST:
  306. IF((xp >= endx) AND (yp >= endy)) THEN
  307. ok_to_plot:=TRUE;
  308. END;
  309. ELSE
  310. IF((xp <= startx) AND (yp <= starty)) THEN
  311. ok_to_plot:=TRUE;
  312. END;
  313. END;
  314. END;
  315. END;
  316. IF ok_to_plot THEN
  317. CoreGraph._plot(xp, yp, CoreGraph._fgcolor);
  318. END;
  319. END;
  320. RETURN ;
  321. END ArcPlot;
  322. PROCEDURE GetInRange(VAR a0, b0: INTEGER);
  323. BEGIN
  324. IF a0 > b0 THEN
  325. IF a0 > 1023 THEN
  326. b0 := INTEGER((LONGINT(b0)*1023) DIV LONGINT(a0));
  327. a0 := 1023;
  328. END;
  329. ELSE
  330. IF b0 > 1023 THEN
  331. a0 := INTEGER((LONGINT(a0)*1023) DIV LONGINT(b0));
  332. b0 := 1023;
  333. END;
  334. END;
  335. END GetInRange;
  336. PROCEDURE DrawEllipse(x0, y0, a0, b0: INTEGER; Fill: BOOLEAN);
  337. VAR
  338. x, y, line, oldline: INTEGER;
  339. a, b: LONGINT;
  340. asq, asq2, bsq, bsq2: LONGINT;
  341. d, dx, dy: LONGINT;
  342. plotx, plotx2, ploty: INTEGER;
  343. no_clip: BOOLEAN;
  344. mask: CARDINAL;
  345. BEGIN
  346. GetInRange(a0, b0);
  347. no_clip:=FALSE;
  348. x := 0 ;
  349. y := b0 ;
  350. a := LONGINT(a0);
  351. b := LONGINT(b0);
  352. asq := a*a ;
  353. asq2 := asq*2 ;
  354. bsq := b*b ;
  355. bsq2 := bsq*2 ;
  356. d := bsq-(asq*b)+(asq>>2) ;
  357. dx := 0 ;
  358. dy := asq2*b ;
  359. oldline := -(y0+y+1);
  360. IF ((x0+a0 <= CoreGraph._clip_br.xcoord) AND (x0-a0 >= CoreGraph._clip_tl.xcoord))
  361. AND ((y0+b0 <= CoreGraph._clip_br.ycoord) AND (y0-b0 >= CoreGraph._clip_tl.ycoord)) THEN
  362. no_clip:=TRUE;
  363. END;
  364. WHILE dx < dy DO
  365. plotx:=x0+x;
  366. ploty:=y0+y;
  367. IF no_clip THEN
  368. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  369. ELSE
  370. EllipsePlot(plotx, ploty);
  371. END;
  372. plotx:=x0-x;
  373. ploty:=y0+y;
  374. IF no_clip THEN
  375. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  376. ELSE
  377. EllipsePlot(plotx, ploty);
  378. END;
  379. plotx:=x0+x;
  380. ploty:=y0-y;
  381. IF no_clip THEN
  382. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  383. ELSE
  384. EllipsePlot(plotx, ploty);
  385. END;
  386. plotx:=x0-x;
  387. ploty:=y0-y;
  388. IF no_clip THEN
  389. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  390. ELSE
  391. EllipsePlot(plotx, ploty);
  392. END;
  393. IF Fill = _GFILLINTERIOR THEN
  394. plotx:=x0-x+1;
  395. plotx2:=x0+x-1;
  396. IF plotx2 > plotx THEN
  397. line:=y0+y;
  398. IF line # oldline THEN
  399. oldline := line;
  400. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])
  401. +CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])*100H;
  402. IF mask = MAX(CARDINAL) THEN
  403. CoreGraph._hline(plotx, line, plotx2, CoreGraph._fgcolor);
  404. ELSE
  405. CoreGraph._line(plotx, line, plotx2, line, mask);
  406. END;
  407. line:=y0-y;
  408. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])
  409. +CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])*100H;
  410. IF mask = MAX(CARDINAL) THEN
  411. CoreGraph._hline(plotx, line, plotx2, CoreGraph._fgcolor);
  412. ELSE
  413. CoreGraph._line(plotx, line, plotx2, line, mask);
  414. END;
  415. END;
  416. END;
  417. END;
  418. IF d > 0 THEN
  419. DEC(y);
  420. DEC(dy, asq2);
  421. DEC(d, dy);
  422. END;
  423. INC(x);
  424. INC(dx, bsq2);
  425. INC(d, bsq+dx);
  426. END;
  427. INC(d, (3*((asq-bsq)>>1)-((dx+dy)>>1)));
  428. WHILE y >= 0 DO
  429. plotx:=x0+x;
  430. ploty:=y0+y;
  431. IF no_clip THEN
  432. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  433. ELSE
  434. EllipsePlot(plotx, ploty);
  435. END;
  436. plotx:=x0-x;
  437. ploty:=y0+y;
  438. IF no_clip THEN
  439. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  440. ELSE
  441. EllipsePlot(plotx, ploty);
  442. END;
  443. plotx:=x0+x;
  444. ploty:=y0-y;
  445. IF no_clip THEN
  446. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  447. ELSE
  448. EllipsePlot(plotx, ploty);
  449. END;
  450. plotx:=x0-x;
  451. ploty:=y0-y;
  452. IF no_clip THEN
  453. CoreGraph._plot(plotx, ploty, CoreGraph._fgcolor);
  454. ELSE
  455. EllipsePlot(plotx, ploty);
  456. END;
  457. IF Fill = _GFILLINTERIOR THEN
  458. plotx:=x0-x+1;
  459. plotx2:=x0+x-1;
  460. IF plotx2 > plotx THEN
  461. line:=y0+y;
  462. IF line # oldline THEN
  463. oldline := line;
  464. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])
  465. +CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])*100H;
  466. IF mask = MAX(CARDINAL) THEN
  467. CoreGraph._hline(plotx, line, plotx2, CoreGraph._fgcolor);
  468. ELSE
  469. CoreGraph._line(plotx, line, plotx2, line, mask);
  470. END;
  471. line:=y0-y;
  472. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])
  473. +CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(line) * BITSET(7))])*100H;
  474. IF mask = MAX(CARDINAL) THEN
  475. CoreGraph._hline(plotx, line, plotx2, CoreGraph._fgcolor);
  476. ELSE
  477. CoreGraph._line(plotx, line, plotx2, line, mask);
  478. END;
  479. END;
  480. END;
  481. END;
  482. IF d < 0 THEN
  483. INC(x);
  484. INC(dx, bsq2);
  485. INC(d, dx);
  486. END;
  487. DEC(y);
  488. DEC(dy, asq2);
  489. INC(d, asq-dy);
  490. END;
  491. RETURN;
  492. END DrawEllipse;
  493. PROCEDURE GetArc(VAR quadrant: ArcQuadrant; x, y, sx, sy, ex, ey: INTEGER): BOOLEAN;
  494. BEGIN
  495. IF ((sx = ex) AND (sy = ey)) THEN
  496. RETURN TRUE;
  497. END;
  498. DEC(sx, x);
  499. DEC(ex, x);
  500. DEC(sy, y);
  501. DEC(ey, y);
  502. IF((sx > 0) AND (sy > 0)) THEN (* start in quad 0 *)
  503. quadrant[0]:=SHORTCARD(_Q_STEST);
  504. IF((ey <= 0) AND (ex > 0)) THEN
  505. quadrant[1]:=SHORTCARD(_Q_ETEST);
  506. quadrant[2]:=SHORTCARD(_Q_NULL);
  507. quadrant[3]:=SHORTCARD(_Q_NULL);
  508. ELSIF((ey <= 0) AND (ex <= 0)) THEN
  509. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  510. quadrant[2]:=SHORTCARD(_Q_ETEST);
  511. quadrant[3]:=SHORTCARD(_Q_NULL);
  512. ELSIF((ey > 0) AND (ex <= 0)) THEN
  513. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  514. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  515. quadrant[3]:=SHORTCARD(_Q_ETEST);
  516. ELSIF((ey > 0) AND (ex > 0)) THEN
  517. IF(sx < ex) THEN
  518. quadrant[0]:=SHORTCARD(_Q_1SEG);
  519. quadrant[1]:=SHORTCARD(_Q_NULL);
  520. quadrant[2]:=SHORTCARD(_Q_NULL);
  521. quadrant[3]:=SHORTCARD(_Q_NULL);
  522. ELSE
  523. quadrant[0]:=SHORTCARD(_Q_2SEG);
  524. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  525. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  526. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  527. END;
  528. ELSE
  529. RETURN FALSE;
  530. END;
  531. ELSIF((sx > 0) AND (sy <= 0)) THEN (* start in quad 1 *)
  532. quadrant[1]:=_Q_STEST;
  533. IF((ey <= 0) AND (ex <= 0)) THEN
  534. quadrant[2]:=SHORTCARD(_Q_ETEST);
  535. quadrant[3]:=SHORTCARD(_Q_NULL);
  536. quadrant[0]:=SHORTCARD(_Q_NULL);
  537. ELSIF((ey > 0) AND (ex <= 0)) THEN
  538. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  539. quadrant[3]:=SHORTCARD(_Q_ETEST);
  540. quadrant[0]:=SHORTCARD(_Q_NULL);
  541. ELSIF((ey > 0) AND (ex > 0)) THEN
  542. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  543. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  544. quadrant[0]:=SHORTCARD(_Q_ETEST);
  545. ELSIF((ey <= 0) AND (ex > 0)) THEN
  546. IF(sx >= ex) THEN
  547. quadrant[1]:=SHORTCARD(_Q_1SEG);
  548. quadrant[2]:=SHORTCARD(_Q_NULL);
  549. quadrant[3]:=SHORTCARD(_Q_NULL);
  550. quadrant[0]:=SHORTCARD(_Q_NULL);
  551. ELSE
  552. quadrant[1]:=SHORTCARD(_Q_2SEG);
  553. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  554. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  555. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  556. END;
  557. ELSE
  558. RETURN FALSE;
  559. END;
  560. ELSIF((sx <= 0) AND (sy <= 0)) THEN (* start in quad 2 *)
  561. quadrant[2]:=SHORTCARD(_Q_STEST);
  562. IF((ey > 0) AND (ex <= 0)) THEN
  563. quadrant[3]:=SHORTCARD(_Q_ETEST);
  564. quadrant[0]:=SHORTCARD(_Q_NULL);
  565. quadrant[1]:=SHORTCARD(_Q_NULL);
  566. ELSIF((ey > 0) AND (ex > 0)) THEN
  567. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  568. quadrant[0]:=SHORTCARD(_Q_ETEST);
  569. quadrant[1]:=SHORTCARD(_Q_NULL);
  570. ELSIF((ey <= 0) AND (ex > 0)) THEN
  571. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  572. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  573. quadrant[1]:=SHORTCARD(_Q_ETEST);
  574. ELSIF((ey <= 0) AND (ex <= 0)) THEN
  575. IF(sx >= ex) THEN
  576. quadrant[2]:=SHORTCARD(_Q_1SEG);
  577. quadrant[3]:=SHORTCARD(_Q_NULL);
  578. quadrant[0]:=SHORTCARD(_Q_NULL);
  579. quadrant[1]:=SHORTCARD(_Q_NULL);
  580. ELSE
  581. quadrant[2]:=SHORTCARD(_Q_2SEG);
  582. quadrant[3]:=SHORTCARD(_Q_CLEAR);
  583. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  584. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  585. END;
  586. ELSE
  587. RETURN FALSE;
  588. END;
  589. ELSIF((sx <= 0) AND (sy > 0)) THEN (* start in quad 3 *)
  590. quadrant[3]:=SHORTCARD(_Q_STEST);
  591. IF((ey > 0) AND (ex > 0)) THEN
  592. quadrant[0]:=SHORTCARD(_Q_ETEST);
  593. quadrant[1]:=SHORTCARD(_Q_NULL);
  594. quadrant[2]:=SHORTCARD(_Q_NULL);
  595. ELSIF((ey <= 0) AND (ex > 0)) THEN
  596. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  597. quadrant[1]:=SHORTCARD(_Q_ETEST);
  598. quadrant[2]:=SHORTCARD(_Q_NULL);
  599. ELSIF((ey <= 0) AND (ex <= 0)) THEN
  600. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  601. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  602. quadrant[2]:=SHORTCARD(_Q_ETEST);
  603. ELSIF((ey > 0) AND (ex <= 0)) THEN
  604. IF(sx < ex) THEN
  605. quadrant[3]:=SHORTCARD(_Q_1SEG);
  606. quadrant[0]:=SHORTCARD(_Q_NULL);
  607. quadrant[1]:=SHORTCARD(_Q_NULL);
  608. quadrant[2]:=SHORTCARD(_Q_NULL);
  609. ELSE
  610. quadrant[3]:=SHORTCARD(_Q_2SEG);
  611. quadrant[0]:=SHORTCARD(_Q_CLEAR);
  612. quadrant[1]:=SHORTCARD(_Q_CLEAR);
  613. quadrant[2]:=SHORTCARD(_Q_CLEAR);
  614. END;
  615. ELSE
  616. RETURN FALSE;
  617. END;
  618. ELSE
  619. RETURN FALSE;
  620. END;
  621. RETURN TRUE;
  622. END GetArc;
  623. PROCEDURE DrawArc(x0, y0, a0, b0, startx, starty, endx, endy: INTEGER): BOOLEAN;
  624. VAR
  625. x, y: INTEGER;
  626. xp, yp: INTEGER;
  627. a, b: LONGINT;
  628. asq, asq2, bsq, bsq2: LONGINT;
  629. d, dx, dy: LONGINT;
  630. quadrant: ArcQuadrant;
  631. no_clip: BOOLEAN;
  632. BEGIN
  633. GetInRange(a0, b0);
  634. no_clip:=FALSE;
  635. quadrant:=ArcQuadrant(_Q_CLEAR,_Q_CLEAR,_Q_CLEAR,_Q_CLEAR);
  636. CoreGraph._fstart.flag:=0;
  637. x := 0 ;
  638. y := b0 ;
  639. a := LONGINT(a0);
  640. b := LONGINT(b0);
  641. asq := a*a ;
  642. asq2 := asq*2 ;
  643. bsq := b*b ;
  644. bsq2 := bsq*2 ;
  645. d := bsq-(asq*b)+(asq>>2) ;
  646. dx := 0 ;
  647. dy := asq2*b ;
  648. IF ~GetArc(quadrant, x0, y0, startx, starty, endx, endy) THEN
  649. RETURN FALSE;
  650. END;
  651. SetFillStart(quadrant);
  652. IF(((x0+a0 <= CoreGraph._clip_br.xcoord) AND (x0-a0 >= CoreGraph._clip_tl.xcoord))
  653. AND((y0+b0 <= CoreGraph._clip_br.ycoord) AND (y0-b0 >= CoreGraph._clip_tl.ycoord))) THEN
  654. no_clip:=TRUE;
  655. END;
  656. WHILE dx < dy DO
  657. xp:=x0+x;
  658. yp:=y0+y;
  659. ArcPlot(0, quadrant[0], no_clip, xp, yp, startx, endx, starty, endy);
  660. xp:=x0-x;
  661. yp:=y0+y;
  662. ArcPlot(3, quadrant[3], no_clip, xp, yp, startx, endx, starty, endy);
  663. xp:=x0+x;
  664. yp:=y0-y;
  665. ArcPlot(1, quadrant[1], no_clip, xp, yp, startx, endx, starty, endy);
  666. xp:=x0-x;
  667. yp:=y0-y;
  668. ArcPlot(2, quadrant[2], no_clip, xp, yp, startx, endx, starty, endy);
  669. IF d > 0 THEN
  670. DEC(y);
  671. DEC(dy, asq2);
  672. DEC(d, dy);
  673. END;
  674. INC(x);
  675. INC(dx, bsq2);
  676. INC(d, bsq+dx);
  677. END;
  678. INC(d, (3*((asq-bsq)>>1)-((dx+dy)>>1)));
  679. WHILE y >= 0 DO
  680. xp:=x0+x;
  681. yp:=y0+y;
  682. ArcPlot(0, quadrant[0], no_clip, xp, yp, startx, endx, starty, endy);
  683. xp:=x0-x;
  684. yp:=y0+y;
  685. ArcPlot(3, quadrant[3], no_clip, xp, yp, startx, endx, starty, endy);
  686. xp:=x0+x;
  687. yp:=y0-y;
  688. ArcPlot(1, quadrant[1], no_clip, xp, yp, startx, endx, starty, endy);
  689. xp:=x0-x;
  690. yp:=y0-y;
  691. ArcPlot(2, quadrant[2], no_clip, xp, yp, startx, endx, starty, endy);
  692. IF d<0 THEN
  693. INC(x);
  694. INC(dx, bsq2);
  695. INC(d, dx);
  696. END;
  697. DEC(y);
  698. DEC(dy, asq2);
  699. INC(d, asq-dy);
  700. END;
  701. RETURN TRUE;
  702. END DrawArc;
  703. PROCEDURE GetVec(x0, y0, a0, b0, vx, vy: INTEGER): InterSect;
  704. VAR
  705. x, y: INTEGER;
  706. a, b: LONGINT;
  707. asq, asq2, bsq, bsq2: LONGINT;
  708. d, dx, dy: LONGINT;
  709. px, py, qx, qy: INTEGER;
  710. Ret: InterSect;
  711. flag: INTEGER;
  712. last_difference: LONGCARD;
  713. res: LONGINT;
  714. BEGIN
  715. Ret:=InterSect(0,0);
  716. x := 0 ;
  717. y := b0 ;
  718. a := LONGINT(a0);
  719. b := LONGINT(b0);
  720. qx:=vx-x0;
  721. qy:=vy-y0;
  722. asq := a*a ;
  723. asq2 := asq*2 ;
  724. bsq := b*b ;
  725. bsq2 := bsq*2 ;
  726. d := bsq-(asq*b)+(asq>>2) ;
  727. dx := 0 ;
  728. dy := asq2*b ;
  729. last_difference:=MAX(LONGCARD);
  730. WHILE dx < dy DO
  731. IF((qx >= 0) AND (qy >= 0)) THEN
  732. px:=x0+x;
  733. py:=y0+y;
  734. flag:=0;
  735. ELSIF((qx < 0) AND (qy >= 0)) THEN
  736. px:=x0-x;
  737. py:=y0+y;
  738. flag:=1;
  739. ELSIF((qx >= 0) AND (qy < 0)) THEN
  740. px:=x0+x;
  741. py:=y0-y;
  742. flag:=2;
  743. ELSIF((qx < 0) AND (qy < 0)) THEN
  744. px:=x0-x;
  745. py:=y0-y;
  746. flag:=3;
  747. END;
  748. res:=(LONGINT(px-x0)*LONGINT(qy)) - (LONGINT(py-y0)*LONGINT(qx));
  749. IF res < 0 THEN
  750. res:=-res;
  751. END;
  752. IF LONGCARD(res) > last_difference THEN
  753. RETURN Ret;
  754. END;
  755. last_difference:=res;
  756. Ret.x:=px;
  757. Ret.y:=py;
  758. IF d > 0 THEN
  759. DEC(y);
  760. DEC(dy, asq2);
  761. DEC(d, dy);
  762. END;
  763. INC(x);
  764. INC(dx, bsq2);
  765. INC(d, bsq+dx);
  766. END;
  767. INC(d, (3*((asq-bsq)>>1)-((dx+dy)>>1)));
  768. last_difference:=MAX(LONGCARD);
  769. WHILE y >0 DO
  770. IF flag = 0 THEN
  771. px:=x0+x;
  772. py:=y0+y;
  773. ELSIF flag = 1 THEN
  774. px:=x0-x;
  775. py:=y0+y;
  776. ELSIF flag = 2 THEN
  777. px:=x0+x;
  778. py:=y0-y;
  779. ELSIF flag = 3 THEN
  780. px:=x0-x;
  781. py:=y0-y;
  782. END;
  783. res:=LONGINT(px-x0)*LONGINT(qy) - LONGINT(py-y0)*LONGINT(qx);
  784. IF res < 0 THEN
  785. res:=-res;
  786. END;
  787. IF LONGCARD(res) > last_difference THEN
  788. RETURN Ret;
  789. END;
  790. last_difference:=res;
  791. Ret.x:=px;
  792. Ret.y:=py;
  793. IF d < 0 THEN
  794. INC(x);
  795. INC(dx, bsq2);
  796. INC(d, dx);
  797. END;
  798. DEC(y);
  799. DEC(dy, asq2);
  800. INC(d, asq-dy);
  801. END;
  802. RETURN Ret;
  803. END GetVec;
  804. PROCEDURE HscanLine(VAR xlp, xrp: INTEGER; y, border: INTEGER);
  805. VAR
  806. mask: CARDINAL;
  807. BEGIN
  808. CoreGraph._hscan(xlp, xrp, y, border);
  809. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(y)*BITSET(7))])
  810. +CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(y)*BITSET(7))])*100H;
  811. IF mask = MAX(CARDINAL) THEN
  812. CoreGraph._hline(xlp, y, xrp, CoreGraph._fgcolor);
  813. ELSE
  814. CoreGraph._line(xlp, y, xrp, y, mask);
  815. END;
  816. END HscanLine;
  817. PROCEDURE LagFill(xl, xr, y, direction, llim, rlim, border: INTEGER);
  818. LABEL
  819. ReStart;
  820. VAR
  821. x, xsl, v: INTEGER;
  822. mask: CARDINAL;
  823. BEGIN
  824. ReStart:
  825. DEC(y, direction);
  826. IF (CoreGraph._clip_tl.ycoord <= y) AND (y <= CoreGraph._clip_br.ycoord) THEN
  827. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(y)*BITSET(7))]);
  828. x:=xl;
  829. WHILE x <= llim-1 DO
  830. IF (BITSET(1<<(CARDINAL(BITSET(x)*BITSET(7)))) * BITSET(mask) # {}) THEN
  831. v:=CoreGraph._point(x, y);
  832. IF((v # border) AND (v # CoreGraph._fgcolor)) THEN
  833. xsl := x;
  834. HscanLine (xsl, x, y, border);
  835. LagFill(xsl, x, y, -direction, xl, xr, border);
  836. END;
  837. END;
  838. INC(x);
  839. END;
  840. x:=rlim+1;
  841. WHILE x <= xr DO
  842. IF (BITSET(1<<(CARDINAL(BITSET(x)*BITSET(7)))) * BITSET(mask) # {}) THEN
  843. v:=CoreGraph._point(x, y);
  844. IF((v # border) AND (v # CoreGraph._fgcolor)) THEN
  845. xsl := x;
  846. HscanLine(xsl, x, y, border);
  847. LagFill(xsl, x, y, -direction, xl, xr, border);
  848. END;
  849. END;
  850. INC(x);
  851. END;
  852. END;
  853. INC(y, direction + direction);
  854. IF ( y >= CoreGraph._clip_tl.ycoord) AND (y <= CoreGraph._clip_br.ycoord ) THEN
  855. mask:=CARDINAL(CoreGraph._fill_mask[CARDINAL(BITSET(y)*BITSET(7))]);
  856. x:=xl;
  857. WHILE x <= xr DO
  858. IF (BITSET(1<<(CARDINAL(BITSET(x)*BITSET(7)))) * BITSET(mask) # {}) THEN
  859. v:=CoreGraph._point(x, y);
  860. IF((v # CoreGraph._fgcolor) AND (v # border)) THEN
  861. xsl := x;
  862. HscanLine (xsl, x, y, border);
  863. IF(x > xr-1) THEN
  864. (* Do last one iteratively... *)
  865. llim := xl;
  866. rlim := xr;
  867. xl := xsl;
  868. xr := x;
  869. GOTO ReStart;
  870. ELSE
  871. LagFill(xsl, x, y, direction, xl, xr, border);
  872. END;
  873. END;
  874. END;
  875. INC(x);
  876. END;
  877. END;
  878. RETURN;
  879. END LagFill;
  880. (*# restore *)
  881. (*****************************************************************************)
  882. (* Function definitions - CGA specIFic *)
  883. (*****************************************************************************)
  884. (*# save *)
  885. (*# call(reg_param => (ax,bx,cx,dx,st0,st6,st5,st4,st3), reg_saved=>(ds, di, si,st1,st2), c_conv=>off) *)
  886. PROCEDURE _CGA320Plot(x, y, c: INTEGER);
  887. VAR
  888. ptr: CGAPointer;
  889. ofs: CARDINAL;
  890. BEGIN
  891. ofs:=(CARDINAL(x)>>2)+((2000H-40)* CARDINAL( BITSET(y)*BITSET(1) ) )+ (40*CARDINAL(y));
  892. ptr := [SEL_B800H:ofs];
  893. x := 3 - INTEGER(BITSET(x)*BITSET(3));
  894. x := x << 1;
  895. ptr^ := SHORTCARD((BITSET(ptr^) - BITSET(3<<x)) + BITSET(c<<x));
  896. RETURN;
  897. END _CGA320Plot;
  898. PROCEDURE _CGA640Plot(x, y, c: INTEGER);
  899. VAR
  900. ptr: CGAPointer;
  901. ofs: CARDINAL;
  902. mask: CARDINAL;
  903. BEGIN
  904. ofs:=(CARDINAL(x)>>3)+((2000H-40)* CARDINAL( BITSET(y)*BITSET(1) ) )+ (40*CARDINAL(y));
  905. ptr := [SEL_B800H:ofs];
  906. x:= INTEGER(BITSET(x) * BITSET(7));
  907. mask:=80H>>x;
  908. IF(c # 0) THEN
  909. c:=mask;
  910. END;
  911. ptr^ := SHORTCARD((BITSET(ptr^) - BITSET(mask)) + BITSET(c));
  912. RETURN;
  913. END _CGA640Plot;
  914. PROCEDURE _CGA320Point(x, y: INTEGER): INTEGER;
  915. VAR
  916. ptr: CGAPointer;
  917. ofs: CARDINAL;
  918. BEGIN
  919. ofs:=(CARDINAL(x)>>2)+((2000H-40)* CARDINAL( BITSET(y)*BITSET(1) ) )+ (40*CARDINAL(y));
  920. ptr := [SEL_B800H:ofs];
  921. x := 3 - INTEGER(BITSET(x)*BITSET(3));
  922. x := (x<<1);
  923. RETURN( CARDINAL(BITSET(ptr^) * BITSET(3<<x)) >> CARDINAL(x));
  924. END _CGA320Point;
  925. PROCEDURE _CGA640Point(x, y: INTEGER): INTEGER;
  926. VAR
  927. c: SHORTCARD;
  928. ptr: CGAPointer;
  929. ofs: CARDINAL;
  930. BEGIN
  931. ofs:=(CARDINAL(x)>>3)+((2000H-40)* CARDINAL( BITSET(y)*BITSET(1) ) )+ (40*CARDINAL(y));
  932. ptr := [SEL_B800H:ofs];
  933. x:=INTEGER(BITSET(x) * BITSET(7));
  934. c:=SHORTCARD(80H>>x);
  935. IF(BITSET(ptr^)* BITSET(c) # {}) THEN
  936. RETURN 1;
  937. END;
  938. RETURN 0;
  939. END _CGA640Point;
  940. PROCEDURE _CGA320HScan(VAR xl, xr: INTEGER; y, border: INTEGER);
  941. VAR
  942. row, left, right: INTEGER;
  943. BEGIN
  944. left:=xl;
  945. right:=xr;
  946. row:=((2000H-40)*INTEGER(BITSET(y) * BITSET(1)))+(40*y);
  947. xl:=CoreGraph._CGA320leftscan((left>>2)+row, border, CoreGraph._clip_tl.xcoord, left);
  948. xr:=CoreGraph._CGA320rightscan((right>>2)+row, border, CoreGraph._clip_br.xcoord, right);
  949. END _CGA320HScan;
  950. PROCEDURE _CGA640HScan(VAR xl, xr: INTEGER; y, border: INTEGER);
  951. VAR
  952. row, left, right: INTEGER;
  953. BEGIN
  954. left:=xl;
  955. right:=xr;
  956. IF border # 0 THEN
  957. border:=1;
  958. END;
  959. row:=((2000H-40)*INTEGER(BITSET(y)*BITSET(1)))+(40*y);
  960. xl:=CoreGraph._CGA640leftscan((left>>3)+row, border, CoreGraph._clip_tl.xcoord, left);
  961. xr:=CoreGraph._CGA640rightscan((right>>3)+row, border, CoreGraph._clip_br.xcoord, right);
  962. END _CGA640HScan;
  963. (*****************************************************************************)
  964. (* Function definitions - VGA 256 color specIFic. *)
  965. (*****************************************************************************)
  966. PROCEDURE _VGAPlot(x, y, c: INTEGER);
  967. VAR
  968. ptr: VGAPointer;
  969. BEGIN
  970. ptr := [SEL_A000H:y*(VGA256Width)+x];
  971. ptr^:= SHORTCARD(c);
  972. END _VGAPlot;
  973. PROCEDURE _VGAHScan(VAR xl, xr: INTEGER; y, border: INTEGER);
  974. VAR
  975. left, right: INTEGER;
  976. ptr: CARDINAL;
  977. BEGIN
  978. left:=xl;
  979. right:=xr;
  980. y:=y*(VGA256Width);
  981. ptr:=y+left;
  982. xl:=CoreGraph._VGAleftscan(ptr, border, CoreGraph._clip_tl.xcoord, left);
  983. ptr:=y+right;
  984. xr:=CoreGraph._VGArightscan(ptr, border, CoreGraph._clip_br.xcoord, right);
  985. RETURN;
  986. END _VGAHScan;
  987. (*****************************************************************************)
  988. (* Function definitions - VGA and EGA native mode specIFic. *)
  989. (*****************************************************************************)
  990. PROCEDURE EGAHScan(VAR xl, xr: INTEGER; y, border: INTEGER);
  991. VAR
  992. left,right : INTEGER;
  993. p,pp : CARDINAL;
  994. ptr : FarADDRESS;
  995. BEGIN
  996. IF CoreGraph._EGAtranslate # 0 THEN
  997. border:=CoreGraph._EGAxlat(border);
  998. END; (*IF*)
  999. left := xl;
  1000. right := xr;
  1001. pp := (CARDINAL(y) * CoreGraph._width) + (CoreGraph._active_page*CoreGraph._page_size) << 4;
  1002. p := CARDINAL(left>>3) + pp;
  1003. ptr := [SEL_A000H:p];
  1004. xl := CoreGraph._EGAleftscan(ptr, border, CoreGraph._clip_tl.xcoord, left);
  1005. p := CARDINAL(right>>3) + pp;
  1006. ptr := [SEL_A000H:p];
  1007. xr := CoreGraph._EGArightscan(ptr, border, CoreGraph._clip_br.xcoord, right);
  1008. END EGAHScan;
  1009. PROCEDURE GenericHScan(VAR xl, xr: INTEGER; y, border: INTEGER);
  1010. VAR
  1011. v, left, right: INTEGER;
  1012. BEGIN
  1013. left:=xl;
  1014. right:=xr;
  1015. REPEAT
  1016. DEC(left);
  1017. v:=CoreGraph._point(left, y);
  1018. UNTIL (v = border) OR (v = CoreGraph._fgcolor) OR (left < CoreGraph._clip_tl.xcoord);
  1019. INC(left);
  1020. REPEAT
  1021. INC(right);
  1022. v:=CoreGraph._point(right, y);
  1023. UNTIL (v = border) OR (v = CoreGraph._fgcolor) OR (right > CoreGraph._clip_br.xcoord);
  1024. DEC(right);
  1025. xl:=left;
  1026. xr:=right;
  1027. END GenericHScan;
  1028. (*****************************************************************************)
  1029. (* Function definitions - Hercules specIFic. *)
  1030. (*****************************************************************************)
  1031. PROCEDURE HercPlot(x,y,c: INTEGER);
  1032. VAR
  1033. Byte: bs;
  1034. BEGIN
  1035. IF (x > HercWidth) OR (y > HercDepth) THEN
  1036. RETURN;
  1037. END;
  1038. Byte:=HercBitMap[CoreGraph._active_page][y MOD 4]^[y >> 2][x >> 3];
  1039. IF c = 0 THEN
  1040. Byte:=Byte - bs{(7-(CARDINAL(x) MOD 8))};
  1041. ELSE
  1042. Byte:=Byte + bs{(7-(CARDINAL(x) MOD 8))};
  1043. END;
  1044. HercBitMap[CoreGraph._active_page][y MOD 4]^[y >> 2][x >> 3]:=Byte;
  1045. END HercPlot;
  1046. PROCEDURE HercPoint(x,y: INTEGER) : INTEGER;
  1047. BEGIN
  1048. IF (x > HercWidth) OR (y > HercDepth) THEN RETURN MAX(CARDINAL); END;
  1049. IF bs{7-(CARDINAL(x) MOD 8)} * HercBitMap[CoreGraph._active_page][y MOD 4]^[y >> 2][x >> 3] # bs(0) THEN
  1050. RETURN 1;
  1051. ELSE
  1052. RETURN 0;
  1053. END;
  1054. END HercPoint;
  1055. (*# restore *)
  1056. PROCEDURE HercGraphMode;
  1057. TYPE
  1058. DataType = ARRAY[0..11] OF SHORTCARD ;
  1059. CONST
  1060. Data = DataType(35H,2DH,2EH,07H,5BH,02H,57H,57H,02H,03H,00H,00H);
  1061. VAR
  1062. I: CARDINAL;
  1063. BEGIN
  1064. SYSTEM.Out(3BFH,03H); (* Remove this if do NOT want to override
  1065. the hercules text mode lock *)
  1066. Lib.Delay(10);
  1067. SYSTEM.Out(3B8H,02H);
  1068. FOR I:= 0 TO 11 DO
  1069. SYSTEM.Out(3B4H,SHORTCARD(I));
  1070. SYSTEM.Out(3B5H,Data[I])
  1071. END;
  1072. Lib.FarWordFill([SEL_B000H:0],4000H,0);
  1073. Lib.Delay(500);
  1074. SYSTEM.Out(3B8H,0AH)
  1075. END HercGraphMode;
  1076. PROCEDURE HercTextMode;
  1077. TYPE
  1078. DataType = ARRAY[0..11] OF SHORTCARD ;
  1079. CONST
  1080. Data = DataType(61H,50H,52H,0FH,19H,06H,19H,19H,02H,0DH,0BH,0CH);
  1081. VAR
  1082. I: CARDINAL;
  1083. BEGIN
  1084. SYSTEM.Out(3B8H,20H);
  1085. FOR I:= 0 TO 11 DO
  1086. SYSTEM.Out(3B4H,SHORTCARD(I));
  1087. SYSTEM.Out(3B5H,Data[I])
  1088. END;
  1089. Lib.FarWordFill([SEL_B000H:0],2000,720H);
  1090. Lib.Delay(500);
  1091. SYSTEM.Out(3B8H,28H)
  1092. END HercTextMode;
  1093. PROCEDURE InternalInitCGA(mode: CARDINAL);
  1094. BEGIN
  1095. IF((mode = 4) OR (mode = 5)) THEN
  1096. CoreGraph._plot := _CGA320Plot;
  1097. CoreGraph._point := _CGA320Point;
  1098. CoreGraph._hline := CoreGraph._CGA320HLine;
  1099. CoreGraph._line := CoreGraph._CGA320Line;
  1100. CoreGraph._hscan := _CGA320HScan;
  1101. CoreGraph._put := CoreGraph._CGA320Put;
  1102. CoreGraph._get := CoreGraph._CGA320Get;
  1103. CoreGraph._width := CGA320Width-1;
  1104. ELSE
  1105. CoreGraph._plot := _CGA640Plot ;
  1106. CoreGraph._point := _CGA640Point ;
  1107. CoreGraph._line := CoreGraph._CGA640Line ;
  1108. CoreGraph._hline := CoreGraph._CGA640HLine ;
  1109. CoreGraph._hscan := _CGA640HScan;
  1110. CoreGraph._put := CoreGraph._CGA640Put;
  1111. CoreGraph._get := CoreGraph._CGA640Get;
  1112. CoreGraph._width := CGA640Width-1;
  1113. END;
  1114. CoreGraph._depth:=CGADepth-1;
  1115. END InternalInitCGA;
  1116. PROCEDURE InternalInitEGA(mode: CARDINAL);
  1117. BEGIN
  1118. IF mode = 13 THEN
  1119. CoreGraph._width := 40;
  1120. CoreGraph._depth := EGA200Depth-1;
  1121. ELSIF mode = 14 THEN
  1122. CoreGraph._width := 80;
  1123. CoreGraph._depth := EGA200Depth-1;
  1124. ELSIF mode <= 16 THEN
  1125. CoreGraph._width := 80;
  1126. CoreGraph._depth := EGA350Depth-1;
  1127. ELSIF mode <= 18 THEN
  1128. CoreGraph._width := 80;
  1129. CoreGraph._depth := EGA480Depth-1;
  1130. END;
  1131. CoreGraph._EGAtranslate:=0;
  1132. IF mode = 15 THEN
  1133. CoreGraph._EGAStartPlane:=2;
  1134. CoreGraph._EGAPlaneShift:=2;
  1135. CoreGraph._EGAtranslate:=1;
  1136. ELSIF mode = 17 THEN
  1137. CoreGraph._EGAStartPlane:=0;
  1138. CoreGraph._EGAPlaneShift:=1;
  1139. ELSE
  1140. CoreGraph._EGAStartPlane:=3;
  1141. CoreGraph._EGAPlaneShift:=1;
  1142. END;
  1143. IF((CoreGraph._EGA64K = TRUE) AND ((mode = _ERESCOLOR) OR (mode = _ERESNOCOLOR))) THEN
  1144. CoreGraph._EGAStartPlane:=2;
  1145. CoreGraph._EGAPlaneShift:=2;
  1146. CoreGraph._EGAtranslate:=1;
  1147. CoreGraph._hscan:= GenericHScan;
  1148. ELSE
  1149. CoreGraph._hscan:= EGAHScan;
  1150. END;
  1151. CoreGraph._put := CoreGraph._EGAPut;
  1152. CoreGraph._get := CoreGraph._EGAGet;
  1153. IF mode = _VRES2COLOR THEN
  1154. CoreGraph._line := CoreGraph._EGA2Line;
  1155. CoreGraph._plot := CoreGraph._EGA2Plot;
  1156. CoreGraph._point := CoreGraph._EGA2Point;
  1157. CoreGraph._hline := CoreGraph._EGA2HLine;
  1158. ELSE
  1159. CoreGraph._line := CoreGraph._EGALine;
  1160. CoreGraph._plot := CoreGraph._EGAPlot;
  1161. CoreGraph._point := CoreGraph._EGAPoint;
  1162. CoreGraph._hline := CoreGraph._EGAHLine;
  1163. END;
  1164. (* _resetEGA();*)
  1165. END InternalInitEGA;
  1166. PROCEDURE InternalInitVGA256();
  1167. BEGIN
  1168. CoreGraph._width := VGA256Width;
  1169. CoreGraph._depth := VGA256Depth-1;
  1170. CoreGraph._plot := _VGAPlot;
  1171. CoreGraph._point := CoreGraph._VGAPoint;
  1172. CoreGraph._line := CoreGraph._VGALine;
  1173. CoreGraph._hline := CoreGraph._VGAHLine;
  1174. CoreGraph._hscan := _VGAHScan;
  1175. CoreGraph._put := CoreGraph._VGAPut;
  1176. CoreGraph._get := CoreGraph._VGAGet;
  1177. END InternalInitVGA256;
  1178. PROCEDURE InternalInitHerc();
  1179. BEGIN
  1180. CoreGraph._depth := HercDepth-1;
  1181. CoreGraph._width := HercWidth-1;
  1182. CoreGraph._plot := HercPlot ;
  1183. CoreGraph._point := HercPoint ;
  1184. CoreGraph._line := CoreGraph._HercLine ;
  1185. CoreGraph._hline := CoreGraph._HercHLine ;
  1186. CoreGraph._hscan := GenericHScan ;
  1187. CoreGraph._put := CoreGraph._HercPut;
  1188. CoreGraph._get := CoreGraph._HercGet;
  1189. HercBitMap[0][0]:= [SEL_B000H:0]; (* Initialise BitMap pointers *)
  1190. HercBitMap[0][1]:= [SEL_B000H:02000H];
  1191. HercBitMap[0][2]:= [SEL_B000H:04000H];
  1192. HercBitMap[0][3]:= [SEL_B000H:06000H];
  1193. HercBitMap[1][0]:= [SEL_B800H:0]; (* 2nd Page *)
  1194. HercBitMap[1][1]:= [SEL_B800H:02000H];
  1195. HercBitMap[1][2]:= [SEL_B800H:04000H];
  1196. HercBitMap[1][3]:= [SEL_B800H:06000H];
  1197. END InternalInitHerc;
  1198. (*****************************************************************************)
  1199. (* Function definitions - Misc low level and initialisation. *)
  1200. (*****************************************************************************)
  1201. CONST
  1202. MDA = 1;
  1203. CGA = 2;
  1204. EGA = 3;
  1205. MCGA = 4;
  1206. VGA = 5;
  1207. HGC = 80H;
  1208. HGCPlus= 81H;
  1209. InColor= 82H;
  1210. MDADisplay = 1;
  1211. CGADisplay = 2;
  1212. EGAColorDisplay = 3;
  1213. PS2MonoDisplay = 4;
  1214. PS2ColorDisplay = 5;
  1215. (*# save *)
  1216. (*# call(near_call=>on) *)
  1217. PROCEDURE SetLimits(VAR v: CoreGraph.VideoConfig);
  1218. BEGIN
  1219. CASE v.mode OF
  1220. | 0:
  1221. v.numxpixels := 0;
  1222. v.numypixels := 0;
  1223. v.numtextcols := 40;
  1224. v.numtextrows := 25;
  1225. v.numcolors := 32;
  1226. v.bitsperpixel := 0;
  1227. v.numvideopages := 8;
  1228. CoreGraph._txcolor := 15;
  1229. CoreGraph._scr_attr := 7;
  1230. | 1:
  1231. v.numxpixels := 0;
  1232. v.numypixels := 0;
  1233. v.numtextcols := 40;
  1234. v.numtextrows := 25;
  1235. v.numcolors := 32;
  1236. v.bitsperpixel := 0;
  1237. v.numvideopages := 8;
  1238. CoreGraph._txcolor := 15;
  1239. CoreGraph._scr_attr := 7;
  1240. | 2:
  1241. v.numxpixels := 0;
  1242. v.numypixels := 0;
  1243. v.numtextcols := 80;
  1244. v.numtextrows := 25;
  1245. v.numcolors := 32;
  1246. v.bitsperpixel := 0;
  1247. v.numvideopages := 4;
  1248. CoreGraph._txcolor := 15;
  1249. CoreGraph._scr_attr := 7;
  1250. | 3:
  1251. v.numxpixels := 0;
  1252. v.numypixels := 0;
  1253. v.numtextcols := 80;
  1254. v.numtextrows := 25;
  1255. v.numcolors := 32;
  1256. v.bitsperpixel := 0;
  1257. v.numvideopages := 4;
  1258. CoreGraph._txcolor := 15;
  1259. CoreGraph._scr_attr := 7;
  1260. | 4:
  1261. v.numxpixels := 320;
  1262. v.numypixels := 200;
  1263. v.numtextcols := 40;
  1264. v.numtextrows := 25;
  1265. v.numcolors := 4;
  1266. v.bitsperpixel := 2;
  1267. v.numvideopages := 1;
  1268. CoreGraph._fgcolor := 3;
  1269. CoreGraph._scr_attr := 0;
  1270. | 5:
  1271. v.numxpixels := 320;
  1272. v.numypixels := 200;
  1273. v.numtextcols := 40;
  1274. v.numtextrows := 25;
  1275. v.numcolors := 4;
  1276. v.bitsperpixel := 2;
  1277. v.numvideopages := 1;
  1278. CoreGraph._page_size:= 0;
  1279. CoreGraph._scr_attr := 0;
  1280. CoreGraph._fgcolor := 3;
  1281. | 6:
  1282. v.numxpixels := 640;
  1283. v.numypixels := 200;
  1284. v.numtextcols := 80;
  1285. v.numtextrows := 25;
  1286. v.numcolors := 2;
  1287. v.bitsperpixel := 1;
  1288. v.numvideopages := 1;
  1289. CoreGraph._page_size:= 0;
  1290. CoreGraph._scr_attr := 0;
  1291. CoreGraph._fgcolor := 1;
  1292. | 7:
  1293. v.numxpixels := 0;
  1294. v.numypixels := 0;
  1295. v.numtextcols := 80;
  1296. v.numtextrows := 25;
  1297. v.numcolors := 2;
  1298. v.bitsperpixel := 0;
  1299. v.numvideopages := 4;
  1300. CoreGraph._txcolor := 1;
  1301. CoreGraph._scr_attr := 7;
  1302. | 8:
  1303. v.numxpixels := 720;
  1304. v.numypixels := 348;
  1305. v.numtextcols := 80;
  1306. v.numtextrows := 25;
  1307. v.numcolors := 2;
  1308. v.bitsperpixel := 1;
  1309. v.numvideopages := 2;
  1310. CoreGraph._page_size:= 800H;
  1311. CoreGraph._fgcolor := 1;
  1312. CoreGraph._scr_attr := 0;
  1313. | 13:
  1314. v.numxpixels := 320;
  1315. v.numypixels := 200;
  1316. v.numtextcols := 40;
  1317. v.numtextrows := 25;
  1318. v.numcolors := 16;
  1319. v.bitsperpixel := 4;
  1320. v.numvideopages := CoreGraph._current_video.memory DIV 32;
  1321. CoreGraph._page_size:= 200H;
  1322. CoreGraph._fgcolor := 15;
  1323. CoreGraph._scr_attr := 0;
  1324. | 14:
  1325. v.numxpixels := 640;
  1326. v.numypixels := 200;
  1327. v.numtextcols := 80;
  1328. v.numtextrows := 25;
  1329. v.numcolors := 16;
  1330. v.bitsperpixel := 4;
  1331. v.numvideopages := CoreGraph._current_video.memory DIV 64;
  1332. CoreGraph._page_size:= 400H;
  1333. CoreGraph._fgcolor := 15;
  1334. CoreGraph._scr_attr := 0;
  1335. | 15:
  1336. v.numxpixels := 640;
  1337. v.numypixels := 350;
  1338. v.numtextcols := 80;
  1339. v.numtextrows := 25;
  1340. v.numcolors := 4;
  1341. v.bitsperpixel := 2;
  1342. v.numvideopages := 2;
  1343. CoreGraph._page_size:= 800H;
  1344. CoreGraph._fgcolor := 3;
  1345. CoreGraph._scr_attr := 0;
  1346. | 16:
  1347. v.numxpixels := 640;
  1348. v.numypixels := 350;
  1349. v.numtextcols := 80;
  1350. v.numtextrows := 25;
  1351. v.numcolors := 16;
  1352. v.bitsperpixel := 4;
  1353. v.numvideopages := 2;
  1354. CoreGraph._page_size:= 800H;
  1355. CoreGraph._fgcolor := 15;
  1356. CoreGraph._scr_attr := 0;
  1357. | 17:
  1358. v.numxpixels := 640;
  1359. v.numypixels := 480;
  1360. v.numtextcols := 80;
  1361. v.numtextrows := 30;
  1362. v.numcolors := 2;
  1363. v.bitsperpixel := 1;
  1364. v.numvideopages := 1;
  1365. CoreGraph._page_size:= 0;
  1366. CoreGraph._fgcolor := 1;
  1367. CoreGraph._scr_attr := 0;
  1368. | 18:
  1369. v.numxpixels := 640;
  1370. v.numypixels := 480;
  1371. v.numtextcols := 80;
  1372. v.numtextrows := 30;
  1373. v.numcolors := 16;
  1374. v.bitsperpixel := 4;
  1375. v.numvideopages := 1;
  1376. CoreGraph._fgcolor := 15;
  1377. CoreGraph._page_size:= 0;
  1378. CoreGraph._scr_attr := 0;
  1379. | 19:
  1380. v.numxpixels := 320;
  1381. v.numypixels := 200;
  1382. v.numtextcols := 40;
  1383. v.numtextrows := 25;
  1384. v.numcolors := 256;
  1385. v.bitsperpixel := 8;
  1386. v.numvideopages := 1;
  1387. CoreGraph._fgcolor := 255;
  1388. CoreGraph._page_size:= 0;
  1389. CoreGraph._scr_attr := 0;
  1390. END;
  1391. CoreGraph._clip_tl.xcoord :=0;
  1392. CoreGraph._clip_tl.ycoord :=0;
  1393. CoreGraph._clip_br.xcoord :=v.numxpixels-1;
  1394. CoreGraph._clip_br.ycoord :=v.numypixels-1;
  1395. CoreGraph._text_tl.row :=0;
  1396. CoreGraph._text_tl.col :=0;
  1397. CoreGraph._text_br.row :=v.numtextrows-1;
  1398. CoreGraph._text_br.col :=v.numtextcols-1;
  1399. END SetLimits;
  1400. PROCEDURE GEnter();
  1401. BEGIN
  1402. IF CoreGraph._cursor_state = _GCURSORON THEN
  1403. CoreGraph._gcur(0, CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._visual_page);
  1404. INC(CoreGraph._cursor_lock);
  1405. END;
  1406. END GEnter;
  1407. PROCEDURE GExit();
  1408. BEGIN
  1409. IF(CoreGraph._cursor_state = _GCURSORON) THEN
  1410. DEC(CoreGraph._cursor_lock);
  1411. IF (CoreGraph._cursor_lock = 0) THEN
  1412. CoreGraph._gcur(CoreGraph._txcolor, CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._visual_page);
  1413. END;
  1414. END;
  1415. END GExit;
  1416. PROCEDURE EGAcolXlat(Color: LONGCARD): INTEGER;
  1417. TYPE
  1418. LongSet = SET OF [0..31];
  1419. VAR
  1420. ncol, blue, green, red: CARDINAL;
  1421. BEGIN
  1422. blue:= CARDINAL(LONGCARD(LongSet(Color)*LongSet(0FF0000H))>>16);
  1423. green:= CARDINAL(LONGCARD(LongSet(Color)*LongSet(0FF00H))>>8);
  1424. red:= CARDINAL(LongSet(Color)*LongSet(0FFH));
  1425. IF red = 0 THEN
  1426. ncol:=0;
  1427. ELSIF red <= 015H THEN
  1428. ncol:=32;
  1429. ELSIF red <= 02AH THEN
  1430. ncol:=4;
  1431. ELSE
  1432. ncol:=36;
  1433. END;
  1434. IF green # 0 THEN
  1435. IF green <= 015H THEN
  1436. INC(ncol, 16);
  1437. ELSIF green <= 02AH THEN
  1438. INC(ncol, 2);
  1439. ELSE
  1440. INC(ncol, 18);
  1441. END;
  1442. END;
  1443. IF blue # 0 THEN
  1444. IF blue <= 015H THEN
  1445. INC(ncol, 8);
  1446. ELSIF blue <= 02AH THEN
  1447. INC(ncol, 1);
  1448. ELSE
  1449. INC(ncol, 9);
  1450. END;
  1451. END;
  1452. RETURN ncol;
  1453. END EGAcolXlat;
  1454. PROCEDURE ColXlat(Color: LONGCARD): INTEGER;
  1455. VAR
  1456. n: INTEGER;
  1457. BEGIN
  1458. n:=0;
  1459. LOOP
  1460. IF n = 16 THEN EXIT END;
  1461. IF ColTable[n] = Color THEN EXIT END;
  1462. INC(n);
  1463. END;
  1464. RETURN n;
  1465. END ColXlat;
  1466. PROCEDURE Scroll();
  1467. VAR
  1468. r: SYSTEM.Registers;
  1469. BEGIN
  1470. r.AX:=0601H;
  1471. r.BH:=SHORTCARD(CoreGraph._scr_attr);
  1472. r.CH:=SHORTCARD(CoreGraph._text_tl.row);
  1473. r.CL:=SHORTCARD(CoreGraph._text_tl.col);
  1474. r.DH:=SHORTCARD(CoreGraph._text_br.row);
  1475. r.DL:=SHORTCARD(CoreGraph._text_br.col);
  1476. Lib.Intr(r, 10H);
  1477. END Scroll;
  1478. (*# restore *)
  1479. (*****************************************************************************)
  1480. (* Public Function definitions. *)
  1481. (*****************************************************************************)
  1482. PROCEDURE GetVideoConfig(VAR V: VideoConfig);
  1483. BEGIN
  1484. IF CoreGraph._defaultmode = 0 THEN RETURN END;
  1485. Lib.FastMove(ADR(CoreGraph._current_video), ADR(V), SIZE(VideoConfig));
  1486. END GetVideoConfig;
  1487. PROCEDURE SetClipRgn(x1, y1, x2, y2: CARDINAL);
  1488. PROCEDURE Max(A, B: CARDINAL): CARDINAL;
  1489. BEGIN
  1490. IF A > B THEN
  1491. RETURN A;
  1492. ELSE
  1493. RETURN B;
  1494. END;
  1495. END Max;
  1496. PROCEDURE Min(A, B: CARDINAL): CARDINAL;
  1497. BEGIN
  1498. IF A < B THEN
  1499. RETURN A;
  1500. ELSE
  1501. RETURN B;
  1502. END;
  1503. END Min;
  1504. BEGIN
  1505. CoreGraph._clip_tl.xcoord:=Max(x1, 0);
  1506. CoreGraph._clip_tl.ycoord:=Max(y1, 0);
  1507. CoreGraph._clip_br.xcoord:=Min(x2, CoreGraph._current_video.numxpixels-1);
  1508. CoreGraph._clip_br.ycoord:=Min(y2, CoreGraph._current_video.numypixels-1);
  1509. END SetClipRgn;
  1510. PROCEDURE GetBkColor(): LONGCARD;
  1511. BEGIN
  1512. RETURN CoreGraph._bkcolor;
  1513. END GetBkColor;
  1514. PROCEDURE GetFillMask(VAR Mask: FillMaskType);
  1515. BEGIN
  1516. Lib.FastMove(ADR(CoreGraph._fill_mask), ADR(Mask), SIZE(CoreGraph.FillMaskType));
  1517. END GetFillMask;
  1518. PROCEDURE GetLinestyle(): CARDINAL;
  1519. BEGIN
  1520. RETURN CoreGraph._current_linestyle;
  1521. END GetLinestyle;
  1522. PROCEDURE SetBkColor(Color: LONGCARD): LONGCARD;
  1523. VAR
  1524. Ret: LONGCARD;
  1525. r: SYSTEM.Registers;
  1526. BEGIN
  1527. Ret:=CoreGraph._bkcolor;
  1528. IF Ret = Color THEN
  1529. RETURN Ret;
  1530. END;
  1531. IF (CoreGraph._current_video.mode = _MRES4COLOR) OR (CoreGraph._current_video.mode = _MRESNOCOLOR) THEN
  1532. r.AH:= 0BH;
  1533. r.BH:= 0;
  1534. r.BL:= SHORTCARD(ColXlat(Color));
  1535. Lib.Intr(r, 10H);
  1536. ELSIF CoreGraph._current_video.mode > _MRES16COLOR THEN
  1537. SYSTEM.Eval(RemapPalette(0, Color));
  1538. END;
  1539. CoreGraph._bkcolor:= Color;
  1540. RETURN Ret;
  1541. END SetBkColor;
  1542. PROCEDURE SetFillMask(Mask: CoreGraph.FillMaskType);
  1543. BEGIN
  1544. CoreGraph._current_mask:= CoreGraph.FillMaskPtr(ADR(Mask));
  1545. Lib.FastMove(ADR(Mask), ADR(CoreGraph._fill_mask), SIZE(CoreGraph.FillMaskType));
  1546. END SetFillMask;
  1547. PROCEDURE SetLinestyle(Mask: CARDINAL);
  1548. BEGIN
  1549. CoreGraph._current_linestyle:=Mask;
  1550. END SetLinestyle;
  1551. PROCEDURE DisplayCursor(Toggle: BOOLEAN): BOOLEAN;
  1552. VAR
  1553. Ret: BOOLEAN;
  1554. BEGIN
  1555. Ret:=CoreGraph._cursor_state;
  1556. CoreGraph._cursor_state:=Toggle;
  1557. RETURN Ret;
  1558. END DisplayCursor;
  1559. PROCEDURE GetTextColor(): CARDINAL;
  1560. BEGIN
  1561. RETURN CoreGraph._txcolor;
  1562. END GetTextColor;
  1563. PROCEDURE GetTextPosition(): TextCoords;
  1564. VAR
  1565. Ret: TextCoords;
  1566. BEGIN
  1567. Ret.row:=CoreGraph._current_text.row-CoreGraph._text_tl.row+1;
  1568. Ret.col:=CoreGraph._current_text.col-CoreGraph._text_tl.col+1;
  1569. RETURN Ret;
  1570. END GetTextPosition;
  1571. PROCEDURE SetTextColor(Color: CARDINAL): CARDINAL;
  1572. VAR
  1573. Ret: CARDINAL;
  1574. BEGIN
  1575. Ret:=CoreGraph._txcolor;
  1576. CoreGraph._txcolor:=Color;
  1577. RETURN Ret;
  1578. END SetTextColor;
  1579. PROCEDURE SetTextPosition(row, col: CARDINAL): TextCoords;
  1580. VAR
  1581. Ret: TextCoords;
  1582. BEGIN
  1583. Ret:=CoreGraph._current_text;
  1584. GEnter();
  1585. CoreGraph._current_text.row:=INTEGER(row)+CoreGraph._text_tl.row-1;
  1586. CoreGraph._current_text.col:=INTEGER(col)+CoreGraph._text_tl.col-1;
  1587. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1588. GExit();
  1589. RETURN Ret;
  1590. END SetTextPosition;
  1591. PROCEDURE SetTextWindow(r1, c1, r2, c2: CARDINAL);
  1592. BEGIN
  1593. CoreGraph._text_tl.row:=r1-1;
  1594. CoreGraph._text_tl.col:=c1-1;
  1595. CoreGraph._text_br.row:=r2-1;
  1596. CoreGraph._text_br.col:=c2-1;
  1597. SYSTEM.Eval(SetTextPosition(1, 1));
  1598. END SetTextWindow;
  1599. PROCEDURE Wrapon(Opt: BOOLEAN): BOOLEAN;
  1600. VAR
  1601. Ret: BOOLEAN;
  1602. BEGIN
  1603. Ret:=CoreGraph._wrap_state;
  1604. CoreGraph._wrap_state:=Opt;
  1605. RETURN Ret;
  1606. END Wrapon;
  1607. PROCEDURE OutText(Text: ARRAY OF CHAR);
  1608. VAR
  1609. c: CHAR;
  1610. n, h: CARDINAL;
  1611. BEGIN
  1612. n:=0;
  1613. h:=HIGH(Text);
  1614. GEnter();
  1615. LOOP
  1616. IF n > h THEN EXIT END;
  1617. c:= Text[n];
  1618. INC(n);
  1619. IF c = CHAR(0) THEN EXIT END;
  1620. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1621. IF c = CHAR(0AH) THEN
  1622. IF CoreGraph._current_text.row < CoreGraph._text_br.row THEN
  1623. INC(CoreGraph._current_text.row);
  1624. ELSE
  1625. Scroll();
  1626. END;
  1627. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1628. ELSIF c = CHAR(0DH) THEN
  1629. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1630. ELSE
  1631. CoreGraph._txt_out(INTEGER(c));
  1632. IF CoreGraph._current_text.col = CoreGraph._text_br.col THEN
  1633. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1634. IF CoreGraph._current_text.row < CoreGraph._text_br.row THEN
  1635. INC(CoreGraph._current_text.row);
  1636. ELSE
  1637. Scroll();
  1638. END;
  1639. IF CoreGraph._wrap_state = _GWRAPOFF THEN EXIT END;
  1640. ELSE
  1641. INC(CoreGraph._current_text.col);
  1642. END;
  1643. END;
  1644. END;
  1645. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1646. GExit();
  1647. END OutText;
  1648. PROCEDURE g_charoutput(c: CARDINAL);
  1649. BEGIN
  1650. GEnter();
  1651. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1652. IF c = 0AH THEN
  1653. IF CoreGraph._current_text.row < CoreGraph._text_br.row THEN
  1654. INC(CoreGraph._current_text.row);
  1655. ELSE
  1656. Scroll();
  1657. END;
  1658. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1659. ELSIF c = 0DH THEN
  1660. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1661. ELSIF c = 8 THEN
  1662. IF CoreGraph._current_text.col = CoreGraph._text_tl.col THEN
  1663. IF CoreGraph._current_text.row > CoreGraph._text_tl.row THEN
  1664. DEC(CoreGraph._current_text.row);
  1665. CoreGraph._current_text.col:=CoreGraph._text_br.col;
  1666. END;
  1667. ELSE
  1668. DEC(CoreGraph._current_text.col);
  1669. END;
  1670. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1671. CoreGraph._txt_out(INTEGER('\ '));
  1672. ELSE
  1673. CoreGraph._txt_out(INTEGER(c));
  1674. IF CoreGraph._current_text.col = CoreGraph._text_br.col THEN
  1675. CoreGraph._current_text.col:=CoreGraph._text_tl.col;
  1676. IF CoreGraph._current_text.row < CoreGraph._text_br.row THEN
  1677. INC(CoreGraph._current_text.row);
  1678. ELSE
  1679. Scroll();
  1680. END;
  1681. ELSE
  1682. INC(CoreGraph._current_text.col);
  1683. END;
  1684. END;
  1685. CoreGraph._setcur(CoreGraph._current_text.row, CoreGraph._current_text.col, CoreGraph._active_page);
  1686. GExit();
  1687. END g_charoutput;
  1688. PROCEDURE g_strinput(String: ARRAY OF CHAR);
  1689. VAR
  1690. c: CHAR;
  1691. p, n: CARDINAL;
  1692. BEGIN
  1693. p:=2;
  1694. n:=0;
  1695. LOOP
  1696. IF n = HIGH(String) THEN EXIT END;
  1697. c:= IO.RdChar();
  1698. IF (c = CHAR(8)) OR (c = CHAR(127)) THEN
  1699. IF n > 0 THEN
  1700. DEC(p);
  1701. DEC(n);
  1702. g_charoutput(8);
  1703. END;
  1704. ELSIF ( c > CHAR(' ')) THEN
  1705. g_charoutput(CARDINAL(c));
  1706. String[p]:=c;
  1707. INC(p);
  1708. INC(n);
  1709. ELSIF c = CHAR(13) THEN
  1710. g_charoutput(CARDINAL(0AH));
  1711. EXIT;
  1712. END;
  1713. END;
  1714. String[p]:=CHAR(0);
  1715. END g_strinput;
  1716. PROCEDURE SetVideoMode(Mode: CARDINAL): BOOLEAN;
  1717. TYPE
  1718. PalRegType = ARRAY [0..16] OF SHORTCARD;
  1719. PalColType = ARRAY [0..15] OF LONGCARD;
  1720. CONST
  1721. PalRegs = PalRegType(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0);
  1722. PalCols = PalColType(_BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN,
  1723. _WHITE, _GRAY, _LIGHTBLUE, _LIGHTGREEN, _LIGHTCYAN,
  1724. _LIGHTRED, _LIGHTMAGENTA, _LIGHTYELLOW, _BRIGHTWHITE);
  1725. VAR
  1726. R: SYSTEM.Registers;
  1727. n: CARDINAL;
  1728. PROCEDURE CheckMode(): BOOLEAN;
  1729. VAR
  1730. Ret: BOOLEAN;
  1731. BEGIN
  1732. Ret:=TRUE;
  1733. IF Mode = _DEFAULTMODE THEN
  1734. RETURN Ret;
  1735. END;
  1736. IF CoreGraph._current_video.adapter = _MDPA THEN
  1737. IF Mode # _TEXTMONO THEN
  1738. Ret:=FALSE;
  1739. END;
  1740. ELSIF CoreGraph._current_video.adapter = _HGC THEN
  1741. IF (Mode # _TEXTMONO) AND (Mode # _HERCMONO) THEN
  1742. Ret:=FALSE;
  1743. END;
  1744. ELSE
  1745. CASE Mode OF
  1746. | _TEXTBW40, _TEXTC40, _TEXTBW80, _TEXTC80,
  1747. _MRES4COLOR, _MRESNOCOLOR, _HRESBW:
  1748. Ret:=TRUE;
  1749. | _TEXTMONO, _MRES16COLOR, _HRES16COLOR,
  1750. _ERESNOCOLOR, _ERESCOLOR:
  1751. IF (CoreGraph._current_video.adapter # _VGA) AND (CoreGraph._current_video.adapter # _EGA) THEN
  1752. Ret:=FALSE;
  1753. END;
  1754. | _VRES2COLOR:
  1755. IF (CoreGraph._current_video.adapter # _VGA) AND (CoreGraph._current_video.adapter # _MCGA) THEN
  1756. Ret:=FALSE;
  1757. END;
  1758. | _VRES16COLOR, _HERCMONO:
  1759. IF CoreGraph._current_video.adapter # _VGA THEN (* HGC already checked *)
  1760. Ret:=FALSE;
  1761. END;
  1762. | _MRES256COLOR:
  1763. IF (CoreGraph._current_video.adapter # _VGA) AND (CoreGraph._current_video.adapter # _MCGA) THEN
  1764. Ret:=FALSE;
  1765. END;
  1766. ELSE
  1767. Ret:=FALSE;
  1768. END;
  1769. END;
  1770. RETURN Ret;
  1771. END CheckMode;
  1772. BEGIN
  1773. IF ~CheckMode() THEN
  1774. RETURN FALSE;
  1775. END; (*IF*)
  1776. IF Mode = _DEFAULTMODE THEN
  1777. Mode := CoreGraph._defaultmode;
  1778. END; (*IF*)
  1779. CoreGraph._display_state := ~(((Mode >= 0) & (Mode <= 3)) OR (Mode = 7));
  1780. IF (Mode >= 4) & (Mode <= 6) THEN
  1781. InternalInitCGA(Mode);
  1782. ELSIF Mode = 8 THEN
  1783. InternalInitHerc;
  1784. ELSIF (Mode >= 13) & (Mode < 19) THEN
  1785. InternalInitEGA(Mode);
  1786. ELSIF Mode = 19 THEN
  1787. InternalInitVGA256;
  1788. END; (*IF*)
  1789. IF CoreGraph._lastmode = 8 THEN
  1790. HercTextMode;
  1791. END; (*IF*)
  1792. IF Mode = 8 THEN
  1793. HercGraphMode;
  1794. ELSE
  1795. CoreGraph._setbiosmode(Mode);
  1796. IF (Mode >= 13) AND (Mode < 19) THEN
  1797. R.AX := 1002H;
  1798. R.ES := Seg(PalRegs);
  1799. R.DX := Ofs(PalRegs);
  1800. Lib.Intr(R,10H);
  1801. FOR n := 0 TO 15 DO
  1802. R.AX := 1010H;
  1803. R.BH := SHORTCARD(n); (* Trial Fix 12/02/91 *)
  1804. R.BL := SHORTCARD(n);
  1805. R.DH := SHORTCARD(PalCols[n]);
  1806. R.CH := SHORTCARD(PalCols[n] >> 8);
  1807. R.CL := SHORTCARD(PalCols[n] >> 16);
  1808. Lib.Intr(R,10H);
  1809. END; (*FOR*)
  1810. END; (*IF*)
  1811. END; (*IF*)
  1812. CoreGraph._current_video.mode := Mode;
  1813. SetLimits(CoreGraph._current_video);
  1814. CoreGraph._lastmode := Mode;
  1815. ModeChanged := TRUE;
  1816. RETURN TRUE;
  1817. END SetVideoMode;
  1818. PROCEDURE SetActivePage(Page: CARDINAL): CARDINAL;
  1819. VAR
  1820. Ret: CARDINAL;
  1821. BEGIN
  1822. Ret:=CoreGraph._active_page;
  1823. IF (Page < 0) OR (Page > CoreGraph._current_video.numvideopages-1) THEN
  1824. RETURN MAX(CARDINAL);
  1825. END;
  1826. CoreGraph._active_page:=Page;
  1827. RETURN Ret;
  1828. END SetActivePage;
  1829. PROCEDURE SetVisualPage(Page:CARDINAL):CARDINAL;
  1830. VAR
  1831. r : SYSTEM.Registers;
  1832. Ret : CARDINAL;
  1833. BEGIN
  1834. Ret := CoreGraph._visual_page;
  1835. IF (Page < 0) OR (Page > CoreGraph._current_video.numvideopages-1) THEN
  1836. RETURN MAX(CARDINAL);
  1837. END; (*IF*)
  1838. CoreGraph._visual_page := Page;
  1839. IF CoreGraph._current_video.mode # _HERCMONO THEN
  1840. r.AH:=5;
  1841. r.AL:=SHORTCARD(Page);
  1842. Lib.Intr(r,10H);
  1843. ELSIF Page = 0 THEN
  1844. SYSTEM.Out(3B8H,0AH);
  1845. ELSE
  1846. SYSTEM.Out(3B8H,08AH);
  1847. END; (*IF*)
  1848. RETURN Ret;
  1849. END SetVisualPage;
  1850. PROCEDURE ClearScreen(Area: CARDINAL);
  1851. VAR
  1852. r: SYSTEM.Registers;
  1853. LineNum: INTEGER;
  1854. BEGIN
  1855. GEnter();
  1856. IF Area = _GWINDOW THEN
  1857. r.AX:=0600H;
  1858. IF CoreGraph._display_state = FALSE THEN
  1859. r.BH:=SHORTCARD(7+(CoreGraph._bkcolor<<4));
  1860. ELSE
  1861. r.BH:=0;
  1862. END;
  1863. r.CH:=SHORTCARD(CoreGraph._text_tl.row);
  1864. r.CL:=SHORTCARD(CoreGraph._text_tl.col);
  1865. r.DH:=SHORTCARD(CoreGraph._text_br.row);
  1866. r.DL:=SHORTCARD(CoreGraph._text_br.col);
  1867. Lib.Intr(r, 10H);
  1868. SYSTEM.Eval(SetTextPosition(1, 1));
  1869. ELSIF Area = _GVIEWPORT THEN
  1870. IF CoreGraph._display_state = TRUE THEN
  1871. LineNum:=CoreGraph._clip_tl.ycoord;
  1872. WHILE LineNum <= CoreGraph._clip_br.ycoord DO
  1873. CoreGraph._hline(CoreGraph._clip_tl.xcoord, LineNum, CoreGraph._clip_br.xcoord, 0);
  1874. INC(LineNum);
  1875. END;
  1876. END;
  1877. ELSIF CoreGraph._current_video.mode = _HERCMONO THEN
  1878. CoreGraph._clear_Herc();
  1879. SYSTEM.Eval(SetTextPosition(1, 1));
  1880. ELSE
  1881. r.AX:=0600H;
  1882. IF CoreGraph._display_state = FALSE THEN
  1883. r.BH:=SHORTCARD(7+(CoreGraph._bkcolor<<4));
  1884. ELSE
  1885. r.BH:=SHORTCARD(CoreGraph._bkcolor);
  1886. END;
  1887. r.CX:=0000H;
  1888. r.DH:=SHORTCARD(CoreGraph._current_video.numtextrows-1);
  1889. r.DL:=SHORTCARD(CoreGraph._current_video.numtextcols-1);
  1890. Lib.Intr(r, 10H);
  1891. SYSTEM.Eval(SetTextPosition(1, 1));
  1892. END;
  1893. GExit();
  1894. END ClearScreen;
  1895. PROCEDURE Line(x1, y1, x2, y2: CARDINAL; Color: CARDINAL);
  1896. BEGIN
  1897. GEnter();
  1898. CoreGraph._fgcolor:=Color;
  1899. IF (y1 = y2) AND (CoreGraph._current_linestyle = MAX(CARDINAL)) THEN
  1900. CoreGraph._hline(x1, y1, x2, Color);
  1901. ELSE
  1902. CoreGraph._line(x1, y1, x2, y2, CoreGraph._current_linestyle);
  1903. END;
  1904. GExit();
  1905. END Line;
  1906. PROCEDURE HLine(x1, y1, x2: CARDINAL; Color: CARDINAL);
  1907. BEGIN
  1908. GEnter();
  1909. CoreGraph._hline(x1, y1, x2, Color);
  1910. GExit();
  1911. END HLine;
  1912. PROCEDURE Rectangle(x1, y1, x2, y2: CARDINAL; Color: CARDINAL;Fill: BOOLEAN);
  1913. VAR
  1914. Mask: CARDINAL;
  1915. BEGIN
  1916. GEnter();
  1917. CoreGraph._fgcolor:=Color;
  1918. IF CoreGraph._current_linestyle = MAX(CARDINAL) THEN
  1919. CoreGraph._hline(x1, y1, x2, Color);
  1920. CoreGraph._line(x2, y1, x2, y2, CoreGraph._current_linestyle);
  1921. CoreGraph._hline(x2, y2, x1, Color);
  1922. CoreGraph._line(x1, y2, x1, y1, CoreGraph._current_linestyle);
  1923. ELSE
  1924. CoreGraph._line(x1, y1, x2, y1, CoreGraph._current_linestyle);
  1925. CoreGraph._line(x2, y1, x2, y2, CoreGraph._current_linestyle);
  1926. CoreGraph._line(x2, y2, x1, y2, CoreGraph._current_linestyle);
  1927. CoreGraph._line(x1, y2, x1, y1, CoreGraph._current_linestyle);
  1928. END;
  1929. IF Fill = _GFILLINTERIOR THEN
  1930. INC(x1);
  1931. INC(y1);
  1932. DEC(x2);
  1933. DEC(y2);
  1934. IF x1 = x2 THEN
  1935. GExit();
  1936. RETURN;
  1937. END;
  1938. WHILE y1 <= y2 DO
  1939. Mask:=CARDINAL(CoreGraph._fill_mask[y1 MOD 8])
  1940. +CARDINAL(CoreGraph._fill_mask[y1 MOD 8])*100H;
  1941. IF Mask = MAX(CARDINAL) THEN
  1942. CoreGraph._hline(x1, y1, x2, Color);
  1943. ELSE
  1944. CoreGraph._line(x1, y1, x2, y1, Mask);
  1945. END;
  1946. INC(y1);
  1947. END;
  1948. END;
  1949. GExit();
  1950. END Rectangle;
  1951. PROCEDURE Ellipse(x0, y0, a0, b0: CARDINAL; Color: CARDINAL; Fill: BOOLEAN);
  1952. BEGIN
  1953. GEnter();
  1954. CoreGraph._fgcolor:= Color;
  1955. DrawEllipse(x0, y0, a0, b0, Fill);
  1956. GExit();
  1957. END Ellipse;
  1958. PROCEDURE Disc(x0, y0, r: CARDINAL; Color: CARDINAL);
  1959. BEGIN
  1960. Ellipse(x0, y0, r, r, Color, TRUE);
  1961. END Disc;
  1962. PROCEDURE Circle(x0, y0, r: CARDINAL; Color: CARDINAL);
  1963. BEGIN
  1964. Ellipse(x0, y0, r, r, Color, FALSE);
  1965. END Circle;
  1966. PROCEDURE Arc(x1, y1, a, b, x3, y3, x4, y4: CARDINAL; Color: CARDINAL);
  1967. VAR
  1968. start, end: InterSect;
  1969. BEGIN
  1970. GEnter();
  1971. CoreGraph._fgcolor:=Color;
  1972. start:=GetVec(x1, y1, a, b, x3, y3);
  1973. end:=GetVec(x1, y1, a, b, x4, y4);
  1974. SYSTEM.Eval(DrawArc(x1, y1, a, b, start.x, start.y, end.x, end.y));
  1975. GExit();
  1976. END Arc;
  1977. PROCEDURE Pie(x1, y1, a, b, x3, y3, x4, y4: CARDINAL; Color: CARDINAL; Fill: BOOLEAN);
  1978. VAR
  1979. Ret: BOOLEAN;
  1980. fx, fy: INTEGER;
  1981. start, end: InterSect;
  1982. BEGIN
  1983. GEnter();
  1984. CoreGraph._fgcolor:=Color;
  1985. start:=GetVec(x1, y1, a, b, x3, y3);
  1986. end:=GetVec(x1, y1, a, b, x4, y4);
  1987. Ret:=DrawArc(x1, y1, a, b, start.x, start.y, end.x, end.y);
  1988. IF Ret = FALSE THEN
  1989. RETURN ;
  1990. END;
  1991. CoreGraph._line(x1, y1, start.x, start.y, CoreGraph._current_linestyle);
  1992. CoreGraph._line(x1, y1, end.x, end.y, CoreGraph._current_linestyle);
  1993. IF (Fill = _GFILLINTERIOR) AND (GetFillStart(fx, fy, x1, y1, start.x, start.y,
  1994. end.x, end.y)) THEN
  1995. FloodFill(fx, fy, CoreGraph._fgcolor, CoreGraph._fgcolor);
  1996. END;
  1997. GExit();
  1998. END Pie;
  1999. PROCEDURE Plot(x, y: CARDINAL; Color: CARDINAL);
  2000. BEGIN
  2001. GEnter();
  2002. IF (INTEGER(x) > CoreGraph._clip_br.xcoord) OR (INTEGER(x) < CoreGraph._clip_tl.xcoord)
  2003. OR (INTEGER(y) > CoreGraph._clip_br.ycoord) OR (INTEGER(y) < CoreGraph._clip_tl.ycoord) THEN
  2004. RETURN;
  2005. END;
  2006. CoreGraph._plot(x, y, Color);
  2007. GExit();
  2008. END Plot;
  2009. PROCEDURE Point(x, y: CARDINAL): CARDINAL;
  2010. BEGIN
  2011. IF (INTEGER(x) > CoreGraph._clip_br.xcoord) OR (INTEGER(x) < CoreGraph._clip_tl.xcoord)
  2012. OR (INTEGER(y) > CoreGraph._clip_br.ycoord) OR (INTEGER(y) < CoreGraph._clip_tl.ycoord) THEN
  2013. RETURN MAX(CARDINAL);
  2014. END;
  2015. RETURN CoreGraph._point(x, y);
  2016. END Point;
  2017. PROCEDURE FloodFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  2018. VAR
  2019. xl, xr, v, i, nx, ny: INTEGER;
  2020. BEGIN
  2021. CoreGraph._fgcolor:=Color;
  2022. i:=0;
  2023. WHILE ( i < FILL_MASK_SIZE) DO
  2024. IF CoreGraph._fill_mask[i] = 0 THEN
  2025. StackFill(x, y, Color, Boundary);
  2026. RETURN;
  2027. END;
  2028. INC(i);
  2029. END;
  2030. GEnter();
  2031. nx := INTEGER(x);
  2032. ny := INTEGER(y);
  2033. IF Boundary >= CoreGraph._current_video.numcolors THEN
  2034. Boundary:=CoreGraph._current_video.numcolors-1;
  2035. END;
  2036. IF (nx > CoreGraph._clip_br.xcoord) OR (nx < CoreGraph._clip_tl.xcoord) THEN
  2037. RETURN;
  2038. END;
  2039. IF (ny > CoreGraph._clip_br.ycoord) OR (ny < CoreGraph._clip_tl.ycoord) THEN
  2040. RETURN;
  2041. END;
  2042. v:=CoreGraph._point(x, y);
  2043. IF v = INTEGER(Boundary) THEN
  2044. RETURN;
  2045. END;
  2046. xr := x;
  2047. xl := xr;
  2048. HscanLine (xl, xr, y, Boundary);
  2049. LagFill(xl, xr, y, UP, xl, xl-1, Boundary);
  2050. GExit();
  2051. END FloodFill;
  2052. PROCEDURE StackFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  2053. VAR
  2054. xl, xr, xp, yp, nx, ny, direction: INTEGER;
  2055. BEGIN
  2056. nx := INTEGER(x);
  2057. ny := INTEGER(y);
  2058. GEnter();
  2059. CoreGraph._fgcolor:=Color;
  2060. IF Boundary >= CoreGraph._current_video.numcolors THEN
  2061. Boundary:=CoreGraph._current_video.numcolors-1;
  2062. END;
  2063. IF (nx > CoreGraph._clip_br.xcoord) OR (nx < CoreGraph._clip_tl.xcoord) THEN
  2064. RETURN;
  2065. END;
  2066. IF (ny > CoreGraph._clip_br.ycoord) OR (ny < CoreGraph._clip_tl.ycoord) THEN
  2067. RETURN;
  2068. END;
  2069. IF CoreGraph._point(x, y) = INTEGER(Boundary) THEN
  2070. RETURN;
  2071. END;
  2072. xr := x;
  2073. xl := xr;
  2074. xp:=x;
  2075. yp:=y;
  2076. HscanLine ( xl, xr, y, Boundary );
  2077. direction := +1;
  2078. LOOP
  2079. ny := yp;
  2080. nx := xl;
  2081. xp := xr;
  2082. LOOP
  2083. INC(ny, direction);
  2084. IF (ny < CoreGraph._clip_tl.ycoord) OR (CoreGraph._clip_br.ycoord < ny) THEN
  2085. EXIT;
  2086. END;
  2087. WHILE (nx <= xp) AND (CoreGraph._point ( nx, ny ) = INTEGER(Boundary)) DO
  2088. INC(nx);
  2089. END;
  2090. IF nx > xp THEN
  2091. EXIT;
  2092. END;
  2093. xp := nx;
  2094. HscanLine (nx, xp, ny, INTEGER(Boundary));
  2095. END;
  2096. IF direction < 0 THEN
  2097. EXIT;
  2098. END;
  2099. direction := -1;
  2100. END;
  2101. GExit();
  2102. END StackFill;
  2103. PROCEDURE RemapPalette(Pixel: CARDINAL; Color: LONGCARD): LONGCARD;
  2104. TYPE
  2105. LongSet = SET OF [0..31];
  2106. VAR
  2107. r: SYSTEM.Registers;
  2108. OldColor: LONGCARD;
  2109. n: CARDINAL;
  2110. ColSet: LongSet;
  2111. BEGIN
  2112. GEnter();
  2113. IF (CoreGraph._current_video.adapter = _VGA) OR (CoreGraph._current_video.adapter = _MCGA) THEN
  2114. ColSet:=LongSet(Color);
  2115. r.AX:=01015H;
  2116. r.BX:=Pixel;
  2117. Lib.Intr(r, 10H);
  2118. OldColor:= LONGCARD(r.DH);
  2119. OldColor:= OldColor+LONGCARD(r.CH)<<8;
  2120. OldColor:= OldColor+LONGCARD(r.CL)<<16;
  2121. r.AX:=01010H;
  2122. r.BX:=Pixel;
  2123. r.DH:=SHORTCARD(LONGCARD(ColSet));
  2124. r.CH:=SHORTCARD(LONGCARD(ColSet*LongSet(0FF00H))>>8);
  2125. r.CL:=SHORTCARD(LONGCARD(ColSet*LongSet(0FF0000H))>>16);
  2126. Lib.Intr(r, 10H);
  2127. ELSIF (CoreGraph._current_video.adapter = _EGA) THEN
  2128. n:=EGAcolXlat(Color);
  2129. r.AX:=01000H;
  2130. r.BL:=SHORTCARD(Pixel);
  2131. r.BH:=SHORTCARD(n);
  2132. Lib.Intr(r, 10H);
  2133. OldColor:=ColTable[EGATable[Pixel]];
  2134. EGATable[Pixel]:=n;
  2135. ELSE
  2136. OldColor := MAX(LONGCARD);
  2137. END;
  2138. GExit();
  2139. RETURN OldColor;
  2140. END RemapPalette;
  2141. PROCEDURE RemapAllPalette(Colarray: ARRAY OF LONGCARD): CARDINAL;
  2142. VAR
  2143. num, Count: CARDINAL;
  2144. Colors: ARRAY [0..256] OF ARRAY [0..2] OF SHORTCARD;
  2145. ColRegs: ARRAY [0..16] OF CHAR;
  2146. r: SYSTEM.Registers;
  2147. BEGIN
  2148. num:=CoreGraph._current_video.numcolors;
  2149. Count:=0;
  2150. GEnter();
  2151. IF (CoreGraph._current_video.adapter = _VGA) OR (CoreGraph._current_video.adapter = _MCGA) THEN
  2152. WHILE Count < num DO
  2153. Lib.Move(ADR(Colarray[Count]), ADR(Colors[Count]), 3);
  2154. INC(Count);
  2155. END;
  2156. r.AX:=01012H;
  2157. r.BX:=0;
  2158. r.CX:=num;
  2159. r.DX:=Ofs(Colors);
  2160. r.ES:=Seg(Colors);
  2161. Lib.Intr(r, 10H);
  2162. ELSIF (CoreGraph._current_video.adapter = _EGA) THEN
  2163. Count:=0;
  2164. WHILE Count < num DO
  2165. ColRegs[Count]:=CHAR(EGAcolXlat(Colarray[Count]));
  2166. INC(Count);
  2167. END;
  2168. ColRegs[16]:=CHAR(0);
  2169. r.AX:=1002H;
  2170. r.DX:=Ofs(ColRegs);
  2171. r.ES:=Seg(ColRegs);
  2172. Lib.Intr(r, 10H);
  2173. Lib.Move(ADR(ColRegs), ADR(EGATable), 17);
  2174. END;
  2175. GExit();
  2176. RETURN Count;
  2177. END RemapAllPalette;
  2178. VAR
  2179. OldPalette: CARDINAL;
  2180. PROCEDURE SelectPalette(Palnum: CARDINAL): CARDINAL;
  2181. VAR
  2182. r: SYSTEM.Registers;
  2183. Ret: CARDINAL;
  2184. BEGIN
  2185. Ret:=OldPalette;
  2186. IF (CoreGraph._current_video.mode # _MRES4COLOR) AND (CoreGraph._current_video.mode # _MRESNOCOLOR) THEN
  2187. RETURN MAX(CARDINAL);
  2188. END;
  2189. GEnter();
  2190. OldPalette:=Palnum;
  2191. r.AH:=0BH;
  2192. r.BH:=1;
  2193. r.BL:=SHORTCARD(Palnum);
  2194. Lib.Intr(r, 10H);
  2195. GExit();
  2196. RETURN Ret;
  2197. END SelectPalette;
  2198. PROCEDURE GetImage(x1, y1, x2, y2: CARDINAL; Buffer: ADDRESS);
  2199. BEGIN
  2200. GEnter();
  2201. CoreGraph._get(FarADR(Buffer^), x1, y1, x2, y2);
  2202. GExit();
  2203. END GetImage;
  2204. PROCEDURE PutImage(x, y: CARDINAL; Buffer: ADDRESS; Action: CARDINAL);
  2205. BEGIN
  2206. GEnter();
  2207. CoreGraph._put(x, y, FarADR(Buffer^), Action);
  2208. GExit();
  2209. END PutImage;
  2210. PROCEDURE ImageSize(x1, y1, x2, y2: CARDINAL): LONGCARD;
  2211. VAR
  2212. Size: LONGCARD;
  2213. ywidth, xwidth: LONGCARD;
  2214. BEGIN
  2215. xwidth:=LONGCARD(ABS(INTEGER(x1)-INTEGER(x2))+1);
  2216. ywidth:=LONGCARD(ABS(INTEGER(y1)-INTEGER(y2))+1);
  2217. Size:=((xwidth DIV 8)+1) * ywidth * LONGCARD(CoreGraph._current_video.bitsperpixel);
  2218. RETURN Size+HEADER_SIZE;
  2219. END ImageSize;
  2220. PROCEDURE Cube(top: BOOLEAN; x1, y1, x2, y2, depth: CARDINAL; Color: CARDINAL; Fill: BOOLEAN);
  2221. VAR
  2222. px, py: ARRAY [0..3] OF CARDINAL;
  2223. height: CARDINAL;
  2224. FillVal: BOOLEAN;
  2225. BEGIN
  2226. GEnter();
  2227. FillVal:=FillState;
  2228. FillState:=Fill;
  2229. CoreGraph._fgcolor:=Color;
  2230. height:=y2-y1;
  2231. px[0]:=x2;
  2232. py[0]:=y2;
  2233. px[1]:=x2+depth;
  2234. py[1]:=y2-(depth>>1);
  2235. px[2]:=px[1];
  2236. py[2]:=py[1]-height;
  2237. px[3]:=px[0];
  2238. py[3]:=py[0]-height;
  2239. Polygon(4, px, py, Color);
  2240. IF top THEN
  2241. px[0]:=x1;
  2242. py[0]:=y1;
  2243. px[1]:=x1+depth;
  2244. py[1]:=y1-(depth>>1);
  2245. DEC(px[2]);
  2246. DEC(px[3]);
  2247. Polygon(4, px, py, Color);
  2248. END;
  2249. Rectangle(x1, y1, x2, y2, Color, Fill);
  2250. FillState:=FillVal;
  2251. GExit();
  2252. END Cube;
  2253. CONST
  2254. MaxPts = 20;
  2255. VAR
  2256. xord: ARRAY [0..MaxPts] OF CARDINAL;
  2257. x: ARRAY [0..MaxPts] OF CARDINAL;
  2258. PROCEDURE QuickSort(l,r: INTEGER);
  2259. VAR
  2260. i,j,temp : INTEGER;
  2261. key : CARDINAL;
  2262. BEGIN
  2263. WHILE ( l < r ) DO
  2264. i := l; j := r; key := x[xord[j]];
  2265. REPEAT
  2266. WHILE ( i < j ) AND ( x[xord[i]] <= key ) DO i := i + 1 END;
  2267. WHILE ( i < j ) AND ( key <= x[xord[j]] ) DO j := j - 1 END;
  2268. IF i < j THEN
  2269. temp := xord[i]; xord[i] := xord[j]; xord[j] := temp;
  2270. END;
  2271. UNTIL ( i >= j );
  2272. temp := xord[i]; xord[i] := xord[r]; xord[r] := temp;
  2273. IF (i-l < r-i) THEN
  2274. QuickSort( l, i-1 ); l := i+1;
  2275. ELSE
  2276. QuickSort( i+1, r ); r := i-1;
  2277. END;
  2278. END;
  2279. END QuickSort;
  2280. PROCEDURE Polygon(n: CARDINAL; px, py: ARRAY OF CARDINAL; Color: CARDINAL);
  2281. VAR
  2282. y, miny, maxy, x0, y0, x1, y1: INTEGER;
  2283. temp, i, edge, next_edge, active: INTEGER;
  2284. e: ARRAY [0..MaxPts] OF INTEGER;
  2285. plotl, plotr: INTEGER;
  2286. Mask: CARDINAL;
  2287. BEGIN
  2288. IF n > MaxPts THEN RETURN END;
  2289. GEnter();
  2290. CoreGraph._fgcolor:=Color;
  2291. i:=0;
  2292. WHILE i < INTEGER(n) DO
  2293. IF i < INTEGER(n-1) THEN
  2294. CoreGraph._line(px[i], py[i], px[i+1], py[i+1], CoreGraph._current_linestyle);
  2295. ELSE
  2296. CoreGraph._line(px[i], py[i], px[0], py[0], CoreGraph._current_linestyle);
  2297. END;
  2298. INC(i);
  2299. END;
  2300. IF FillState = _GBORDER THEN
  2301. GExit();
  2302. RETURN;
  2303. END;
  2304. miny:=py[0]; (* find extremal y points *)
  2305. maxy:=miny;
  2306. i:=0;
  2307. WHILE i < INTEGER(n) DO
  2308. IF INTEGER(py[i]) < miny THEN
  2309. miny:=py[i];
  2310. END;
  2311. IF INTEGER(py[i]) > maxy THEN
  2312. maxy:=py[i];
  2313. END;
  2314. INC(i);
  2315. END;
  2316. y:=miny;
  2317. WHILE y <= maxy DO
  2318. active:=-1;
  2319. edge:= 0;
  2320. WHILE edge < INTEGER(n) DO
  2321. IF edge = INTEGER(n-1) THEN
  2322. next_edge:=0;
  2323. ELSE
  2324. next_edge:=edge+1;
  2325. END;
  2326. x0:=px[edge];
  2327. y0:=py[edge];
  2328. x1:=px[next_edge];
  2329. y1:=py[next_edge];
  2330. IF y0 > y1 THEN
  2331. temp:=x0;
  2332. x0:=x1;
  2333. x1:=temp;
  2334. temp:=y0;
  2335. y0:=y1;
  2336. y1:=temp;
  2337. END;
  2338. IF y = y0 THEN
  2339. e[edge]:=0;
  2340. x[edge]:=x0;
  2341. ELSIF (y0 <= y) AND (y <= y1) THEN
  2342. IF x1 >= x0 THEN (* x increases with y *)
  2343. INC(e[edge], (2*(x1-x0)));
  2344. WHILE e[edge] > (y1-y0) DO
  2345. DEC(e[edge], (2*(y1-y0)));
  2346. INC(x[edge]);
  2347. END;
  2348. ELSE (* x decreases with y *)
  2349. INC(e[edge], (2*(x0-x1)));
  2350. WHILE e[edge] > (y1-y0) DO
  2351. DEC(e[edge], (2*(y1-y0)));
  2352. DEC(x[edge]);
  2353. END;
  2354. END;
  2355. INC(active);
  2356. xord[active]:=edge;
  2357. END;
  2358. INC(edge);
  2359. END;
  2360. QuickSort(0, active);
  2361. i:=0;
  2362. WHILE i < active DO
  2363. plotl:=x[xord[i]]+1;
  2364. plotr:=x[xord[i+1]]-1;
  2365. IF plotr >= plotl THEN
  2366. CoreGraph._fgcolor:=Color;
  2367. Mask:=CARDINAL(CoreGraph._fill_mask[y MOD 8])
  2368. +CARDINAL(CoreGraph._fill_mask[y MOD 8])*100H;
  2369. IF Mask = MAX(CARDINAL) THEN
  2370. CoreGraph._hline(plotl, y, plotr, Color);
  2371. ELSE
  2372. CoreGraph._line(plotl, y, plotr, y, Mask);
  2373. END;
  2374. END;
  2375. INC(i, 2);
  2376. END;
  2377. INC(y);
  2378. END; (* for y = .. *)
  2379. GExit();
  2380. END Polygon;
  2381. PROCEDURE GraphMode();
  2382. BEGIN
  2383. (*%T AutoDetect *)
  2384. CASE CoreGraph._current_video.adapter OF
  2385. | _HGC :
  2386. Width:=HercWidth;
  2387. Depth:=HercDepth;
  2388. NumColor:=HercNumColor;
  2389. IF SetVideoMode(_HERCMONO) THEN END;
  2390. | _CGA, _MCGA:
  2391. Width:=CGAWidth;
  2392. Depth:=CGADepth;
  2393. NumColor:=CGANumColor;
  2394. IF SetVideoMode(_MRES4COLOR) THEN END;
  2395. | _EGA, _VGA :
  2396. Width:=EGAWidth;
  2397. Depth:=EGADepth;
  2398. NumColor:=EGANumColor;
  2399. IF SetVideoMode(_ERESCOLOR) THEN END;
  2400. ELSE
  2401. RETURN;
  2402. END;
  2403. (*%E *)
  2404. (*%F AutoDetect *)
  2405. CoreGraph._display_state:=TRUE;
  2406. IF StaticMode = _HERCMONO THEN
  2407. HercGraphMode();
  2408. ELSE
  2409. CoreGraph._setbiosmode(StaticMode);
  2410. END;
  2411. CoreGraph._current_video.mode:= StaticMode;
  2412. SetLimits(CoreGraph._current_video);
  2413. CoreGraph._lastmode:=StaticMode;
  2414. (*%E *)
  2415. END GraphMode;
  2416. PROCEDURE TextMode();
  2417. BEGIN
  2418. (*%T AutoDetect *)
  2419. IF SetVideoMode(_DEFAULTMODE) THEN END;
  2420. (*%E *)
  2421. (*%F AutoDetect *)
  2422. CoreGraph._display_state:=FALSE;
  2423. IF StaticMode = _HERCMONO THEN
  2424. HercTextMode();
  2425. ELSE
  2426. CoreGraph._setbiosmode(CoreGraph._defaultmode);
  2427. END;
  2428. CoreGraph._current_video.mode:= CoreGraph._defaultmode;
  2429. SetLimits(CoreGraph._current_video);
  2430. CoreGraph._lastmode:=CoreGraph._defaultmode;
  2431. (*%E *)
  2432. END TextMode;
  2433. PROCEDURE InitCGA();
  2434. BEGIN
  2435. InternalInitCGA(_MRES4COLOR);
  2436. CoreGraph._current_video.adapter := _CGA;
  2437. StaticMode:=_MRES4COLOR;
  2438. Width:=CGAWidth;
  2439. Depth:=CGADepth;
  2440. NumColor:=CGANumColor;
  2441. END InitCGA;
  2442. PROCEDURE InitEGA();
  2443. BEGIN
  2444. InternalInitEGA(_ERESCOLOR);
  2445. CoreGraph._current_video.adapter := _EGA;
  2446. StaticMode:=_ERESCOLOR;
  2447. Width:=EGAWidth;
  2448. Depth:=EGADepth;
  2449. NumColor:=EGANumColor;
  2450. END InitEGA;
  2451. PROCEDURE InitVGA();
  2452. BEGIN
  2453. InternalInitVGA256();
  2454. CoreGraph._current_video.adapter := _VGA;
  2455. StaticMode:=_MRES256COLOR;
  2456. Width:=VGA256Width;
  2457. Depth:=VGA256Depth;
  2458. NumColor:=VGANumColor;
  2459. END InitVGA;
  2460. PROCEDURE InitHerc();
  2461. BEGIN
  2462. InternalInitHerc();
  2463. CoreGraph._current_video.adapter := _HGC;
  2464. StaticMode:=_HERCMONO;
  2465. Width:=HercWidth;
  2466. Depth:=HercDepth;
  2467. NumColor:=HercNumColor;
  2468. END InitHerc;
  2469. PROCEDURE InitGraph();
  2470. VAR
  2471. display : CoreGraph.VideoType;
  2472. Disp : CARDINAL;
  2473. BEGIN
  2474. CoreGraph._defaultmode := CoreGraph._getvideomode();
  2475. CoreGraph._lastmode := CoreGraph._defaultmode;
  2476. CoreGraph._current_video.mode := CoreGraph._defaultmode;
  2477. SetLimits(CoreGraph._current_video);
  2478. CoreGraph._getsystem(display);
  2479. Disp := SetActivePage(0);
  2480. Disp := SetVisualPage(0);
  2481. CASE display.sys0 OF
  2482. MDA : CoreGraph._current_video.adapter:=_MDPA; |
  2483. CGA : CoreGraph._current_video.adapter:=_CGA;
  2484. Width:=CGAWidth;
  2485. Depth:=CGADepth;
  2486. NumColor:=CGANumColor; |
  2487. EGA : CoreGraph._current_video.adapter:=_EGA;
  2488. CoreGraph._current_video.memory:=CoreGraph._getmemory();
  2489. IF (CoreGraph._current_video.memory = 64 )THEN
  2490. CoreGraph._EGA64K:=TRUE;
  2491. END; (*IF*)
  2492. Width:=EGAWidth;
  2493. Depth:=EGADepth;
  2494. NumColor:=EGANumColor; |
  2495. MCGA : CoreGraph._current_video.adapter:=_MCGA;
  2496. CoreGraph._current_video.memory:=CoreGraph._getmemory();
  2497. Width:=CGAWidth;
  2498. Depth:=CGADepth;
  2499. NumColor:=CGANumColor; |
  2500. VGA : CoreGraph._current_video.adapter:=_VGA;
  2501. CoreGraph._current_video.memory:=CoreGraph._getmemory();
  2502. Width := VGAWidth;
  2503. Depth := VGADepth;
  2504. NumColor:=EGANumColor; |
  2505. HGC : CoreGraph._current_video.adapter:=_HGC;
  2506. CoreGraph._current_video.memory:=64;
  2507. Width:=HercWidth;
  2508. Depth:=HercDepth;
  2509. NumColor:=HercNumColor; |
  2510. HGCPlus,
  2511. InColor : CoreGraph._current_video.adapter:=-1; |
  2512. END; (*CASE*)
  2513. CASE display.dis0 OF
  2514. | MDADisplay:
  2515. CoreGraph._current_video.monitor:=_MONO;
  2516. | CGADisplay:
  2517. CoreGraph._current_video.monitor:=_COLOR;
  2518. | EGAColorDisplay:
  2519. CoreGraph._current_video.monitor:=_ENHCOLOR;
  2520. | PS2MonoDisplay:
  2521. CoreGraph._current_video.monitor:=_MONO;
  2522. | PS2ColorDisplay:
  2523. CoreGraph._current_video.monitor:=_ANALOG;
  2524. END;
  2525. END InitGraph;
  2526. PROCEDURE TrueDisc(x0,y0,r: CARDINAL; c: CARDINAL);
  2527. VAR b:CARDINAL;
  2528. BEGIN
  2529. IF CoreGraph._width=CGAWidth-1 THEN b := (r*5)DIV 6;
  2530. ELSIF CoreGraph._depth=EGADepth-1 THEN b := (r*73)DIV 100;
  2531. ELSE b := r;
  2532. END;
  2533. Ellipse (x0,y0,r,b,c,TRUE) ;
  2534. END TrueDisc;
  2535. PROCEDURE TrueCircle(x0,y0,r: CARDINAL; c: CARDINAL);
  2536. VAR b:CARDINAL;
  2537. BEGIN
  2538. IF CoreGraph._width=CGAWidth-1 THEN b := (r*5)DIV 6;
  2539. ELSIF CoreGraph._depth=EGADepth-1 THEN b := (r*73)DIV 100;
  2540. ELSE b := r;
  2541. END;
  2542. Ellipse (x0,y0,r,b,c,FALSE) ;
  2543. END TrueCircle;
  2544. VAR
  2545. C: PROC;
  2546. PROCEDURE GraphTerminate();
  2547. BEGIN
  2548. IF (CoreGraph._display_state = TRUE) AND (ModeChanged = TRUE) THEN
  2549. IF SetVideoMode(_DEFAULTMODE) THEN END;
  2550. END;
  2551. C;
  2552. END GraphTerminate;
  2553. (*%E _XTDDOS *)
  2554. (*%F _XTDDOS *)
  2555. PROCEDURE GenericGraphMode;
  2556. VAR r : CARDINAL;
  2557. BitMap : CARDINAL;
  2558. BEGIN
  2559. WHILE GraphI.Virtual DO Lib.Delay(100) END;
  2560. GraphI.CurMode.b := SIZE(GraphI.CurMode);
  2561. GraphI.CurMode.col := 80;
  2562. GraphI.CurMode.row := 25;
  2563. GraphI.CurMode.hres := Width;
  2564. GraphI.CurMode.vres := Depth;
  2565. IF Width<EGAWidth THEN GraphI.CurMode.col := 40 ELSE GraphI.CurMode.col := 80 END;
  2566. IF Depth<VGADepth THEN GraphI.CurMode.row := 25 ELSE GraphI.CurMode.row := 30 END;
  2567. IF NumColor=0 THEN GraphI.CurMode.color := 0
  2568. ELSIF NumColor<=2 THEN GraphI.CurMode.color := 1
  2569. ELSIF NumColor<=4 THEN GraphI.CurMode.color := 2
  2570. ELSIF NumColor<=16 THEN GraphI.CurMode.color := 4
  2571. ELSE GraphI.CurMode.color := 8
  2572. END;
  2573. GraphI.CurMode.type := 3;
  2574. r := Vio.SetMode(GraphI.CurMode,0);
  2575. Lib.OSFatalError('Vio.SetMode ',r);
  2576. IF GraphI.IsCGA THEN
  2577. Lib.FarWordFill(GraphI.Buffer[0],2000H,0);
  2578. ELSE
  2579. FOR BitMap := 0 TO GraphI.MaxBitMap DO
  2580. Lib.FarWordFill(GraphI.Buffer[BitMap],SIZE(GraphI.Buffer[BitMap]^) DIV 2,0);
  2581. END;
  2582. END;
  2583. GraphI.RestoreScreen;
  2584. GraphI.GraphM := TRUE ;
  2585. END GenericGraphMode;
  2586. PROCEDURE CGAPlot(x,y:CARDINAL;c:CARDINAL);
  2587. BEGIN
  2588. GraphI.CGAPlot(x,y,c);
  2589. END CGAPlot;
  2590. PROCEDURE CGAPoint(x,y:CARDINAL) : CARDINAL;
  2591. BEGIN
  2592. RETURN GraphI.CGAPoint(x,y);
  2593. END CGAPoint;
  2594. PROCEDURE CGAHLine ( x,y,x2 : CARDINAL; c:CARDINAL );
  2595. BEGIN
  2596. GraphI.CGAHLine(x,y,x2,c);
  2597. END CGAHLine;
  2598. (* == EGA/VGA specific routines == *)
  2599. PROCEDURE EGAPlot( x,y,c : CARDINAL); (* Also VGA *)
  2600. VAR
  2601. t:GraphI.BS;
  2602. p,b,s:CARDINAL;
  2603. BEGIN
  2604. GraphI.EGAPlot(x,y,c);
  2605. END EGAPlot;
  2606. PROCEDURE EGAPoint(x,y:CARDINAL) : CARDINAL; (* Also VGA *)
  2607. BEGIN
  2608. RETURN GraphI.EGAPoint(x,y);
  2609. END EGAPoint;
  2610. PROCEDURE EGAHLine ( x,y,x2 : CARDINAL; c:CARDINAL ); (* Also VGA *)
  2611. BEGIN
  2612. GraphI.EGAHLine(x,y,x2,c);
  2613. END EGAHLine;
  2614. PROCEDURE CGAGraphMode;
  2615. BEGIN
  2616. GenericGraphMode;
  2617. END CGAGraphMode;
  2618. PROCEDURE CGATextMode; (* General Text Mode *)
  2619. VAR r : CARDINAL;
  2620. BEGIN
  2621. WHILE GraphI.Virtual DO Lib.Delay(100) END;
  2622. GraphI.CurMode.b := VSIZE(Vio.MODEINFO.type);
  2623. GraphI.CurMode.type := 1;
  2624. r := Vio.SetMode(GraphI.CurMode,0);
  2625. GraphI.GraphM := FALSE;
  2626. END CGATextMode;
  2627. PROCEDURE EGAGraphMode; (* Also VGA *)
  2628. BEGIN
  2629. GenericGraphMode;
  2630. END EGAGraphMode;
  2631. PROCEDURE InitVGA ;
  2632. BEGIN
  2633. InitEGA ;
  2634. Depth := VGADepth ; (* Width same as EGA *)
  2635. END InitVGA ;
  2636. PROCEDURE Line(x1,y1,x2,y2: CARDINAL; c: CARDINAL);
  2637. BEGIN
  2638. GraphI.Line(x1,y1,x2,y2,c);
  2639. END Line;
  2640. PROCEDURE Disc(x0,y0,r: CARDINAL; c: CARDINAL);
  2641. BEGIN
  2642. GraphI.Disc(x0,y0,r,c);
  2643. END Disc;
  2644. PROCEDURE Circle(x0,y0,r: CARDINAL; c: CARDINAL);
  2645. BEGIN
  2646. GraphI.Circle(x0,y0,r,c);
  2647. END Circle;
  2648. PROCEDURE TrueCircle(x0,y0,r: CARDINAL; c: CARDINAL);
  2649. VAR b:CARDINAL;
  2650. BEGIN
  2651. IF Width=CGAWidth THEN b := (r*5)DIV 6;
  2652. ELSIF Depth=EGADepth THEN b := (r*73)DIV 100;
  2653. ELSE b := r;
  2654. END;
  2655. Ellipse (x0,y0,r,b,c,FALSE) ;
  2656. END TrueCircle;
  2657. PROCEDURE TrueDisc(x0,y0,r: CARDINAL; c: CARDINAL);
  2658. VAR b:CARDINAL;
  2659. BEGIN
  2660. IF Width=CGAWidth THEN b := (r*5)DIV 6;
  2661. ELSIF Depth=EGADepth THEN b := (r*73)DIV 100;
  2662. ELSE b := r;
  2663. END;
  2664. Ellipse (x0,y0,r,b,c,TRUE) ;
  2665. END TrueDisc;
  2666. PROCEDURE Ellipse ( x0,y0 : CARDINAL ; (* center *)
  2667. a0,b0 : CARDINAL ; (* semi-axes *)
  2668. c : CARDINAL ; (* color *)
  2669. fill : BOOLEAN ) ; (* wether filled *)
  2670. VAR
  2671. x,y : CARDINAL ;
  2672. a,b : LONGINT ;
  2673. asq,asq2,bsq,bsq2 : LONGINT ;
  2674. d,dx,dy : LONGINT ;
  2675. BEGIN
  2676. x := 0 ;
  2677. y := b0 ;
  2678. a := LONGINT(a0) ;
  2679. b := LONGINT(b0) ;
  2680. asq := a*a ;
  2681. asq2 := asq*2 ;
  2682. bsq := b*b ;
  2683. bsq2 := bsq*2 ;
  2684. d := bsq-(asq*b)+(asq DIV 4) ;
  2685. dx := 0 ;
  2686. dy := asq2*b ;
  2687. WHILE dx<dy DO
  2688. IF fill THEN
  2689. HLine(x0-x,y0+y,x0+x,c);
  2690. HLine(x0-x,y0-y,x0+x,c);
  2691. ELSE
  2692. Plot(x0+x,y0+y,c) ;
  2693. Plot(x0-x,y0+y,c) ;
  2694. Plot(x0+x,y0-y,c) ;
  2695. Plot(x0-x,y0-y,c) ;
  2696. END ;
  2697. IF d>0 THEN
  2698. DEC(y) ;
  2699. DEC(dy,asq2) ;
  2700. DEC(d,dy) ;
  2701. END ;
  2702. INC(x) ;
  2703. INC(dx,bsq2) ;
  2704. INC(d,bsq+dx) ;
  2705. END ;
  2706. INC(d,(3*(asq-bsq)DIV 2-(dx+dy))DIV 2) ;
  2707. WHILE INTEGER(y)>=0 DO
  2708. IF fill THEN
  2709. HLine(x0-x,y0+y,x0+x,c);
  2710. HLine(x0-x,y0-y,x0+x,c);
  2711. ELSE
  2712. Plot(x0+x,y0+y,c) ;
  2713. Plot(x0-x,y0+y,c) ;
  2714. Plot(x0+x,y0-y,c) ;
  2715. Plot(x0-x,y0-y,c) ;
  2716. END ;
  2717. IF d<0 THEN
  2718. INC(x) ;
  2719. INC(dx,bsq2) ;
  2720. INC(d,dx) ;
  2721. END ;
  2722. DEC(y) ;
  2723. DEC(dy,asq2) ;
  2724. INC(d,asq-dy) ;
  2725. END ;
  2726. END Ellipse ;
  2727. PROCEDURE Polygon(n: CARDINAL; px,py: ARRAY OF CARDINAL; c: CARDINAL);
  2728. BEGIN
  2729. GraphI.Polygon(n,px,py,c);
  2730. END Polygon;
  2731. VAR
  2732. SwapStack : ARRAY [0..1023] OF BYTE;
  2733. SwapThread : CARDINAL;
  2734. PROCEDURE SwapProcess;
  2735. VAR r,action,svs : CARDINAL;
  2736. BEGIN
  2737. GraphI.Virtual := FALSE;
  2738. Lib.OSFatalError('Dos.SetPrty',
  2739. Dos.SetPrty(2,3,0,SwapThread));
  2740. LOOP
  2741. Lib.OSFatalError('Vio.SavRedrawWait',
  2742. Vio.SavRedrawWait(0,action,0));
  2743. IF GraphI.GraphM THEN
  2744. IF (action=1)AND GraphI.Virtual THEN (* restore *)
  2745. Dos.EnterCritSec;
  2746. GraphI.VideoSel := svs;
  2747. GraphI.Virtual := FALSE;
  2748. GraphI.RestoreScreen;
  2749. Dos.ExitCritSec;
  2750. r := Vio.SetMode(GraphI.CurMode,0);
  2751. ELSIF (action=0)AND NOT GraphI.Virtual THEN (* save *)
  2752. Dos.EnterCritSec;
  2753. svs := GraphI.VideoSel;
  2754. GraphI.SaveScreen;
  2755. GraphI.VideoSel := SYSTEM.Seg(GraphI.Buffer[0]^);
  2756. GraphI.Virtual := TRUE;
  2757. Dos.ExitCritSec;
  2758. Lib.Delay(100); (* wait for pending operations to finish *)
  2759. END;
  2760. END;
  2761. END;
  2762. END SwapProcess;
  2763. PROCEDURE GraphMode;
  2764. BEGIN
  2765. GraphI.G_GraphMode;
  2766. END GraphMode;
  2767. PROCEDURE TextMode;
  2768. BEGIN
  2769. GraphI.G_TextMode;
  2770. END TextMode;
  2771. PROCEDURE InitCGA ;
  2772. VAR
  2773. r : CARDINAL;
  2774. sl : Vio.PHYSBUF;
  2775. BEGIN
  2776. sl.bufaddr := 0B8000H;
  2777. sl.buflen := 004000H;
  2778. r := Vio.GetPhysBuf(sl,0);
  2779. GraphI.VideoSel := sl.sel[0];
  2780. Width := CGAWidth ;
  2781. Depth := CGADepth ;
  2782. NumColor := 4 ;
  2783. GraphI.G_TextMode := CGATextMode ;
  2784. GraphI.G_GraphMode := CGAGraphMode ;
  2785. GraphI.G_Plot := CGAPlot ;
  2786. GraphI.G_Point := CGAPoint ;
  2787. GraphI.G_HLine := CGAHLine ;
  2788. IF GraphI.Buffer[0]=FarNIL THEN
  2789. Storage.FarAllocate(GraphI.Buffer[0], GraphI.BitMapSize);
  2790. END;
  2791. GraphI.IsCGA := TRUE;
  2792. END InitCGA ;
  2793. PROCEDURE InitEGA ;
  2794. VAR
  2795. BitMap : CARDINAL;
  2796. r : CARDINAL;
  2797. sl : Vio.PHYSBUF;
  2798. BEGIN
  2799. FOR BitMap := 0 TO GraphI.MaxBitMap DO
  2800. IF GraphI.Buffer[BitMap]=FarNIL THEN
  2801. Storage.FarAllocate(GraphI.Buffer[BitMap], GraphI.BitMapSize);
  2802. END;
  2803. END;
  2804. sl.bufaddr := 0A0000H;
  2805. sl.buflen := 010000H;
  2806. r := Vio.GetPhysBuf(sl,0);
  2807. GraphI.VideoSel := sl.sel[0];
  2808. Width := EGAWidth ;
  2809. Depth := EGADepth ;
  2810. Depth := EGADepth;
  2811. NumColor := 16 ;
  2812. GraphI.G_TextMode := CGATextMode ;
  2813. GraphI.G_GraphMode := EGAGraphMode ;
  2814. GraphI.G_Plot := EGAPlot ;
  2815. GraphI.G_Point := EGAPoint ;
  2816. GraphI.G_HLine := EGAHLine ;
  2817. GraphI.IsCGA := FALSE;
  2818. END InitEGA ;
  2819. PROCEDURE Plot(x,y: CARDINAL; Color: CARDINAL);
  2820. BEGIN
  2821. GraphI.G_Plot(x, y, Color);
  2822. END Plot;
  2823. PROCEDURE Point(x,y: CARDINAL) : CARDINAL;
  2824. BEGIN
  2825. RETURN GraphI.G_Point(x, y);
  2826. END Point;
  2827. PROCEDURE HLine(x,y,x2: CARDINAL; FillColor: CARDINAL);
  2828. BEGIN
  2829. GraphI.G_HLine(x, y, x2, FillColor);
  2830. END HLine;
  2831. PROCEDURE NotSupported(Func: ARRAY OF CHAR);
  2832. VAR
  2833. Msg: ARRAY [0..79] OF CHAR;
  2834. BEGIN
  2835. Str.Concat(Msg, Func, ': Not Supported Under OS2.');
  2836. Lib.RunTimeError(CoreSig._FatalErrorPos(), 0D1H, Msg);
  2837. END NotSupported;
  2838. PROCEDURE GetVideoConfig(VAR V: VideoConfig);
  2839. BEGIN
  2840. NotSupported('GetVideoConfig');
  2841. END GetVideoConfig;
  2842. PROCEDURE SetClipRgn(x1, y1, x2, y2: CARDINAL);
  2843. BEGIN
  2844. NotSupported('SetClipRgn');
  2845. END SetClipRgn;
  2846. PROCEDURE GetBkColor(): LONGCARD;
  2847. BEGIN
  2848. NotSupported('GetBkColor');
  2849. RETURN 0;
  2850. END GetBkColor;
  2851. PROCEDURE GetFillMask(VAR Mask: FillMaskType);
  2852. BEGIN
  2853. NotSupported('GetFillMask');
  2854. END GetFillMask;
  2855. PROCEDURE GetLinestyle(): CARDINAL;
  2856. BEGIN
  2857. NotSupported( 'GetLineStyle');
  2858. RETURN 0;
  2859. END GetLinestyle;
  2860. PROCEDURE SetBkColor(Color: LONGCARD): LONGCARD;
  2861. BEGIN
  2862. NotSupported( 'SetBkColor');
  2863. RETURN 0;
  2864. END SetBkColor;
  2865. PROCEDURE SetFillMask(Mask: FillMaskType);
  2866. BEGIN
  2867. NotSupported( 'SetFillMask');
  2868. END SetFillMask;
  2869. PROCEDURE SetLinestyle(Mask: CARDINAL);
  2870. BEGIN
  2871. NotSupported( 'SetLinestyle');
  2872. END SetLinestyle;
  2873. PROCEDURE GetTextColor(): CARDINAL;
  2874. BEGIN
  2875. NotSupported( 'GetTextColor');
  2876. RETURN 0;
  2877. END GetTextColor;
  2878. PROCEDURE GetTextPosition(): TextCoords;
  2879. BEGIN
  2880. NotSupported( 'GetTextPosition');
  2881. RETURN TextCoords(0,0);
  2882. END GetTextPosition;
  2883. PROCEDURE DisplayCursor(Mode: BOOLEAN): BOOLEAN;
  2884. BEGIN
  2885. NotSupported( 'DisplayCursor');
  2886. RETURN FALSE;
  2887. END DisplayCursor;
  2888. PROCEDURE SetTextPosition(row, col: CARDINAL): TextCoords;
  2889. BEGIN
  2890. NotSupported( 'SetTextPosition');
  2891. RETURN TextCoords(0,0);
  2892. END SetTextPosition;
  2893. PROCEDURE SetTextWindow(r1, c1, r2, c2: CARDINAL);
  2894. BEGIN
  2895. NotSupported( 'SetTextWindow');
  2896. END SetTextWindow;
  2897. PROCEDURE Wrapon(Opt: BOOLEAN): BOOLEAN;
  2898. BEGIN
  2899. NotSupported( 'Wrapon');
  2900. RETURN FALSE;
  2901. END Wrapon;
  2902. PROCEDURE OutText(Text: ARRAY OF CHAR);
  2903. BEGIN
  2904. NotSupported( 'OutText');
  2905. END OutText;
  2906. PROCEDURE SetVideoMode(Mode: CARDINAL): BOOLEAN;
  2907. BEGIN
  2908. NotSupported( 'SetVideoMode');
  2909. RETURN FALSE;
  2910. END SetVideoMode;
  2911. PROCEDURE SetActivePage(Page: CARDINAL): CARDINAL;
  2912. BEGIN
  2913. NotSupported('SetActivePage');
  2914. RETURN 0;
  2915. END SetActivePage;
  2916. PROCEDURE SetVisualPage(Page: CARDINAL): CARDINAL;
  2917. BEGIN
  2918. NotSupported( 'SetVisualPage');
  2919. RETURN 0;
  2920. END SetVisualPage;
  2921. PROCEDURE ClearScreen(Area: CARDINAL);
  2922. BEGIN
  2923. NotSupported( 'ClearScreen');
  2924. END ClearScreen;
  2925. PROCEDURE Rectangle(x1, y1, x2, y2: CARDINAL; Color: CARDINAL;Fill: BOOLEAN);
  2926. BEGIN
  2927. NotSupported( 'Rectangle');
  2928. END Rectangle;
  2929. PROCEDURE Arc(x1, y1, x2, y2, x3, y3, x4, y4: CARDINAL; Color: CARDINAL);
  2930. BEGIN
  2931. NotSupported( 'Arc');
  2932. END Arc;
  2933. PROCEDURE Pie(x1, y1, x2, y2, x3, y3, x4, y4: CARDINAL; Colr: CARDINAL; Fill: BOOLEAN);
  2934. BEGIN
  2935. NotSupported( 'Pie');
  2936. END Pie;
  2937. PROCEDURE FloodFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  2938. BEGIN
  2939. NotSupported( 'FloodFill');
  2940. END FloodFill;
  2941. PROCEDURE StackFill(x, y: CARDINAL; Color: CARDINAL; Boundary: CARDINAL);
  2942. BEGIN
  2943. NotSupported( 'StackFill');
  2944. END StackFill;
  2945. PROCEDURE RemapPalette(Pixel: CARDINAL; Color: LONGCARD): LONGCARD;
  2946. BEGIN
  2947. NotSupported( 'RemapPalette');
  2948. RETURN 0;
  2949. END RemapPalette;
  2950. PROCEDURE RemapAllPalette(Colarray: ARRAY OF LONGCARD): CARDINAL;
  2951. BEGIN
  2952. NotSupported( 'RemapAllPalette');
  2953. RETURN 0;
  2954. END RemapAllPalette;
  2955. PROCEDURE SelectPalette(Palnum: CARDINAL): CARDINAL;
  2956. BEGIN
  2957. NotSupported( 'SelectPalette');
  2958. RETURN 0;
  2959. END SelectPalette;
  2960. PROCEDURE GetImage(x1, y1, x2, y2: CARDINAL; Buffer: ADDRESS);
  2961. BEGIN
  2962. NotSupported( 'GetImage');
  2963. END GetImage;
  2964. PROCEDURE PutImage(x, y: CARDINAL; Buffer: ADDRESS; Action: CARDINAL);
  2965. BEGIN
  2966. NotSupported( 'PutImage');
  2967. END PutImage;
  2968. PROCEDURE ImageSize(x1, y1, x2, y2: CARDINAL): LONGCARD;
  2969. BEGIN
  2970. NotSupported( 'ImageSize');
  2971. RETURN 0;
  2972. END ImageSize;
  2973. PROCEDURE Cube(top: BOOLEAN; x1, y1, x2, y2, depth: CARDINAL; Color: CARDINAL; Fill: BOOLEAN);
  2974. BEGIN
  2975. NotSupported( 'Cube');
  2976. END Cube;
  2977. PROCEDURE InitHerc();
  2978. BEGIN
  2979. NotSupported( 'InitHerc');
  2980. END InitHerc;
  2981. PROCEDURE InitGraph();
  2982. BEGIN
  2983. NotSupported( 'InitGraph');
  2984. END InitGraph;
  2985. PROCEDURE SetTextColor(Col: CARDINAL): CARDINAL;
  2986. BEGIN
  2987. NotSupported( 'SetTextColor');
  2988. RETURN 0;
  2989. END SetTextColor;
  2990. PROCEDURE Init;
  2991. VAR
  2992. i,r : CARDINAL;
  2993. BEGIN
  2994. GraphI.GraphM := FALSE;
  2995. r := Dos.CreateThread(Dos.THREAD(SwapProcess),SwapThread,FarADR(SwapStack[HIGH(SwapStack)]));
  2996. FOR i := 0 TO 4 DO
  2997. GraphI.Buffer[i] := FarNIL;
  2998. END;
  2999. InitCGA;
  3000. END Init;
  3001. (*%E _XTDDOS *)
  3002. BEGIN (*Initialization*)
  3003. (*%T _XTDDOS *)
  3004. (*%T _XTD *)
  3005. TSXLIB.InitInt10;
  3006. (*%E *)
  3007. (*%T AutoDetect *)
  3008. InitGraph();
  3009. (*%E *)
  3010. (*%F AutoDetect *)
  3011. InitCGA;
  3012. (*%E *)
  3013. Lib.Terminate(GraphTerminate, C);
  3014. FillState:=_GFILLINTERIOR;
  3015. ModeChanged := FALSE;
  3016. EGATable := EGATableType( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  3017. (*%E *)
  3018. (*%F _XTDDOS *)
  3019. (*%F _fcall *)
  3020. IO.WrStr('OS/2 Graphics Not Supported In This Model.');
  3021. IO.WrLn;
  3022. HALT;
  3023. (*%E *)
  3024. Init;
  3025. (*%E _XTDDOS *)
  3026. END Graph.
  3027.