COREGRAP.A 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * COREGRAP.A - low-level graphics routines *
  5. * *
  6. * COPYRIGHT (C) 1989..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. include "corelib.inc"
  11. FastIO = 0 (* Set to 0 prevents words being written to adjacent ports *)
  12. module CoreGraph
  13. (*****************************************************************************)
  14. segment _BSS(BSS, 28H)
  15. public __fstart : org 6
  16. segment _BSS(BSS, 28H)
  17. public __g_charout : org FarCodePtrSize
  18. public __g_strin : org FarCodePtrSize
  19. segment _DATA(DATA, 28H)
  20. extrn __gdummy
  21. (*%F NearCall *)
  22. public __get : dd __gdummy
  23. public __put : dd __gdummy
  24. public __hscan : dd __gdummy
  25. public __plot : dd __gdummy
  26. public __point : dd __gdummy
  27. public __hline : dd __gdummy
  28. public __line : dd __gdummy
  29. (*%E *)
  30. (*%T NearCall *)
  31. public __get : dw __gdummy
  32. public __put : dw __gdummy
  33. public __hscan : dw __gdummy
  34. public __plot : dw __gdummy
  35. public __point : dw __gdummy
  36. public __hline : dw __gdummy
  37. public __line : dw __gdummy
  38. (*%E *)
  39. segment _DATA(DATA, 28H)
  40. public __EGA_table : db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
  41. (*%T _DLL *)
  42. public __setvideomode_vector : org FarCodePtrSize
  43. public __initgraph_vector : org FarCodePtrSize
  44. (*%E *)
  45. segment _BSS(BSS, 28H)
  46. public __lastmode : org 2
  47. public __depth : org 2
  48. public __width : org 2
  49. public __current_video : org VideoConfigSize
  50. public __origin : org XYcoordSize
  51. public __clip_tl : org XYcoordSize
  52. public __clip_br : org XYcoordSize
  53. public __current_graph : org XYcoordSize
  54. public __text_tl : org RCcoordSize
  55. public __current_text : org RCcoordSize
  56. public __active_page : org 2
  57. public __visual_page : org 2
  58. public __page_size : org 2
  59. public __fgcolor : org 2
  60. public __mode_changed : org 2
  61. public __txcolor : org 2
  62. public __cursor_lock : org 2
  63. public __scr_attr : org 2
  64. public __current_mask : org FarDataPtrSize
  65. public __EGA64K : org 1
  66. public __cursor_state : org 1
  67. public __wrap_state : org 1
  68. public __display_state : org 1
  69. public __EGAtranslate : org 2
  70. public __bkcolor : org 4
  71. segment _DATA(DATA, 28H)
  72. public __text_br : dw 24, 79
  73. public __fill_mask : db 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH
  74. public __current_linestyle : dw 0FFFFH
  75. public __EGAScreen : dd 0A0000000H;
  76. public __EGAStartPlane : dw 3
  77. public __EGAPlaneShift : dw 1
  78. (**************************************************************************)
  79. section
  80. (*%F NearCall *)
  81. segment Graphics_TEXT(CODE,28H)
  82. (*%E *)
  83. (*%T NearCall *)
  84. segment _TEXT(CODE,28H)
  85. (*%E *)
  86. public $OutWord :
  87. out byte dx, al
  88. inc dx
  89. xchg ah, al
  90. out byte dx, al
  91. dec dx
  92. xchg ah, al
  93. ret 0
  94. (**************************************************************************)
  95. section
  96. (*%F NearCall *)
  97. segment Graphics_TEXT(CODE,28H)
  98. (*%E *)
  99. (*%T NearCall *)
  100. segment _TEXT(CODE,28H)
  101. (*%E *)
  102. segment _DATA(DATA, 28H)
  103. select _DATA
  104. extrn __page_size
  105. extrn __active_page
  106. (*%F NearCall *)
  107. select Graphics_TEXT
  108. (*%E *)
  109. (*%T NearCall *)
  110. select _TEXT
  111. (*%E *)
  112. public __pixeladdrEGA :
  113. BytesPerRow= -2
  114. mov cl, bl
  115. push dx
  116. mul word [bp][BytesPerRow]
  117. pop dx
  118. (*%T _XTD *)
  119. db 0C1H,0FBH,003H (*I shr bx, 3 *)
  120. (*%E *)
  121. (*%F _XTD *)
  122. shr bx, 1
  123. shr bx, 1
  124. shr bx, 1
  125. (*%E *)
  126. add bx, ax
  127. mov ax, [__active_page]
  128. mov dx, [__page_size]
  129. mul dx
  130. (*%T _XTD *)
  131. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  132. add bx, ax
  133. extrn __A000h
  134. mov ax, __A000h
  135. (*%E *)
  136. (*%F _XTD *)
  137. add ax, 0A000H
  138. (*%E *)
  139. mov es, ax
  140. and cl, 7
  141. xor cl, 7
  142. mov ah, 1
  143. ret 0
  144. (**************************************************************************)
  145. section
  146. (*%F NearCall *)
  147. segment Graphics_TEXT(CODE,28H)
  148. (*%E *)
  149. (*%T NearCall *)
  150. segment _TEXT(CODE,28H)
  151. (*%E *)
  152. segment _DATA(DATA, 28H)
  153. select _DATA
  154. extrn __page_size
  155. extrn __active_page
  156. extrn __width
  157. (*%F NearCall *)
  158. select Graphics_TEXT
  159. (*%E *)
  160. (*%T NearCall *)
  161. select _TEXT
  162. (*%E *)
  163. public __pixeladdrEGA2 :
  164. mov cl, bl
  165. push dx
  166. mul word [__width]
  167. (*%T _XTD *)
  168. db 0C1H,0FBH,003H (*I shr bx, 3 *)
  169. (*%E *)
  170. (*%F _XTD *)
  171. shr bx, 1
  172. shr bx, 1
  173. shr bx, 1
  174. (*%E *)
  175. add bx, ax
  176. mov ax, [__active_page]
  177. mov dx, [__page_size]
  178. mul dx
  179. (*%T _XTD *)
  180. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  181. add bx, ax
  182. extrn __A000h
  183. mov ax, __A000h
  184. (*%E *)
  185. (*%F _XTD *)
  186. add ax, 0A000H
  187. (*%E *)
  188. mov es, ax
  189. and cl, 7
  190. xor cl, 7
  191. mov ah, 1
  192. pop dx
  193. ret 0
  194. (**************************************************************************)
  195. section
  196. (*%F NearCall *)
  197. segment Graphics_TEXT(CODE,28H)
  198. (*%E *)
  199. (*%T NearCall *)
  200. segment _TEXT(CODE,28H)
  201. (*%E *)
  202. segment _DATA(DATA, 28H)
  203. select _DATA
  204. extrn __active_page
  205. extrn __page_size
  206. (*%F NearCall *)
  207. select Graphics_TEXT
  208. (*%E *)
  209. (*%T NearCall *)
  210. select _TEXT
  211. (*%E *)
  212. public __pixeladdrHerc :
  213. mov cl, bl
  214. shr ax, 1
  215. rcr bx, 1
  216. shr ax, 1
  217. rcr bx, 1
  218. shr bx, 1
  219. mov ah, 90
  220. mul ah
  221. add bx, ax
  222. mov ax, [__active_page]
  223. mov dx, [__page_size]
  224. mul dx
  225. (*%T _XTD *)
  226. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  227. add bx, ax
  228. extrn __B000h
  229. mov ax, __B000h
  230. (*%E *)
  231. (*%F _XTD *)
  232. add ax, 0B000H (* NB New Fix *)
  233. (*%E *)
  234. mov es, ax
  235. and cl, 7
  236. xor cl, 7
  237. mov ah, 1
  238. ret 0
  239. (**************************************************************************)
  240. section
  241. (*%F NearCall *)
  242. segment Graphics_TEXT(CODE,28H)
  243. (*%E *)
  244. (*%T NearCall *)
  245. segment _TEXT(CODE,28H)
  246. (*%E *)
  247. segment _DATA(DATA, 28H)
  248. (*%F NearCall *)
  249. select Graphics_TEXT
  250. (*%E *)
  251. (*%T NearCall *)
  252. select _TEXT
  253. (*%E *)
  254. calcAddress:
  255. shr ax, 1
  256. add bh, al
  257. sub al, al
  258. add bx, ax
  259. shr ax, 1
  260. shr ax, 1
  261. add bx, ax
  262. shr bx, 1
  263. shr bx, 1
  264. (*%T _XTD *)
  265. extrn __B800h
  266. mov ax, __B800h
  267. (*%E *)
  268. (*%F _XTD *)
  269. mov ax, 0B800H
  270. (*%E*)
  271. mov es, ax
  272. ret 0
  273. public __pixeladdr320x200 :
  274. mov cl, bl
  275. xchg ah, al
  276. call calcAddress
  277. mov ah, 3
  278. and cl, ah
  279. xor cl, ah
  280. shl cl, 1
  281. ret 0
  282. public __pixeladdr640x200 :
  283. mov cl, bl
  284. xchg ah, al
  285. shr bx, 1
  286. call calcAddress
  287. and cl, 7
  288. xor cl, 7
  289. mov ah, 1
  290. ret 0
  291. (**************************************************************************)
  292. section
  293. (*%F NearCall *)
  294. segment Graphics_TEXT(CODE,28H)
  295. (*%E *)
  296. (*%T NearCall *)
  297. segment _TEXT(CODE,28H)
  298. (*%E *)
  299. segment _DATA(DATA, 28H)
  300. select _DATA
  301. extrn __clip_tl
  302. extrn __clip_br
  303. (*%F NearCall *)
  304. select Graphics_TEXT
  305. (*%E *)
  306. (*%T NearCall *)
  307. select _TEXT
  308. (*%E *)
  309. public __hclip : (* ax = x1, bx = y1, cx = x2 *)
  310. cmp bx, [__clip_tl][graph_ycoord]
  311. jl hclipError
  312. cmp bx, [__clip_br][graph_ycoord]
  313. jg hclipError
  314. cmp ax, cx
  315. jle noSwap
  316. xchg ax, cx
  317. noSwap:
  318. mov di, [__clip_tl][graph_xcoord]
  319. mov si, [__clip_br][graph_xcoord]
  320. cmp cx, di
  321. jl hclipError
  322. cmp ax, si
  323. jg hclipError
  324. cmp ax, di
  325. jge leftOK
  326. mov ax, di
  327. leftOK:
  328. cmp cx, si
  329. jle rightOK
  330. mov cx, si
  331. rightOK:
  332. clc
  333. ret 0 (* ax = x1, bx = y1, cx = x2, cy clear *)
  334. hclipError:
  335. stc
  336. ret 0
  337. (**************************************************************************)
  338. section
  339. (*%F NearCall *)
  340. segment Graphics_TEXT(CODE,28H)
  341. (*%E *)
  342. (*%T NearCall *)
  343. segment _TEXT(CODE,28H)
  344. (*%E *)
  345. segment _DATA(DATA, 28H)
  346. xLtl = 1
  347. yLtl = 2
  348. xGbr = 4
  349. yGbr = 8
  350. extrn F$SgnDiv
  351. extrn N$SgnDiv
  352. select _DATA
  353. extrn __clip_tl
  354. extrn __clip_br
  355. (*%F NearCall *)
  356. select Graphics_TEXT
  357. (*%E *)
  358. (*%T NearCall *)
  359. select _TEXT
  360. (*%E *)
  361. public __lclip : (* ax = x1, bx = y1, cx = x2, dx = y2 *)
  362. push bp
  363. sub si, si (* set outcodes *)
  364. mov di, si
  365. mov bp, [__clip_tl][graph_xcoord]
  366. cmp ax, bp
  367. jge l1
  368. or di, xLtl
  369. l1:
  370. cmp cx, bp
  371. jge l2
  372. or si, xLtl
  373. l2:
  374. mov bp, [__clip_br][graph_xcoord]
  375. cmp ax, bp
  376. jle l3
  377. or di, xGbr
  378. l3:
  379. cmp cx, bp
  380. jle l4
  381. or si, xGbr
  382. l4:
  383. mov bp, [__clip_tl][graph_ycoord]
  384. cmp bx, bp
  385. jge l5
  386. or di, yLtl
  387. l5:
  388. cmp dx, bp
  389. jge l6
  390. or si, yLtl
  391. l6:
  392. mov bp, [__clip_br][graph_ycoord]
  393. cmp bx, bp
  394. jle l7
  395. or di, yGbr
  396. l7:
  397. cmp dx, bp
  398. jle l8
  399. or si, yGbr
  400. l8:
  401. clipLoop:
  402. or si, si
  403. jnz $NotZero
  404. or di, di
  405. jz near clipDone
  406. $NotZero:
  407. test si, di
  408. jnz near clipNoLine
  409. or di, di
  410. jnz noSwap2
  411. xchg ax, cx
  412. xchg bx, dx
  413. xchg di, si
  414. noSwap2:
  415. push dx
  416. test di, xLtl
  417. jz nC10
  418. mov bp, [__clip_tl][graph_xcoord]
  419. mov di, cx
  420. sub di, ax
  421. mov si, bp
  422. sub si, ax
  423. mov ax, dx
  424. sub ax, bx
  425. imul si (* result in ax, dx *)
  426. push dx
  427. push ax
  428. mov ax, di
  429. cwd
  430. push dx
  431. push ax
  432. (*%F NearCall *)
  433. call far F$SgnDiv
  434. (*%E *)
  435. (*%T NearCall *)
  436. call N$SgnDiv
  437. (*%E *)
  438. add bx, ax
  439. mov ax, bp
  440. jmp near nC13
  441. nC10:
  442. test di, yLtl
  443. jz nC11
  444. mov bp, [__clip_tl][graph_ycoord]
  445. mov di, dx
  446. sub di, bx
  447. mov si, bp
  448. sub si, bx
  449. push ax
  450. sub ax, cx
  451. neg ax
  452. imul si (* result in ax, dx *)
  453. push dx
  454. push ax
  455. mov ax, di
  456. cwd
  457. push dx
  458. push ax
  459. (*%F NearCall *)
  460. call far F$SgnDiv
  461. (*%E *)
  462. (*%T NearCall *)
  463. call N$SgnDiv
  464. (*%E *)
  465. pop dx
  466. add ax, dx
  467. mov bx, bp
  468. jmp nC13
  469. nC11:
  470. test di, xGbr
  471. jz nC12
  472. mov bp, [__clip_br][graph_xcoord]
  473. mov di, cx
  474. sub di, ax
  475. mov si, bp
  476. sub si, ax
  477. mov ax, dx
  478. sub ax, bx
  479. imul si (* result in ax, dx *)
  480. push dx
  481. push ax
  482. mov ax, di
  483. cwd
  484. push dx
  485. push ax
  486. (*%F NearCall *)
  487. call far F$SgnDiv
  488. (*%E *)
  489. (*%T NearCall *)
  490. call N$SgnDiv
  491. (*%E *)
  492. add bx, ax
  493. mov ax, bp
  494. jmp nC13
  495. nC12:
  496. test di, yGbr
  497. jz nC13
  498. mov bp, [__clip_br][graph_ycoord]
  499. mov di, dx
  500. sub di, bx
  501. mov si, bp
  502. sub si, bx
  503. push ax
  504. sub ax, cx
  505. neg ax
  506. imul si (* result in ax, dx *)
  507. push dx
  508. push ax
  509. mov ax, di
  510. cwd
  511. push dx
  512. push ax
  513. (*%F NearCall *)
  514. call far F$SgnDiv
  515. (*%E *)
  516. (*%T NearCall *)
  517. call N$SgnDiv
  518. (*%E *)
  519. pop dx
  520. add ax, dx
  521. mov bx, bp
  522. nC13:
  523. pop dx
  524. sub si, si (* set outcodes *)
  525. sub di, di
  526. mov bp, [__clip_tl][graph_xcoord]
  527. cmp ax, bp
  528. jge l11
  529. or di, xLtl
  530. l11:
  531. cmp cx, bp
  532. jge l12
  533. or si, xLtl
  534. l12:
  535. mov bp, [__clip_br][graph_xcoord]
  536. cmp ax, bp
  537. jle l13
  538. or di, xGbr
  539. l13:
  540. cmp cx, bp
  541. jle l14
  542. or si, xGbr
  543. l14:
  544. mov bp, [__clip_tl][graph_ycoord]
  545. cmp bx, bp
  546. jge l15
  547. or di, yLtl
  548. l15:
  549. cmp dx, bp
  550. jge l16
  551. or si, yLtl
  552. l16:
  553. mov bp, [__clip_br][graph_ycoord]
  554. cmp bx, bp
  555. jle l17
  556. or di, yGbr
  557. l17:
  558. cmp dx, bp
  559. jle l18
  560. or si, yGbr
  561. l18:
  562. jmp clipLoop
  563. clipDone:
  564. cmp ax, cx
  565. jle noSwap
  566. xchg bx, dx
  567. xchg ax, cx
  568. noSwap:
  569. pop bp
  570. clc
  571. ret 0
  572. clipNoLine:
  573. pop bp
  574. stc
  575. ret 0
  576. (**************************************************************************)
  577. section
  578. (*%F NearCall *)
  579. segment Graphics_TEXT(CODE,28H)
  580. (*%E *)
  581. (*%T NearCall *)
  582. segment _TEXT(CODE,28H)
  583. (*%E *)
  584. segment _DATA(DATA, 28H)
  585. extrn __hclip
  586. extrn __pixeladdr640x200
  587. select _DATA
  588. extrn __fgcolor
  589. select _DATA
  590. PropPix: db 0, 0FFH
  591. (*%F NearCall *)
  592. select Graphics_TEXT
  593. (*%E *)
  594. (*%T NearCall *)
  595. select _TEXT
  596. (*%E *)
  597. x1 = -2
  598. y1 = -4
  599. x2 = -6
  600. color = -8
  601. locals = 8
  602. public __CGA640HLine :
  603. push bp
  604. mov bp, sp
  605. sub sp, locals
  606. push di
  607. push si
  608. (*%F SameDS *)
  609. push ds
  610. mov si, _DATA
  611. mov ds, si
  612. (*%E *)
  613. call __hclip
  614. jc noDraw
  615. mov [bp][x1], ax
  616. mov [bp][y1], bx
  617. mov [bp][x2], cx
  618. mov [bp][color], dx
  619. xchg ax, bx
  620. call __pixeladdr640x200
  621. mov di, bx
  622. mov dh, ah
  623. not dh
  624. mov dl, 0FFH
  625. shl dh, cl
  626. not dh
  627. mov cx, [bp][x2]
  628. and cl, 7
  629. xor cl, 7
  630. shl dl, cl
  631. mov ax, [bp][x2]
  632. mov bx, [bp][x1]
  633. mov cl, 3
  634. shr ax, cl
  635. shr bx, cl
  636. mov cx, ax
  637. sub cx, bx
  638. mov bx, PropPix
  639. mov al, [bp][color]
  640. xlat
  641. or dh, dh
  642. js byteAligned
  643. or cx, cx
  644. jnz multiByte
  645. and dl, dh
  646. jmp singleByte
  647. multiByte:
  648. mov ah, al
  649. and ah, dh
  650. not dh
  651. and es:[di], dh
  652. or es:[di], ah
  653. inc di
  654. dec cx
  655. byteAligned:
  656. rep ; stosb
  657. singleByte:
  658. and al, dl
  659. not dl
  660. and es:[di], dl
  661. or es:[di], al
  662. noDraw:
  663. (*%F SameDS *)
  664. pop ds
  665. (*%E *)
  666. pop si
  667. pop di
  668. mov sp, bp
  669. pop bp
  670. (*%F NearCall *)
  671. ret far 0
  672. (*%E *)
  673. (*%T NearCall *)
  674. ret 0
  675. (*%E *)
  676. (**************************************************************************)
  677. section
  678. (*%F NearCall *)
  679. segment Graphics_TEXT(CODE,28H)
  680. (*%E *)
  681. (*%T NearCall *)
  682. segment _TEXT(CODE,28H)
  683. (*%E *)
  684. segment _DATA(DATA, 28H)
  685. extrn __hclip
  686. extrn __pixeladdr320x200
  687. select _DATA
  688. select _DATA
  689. PropPix: db 0, 55H, 0AAH, 0FFH
  690. (*%F NearCall *)
  691. select Graphics_TEXT
  692. (*%E *)
  693. (*%T NearCall *)
  694. select _TEXT
  695. (*%E *)
  696. x1 = -2
  697. y1 = -4
  698. x2 = -6
  699. color = -8
  700. locals = 8
  701. public __CGA320HLine :
  702. push bp
  703. mov bp, sp
  704. sub sp, locals
  705. push di
  706. push si
  707. (*%F SameDS *)
  708. push ds
  709. mov si, _DATA
  710. mov ds, si
  711. (*%E *)
  712. call __hclip
  713. jc noDraw
  714. mov [bp][x1], ax
  715. mov [bp][y1], bx
  716. mov [bp][x2], cx
  717. mov [bp][color], dx
  718. xchg ax, bx
  719. call __pixeladdr320x200
  720. mov di, bx
  721. mov dh, ah
  722. not dh
  723. mov dl, 0FFH
  724. shl dh, cl
  725. not dh
  726. mov cx, [bp][x2]
  727. and cl, 3
  728. xor cl, 3
  729. shl cl, 1
  730. shl dl, cl
  731. mov ax, [bp][x2]
  732. mov bx, [bp][x1]
  733. mov cl, 2
  734. shr ax, cl
  735. shr bx, cl
  736. mov cx, ax
  737. sub cx, bx
  738. mov bx, PropPix
  739. mov al, [bp][color]
  740. xlat
  741. or dh, dh
  742. js byteAligned
  743. or cx, cx
  744. jnz multiByte
  745. and dl, dh
  746. jmp singleByte
  747. multiByte:
  748. mov ah, al
  749. and ah, dh
  750. not dh
  751. and es:[di], dh
  752. or es:[di], ah
  753. inc di
  754. dec cx
  755. byteAligned:
  756. rep ; stosb
  757. singleByte:
  758. and al, dl
  759. not dl
  760. and es:[di], dl
  761. or es:[di], al
  762. noDraw:
  763. (*%F SameDS *)
  764. pop ds
  765. (*%E *)
  766. pop si
  767. pop di
  768. mov sp, bp
  769. pop bp
  770. (*%F NearCall *)
  771. ret far 0
  772. (*%E *)
  773. (*%T NearCall *)
  774. ret 0
  775. (*%E *)
  776. (**************************************************************************)
  777. section
  778. (*%F NearCall *)
  779. segment Graphics_TEXT(CODE,28H)
  780. (*%E *)
  781. (*%T NearCall *)
  782. segment _TEXT(CODE,28H)
  783. (*%E *)
  784. segment _DATA(DATA, 28H)
  785. extrn __hclip
  786. extrn __pixeladdrHerc
  787. select _DATA
  788. select _DATA
  789. PropPix: db 0, 0FFH
  790. (*%F NearCall *)
  791. select Graphics_TEXT
  792. (*%E *)
  793. (*%T NearCall *)
  794. select _TEXT
  795. (*%E *)
  796. x1 = -2
  797. y1 = -4
  798. x2 = -6
  799. color = -8
  800. locals = 8
  801. public __HercHLine :
  802. push bp
  803. mov bp, sp
  804. sub sp, locals
  805. push di
  806. push si
  807. (*%F SameDS *)
  808. push ds
  809. mov si, _DATA
  810. mov ds, si
  811. (*%E *)
  812. call __hclip
  813. jc noDraw
  814. mov [bp][x1], ax
  815. mov [bp][y1], bx
  816. mov [bp][x2], cx
  817. mov [bp][color], dx
  818. xchg ax, bx
  819. call __pixeladdrHerc
  820. mov di, bx
  821. mov dh, ah
  822. not dh
  823. mov dl, 0FFH
  824. shl dh, cl
  825. not dh
  826. mov cx, [bp][x2]
  827. and cl, 7
  828. xor cl, 7
  829. shl dl, cl
  830. mov ax, [bp][x2]
  831. mov bx, [bp][x1]
  832. mov cl, 3
  833. shr ax, cl
  834. shr bx, cl
  835. mov cx, ax
  836. sub cx, bx
  837. mov bx, PropPix
  838. mov al, [bp][color]
  839. xlat
  840. or dh, dh
  841. js byteAligned
  842. or cx, cx
  843. jnz multiByte
  844. and dl, dh
  845. jmp singleByte
  846. multiByte:
  847. mov ah, al
  848. and ah, dh
  849. not dh
  850. and es:[di], dh
  851. or es:[di], ah
  852. inc di
  853. dec cx
  854. byteAligned:
  855. rep ; stosb
  856. singleByte:
  857. and al, dl
  858. not dl
  859. and es:[di], dl
  860. or es:[di], al
  861. noDraw:
  862. (*%F SameDS *)
  863. pop ds
  864. (*%E *)
  865. pop si
  866. pop di
  867. mov sp, bp
  868. pop bp
  869. (*%F NearCall *)
  870. ret far 0
  871. (*%E *)
  872. (*%T NearCall *)
  873. ret 0
  874. (*%E *)
  875. (**************************************************************************)
  876. section
  877. (*%F NearCall *)
  878. segment Graphics_TEXT(CODE,28H)
  879. (*%E *)
  880. (*%T NearCall *)
  881. segment _TEXT(CODE,28H)
  882. (*%E *)
  883. segment _DATA(DATA, 28H)
  884. extrn __hclip
  885. extrn __pixeladdrEGA2
  886. extrn __EGAxlat
  887. select _DATA
  888. extrn __EGAtranslate
  889. (*%F NearCall *)
  890. select Graphics_TEXT
  891. (*%E *)
  892. (*%T NearCall *)
  893. select _TEXT
  894. (*%E *)
  895. x1 = -2
  896. y1 = -4
  897. x2 = -6
  898. EGAcolor = -8
  899. locals = 8
  900. public __EGAHLine :
  901. push bp
  902. mov bp, sp
  903. sub sp, locals
  904. push di
  905. push si
  906. push ds
  907. (*%F SameDS *)
  908. mov si, _DATA
  909. mov ds, si
  910. (*%E *)
  911. call __hclip
  912. jc near noDraw
  913. mov [bp][x1], ax
  914. mov [bp][y1], bx
  915. mov [bp][x2], cx
  916. mov ax, dx
  917. cmp byte [__EGAtranslate], 0
  918. jz notNeeded
  919. call __EGAxlat
  920. notNeeded:
  921. mov [bp][EGAcolor], ax
  922. mov dx, 3CEH
  923. mov ax, 5H
  924. (*%F FastIO *)
  925. extrn $OutWord
  926. call $OutWord
  927. (*%E *)
  928. (*%T FastIO *)
  929. out word dx, ax
  930. (*%E *)
  931. mov ah, [bp][EGAcolor]
  932. sub al, al
  933. (*%F FastIO *)
  934. call $OutWord
  935. (*%E *)
  936. (*%T FastIO *)
  937. out word dx, ax
  938. (*%E *)
  939. mov ax, 0FF01H
  940. (*%F FastIO *)
  941. call $OutWord
  942. (*%E *)
  943. (*%T FastIO *)
  944. out word dx, ax
  945. (*%E *)
  946. mov al, 3
  947. mov ah, 0
  948. (*%F FastIO *)
  949. call $OutWord
  950. (*%E *)
  951. (*%T FastIO *)
  952. out word dx, ax
  953. (*%E *)
  954. mov ax, [bp][y1]
  955. mov bx, [bp][x1]
  956. call __pixeladdrEGA2
  957. mov di, bx
  958. mov dh, ah
  959. not dh
  960. shl dh, cl
  961. not dh
  962. mov cx, [bp][x2]
  963. and cl, 7
  964. xor cl, 7
  965. mov dl, 0FFH
  966. shl dl, cl
  967. mov ax, [bp][x2]
  968. mov bx, [bp][x1]
  969. mov cl, 3
  970. shr ax, cl
  971. shr bx, cl
  972. mov cx, ax
  973. sub cx, bx
  974. mov bx, dx
  975. mov dx, 3CEH
  976. mov al, 8
  977. push es
  978. pop ds
  979. mov si, di
  980. or bh, bh
  981. js byteAligned
  982. or cx, cx
  983. jnz multiByte
  984. and bl, bh
  985. jmp singleByte
  986. multiByte:
  987. mov ah, bh
  988. (*%F FastIO *)
  989. call $OutWord
  990. (*%E *)
  991. (*%T FastIO *)
  992. out word dx, ax
  993. (*%E *)
  994. movsb
  995. dec cx
  996. byteAligned:
  997. mov ah, 0FFH
  998. (*%F FastIO *)
  999. call $OutWord
  1000. (*%E *)
  1001. (*%T FastIO *)
  1002. out word dx, ax
  1003. (*%E *)
  1004. rep ; movsb
  1005. singleByte:
  1006. mov ah, bl
  1007. (*%F FastIO *)
  1008. call $OutWord
  1009. (*%E *)
  1010. (*%T FastIO *)
  1011. out word dx, ax
  1012. (*%E *)
  1013. movsb
  1014. sub ax, ax
  1015. (*%F FastIO *)
  1016. call $OutWord
  1017. (*%E *)
  1018. (*%T FastIO *)
  1019. out word dx, ax
  1020. (*%E *)
  1021. inc ax
  1022. (*%F FastIO *)
  1023. call $OutWord
  1024. (*%E *)
  1025. (*%T FastIO *)
  1026. out word dx, ax
  1027. (*%E *)
  1028. mov al, 3
  1029. (*%F FastIO *)
  1030. call $OutWord
  1031. (*%E *)
  1032. (*%T FastIO *)
  1033. out word dx, ax
  1034. (*%E *)
  1035. mov ax, 0FF08H
  1036. (*%F FastIO *)
  1037. call $OutWord
  1038. (*%E *)
  1039. (*%T FastIO *)
  1040. out word dx, ax
  1041. (*%E *)
  1042. noDraw:
  1043. pop ds
  1044. pop si
  1045. pop di
  1046. mov sp, bp
  1047. pop bp
  1048. (*%F NearCall *)
  1049. ret far 0
  1050. (*%E *)
  1051. (*%T NearCall *)
  1052. ret 0
  1053. (*%E *)
  1054. (****************************************************************************)
  1055. section
  1056. (*%F NearCall *)
  1057. segment Graphics_TEXT(CODE,28H)
  1058. (*%E *)
  1059. (*%T NearCall *)
  1060. segment _TEXT(CODE,28H)
  1061. (*%E *)
  1062. segment _DATA(DATA, 28H)
  1063. extrn __pixeladdrEGA2
  1064. extrn __hclip
  1065. select _DATA
  1066. EGA2x1 : dw 0
  1067. EGA2y1 : dw 0
  1068. EGA2x2 : dw 0
  1069. EGA2color : dw 0
  1070. propPix : db 0, 0FFH
  1071. (*%F NearCall *)
  1072. select Graphics_TEXT
  1073. (*%E *)
  1074. (*%T NearCall *)
  1075. select _TEXT
  1076. (*%E *)
  1077. public __EGA2HLine :
  1078. push bp
  1079. mov bp, sp
  1080. push di
  1081. push si
  1082. (*%F SameDS *)
  1083. push ds
  1084. mov si, _DATA
  1085. mov ds, si
  1086. (*%E *)
  1087. call __hclip
  1088. jc noDraw
  1089. mov [EGA2x1], ax
  1090. mov [EGA2y1], bx
  1091. mov [EGA2x2], cx
  1092. mov [EGA2color], dx
  1093. mov ax, [EGA2y1]
  1094. mov bx, [EGA2x1]
  1095. call __pixeladdrEGA2
  1096. mov di, bx
  1097. mov dh, ah
  1098. not dh
  1099. mov dl, 0FFH
  1100. shl dh, cl
  1101. not dh
  1102. mov cx, [EGA2x2]
  1103. and cl, 7
  1104. xor cl, 7
  1105. shl dl, cl
  1106. mov ax, [EGA2x2]
  1107. mov bx, [EGA2x1]
  1108. mov cl, 3
  1109. shr ax, cl
  1110. shr bx, cl
  1111. mov cx, ax
  1112. sub cx, bx
  1113. mov bx, propPix
  1114. mov al, [EGA2color]
  1115. xlat
  1116. or dh, dh
  1117. js fullByte
  1118. or cx, cx
  1119. jnz multiByte
  1120. and dl, dh
  1121. jmp lastByte
  1122. multiByte:
  1123. mov ah, al
  1124. and ah, dh
  1125. not dh
  1126. and es:[di], dh
  1127. or es:[di], ah
  1128. inc di
  1129. dec cx
  1130. fullByte:
  1131. rep ; stosb
  1132. lastByte:
  1133. and al, dl
  1134. not dl
  1135. and es:[di], dl
  1136. or es:[di], al
  1137. noDraw:
  1138. (*%F SameDS *)
  1139. pop ds
  1140. (*%E *)
  1141. pop si
  1142. pop di
  1143. pop bp
  1144. (*%F NearCall *)
  1145. ret far 0
  1146. (*%E *)
  1147. (*%T NearCall *)
  1148. ret 0
  1149. (*%E *)
  1150. (**************************************************************************)
  1151. section
  1152. (*%F NearCall *)
  1153. segment Graphics_TEXT(CODE,28H)
  1154. (*%E *)
  1155. (*%T NearCall *)
  1156. segment _TEXT(CODE,28H)
  1157. (*%E *)
  1158. segment _DATA(DATA, 28H)
  1159. extrn __hclip
  1160. (*%F NearCall *)
  1161. select Graphics_TEXT
  1162. (*%E *)
  1163. (*%T NearCall *)
  1164. select _TEXT
  1165. (*%E *)
  1166. mask = frame
  1167. public __VGAHLine :
  1168. (*%T _DLLOVL *)
  1169. push bp
  1170. mov bp, sp
  1171. (*%E *)
  1172. push di
  1173. push si
  1174. (*%F SameDS *)
  1175. push ds
  1176. mov si, _DATA
  1177. mov ds, si
  1178. (*%E *)
  1179. call __hclip
  1180. jc noDraw
  1181. mov di, cx
  1182. sub di, ax
  1183. inc di
  1184. push dx
  1185. mov dx, 320
  1186. xchg bx, ax
  1187. mul dx
  1188. add ax, bx
  1189. mov cx, di
  1190. (*%T _XTD *)
  1191. extrn __A000h
  1192. mov bx, __A000h
  1193. (*%E *)
  1194. (*%F _XTD *)
  1195. mov bx, 0A000H
  1196. (*%E *)
  1197. mov es, bx
  1198. mov di, ax
  1199. pop ax
  1200. rep ; stosb
  1201. noDraw:
  1202. (*%F SameDS *)
  1203. pop ds
  1204. (*%E *)
  1205. pop si
  1206. pop di
  1207. (*%T _DLLOVL *)
  1208. pop bp
  1209. (*%E *)
  1210. (*%F NearCall *)
  1211. ret far 0
  1212. (*%E *)
  1213. (*%T NearCall *)
  1214. ret 0
  1215. (*%E *)
  1216. (**************************************************************************)
  1217. section
  1218. (*%F NearCall *)
  1219. segment Graphics_TEXT(CODE,28H)
  1220. (*%E *)
  1221. (*%T NearCall *)
  1222. segment _TEXT(CODE,28H)
  1223. (*%E *)
  1224. segment _DATA(DATA, 28H)
  1225. extrn __lclip
  1226. select _DATA
  1227. extrn __fgcolor
  1228. (*%F NearCall *)
  1229. select Graphics_TEXT
  1230. (*%E *)
  1231. (*%T NearCall *)
  1232. select _TEXT
  1233. (*%E *)
  1234. lstyle = frame
  1235. x1 = -2
  1236. y1 = -4
  1237. x2 = -6
  1238. y2 = -8
  1239. inc1 = -10
  1240. inc2 = -12
  1241. mask = -14
  1242. draw = -16
  1243. locals = 16
  1244. verticalLine:
  1245. mov ax, [bp][y1]
  1246. mov bx, [bp][y2]
  1247. mov cx, bx
  1248. sub cx, ax
  1249. jge Ps
  1250. neg cx
  1251. mov ax, bx
  1252. Ps:
  1253. inc cx
  1254. mov di, [bp][x1]
  1255. mov dx, 320
  1256. mul dx
  1257. add di, ax
  1258. dec si
  1259. mov al, [__fgcolor]
  1260. mov bx, [bp][lstyle]
  1261. cmp bx, -1
  1262. jne vertMask
  1263. vertLoop:
  1264. stosb
  1265. add di, si
  1266. loop vertLoop
  1267. jmp lineExit
  1268. vertMask:
  1269. mov dx, [bp][mask]
  1270. vertMLoop:
  1271. test dx, bx
  1272. jz noStore
  1273. stosb
  1274. cont:
  1275. add di, si
  1276. rol dx, 1
  1277. loop vertMLoop
  1278. jmp lineExit
  1279. noStore:
  1280. inc di
  1281. jmp cont
  1282. VGAhoriz:
  1283. mov ax, [bp][y1]
  1284. mov bx, [bp][x1]
  1285. mov dx, 320
  1286. mul dx
  1287. add ax, bx
  1288. mov di, ax
  1289. inc cx
  1290. mov al, [__fgcolor]
  1291. mov bx, [bp][lstyle]
  1292. mov dx, [bp][mask]
  1293. hLoop:
  1294. test bx, dx
  1295. jz noStore5
  1296. mov es:[di], al
  1297. noStore5:
  1298. inc di
  1299. rol dx, 1
  1300. loop hLoop
  1301. jmp lineExit
  1302. lowLine:
  1303. test dx, [bp][lstyle]
  1304. jz noStore2
  1305. stosb
  1306. cont2:
  1307. rol dx, 1
  1308. or si, si
  1309. jns lPos
  1310. add si, [bp][inc1]
  1311. loop lowLine
  1312. jmp lineExit
  1313. noStore2:
  1314. inc di
  1315. jmp cont2
  1316. lPos:
  1317. add si, [bp][inc2]
  1318. add di, bx
  1319. loop lowLine
  1320. jmp lineExit
  1321. highLine:
  1322. test dx, [bp][lstyle]
  1323. jz noStore3
  1324. stosb
  1325. cont3:
  1326. rol dx, 1
  1327. add di, bx
  1328. or si, si
  1329. jns hPos
  1330. add si, [bp][inc1]
  1331. dec di
  1332. loop highLine
  1333. jmp lineExit
  1334. noStore3:
  1335. inc di
  1336. jmp cont3
  1337. hPos:
  1338. add si, [bp][inc2]
  1339. loop highLine
  1340. lineExit:
  1341. (*%F SameDS *)
  1342. pop ds
  1343. (*%E *)
  1344. pop si
  1345. pop di
  1346. mov sp, bp
  1347. pop bp
  1348. (*%F NearCall *)
  1349. ret far 2
  1350. (*%E *)
  1351. (*%T NearCall *)
  1352. ret 2
  1353. (*%E *)
  1354. public __VGALine : (* ax = x1, bx = y1, cx = x2, dx = y2 *)
  1355. push bp
  1356. mov bp, sp
  1357. sub sp, locals
  1358. push di
  1359. push si
  1360. (*%F SameDS *)
  1361. push ds
  1362. mov si, _DATA
  1363. mov ds, si
  1364. (*%E *)
  1365. call __lclip
  1366. jc lineExit
  1367. mov [bp][x1], ax
  1368. mov [bp][y1], bx
  1369. mov [bp][x2], cx
  1370. mov [bp][y2], dx
  1371. (*%T _XTD *)
  1372. extrn __A000h
  1373. mov ax, __A000h
  1374. (*%E *)
  1375. (*%F _XTD *)
  1376. mov ax, 0A000H
  1377. (*%E *)
  1378. mov es, ax
  1379. mov si, 320
  1380. sub cx, [bp][x1]
  1381. jz verticalLine
  1382. push cx
  1383. mov cx, [bp][x1]
  1384. and cl, 15
  1385. mov bx, 1
  1386. shl bx, cl
  1387. mov [bp][mask], bx
  1388. pop cx
  1389. mov bx, [bp][y2]
  1390. sub bx, [bp][y1]
  1391. jz VGAhoriz
  1392. jns slopePos
  1393. neg bx
  1394. neg si
  1395. slopePos:
  1396. push si
  1397. mov word [bp][draw], lowLine
  1398. cmp bx, cx
  1399. jle useLowSlope
  1400. mov word [bp][draw], highLine
  1401. xchg bx, cx
  1402. useLowSlope:
  1403. shl bx, 1
  1404. mov [bp][inc1], bx
  1405. sub bx, cx
  1406. mov si, bx
  1407. sub bx, cx
  1408. mov [bp][inc2], bx
  1409. mov ax, [bp][y1]
  1410. mov di, [bp][x1]
  1411. mov dx, 320
  1412. mul dx
  1413. add di, ax
  1414. inc cx
  1415. pop bx
  1416. mov al, [__fgcolor]
  1417. mov dx, [bp][mask]
  1418. jmp [bp][draw]
  1419. (**************************************************************************)
  1420. section
  1421. (*%F NearCall *)
  1422. segment Graphics_TEXT(CODE,28H)
  1423. (*%E *)
  1424. (*%T NearCall *)
  1425. segment _TEXT(CODE,28H)
  1426. (*%E *)
  1427. segment _DATA(DATA, 28H)
  1428. (*%F NearCall *)
  1429. select Graphics_TEXT
  1430. (*%E *)
  1431. (*%T NearCall *)
  1432. select _TEXT
  1433. (*%E *)
  1434. public __VGAleftscan :
  1435. (*%T _DLLOVL *)
  1436. push bp
  1437. mov bp, sp
  1438. (*%E *)
  1439. push di
  1440. mov di, ax
  1441. (*%T _XTD *)
  1442. extrn __A000h
  1443. mov ax, __A000h
  1444. (*%E *)
  1445. (*%F _XTD *)
  1446. mov ax, 0A000H
  1447. (*%E *)
  1448. mov es, ax
  1449. mov al, bl
  1450. scanLoop:
  1451. dec di
  1452. dec dx
  1453. cmp al, es:[di]
  1454. je scanDone
  1455. cmp dx, cx
  1456. jge scanLoop
  1457. scanDone:
  1458. mov ax, dx
  1459. inc ax
  1460. pop di
  1461. (*%T _DLLOVL *)
  1462. pop bp
  1463. (*%E *)
  1464. (*%F NearCall *)
  1465. ret far 0
  1466. (*%E *)
  1467. (*%T NearCall *)
  1468. ret 0
  1469. (*%E *)
  1470. (**************************************************************************)
  1471. section
  1472. (*%F NearCall *)
  1473. segment Graphics_TEXT(CODE,28H)
  1474. (*%E *)
  1475. (*%T NearCall *)
  1476. segment _TEXT(CODE,28H)
  1477. (*%E *)
  1478. segment _DATA(DATA, 28H)
  1479. (*%F NearCall *)
  1480. select Graphics_TEXT
  1481. (*%E *)
  1482. (*%T NearCall *)
  1483. select _TEXT
  1484. (*%E *)
  1485. public __VGArightscan :
  1486. (*%T _DLLOVL *)
  1487. push bp
  1488. mov bp, sp
  1489. (*%E *)
  1490. push di
  1491. mov di, ax
  1492. (*%T _XTD *)
  1493. extrn __A000h
  1494. mov ax, __A000h
  1495. (*%E *)
  1496. (*%F _XTD *)
  1497. mov ax, 0A000H
  1498. (*%E *)
  1499. mov es, ax
  1500. mov al, bl
  1501. scanLoop:
  1502. inc di
  1503. inc dx
  1504. cmp al, es:[di]
  1505. je scanDone
  1506. cmp dx, cx
  1507. jle scanLoop
  1508. scanDone:
  1509. mov ax, dx
  1510. dec ax
  1511. pop di
  1512. (*%T _DLLOVL *)
  1513. pop bp
  1514. (*%E *)
  1515. (*%F NearCall *)
  1516. ret far 0
  1517. (*%E *)
  1518. (*%T NearCall *)
  1519. ret 0
  1520. (*%E *)
  1521. (**************************************************************************)
  1522. section
  1523. (*%F NearCall *)
  1524. segment Graphics_TEXT(CODE,28H)
  1525. (*%E *)
  1526. (*%T NearCall *)
  1527. segment _TEXT(CODE,28H)
  1528. (*%E *)
  1529. segment _DATA(DATA, 28H)
  1530. extrn __pixeladdr640x200
  1531. extrn __lclip
  1532. select _DATA
  1533. extrn __fgcolor
  1534. L640x1 : dw 0
  1535. L640y1 : dw 0
  1536. L640x2 : dw 0
  1537. L640y2 : dw 0
  1538. L640inc1 : dw 0
  1539. L640inc2 : dw 0
  1540. L640leafinc : dw 0
  1541. L640draw : dw 0
  1542. L640lstyle : dw 0
  1543. L640buffer : dw 0
  1544. (*%F NearCall *)
  1545. select Graphics_TEXT
  1546. (*%E *)
  1547. (*%T NearCall *)
  1548. select _TEXT
  1549. (*%E *)
  1550. L640verticalLine:
  1551. mov ax, [L640y1]
  1552. mov bx, [L640y2]
  1553. mov cx, bx
  1554. sub cx, ax
  1555. jge L640dyPos
  1556. neg cx
  1557. mov ax, bx
  1558. L640dyPos:
  1559. inc cx
  1560. mov bx, [L640x1]
  1561. push cx
  1562. call __pixeladdr640x200
  1563. mov al, [__fgcolor]
  1564. shl ax, cl
  1565. not ah
  1566. pop cx
  1567. test bx, si
  1568. jz L640int1
  1569. xchg si, di
  1570. L640int1:
  1571. or al, al
  1572. jz L640pixVal0
  1573. L640vertLoop:
  1574. test bp, [L640lstyle]
  1575. jz L640noStore1
  1576. or es:[bx], al
  1577. L640noStore1:
  1578. rol bp, 1
  1579. add bx, si
  1580. xchg si, di
  1581. loop L640vertLoop
  1582. jmp near L640lineExit
  1583. L640pixVal0:
  1584. test bp, [L640lstyle]
  1585. jz L640noStore2
  1586. and es:[bx], ah
  1587. L640noStore2:
  1588. rol bp, 1
  1589. add bx, si
  1590. xchg si, di
  1591. loop L640pixVal0
  1592. jmp near L640lineExit
  1593. L640horizLine:
  1594. mov ax, [L640y1]
  1595. mov bx, [L640x1]
  1596. call __pixeladdr640x200
  1597. mov al, [__fgcolor]
  1598. shl ax, cl
  1599. mov dx, ax
  1600. not dh
  1601. mov cx, [L640x2]
  1602. sub cx, [L640x1]
  1603. inc cx
  1604. mov di, [L640lstyle]
  1605. mov si, -1
  1606. L640horizSlope:
  1607. mov ah, es:[bx]
  1608. L640horizLoop:
  1609. and ah, dh
  1610. test bp, di
  1611. jz L640noStore5
  1612. or ah, dl
  1613. L640noStore5:
  1614. rol bp, 1
  1615. ror dl, 1
  1616. ror dh, 1
  1617. jnc L640maskLeft5
  1618. loop L640horizLoop
  1619. mov es:[bx], ah
  1620. jmp near L640lineExit
  1621. L640maskLeft5:
  1622. mov es:[bx], ah
  1623. inc bx
  1624. dec cx
  1625. or si, si
  1626. js notYet
  1627. mov [si][L640buffer], ah
  1628. notYet:
  1629. cmp si, 1
  1630. jz storeBytes
  1631. inc si
  1632. notEnough:
  1633. jcxz near L640lineExit
  1634. jmp L640horizSlope
  1635. storeBytes:
  1636. mov si, cx
  1637. and si, 7
  1638. push si
  1639. shr cx, 1
  1640. shr cx, 1
  1641. shr cx, 1
  1642. jcxz abort
  1643. sub si, si
  1644. sbLoop:
  1645. mov ah, [si][L640buffer]
  1646. mov es:[bx], ah
  1647. inc si
  1648. inc bx
  1649. and si, 2
  1650. loop sbLoop
  1651. abort:
  1652. pop cx
  1653. jmp notEnough
  1654. L640lowSlope:
  1655. mov ah, es:[bx]
  1656. L640lowLoop:
  1657. and ah, dh
  1658. test bp, [L640lstyle]
  1659. jz L640noStore3
  1660. or ah, dl
  1661. L640noStore3:
  1662. rol bp, 1
  1663. ror dl, 1
  1664. ror dh, 1
  1665. jnc L640maskLeft
  1666. or di, di
  1667. jns L640dPos
  1668. add di, [L640inc1]
  1669. loop L640lowLoop
  1670. mov es:[bx], ah
  1671. jmp L640lineExit
  1672. L640dPos:
  1673. add di, [L640inc2]
  1674. mov es:[bx], ah
  1675. add bx, si
  1676. xchg si, [L640leafinc]
  1677. loop L640lowSlope
  1678. jmp L640lineExit
  1679. L640maskLeft:
  1680. mov es:[bx], ah
  1681. inc bx
  1682. or di, di
  1683. jns L640dPos2
  1684. add di, [L640inc1]
  1685. loop L640lowSlope
  1686. jmp L640lineExit
  1687. L640dPos2:
  1688. add di, [L640inc2]
  1689. add bx, si
  1690. xchg si, [L640leafinc]
  1691. loop L640lowSlope
  1692. jmp L640lineExit
  1693. L640highSlope:
  1694. and es:[bx], dh
  1695. test bp, [L640lstyle]
  1696. jz L640noStore4
  1697. or es:[bx], dl
  1698. L640noStore4:
  1699. rol bp, 1
  1700. add bx, si
  1701. xchg si, [L640leafinc]
  1702. or di, di
  1703. jns L640dPos3
  1704. add di, [L640inc1]
  1705. loop L640highSlope
  1706. jmp L640lineExit
  1707. L640dPos3:
  1708. add di, [L640inc2]
  1709. ror dl ,1
  1710. ror dh, 1
  1711. cmc
  1712. adc bx, 0
  1713. loop L640highSlope
  1714. L640lineExit:
  1715. (*%F SameDS *)
  1716. pop ds
  1717. (*%E *)
  1718. pop si
  1719. pop di
  1720. pop bp
  1721. (*%F NearCall *)
  1722. ret far 2
  1723. (*%E *)
  1724. (*%T NearCall *)
  1725. ret 2
  1726. (*%E *)
  1727. public __CGA640Line :
  1728. push bp
  1729. mov bp, sp
  1730. push di
  1731. push si
  1732. (*%F SameDS *)
  1733. push ds
  1734. mov si, _DATA
  1735. mov ds, si
  1736. (*%E *)
  1737. call __lclip
  1738. jc L640lineExit
  1739. mov [L640x1], ax
  1740. mov [L640y1], bx
  1741. mov [L640x2], cx
  1742. mov [L640y2], dx
  1743. mov cx, [bp][frame]
  1744. mov [L640lstyle], cx
  1745. mov cx, ax
  1746. and cl, 15
  1747. mov bp, 1
  1748. shl bp, cl
  1749. mov si, 2000H
  1750. mov di, 80-2000H
  1751. mov cx, [L640x2]
  1752. sub cx, ax
  1753. jz L640verticalLine
  1754. mov bx, [L640y2]
  1755. sub bx, [L640y1]
  1756. je L640horizLine
  1757. jns L640posInc
  1758. neg bx
  1759. xchg si, di
  1760. neg si
  1761. neg di
  1762. L640posInc:
  1763. mov [L640leafinc], di
  1764. mov word [L640draw], L640lowSlope
  1765. cmp bx, cx
  1766. jle L640useLowSlope
  1767. mov word [L640draw], L640highSlope
  1768. xchg bx, cx
  1769. L640useLowSlope:
  1770. shl bx, 1
  1771. mov [L640inc1], bx
  1772. sub bx, cx
  1773. mov di, bx
  1774. sub bx, cx
  1775. mov [L640inc2], bx
  1776. push cx
  1777. mov bx, [L640x1]
  1778. mov ax, [L640y1]
  1779. call __pixeladdr640x200
  1780. mov al, [__fgcolor]
  1781. shl ax, cl
  1782. mov dx, ax
  1783. not dh
  1784. pop cx
  1785. inc cx
  1786. test bx, 2000H
  1787. jz L640iLeave0
  1788. xchg si, [L640leafinc]
  1789. L640iLeave0:
  1790. jmp [L640draw]
  1791. (**************************************************************************)
  1792. section
  1793. extrn __pixeladdr320x200
  1794. (*%F NearCall *)
  1795. segment Graphics_TEXT(CODE,28H)
  1796. (*%E *)
  1797. (*%T NearCall *)
  1798. segment _TEXT(CODE,28H)
  1799. (*%E *)
  1800. segment _DATA(DATA, 28H)
  1801. extrn __lclip
  1802. select _DATA
  1803. extrn __fgcolor
  1804. L320x1 : dw 0
  1805. L320y1 : dw 0
  1806. L320x2 : dw 0
  1807. L320y2 : dw 0
  1808. L320inc1 : dw 0
  1809. L320inc2 : dw 0
  1810. L320leafinc : dw 0
  1811. L320draw : dw 0
  1812. L320lstyle : dw 0
  1813. L320buffer : dw 0, 0
  1814. (*%F NearCall *)
  1815. select Graphics_TEXT
  1816. (*%E *)
  1817. (*%T NearCall *)
  1818. select _TEXT
  1819. (*%E *)
  1820. L320verticalLine:
  1821. mov ax, [L320y1]
  1822. mov bx, [L320y2]
  1823. mov cx, bx
  1824. sub cx, ax
  1825. jge L320dyPos
  1826. neg cx
  1827. mov ax, bx
  1828. L320dyPos:
  1829. inc cx
  1830. mov bx, [L320x1]
  1831. push cx
  1832. call __pixeladdr320x200
  1833. mov al, [__fgcolor]
  1834. shl ax, cl
  1835. not ah
  1836. pop cx
  1837. test bx, si
  1838. jz L320vertLoop
  1839. xchg si, di
  1840. L320vertLoop:
  1841. and es:[bx], ah
  1842. test bp, [L320lstyle]
  1843. jz L320noStore1
  1844. or es:[bx], al
  1845. L320noStore1:
  1846. rol bp, 1
  1847. add bx, si
  1848. xchg si, di
  1849. loop L320vertLoop
  1850. jmp near L320lineExit
  1851. L320horizLine:
  1852. mov ax, [L320y1]
  1853. mov bx, [L320x1]
  1854. call __pixeladdr320x200
  1855. mov al, [__fgcolor]
  1856. shl ax, cl
  1857. mov dx, ax
  1858. not dh
  1859. mov cx, [L320x2]
  1860. sub cx, [L320x1]
  1861. inc cx
  1862. mov di, [L320lstyle]
  1863. mov si, -1
  1864. L320horizSlope:
  1865. mov ah, es:[bx]
  1866. L320horizLoop:
  1867. and ah, dh
  1868. test bp, di
  1869. jz L320noStore5
  1870. or ah, dl
  1871. L320noStore5:
  1872. rol bp, 1
  1873. ror dl, 1
  1874. ror dl, 1
  1875. ror dh, 1
  1876. ror dh, 1
  1877. jnc L320maskLeft5
  1878. loop L320horizLoop
  1879. mov es:[bx], ah
  1880. jmp near L320lineExit
  1881. L320maskLeft5:
  1882. mov es:[bx], ah
  1883. inc bx
  1884. dec cx
  1885. or si, si
  1886. js notYet
  1887. mov [si][L320buffer], ah
  1888. notYet:
  1889. cmp si, 3
  1890. jz storeBytes
  1891. inc si
  1892. notEnough:
  1893. jcxz near L320lineExit
  1894. jmp L320horizSlope
  1895. storeBytes:
  1896. mov si, cx
  1897. and si, 3
  1898. push si
  1899. shr cx, 1
  1900. shr cx, 1
  1901. jcxz abort
  1902. sub si, si
  1903. sbLoop:
  1904. mov ah, [si][L320buffer]
  1905. mov es:[bx], ah
  1906. inc si
  1907. inc bx
  1908. and si, 3
  1909. loop sbLoop
  1910. abort:
  1911. pop cx
  1912. jmp notEnough
  1913. L320lowSlope:
  1914. mov ah, es:[bx]
  1915. L320lowLoop:
  1916. and ah, dh
  1917. test bp, [L320lstyle]
  1918. jz L320noStore3
  1919. or ah, dl
  1920. L320noStore3:
  1921. rol bp, 1
  1922. ror dl, 1
  1923. ror dl, 1
  1924. ror dh, 1
  1925. ror dh, 1
  1926. jnc L320maskLeft
  1927. or di, di
  1928. jns L320dPos
  1929. add di, [L320inc1]
  1930. loop L320lowLoop
  1931. mov es:[bx], ah
  1932. jmp L320lineExit
  1933. L320dPos:
  1934. add di, [L320inc2]
  1935. mov es:[bx], ah
  1936. add bx, si
  1937. xchg si, [L320leafinc]
  1938. loop L320lowSlope
  1939. jmp L320lineExit
  1940. L320maskLeft:
  1941. mov es:[bx], ah
  1942. inc bx
  1943. or di, di
  1944. jns L320dPos2
  1945. add di, [L320inc1]
  1946. loop L320lowSlope
  1947. jmp L320lineExit
  1948. L320dPos2:
  1949. add di, [L320inc2]
  1950. add bx, si
  1951. xchg si, [L320leafinc]
  1952. loop L320lowSlope
  1953. jmp L320lineExit
  1954. L320highSlope:
  1955. and es:[bx], dh
  1956. test bp, [L320lstyle]
  1957. jz L320noStore4
  1958. or es:[bx], dl
  1959. L320noStore4:
  1960. rol bp, 1
  1961. add bx, si
  1962. xchg si, [L320leafinc]
  1963. or di, di
  1964. jns L320dPos3
  1965. add di, [L320inc1]
  1966. loop L320highSlope
  1967. jmp L320lineExit
  1968. L320dPos3:
  1969. add di, [L320inc2]
  1970. ror dl ,1
  1971. ror dl ,1
  1972. ror dh, 1
  1973. ror dh, 1
  1974. cmc
  1975. adc bx, 0
  1976. loop L320highSlope
  1977. L320lineExit:
  1978. (*%F SameDS *)
  1979. pop ds
  1980. (*%E *)
  1981. pop si
  1982. pop di
  1983. pop bp
  1984. (*%F NearCall *)
  1985. ret far 2
  1986. (*%E *)
  1987. (*%T NearCall *)
  1988. ret 2
  1989. (*%E *)
  1990. public __CGA320Line :
  1991. push bp
  1992. mov bp, sp
  1993. push di
  1994. push si
  1995. (*%F SameDS *)
  1996. push ds
  1997. mov si, _DATA
  1998. mov ds, si
  1999. (*%E *)
  2000. call __lclip
  2001. jc L320lineExit
  2002. mov [L320x1], ax
  2003. mov [L320y1], bx
  2004. mov [L320x2], cx
  2005. mov [L320y2], dx
  2006. mov cx, [bp][frame]
  2007. mov [L320lstyle], cx
  2008. mov cx, ax
  2009. and cl, 15
  2010. mov bp, 1
  2011. shl bp, cl
  2012. mov si, 2000H
  2013. mov di, 80-2000H
  2014. mov cx, [L320x2]
  2015. sub cx, ax
  2016. jz L320verticalLine
  2017. mov bx, [L320y2]
  2018. sub bx, [L320y1]
  2019. je L320horizLine
  2020. jns L320posInc
  2021. neg bx
  2022. xchg si, di
  2023. neg si
  2024. neg di
  2025. L320posInc:
  2026. mov [L320leafinc], di
  2027. mov word [L320draw], L320lowSlope
  2028. cmp bx, cx
  2029. jle L320useLowSlope
  2030. mov word [L320draw], L320highSlope
  2031. xchg bx, cx
  2032. L320useLowSlope:
  2033. shl bx, 1
  2034. mov [L320inc1], bx
  2035. sub bx, cx
  2036. mov di, bx
  2037. sub bx, cx
  2038. mov [L320inc2], bx
  2039. push cx
  2040. mov bx, [L320x1]
  2041. mov ax, [L320y1]
  2042. call __pixeladdr320x200
  2043. mov al, [__fgcolor]
  2044. shl ax, cl
  2045. mov dx, ax
  2046. not dh
  2047. pop cx
  2048. inc cx
  2049. test bx, 2000H
  2050. jz L320iLeave0
  2051. xchg si, [L320leafinc]
  2052. L320iLeave0:
  2053. jmp [L320draw]
  2054. (**************************************************************************)
  2055. section
  2056. (*%F NearCall *)
  2057. segment Graphics_TEXT(CODE,28H)
  2058. (*%E *)
  2059. (*%T NearCall *)
  2060. segment _TEXT(CODE,28H)
  2061. (*%E *)
  2062. segment _DATA(DATA, 28H)
  2063. extrn __pixeladdrHerc
  2064. extrn __lclip
  2065. select _DATA
  2066. extrn __fgcolor
  2067. Hercx1 : dw 0
  2068. Hercy1 : dw 0
  2069. Hercx2 : dw 0
  2070. Hercy2 : dw 0
  2071. Hercinc1 : dw 0
  2072. Hercinc2 : dw 0
  2073. Hercleafinc : dw 0
  2074. Hercdraw : dw 0
  2075. Herclstyle : dw 0
  2076. (*%F NearCall *)
  2077. select Graphics_TEXT
  2078. (*%E *)
  2079. (*%T NearCall *)
  2080. select _TEXT
  2081. (*%E *)
  2082. HERCverticalLine:
  2083. mov ax, [Hercy1]
  2084. mov bx, [Hercy2]
  2085. mov cx, bx
  2086. sub cx, ax
  2087. jge HERCdyPos
  2088. neg cx
  2089. mov ax, bx
  2090. HERCdyPos:
  2091. inc cx
  2092. mov bx, [Hercx1]
  2093. push cx
  2094. call __pixeladdrHerc
  2095. mov al, [__fgcolor]
  2096. shl ax, cl
  2097. not ah
  2098. pop cx
  2099. or al, al
  2100. jz HERCpixVal0
  2101. HERCvertLoop:
  2102. test bp, [Herclstyle]
  2103. jz HERCnoStore1
  2104. or es:[bx], al
  2105. HERCnoStore1:
  2106. rol bp, 1
  2107. add bx, si
  2108. jns iLeave2
  2109. add bx, di
  2110. iLeave2:
  2111. loop HERCvertLoop
  2112. jmp near HERClineExit
  2113. HERCpixVal0:
  2114. test bp, [Herclstyle]
  2115. jz HERCnoStore2
  2116. and es:[bx], ah
  2117. HERCnoStore2:
  2118. rol bp, 1
  2119. add bx, si
  2120. jns iLeave3
  2121. add bx, di
  2122. iLeave3:
  2123. loop HERCpixVal0
  2124. jmp near HERClineExit
  2125. HERClowSlope:
  2126. mov ah, es:[bx]
  2127. HERClowLoop:
  2128. and ah, dh
  2129. test bp, [Herclstyle]
  2130. jz HERCnoStore3
  2131. or ah, dl
  2132. HERCnoStore3:
  2133. rol bp, 1
  2134. ror dl, 1
  2135. ror dh, 1
  2136. jnc HERCmaskLeft
  2137. or di, di
  2138. jns HERCdPos
  2139. add di, [Hercinc1]
  2140. loop HERClowLoop
  2141. mov es:[bx], ah
  2142. jmp HERClineExit
  2143. HERCdPos:
  2144. add di, [Hercinc2]
  2145. mov es:[bx], ah
  2146. add bx, si
  2147. jns HERCnotLastInt
  2148. add bx, [Hercleafinc]
  2149. HERCnotLastInt:
  2150. loop HERClowSlope
  2151. jmp HERClineExit
  2152. HERCmaskLeft:
  2153. mov es:[bx], ah
  2154. inc bx
  2155. or di, di
  2156. jns HERCdPos2
  2157. add di, [Hercinc1]
  2158. loop HERClowSlope
  2159. jmp HERClineExit
  2160. HERCdPos2:
  2161. add di, [Hercinc2]
  2162. add bx, si
  2163. jns HERCnotLastInt2
  2164. add bx, [Hercleafinc]
  2165. HERCnotLastInt2:
  2166. loop HERClowSlope
  2167. jmp HERClineExit
  2168. HERChighSlope:
  2169. and es:[bx], dh
  2170. test bp, [Herclstyle]
  2171. jz HERCnoStore4
  2172. or es:[bx], dl
  2173. HERCnoStore4:
  2174. rol bp, 1
  2175. add bx, si
  2176. jns HERCnotLastInt3
  2177. add bx, [Hercleafinc]
  2178. HERCnotLastInt3:
  2179. or di, di
  2180. jns HERCdPos3
  2181. add di, [Hercinc1]
  2182. loop HERChighSlope
  2183. jmp HERClineExit
  2184. HERCdPos3:
  2185. add di, [Hercinc2]
  2186. ror dl ,1
  2187. ror dh, 1
  2188. cmc
  2189. adc bx, 0
  2190. loop HERChighSlope
  2191. HERClineExit:
  2192. (*%F SameDS *)
  2193. pop ds
  2194. (*%E *)
  2195. pop si
  2196. pop di
  2197. pop bp
  2198. (*%F NearCall *)
  2199. ret far 2
  2200. (*%E *)
  2201. (*%T NearCall *)
  2202. ret 2
  2203. (*%E *)
  2204. public __HercLine :
  2205. push bp
  2206. mov bp, sp
  2207. push di
  2208. push si
  2209. (*%F SameDS *)
  2210. push ds
  2211. mov si, _DATA
  2212. mov ds, si
  2213. (*%E *)
  2214. call __lclip
  2215. jc HERClineExit
  2216. mov [Hercx1], ax
  2217. mov [Hercy1], bx
  2218. mov [Hercx2], cx
  2219. mov [Hercy2], dx
  2220. mov cx, [bp][frame]
  2221. mov [Herclstyle], cx
  2222. mov cx, ax
  2223. and cl, 15
  2224. mov bp, 1
  2225. shl bp, cl
  2226. mov si, 2000H
  2227. mov di, 90-8000H
  2228. mov cx, [Hercx2]
  2229. sub cx, ax
  2230. jz HERCverticalLine
  2231. mov bx, [Hercy2]
  2232. sub bx, [Hercy1]
  2233. jns HERCposInc
  2234. neg bx
  2235. neg si
  2236. neg di
  2237. HERCposInc:
  2238. mov [Hercleafinc], di
  2239. mov word [Hercdraw], HERClowSlope
  2240. cmp bx, cx
  2241. jle HERCuseLowSlope
  2242. mov word [Hercdraw], HERChighSlope
  2243. xchg bx, cx
  2244. HERCuseLowSlope:
  2245. shl bx, 1
  2246. mov [Hercinc1], bx
  2247. sub bx, cx
  2248. mov di, bx
  2249. sub bx, cx
  2250. mov [Hercinc2], bx
  2251. push cx
  2252. mov bx, [Hercx1]
  2253. mov ax, [Hercy1]
  2254. call __pixeladdrHerc
  2255. mov al, [__fgcolor]
  2256. shl ax, cl
  2257. mov dx, ax
  2258. not dh
  2259. pop cx
  2260. inc cx
  2261. jmp [Hercdraw]
  2262. (**************************************************************************)
  2263. section
  2264. (*%F NearCall *)
  2265. segment Graphics_TEXT(CODE,28H)
  2266. (*%E *)
  2267. (*%T NearCall *)
  2268. segment _TEXT(CODE,28H)
  2269. (*%E *)
  2270. segment _DATA(DATA, 28H)
  2271. extrn __pixeladdrEGA2
  2272. extrn __EGAxlat
  2273. extrn __lclip
  2274. select _DATA
  2275. extrn __fgcolor
  2276. extrn __width
  2277. extrn __EGAtranslate
  2278. EGAx1 : dw 0
  2279. EGAy1 : dw 0
  2280. EGAx2 : dw 0
  2281. EGAy2 : dw 0
  2282. EGAinc1 : dw 0
  2283. EGAinc2 : dw 0
  2284. EGAvertinc1 : dw 0
  2285. EGAdraw : dw 0
  2286. EGAcolor : dw 0
  2287. EGAlstyle : dw 0
  2288. EGAmaskbit : dw 0
  2289. (*%F NearCall *)
  2290. select Graphics_TEXT
  2291. (*%E *)
  2292. (*%T NearCall *)
  2293. select _TEXT
  2294. (*%E *)
  2295. out byte dx, ax
  2296. EGAverticalLine:
  2297. mov cx, [EGAx1]
  2298. and cl, 15
  2299. mov bp, 1
  2300. shl bp, cl
  2301. mov ax, [EGAy1]
  2302. mov bx, [EGAy2]
  2303. mov cx, bx
  2304. sub cx, ax
  2305. jge EGAdPos
  2306. neg cx
  2307. mov ax, bx
  2308. EGAdPos:
  2309. inc cx
  2310. mov bx, [EGAx1]
  2311. push cx
  2312. call __pixeladdrEGA2
  2313. shl ah, cl
  2314. mov al, 8
  2315. (*%F FastIO *)
  2316. extrn $OutWord
  2317. call $OutWord
  2318. (*%E *)
  2319. (*%T FastIO *)
  2320. out word dx, ax
  2321. (*%E *)
  2322. pop cx
  2323. mov dx, [EGAlstyle]
  2324. EGAvertLoop:
  2325. test bp, dx
  2326. jz EGAnoStore1
  2327. or byte es:[bx], 0FFH
  2328. EGAnoStore1:
  2329. rol bp, 1
  2330. add bx, si
  2331. loop EGAvertLoop
  2332. jmp near EGAlineExit
  2333. EGAlowSlope:
  2334. mov bp, [EGAinc1]
  2335. EGAlowSlopeL:
  2336. sub ah, ah
  2337. EGAlowLoop:
  2338. or ah, bl
  2339. ror bl, 1
  2340. jc EGAmaskLeft
  2341. or si, si
  2342. jns EGAdPos1
  2343. add si, bp
  2344. loop EGAlowLoop
  2345. (*%F FastIO *)
  2346. call $OutWord
  2347. (*%E *)
  2348. (*%T FastIO *)
  2349. out word dx, ax
  2350. (*%E *)
  2351. or byte es:[di], 0FFH
  2352. jmp near EGAlineExit
  2353. EGAdPos1:
  2354. add si, [EGAinc2]
  2355. (*%F FastIO *)
  2356. extrn $OutWord
  2357. call $OutWord
  2358. (*%E *)
  2359. (*%T FastIO *)
  2360. out word dx, ax
  2361. (*%E *)
  2362. or byte es:[di], 0FFH
  2363. add di, [EGAvertinc1]
  2364. loop EGAlowSlopeL
  2365. jmp near EGAlineExit
  2366. EGAmaskLeft:
  2367. (*%F FastIO *)
  2368. call $OutWord
  2369. (*%E *)
  2370. (*%T FastIO *)
  2371. out word dx, ax
  2372. (*%E *)
  2373. or byte es:[di], 0FFH
  2374. inc di
  2375. or si, si
  2376. jns EGAdPos2
  2377. add si, bp
  2378. loop EGAlowSlopeL
  2379. jmp near EGAlineExit
  2380. EGAdPos2:
  2381. add si, [EGAinc2]
  2382. add di, [EGAvertinc1]
  2383. loop EGAlowSlopeL
  2384. jmp near EGAlineExit
  2385. EGAlowSlopeM:
  2386. sub ah, ah
  2387. EGAlowLoopM:
  2388. push ax
  2389. mov ax, [EGAmaskbit]
  2390. test ax, [EGAlstyle]
  2391. pop ax
  2392. jz EGAnoStore3M
  2393. or ah, bl
  2394. EGAnoStore3M:
  2395. rol word [EGAmaskbit], 1
  2396. ror bl, 1
  2397. jc EGAmaskLeftM
  2398. or si, si
  2399. jns EGAdPos1M
  2400. add si, [EGAinc1]
  2401. loop EGAlowLoopM
  2402. (*%F FastIO *)
  2403. extrn $OutWord
  2404. call $OutWord
  2405. (*%E *)
  2406. (*%T FastIO *)
  2407. out word dx, ax
  2408. (*%E *)
  2409. or byte es:[di], 0FFH
  2410. jmp near EGAlineExit
  2411. EGAdPos1M:
  2412. add si, [EGAinc2]
  2413. (*%F FastIO *)
  2414. call $OutWord
  2415. (*%E *)
  2416. (*%T FastIO *)
  2417. out word dx, ax
  2418. (*%E *)
  2419. or byte es:[di], 0FFH
  2420. add di, [EGAvertinc1]
  2421. loop EGAlowSlopeM
  2422. jmp EGAlineExit
  2423. EGAmaskLeftM:
  2424. (*%F FastIO *)
  2425. extrn $OutWord
  2426. call $OutWord
  2427. (*%E *)
  2428. (*%T FastIO *)
  2429. out word dx, ax
  2430. (*%E *)
  2431. or byte es:[di], 0FFH
  2432. inc di
  2433. or si, si
  2434. jns EGAdPos2M
  2435. add si, [EGAinc1]
  2436. loop EGAlowSlopeM
  2437. jmp EGAlineExit
  2438. EGAdPos2M:
  2439. add si, [EGAinc2]
  2440. add di, [EGAvertinc1]
  2441. loop EGAlowSlopeM
  2442. jmp EGAlineExit
  2443. EGAhighSlope:
  2444. mov bp, [EGAinc1]
  2445. mov bx, [EGAvertinc1]
  2446. EGAhighLoop:
  2447. (*%F FastIO *)
  2448. call $OutWord
  2449. (*%E *)
  2450. (*%T FastIO *)
  2451. out word dx, ax
  2452. (*%E *)
  2453. or byte es:[di], 0FFH
  2454. add di, bx
  2455. or si, si
  2456. jns EGAdPos3
  2457. add si, bp
  2458. loop EGAhighLoop
  2459. jmp EGAlineExit
  2460. EGAdPos3:
  2461. add si, [EGAinc2]
  2462. ror ah, 1
  2463. adc di, 0
  2464. loop EGAhighLoop
  2465. jmp EGAlineExit
  2466. EGAhighSlopeM:
  2467. mov bp, [EGAinc1]
  2468. mov bx, [EGAvertinc1]
  2469. EGAhighLoopM:
  2470. push ax
  2471. mov ax, [EGAmaskbit]
  2472. test ax, [EGAlstyle]
  2473. pop ax
  2474. jz EGAnoStore4M
  2475. (*%F FastIO *)
  2476. call $OutWord
  2477. (*%E *)
  2478. (*%T FastIO *)
  2479. out word dx, ax
  2480. (*%E *)
  2481. or byte es:[di], 0FFH
  2482. EGAnoStore4M:
  2483. rol word [EGAmaskbit], 1
  2484. add di, bx
  2485. or si, si
  2486. jns EGAdPos3M
  2487. add si, bp
  2488. loop EGAhighLoopM
  2489. jmp EGAlineExit
  2490. EGAdPos3M:
  2491. add si, [EGAinc2]
  2492. ror ah, 1
  2493. adc di, 0
  2494. loop EGAhighLoopM
  2495. EGAlineExit:
  2496. mov dx, 3CEH
  2497. sub ax, ax
  2498. (*%F FastIO *)
  2499. call $OutWord
  2500. (*%E *)
  2501. (*%T FastIO *)
  2502. out word dx, ax
  2503. (*%E *)
  2504. inc ax
  2505. (*%F FastIO *)
  2506. call $OutWord
  2507. (*%E *)
  2508. (*%T FastIO *)
  2509. out word dx, ax
  2510. (*%E *)
  2511. mov al, 3
  2512. (*%F FastIO *)
  2513. call $OutWord
  2514. (*%E *)
  2515. (*%T FastIO *)
  2516. out word dx, ax
  2517. (*%E *)
  2518. mov ax, 0FF08H
  2519. (*%F FastIO *)
  2520. call $OutWord
  2521. (*%E *)
  2522. (*%T FastIO *)
  2523. out word dx, ax
  2524. (*%E *)
  2525. noDraw:
  2526. (*%F SameDS *)
  2527. pop ds
  2528. (*%E *)
  2529. pop si
  2530. pop di
  2531. pop bp
  2532. (*%F NearCall *)
  2533. ret far 2
  2534. (*%E *)
  2535. (*%T NearCall *)
  2536. ret 2
  2537. (*%E *)
  2538. public __EGALine :
  2539. push bp
  2540. mov bp, sp
  2541. push di
  2542. push si
  2543. (*%F SameDS *)
  2544. push ds
  2545. mov si, _DATA
  2546. mov ds, si
  2547. (*%E *)
  2548. call __lclip
  2549. jc noDraw
  2550. mov [EGAx1], ax
  2551. mov [EGAy1], bx
  2552. mov [EGAx2], cx
  2553. mov [EGAy2], dx
  2554. mov ax, [bp][frame]
  2555. mov [EGAlstyle], ax
  2556. mov ax, [__fgcolor]
  2557. cmp byte [__EGAtranslate], 0
  2558. jz notNeeded
  2559. call __EGAxlat
  2560. notNeeded:
  2561. mov [EGAcolor], ax
  2562. mov dx, 3CEH
  2563. mov ax, 5H
  2564. (*%F FastIO *)
  2565. extrn $OutWord
  2566. call $OutWord
  2567. (*%E *)
  2568. (*%T FastIO *)
  2569. out word dx, ax
  2570. (*%E *)
  2571. mov ah, [EGAcolor]
  2572. sub al, al
  2573. (*%F FastIO *)
  2574. call $OutWord
  2575. (*%E *)
  2576. (*%T FastIO *)
  2577. out word dx, ax
  2578. (*%E *)
  2579. mov ax, 0FF01H
  2580. (*%F FastIO *)
  2581. call $OutWord
  2582. (*%E *)
  2583. (*%T FastIO *)
  2584. out word dx, ax
  2585. (*%E *)
  2586. mov al, 3
  2587. mov ah, 0
  2588. (*%F FastIO *)
  2589. call $OutWord
  2590. (*%E *)
  2591. (*%T FastIO *)
  2592. out word dx, ax
  2593. (*%E *)
  2594. mov si, [__width]
  2595. mov cx, [EGAx2]
  2596. mov ax, [EGAx1]
  2597. sub cx, ax
  2598. jz EGAverticalLine
  2599. mov bx, [EGAy2]
  2600. sub bx, [EGAy1]
  2601. jns EGAposInc
  2602. neg bx
  2603. neg si
  2604. EGAposInc:
  2605. mov [EGAvertinc1], si
  2606. cmp bx, cx
  2607. jle EGAuseLowSlope
  2608. mov bp, 1
  2609. xchg bx, cx
  2610. jmp EGAgotSlope
  2611. EGAuseLowSlope:
  2612. mov bp, 2
  2613. EGAgotSlope:
  2614. shl bx, 1
  2615. mov [EGAinc1], bx
  2616. sub bx, cx
  2617. mov si, bx
  2618. sub bx, cx
  2619. mov [EGAinc2], bx
  2620. push cx
  2621. mov bx, [EGAx1]
  2622. mov ax, [EGAy1]
  2623. call __pixeladdrEGA2
  2624. mov di, bx
  2625. shl ah, cl
  2626. mov bl, ah
  2627. mov al, 8
  2628. pop cx
  2629. inc cx
  2630. cmp word [EGAlstyle], -1
  2631. jne EGAMaskSet
  2632. cmp bp, 1
  2633. je EGAhighSlope
  2634. jmp EGAlowSlope
  2635. EGAMaskSet:
  2636. mov [EGAdraw], bp
  2637. push cx
  2638. mov cx, [EGAx1]
  2639. and cl, 15
  2640. mov bp, 1
  2641. shl bp, cl
  2642. mov [EGAmaskbit], bp
  2643. pop cx
  2644. cmp byte [EGAdraw], 1
  2645. je EGAhighSlopeM
  2646. jmp EGAlowSlopeM
  2647. (**************************************************************************)
  2648. section
  2649. (*%F NearCall *)
  2650. segment Graphics_TEXT(CODE,28H)
  2651. (*%E *)
  2652. (*%T NearCall *)
  2653. segment _TEXT(CODE,28H)
  2654. (*%E *)
  2655. segment _DATA(DATA, 28H)
  2656. extrn __pixeladdrEGA2
  2657. extrn __lclip
  2658. select _DATA
  2659. extrn __fgcolor
  2660. extrn __width
  2661. EGA2x1 : dw 0
  2662. EGA2y1 : dw 0
  2663. EGA2x2 : dw 0
  2664. EGA2y2 : dw 0
  2665. EGA2inc1 : dw 0
  2666. EGA2inc2 : dw 0
  2667. EGA2draw : dw 0
  2668. EGA2lstyle : dw 0
  2669. propPix : db 0, 0FFH
  2670. (*%F NearCall *)
  2671. select Graphics_TEXT
  2672. (*%E *)
  2673. (*%T NearCall *)
  2674. select _TEXT
  2675. (*%E *)
  2676. rotate:
  2677. push cx
  2678. push ax
  2679. mov cx, 1
  2680. mov si, 8000H
  2681. sub ax, ax
  2682. rotLoop:
  2683. test bx, cx
  2684. jz zeroBit
  2685. or ax, si
  2686. zeroBit:
  2687. shr si, 1
  2688. shl cx, 1
  2689. jc rotDone
  2690. jmp rotLoop
  2691. rotDone:
  2692. mov bx, ax
  2693. pop ax
  2694. pop cx
  2695. ret 0
  2696. EGA2verticalLine:
  2697. mov cx, [EGA2x1]
  2698. and cl, 15
  2699. mov bp, 1
  2700. shl bp, cl
  2701. mov ax, [EGA2y1]
  2702. mov bx, [EGA2y2]
  2703. mov cx, bx
  2704. sub cx, ax
  2705. jge EGA2dPos
  2706. neg cx
  2707. mov ax, bx
  2708. EGA2dPos:
  2709. inc cx
  2710. mov bx, [EGA2x1]
  2711. push cx
  2712. call __pixeladdrEGA2
  2713. mov al, [__fgcolor]
  2714. shl ax, cl
  2715. not ah
  2716. pop cx
  2717. mov dx, [EGA2lstyle]
  2718. or al, al
  2719. jz EGA2vertLoop2
  2720. EGA2vertLoop1:
  2721. test bp, dx
  2722. jz EGA2noStore1
  2723. or es:[bx], al
  2724. EGA2noStore1:
  2725. rol bp, 1
  2726. add bx, si
  2727. loop EGA2vertLoop1
  2728. jmp near EGA2lineExit
  2729. EGA2vertLoop2:
  2730. test bp, dx
  2731. jz EGA2noStore2
  2732. and es:[bx], ah
  2733. EGA2noStore2:
  2734. rol bp, 1
  2735. add bx, si
  2736. loop EGA2vertLoop2
  2737. jmp near EGA2lineExit
  2738. EGA2horiz:
  2739. mov ax, [EGA2y1]
  2740. mov bx, [EGA2x1]
  2741. call __pixeladdrEGA2
  2742. mov di, bx
  2743. mov dh, ah
  2744. not dh
  2745. mov dl, 0FFH
  2746. shl dh, cl
  2747. not dh
  2748. mov cx, [EGA2x2]
  2749. and cl, 7
  2750. xor cl, 7
  2751. shl dl, cl
  2752. mov ax, [EGA2x2]
  2753. mov bx, [EGA2x1]
  2754. mov cl, 3
  2755. shr ax, cl
  2756. shr bx, cl
  2757. mov cx, ax
  2758. sub cx, bx
  2759. mov bx, propPix
  2760. mov al, [__fgcolor]
  2761. xlat
  2762. mov bx, [EGA2lstyle]
  2763. call rotate
  2764. test di, 1
  2765. jz maskSetOK
  2766. xchg bh, bl
  2767. maskSetOK:
  2768. mov bp, ax
  2769. and al, bh
  2770. or dh, dh
  2771. js fullByte
  2772. or cx, cx
  2773. jnz multiByte
  2774. and dl, dh
  2775. jmp lastByte
  2776. multiByte:
  2777. mov ah, al
  2778. and ah, dh
  2779. not dh
  2780. and es:[di], dh
  2781. or es:[di], ah
  2782. inc di
  2783. dec cx
  2784. fullByte:
  2785. mov ax, bp
  2786. xchg bh, bl
  2787. and al, bh
  2788. jcxz lastByte
  2789. stosb
  2790. loop fullByte
  2791. lastByte:
  2792. and al, dl
  2793. not dl
  2794. and es:[di], dl
  2795. or es:[di], al
  2796. jmp near EGA2lineExit
  2797. EGA2lowSlope:
  2798. mov bp, [EGA2inc1]
  2799. EGA2lowSlopeL:
  2800. mov ah, es:[bx]
  2801. EGA2lowLoop:
  2802. and ah, dh
  2803. or ah, dl
  2804. ror dl, 1
  2805. ror dh, 1
  2806. jnc EGA2maskLeft
  2807. or di, di
  2808. jns EGA2dPos1
  2809. add di, bp
  2810. loop EGA2lowLoop
  2811. mov es:[bx], ah
  2812. jmp near EGA2lineExit
  2813. EGA2dPos1:
  2814. add di, [EGA2inc2]
  2815. mov es:[bx], ah
  2816. add bx, si
  2817. loop EGA2lowSlopeL
  2818. jmp near EGA2lineExit
  2819. EGA2maskLeft:
  2820. mov es:[bx], ah
  2821. inc bx
  2822. or di, di
  2823. jns EGA2dPos2
  2824. add di, bp
  2825. loop EGA2lowSlopeL
  2826. jmp near EGA2lineExit
  2827. EGA2dPos2:
  2828. add di, [EGA2inc2]
  2829. add bx, si
  2830. loop EGA2lowSlopeL
  2831. jmp near EGA2lineExit
  2832. EGA2lowSlopeM:
  2833. mov ah, es:[bx]
  2834. EGA2lowLoopM:
  2835. and ah, dh
  2836. test bp, [EGA2lstyle]
  2837. jz EGA2noStore3
  2838. or ah, dl
  2839. EGA2noStore3:
  2840. rol bp, 1
  2841. ror dl, 1
  2842. ror dh, 1
  2843. jnc EGA2maskLeftM
  2844. or di, di
  2845. jns EGA2dPos1M
  2846. add di, [EGA2inc1]
  2847. loop EGA2lowLoopM
  2848. mov es:[bx], ah
  2849. jmp EGA2lineExit
  2850. EGA2dPos1M:
  2851. add di, [EGA2inc2]
  2852. mov es:[bx], ah
  2853. add bx, si
  2854. loop EGA2lowSlopeM
  2855. jmp EGA2lineExit
  2856. EGA2maskLeftM:
  2857. mov es:[bx], ah
  2858. inc bx
  2859. or di, di
  2860. jns EGA2dPos2M
  2861. add di, [EGA2inc1]
  2862. loop EGA2lowSlopeM
  2863. jmp EGA2lineExit
  2864. EGA2dPos2M:
  2865. add di, [EGA2inc2]
  2866. add bx, si
  2867. loop EGA2lowSlopeM
  2868. jmp EGA2lineExit
  2869. EGA2highSlope:
  2870. mov bp, [EGA2inc1]
  2871. EGA2highSlopeL:
  2872. and es:[bx], dh
  2873. or es:[bx], dl
  2874. add bx, si
  2875. or di, di
  2876. jns EGA2dPos3
  2877. add di, bp
  2878. loop EGA2highSlopeL
  2879. jmp EGA2lineExit
  2880. EGA2dPos3:
  2881. add di, [EGA2inc2]
  2882. ror dl, 1
  2883. ror dh, 1
  2884. cmc
  2885. adc bx, 0
  2886. loop EGA2highSlopeL
  2887. jmp EGA2lineExit
  2888. EGA2highSlopeM:
  2889. and es:[bx], dh
  2890. test bp, [EGA2lstyle]
  2891. jz EGA2noStore4
  2892. or es:[bx], dl
  2893. EGA2noStore4:
  2894. rol bp, 1
  2895. add bx, si
  2896. or di, di
  2897. jns EGA2dPos3M
  2898. add di, [EGA2inc1]
  2899. loop EGA2highSlopeM
  2900. jmp EGA2lineExit
  2901. EGA2dPos3M:
  2902. add di, [EGA2inc2]
  2903. ror dl, 1
  2904. ror dh, 1
  2905. cmc
  2906. adc bx, 0
  2907. loop EGA2highSlopeM
  2908. EGA2lineExit:
  2909. (*%F SameDS *)
  2910. pop ds
  2911. (*%E *)
  2912. pop si
  2913. pop di
  2914. pop bp
  2915. (*%F NearCall *)
  2916. ret far 2
  2917. (*%E *)
  2918. (*%T NearCall *)
  2919. ret 2
  2920. (*%E *)
  2921. public __EGA2Line :
  2922. push bp
  2923. mov bp, sp
  2924. push di
  2925. push si
  2926. (*%F SameDS *)
  2927. push ds
  2928. mov si, _DATA
  2929. mov ds, si
  2930. (*%E *)
  2931. call __lclip
  2932. jc EGA2lineExit
  2933. mov [EGA2x1], ax
  2934. mov [EGA2y1], bx
  2935. mov [EGA2x2], cx
  2936. mov [EGA2y2], dx
  2937. mov ax, [bp][frame]
  2938. mov [EGA2lstyle], ax
  2939. mov si, 80
  2940. mov cx, [EGA2x2]
  2941. mov ax, [EGA2x1]
  2942. sub cx, ax
  2943. jz EGA2verticalLine
  2944. mov bx, [EGA2y2]
  2945. sub bx, [EGA2y1]
  2946. je EGA2horiz
  2947. jns EGA2posInc
  2948. neg bx
  2949. neg si
  2950. EGA2posInc:
  2951. cmp bx, cx
  2952. jle EGA2useLowSlope
  2953. mov bp, 1
  2954. xchg bx, cx
  2955. jmp EGA2gotSlope
  2956. EGA2useLowSlope:
  2957. mov bp, 2
  2958. EGA2gotSlope:
  2959. shl bx, 1
  2960. mov [EGA2inc1], bx
  2961. sub bx, cx
  2962. mov di, bx
  2963. sub bx, cx
  2964. mov [EGA2inc2], bx
  2965. push cx
  2966. mov bx, [EGA2x1]
  2967. mov ax, [EGA2y1]
  2968. call __pixeladdrEGA2
  2969. mov al, [__fgcolor]
  2970. shl ax, cl
  2971. mov dx, ax
  2972. not dh
  2973. pop cx
  2974. inc cx
  2975. cmp word [EGA2lstyle], -1
  2976. jne EGA2MaskSet
  2977. cmp bp, 1
  2978. je EGA2highSlope
  2979. jmp EGA2lowSlope
  2980. EGA2MaskSet:
  2981. mov [EGA2draw], bp
  2982. push cx
  2983. mov cx, [EGA2x1]
  2984. and cl, 15
  2985. mov bp, 1
  2986. shl bp, cl
  2987. pop cx
  2988. cmp byte [EGA2draw], 1
  2989. je EGA2highSlopeM
  2990. jmp EGA2lowSlopeM
  2991. (**************************************************************************)
  2992. section
  2993. (*%F NearCall *)
  2994. segment Graphics_TEXT(CODE,28H)
  2995. (*%E *)
  2996. (*%T NearCall *)
  2997. segment _TEXT(CODE,28H)
  2998. (*%E *)
  2999. segment _DATA(DATA, 28H)
  3000. (*%F NearCall *)
  3001. select Graphics_TEXT
  3002. (*%E *)
  3003. (*%T NearCall *)
  3004. select _TEXT
  3005. (*%E *)
  3006. public __VGAPoint :
  3007. (*%T _DLLOVL *)
  3008. push bp
  3009. mov bp, sp
  3010. (*%E *)
  3011. mov cx, ax
  3012. mov ax, 320
  3013. mul bx
  3014. add ax, cx
  3015. mov bx, ax
  3016. (*%T _XTD *)
  3017. extrn __A000h
  3018. mov ax, __A000h
  3019. (*%E *)
  3020. (*%F _XTD *)
  3021. mov ax, 0A000H
  3022. (*%E *)
  3023. mov es, ax
  3024. mov al, es:[bx]
  3025. sub ah, ah
  3026. (*%T _DLLOVL *)
  3027. pop bp
  3028. (*%E *)
  3029. (*%F NearCall *)
  3030. ret far 0
  3031. (*%E *)
  3032. (*%T NearCall *)
  3033. ret 0
  3034. (*%E *)
  3035. (**************************************************************************)
  3036. section
  3037. (*%F NearCall *)
  3038. segment Graphics_TEXT(CODE,28H)
  3039. (*%E *)
  3040. (*%T NearCall *)
  3041. segment _TEXT(CODE,28H)
  3042. (*%E *)
  3043. segment _DATA(DATA, 28H)
  3044. (*%F NearCall *)
  3045. select Graphics_TEXT
  3046. (*%E *)
  3047. (*%T NearCall *)
  3048. select _TEXT
  3049. (*%E *)
  3050. (*
  3051. void VGAGet(unsigned char *buffer, short x1, y1, x2, y2);
  3052. *)
  3053. buffer = frame
  3054. x1 = 4+frame
  3055. y1 = 6+frame
  3056. x2 = 8+frame
  3057. y2 = 10+frame
  3058. len = -2
  3059. incr = -4
  3060. pixAddress= -6
  3061. byteShift = -7
  3062. locals = 7
  3063. public __VGAGet :
  3064. push bp
  3065. mov bp, sp
  3066. sub sp, locals
  3067. push di
  3068. push si
  3069. push ds
  3070. les di, [bp][buffer]
  3071. (*%T _XTD *)
  3072. extrn __A000h
  3073. mov ax, __A000h
  3074. (*%E *)
  3075. (*%F _XTD *)
  3076. mov ax, 0A000H
  3077. (*%E *)
  3078. mov ds, ax
  3079. mov ax, [bp][y1]
  3080. mov dx, 320
  3081. mul dx
  3082. add ax, [bp][x1]
  3083. mov si, ax
  3084. mov ax, [bp][x2] (* cols *)
  3085. sub ax, [bp][x1]
  3086. inc ax
  3087. push ax
  3088. mov cl, 3
  3089. shl ax, cl
  3090. stosw
  3091. mov ax, [bp][y2] (* rows *)
  3092. sub ax, [bp][y1]
  3093. inc ax
  3094. mov cx, ax
  3095. stosw
  3096. mov bx, 320
  3097. pop ax
  3098. getRowLoop:
  3099. push cx
  3100. mov dx, si
  3101. mov cx, ax
  3102. shr cx, 1
  3103. rep ; movsw
  3104. adc cx, cx
  3105. rep ; movsb
  3106. mov si, dx
  3107. add si, bx
  3108. pop cx
  3109. loop getRowLoop
  3110. pop ds
  3111. pop si
  3112. pop di
  3113. mov sp, bp
  3114. pop bp
  3115. (*%F NearCall *)
  3116. ret far 0
  3117. (*%E *)
  3118. (*%T NearCall *)
  3119. ret 0
  3120. (*%E *)
  3121. (**************************************************************************)
  3122. section
  3123. (*%F NearCall *)
  3124. segment Graphics_TEXT(CODE,28H)
  3125. (*%E *)
  3126. (*%T NearCall *)
  3127. segment _TEXT(CODE,28H)
  3128. (*%E *)
  3129. segment _DATA(DATA, 28H)
  3130. (*%F NearCall *)
  3131. select Graphics_TEXT
  3132. (*%E *)
  3133. (*%T NearCall *)
  3134. select _TEXT
  3135. (*%E *)
  3136. x1 = frame
  3137. y1 = 2+frame
  3138. buffer = 4+frame
  3139. action = 8+frame
  3140. len = -2
  3141. incr = -4
  3142. rows = -6
  3143. bitOp = -8
  3144. pixAddress = -10
  3145. locals = 10
  3146. public __VGAPut :
  3147. push bp
  3148. mov bp, sp
  3149. sub sp, locals
  3150. push di
  3151. push si
  3152. push ds
  3153. lds si, [bp][buffer]
  3154. lodsw
  3155. mov [bp][len], ax
  3156. mov cl, 3
  3157. shr ax, cl
  3158. mov [bp][len], ax
  3159. lodsw
  3160. mov [bp][rows], ax
  3161. (*%T _XTD *)
  3162. extrn __A000h
  3163. mov ax, __A000h
  3164. (*%E *)
  3165. (*%F _XTD *)
  3166. mov ax, 0A000H
  3167. (*%E *)
  3168. mov es, ax
  3169. mov ax, [bp][y1]
  3170. mov dx, 320
  3171. mul dx
  3172. add ax, [bp][x1]
  3173. mov di, ax
  3174. mov ax, [bp][action]
  3175. mov cx, [bp][rows]
  3176. mov bx, 320
  3177. or ax, ax
  3178. jz __OR
  3179. dec ax
  3180. or ax, ax
  3181. jz __AND
  3182. dec ax
  3183. or ax, ax
  3184. jz __RESET
  3185. dec ax
  3186. or ax, ax
  3187. jz __SET
  3188. dec ax
  3189. or ax, ax
  3190. jz __XOR
  3191. setExit:
  3192. pop ds
  3193. pop si
  3194. pop di
  3195. mov sp, bp
  3196. pop bp
  3197. (*%F NearCall *)
  3198. ret far 0
  3199. (*%E *)
  3200. (*%T NearCall *)
  3201. ret 0
  3202. (*%E *)
  3203. __OR:
  3204. orRowLoop:
  3205. push cx
  3206. mov dx, di
  3207. mov cx, [bp][len]
  3208. orColLoop:
  3209. lodsb
  3210. or ax, es:[di]
  3211. stosb
  3212. loop orColLoop
  3213. mov di, dx
  3214. add di, bx
  3215. pop cx
  3216. loop orRowLoop
  3217. jmp setExit
  3218. __AND:
  3219. andRowLoop:
  3220. push cx
  3221. mov dx, di
  3222. mov cx, [bp][len]
  3223. andColLoop:
  3224. lodsb
  3225. and es:[di], al
  3226. inc di
  3227. loop andColLoop
  3228. mov di, dx
  3229. add di, bx
  3230. pop cx
  3231. loop andRowLoop
  3232. jmp setExit
  3233. __RESET:
  3234. resetRowLoop:
  3235. push cx
  3236. mov dx, di
  3237. mov cx, [bp][len]
  3238. resetColLoop:
  3239. lodsb
  3240. not al
  3241. stosb
  3242. loop resetColLoop
  3243. mov di, dx
  3244. add di, bx
  3245. pop cx
  3246. loop resetRowLoop
  3247. jmp setExit
  3248. __SET:
  3249. setRowLoop:
  3250. push cx
  3251. mov dx, di
  3252. mov cx, [bp][len]
  3253. rep; movsb
  3254. mov di, dx
  3255. add di, bx
  3256. pop cx
  3257. loop setRowLoop
  3258. jmp setExit
  3259. __XOR:
  3260. xorRowLoop:
  3261. push cx
  3262. mov dx, di
  3263. mov cx, [bp][len]
  3264. xorColLoop:
  3265. lodsb
  3266. xor es:[di], al
  3267. inc di
  3268. loop xorColLoop
  3269. mov di, dx
  3270. add di, bx
  3271. pop cx
  3272. loop xorRowLoop
  3273. jmp setExit
  3274. (**************************************************************************)
  3275. section
  3276. (*%F NearCall *)
  3277. segment Graphics_TEXT(CODE,28H)
  3278. (*%E *)
  3279. (*%T NearCall *)
  3280. segment _TEXT(CODE,28H)
  3281. (*%E *)
  3282. segment _DATA(DATA, 28H)
  3283. extrn __pixeladdrEGA
  3284. select _DATA
  3285. extrn __width
  3286. extrn __EGAPlaneShift
  3287. extrn __EGAStartPlane
  3288. (*%F NearCall *)
  3289. select Graphics_TEXT
  3290. (*%E *)
  3291. (*%T NearCall *)
  3292. select _TEXT
  3293. (*%E *)
  3294. (****Move from selector for a huge selector to the next****)
  3295. (* Input : Selector on stack *)
  3296. (* Output : Selector on stack, all regs preserved *)
  3297. (* Internal routine, always near called *)
  3298. extrn __hugeshift
  3299. public @next_seg:
  3300. push bp
  3301. mov bp,sp
  3302. push ax
  3303. (*%F SameDS *)
  3304. push ds
  3305. mov ax, seg __hugeshift
  3306. mov ds, ax
  3307. (*%E *)
  3308. mov ax,[__hugeshift]
  3309. add [bp][4],ax
  3310. (*%F SameDS *)
  3311. pop ds
  3312. (*%E *)
  3313. pop ax
  3314. pop bp
  3315. ret 0
  3316. (*
  3317. void EGAGet(unsigned char *buffer, short x1, y1, x2, y2);
  3318. *)
  3319. buffer = frame
  3320. x1 = 4+frame
  3321. y1 = 6+frame
  3322. x2 = 8+frame
  3323. y2 = 10+frame
  3324. BytesPerRow = -2
  3325. len = -4
  3326. rows = -6
  3327. EGAPlaneShift = -8
  3328. EGAStartPlane = -10
  3329. locals = 10
  3330. ByteShift = 3
  3331. public __EGAGet :
  3332. push bp
  3333. mov bp, sp
  3334. sub sp, locals
  3335. push di
  3336. push si
  3337. push ds
  3338. (*%F SameDS *)
  3339. mov ax, _DATA
  3340. mov ds, ax
  3341. (*%E *)
  3342. mov ax, [__EGAPlaneShift]
  3343. mov [bp][EGAPlaneShift], ax
  3344. mov ax, [__EGAStartPlane]
  3345. mov [bp][EGAStartPlane], ax
  3346. mov ax, [__width]
  3347. mov [bp][BytesPerRow], ax
  3348. mov ax, [bp][x2]
  3349. sub ax, [bp][x1]
  3350. mov cx, 0FF07H
  3351. and cl, al
  3352. xor cl, 7
  3353. shl ch, cl
  3354. mov cl, ch
  3355. push cx
  3356. mov cl, ByteShift
  3357. shr ax, cl
  3358. inc ax
  3359. push ax
  3360. mov ax, [bp][y2]
  3361. sub ax, [bp][y1]
  3362. inc ax
  3363. push ax
  3364. (* setup addressing *)
  3365. mov ax, [bp][y1]
  3366. mov bx, [bp][x1]
  3367. call __pixeladdrEGA
  3368. xor cl, 7
  3369. mov si, es
  3370. mov ds, si
  3371. mov si, bx
  3372. les di, [bp][buffer]
  3373. (* build header *)
  3374. pop ax
  3375. mov [bp][rows], ax
  3376. stosw
  3377. pop ax
  3378. mov [bp][len], ax
  3379. stosb
  3380. pop ax
  3381. mov ch, al
  3382. stosb
  3383. (* setup controller *)
  3384. mov dx, 3CEH
  3385. mov al, 5
  3386. out byte dx, al
  3387. sub al, al
  3388. inc dx
  3389. out byte dx, al
  3390. dec dx
  3391. mov al, 4H
  3392. out byte dx, al
  3393. mov al, [bp][EGAStartPlane]
  3394. mov ah, [bp][EGAPlaneShift]
  3395. inc dx
  3396. getPlaneLoop:
  3397. out byte dx, al
  3398. push ax
  3399. push [bp][rows]
  3400. push si
  3401. op2:
  3402. mov bx, [bp][len]
  3403. push si
  3404. op3:
  3405. lodsw
  3406. dec si
  3407. rol ax, cl
  3408. stosb
  3409. or di, di
  3410. jnz inSeg
  3411. push es
  3412. call @next_seg
  3413. pop es
  3414. inSeg:
  3415. dec bx
  3416. jnz op3
  3417. and es:[di][-1], ch
  3418. pop si
  3419. add si, [bp][BytesPerRow]
  3420. dec word [bp][rows]
  3421. jnz op2
  3422. pop si
  3423. pop [bp][rows]
  3424. pop ax
  3425. sub al, ah
  3426. jns getPlaneLoop
  3427. pop ds
  3428. pop si
  3429. pop di
  3430. mov sp, bp
  3431. pop bp
  3432. (*%F NearCall *)
  3433. ret far 0
  3434. (*%E *)
  3435. (*%T NearCall *)
  3436. ret 0
  3437. (*%E *)
  3438. (**************************************************************************)
  3439. section
  3440. (*%F NearCall *)
  3441. segment Graphics_TEXT(CODE,28H)
  3442. (*%E *)
  3443. (*%T NearCall *)
  3444. segment _TEXT(CODE,28H)
  3445. (*%E *)
  3446. segment _DATA(DATA, 28H)
  3447. extrn __EGArexlat
  3448. select _DATA
  3449. extrn __width
  3450. extrn __page_size
  3451. extrn __active_page
  3452. extrn __EGAPlaneShift
  3453. extrn __EGAStartPlane
  3454. extrn __EGA64K
  3455. extrn __EGAtranslate
  3456. (*%F NearCall *)
  3457. select Graphics_TEXT
  3458. (*%E *)
  3459. (*%T NearCall *)
  3460. select _TEXT
  3461. (*%E *)
  3462. public __EGAPoint :
  3463. (*%T _DLLOVL *)
  3464. push bp
  3465. mov bp, sp
  3466. (*%E *)
  3467. push si
  3468. (*%F SameDS *)
  3469. push ds
  3470. mov si, _DATA
  3471. mov ds, si
  3472. (*%E *)
  3473. mov cx, ax
  3474. and cx, 7
  3475. mov ch, 80H
  3476. shr ch, cl
  3477. mov cl, ch (* cl = mask *)
  3478. (*%T _XTD *)
  3479. db 0C1H,0F8H,003H (*I shr ax, 3 *)
  3480. (*%E *)
  3481. (*%F _XTD *)
  3482. shr ax, 1
  3483. shr ax, 1
  3484. shr ax, 1
  3485. (*%E *)
  3486. mov si, ax
  3487. mov ax, [__width]
  3488. mul bx
  3489. add si, ax (* offset *)
  3490. mov ax, [__active_page]
  3491. mul word [__page_size]
  3492. (*%T _XTD *)
  3493. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  3494. add si, ax
  3495. extrn __A000h
  3496. mov ax, __A000h
  3497. (*%E *)
  3498. (*%F _XTD *)
  3499. add ax, 0A000H
  3500. (*%E *)
  3501. mov es, ax (* segment *)
  3502. mov dx, 03CEH
  3503. mov ax, 5
  3504. (*%F FastIO *)
  3505. extrn $OutWord
  3506. call $OutWord
  3507. (*%E *)
  3508. (*%T FastIO *)
  3509. out word dx, ax
  3510. (*%E *)
  3511. mov al, 4
  3512. out byte dx, al
  3513. inc dx
  3514. cmp byte [__EGA64K], 0
  3515. je fullEGA
  3516. mov ax, 1
  3517. and ax, si
  3518. add ax, [__EGAStartPlane]
  3519. jmp gotPlane
  3520. fullEGA:
  3521. mov ax, [__EGAStartPlane]
  3522. gotPlane:
  3523. mov bl, [__EGAPlaneShift]
  3524. readLoop:
  3525. out byte dx, al
  3526. mov ch, es:[si]
  3527. and ch, cl
  3528. neg ch
  3529. rcl ah, 1
  3530. sub al, bl
  3531. jns readLoop
  3532. mov al, ah
  3533. sub ah, ah
  3534. (*%F SameDS *)
  3535. pop ds
  3536. (*%E *)
  3537. pop si
  3538. (*%T _DLLOVL *)
  3539. pop bp
  3540. (*%E *)
  3541. (*%F NearCall *)
  3542. ret far 0
  3543. (*%E *)
  3544. (*%T NearCall *)
  3545. ret 0
  3546. (*%E *)
  3547. (**************************************************************************)
  3548. section
  3549. (*%F NearCall *)
  3550. segment Graphics_TEXT(CODE,28H)
  3551. (*%E *)
  3552. (*%T NearCall *)
  3553. segment _TEXT(CODE,28H)
  3554. (*%E *)
  3555. segment _DATA(DATA, 28H)
  3556. select _DATA
  3557. extrn __width
  3558. extrn __page_size
  3559. extrn __active_page
  3560. (*%F NearCall *)
  3561. select Graphics_TEXT
  3562. (*%E *)
  3563. (*%T NearCall *)
  3564. select _TEXT
  3565. (*%E *)
  3566. public __EGA2Point :
  3567. (*%T _DLLOVL *)
  3568. push bp
  3569. mov bp, sp
  3570. (*%E *)
  3571. push si
  3572. (*%F SameDS *)
  3573. push ds
  3574. mov si, _DATA
  3575. mov ds, si
  3576. (*%E *)
  3577. mov cx, ax
  3578. and cl, 7
  3579. xor cl, 7
  3580. (*%T _XTD *)
  3581. db 0C1H,0F8H,003H (*I shr ax, 3 *)
  3582. (*%E *)
  3583. (*%F _XTD *)
  3584. shr ax, 1
  3585. shr ax, 1
  3586. shr ax, 1
  3587. (*%E *)
  3588. mov si, ax
  3589. mov ax, [__width]
  3590. mul bx
  3591. add si, ax (* offset *)
  3592. mov ax, [__active_page]
  3593. mul word [__page_size]
  3594. (*%T _XTD *)
  3595. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  3596. add si, ax
  3597. extrn __A000h
  3598. mov ax, __A000h
  3599. (*%E *)
  3600. (*%F _XTD *)
  3601. add ax, 0A000H
  3602. (*%E *)
  3603. mov es, ax (* segment *)
  3604. mov al, es:[si]
  3605. shr al, cl
  3606. and ax, 1
  3607. (*%F SameDS *)
  3608. pop ds
  3609. (*%E *)
  3610. pop si
  3611. (*%T _DLLOVL *)
  3612. pop bp
  3613. (*%E *)
  3614. (*%F NearCall *)
  3615. ret far 0
  3616. (*%E *)
  3617. (*%T NearCall *)
  3618. ret 0
  3619. (*%E *)
  3620. (**************************************************************************)
  3621. section
  3622. (*%F NearCall *)
  3623. segment Graphics_TEXT(CODE,28H)
  3624. (*%E *)
  3625. (*%T NearCall *)
  3626. segment _TEXT(CODE,28H)
  3627. (*%E *)
  3628. segment _DATA(DATA, 28H)
  3629. select _DATA
  3630. extrn __EGA64K
  3631. EGAtable1 : db 0, 1, 4, 5
  3632. EGAtable2 : db 0, 3, 0CH, 0FH
  3633. (*%F NearCall *)
  3634. select Graphics_TEXT
  3635. (*%E *)
  3636. (*%T NearCall *)
  3637. select _TEXT
  3638. (*%E *)
  3639. public __EGAxlat :
  3640. (*%T _DLLOVL *)
  3641. push bp
  3642. mov bp, sp
  3643. (*%E *)
  3644. (*%F SameDS *)
  3645. push ds
  3646. mov bx, _DATA
  3647. mov ds, bx
  3648. (*%E *)
  3649. cmp byte [__EGA64K], 0
  3650. je XfullEGA
  3651. mov bx, EGAtable2
  3652. jmp gotTable
  3653. XfullEGA:
  3654. mov bx, EGAtable1
  3655. gotTable:
  3656. xlat
  3657. (*%F SameDS *)
  3658. pop ds
  3659. (*%E *)
  3660. (*%T _DLLOVL *)
  3661. pop bp
  3662. (*%E *)
  3663. (*%F NearCall *)
  3664. ret far 0
  3665. (*%E *)
  3666. (*%T NearCall *)
  3667. ret 0
  3668. (*%E *)
  3669. (**************************************************************************)
  3670. section
  3671. (*%F NearCall *)
  3672. segment Graphics_TEXT(CODE,28H)
  3673. (*%E *)
  3674. (*%T NearCall *)
  3675. segment _TEXT(CODE,28H)
  3676. (*%E *)
  3677. segment _DATA(DATA, 28H)
  3678. select _DATA
  3679. extrn __EGA64K
  3680. EGAtable1 : db 0, 1, 0, 2, 0, 3
  3681. EGAtable2 : db 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 4
  3682. (*%F NearCall *)
  3683. select Graphics_TEXT
  3684. (*%E *)
  3685. (*%T NearCall *)
  3686. select _TEXT
  3687. (*%E *)
  3688. public __EGArexlat :
  3689. (*%T _DLLOVL *)
  3690. push bp
  3691. mov bp, sp
  3692. (*%E *)
  3693. (*%F SameDS *)
  3694. push ds
  3695. mov bx, _DATA
  3696. mov ds, bx
  3697. (*%E *)
  3698. cmp byte [__EGA64K], 0
  3699. je XfullEGA
  3700. mov bx, EGAtable2
  3701. jmp gotTable
  3702. XfullEGA:
  3703. mov bx, EGAtable1
  3704. gotTable:
  3705. xlat
  3706. (*%F SameDS *)
  3707. pop ds
  3708. (*%E *)
  3709. (*%T _DLLOVL *)
  3710. pop bp
  3711. (*%E *)
  3712. (*%F NearCall *)
  3713. ret far 0
  3714. (*%E *)
  3715. (*%T NearCall *)
  3716. ret 0
  3717. (*%E *)
  3718. (**************************************************************************)
  3719. section
  3720. (*%F NearCall *)
  3721. segment Graphics_TEXT(CODE,28H)
  3722. (*%E *)
  3723. (*%T NearCall *)
  3724. segment _TEXT(CODE,28H)
  3725. (*%E *)
  3726. segment _DATA(DATA, 28H)
  3727. extrn __EGAxlat
  3728. select _DATA
  3729. extrn __width
  3730. extrn __page_size
  3731. extrn __active_page
  3732. extrn __EGAtranslate
  3733. (*%F NearCall *)
  3734. select Graphics_TEXT
  3735. (*%E *)
  3736. (*%T NearCall *)
  3737. select _TEXT
  3738. (*%E *)
  3739. public __EGAPlot1 : (* doesn't translate pixel value *)
  3740. (*%T _DLLOVL *)
  3741. push bp
  3742. mov bp, sp
  3743. (*%E *)
  3744. push si
  3745. jmp notNeeded
  3746. public __EGAPlot :
  3747. (*%T _DLLOVL *)
  3748. push bp
  3749. mov bp, sp
  3750. (*%E *)
  3751. push si
  3752. (*%F SameDS *)
  3753. push ds
  3754. mov si, _DATA
  3755. mov ds, si
  3756. (*%E *)
  3757. cmp byte [__EGAtranslate], 0
  3758. jz notNeeded
  3759. push ax
  3760. push bx
  3761. mov ax, cx
  3762. call __EGAxlat
  3763. mov cx, ax
  3764. pop bx
  3765. pop ax
  3766. notNeeded:
  3767. push cx
  3768. mov cx, ax
  3769. and cx, 7
  3770. mov ch, 80H
  3771. shr ch, cl
  3772. mov cl, ch (* cl = mask *)
  3773. (*%T _XTD *)
  3774. db 0C1H,0F8H,003H (*I shr ax, 3 *)
  3775. (*%E *)
  3776. (*%F _XTD *)
  3777. shr ax, 1
  3778. shr ax, 1
  3779. shr ax, 1
  3780. (*%E *)
  3781. mov si, ax
  3782. mov ax, [__width]
  3783. mul bx
  3784. add si, ax (* offset *)
  3785. mov ax, [__active_page]
  3786. mul word [__page_size]
  3787. (*%T _XTD *)
  3788. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  3789. add si, ax
  3790. extrn __A000h
  3791. mov ax, __A000h
  3792. (*%E *)
  3793. (*%F _XTD *)
  3794. add ax, 0A000H
  3795. (*%E *)
  3796. mov es, ax (* segment *)
  3797. pop bx (* cx = mask, bx = col *)
  3798. mov dx, 03CEH
  3799. mov ax, 205H
  3800. (*%F FastIO *)
  3801. extrn $OutWord
  3802. call $OutWord
  3803. (*%E *)
  3804. (*%T FastIO *)
  3805. out word dx, ax
  3806. (*%E *)
  3807. mov al, 8
  3808. mov ah, cl
  3809. (*%F FastIO *)
  3810. call $OutWord
  3811. (*%E *)
  3812. (*%T FastIO *)
  3813. out word dx, ax
  3814. (*%E *)
  3815. xchg bl, es:[si]
  3816. mov ah, 0FFH
  3817. (*%F FastIO *)
  3818. call $OutWord
  3819. (*%E *)
  3820. (*%T FastIO *)
  3821. out word dx, ax
  3822. (*%E *)
  3823. mov ax, 5
  3824. (*%F FastIO *)
  3825. call $OutWord
  3826. (*%E *)
  3827. (*%T FastIO *)
  3828. out word dx, ax
  3829. (*%E *)
  3830. (*%F SameDS *)
  3831. pop ds
  3832. (*%E *)
  3833. pop si
  3834. (*%T _DLLOVL *)
  3835. pop bp
  3836. (*%E *)
  3837. (*%F NearCall *)
  3838. ret far 0
  3839. (*%E *)
  3840. (*%T NearCall *)
  3841. ret 0
  3842. (*%E *)
  3843. (**************************************************************************)
  3844. section
  3845. (*%F NearCall *)
  3846. segment Graphics_TEXT(CODE,28H)
  3847. (*%E *)
  3848. (*%T NearCall *)
  3849. segment _TEXT(CODE,28H)
  3850. (*%E *)
  3851. segment _DATA(DATA, 28H)
  3852. extrn __EGAxlat
  3853. select _DATA
  3854. extrn __width
  3855. extrn __page_size
  3856. extrn __active_page
  3857. (*%F NearCall *)
  3858. select Graphics_TEXT
  3859. (*%E *)
  3860. (*%T NearCall *)
  3861. select _TEXT
  3862. (*%E *)
  3863. public __EGA2Plot :
  3864. (*%T _DLLOVL *)
  3865. push bp
  3866. mov bp, sp
  3867. (*%E *)
  3868. push si
  3869. (*%F SameDS *)
  3870. push ds
  3871. mov si, _DATA
  3872. mov ds, si
  3873. (*%E *)
  3874. mov dx, cx
  3875. mov cx, ax
  3876. and cl, 7
  3877. xor cl, 7
  3878. shl dl, cl
  3879. mov cl, dl
  3880. (*%T _XTD *)
  3881. db 0C1H,0F8H,003H (*I shr ax, 3 *)
  3882. (*%E *)
  3883. (*%F _XTD *)
  3884. shr ax, 1
  3885. shr ax, 1
  3886. shr ax, 1
  3887. (*%E *)
  3888. mov si, ax
  3889. mov ax, [__width]
  3890. mul bx
  3891. add si, ax (* offset *)
  3892. mov ax, [__active_page]
  3893. mul word [__page_size]
  3894. (*%T _XTD *)
  3895. db 0C1H,0E0H,004H (*I shl ax, 4 *)
  3896. add si, ax
  3897. extrn __A000h
  3898. mov ax, __A000h
  3899. (*%E *)
  3900. (*%F _XTD *)
  3901. add ax, 0A000H
  3902. (*%E *)
  3903. mov es, ax (* segment *)
  3904. or es:[si], cl
  3905. (*%F SameDS *)
  3906. pop ds
  3907. (*%E *)
  3908. pop si
  3909. (*%T _DLLOVL *)
  3910. pop bp
  3911. (*%E *)
  3912. (*%F NearCall *)
  3913. ret far 0
  3914. (*%E *)
  3915. (*%T NearCall *)
  3916. ret 0
  3917. (*%E *)
  3918. (**************************************************************************)
  3919. section
  3920. (*%F NearCall *)
  3921. segment Graphics_TEXT(CODE,28H)
  3922. (*%E *)
  3923. (*%T NearCall *)
  3924. segment _TEXT(CODE,28H)
  3925. (*%E *)
  3926. segment _DATA(DATA, 28H)
  3927. extrn __pixeladdrEGA
  3928. extrn __resetEGA
  3929. extrn __EGAPlaneShift
  3930. extrn __EGAStartPlane
  3931. select _DATA
  3932. extrn __width
  3933. actionTable : db 10H, 8H, 0H, 0H, 18H
  3934. (*%F NearCall *)
  3935. select Graphics_TEXT
  3936. (*%E *)
  3937. (*%T NearCall *)
  3938. select _TEXT
  3939. (*%E *)
  3940. x1 = frame
  3941. y1 = 2+frame
  3942. buffer = 4+frame
  3943. action = 8+frame
  3944. BytesPerRow = -2
  3945. len = -4
  3946. rows = -6
  3947. rowcount = -8
  3948. startmask = -10
  3949. endmaskL = -12
  3950. endmaskR = -14
  3951. RMWBits = -16
  3952. NotFlag = -18
  3953. EGAPlaneShift = -20
  3954. EGAStartPlane = -22
  3955. locals = 22
  3956. _GPRESET = 2
  3957. ByteShift = 3
  3958. public __EGAPut :
  3959. push bp
  3960. mov bp, sp
  3961. sub sp, locals
  3962. push di
  3963. push si
  3964. push ds
  3965. (*%F SameDS *)
  3966. mov ax, _DATA
  3967. mov ds, ax
  3968. (*%E *)
  3969. mov ax, [__EGAPlaneShift]
  3970. mov [bp][EGAPlaneShift], ax
  3971. mov ax, [__EGAStartPlane]
  3972. mov [bp][EGAStartPlane], ax
  3973. mov ax, [__width]
  3974. mov [bp][BytesPerRow], ax
  3975. mov al, [bp][action]
  3976. cmp al, _GPRESET
  3977. jnz selectMode
  3978. mov byte [bp][RMWBits], 0
  3979. mov byte [bp][NotFlag], 1
  3980. jmp modeSelected
  3981. selectMode:
  3982. mov bx, actionTable
  3983. xlat
  3984. mov [bp][RMWBits], ax
  3985. mov byte [bp][NotFlag], 0
  3986. modeSelected:
  3987. mov ax, [bp][y1] (* setup addressing *)
  3988. mov bx, [bp][x1]
  3989. call __pixeladdrEGA
  3990. inc cl
  3991. and cl, 7
  3992. mov di, bx
  3993. lds si, [bp][buffer]
  3994. (* get header *)
  3995. lodsw
  3996. mov [bp][rows], ax
  3997. lodsb
  3998. sub ah, ah
  3999. mov [bp][len], ax
  4000. lodsb
  4001. mov ch, al
  4002. (* setup controller *)
  4003. mov dx, 3CEH
  4004. mov al, 3
  4005. out byte dx, al
  4006. inc dx
  4007. mov al, [bp][RMWBits]
  4008. out byte dx, al
  4009. dec dx
  4010. mov al, 5H
  4011. out byte dx, al
  4012. inc dx
  4013. mov al, 8
  4014. out byte dx, al
  4015. dec dx
  4016. mov al, 7H
  4017. out byte dx, al
  4018. inc dx
  4019. mov al, 0
  4020. out byte dx, al
  4021. dec dx
  4022. mov dl, 0C4H
  4023. mov al, 2H
  4024. mov ah, 1
  4025. push cx
  4026. mov cl, [bp][EGAStartPlane]
  4027. shl ah, cl
  4028. pop cx
  4029. cmp cx, 0FF00H
  4030. jne op15
  4031. (* byte aligned blocks *)
  4032. mov cx, [bp][len]
  4033. op10:
  4034. (*%F FastIO *)
  4035. extrn $OutWord
  4036. call $OutWord
  4037. (*%E *)
  4038. (*%T FastIO *)
  4039. out word dx, ax
  4040. (*%E *)
  4041. push ax
  4042. push di
  4043. mov bx, [bp][rows]
  4044. mov ah, [bp][NotFlag]
  4045. op11:
  4046. push di
  4047. push cx
  4048. op12:
  4049. lodsb
  4050. or si, si
  4051. jnz inSeg1
  4052. push ds
  4053. extrn @next_seg
  4054. call @next_seg
  4055. pop ds
  4056. inSeg1:
  4057. or ah, ah
  4058. jz EGApStore
  4059. not al
  4060. EGApStore:
  4061. and es:[di], al
  4062. inc di
  4063. loop op12
  4064. pop cx
  4065. pop di
  4066. add di, [bp][BytesPerRow]
  4067. dec bx
  4068. jnz op11
  4069. pop di
  4070. pop ax
  4071. push cx
  4072. mov cl, [bp][EGAPlaneShift]
  4073. shr ah, cl
  4074. pop cx
  4075. jnz op10
  4076. jmp near EGAPutExit
  4077. op15: (* non aligned blocks *)
  4078. push ax
  4079. mov bx, 0FFH
  4080. mov al, ch
  4081. cbw
  4082. cmp word [bp][len], 1
  4083. jne op16
  4084. mov bl, ch
  4085. mov ah, ch
  4086. sub al, al
  4087. op16:
  4088. shl ax, cl
  4089. shl bx, cl
  4090. mov bl, al
  4091. mov al, 8
  4092. mov [bp][endmaskL], ax
  4093. mov ah, bl
  4094. mov [bp][endmaskR], ax
  4095. mov ah, bh
  4096. mov [bp][startmask], ax
  4097. mov bx, [bp][len]
  4098. pop ax
  4099. op17:
  4100. (*%F FastIO *)
  4101. call $OutWord
  4102. (*%E *)
  4103. (*%T FastIO *)
  4104. out word dx, ax
  4105. (*%E *)
  4106. push ax
  4107. push di
  4108. mov dl, 0CEH
  4109. mov ax, [bp][rows]
  4110. mov [bp][rowcount], ax
  4111. op18:
  4112. push di
  4113. push ds
  4114. push si
  4115. push bx
  4116. mov ax, [bp][startmask]
  4117. (*%F FastIO *)
  4118. call $OutWord
  4119. (*%E *)
  4120. (*%T FastIO *)
  4121. out word dx, ax
  4122. (*%E *)
  4123. lodsb
  4124. or si, si
  4125. jnz inSeg2
  4126. push ds
  4127. call @next_seg
  4128. pop ds
  4129. inSeg2:
  4130. mov ah, al
  4131. lodsb
  4132. xchg ah, al
  4133. cmp byte [bp][NotFlag], 0
  4134. je noNot1
  4135. not ax
  4136. noNot1:
  4137. dec si
  4138. test cl, cl
  4139. jnz op19
  4140. dec bx
  4141. jnz op20
  4142. jmp op22
  4143. op19:
  4144. rol ax, cl
  4145. and es:[di], ah
  4146. inc di
  4147. dec bx
  4148. op20:
  4149. push ax
  4150. mov ax, 0FF08H
  4151. (*%F FastIO *)
  4152. call $OutWord
  4153. (*%E *)
  4154. (*%T FastIO *)
  4155. out word dx, ax
  4156. (*%E *)
  4157. pop ax
  4158. dec bx
  4159. jng op22
  4160. op21:
  4161. and es:[di], al
  4162. inc di
  4163. lodsb
  4164. or si, si
  4165. jnz inSeg3
  4166. push ds
  4167. call @next_seg
  4168. pop ds
  4169. inSeg3:
  4170. mov ah, al
  4171. lodsb
  4172. xchg ah, al
  4173. cmp byte [bp][NotFlag], 0
  4174. je noNot2
  4175. not ax
  4176. noNot2:
  4177. dec si
  4178. rol ax, cl
  4179. dec bx
  4180. jnz op21
  4181. op22:
  4182. mov bx, ax
  4183. mov ax, [bp][endmaskL]
  4184. (*%F FastIO *)
  4185. call $OutWord
  4186. (*%E *)
  4187. (*%T FastIO *)
  4188. out word dx, ax
  4189. (*%E *)
  4190. and es:[di], bl
  4191. mov ax, [bp][endmaskR]
  4192. (*%F FastIO *)
  4193. call $OutWord
  4194. (*%E *)
  4195. (*%T FastIO *)
  4196. out word dx, ax
  4197. (*%E *)
  4198. and es:[di][1], bh
  4199. pop bx
  4200. pop si
  4201. pop ds
  4202. add si, bx
  4203. jnc inSeg4
  4204. mov di, ds (*@@@ Ask Nigel *)
  4205. add di, 1000H
  4206. mov ds, di
  4207. inSeg4:
  4208. pop di
  4209. add di, [bp][BytesPerRow]
  4210. dec word [bp][rowcount]
  4211. jnz op18
  4212. pop di
  4213. pop ax
  4214. mov dl, 0C4H
  4215. push cx
  4216. mov cl, [bp][EGAPlaneShift]
  4217. shr ah, cl
  4218. pop cx
  4219. jnz op17
  4220. EGAPutExit:
  4221. (*%F NearCall *)
  4222. call far __resetEGA
  4223. (*%E *)
  4224. (*%T NearCall *)
  4225. call __resetEGA
  4226. (*%E *)
  4227. pop ds
  4228. pop si
  4229. pop di
  4230. mov sp, bp
  4231. pop bp
  4232. (*%F NearCall *)
  4233. ret far 0
  4234. (*%E *)
  4235. (*%T NearCall *)
  4236. ret 0
  4237. (*%E *)
  4238. (**************************************************************************)
  4239. section
  4240. (*%F NearCall *)
  4241. segment Graphics_TEXT(CODE,28H)
  4242. (*%E *)
  4243. (*%T NearCall *)
  4244. segment _TEXT(CODE,28H)
  4245. (*%E *)
  4246. segment _DATA(DATA, 28H)
  4247. (*%F NearCall *)
  4248. select Graphics_TEXT
  4249. (*%E *)
  4250. (*%T NearCall *)
  4251. select _TEXT
  4252. (*%E *)
  4253. public __EGAleftscan :
  4254. left = frame
  4255. border = frame
  4256. push bp
  4257. mov bp, sp
  4258. push di
  4259. push si
  4260. push ds
  4261. std
  4262. mov si, ax (* ptr *)
  4263. mov ds, bx
  4264. mov di, dx (* lim value *)
  4265. mov bp, [bp][left] (* left *)
  4266. mov bx, cx (* bl border *)
  4267. mov cx, 7 (* calculate mask *)
  4268. and cx, bp
  4269. mov ch, 80H
  4270. shr ch, cl
  4271. mov cl, ch (* cl = mask *)
  4272. mov dx, 03CEH (* set read mode *)
  4273. mov al, 5
  4274. out byte dx, al
  4275. mov al, 8
  4276. inc dx
  4277. out byte dx, al
  4278. dec dx
  4279. mov al, 2
  4280. out byte dx, al
  4281. inc dx
  4282. mov al, bl
  4283. out byte dx, al
  4284. dec dx
  4285. mov ax, 0FF08H
  4286. (*%F FastIO *)
  4287. extrn $OutWord
  4288. call $OutWord
  4289. (*%E *)
  4290. (*%T FastIO *)
  4291. out word dx, ax
  4292. (*%E *)
  4293. lodsb
  4294. scanLoop:
  4295. dec bp
  4296. cmp cl, 80H
  4297. je needNewByte
  4298. shl cl, 1
  4299. getPixel:
  4300. test al, cl
  4301. jnz scanDone
  4302. cmp bp, di
  4303. jge scanLoop
  4304. scanDone:
  4305. inc bp
  4306. mov ax, bp
  4307. cld
  4308. pop ds
  4309. pop si
  4310. pop di
  4311. pop bp
  4312. (*%F NearCall *)
  4313. ret far 2
  4314. (*%E *)
  4315. (*%T NearCall *)
  4316. ret 2
  4317. (*%E *)
  4318. needNewByte:
  4319. mov cl, 1H
  4320. newByteLoop:
  4321. lodsb
  4322. or al, al
  4323. jnz getPixel
  4324. sub bp, 8
  4325. cmp bp, di
  4326. jge newByteLoop
  4327. mov bp, di
  4328. dec bp
  4329. jmp scanDone
  4330. (**************************************************************************)
  4331. section
  4332. (*%F NearCall *)
  4333. segment Graphics_TEXT(CODE,28H)
  4334. (*%E *)
  4335. (*%T NearCall *)
  4336. segment _TEXT(CODE,28H)
  4337. (*%E *)
  4338. segment _DATA(DATA, 28H)
  4339. (*%F NearCall *)
  4340. select Graphics_TEXT
  4341. (*%E *)
  4342. (*%T NearCall *)
  4343. select _TEXT
  4344. (*%E *)
  4345. public __EGArightscan :
  4346. right = frame
  4347. border = frame
  4348. push bp
  4349. mov bp, sp
  4350. push di
  4351. push si
  4352. push ds
  4353. mov si, ax (* ptr *)
  4354. mov ds, bx
  4355. mov es, bx
  4356. mov di, dx (* lim value *)
  4357. mov bp, [bp][right] (* right *)
  4358. mov bx, cx (* bl border *)
  4359. mov cx, 7 (* calculate mask *)
  4360. and cx, bp
  4361. mov ch, 80H
  4362. shr ch, cl
  4363. mov cl, ch (* cl = mask *)
  4364. (* read mode set in left scan *)
  4365. lodsb
  4366. EGARsLoop:
  4367. inc bp
  4368. cmp cl, 1H
  4369. je EGAnNewByte
  4370. shr cl, 1
  4371. EGARgPixel:
  4372. test al, cl
  4373. jnz EGARsDone
  4374. cmp bp, di
  4375. jle EGARsLoop
  4376. EGARsDone:
  4377. dec bp
  4378. mov dx, 3CEH
  4379. mov al, 5
  4380. out byte dx, al
  4381. inc dx
  4382. mov al, 0
  4383. out byte dx, al
  4384. mov ax, bp
  4385. pop ds
  4386. pop si
  4387. pop di
  4388. pop bp
  4389. (*%F NearCall *)
  4390. ret far 2
  4391. (*%E *)
  4392. (*%T NearCall *)
  4393. ret 2
  4394. (*%E *)
  4395. EGAnNewByte:
  4396. mov ax, bp
  4397. mov cx, di
  4398. sub cx, bp
  4399. inc cx
  4400. mov bp, cx
  4401. and bp, 7
  4402. shr cx, 1
  4403. shr cx, 1
  4404. shr cx, 1
  4405. jcxz noneLeft
  4406. sub al, al
  4407. xchg si, di
  4408. repe ; scasb
  4409. xchg si, di
  4410. je byteF
  4411. inc cx
  4412. shl cx, 1
  4413. shl cx, 1
  4414. shl cx, 1
  4415. byteF:
  4416. mov ax, di
  4417. sub ax, cx
  4418. sub ax, bp
  4419. mov bp, ax
  4420. inc bp
  4421. cmp bp, di
  4422. ja EGARsDone
  4423. EGAFastDone:
  4424. dec si
  4425. EGAFastDone2:
  4426. lodsb
  4427. mov cl, 80H
  4428. jmp EGARgPixel
  4429. noneLeft:
  4430. mov bp, ax
  4431. jmp EGAFastDone2
  4432. (**************************************************************************)
  4433. section
  4434. (*%F NearCall *)
  4435. segment Graphics_TEXT(CODE,28H)
  4436. (*%E *)
  4437. (*%T NearCall *)
  4438. segment _TEXT(CODE,28H)
  4439. (*%E *)
  4440. segment _DATA(DATA, 28H)
  4441. extrn __pixeladdr320x200
  4442. extrn __pixeladdr640x200
  4443. select _DATA
  4444. extrn __width
  4445. (*%F NearCall *)
  4446. select Graphics_TEXT
  4447. (*%E *)
  4448. (*%T NearCall *)
  4449. select _TEXT
  4450. (*%E *)
  4451. (*
  4452. void CGAGet(unsigned char *buffer, short x1, y1, x2, y2);
  4453. *)
  4454. buffer = frame
  4455. x1 = 4+frame
  4456. y1 = 6+frame
  4457. x2 = 8+frame
  4458. y2 = 10+frame
  4459. len = -2
  4460. incr = -4
  4461. locals = 4
  4462. public __CGA320Get :
  4463. push bp
  4464. mov bp, sp
  4465. sub sp, locals
  4466. push di
  4467. push si
  4468. push ds
  4469. (*%F SameDS *)
  4470. mov si, _DATA
  4471. mov ds, si
  4472. (*%E *)
  4473. mov ax, [bp][x2] (* get block size *)
  4474. sub ax, [bp][x1]
  4475. mov cx, 0FF03H
  4476. and cl, al
  4477. xor cl, 3
  4478. shl cl, 1
  4479. shl ch, cl
  4480. mov cl, ch
  4481. push cx
  4482. mov cl, 2
  4483. shr ax, cl
  4484. inc ax
  4485. push ax
  4486. mov ax, [bp][y2]
  4487. sub ax, [bp][y1]
  4488. inc ax
  4489. push ax
  4490. mov ax, [bp][y1] (* compute video address *)
  4491. mov bx, [bp][x1]
  4492. call __pixeladdr320x200
  4493. xor cl, 6
  4494. jmp common
  4495. (*
  4496. void CGAGet(unsigned char *buffer, short x1, y1, x2, y2);
  4497. *)
  4498. public __CGA640Get :
  4499. push bp
  4500. mov bp, sp
  4501. sub sp, locals
  4502. push di
  4503. push si
  4504. push ds
  4505. (*%F SameDS *)
  4506. mov si, _DATA
  4507. mov ds, si
  4508. (*%E *)
  4509. mov ax, [bp][x2] (* get block size *)
  4510. sub ax, [bp][x1]
  4511. mov cx, 0FF07H
  4512. and cl, al
  4513. xor cl, 7
  4514. shl ch, cl
  4515. mov cl, ch
  4516. push cx
  4517. mov cl, 3
  4518. shr ax, cl
  4519. inc ax
  4520. push ax
  4521. mov ax, [bp][y2]
  4522. sub ax, [bp][y1]
  4523. inc ax
  4524. push ax
  4525. mov ax, [bp][y1] (* compute video address *)
  4526. mov bx, [bp][x1]
  4527. call __pixeladdr640x200
  4528. xor cl, 7
  4529. common:
  4530. push es
  4531. pop ds
  4532. mov si, bx
  4533. mov bx, 2000H
  4534. test si, 2000H
  4535. jz interleave1
  4536. mov bx, 80-2000H
  4537. interleave1:
  4538. mov [bp][incr], bx
  4539. les di, [bp][buffer]
  4540. pop ax (* pixel rows *)
  4541. stosw
  4542. mov dx, ax (* dx = row count *)
  4543. pop ax (* bytes per pixel row *)
  4544. stosb
  4545. mov [bp][len], ax
  4546. pop ax
  4547. stosb (* mask for last byte *)
  4548. mov ch, al
  4549. getLoop1:
  4550. mov bx, [bp][len]
  4551. push si
  4552. getLoop2:
  4553. lodsw
  4554. dec si
  4555. rol ax, cl
  4556. stosb
  4557. dec bx
  4558. jnz getLoop2
  4559. and es:[di][-1], ch
  4560. pop si
  4561. add si, [bp][incr]
  4562. mov ax, 2000H
  4563. xor ax, 80-2000H
  4564. xor [bp][incr], ax
  4565. dec dx
  4566. jnz getLoop1
  4567. pop ds
  4568. pop si
  4569. pop di
  4570. mov sp, bp
  4571. pop bp
  4572. (*%F NearCall *)
  4573. ret far 0
  4574. (*%E *)
  4575. (*%T NearCall *)
  4576. ret 0
  4577. (*%E *)
  4578. (**************************************************************************)
  4579. section
  4580. (*%F NearCall *)
  4581. segment Graphics_TEXT(CODE,28H)
  4582. (*%E *)
  4583. (*%T NearCall *)
  4584. segment _TEXT(CODE,28H)
  4585. (*%E *)
  4586. segment _DATA(DATA, 28H)
  4587. extrn __pixeladdr320x200
  4588. extrn __pixeladdr640x200
  4589. (*%F NearCall *)
  4590. select Graphics_TEXT
  4591. (*%E *)
  4592. (*%T NearCall *)
  4593. select _TEXT
  4594. (*%E *)
  4595. x1 = frame
  4596. y1 = 2+frame
  4597. buffer = 4+frame
  4598. action = 8+frame
  4599. len = -2
  4600. incr = -4
  4601. rows = -6
  4602. bitOp = -8
  4603. pixAddress = -10
  4604. lastMask = -12
  4605. clShift = -13
  4606. locals = 13
  4607. incRow:
  4608. add di, [bp][incr]
  4609. mov ax, 2000H
  4610. xor ax, 80-2000H
  4611. xor [bp][incr], ax
  4612. dec word [bp][rows]
  4613. ret 0
  4614. __setBlock:
  4615. cmp cx, 0FF00H
  4616. jnz L640op15
  4617. mov cx, [bp][len]
  4618. L640op10:
  4619. push cx
  4620. push di
  4621. rep ; movsb
  4622. pop di
  4623. pop cx
  4624. call incRow
  4625. jnz L640op10
  4626. jmp near L640setExit
  4627. L640op15:
  4628. not ch
  4629. mov dx, 0FF00H
  4630. ror dx, cl
  4631. mov bx, [bp][len]
  4632. dec bx
  4633. L640op16:
  4634. push di
  4635. or bx, bx
  4636. jz L640op18
  4637. push bx
  4638. L640op17:
  4639. and es:[di], dx
  4640. lodsb
  4641. sub ah, ah
  4642. ror ax, cl
  4643. or es:[di], ax
  4644. inc di
  4645. dec bx
  4646. jnz L640op17
  4647. pop bx
  4648. L640op18:
  4649. mov al, ch
  4650. mov ah, 0FFH
  4651. ror ax, cl
  4652. and es:[di], ax
  4653. lodsb
  4654. sub ah, ah
  4655. ror ax, cl
  4656. or es:[di], ax
  4657. pop di
  4658. call incRow
  4659. jnz L640op16
  4660. jmp near L640setExit
  4661. __XORBlock:
  4662. mov bx, [bp][len]
  4663. L640op20:
  4664. push di
  4665. push bx
  4666. L640op21:
  4667. lodsb
  4668. sub ah, ah
  4669. ror ax, cl
  4670. xor es:[di], ax
  4671. inc di
  4672. dec bx
  4673. jnz L640op21
  4674. pop bx
  4675. pop di
  4676. call incRow
  4677. jnz L640op20
  4678. jmp near L640setExit
  4679. __ANDBlock:
  4680. not ch
  4681. mov bx, [bp][len]
  4682. dec bx
  4683. L640op30:
  4684. push di
  4685. or bx, bx
  4686. jz L640op32
  4687. push bx
  4688. L640op31:
  4689. lodsb
  4690. mov ah, 0FFH
  4691. ror ax, cl
  4692. and es:[di], ax
  4693. inc di
  4694. dec bx
  4695. jnz L640op31
  4696. pop bx
  4697. L640op32:
  4698. lodsb
  4699. or al, ch
  4700. mov ah, 0FFH
  4701. ror ax, cl
  4702. and es:[di], ax
  4703. pop di
  4704. call incRow
  4705. jnz L640op30
  4706. jmp near L640setExit
  4707. __ORBlock:
  4708. mov bx, [bp][len]
  4709. L640op40:
  4710. push di
  4711. push bx
  4712. L640op41:
  4713. lodsb
  4714. sub ah, ah
  4715. ror ax, cl
  4716. or es:[di], ax
  4717. inc di
  4718. dec bx
  4719. jnz L640op41
  4720. pop bx
  4721. pop di
  4722. call incRow
  4723. jnz L640op40
  4724. jmp near L640setExit
  4725. __reverseBlock:
  4726. cmp cx, 0FF00H
  4727. jnz L640op55
  4728. mov cx, [bp][len]
  4729. L640op50:
  4730. push cx
  4731. push di
  4732. revLoop1:
  4733. lodsb
  4734. not al
  4735. stosb
  4736. loop revLoop1
  4737. pop di
  4738. pop cx
  4739. call incRow
  4740. jnz L640op50
  4741. jmp near L640setExit
  4742. L640op55:
  4743. not ch
  4744. mov dx, 0FF00H
  4745. ror dx, cl
  4746. mov bx, [bp][len]
  4747. dec bx
  4748. L640op56:
  4749. push di
  4750. or bx, bx
  4751. jz L640op58
  4752. push bx
  4753. L640op57:
  4754. and es:[di], dx
  4755. lodsb
  4756. sub ah, ah
  4757. not al
  4758. ror ax, cl
  4759. or es:[di], ax
  4760. inc di
  4761. dec bx
  4762. jnz L640op57
  4763. pop bx
  4764. L640op58:
  4765. mov al, ch
  4766. mov ah, 0FFH
  4767. ror ax, cl
  4768. and es:[di], ax
  4769. not ax
  4770. mov [bp][lastMask], ax
  4771. lodsb
  4772. sub ah, ah
  4773. not al
  4774. ror ax, cl
  4775. and ax, [bp][lastMask]
  4776. or es:[di], ax
  4777. pop di
  4778. call incRow
  4779. jnz L640op56
  4780. jmp near L640setExit
  4781. (*
  4782. void CGA640Put(short x1, y1, unsigned char *buffer, short action);
  4783. *)
  4784. public __CGA320Put :
  4785. push bp
  4786. mov bp, sp
  4787. sub sp, locals
  4788. mov word [bp][pixAddress], __pixeladdr320x200
  4789. mov byte [bp][clShift], 6
  4790. jmp PCGAcommon
  4791. public __CGA640Put :
  4792. push bp
  4793. mov bp, sp
  4794. sub sp, locals
  4795. mov word [bp][pixAddress], __pixeladdr640x200
  4796. mov byte [bp][clShift], 7
  4797. PCGAcommon:
  4798. push di
  4799. push si
  4800. push ds
  4801. (*%F SameDS *)
  4802. mov si, _DATA
  4803. mov ds, si
  4804. (*%E *)
  4805. mov ax, [bp][action]
  4806. or ax, ax
  4807. jnz L640op2
  4808. L640op1:
  4809. mov word [bp][bitOp], __ORBlock
  4810. jmp gotOp
  4811. L640op2:
  4812. dec ax
  4813. jnz L640op3
  4814. mov word [bp][bitOp], __ANDBlock
  4815. jmp gotOp
  4816. L640op3:
  4817. dec ax
  4818. jnz L640op4
  4819. mov word [bp][bitOp], __reverseBlock
  4820. jmp gotOp
  4821. L640op4:
  4822. dec ax
  4823. jnz L640op5
  4824. mov word [bp][bitOp], __setBlock
  4825. jmp gotOp
  4826. L640op5:
  4827. mov word [bp][bitOp], __XORBlock
  4828. gotOp:
  4829. mov ax, [bp][y1]
  4830. mov bx, [bp][x1]
  4831. call [bp][pixAddress]
  4832. xor cl, [bp][clShift]
  4833. mov di, bx
  4834. mov bx, 2000H
  4835. test di, 2000H
  4836. jz L640interleave1
  4837. mov bx, 80-2000H
  4838. L640interleave1:
  4839. mov [bp][incr], bx
  4840. lds si, [bp][buffer]
  4841. lodsw
  4842. mov [bp][rows], ax
  4843. lodsb
  4844. sub ah, ah
  4845. mov [bp][len], ax
  4846. lodsb
  4847. mov ch, al
  4848. jmp [bp][bitOp]
  4849. L640setExit:
  4850. pop ds
  4851. pop si
  4852. pop di
  4853. mov sp, bp
  4854. pop bp
  4855. (*%F NearCall *)
  4856. ret far 0
  4857. (*%E *)
  4858. (*%T NearCall *)
  4859. ret 0
  4860. (*%E *)
  4861. (**************************************************************************)
  4862. section
  4863. (*%F NearCall *)
  4864. segment Graphics_TEXT(CODE,28H)
  4865. (*%E *)
  4866. (*%T NearCall *)
  4867. segment _TEXT(CODE,28H)
  4868. (*%E *)
  4869. segment _DATA(DATA, 28H)
  4870. (*%F NearCall *)
  4871. select Graphics_TEXT
  4872. (*%E *)
  4873. (*%T NearCall *)
  4874. select _TEXT
  4875. (*%E *)
  4876. public __CGA320leftscan :
  4877. (*%T _DLLOVL *)
  4878. push bp
  4879. mov bp, sp
  4880. (*%E *)
  4881. push di
  4882. push si
  4883. push ds
  4884. std
  4885. mov si, ax (* ptr *)
  4886. (*%T _XTD *)
  4887. extrn __B800h
  4888. mov ax, __B800h
  4889. (*%E *)
  4890. (*%F _XTD *)
  4891. mov ax, 0B800H
  4892. (*%E *)
  4893. mov ds, ax
  4894. mov di, dx (* left *)
  4895. mov ax, dx
  4896. mov dx, cx (* limit *)
  4897. mov cl, 6
  4898. shl bl, cl
  4899. mov cx, ax
  4900. and cl, 3
  4901. shl cl, 1
  4902. mov bh, 0C0H
  4903. shr bx, cl
  4904. lodsb
  4905. CGALscanLoop:
  4906. dec di
  4907. rol bl, 1
  4908. rol bl, 1
  4909. rol bh, 1
  4910. rol bh, 1
  4911. jc CGALoad
  4912. CGAloadDone:
  4913. mov ah, al
  4914. and ah, bh
  4915. cmp ah, bl
  4916. je CGALscanDone
  4917. cmp di, dx
  4918. jge CGALscanLoop
  4919. CGALscanDone:
  4920. inc di
  4921. mov ax, di
  4922. cld
  4923. pop ds
  4924. pop si
  4925. pop di
  4926. (*%T _DLLOVL *)
  4927. pop bp
  4928. (*%E *)
  4929. (*%F NearCall *)
  4930. ret far 0
  4931. (*%E *)
  4932. (*%T NearCall *)
  4933. ret 0
  4934. (*%E *)
  4935. CGALoad:
  4936. lodsb
  4937. jmp CGAloadDone
  4938. (**************************************************************************)
  4939. section
  4940. (*%F NearCall *)
  4941. segment Graphics_TEXT(CODE,28H)
  4942. (*%E *)
  4943. (*%T NearCall *)
  4944. segment _TEXT(CODE,28H)
  4945. (*%E *)
  4946. segment _DATA(DATA, 28H)
  4947. (*%F NearCall *)
  4948. select Graphics_TEXT
  4949. (*%E *)
  4950. (*%T NearCall *)
  4951. select _TEXT
  4952. (*%E *)
  4953. public __CGA320rightscan :
  4954. push bp
  4955. mov bp, sp
  4956. push di
  4957. push si
  4958. push ds
  4959. mov si, ax (* ptr *)
  4960. (*%T _XTD *)
  4961. extrn __B800h
  4962. mov ax, __B800h
  4963. (*%E *)
  4964. (*%F _XTD *)
  4965. mov ax, 0B800H
  4966. (*%E *)
  4967. mov ds, ax
  4968. mov es, ax
  4969. mov di, dx (* right *)
  4970. mov ax, dx
  4971. mov dx, cx (* limit *)
  4972. mov cl, 6
  4973. shl bl, cl
  4974. mov cx, ax
  4975. and cl, 3
  4976. shl cl, 1
  4977. mov bh, 0C0H
  4978. shr bx, cl
  4979. mov cx, dx
  4980. sub cx, di
  4981. mov di, -1
  4982. lodsb
  4983. CGARscanLoop:
  4984. ror bl, 1
  4985. ror bl, 1
  4986. ror bh, 1
  4987. ror bh, 1
  4988. jc CGARLoad
  4989. CGARnoInc:
  4990. mov ah, al
  4991. and ah, bh
  4992. cmp ah, bl
  4993. loopne CGARscanLoop
  4994. CGARscanDone:
  4995. jne noInc
  4996. inc cx
  4997. noInc:
  4998. mov ax, dx
  4999. sub ax, cx
  5000. pop ds
  5001. pop si
  5002. pop di
  5003. pop bp
  5004. (*%F NearCall *)
  5005. ret far 0
  5006. (*%E *)
  5007. (*%T NearCall *)
  5008. ret 0
  5009. (*%E *)
  5010. CGARLoad:
  5011. inc di
  5012. jne CGARfastTest
  5013. lodsb
  5014. jmp CGARnoInc
  5015. CGARfastTest:
  5016. mov bp, cx
  5017. and bp, 3
  5018. shr cx, 1
  5019. shr cx, 1
  5020. jcxz CGARnoInc
  5021. mov di, si
  5022. repe ; scasb
  5023. jne foundNewByte
  5024. mov cx, bp
  5025. jcxz noInc
  5026. jmp setupNext
  5027. foundNewByte:
  5028. inc cx
  5029. shl cx, 1
  5030. shl cx, 1
  5031. add cx, bp
  5032. setupNext:
  5033. dec di
  5034. mov si, di
  5035. sub di, di
  5036. lodsb
  5037. jmp CGARnoInc
  5038. (**************************************************************************)
  5039. section
  5040. (*%F NearCall *)
  5041. segment Graphics_TEXT(CODE,28H)
  5042. (*%E *)
  5043. (*%T NearCall *)
  5044. segment _TEXT(CODE,28H)
  5045. (*%E *)
  5046. segment _DATA(DATA, 28H)
  5047. (*%F NearCall *)
  5048. select Graphics_TEXT
  5049. (*%E *)
  5050. (*%T NearCall *)
  5051. select _TEXT
  5052. (*%E *)
  5053. public __CGA640leftscan :
  5054. (*%T _DLLOVL *)
  5055. push bp
  5056. mov bp, sp
  5057. (*%E *)
  5058. push di
  5059. push si
  5060. push ds
  5061. std
  5062. mov si, ax (* ptr *)
  5063. (*%T _XTD *)
  5064. extrn __B800h
  5065. mov ax, __B800h
  5066. (*%E *)
  5067. (*%F _XTD *)
  5068. mov ax, 0B800H
  5069. (*%E *)
  5070. mov ds, ax
  5071. mov di, dx (* left *)
  5072. mov ax, dx
  5073. mov dx, cx (* limit *)
  5074. mov cx, 7
  5075. and ax, cx
  5076. sub cx, ax
  5077. lodsb
  5078. L640LscanLoop:
  5079. dec di
  5080. inc cl
  5081. cmp cl, 8
  5082. jnz L640LnoLoad
  5083. sub cl, cl
  5084. lodsb
  5085. L640LnoLoad:
  5086. mov ah, 1
  5087. shl ah, cl
  5088. and ah, al
  5089. shr ah, cl
  5090. cmp ah, bl
  5091. jz L640LscanDone
  5092. cmp di, dx
  5093. jge L640LscanLoop
  5094. L640LscanDone:
  5095. inc di
  5096. mov ax, di
  5097. cld
  5098. pop ds
  5099. pop si
  5100. pop di
  5101. (*%T _DLLOVL *)
  5102. pop bp
  5103. (*%E *)
  5104. (*%F NearCall *)
  5105. ret far 0
  5106. (*%E *)
  5107. (*%T NearCall *)
  5108. ret 0
  5109. (*%E *)
  5110. (**************************************************************************)
  5111. section
  5112. (*%F NearCall *)
  5113. segment Graphics_TEXT(CODE,28H)
  5114. (*%E *)
  5115. (*%T NearCall *)
  5116. segment _TEXT(CODE,28H)
  5117. (*%E *)
  5118. segment _DATA(DATA, 28H)
  5119. (*%F NearCall *)
  5120. select Graphics_TEXT
  5121. (*%E *)
  5122. (*%T NearCall *)
  5123. select _TEXT
  5124. (*%E *)
  5125. public __CGA640rightscan :
  5126. push bp
  5127. mov bp, sp
  5128. push di
  5129. push si
  5130. push ds
  5131. mov si, ax (* ptr *)
  5132. (*%T _XTD *)
  5133. extrn __B800h
  5134. mov ax, __B800h
  5135. (*%E *)
  5136. (*%F _XTD *)
  5137. mov ax, 0B800H
  5138. (*%E *)
  5139. mov ds, ax
  5140. mov es, ax
  5141. mov di, dx (* right *)
  5142. mov ax, dx
  5143. mov dx, cx (* limit *)
  5144. mov cl, 7
  5145. shl bl, cl
  5146. mov cx, ax
  5147. and cl, 7
  5148. mov bh, 080H
  5149. shr bx, cl
  5150. mov cx, dx
  5151. sub cx, di
  5152. mov di, -1
  5153. lodsb
  5154. CGARscanLoop:
  5155. ror bl, 1
  5156. ror bh, 1
  5157. jc CGARLoad
  5158. CGARnoInc:
  5159. mov ah, al
  5160. and ah, bh
  5161. cmp ah, bl
  5162. loopne CGARscanLoop
  5163. CGARscanDone:
  5164. jne noInc
  5165. inc cx
  5166. noInc:
  5167. mov ax, dx
  5168. sub ax, cx
  5169. pop ds
  5170. pop si
  5171. pop di
  5172. pop bp
  5173. (*%F NearCall *)
  5174. ret far 0
  5175. (*%E *)
  5176. (*%T NearCall *)
  5177. ret 0
  5178. (*%E *)
  5179. CGARLoad:
  5180. inc di
  5181. jne CGARfastTest
  5182. lodsb
  5183. jmp CGARnoInc
  5184. CGARfastTest:
  5185. mov bp, cx
  5186. and bp, 7
  5187. shr cx, 1
  5188. shr cx, 1
  5189. shr cx, 1
  5190. jcxz CGARnoInc
  5191. mov di, si
  5192. repe ; scasb
  5193. jne foundNewByte
  5194. mov cx, bp
  5195. jcxz noInc
  5196. jmp setupNext
  5197. foundNewByte:
  5198. inc cx
  5199. shl cx, 1
  5200. shl cx, 1
  5201. shl cx, 1
  5202. add cx, bp
  5203. setupNext:
  5204. dec di
  5205. mov si, di
  5206. sub di, di
  5207. lodsb
  5208. jmp CGARnoInc
  5209. (**************************************************************************)
  5210. section
  5211. (*%F NearCall *)
  5212. segment Graphics_TEXT(CODE,28H)
  5213. (*%E *)
  5214. (*%T NearCall *)
  5215. segment _TEXT(CODE,28H)
  5216. (*%E *)
  5217. segment _DATA(DATA, 28H)
  5218. extrn __pixeladdrHerc
  5219. (*%F NearCall *)
  5220. select Graphics_TEXT
  5221. (*%E *)
  5222. (*%T NearCall *)
  5223. select _TEXT
  5224. (*%E *)
  5225. (*
  5226. void HercGet(unsigned char *buffer, short x1, y1, x2, y2);
  5227. *)
  5228. buffer = frame
  5229. x1 = 4+frame
  5230. y1 = 6+frame
  5231. x2 = 8+frame
  5232. y2 = 10+frame
  5233. len = -2
  5234. leaf = -4
  5235. locals = 4
  5236. public __HercGet :
  5237. push bp
  5238. mov bp, sp
  5239. sub sp, locals
  5240. push di
  5241. push si
  5242. push ds
  5243. (*%F SameDS *)
  5244. mov si, _DATA
  5245. mov ds, si
  5246. (*%E *)
  5247. mov ax, [bp][x2] (* get block size *)
  5248. sub ax, [bp][x1]
  5249. mov cx, 0FF07H
  5250. and cl, al
  5251. xor cl, 7
  5252. shl ch, cl
  5253. mov cl, ch
  5254. push cx
  5255. mov cl, 3
  5256. shr ax, cl
  5257. inc ax
  5258. push ax
  5259. mov ax, [bp][y2]
  5260. sub ax, [bp][y1]
  5261. inc ax
  5262. push ax
  5263. mov ax, [bp][y1] (* compute video address *)
  5264. mov bx, [bp][x1]
  5265. call __pixeladdrHerc
  5266. xor cl, 7
  5267. push es
  5268. pop ds
  5269. mov si, bx
  5270. cmp si, 2000H
  5271. jb HGinterleave1
  5272. cmp si, 4000H
  5273. jb HGinterleave2
  5274. cmp si, 6000H
  5275. jb HGinterleave3
  5276. HGinterleave4:
  5277. mov bx, 3H
  5278. jmp HGgotInterleave
  5279. HGinterleave3:
  5280. mov bx, 2H
  5281. jmp HGgotInterleave
  5282. HGinterleave2:
  5283. mov bx, 1H
  5284. jmp HGgotInterleave
  5285. HGinterleave1:
  5286. mov bx, 0H
  5287. HGgotInterleave:
  5288. mov [bp][leaf], bx
  5289. les di, [bp][buffer]
  5290. pop ax (* pixel rows *)
  5291. stosw
  5292. mov dx, ax
  5293. pop ax (* bytes per pixel row *)
  5294. stosb
  5295. mov [bp][len], ax
  5296. pop ax
  5297. stosb (* mask for last byte *)
  5298. mov ch, al
  5299. HGgetLoop1:
  5300. mov bx, [bp][len]
  5301. push si
  5302. HGgetLoop2:
  5303. lodsw
  5304. dec si
  5305. rol ax, cl
  5306. stosb
  5307. dec bx
  5308. jnz HGgetLoop2
  5309. pop si
  5310. and es:[di][-1], ch
  5311. mov ax, [bp][leaf]
  5312. cmp ax, 3
  5313. jnz HGnotLast
  5314. sub ax, ax
  5315. mov [bp][leaf], ax
  5316. sub si, 6000H-90
  5317. jmp HGgotRow
  5318. HGnotLast:
  5319. inc ax
  5320. mov [bp][leaf], ax
  5321. add si, 2000H
  5322. HGgotRow:
  5323. dec dx
  5324. jnz HGgetLoop1
  5325. pop ds
  5326. pop si
  5327. pop di
  5328. mov sp, bp
  5329. pop bp
  5330. (*%F NearCall *)
  5331. ret far 0
  5332. (*%E *)
  5333. (*%T NearCall *)
  5334. ret 0
  5335. (*%E *)
  5336. (**************************************************************************)
  5337. section
  5338. (*%F NearCall *)
  5339. segment Graphics_TEXT(CODE,28H)
  5340. (*%E *)
  5341. (*%T NearCall *)
  5342. segment _TEXT(CODE,28H)
  5343. (*%E *)
  5344. segment _DATA(DATA, 28H)
  5345. extrn __pixeladdrHerc
  5346. (*%F NearCall *)
  5347. select Graphics_TEXT
  5348. (*%E *)
  5349. (*%T NearCall *)
  5350. select _TEXT
  5351. (*%E *)
  5352. x1 = frame
  5353. y1 = 2+frame
  5354. buffer = 4+frame
  5355. action = 8+frame
  5356. len = -2
  5357. leaf = -4
  5358. rows = -6
  5359. bitOp = -8
  5360. lastMask = -10
  5361. locals = 10
  5362. incRow:
  5363. mov ax, [bp][leaf]
  5364. cmp ax, 3
  5365. jnz notLast
  5366. sub ax, ax
  5367. mov [bp][leaf], ax
  5368. sub di, 6000H-90
  5369. jmp gotRow
  5370. notLast:
  5371. inc ax
  5372. mov [bp][leaf], ax
  5373. add di, 2000H
  5374. gotRow:
  5375. dec word [bp][rows]
  5376. ret 0
  5377. __setBlock:
  5378. cmp cx, 0FF00H
  5379. jnz op15
  5380. mov cx, [bp][len]
  5381. op10:
  5382. push cx
  5383. push di
  5384. rep ; movsb
  5385. pop di
  5386. pop cx
  5387. call incRow
  5388. jnz op10
  5389. jmp near setExit
  5390. op15:
  5391. not ch
  5392. mov dx, 0FF00H
  5393. ror dx, cl
  5394. mov bx, [bp][len]
  5395. dec bx
  5396. op16:
  5397. push di
  5398. or bx, bx
  5399. jz op18
  5400. push bx
  5401. op17:
  5402. and es:[di], dx
  5403. lodsb
  5404. sub ah, ah
  5405. ror ax, cl
  5406. or es:[di], ax
  5407. inc di
  5408. dec bx
  5409. jnz op17
  5410. pop bx
  5411. op18:
  5412. mov al, ch
  5413. mov ah, 0FFH
  5414. ror ax, cl
  5415. and es:[di], ax
  5416. lodsb
  5417. sub ah, ah
  5418. ror ax, cl
  5419. or es:[di], ax
  5420. pop di
  5421. call incRow
  5422. jnz op16
  5423. jmp near setExit
  5424. __XORBlock:
  5425. mov bx, [bp][len]
  5426. op20:
  5427. push di
  5428. push bx
  5429. op21:
  5430. lodsb
  5431. sub ah, ah
  5432. ror ax, cl
  5433. xor es:[di], ax
  5434. inc di
  5435. dec bx
  5436. jnz op21
  5437. pop bx
  5438. pop di
  5439. call incRow
  5440. jnz op20
  5441. jmp near setExit
  5442. __ANDBlock:
  5443. not ch
  5444. mov bx, [bp][len]
  5445. dec bx
  5446. op30:
  5447. push di
  5448. or bx, bx
  5449. jz op32
  5450. push bx
  5451. op31:
  5452. lodsb
  5453. mov ah, 0FFH
  5454. ror ax, cl
  5455. and es:[di], ax
  5456. inc di
  5457. dec bx
  5458. jnz op31
  5459. pop bx
  5460. op32:
  5461. lodsb
  5462. or al, ch
  5463. mov ah, 0FFH
  5464. ror ax, cl
  5465. and es:[di], ax
  5466. pop di
  5467. call incRow
  5468. jnz op30
  5469. jmp near setExit
  5470. __ORBlock:
  5471. mov bx, [bp][len]
  5472. op40:
  5473. push di
  5474. push bx
  5475. op41:
  5476. lodsb
  5477. sub ah, ah
  5478. ror ax, cl
  5479. or es:[di], ax
  5480. inc di
  5481. dec bx
  5482. jnz op41
  5483. pop bx
  5484. pop di
  5485. call incRow
  5486. jnz op40
  5487. jmp near setExit
  5488. __reverseBlock:
  5489. cmp cx, 0FF00H
  5490. jnz op55
  5491. mov cx, [bp][len]
  5492. op50:
  5493. push cx
  5494. push di
  5495. revLoop1:
  5496. lodsb
  5497. not al
  5498. stosb
  5499. loop revLoop1
  5500. pop di
  5501. pop cx
  5502. call incRow
  5503. jnz op50
  5504. jmp near setExit
  5505. op55:
  5506. not ch
  5507. mov dx, 0FF00H
  5508. ror dx, cl
  5509. mov bx, [bp][len]
  5510. dec bx
  5511. op56:
  5512. push di
  5513. or bx, bx
  5514. jz op58
  5515. push bx
  5516. op57:
  5517. and es:[di], dx
  5518. lodsb
  5519. not al
  5520. sub ah, ah
  5521. ror ax, cl
  5522. or es:[di], ax
  5523. inc di
  5524. dec bx
  5525. jnz op57
  5526. pop bx
  5527. op58:
  5528. mov al, ch
  5529. mov ah, 0FFH
  5530. ror ax, cl
  5531. and es:[di], ax
  5532. not ax
  5533. mov [bp][lastMask], ax
  5534. lodsb
  5535. sub ah, ah
  5536. not al
  5537. ror ax, cl
  5538. and ax, [bp][lastMask]
  5539. or es:[di], ax
  5540. pop di
  5541. call incRow
  5542. jnz op56
  5543. jmp near setExit
  5544. (*
  5545. void HercPut(short x1, y1, unsigned char *buffer, short action);
  5546. *)
  5547. public __HercPut :
  5548. push bp
  5549. mov bp, sp
  5550. sub sp, locals
  5551. push di
  5552. push si
  5553. push ds
  5554. (*%F SameDS *)
  5555. mov si, _DATA
  5556. mov ds, si
  5557. (*%E *)
  5558. mov ax, [bp][action]
  5559. or ax, ax
  5560. jnz op2
  5561. op1:
  5562. mov word [bp][bitOp], __ORBlock
  5563. jmp gotOp
  5564. op2:
  5565. dec ax
  5566. jnz op3
  5567. mov word [bp][bitOp], __ANDBlock
  5568. jmp gotOp
  5569. op3:
  5570. dec ax
  5571. jnz op4
  5572. mov word [bp][bitOp], __reverseBlock
  5573. jmp gotOp
  5574. op4:
  5575. dec ax
  5576. jnz op5
  5577. mov word [bp][bitOp], __setBlock
  5578. jmp gotOp
  5579. op5:
  5580. mov word [bp][bitOp], __XORBlock
  5581. gotOp:
  5582. mov ax, [bp][y1]
  5583. mov bx, [bp][x1]
  5584. call __pixeladdrHerc
  5585. xor cl, 7
  5586. mov di, bx
  5587. cmp di, 2000H
  5588. jb interleave1
  5589. cmp di, 4000H
  5590. jb interleave2
  5591. cmp di, 6000H
  5592. jb interleave3
  5593. interleave4:
  5594. mov bx, 3H
  5595. jmp gotInterleave
  5596. interleave3:
  5597. mov bx, 2H
  5598. jmp gotInterleave
  5599. interleave2:
  5600. mov bx, 1H
  5601. jmp gotInterleave
  5602. interleave1:
  5603. mov bx, 0H
  5604. gotInterleave:
  5605. mov [bp][leaf], bx
  5606. lds si, [bp][buffer]
  5607. lodsw
  5608. mov [bp][rows], ax
  5609. lodsb
  5610. sub ah, ah
  5611. mov [bp][len], ax
  5612. lodsb
  5613. mov ch, al
  5614. mov bx, [bp][len]
  5615. jmp [bp][bitOp]
  5616. setExit:
  5617. pop ds
  5618. pop si
  5619. pop di
  5620. mov sp, bp
  5621. pop bp
  5622. (*%F NearCall *)
  5623. ret far 0
  5624. (*%E *)
  5625. (*%T NearCall *)
  5626. ret 0
  5627. (*%E *)
  5628. (**************************************************************************)
  5629. section
  5630. (*%F NearCall *)
  5631. segment Graphics_TEXT(CODE,28H)
  5632. (*%E *)
  5633. (*%T NearCall *)
  5634. segment _TEXT(CODE,28H)
  5635. (*%E *)
  5636. segment _DATA(DATA, 28H)
  5637. select _DATA
  5638. extrn __active_page
  5639. extrn __page_size
  5640. extrn __bkcolor
  5641. (*%F NearCall *)
  5642. select Graphics_TEXT
  5643. (*%E *)
  5644. (*%T NearCall *)
  5645. select _TEXT
  5646. (*%E *)
  5647. public __clear_Herc :
  5648. (*%T _DLLOVL *)
  5649. push bp
  5650. mov bp, sp
  5651. (*%E *)
  5652. push di
  5653. (*%F SameDS *)
  5654. push ds
  5655. mov ax, _DATA
  5656. mov ds, ax
  5657. (*%E *)
  5658. mov ax, [__active_page]
  5659. mul word [__page_size]
  5660. (*%T _XTD *)
  5661. db 0C1H,0F8H,004H (*I shl ax, 4 *)
  5662. mov di, ax
  5663. extrn __B000h
  5664. mov ax, __B000h
  5665. (*%E *)
  5666. (*%F _XTD *)
  5667. add ax, 0B000H
  5668. sub di, di
  5669. (*%E *)
  5670. mov es, ax
  5671. mov ax, [__bkcolor]
  5672. jz black
  5673. mov ax, 0FFFFH
  5674. black:
  5675. mov cx, 4000H
  5676. rep; stosw
  5677. (*%F SameDS *)
  5678. pop ds
  5679. (*%E *)
  5680. pop di
  5681. (*%T _DLLOVL *)
  5682. pop bp
  5683. (*%E *)
  5684. (*%F NearCall *)
  5685. ret far 0
  5686. (*%E *)
  5687. (*%T NearCall *)
  5688. ret 0
  5689. (*%E *)
  5690. (**************************************************************************)
  5691. section
  5692. (*%F NearCall *)
  5693. segment Graphics_TEXT(CODE,28H)
  5694. (*%E *)
  5695. (*%T NearCall *)
  5696. segment _TEXT(CODE,28H)
  5697. (*%E *)
  5698. segment _DATA(DATA, 28H)
  5699. select _DATA
  5700. extrn __fgcolor
  5701. extrn __bkcolor
  5702. extrn __display_state
  5703. extrn __active_page
  5704. extrn __txcolor
  5705. extrn __current_video
  5706. extrn __HercPut
  5707. extrn __current_text
  5708. __GPSET = 3
  5709. __GPRESET = 2
  5710. __GPAND = 1
  5711. __GPOR = 0
  5712. __GPXOR = 4
  5713. __RHUNDLIN = 8
  5714. mode = 14 (* current video mode *)
  5715. _HERCMONO = 8 (* 720 x 348, BW for HGC *)
  5716. (* Buffer for character shape in putimage format for hercules *)
  5717. __PixRows : dw 12 (* pixel rows per char - 12 vertical **)
  5718. __BytsPerRow : db 1 (* 8 bit wide chars **)
  5719. __FinalMask : db 0FFH (* All bits matter **)
  5720. dw 0 (* Two zero pixel rows **)
  5721. __Character : dw 0,0,0,0 (* 8 pixel rows **)
  5722. __Underline : db 0 (* This byte for underlining **)
  5723. db 0 (* 1 more zero pixel row **)
  5724. (*%F NearCall *)
  5725. select Graphics_TEXT
  5726. (*%E *)
  5727. (*%T NearCall *)
  5728. select _TEXT
  5729. (*%E *)
  5730. public __txt_out :
  5731. chk = frame
  5732. push bp
  5733. mov bp, sp
  5734. (*%F SameDS *)
  5735. push ds
  5736. mov ax, _DATA
  5737. mov ds, ax
  5738. (*%E *)
  5739. mov ah, 9
  5740. mov bh, [__active_page]
  5741. mov al, [bp][chk]
  5742. mov cl, 4
  5743. mov bl, [__bkcolor]
  5744. shl bl, cl
  5745. mov dl, [__txcolor]
  5746. mov dh, dl
  5747. and dl, 0FH
  5748. or bl, dl
  5749. test dh, 10H
  5750. jz outChar
  5751. or bl, 80H
  5752. outChar:
  5753. cmp word ds:[__current_video][mode], _HERCMONO
  5754. jz herc_text
  5755. mov cx, 1
  5756. int 10H
  5757. done:
  5758. (*%F SameDS *)
  5759. pop ds
  5760. (*%E *)
  5761. pop bp
  5762. (*%F NearCall *)
  5763. ret far 0
  5764. (*%E *)
  5765. (*%T NearCall *)
  5766. ret 0
  5767. (*%E *)
  5768. (* Obtain the character shape from the bios table at F000:FA6E**)
  5769. (* al = char to output **)
  5770. herc_text:
  5771. push di
  5772. push si
  5773. (* Copy char shape from bios table into buffer **)
  5774. mov bl, al (* char to output *)
  5775. xor bh, bh
  5776. push ds
  5777. mov ax, ds
  5778. mov es, ax
  5779. (*%F _XTD *)
  5780. mov ax, 0F000H (* bios segment *)
  5781. (*%E *)
  5782. (*%T _XTD *)
  5783. extrn __F000h
  5784. mov ax, __F000h
  5785. (*%E *)
  5786. mov ds, ax
  5787. mov ax, 0FA6EH (* char table starting offset *)
  5788. mov cl, 3
  5789. shl bx, cl (* char code * 8 (8 bytes in table/char) *)
  5790. add ax, bx (* offset of char in table *)
  5791. mov si, ax (* ds:si is char loc in bios **)
  5792. mov di, __Character (* address of dest. down here **)
  5793. lodsw
  5794. stosw
  5795. lodsw
  5796. stosw
  5797. lodsw
  5798. stosw
  5799. lodsw
  5800. stosw
  5801. xor al, al (* Assume no underline *)
  5802. xor dh, dh (* dx is foreground 'colour' *)
  5803. mov cx, dx
  5804. and cl, 07H
  5805. and dl, 08H (* dx is underline bit **)
  5806. jz normal
  5807. not al
  5808. normal:
  5809. stosb
  5810. pop ds
  5811. (* Now call HercPut to load the character shape onto the screen RAM **)
  5812. push cx
  5813. push ds (* buffer *)
  5814. mov cx, __PixRows
  5815. push cx
  5816. mov al, [__current_text] (* convert row to y pixels *)
  5817. xor ah, ah
  5818. shl ax, 1
  5819. shl ax, 1
  5820. mov bx, ax
  5821. shl ax, 1
  5822. add ax, bx (* row * 12 *)
  5823. push ax
  5824. mov al, [__current_text][2] (* convert col to x pixels *)
  5825. xor ah, ah
  5826. mov cl, 3
  5827. shl ax, cl
  5828. push ax
  5829. (*%F NearCall *)
  5830. call far __HercPut
  5831. (*%E *)
  5832. (*%T NearCall *)
  5833. call __HercPut
  5834. (*%E *)
  5835. add sp, 0AH
  5836. pop si
  5837. pop di
  5838. jmp done
  5839. (**************************************************************************)
  5840. section
  5841. (*%F NearCall *)
  5842. segment Graphics_TEXT(CODE,28H)
  5843. (*%E *)
  5844. (*%T NearCall *)
  5845. segment _TEXT(CODE,28H)
  5846. (*%E *)
  5847. segment _DATA(DATA, 28H)
  5848. select _DATA
  5849. extrn __fgcolor
  5850. extrn __bkcolor
  5851. extrn __display_state
  5852. extrn __active_page
  5853. extrn __txcolor
  5854. (*%F NearCall *)
  5855. select Graphics_TEXT
  5856. (*%E *)
  5857. (*%T NearCall *)
  5858. select _TEXT
  5859. (*%E *)
  5860. public __gcur :
  5861. (*%T _DLLOVL *)
  5862. push bp
  5863. mov bp, sp
  5864. (*%E *)
  5865. push ax
  5866. mov ah, 2
  5867. mov bh, dl
  5868. mov dl, cl
  5869. mov dh, bl
  5870. int 10H
  5871. pop bx
  5872. or bl, 80H
  5873. mov ah, 9
  5874. mov al, 219
  5875. outChar:
  5876. mov cx, 1
  5877. int 10H
  5878. (*%T _DLLOVL *)
  5879. pop bp
  5880. (*%E *)
  5881. (*%F NearCall *)
  5882. ret far 0
  5883. (*%E *)
  5884. (*%T NearCall *)
  5885. ret 0
  5886. (*%E *)
  5887. (**************************************************************************)
  5888. section
  5889. (*%F NearCall *)
  5890. segment Graphics_TEXT(CODE,28H)
  5891. (*%E *)
  5892. (*%T NearCall *)
  5893. segment _TEXT(CODE,28H)
  5894. (*%E *)
  5895. segment _DATA(DATA, 28H)
  5896. select _DATA
  5897. extrn __defaultmode
  5898. (*%F NearCall *)
  5899. select Graphics_TEXT
  5900. (*%E *)
  5901. (*%T NearCall *)
  5902. select _TEXT
  5903. (*%E *)
  5904. public __setbiosmode :
  5905. mode = frame
  5906. push bp
  5907. mov bp, sp
  5908. mov ax, [bp][mode]
  5909. mov ah, 0H
  5910. int 10H
  5911. pop bp
  5912. (*%F NearCall *)
  5913. ret far 0
  5914. (*%E *)
  5915. (*%T NearCall *)
  5916. ret 0
  5917. (*%E *)
  5918. (**************************************************************************)
  5919. section
  5920. (*%F NearCall *)
  5921. segment Graphics_TEXT(CODE,28H)
  5922. (*%E *)
  5923. (*%T NearCall *)
  5924. segment _TEXT(CODE,28H)
  5925. (*%E *)
  5926. segment _DATA(DATA, 28H)
  5927. (*%F NearCall *)
  5928. select Graphics_TEXT
  5929. (*%E *)
  5930. (*%T NearCall *)
  5931. select _TEXT
  5932. (*%E *)
  5933. public __getvideomode :
  5934. (*%T _DLLOVL *)
  5935. push bp
  5936. mov bp, sp
  5937. (*%E *)
  5938. mov ah, 0FH
  5939. int 10H
  5940. sub ah, ah
  5941. (*%T _DLLOVL *)
  5942. pop bp
  5943. (*%E *)
  5944. (*%F NearCall *)
  5945. ret far 0
  5946. (*%E *)
  5947. (*%T NearCall *)
  5948. ret 0
  5949. (*%E *)
  5950. (**************************************************************************)
  5951. section
  5952. (*%F NearCall *)
  5953. segment Graphics_TEXT(CODE,28H)
  5954. (*%E *)
  5955. (*%T NearCall *)
  5956. segment _TEXT(CODE,28H)
  5957. (*%E *)
  5958. segment _DATA(DATA, 28H)
  5959. (*%F NearCall *)
  5960. select Graphics_TEXT
  5961. (*%E *)
  5962. (*%T NearCall *)
  5963. select _TEXT
  5964. (*%E *)
  5965. public __change_screen_background :
  5966. (*%T _DLLOVL *)
  5967. push bp
  5968. mov bp, sp
  5969. (*%E *)
  5970. push di
  5971. push si
  5972. push ds
  5973. mov es, bx
  5974. mov ds, bx
  5975. mov di, ax
  5976. mov si, ax
  5977. shl dl, 1
  5978. shl dl, 1
  5979. shl dl, 1
  5980. shl dl, 1
  5981. changeLoop:
  5982. lodsw
  5983. and ah, 0FH
  5984. or ah, dl
  5985. stosw
  5986. loop changeLoop
  5987. pop ds
  5988. pop si
  5989. pop di
  5990. (*%T _DLLOVL *)
  5991. pop bp
  5992. (*%E *)
  5993. (*%F NearCall *)
  5994. ret far 0
  5995. (*%E *)
  5996. (*%T NearCall *)
  5997. ret 0
  5998. (*%E *)
  5999. (****************************************************************************)
  6000. section
  6001. (*%F NearCall *)
  6002. segment Graphics_TEXT(CODE,28H)
  6003. (*%E *)
  6004. (*%T NearCall *)
  6005. segment _TEXT(CODE,28H)
  6006. (*%E *)
  6007. segment _DATA(DATA, 28H)
  6008. extrn __FindPS2
  6009. extrn __FindEGA
  6010. extrn __FindCGA
  6011. extrn __FindMono
  6012. select _DATA
  6013. public __TestSequence: db 0 (* this list of flags and addresses *)
  6014. dw __FindPS2 (* determines the order in which this *)
  6015. (* program looks for the various *) (* subsystems *)
  6016. public __EGAflag : db 0
  6017. dw __FindEGA
  6018. public __CGAflag : db 0
  6019. dw __FindCGA
  6020. public __Monoflag : db 0
  6021. dw __FindMono
  6022. (****************************************************************************)
  6023. section
  6024. (*%F NearCall *)
  6025. segment Graphics_TEXT(CODE,28H)
  6026. (*%E *)
  6027. (*%T NearCall *)
  6028. segment _TEXT(CODE,28H)
  6029. (*%E *)
  6030. segment _DATA(DATA, 28H)
  6031. select _DATA
  6032. (*%F NearCall *)
  6033. select Graphics_TEXT
  6034. (*%E *)
  6035. (*%T NearCall *)
  6036. select _TEXT
  6037. (*%E *)
  6038. (* TYPE
  6039. VIDstruct = RECORD
  6040. VideoSubsystem0 : SHORTCARD
  6041. Display0 : SHORTCARD
  6042. VideoSubsystem1 : SHORTCARD
  6043. Display1 : SHORTCARD
  6044. END
  6045. PROCEDURE VideoID(VAR vs: VIDstruct)
  6046. Subsystem ID values:
  6047. 0 = (none)
  6048. 1 = MDA
  6049. 2 = CGA
  6050. 3 = EGA
  6051. 4 = MCGA
  6052. 5 = VGA
  6053. 80h = HGC
  6054. 81h = HGC+
  6055. 82h = Hercules InColor
  6056. Display types: 0 = (none)
  6057. 1 = MDA-compatible monochrome
  6058. 2 = CGA-compatible color
  6059. 3 = EGA-compatible color
  6060. 4 = PS/2-compatible monochrome
  6061. 5 = PS/2-compatible color
  6062. The values returned in VIDstruct[0].VideoSubsystem and
  6063. VIDstruct[0].Display indicate the currently active subsystem.
  6064. *)
  6065. Video0Type = 0 (* first subsytem type *)
  6066. Display0Type = 1 (* display attached to first subsystem *)
  6067. Video1Type = 2 (* second subsystem type *)
  6068. Display1Type = 3 (* display attached to second subsystem *)
  6069. Device0 = 0
  6070. Device1 = 2
  6071. MDA = 1
  6072. CGA = 2
  6073. EGA = 3
  6074. MCGA = 4
  6075. VGA = 5
  6076. HGC = 80H
  6077. HGCPlus = 81H
  6078. InColor = 82H
  6079. MDADisplay = 1
  6080. CGADisplay = 2
  6081. EGAColorDisplay = 3
  6082. PS2MonoDisplay = 4
  6083. PS2ColorDisplay = 5
  6084. TRUE = 1
  6085. FALSE = 0
  6086. select _DATA
  6087. extrn __Monoflag
  6088. extrn __EGAflag
  6089. extrn __CGAflag
  6090. extrn __TestSequence
  6091. EGADisplays : db CGADisplay (* 0000b, 0001b (EGA switch values) *)
  6092. db EGAColorDisplay (* 0010b, 0011b *)
  6093. db MDADisplay (* 0100b, 0101b *)
  6094. db CGADisplay (* 0110b, 0111b *)
  6095. db EGAColorDisplay (* 1000b, 1001b *)
  6096. db MDADisplay (* 1010b, 1011b *)
  6097. DCCtable : db 0,0 (* translate table for INT 10H func 1AH *)
  6098. db MDA,MDADisplay
  6099. db CGA,CGADisplay
  6100. db 0,0
  6101. db EGA,EGAColorDisplay
  6102. db EGA,MDADisplay
  6103. db 0,0
  6104. db VGA,PS2MonoDisplay
  6105. db VGA,PS2ColorDisplay
  6106. db 0,0
  6107. db MCGA,EGAColorDisplay
  6108. db MCGA,PS2MonoDisplay
  6109. db MCGA,PS2ColorDisplay
  6110. NumberOfTests = 4
  6111. (*%F NearCall *)
  6112. select Graphics_TEXT
  6113. (*%E *)
  6114. (*%T NearCall *)
  6115. select _TEXT
  6116. (*%E *)
  6117. (*
  6118. __FindPS2
  6119. This subroutine uses INT 10H function 1AH to determine the video BIOS
  6120. Display Combination Code (DCC) for each video subsystem present.
  6121. *)
  6122. public __FindPS2 :
  6123. mov ax, 1A00H
  6124. int 10H (* call video BIOS for info *)
  6125. cmp al, 1AH (* exit if function not supported (i.e., *)
  6126. jne L13 (* no MCGA or VGA in system) *)
  6127. (* convert BIOS DCCs into specific subsystems & displays *)
  6128. mov cx, bx
  6129. xor bh, bh (* BX := DCC for active subsystem *)
  6130. or ch, ch
  6131. jz L11 (* jump if only one subsystem present *)
  6132. mov bl, ch (* BX := inactive DCC *)
  6133. add bx, bx
  6134. mov ax, [bx][DCCtable]
  6135. mov es:[di][Device1], ax
  6136. mov bl, cl
  6137. xor bh, bh (* BX := active DCC *)
  6138. L11:
  6139. add bx, bx
  6140. mov ax, [bx][DCCtable]
  6141. mov es:[di][Device0], ax
  6142. (* reset flags for subsystems that have been ruled out *)
  6143. mov byte [__CGAflag], FALSE
  6144. mov byte [__EGAflag], FALSE
  6145. mov byte [__Monoflag], FALSE
  6146. lea bx, [Video0Type][di] (* if the BIOS reported an MDA ... *)
  6147. cmp byte es:[bx], MDA
  6148. je L12
  6149. lea bx, [Video1Type][di] (* if the BIOS reported an MDA ... *)
  6150. cmp byte es:[bx], MDA
  6151. jne L13
  6152. L12:
  6153. mov word es:[bx], 0 (* ..... Hercules can't be ruled out *)
  6154. mov byte [__Monoflag], TRUE
  6155. L13:
  6156. ret 0
  6157. (* Look for an EGA. This is done by making a call to an EGA BIOS function
  6158. which doesn't exist in the default (MDA, CGA) BIOS.
  6159. *)
  6160. public __FindEGA : (* Caller: AH = flags *)
  6161. (* Returns: AH = flags *)
  6162. (* Video0Type and *)
  6163. (* Display0Type updated *)
  6164. mov bl, 10H (* BL := 10H (return EGA info) *)
  6165. mov ah, 12H
  6166. int 10H (* call EGA BIOS for info *)
  6167. (* if EGA BIOS is present *)
  6168. (* BL <> 10H *)
  6169. (* CL = switch setting *)
  6170. cmp bl,10H
  6171. je L22 (* jump if EGA BIOS not present *)
  6172. mov al, cl
  6173. shr al, 1 (* AL := switches/2 *)
  6174. mov bx, EGADisplays
  6175. xlat (* determine display type from switches *)
  6176. mov ah, al (* AH := display type *)
  6177. mov al, EGA (* AL := subsystem type *)
  6178. call FoundDevice
  6179. cmp ah, MDADisplay
  6180. je L21 (* jump if EGA has a monochrome display *)
  6181. mov byte [__CGAflag], FALSE(* no CGA if EGA has color display *)
  6182. jmp L22
  6183. L21:
  6184. mov byte [__Monoflag], FALSE (* EGA has a mono display, so MDA and *)
  6185. (* Hercules are ruled out *)
  6186. L22:
  6187. ret 0
  6188. (* This is done by looking for the CGA's 6845 CRTC at I/O port 3D4H *)
  6189. public __FindCGA : (* Returns: VIDstruct updated *)
  6190. mov dx, 3D4H (* DX := CRTC address port *)
  6191. call __Find6845
  6192. jc L31 (* jump if not present *)
  6193. mov al, CGA
  6194. mov ah, CGADisplay
  6195. call FoundDevice
  6196. L31:
  6197. ret 0
  6198. (*
  6199. __FindMono This is done by looking for the MDA's 6845 CRTC at I/O port 3B4H.
  6200. If a 6845 is found, the subroutine distinguishes between an MDA
  6201. and a Hercules adapter by monitoring bit 7 of the CRT Status byte.
  6202. This bit changes on Hercules adapters but does not change on an MDA.
  6203. The various Hercules adapters are identified by bits 4 through 6 of
  6204. the CRT Status value:
  6205. 000BH = HGC
  6206. 001BH = HGC+
  6207. 101BH = InColor card
  6208. *)
  6209. public __FindMono : (* Returns: VIDstruct updated *)
  6210. xor bx, bx (* Clear RetraceToggle *)
  6211. mov dx, 003BAH (* Set DX := Status Port Address *)
  6212. in al, dx (* Get Status Byte *)
  6213. and al, 080H (* Mask out bits 0..6 *)
  6214. mov ah, al (* Store RdPort in AH *)
  6215. mov cx, 08000H (* Set loop count to 32767 *)
  6216. $$RdPortLoop:
  6217. dec cx
  6218. jcxz $$RdPortDone
  6219. $$RdPortLoop2:
  6220. in al, dx (* Get Status Byte *)
  6221. and al, 080H (* Mask out bits 0..6 *)
  6222. cmp al, ah (* Same as last time? *)
  6223. jz $$RdPortLoop (* If So, try again *)
  6224. in al, dx (* Otherwise, update RdPort *)
  6225. and al, 080H
  6226. mov ah, al
  6227. inc bx (* Increase RetraceToggle *)
  6228. loop $$RdPortLoop2
  6229. $$RdPortDone:
  6230. mov ah, MDADisplay (* Assume MDA *)
  6231. cmp bx, 2 (* Did the Retrace Toggle > twice *)
  6232. ja $$IsHerc (* If so, it's a Herc *)
  6233. mov al, MDA (* If not, it's a plain MDA *)
  6234. jmp $$Exit
  6235. $$IsHerc:
  6236. in al, dx (* Get the Status Byte *)
  6237. and al, 70H (* Mask out bits 0..3 *)
  6238. cmp al, 10H (* Is it a HGC+ ? *)
  6239. jnz $$NotPlus (* If not, keep looking *)
  6240. mov al, HGCPlus (* If so, tell the world *)
  6241. jmp $$Exit
  6242. $$NotPlus:
  6243. cmp al, 50H (* Is it an InColor Card *)
  6244. jnz $$PlainHGC (* If not, keep looking *)
  6245. mov ah, EGAColorDisplay (* InColor is EGA compatible *)
  6246. mov al, InColor (* Shout it loud *)
  6247. jmp $$Exit
  6248. $$PlainHGC:
  6249. mov al, HGC (* It must be a plain HGC *)
  6250. $$Exit:
  6251. call FoundDevice (* update VideoConfig *)
  6252. ret 0 (* Go Home *)
  6253. (*
  6254. __Find6845 This routine detects the presence of the CRTC on an MDA,CGA, or
  6255. HGC. The technique is to write and read register 0FH of the chip (Cursor
  6256. Location low). If the same value is read as written, assume the chip
  6257. is present at the specified port address.
  6258. *)
  6259. __Find6845 :
  6260. (* Caller: DX = port addr *)
  6261. (* Returns: cf set if not present *)
  6262. mov al, 0FH
  6263. out byte dx, al (* select 6845 reg 0FH (Cursor Low) *)
  6264. inc dx
  6265. in al, dx (* AL := current Cursor Low value *)
  6266. mov ah, al (* preserve in AH *)
  6267. mov al, 66H (* AL := arbritrary value *)
  6268. out byte dx, al (* try to write to 6845 *)
  6269. mov cx, 8000H
  6270. L51:
  6271. loop L51 (* wait for 6845 to respond *)
  6272. in al, dx
  6273. xchg ah, al (* AH := returned value *)
  6274. (* AL := original value *)
  6275. out byte dx, al (* restore original value *)
  6276. cmp ah, 66H (* test whether 6845 responded *)
  6277. je L52 (* jump if it did cf is reset *)
  6278. stc (* set carry flag if no 6845 present *)
  6279. ret 0
  6280. L52:
  6281. clc
  6282. ret 0
  6283. __FindHercMode:
  6284. mov ax, 0F00H
  6285. int 10H
  6286. cmp al, 7
  6287. jne noMono
  6288. clc
  6289. ret 0
  6290. noMono:
  6291. stc
  6292. ret 0
  6293. (* __FindActive This subroutine stores the currently active device as Device0.
  6294. The current video mode determines which subsystem is active.
  6295. *)
  6296. __FindActive :
  6297. cmp word es:[di][Device1], 0
  6298. je L63 (* exit if only one subsystem *)
  6299. cmp byte es:[Video0Type][di], 4 (* exit if MCGA or VGA present *)
  6300. jge L63 (* INT 10H function 1AH *)
  6301. cmp byte es:[Video1Type][di], 4 (* already did the work *)
  6302. jge L63
  6303. mov ah, 0FH
  6304. int 10H (* AL := current BIOS video mode *)
  6305. and al, 7
  6306. cmp al, 7 (* jump if monochrome *)
  6307. je L61 (* (mode 7 or 0FH) *)
  6308. cmp byte es:[Display0Type][di], MDADisplay
  6309. L61:
  6310. jne L63 (* exit if Display0 is monochrome *)
  6311. L62:
  6312. mov ax, es:[di][Device0] (* make Device0 currently active *)
  6313. xchg ax, es:[di][Device1]
  6314. mov es:[di][Device0], ax
  6315. L63:
  6316. ret 0
  6317. (*
  6318. FoundDevice This routine updates the list of subsystems
  6319. *)
  6320. FoundDevice :
  6321. (* Caller: AH = display # *)
  6322. (* AL = subsystem # *)
  6323. (* Destroys: BX *)
  6324. lea bx, es:[Video0Type][di]
  6325. cmp byte es:[bx], 0
  6326. je L71 (* jump if 1st subsystem *)
  6327. lea bx, es:[Video1Type][di] (* must be 2nd subsystem *)
  6328. L71:
  6329. mov es:[bx], ax (* update list entry *)
  6330. ret 0
  6331. (*%F NearCall *)
  6332. select Graphics_TEXT
  6333. (*%E *)
  6334. (*%T NearCall *)
  6335. select _TEXT
  6336. (*%E *)
  6337. public __getsystem :
  6338. (* void _getsystem(VIDstruct *vid) *)
  6339. ARGpVID = frame
  6340. push bp
  6341. mov bp,sp
  6342. push si
  6343. push di
  6344. (*%F SameDS *)
  6345. push ds
  6346. mov cx, _DATA
  6347. mov ds, cx
  6348. (*%E *)
  6349. (* initialize the data structure that will contain the results *)
  6350. (*%F NearPtr *)
  6351. les di, [bp][ARGpVID] (* ES:DI -> start of data structure *)
  6352. (*%E *)
  6353. (*%T NearPtr *)
  6354. mov di, ds
  6355. mov es, di
  6356. mov di, [bp][ARGpVID] (* ES:DI -> start of data structure *)
  6357. (*%E *)
  6358. mov word es:[di][Device0], 0 (* zero these variables *)
  6359. mov word es:[di][Device1], 0
  6360. (* look for various subsystems using the subroutines whose addresses are *)
  6361. (* tabulated in TestSequence; each subroutine sets flags in TestSequence *)
  6362. (* to indicate whether subsequent subroutines need to be called *)
  6363. mov byte [__CGAflag], TRUE
  6364. mov byte [__EGAflag], TRUE
  6365. mov byte [__Monoflag], TRUE
  6366. mov byte [__TestSequence], TRUE
  6367. mov cx, NumberOfTests
  6368. mov si, __TestSequence
  6369. L01:
  6370. lodsb (* AL = flag *)
  6371. test al,al
  6372. lodsw (* AX = subroutine address *)
  6373. jz L02 (* skip subroutine if flag is false *)
  6374. push si
  6375. push cx
  6376. call ax (* call subroutine to detect subsystem *)
  6377. pop cx
  6378. pop si
  6379. L02:
  6380. loop L01
  6381. (* determine which subsystem is active *)
  6382. call __FindActive
  6383. (*%F SameDS *)
  6384. pop ds
  6385. (*%E *)
  6386. pop di (* restore caller registers and return *)
  6387. pop si
  6388. pop bp
  6389. (*%F NearCall *)
  6390. ret far 0
  6391. (*%E *)
  6392. (*%T NearCall *)
  6393. ret 0
  6394. (*%E *)
  6395. (****************************************************************************)
  6396. section
  6397. (*%F NearCall *)
  6398. segment Graphics_TEXT(CODE,28H)
  6399. (*%E *)
  6400. (*%T NearCall *)
  6401. segment _TEXT(CODE,28H)
  6402. (*%E *)
  6403. segment _DATA(DATA, 28H)
  6404. (*%F NearCall *)
  6405. select Graphics_TEXT
  6406. (*%E *)
  6407. (*%T NearCall *)
  6408. select _TEXT
  6409. (*%E *)
  6410. public __getmemory :
  6411. (*%T _DLLOVL *)
  6412. push bp
  6413. mov bp, sp
  6414. (*%E *)
  6415. mov ah, 12H
  6416. mov bl, 10H
  6417. int 10H
  6418. mov al, 64
  6419. inc bl
  6420. mov dl, bl
  6421. mul dl
  6422. (*%T _DLLOVL *)
  6423. pop bp
  6424. (*%E *)
  6425. (*%F NearCall *)
  6426. ret far 0
  6427. (*%E *)
  6428. (*%T NearCall *)
  6429. ret 0
  6430. (*%E *)
  6431. (****************************************************************************)
  6432. section
  6433. (*%F NearCall *)
  6434. segment Graphics_TEXT(CODE,28H)
  6435. (*%E *)
  6436. (*%T NearCall *)
  6437. segment _TEXT(CODE,28H)
  6438. (*%E *)
  6439. segment _DATA(DATA, 28H)
  6440. (*%F NearCall *)
  6441. select Graphics_TEXT
  6442. (*%E *)
  6443. (*%T NearCall *)
  6444. select _TEXT
  6445. (*%E *)
  6446. public __clear_blink :
  6447. mov ax, 1003H
  6448. mov bl, 0H
  6449. int 10H
  6450. ret 0
  6451. (******************************************************************************)
  6452. section
  6453. (*%F NearCall *)
  6454. segment Graphics_TEXT(CODE,28H)
  6455. (*%E *)
  6456. (*%T NearCall *)
  6457. segment _TEXT(CODE,28H)
  6458. (*%E *)
  6459. segment _DATA(DATA, 28H)
  6460. (*%F NearCall *)
  6461. select Graphics_TEXT
  6462. (*%E *)
  6463. (*%T NearCall *)
  6464. select _TEXT
  6465. (*%E *)
  6466. public __gr_abs_value :
  6467. (*%T _DLLOVL *)
  6468. push bp
  6469. mov bp, sp
  6470. (*%E *)
  6471. test ah, 80H
  6472. jz absRet
  6473. neg ax
  6474. absRet:
  6475. (*%T _DLLOVL *)
  6476. pop bp
  6477. (*%E *)
  6478. (*%F NearCall *)
  6479. ret far 0
  6480. (*%E *)
  6481. (*%T NearCall *)
  6482. ret 0
  6483. (*%E *)
  6484. (**************************************************************************)
  6485. section
  6486. (*%F NearCall *)
  6487. segment Graphics_TEXT(CODE,28H)
  6488. (*%E *)
  6489. (*%T NearCall *)
  6490. segment _TEXT(CODE,28H)
  6491. (*%E *)
  6492. segment _DATA(DATA, 28H)
  6493. (*%F NearCall *)
  6494. select Graphics_TEXT
  6495. (*%E *)
  6496. (*%T NearCall *)
  6497. select _TEXT
  6498. (*%E *)
  6499. public __gdummy : (* default null procedure for function pointers *)
  6500. (*%F NearCall *)
  6501. ret far 0
  6502. (*%E *)
  6503. (*%T NearCall *)
  6504. ret 0
  6505. (*%E *)
  6506. (**************************************************************************)
  6507. section
  6508. (*%F NearCall *)
  6509. segment Graphics_TEXT(CODE,28H)
  6510. (*%E *)
  6511. (*%T NearCall *)
  6512. segment _TEXT(CODE,28H)
  6513. (*%E *)
  6514. segment _DATA(DATA, 28H)
  6515. (*%F NearCall *)
  6516. select Graphics_TEXT
  6517. (*%E *)
  6518. (*%T NearCall *)
  6519. select _TEXT
  6520. (*%E *)
  6521. (*
  6522. void _setcur(short row, short col, short page);
  6523. *)
  6524. public __setcur :
  6525. (*%T _DLLOVL *)
  6526. push bp
  6527. mov bp, sp
  6528. (*%E *)
  6529. mov dh, al
  6530. mov dl, bl
  6531. mov bh, cl
  6532. mov ah, 2
  6533. int 10H
  6534. (*%T _DLLOVL *)
  6535. pop bp
  6536. (*%E *)
  6537. (*%F NearCall *)
  6538. ret far 0
  6539. (*%E *)
  6540. (*%T NearCall *)
  6541. ret 0
  6542. (*%E *)
  6543. (*************************************************************************)
  6544. numxpixels = 0 (* number of pixels on X axis *)
  6545. numypixels = 2 (* number of pixels on Y axis *)
  6546. numtextcols = 4 (* number of text columns available *)
  6547. numtextrows = 6 (* number of text rows available *)
  6548. numcolors = 8 (* number of actual colors *)
  6549. bitsperpixel = 10 (* number of bits per pixel *)
  6550. numvideopages = 12 (* number of available video pages *)
  6551. mode = 14 (* current video mode *)
  6552. adapter = 16 (* active display adapter *)
  6553. monitor = 18 (* active display monitor *)
  6554. memory = 20 (* adapter video memory in K bytes *)
  6555. _DEFAULTMODE = -1 (* restore screen to original mode *)
  6556. _TEXTBW40 = 0 (* 40 x 25 text, 16 grey *)
  6557. _TEXTC40 = 1 (* 40 x 25 text, 16/8 color *)
  6558. _TEXTBW80 = 2 (* 80 x 25 text, 16 grey *)
  6559. _TEXTC80 = 3 (* 80 x 25 text, 16/8 color *)
  6560. _MRES4COLOR = 4 (* 320 x 200, 4 color *)
  6561. _MRESNOCOLOR = 5 (* 320 x 200, 4 grey *)
  6562. _HRESBW = 6 (* 640 x 200, BW *)
  6563. _TEXTMONO = 7 (* 80 x 25 text, BW *)
  6564. _HERCMONO = 8 (* 720 x 348, BW for HGC *)
  6565. _MRES16COLOR = 13 (* 320 x 200, 16 color *)
  6566. _HRES16COLOR = 14 (* 640 x 200, 16 color *)
  6567. _ERESNOCOLOR = 15 (* 640 x 350, BW *)
  6568. _ERESCOLOR = 16 (* 640 x 350, 4 or 16 color *)
  6569. _VRES2COLOR = 17 (* 640 x 480, BW *)
  6570. _VRES16COLOR = 18 (* 640 x 480, 16 color *)
  6571. _MRES256COLOR = 19 (* 320 x 200, 256 color *)
  6572. extrn __current_video
  6573. extrn __clear_blink
  6574. public __resetEGA :
  6575. mov ax, _DATA
  6576. mov es, ax
  6577. cmp word es:[__current_video][mode], _VRES2COLOR
  6578. jnz notVres
  6579. mov cx, 1
  6580. jmp ccDone
  6581. notVres:
  6582. cmp word es:[__current_video][mode], _ERESNOCOLOR
  6583. jnz notEres
  6584. mov cx, 5
  6585. jmp ccDone
  6586. notEres:
  6587. mov cx, 0FH;
  6588. ccDone:
  6589. mov al, 2
  6590. mov dx, 3CEH
  6591. out byte dx, al
  6592. mov al, 0FH
  6593. inc dx
  6594. out byte dx, al
  6595. mov al, 1
  6596. dec dx
  6597. out byte dx, al
  6598. sub al, al
  6599. inc dx
  6600. out byte dx, al
  6601. mov al, 2
  6602. dec dx
  6603. out byte dx, al
  6604. sub al, al
  6605. inc dx
  6606. out byte dx, al
  6607. mov al, 3
  6608. dec dx
  6609. out byte dx, al
  6610. sub al, al
  6611. inc dx
  6612. out byte dx, al
  6613. mov al, 8
  6614. dec dx
  6615. out byte dx, al
  6616. mov al, 0FFH
  6617. inc dx
  6618. out byte dx, al
  6619. mov al, 7
  6620. dec dx
  6621. out byte dx, al
  6622. mov al, cl
  6623. inc dx
  6624. out byte dx, al
  6625. mov al, 5
  6626. dec dx
  6627. out byte dx, al
  6628. sub al, al
  6629. inc dx
  6630. out byte dx, al
  6631. mov al, 2
  6632. mov dx, 3C4H
  6633. out byte dx, al
  6634. mov al, 0FH
  6635. inc dx
  6636. out byte dx, al
  6637. call __clear_blink
  6638. (*%F NearCall *)
  6639. ret far 0
  6640. (*%E *)
  6641. (*%T NearCall *)
  6642. ret 0
  6643. (*%E *)
  6644. public __setbc :
  6645. mov ah, 0BH
  6646. sub bx, bx
  6647. (*%F NearCall *)
  6648. ret far 0
  6649. (*%E *)
  6650. (*%T NearCall *)
  6651. ret 0
  6652. (*%E *)
  6653. public __setr10 :
  6654. mov ax, 1010H
  6655. mov bx, 10H
  6656. sub cx, cx
  6657. sub dx, dx
  6658. (*%F NearCall *)
  6659. ret far 0
  6660. (*%E *)
  6661. (*%T NearCall *)
  6662. ret 0
  6663. (*%E *)
  6664. (***************************************************************************)
  6665. section
  6666. (*%F NearCall *)
  6667. segment Graphics_TEXT(CODE,28H)
  6668. (*%E *)
  6669. (*%T NearCall *)
  6670. segment _TEXT(CODE,28H)
  6671. (*%E *)
  6672. segment _DATA(DATA, 28H)
  6673. (*%F NearCall *)
  6674. select Graphics_TEXT
  6675. (*%E *)
  6676. (*%T NearCall *)
  6677. select _TEXT
  6678. (*%E *)
  6679. public __gmemcpy :
  6680. (*
  6681. void *_gmemcpy(void *dest, void *source, unsigned num)
  6682. Copies num bytes from source to dest (Does not handle any overlap).
  6683. Returns destination address.
  6684. *)
  6685. num = bxframe
  6686. mov es, bx
  6687. mov bx, sp
  6688. mov bx, ss:[bx][num]
  6689. push di
  6690. push si
  6691. push ds
  6692. mov ds, dx
  6693. mov si, cx
  6694. mov di, ax
  6695. mov cx, bx
  6696. jcxz noMove
  6697. test al, 1
  6698. jz evenAdd (* word align *)
  6699. movsb
  6700. dec cx
  6701. evenAdd:
  6702. shr cx, 1
  6703. rep; movsw (* move words *)
  6704. adc cx, cx
  6705. rep; movsb (* move odd byte *)
  6706. noMove:
  6707. mov dx, es
  6708. pop ds
  6709. pop si
  6710. pop di
  6711. (*%F NearCall *)
  6712. ret far 2
  6713. (*%E *)
  6714. (*%T NearCall *)
  6715. ret 2
  6716. (*%E *)
  6717. (****************************************************************************)
  6718. section
  6719. (*%F NearCall *)
  6720. segment Graphics_TEXT(CODE,28H)
  6721. (*%E *)
  6722. (*%T NearCall *)
  6723. segment _TEXT(CODE,28H)
  6724. (*%E *)
  6725. segment _DATA(DATA, 28H)
  6726. (*%F NearCall *)
  6727. select Graphics_TEXT
  6728. (*%E *)
  6729. (*%T NearCall *)
  6730. select _TEXT
  6731. (*%E *)
  6732. public __gmemset :
  6733. (*
  6734. void *_gmemset(void *s, char c, unsigned num)
  6735. Sets num bytes to c.
  6736. Returns buffer address.
  6737. *)
  6738. push di
  6739. mov es, bx
  6740. mov di, ax
  6741. mov al, cl
  6742. mov cx, dx
  6743. mov dx, di
  6744. jcxz noMove
  6745. mov ah, al
  6746. test di, 1
  6747. jz evenAdd
  6748. stosb (* word align *)
  6749. dec cx
  6750. evenAdd:
  6751. shr cx, 1
  6752. rep ; stosw (* move words *)
  6753. adc cx, cx
  6754. rep ; stosb (* move odd byte *)
  6755. noMove:
  6756. mov ax, dx
  6757. mov dx, es (* return buffer address *)
  6758. pop di
  6759. (*%F NearCall *)
  6760. ret far 0
  6761. (*%E *)
  6762. (*%T NearCall *)
  6763. ret 0
  6764. (*%E *)
  6765. (***************************************************************************)
  6766. section
  6767. (*%F NearCall *)
  6768. segment Graphics_TEXT(CODE,28H)
  6769. (*%E *)
  6770. (*%T NearCall *)
  6771. segment _TEXT(CODE,28H)
  6772. (*%E *)
  6773. segment _DATA(DATA, 28H)
  6774. (*%F NearCall *)
  6775. select Graphics_TEXT
  6776. (*%E *)
  6777. (*%T NearCall *)
  6778. select _TEXT
  6779. (*%E *)
  6780. public __gmemwset :
  6781. (*
  6782. void *memwset(void *s, char c, unsigned num)
  6783. Sets num words to c.
  6784. Returns buffer address.
  6785. *)
  6786. push di
  6787. mov es, bx
  6788. mov di, ax
  6789. mov ax, cx
  6790. mov cx, dx
  6791. mov dx, di
  6792. rep ; stosw
  6793. mov ax, dx
  6794. mov dx, es (* return buffer address *)
  6795. pop di
  6796. (*%F NearCall *)
  6797. ret far 0
  6798. (*%E *)
  6799. (*%T NearCall *)
  6800. ret 0
  6801. (*%E *)
  6802. (****************************************************************************)
  6803. section
  6804. segment _DATA(DATA, 28H)
  6805. segment _TEXT(CODE,28H)
  6806. extrn __setvideomode
  6807. extrn __setvideomode_vector
  6808. extrn __display_state
  6809. extrn __mode_changed
  6810. select _TEXT
  6811. public __restore_mode :
  6812. (*%T _DLLOVL *)
  6813. push bp
  6814. mov bp, sp
  6815. (*%E *)
  6816. (*%F SameDS *)
  6817. push ds
  6818. mov ax, _DATA
  6819. mov ds, ax
  6820. (*%E *)
  6821. cmp byte [__display_state], 0
  6822. jz dontReset
  6823. cmp byte [__mode_changed], 0
  6824. jz dontReset
  6825. mov ax, -1
  6826. (*%F RegParam *)
  6827. push ax
  6828. (*%E *)
  6829. (*%F _DLL *)
  6830. call far __setvideomode
  6831. (*%E *)
  6832. (*%T _DLL *)
  6833. call far [__setvideomode_vector]
  6834. (*%E *)
  6835. (*%F RegParam *)
  6836. pop ax
  6837. (*%E *)
  6838. dontReset:
  6839. (*%F SameDS *)
  6840. pop ds
  6841. (*%E *)
  6842. (*%T _DLLOVL *)
  6843. pop bp
  6844. (*%E *)
  6845. (*%F NearCall *)
  6846. ret far 0
  6847. (*%E *)
  6848. (*%T NearCall *)
  6849. ret 0
  6850. (*%E *)
  6851. (****************************************************************************)
  6852. section
  6853. segment _TEXT(CODE,28H)
  6854. segment _DATA(DATA, 28H)
  6855. segment _INIT(INIT_CODE,28H)
  6856. extrn __initgraph
  6857. extrn __initgraph_vector
  6858. extrn __exitgraph
  6859. extrn __restore_mode
  6860. (*%T _DLLOVL *)
  6861. select _DATA
  6862. RestAdr: dd __restore_mode
  6863. (*%E *)
  6864. select _TEXT
  6865. do_initgraph : (* defined later on ! *)
  6866. select _INIT
  6867. (*%F NearCall *)
  6868. initgraph : dw MAGIC_NUM
  6869. db PR4
  6870. dd do_initgraph
  6871. (*%E *)
  6872. (*%T NearCall *)
  6873. initgraph : dw MAGIC_NUM
  6874. db PR4
  6875. dw do_initgraph
  6876. (*%E *)
  6877. select _DATA
  6878. public __defaultmode : dw initgraph, 0
  6879. select _TEXT
  6880. (*%T _DLLOVL *)
  6881. push bp
  6882. mov bp, sp
  6883. (*%E *)
  6884. push ds
  6885. mov ax, _DATA
  6886. mov ds, ax
  6887. (*%F _DLL *)
  6888. call far __initgraph
  6889. (*%E *)
  6890. (*%T _DLL *)
  6891. cmp word [__initgraph_vector], 0
  6892. jz noInit
  6893. call far [__initgraph_vector]
  6894. (*%E *)
  6895. (*%F _DLLOVL *)
  6896. mov word [__exitgraph], __restore_mode
  6897. (*%F NearCall *)
  6898. mov word [__exitgraph][2], cs
  6899. (*%E *)
  6900. (*%E *)
  6901. (*%T _DLLOVL *)
  6902. mov ax, [RestAdr]
  6903. mov word [__exitgraph], ax
  6904. mov ax, [RestAdr][2]
  6905. mov word [__exitgraph][2], ax
  6906. (*%E *)
  6907. noInit:
  6908. pop ds
  6909. (*%F NearCall *)
  6910. (*%T _DLLOVL *)
  6911. pop bp
  6912. (*%E *)
  6913. ret far 0
  6914. (*%E *)
  6915. (*%T NearCall *)
  6916. ret 0
  6917. (*%E *)
  6918. (*%E *)
  6919. (****************************************************************************)
  6920. (*%T _DLL *)
  6921. section
  6922. segment _DATA(DATA,28H)
  6923. segment _TEXT(CODE,28H)
  6924. extrn __setvideomode_vector
  6925. extrn __initgraph_vector
  6926. public __set_initgraph_vector :
  6927. push bp
  6928. mov bp, sp
  6929. push ds
  6930. push di
  6931. mov di, _DATA
  6932. mov ds, di
  6933. mov [__setvideomode_vector][2], dx
  6934. mov [__setvideomode_vector], cx
  6935. mov [__initgraph_vector][2], bx
  6936. mov [__initgraph_vector], ax
  6937. pop di
  6938. pop ds
  6939. pop bp
  6940. ret far 0
  6941. (*%E *)
  6942. end