KEYFBUFF.ASM 128 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210
  1. ;
  2. ; Copyright 2020 Electronic Arts Inc.
  3. ;
  4. ; TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. ; software: you can redistribute it and/or modify it under the terms of
  6. ; the GNU General Public License as published by the Free Software Foundation,
  7. ; either version 3 of the License, or (at your option) any later version.
  8. ; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. ; in the hope that it will be useful, but with permitted additional restrictions
  10. ; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. ; distributed with this program. You should have received a copy of the
  12. ; GNU General Public License along with permitted additional restrictions
  13. ; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
  14. ;***************************************************************************
  15. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  16. ;***************************************************************************
  17. ;* *
  18. ;* Project Name : Command & Conquer *
  19. ;* *
  20. ;* File Name : KEYFBUFF.ASM *
  21. ;* *
  22. ;* Programmer : David R. Dettmer *
  23. ;* *
  24. ;* Start Date : March 3, 1995 *
  25. ;* *
  26. ;* Last Update : *
  27. ;* *
  28. ;*-------------------------------------------------------------------------*
  29. ;* Functions: *
  30. ;* Buffer_Frame_To_Page -- Copies a linear buffer to a virtual viewport *
  31. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  32. ;********************** Model & Processor Directives ***********************
  33. ;IDEAL
  34. ;P386
  35. ;MODEL USE32 FLAT
  36. ;jumps
  37. .MODEL FLAT
  38. ;.386
  39. ;******************************** Includes *********************************
  40. ;INCLUDE "gbuffer.inc"
  41. ;include "profile.inc"
  42. OPTIMAL_BYTE_COPY equ 14
  43. GraphicViewPort STRUCT
  44. GVPOffset DD ? ; offset to virtual viewport
  45. GVPWidth DD ? ; width of virtual viewport
  46. GVPHeight DD ? ; height of virtual viewport
  47. GVPXAdd DD ? ; x mod to get to next line
  48. GVPXPos DD ? ; x pos relative to Graphic Buff
  49. GVPYPos DD ? ; y pos relative to Graphic Buff
  50. GVPPitch dd ? ; modulo of graphic view port
  51. GVPBuffPtr DD ? ; ptr to associated Graphic Buff
  52. GraphicViewPort ENDS
  53. ;******************************** Equates **********************************
  54. TRUE equ 1 ; Boolean 'true' value
  55. FALSE equ 0 ; Boolean 'false' value
  56. ;*=========================================================================*/
  57. ;* The following are defines used to control what functions are linked *
  58. ;* in for Buffer_Frame_To_Page. *
  59. ;*=========================================================================*/
  60. ;USE_NORMAL EQU TRUE
  61. ;USE_HORZ_REV EQU TRUE
  62. ;USE_VERT_REV EQU TRUE
  63. ;USE_SCALING EQU TRUE
  64. FLAG_NORMAL EQU 0
  65. FLAG_TRANS EQU 1
  66. FLAG_GHOST EQU 2
  67. FLAG_FADING EQU 4
  68. FLAG_PREDATOR EQU 8
  69. FLAG_MASK EQU 0Fh
  70. SHAPE_NORMAL EQU 0000h ; Standard shape
  71. ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally
  72. ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically
  73. ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y)
  74. ;SHAPE_VIEWPORT_REL EQU 0010h ; Coords are window-relative
  75. ;SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute.
  76. SHAPE_CENTER EQU 0020h ; Coords are based on shape's center pt
  77. SHAPE_TRANS EQU 0040h ; has transparency
  78. SHAPE_FADING EQU 0100h ; Fading effect (VOID * fading_table,
  79. ; WORD fading_num)
  80. SHAPE_PREDATOR EQU 0200h ; Transparent warping effect
  81. ;SHAPE_COMPACT EQU 0400h ; Never use this bit
  82. ;SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing
  83. SHAPE_GHOST EQU 1000h ; Shape is drawn ghosted
  84. ;SHAPE_SHADOW EQU 2000h
  85. SHAPE_PARTIAL EQU 4000h
  86. ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors
  87. ; (VOID * color_table)
  88. ;
  89. ;.......................... Shadow Effect ..................................
  90. ;
  91. SHADOW_COL EQU 00FFh ; magic number for shadows
  92. ;......................... Priority System .................................
  93. ;
  94. CLEAR_UNUSED_BITS EQU 0007h ; and with 0000-0111 to clear
  95. ; non-walkable high bit and
  96. ; scaling id bits
  97. NON_WALKABLE_BIT EQU 0080h ; and with 1000-0000 to clear all
  98. ; but non-walkable bit
  99. ;
  100. ;......................... Predator Effect .................................
  101. ;
  102. ;PRED_MASK EQU 0007h ; mask used for predator pixel puts
  103. PRED_MASK EQU 000Eh ; mask used for predator pixel puts
  104. ;---------------------------------------------------------------------------
  105. ;
  106. ; Use a macro to make code a little cleaner.
  107. ; The parameter varname is optional.
  108. ; Syntax to use macro is :
  109. ; WANT equ expression
  110. ; USE func [,varname]
  111. ; If the 'varname' is defined, a table declaration is created like:
  112. ; GLOBAL TableName:DWORD
  113. ; Then, the table entry is created:
  114. ; If WANT is true, the table entry is created for the given function:
  115. ; varname DD func
  116. ; If WANT is not TRUE, a Not_Supported entry is put in the table:
  117. ; varname DD Not_Supported
  118. ; The resulting tables look like:
  119. ;
  120. ; GLOBAL ExampTable:DWORD
  121. ; ExampTable DD routine1
  122. ; DD routine2
  123. ; DD routine3
  124. ; ...
  125. ; Thus, each table is an array of function pointers.
  126. ;
  127. ;---------------------------------------------------------------------------
  128. USE MACRO func, varname
  129. IF WANT
  130. varname DD func
  131. ELSE
  132. varname DD Not_Supported
  133. ENDIF
  134. ENDM
  135. prologue macro
  136. endm
  137. epilogue macro
  138. endm
  139. ; IFNB <varname>
  140. ; GLOBAL varname:DWORD
  141. ; ENDIF
  142. ;---------------------------------------------------------------------------
  143. .DATA
  144. ;---------------------------------------------------------------------------
  145. ; Predator effect variables
  146. ;---------------------------------------------------------------------------
  147. ; make table for negative offset and use the used space for other variables
  148. BFPredNegTable DW -1, -3, -2, -5, -2, -4, -3, -1
  149. ; 8 words below calculated
  150. DW 0, 0, 0, 0, 0, 0, 0, 0 ; index ffffff00
  151. DD 0, 0, 0, 0 ; index ffffff10
  152. BFPredOffset DD 0, 0, 0, 0 ; index ffffff20
  153. DD 0, 0, 0, 0 ; index ffffff30
  154. ; partially faded predator effect value
  155. BFPartialPred DD 0, 0, 0, 0 ; index ffffff40
  156. BFPartialCount DD 0, 0, 0, 0 ; index ffffff50
  157. DD 0, 0, 0, 0 ; index ffffff60
  158. DD 0, 0, 0, 0 ; index ffffff70
  159. DD 0, 0, 0, 0 ; index ffffff80
  160. DD 0, 0, 0, 0 ; index ffffff90
  161. DD 0, 0, 0, 0 ; index ffffffa0
  162. DD 0, 0, 0, 0 ; index ffffffb0
  163. DD 0, 0, 0, 0 ; index ffffffc0
  164. DD 0, 0, 0, 0 ; index ffffffd0
  165. DD 0, 0, 0, 0 ; index ffffffe0
  166. DD 0, 0, 0, 0 ; index fffffff0
  167. BFPredTable DW 1, 3, 2, 5, 2, 3, 4, 1
  168. ;BFPredTable DB 1, 3, 2, 5, 4, 3, 2, 1
  169. extern C BigShapeBufferStart:dword
  170. extern C UseBigShapeBuffer:dword
  171. extern C TheaterShapeBufferStart:dword
  172. extern C IsTheaterShape:dword
  173. ;extern C Single_Line_Trans_Entry:near
  174. ;extern C Next_Line:near
  175. extern C MMX_Done:near
  176. extern C MMXAvailable:dword
  177. ;extern C EndNewShapeJumpTable:byte
  178. ;extern C NewShapeJumpTable:dword
  179. ;**********************************************************************************
  180. ;
  181. ; Jump tables for new line header system
  182. ;
  183. ; Each line of shape data now has a header byte which describes the data on the line.
  184. ;
  185. ;
  186. ; Header byte control bits
  187. ;
  188. BLIT_TRANSPARENT =1
  189. BLIT_GHOST =2
  190. BLIT_FADING =4
  191. BLIT_PREDATOR =8
  192. BLIT_SKIP =16
  193. BLIT_ALL =BLIT_TRANSPARENT or BLIT_GHOST or BLIT_FADING or BLIT_PREDATOR or BLIT_SKIP
  194. ShapeHeaderType STRUCT
  195. draw_flags dd ?
  196. shape_data dd ?
  197. shape_buffer dd ?
  198. ShapeHeaderType ENDS
  199. ;
  200. ; Global definitions for routines that draw a single line of a shape
  201. ;
  202. ;extern Short_Single_Line_Copy:near
  203. ;extern Single_Line_Trans:near
  204. ;extern Single_Line_Ghost:near
  205. ;extern Single_Line_Ghost_Trans:near
  206. ;extern Single_Line_Fading:near
  207. ;extern Single_Line_Fading_Trans:near
  208. ;extern Single_Line_Ghost_Fading:near
  209. ;extern Single_Line_Ghost_Fading_Trans:near
  210. ;extern Single_Line_Predator:near
  211. ;extern Single_Line_Predator_Trans:near
  212. ;extern Single_Line_Predator_Ghost:near
  213. ;extern Single_Line_Predator_Ghost_Trans:near
  214. ;extern Single_Line_Predator_Fading:near
  215. ;extern Single_Line_Predator_Fading_Trans:near
  216. ;extern Single_Line_Predator_Ghost_Fading:near
  217. ;extern Single_Line_Predator_Ghost_Fading_Trans:near
  218. ;extern Single_Line_Skip:near
  219. ;extern Single_Line_Single_Fade:near
  220. ;extern Single_Line_Single_Fade_Trans:near
  221. ;externdef AllFlagsJumpTable:dword
  222. ;
  223. externdef NewShapeJumpTable:dword
  224. externdef EndNewShapeJumpTable:byte
  225. externdef CriticalFadeRedirections:dword
  226. ;externdef BufferFrameTable:dword
  227. ;externdef CriticalFadeRedirections:dword
  228. ;externdef CriticalFadeRedirections:dword
  229. ;externdef CriticalFadeRedirections:dword
  230. ;externdef BF_Copy:far ptr
  231. ;externdef BF_Trans:dword
  232. ;externdef BF_Ghost:dword
  233. ;externdef BF_Ghost_Trans:dword
  234. ;externdef BF_Fading:dword
  235. ;externdef BF_Fading_Trans:dword
  236. ;externdef BF_Ghost_Fading:dword
  237. ;externdef BF_Ghost_Fading_Trans:dword
  238. ;externdef BF_Predator:dword
  239. ;externdef BF_Predator_Trans:dword
  240. ;externdef BF_Predator_Ghost:dword
  241. ;externdef BF_Predator_Ghost_Trans:dword
  242. ;externdef BF_Predator_Fading:dword
  243. ;externdef BF_Predator_Fading_Trans:dword
  244. ;externdef BF_Predator_Ghost_Fading:dword
  245. ;externdef BF_Predator_Ghost_Fading_Trans:dword
  246. externdef C Single_Line_Trans:near
  247. externdef C Single_Line_Trans_Entry:near
  248. externdef C Next_Line:near
  249. .CODE
  250. ;---------------------------------------------------------------------------
  251. ; Code Segment Tables:
  252. ; This code uses the USE macro to set up tables of function addresses.
  253. ; The tables have the following format:
  254. ; Tables defined are:
  255. ; BufferFrameTable
  256. ;---------------------------------------------------------------------------
  257. WANT equ <TRUE>
  258. USE BF_Copy, BufferFrameTable
  259. WANT equ <TRUE>
  260. USE BF_Trans
  261. WANT equ <TRUE>
  262. USE BF_Ghost
  263. WANT equ <TRUE>
  264. USE BF_Ghost_Trans
  265. WANT equ <TRUE>
  266. USE BF_Fading
  267. WANT equ <TRUE>
  268. USE BF_Fading_Trans
  269. WANT equ <TRUE>
  270. USE BF_Ghost_Fading
  271. WANT equ <TRUE>
  272. USE BF_Ghost_Fading_Trans
  273. WANT equ <TRUE>
  274. USE BF_Predator
  275. WANT equ <TRUE>
  276. USE BF_Predator_Trans
  277. WANT equ <TRUE>
  278. USE BF_Predator_Ghost
  279. WANT equ <TRUE>
  280. USE BF_Predator_Ghost_Trans
  281. WANT equ <TRUE>
  282. USE BF_Predator_Fading
  283. WANT equ <TRUE>
  284. USE BF_Predator_Fading_Trans
  285. WANT equ <TRUE>
  286. USE BF_Predator_Ghost_Fading
  287. WANT equ <TRUE>
  288. USE BF_Predator_Ghost_Fading_Trans
  289. .DATA
  290. ;NewShapeJumpTable label near ptr dword
  291. ;
  292. ; Jumptable for shape line drawing with no flags set
  293. ;
  294. NewShapeJumpTable dd Short_Single_Line_Copy
  295. dd Short_Single_Line_Copy
  296. dd Short_Single_Line_Copy
  297. dd Short_Single_Line_Copy
  298. ;CriticalFadeRedirections label dword
  299. CriticalFadeRedirections dd Short_Single_Line_Copy
  300. dd Short_Single_Line_Copy
  301. dd Short_Single_Line_Copy
  302. dd Short_Single_Line_Copy
  303. dd Short_Single_Line_Copy
  304. dd Short_Single_Line_Copy
  305. dd Short_Single_Line_Copy
  306. dd Short_Single_Line_Copy
  307. dd Short_Single_Line_Copy
  308. dd Short_Single_Line_Copy
  309. dd Short_Single_Line_Copy
  310. dd Short_Single_Line_Copy
  311. dd Single_Line_Skip
  312. dd Single_Line_Skip
  313. dd Single_Line_Skip
  314. dd Single_Line_Skip
  315. dd Single_Line_Skip
  316. dd Single_Line_Skip
  317. dd Single_Line_Skip
  318. dd Single_Line_Skip
  319. dd Single_Line_Skip
  320. dd Single_Line_Skip
  321. dd Single_Line_Skip
  322. dd Single_Line_Skip
  323. dd Single_Line_Skip
  324. dd Single_Line_Skip
  325. dd Single_Line_Skip
  326. dd Single_Line_Skip
  327. ;
  328. ; Jumptable for shape line drawing routines with transparent flags set
  329. ;
  330. dd Short_Single_Line_Copy
  331. dd Single_Line_Trans
  332. dd Short_Single_Line_Copy
  333. dd Single_Line_Trans
  334. dd Short_Single_Line_Copy
  335. dd Single_Line_Trans
  336. dd Short_Single_Line_Copy
  337. dd Single_Line_Trans
  338. dd Short_Single_Line_Copy
  339. dd Single_Line_Trans
  340. dd Short_Single_Line_Copy
  341. dd Single_Line_Trans
  342. dd Short_Single_Line_Copy
  343. dd Single_Line_Trans
  344. dd Short_Single_Line_Copy
  345. dd Single_Line_Trans
  346. dd Single_Line_Skip
  347. dd Single_Line_Skip
  348. dd Single_Line_Skip
  349. dd Single_Line_Skip
  350. dd Single_Line_Skip
  351. dd Single_Line_Skip
  352. dd Single_Line_Skip
  353. dd Single_Line_Skip
  354. dd Single_Line_Skip
  355. dd Single_Line_Skip
  356. dd Single_Line_Skip
  357. dd Single_Line_Skip
  358. dd Single_Line_Skip
  359. dd Single_Line_Skip
  360. dd Single_Line_Skip
  361. dd Single_Line_Skip
  362. ;
  363. ; Jumptable for shape line drawing routines with ghost flags set
  364. ;
  365. dd Short_Single_Line_Copy
  366. dd Short_Single_Line_Copy
  367. dd Single_Line_Ghost
  368. dd Single_Line_Ghost
  369. dd Short_Single_Line_Copy
  370. dd Short_Single_Line_Copy
  371. dd Single_Line_Ghost
  372. dd Single_Line_Ghost
  373. dd Short_Single_Line_Copy
  374. dd Short_Single_Line_Copy
  375. dd Single_Line_Ghost
  376. dd Single_Line_Ghost
  377. dd Short_Single_Line_Copy
  378. dd Short_Single_Line_Copy
  379. dd Single_Line_Ghost
  380. dd Single_Line_Ghost
  381. dd Single_Line_Skip
  382. dd Single_Line_Skip
  383. dd Single_Line_Skip
  384. dd Single_Line_Skip
  385. dd Single_Line_Skip
  386. dd Single_Line_Skip
  387. dd Single_Line_Skip
  388. dd Single_Line_Skip
  389. dd Single_Line_Skip
  390. dd Single_Line_Skip
  391. dd Single_Line_Skip
  392. dd Single_Line_Skip
  393. dd Single_Line_Skip
  394. dd Single_Line_Skip
  395. dd Single_Line_Skip
  396. dd Single_Line_Skip
  397. ;
  398. ; Jumptable for shape line drawing routines with ghost and transparent flags set
  399. ;
  400. dd Short_Single_Line_Copy
  401. dd Single_Line_Trans
  402. dd Single_Line_Ghost
  403. dd Single_Line_Ghost_Trans
  404. dd Short_Single_Line_Copy
  405. dd Single_Line_Trans
  406. dd Single_Line_Ghost
  407. dd Single_Line_Ghost_Trans
  408. dd Short_Single_Line_Copy
  409. dd Single_Line_Trans
  410. dd Single_Line_Ghost
  411. dd Single_Line_Ghost_Trans
  412. dd Short_Single_Line_Copy
  413. dd Single_Line_Trans
  414. dd Single_Line_Ghost
  415. dd Single_Line_Ghost_Trans
  416. dd Single_Line_Skip
  417. dd Single_Line_Skip
  418. dd Single_Line_Skip
  419. dd Single_Line_Skip
  420. dd Single_Line_Skip
  421. dd Single_Line_Skip
  422. dd Single_Line_Skip
  423. dd Single_Line_Skip
  424. dd Single_Line_Skip
  425. dd Single_Line_Skip
  426. dd Single_Line_Skip
  427. dd Single_Line_Skip
  428. dd Single_Line_Skip
  429. dd Single_Line_Skip
  430. dd Single_Line_Skip
  431. dd Single_Line_Skip
  432. ;
  433. ; Jumptable for shape line drawing routines with fading flag set
  434. ;
  435. dd Short_Single_Line_Copy
  436. dd Short_Single_Line_Copy
  437. dd Short_Single_Line_Copy
  438. dd Short_Single_Line_Copy
  439. dd Single_Line_Single_Fade
  440. dd Single_Line_Single_Fade
  441. dd Single_Line_Fading
  442. dd Single_Line_Fading
  443. dd Short_Single_Line_Copy
  444. dd Short_Single_Line_Copy
  445. dd Short_Single_Line_Copy
  446. dd Short_Single_Line_Copy
  447. dd Single_Line_Fading
  448. dd Single_Line_Fading
  449. dd Single_Line_Fading
  450. dd Single_Line_Fading
  451. dd Single_Line_Skip
  452. dd Single_Line_Skip
  453. dd Single_Line_Skip
  454. dd Single_Line_Skip
  455. dd Single_Line_Skip
  456. dd Single_Line_Skip
  457. dd Single_Line_Skip
  458. dd Single_Line_Skip
  459. dd Single_Line_Skip
  460. dd Single_Line_Skip
  461. dd Single_Line_Skip
  462. dd Single_Line_Skip
  463. dd Single_Line_Skip
  464. dd Single_Line_Skip
  465. dd Single_Line_Skip
  466. dd Single_Line_Skip
  467. ;
  468. ; Jumptable for shape line drawing routines with fading and transparent flags set
  469. ;
  470. dd Short_Single_Line_Copy
  471. dd Single_Line_Trans
  472. dd Short_Single_Line_Copy
  473. dd Single_Line_Trans
  474. dd Single_Line_Single_Fade
  475. dd Single_Line_Single_Fade_Trans
  476. dd Single_Line_Fading
  477. dd Single_Line_Fading_Trans
  478. dd Short_Single_Line_Copy
  479. dd Single_Line_Trans
  480. dd Short_Single_Line_Copy
  481. dd Single_Line_Trans
  482. dd Single_Line_Fading
  483. dd Single_Line_Fading_Trans
  484. dd Single_Line_Fading
  485. dd Single_Line_Fading_Trans
  486. dd Single_Line_Skip
  487. dd Single_Line_Skip
  488. dd Single_Line_Skip
  489. dd Single_Line_Skip
  490. dd Single_Line_Skip
  491. dd Single_Line_Skip
  492. dd Single_Line_Skip
  493. dd Single_Line_Skip
  494. dd Single_Line_Skip
  495. dd Single_Line_Skip
  496. dd Single_Line_Skip
  497. dd Single_Line_Skip
  498. dd Single_Line_Skip
  499. dd Single_Line_Skip
  500. dd Single_Line_Skip
  501. dd Single_Line_Skip
  502. ;
  503. ; Jumptable for shape line drawing routines with fading and ghost flags set
  504. ;
  505. dd Short_Single_Line_Copy
  506. dd Short_Single_Line_Copy
  507. dd Single_Line_Ghost
  508. dd Single_Line_Ghost
  509. dd Single_Line_Single_Fade
  510. dd Single_Line_Single_Fade
  511. dd Single_Line_Ghost_Fading
  512. dd Single_Line_Ghost_Fading
  513. dd Short_Single_Line_Copy
  514. dd Short_Single_Line_Copy
  515. dd Single_Line_Ghost
  516. dd Single_Line_Ghost
  517. dd Single_Line_Fading
  518. dd Single_Line_Fading
  519. dd Single_Line_Ghost_Fading
  520. dd Single_Line_Ghost_Fading
  521. dd Single_Line_Skip
  522. dd Single_Line_Skip
  523. dd Single_Line_Skip
  524. dd Single_Line_Skip
  525. dd Single_Line_Skip
  526. dd Single_Line_Skip
  527. dd Single_Line_Skip
  528. dd Single_Line_Skip
  529. dd Single_Line_Skip
  530. dd Single_Line_Skip
  531. dd Single_Line_Skip
  532. dd Single_Line_Skip
  533. dd Single_Line_Skip
  534. dd Single_Line_Skip
  535. dd Single_Line_Skip
  536. dd Single_Line_Skip
  537. ;
  538. ; Jumptable for shape line drawing routines with fading, transparent and ghost flags set
  539. ;
  540. dd Short_Single_Line_Copy
  541. dd Single_Line_Trans
  542. dd Single_Line_Ghost
  543. dd Single_Line_Ghost_Trans
  544. dd Single_Line_Single_Fade
  545. dd Single_Line_Single_Fade_Trans
  546. dd Single_Line_Ghost_Fading
  547. dd Single_Line_Ghost_Fading_Trans
  548. dd Short_Single_Line_Copy
  549. dd Single_Line_Trans
  550. dd Single_Line_Ghost
  551. dd Single_Line_Ghost_Trans
  552. dd Single_Line_Fading
  553. dd Single_Line_Fading_Trans
  554. dd Single_Line_Ghost_Fading
  555. dd Single_Line_Ghost_Fading_Trans
  556. dd Single_Line_Skip
  557. dd Single_Line_Skip
  558. dd Single_Line_Skip
  559. dd Single_Line_Skip
  560. dd Single_Line_Skip
  561. dd Single_Line_Skip
  562. dd Single_Line_Skip
  563. dd Single_Line_Skip
  564. dd Single_Line_Skip
  565. dd Single_Line_Skip
  566. dd Single_Line_Skip
  567. dd Single_Line_Skip
  568. dd Single_Line_Skip
  569. dd Single_Line_Skip
  570. dd Single_Line_Skip
  571. dd Single_Line_Skip
  572. ;
  573. ; Jumptable for shape line drawing with predator flag set
  574. ;
  575. dd Short_Single_Line_Copy
  576. dd Short_Single_Line_Copy
  577. dd Short_Single_Line_Copy
  578. dd Short_Single_Line_Copy
  579. dd Short_Single_Line_Copy
  580. dd Short_Single_Line_Copy
  581. dd Short_Single_Line_Copy
  582. dd Short_Single_Line_Copy
  583. dd Single_Line_Predator
  584. dd Single_Line_Predator
  585. dd Single_Line_Predator
  586. dd Single_Line_Predator
  587. dd Single_Line_Predator
  588. dd Single_Line_Predator
  589. dd Single_Line_Predator
  590. dd Single_Line_Predator
  591. dd Single_Line_Skip
  592. dd Single_Line_Skip
  593. dd Single_Line_Skip
  594. dd Single_Line_Skip
  595. dd Single_Line_Skip
  596. dd Single_Line_Skip
  597. dd Single_Line_Skip
  598. dd Single_Line_Skip
  599. dd Single_Line_Skip
  600. dd Single_Line_Skip
  601. dd Single_Line_Skip
  602. dd Single_Line_Skip
  603. dd Single_Line_Skip
  604. dd Single_Line_Skip
  605. dd Single_Line_Skip
  606. dd Single_Line_Skip
  607. ;
  608. ; Jumptable for shape line drawing routines with transparent and predator flags set
  609. ;
  610. dd Short_Single_Line_Copy
  611. dd Single_Line_Trans
  612. dd Short_Single_Line_Copy
  613. dd Single_Line_Trans
  614. dd Short_Single_Line_Copy
  615. dd Single_Line_Trans
  616. dd Short_Single_Line_Copy
  617. dd Single_Line_Trans
  618. dd Single_Line_Predator
  619. dd Single_Line_Predator_Trans
  620. dd Single_Line_Predator
  621. dd Single_Line_Predator_Trans
  622. dd Single_Line_Predator
  623. dd Single_Line_Predator_Trans
  624. dd Single_Line_Predator
  625. dd Single_Line_Predator_Trans
  626. dd Single_Line_Skip
  627. dd Single_Line_Skip
  628. dd Single_Line_Skip
  629. dd Single_Line_Skip
  630. dd Single_Line_Skip
  631. dd Single_Line_Skip
  632. dd Single_Line_Skip
  633. dd Single_Line_Skip
  634. dd Single_Line_Skip
  635. dd Single_Line_Skip
  636. dd Single_Line_Skip
  637. dd Single_Line_Skip
  638. dd Single_Line_Skip
  639. dd Single_Line_Skip
  640. dd Single_Line_Skip
  641. dd Single_Line_Skip
  642. ;
  643. ; Jumptable for shape line drawing routines with ghost and predator flags set
  644. ;
  645. dd Short_Single_Line_Copy
  646. dd Short_Single_Line_Copy
  647. dd Single_Line_Ghost
  648. dd Single_Line_Ghost
  649. dd Short_Single_Line_Copy
  650. dd Short_Single_Line_Copy
  651. dd Single_Line_Ghost
  652. dd Single_Line_Ghost
  653. dd Single_Line_Predator
  654. dd Single_Line_Predator
  655. dd Single_Line_Predator_Ghost
  656. dd Single_Line_Predator_Ghost
  657. dd Single_Line_Predator
  658. dd Single_Line_Predator
  659. dd Single_Line_Predator_Ghost
  660. dd Single_Line_Predator_Ghost
  661. dd Single_Line_Skip
  662. dd Single_Line_Skip
  663. dd Single_Line_Skip
  664. dd Single_Line_Skip
  665. dd Single_Line_Skip
  666. dd Single_Line_Skip
  667. dd Single_Line_Skip
  668. dd Single_Line_Skip
  669. dd Single_Line_Skip
  670. dd Single_Line_Skip
  671. dd Single_Line_Skip
  672. dd Single_Line_Skip
  673. dd Single_Line_Skip
  674. dd Single_Line_Skip
  675. dd Single_Line_Skip
  676. dd Single_Line_Skip
  677. ;
  678. ; Jumptable for shape line drawing routines with ghost and transparent and predator flags set
  679. ;
  680. dd Short_Single_Line_Copy
  681. dd Single_Line_Trans
  682. dd Single_Line_Ghost
  683. dd Single_Line_Ghost_Trans
  684. dd Short_Single_Line_Copy
  685. dd Single_Line_Trans
  686. dd Single_Line_Ghost
  687. dd Single_Line_Ghost_Trans
  688. dd Single_Line_Predator
  689. dd Single_Line_Predator_Trans
  690. dd Single_Line_Predator_Ghost
  691. dd Single_Line_Predator_Ghost_Trans
  692. dd Single_Line_Predator
  693. dd Single_Line_Predator_Trans
  694. dd Single_Line_Predator_Ghost
  695. dd Single_Line_Predator_Ghost_Trans
  696. dd Single_Line_Skip
  697. dd Single_Line_Skip
  698. dd Single_Line_Skip
  699. dd Single_Line_Skip
  700. dd Single_Line_Skip
  701. dd Single_Line_Skip
  702. dd Single_Line_Skip
  703. dd Single_Line_Skip
  704. dd Single_Line_Skip
  705. dd Single_Line_Skip
  706. dd Single_Line_Skip
  707. dd Single_Line_Skip
  708. dd Single_Line_Skip
  709. dd Single_Line_Skip
  710. dd Single_Line_Skip
  711. dd Single_Line_Skip
  712. ;
  713. ; Jumptable for shape line drawing routines with fading and predator flags set
  714. ;
  715. dd Short_Single_Line_Copy
  716. dd Short_Single_Line_Copy
  717. dd Short_Single_Line_Copy
  718. dd Short_Single_Line_Copy
  719. dd Single_Line_Single_Fade
  720. dd Single_Line_Single_Fade
  721. dd Single_Line_Fading
  722. dd Single_Line_Fading
  723. dd Single_Line_Predator
  724. dd Single_Line_Predator
  725. dd Single_Line_Predator
  726. dd Single_Line_Predator
  727. dd Single_Line_Predator_Fading
  728. dd Single_Line_Predator_Fading
  729. dd Single_Line_Predator_Fading
  730. dd Single_Line_Predator_Fading
  731. dd Single_Line_Skip
  732. dd Single_Line_Skip
  733. dd Single_Line_Skip
  734. dd Single_Line_Skip
  735. dd Single_Line_Skip
  736. dd Single_Line_Skip
  737. dd Single_Line_Skip
  738. dd Single_Line_Skip
  739. dd Single_Line_Skip
  740. dd Single_Line_Skip
  741. dd Single_Line_Skip
  742. dd Single_Line_Skip
  743. dd Single_Line_Skip
  744. dd Single_Line_Skip
  745. dd Single_Line_Skip
  746. dd Single_Line_Skip
  747. ;
  748. ; Jumptable for shape line drawing routines with fading and transparent and predator flags set
  749. ;
  750. dd Short_Single_Line_Copy
  751. dd Single_Line_Trans
  752. dd Short_Single_Line_Copy
  753. dd Single_Line_Trans
  754. dd Single_Line_Single_Fade
  755. dd Single_Line_Single_Fade_Trans
  756. dd Single_Line_Fading
  757. dd Single_Line_Fading_Trans
  758. dd Single_Line_Predator
  759. dd Single_Line_Predator_Trans
  760. dd Single_Line_Predator
  761. dd Single_Line_Predator_Trans
  762. dd Single_Line_Predator_Fading
  763. dd Single_Line_Predator_Fading_Trans
  764. dd Single_Line_Predator_Fading
  765. dd Single_Line_Predator_Fading_Trans
  766. dd Single_Line_Skip
  767. dd Single_Line_Skip
  768. dd Single_Line_Skip
  769. dd Single_Line_Skip
  770. dd Single_Line_Skip
  771. dd Single_Line_Skip
  772. dd Single_Line_Skip
  773. dd Single_Line_Skip
  774. dd Single_Line_Skip
  775. dd Single_Line_Skip
  776. dd Single_Line_Skip
  777. dd Single_Line_Skip
  778. dd Single_Line_Skip
  779. dd Single_Line_Skip
  780. dd Single_Line_Skip
  781. dd Single_Line_Skip
  782. ;
  783. ; Jumptable for shape line drawing routines with fading and ghost and predator flags set
  784. ;
  785. dd Short_Single_Line_Copy
  786. dd Short_Single_Line_Copy
  787. dd Single_Line_Ghost
  788. dd Single_Line_Ghost
  789. dd Single_Line_Single_Fade
  790. dd Single_Line_Single_Fade
  791. dd Single_Line_Ghost_Fading
  792. dd Single_Line_Ghost_Fading
  793. dd Single_Line_Predator
  794. dd Single_Line_Predator
  795. dd Single_Line_Predator_Ghost
  796. dd Single_Line_Predator_Ghost
  797. dd Single_Line_Predator_Fading
  798. dd Single_Line_Predator_Fading
  799. dd Single_Line_Predator_Ghost_Fading
  800. dd Single_Line_Predator_Ghost_Fading
  801. dd Single_Line_Skip
  802. dd Single_Line_Skip
  803. dd Single_Line_Skip
  804. dd Single_Line_Skip
  805. dd Single_Line_Skip
  806. dd Single_Line_Skip
  807. dd Single_Line_Skip
  808. dd Single_Line_Skip
  809. dd Single_Line_Skip
  810. dd Single_Line_Skip
  811. dd Single_Line_Skip
  812. dd Single_Line_Skip
  813. dd Single_Line_Skip
  814. dd Single_Line_Skip
  815. dd Single_Line_Skip
  816. dd Single_Line_Skip
  817. ;
  818. ; Jumptable for shape line drawing routines with all flags set
  819. ;
  820. AllFlagsJumpTable label dword
  821. dd Short_Single_Line_Copy
  822. dd Single_Line_Trans
  823. dd Single_Line_Ghost
  824. dd Single_Line_Ghost_Trans
  825. dd Single_Line_Single_Fade
  826. dd Single_Line_Single_Fade_Trans
  827. dd Single_Line_Ghost_Fading
  828. dd Single_Line_Ghost_Fading_Trans
  829. dd Single_Line_Predator
  830. dd Single_Line_Predator_Trans
  831. dd Single_Line_Predator_Ghost
  832. dd Single_Line_Predator_Ghost_Trans
  833. dd Single_Line_Predator_Fading
  834. dd Single_Line_Predator_Fading_Trans
  835. dd Single_Line_Predator_Ghost_Fading
  836. dd Single_Line_Predator_Ghost_Fading_Trans
  837. dd Single_Line_Skip
  838. dd Single_Line_Skip
  839. dd Single_Line_Skip
  840. dd Single_Line_Skip
  841. dd Single_Line_Skip
  842. dd Single_Line_Skip
  843. dd Single_Line_Skip
  844. dd Single_Line_Skip
  845. dd Single_Line_Skip
  846. dd Single_Line_Skip
  847. dd Single_Line_Skip
  848. dd Single_Line_Skip
  849. dd Single_Line_Skip
  850. dd Single_Line_Skip
  851. dd Single_Line_Skip
  852. dd Single_Line_Skip
  853. EndNewShapeJumpTable db 0
  854. .CODE
  855. ;---------------------------------------------------------------------------
  856. ;*********************************************************************************************
  857. ;* Set_Shape_Header -- create the line header bytes for a shape *
  858. ;* *
  859. ;* INPUT: Shape width *
  860. ;* Shape height *
  861. ;* ptr to raw shape data *
  862. ;* ptr to shape headers *
  863. ;* shape flags *
  864. ;* ptr to translucency table *
  865. ;* IsTranslucent *
  866. ;* *
  867. ;* OUTPUT: none *
  868. ;* *
  869. ;* Warnings: *
  870. ;* *
  871. ;* HISTORY: *
  872. ;* 11/29/95 10:09AM ST : Created. *
  873. ;*===========================================================================================*
  874. Setup_Shape_Header proc C pixel_width:DWORD, pixel_height:DWORD, src:DWORD, headers:DWORD, flags:DWORD, Translucent:DWORD, IsTranslucent:DWORD
  875. ;ARG pixel_width :DWORD ; width of rectangle to blit
  876. ;ARG pixel_height :DWORD ; height of rectangle to blit
  877. ;ARG src :DWORD ; this is a member function
  878. ;ARG headers :DWORD
  879. ;ARG flags :DWORD
  880. ;ARG Translucent :DWORD
  881. ;ARG IsTranslucent :DWORD
  882. LOCAL trans_count :DWORD
  883. pushad
  884. mov esi,[src] ;ptr to raw shape data
  885. mov edi,[headers] ;ptr to headers we are going to set up
  886. mov eax,[flags]
  887. and eax,SHAPE_TRANS or SHAPE_FADING or SHAPE_PREDATOR or SHAPE_GHOST
  888. mov [edi].ShapeHeaderType.draw_flags,eax ;save old flags in header
  889. add edi,size ShapeHeaderType
  890. mov edx,[pixel_height] ;number of shape lines to scan
  891. outer_loop: mov ecx,[pixel_width] ;number of pixels in shape line
  892. xor bl,bl ;flag the we dont know anything about this line yet
  893. mov [trans_count],0 ;we havnt scanned any transparent pixels yet
  894. ;
  895. ; Scan one shape line to see what kind of data it contains
  896. ;
  897. inner_loop: xor eax,eax
  898. mov al,[esi]
  899. inc esi
  900. ;
  901. ; Check for transparent pixel
  902. ;
  903. test al,al
  904. jnz not_transp
  905. test [flags],SHAPE_TRANS
  906. jz not_transp
  907. or bl,BLIT_TRANSPARENT ;flag that pixel is transparent
  908. inc [trans_count] ;keep count of the number of transparent pixels on the line
  909. jmp end_lp
  910. ;
  911. ; Check for predator effect on this line
  912. ;
  913. not_transp: test [flags],SHAPE_PREDATOR
  914. jz not_pred
  915. or bl,BLIT_PREDATOR
  916. ;
  917. ; Check for ghost effects
  918. ;
  919. not_pred: test [flags],SHAPE_GHOST
  920. jz not_ghost
  921. push edi
  922. mov edi,[IsTranslucent]
  923. cmp byte ptr [edi+eax],-1
  924. pop edi
  925. jz not_ghost
  926. or bl,BLIT_GHOST
  927. ;
  928. ; Check if fading is required
  929. ;
  930. not_ghost: test [flags],SHAPE_FADING
  931. jz end_lp
  932. or bl,BLIT_FADING
  933. end_lp: dec ecx
  934. jnz inner_loop
  935. ;
  936. ; Interpret the info we have collected and decide which routine will be
  937. ; used to draw this line
  938. ;
  939. xor bh,bh
  940. test bl,BLIT_TRANSPARENT
  941. jz no_transparencies
  942. or bh,BLIT_TRANSPARENT
  943. mov ecx,[pixel_width]
  944. cmp ecx,[trans_count]
  945. jnz not_all_trans
  946. ; all pixels in the line were transparent so we dont need to draw it at all
  947. mov bh,BLIT_SKIP
  948. jmp got_line_type
  949. not_all_trans:
  950. no_transparencies:
  951. mov al,bl
  952. and al,BLIT_PREDATOR
  953. or bh,al
  954. mov al,bl
  955. and al,BLIT_GHOST
  956. or bh,al
  957. mov al,bl
  958. and al,BLIT_FADING
  959. or bh,al
  960. ;
  961. ; Save the line header and do the next line
  962. ;
  963. got_line_type:mov [edi],bh
  964. inc edi
  965. dec edx
  966. jnz outer_loop
  967. popad
  968. ret
  969. Setup_Shape_Header endp
  970. ;**************************************************************
  971. ;
  972. ; Macro to fetch the header of the next line and jump to the appropriate routine
  973. ;
  974. next_line macro
  975. add edi , [ dest_adjust_width ] ;add in dest modulo
  976. dec edx ;line counter
  977. jz real_out ;return
  978. mov ecx,[save_ecx] ;ecx is pixel count
  979. mov eax,[header_pointer] ;ptr to next header byte
  980. mov al,[eax]
  981. inc [header_pointer]
  982. and eax,BLIT_ALL ;Make sure we dont jump to some spurious address
  983. ; if the header is wrong then its better to draw with the wrong
  984. ; shape routine than to die
  985. shl eax,2
  986. add eax,[ShapeJumpTableAddress] ;get the address to jump to
  987. jmp dword ptr [eax] ;do the jump
  988. endm
  989. ;***************************************************************************
  990. ;* VVC::TOPAGE -- Copies a linear buffer to a virtual viewport *
  991. ;* *
  992. ;* INPUT: WORD x_pixel - x pixel on viewport to copy from *
  993. ;* WORD y_pixel - y pixel on viewport to copy from *
  994. ;* WORD pixel_width - the width of copy region *
  995. ;* WORD pixel_height - the height of copy region *
  996. ;* BYTE * src - buffer to copy from *
  997. ;* VVPC * dest - virtual viewport to copy to *
  998. ;* *
  999. ;* OUTPUT: none *
  1000. ;* *
  1001. ;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
  1002. ;* the boundaries. In the event that no adjustment is *
  1003. ;* possible this routine will abort. If the size of the *
  1004. ;* region to copy exceeds the size passed in for the buffer *
  1005. ;* the routine will automatically abort. *
  1006. ;* *
  1007. ;* HISTORY: *
  1008. ;* 06/15/1994 PWG : Created. *
  1009. ;*=========================================================================*
  1010. Buffer_Frame_To_Page proc C public USES eax ebx ecx edx esi edi x_pixel:DWORD, y_pixel:DWORD, pixel_width:DWORD, pixel_height:DWORD, src:DWORD, dest:DWORD, flags:DWORD
  1011. ;USES eax,ebx,ecx,edx,esi,edi
  1012. ;*===================================================================
  1013. ;* define the arguements that our function takes.
  1014. ;*===================================================================
  1015. ;ARG x_pixel :DWORD ; x pixel position in source
  1016. ;ARG y_pixel :DWORD ; y pixel position in source
  1017. ;ARG pixel_width :DWORD ; width of rectangle to blit
  1018. ;ARG pixel_height:DWORD ; height of rectangle to blit
  1019. ;ARG src :DWORD ; this is a member function
  1020. ;ARG dest :DWORD ; what are we blitting to
  1021. ;ARG flags :DWORD ; flags passed
  1022. ;*===================================================================
  1023. ; Define some locals so that we can handle things quickly
  1024. ;*===================================================================
  1025. LOCAL IsTranslucent :DWORD ; ptr to the is_translucent table
  1026. LOCAL Translucent :DWORD ; ptr to the actual translucent table
  1027. LOCAL FadingTable :DWORD ; extracted fading table pointer
  1028. LOCAL FadingNum :DWORD ; get the number of times to fade
  1029. LOCAL StashECX :DWORD ; temp variable for ECX register
  1030. LOCAL jflags :DWORD ; flags used to goto correct buff frame routine
  1031. LOCAL BufferFrameRout :DWORD ; ptr to the buffer frame routine
  1032. LOCAL jmp_loc :DWORD ; calculated jump location
  1033. LOCAL loop_cnt :DWORD
  1034. LOCAL x1_pixel :DWORD
  1035. LOCAL y1_pixel :DWORD
  1036. LOCAL scr_x :DWORD
  1037. LOCAL scr_y :DWORD
  1038. LOCAL dest_adjust_width :DWORD
  1039. LOCAL scr_adjust_width :DWORD
  1040. LOCAL header_pointer :DWORD
  1041. LOCAL use_old_draw :DWORD
  1042. LOCAL save_ecx :DWORD
  1043. LOCAL ShapeJumpTableAddress :DWORD
  1044. LOCAL shape_buffer_start :DWORD
  1045. prologue
  1046. cmp [ src ] , 0
  1047. jz real_out
  1048. ;
  1049. ; Save the line attributes pointers and
  1050. ; Modify the src pointer to point to the actual image
  1051. ;
  1052. cmp [UseBigShapeBuffer],0
  1053. jz do_args ;just use the old shape drawing system
  1054. mov edi,[src]
  1055. mov [header_pointer],edi
  1056. mov eax,[BigShapeBufferStart]
  1057. cmp [edi].ShapeHeaderType.shape_buffer,0
  1058. jz is_ordinary_shape
  1059. mov eax,[TheaterShapeBufferStart]
  1060. is_ordinary_shape:
  1061. mov [shape_buffer_start],eax
  1062. mov edi,[edi].ShapeHeaderType.shape_data
  1063. add edi,[shape_buffer_start]
  1064. mov [src],edi
  1065. mov [use_old_draw],0
  1066. ;====================================================================
  1067. ; Pull off optional arguments:
  1068. ; EDI is used as an offset from the 'flags' parameter, to point
  1069. ; to the optional argument currently being processed.
  1070. ;====================================================================
  1071. do_args:
  1072. mov edi , 4 ; optional params start past flags
  1073. mov [ jflags ] , 0 ; clear jump flags
  1074. check_centering:
  1075. ;-------------------------------------------------------------------
  1076. ; See if we need to center the frame
  1077. ;-------------------------------------------------------------------
  1078. test [ flags ] , SHAPE_CENTER ; does this need to be centered?
  1079. je check_trans ; if not the skip over this stuff
  1080. mov eax , [ pixel_width ]
  1081. mov ebx , [ pixel_height ]
  1082. sar eax , 1
  1083. sar ebx , 1
  1084. sub [ x_pixel ] , eax
  1085. sub [ y_pixel ] , ebx
  1086. check_trans:
  1087. test [ flags ] , SHAPE_TRANS
  1088. jz check_ghost
  1089. or [ jflags ] , FLAG_TRANS
  1090. ;--------------------------------------------------------------------
  1091. ; SHAPE_GHOST: DWORD is_translucent tbl
  1092. ;--------------------------------------------------------------------
  1093. check_ghost:
  1094. test [ flags ] , SHAPE_GHOST ; are we ghosting this shape
  1095. jz check_fading
  1096. mov eax , [ flags + edi ]
  1097. or [ jflags ] , FLAG_GHOST
  1098. mov [ IsTranslucent ] , eax ; save ptr to is_trans. tbl
  1099. add eax , 0100h ; add 256 for first table
  1100. add edi , 4 ; next argument
  1101. mov [ Translucent ] , eax ; save ptr to translucent tbl
  1102. check_fading:
  1103. ;______________________________________________________________________
  1104. ; If this is the first time through for this shape then
  1105. ; set up the shape header
  1106. ;______________________________________________________________________
  1107. pushad
  1108. cmp [UseBigShapeBuffer],0
  1109. jz new_shape
  1110. mov edi,[header_pointer]
  1111. cmp [edi].ShapeHeaderType.draw_flags,-1
  1112. jz setup_headers
  1113. mov eax,[flags] ;Redo the shape headers if this shape was
  1114. and eax,SHAPE_TRANS or SHAPE_FADING or SHAPE_PREDATOR or SHAPE_GHOST ;initially set up with different flags
  1115. cmp eax,[edi].ShapeHeaderType.draw_flags
  1116. jz no_header_setup
  1117. new_shape:
  1118. mov [use_old_draw],1
  1119. jmp no_header_setup
  1120. setup_headers:
  1121. push [IsTranslucent]
  1122. push [Translucent]
  1123. push [flags]
  1124. push [header_pointer]
  1125. push [src]
  1126. push [pixel_height]
  1127. push [pixel_width]
  1128. call Setup_Shape_Header
  1129. add esp,7*4
  1130. mov [ShapeJumpTableAddress], offset AllFlagsJumpTable
  1131. jmp headers_set
  1132. no_header_setup:
  1133. xor eax,eax
  1134. test [flags],SHAPE_PREDATOR
  1135. jz not_shape_predator
  1136. or al,BLIT_PREDATOR
  1137. not_shape_predator:
  1138. test [flags],SHAPE_FADING
  1139. jz not_shape_fading
  1140. or al,BLIT_FADING
  1141. not_shape_fading:
  1142. test [flags],SHAPE_TRANS
  1143. jz not_shape_transparent
  1144. or al,BLIT_TRANSPARENT
  1145. not_shape_transparent:
  1146. test [flags],SHAPE_GHOST
  1147. jz not_shape_ghost
  1148. or al,BLIT_GHOST
  1149. not_shape_ghost:
  1150. shl eax,7
  1151. add eax, offset NewShapeJumpTable
  1152. mov [ShapeJumpTableAddress],eax
  1153. ;call Init_New_Shape_Jump_Table_Address
  1154. headers_set:
  1155. popad
  1156. ;--------------------------------------------------------------------
  1157. ; SHAPE_FADING: DWORD fade_table[256], DWORD fade_count
  1158. ;--------------------------------------------------------------------
  1159. test [ flags ] , SHAPE_FADING ; are we fading this shape
  1160. jz check_predator
  1161. mov eax , [ flags + edi ]
  1162. mov [ FadingTable ] , eax ; save address of fading tbl
  1163. mov eax , [ flags + edi + 4 ] ; get fade num
  1164. or [ jflags ] , FLAG_FADING
  1165. and eax , 03fh ; no need for more than 63
  1166. add edi , 8 ; next argument
  1167. cmp eax , 0 ; check if it's 0
  1168. jnz set_fading ; if not, store fade num
  1169. and [ flags ] , NOT SHAPE_FADING ; otherwise, don't fade
  1170. set_fading:
  1171. mov [ FadingNum ] , eax
  1172. mov ebx,[ShapeJumpTableAddress]
  1173. mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx],offset Single_Line_Single_Fade
  1174. mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx+4],offset Single_Line_Single_Fade_Trans
  1175. cmp eax,1
  1176. jz single_fade
  1177. mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx],offset Single_Line_Fading
  1178. mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx+4],offset Single_Line_Fading_Trans
  1179. single_fade:
  1180. ;--------------------------------------------------------------------
  1181. ; SHAPE_PREDATOR: DWORD init_pred_lookup_offset (0-7)
  1182. ;--------------------------------------------------------------------
  1183. check_predator:
  1184. test [ flags ] , SHAPE_PREDATOR ; is predator effect on
  1185. jz check_partial
  1186. mov eax , [ flags + edi ] ; pull the partial value
  1187. or [ jflags ] , FLAG_PREDATOR
  1188. shl eax , 1
  1189. cmp eax , 0
  1190. jge check_range
  1191. neg eax
  1192. mov ebx , -1
  1193. and eax , PRED_MASK ; keep entries within bounds
  1194. mov bl , al
  1195. mov eax , ebx ; will be ffffff00-ffffff07
  1196. jmp pred_cont
  1197. check_range:
  1198. and eax , PRED_MASK ; keep entries within bounds
  1199. pred_cont:
  1200. add edi , 4 ; next argument
  1201. mov [ BFPredOffset ] , eax
  1202. mov [ BFPartialCount ] , 0 ; clear the partial count
  1203. mov [ BFPartialPred ] , 100h ; init partial to off
  1204. pred_neg_init:
  1205. mov esi , [ dest ] ; get ptr to dest
  1206. mov ebx, 7 * 2
  1207. pred_loop:
  1208. movzx eax , [ WORD PTR BFPredNegTable + ebx ]
  1209. add eax , [esi].GraphicViewPort.GVPWidth ; add width
  1210. add eax , [esi].GraphicViewPort.GVPXAdd ; add x add
  1211. add eax , [esi].GraphicViewPort.GVPPitch ; extra pitch of DD surface ST - 9/29/95 1:08PM
  1212. mov [ WORD PTR BFPredNegTable + 16 + ebx ] , ax
  1213. dec ebx
  1214. dec ebx
  1215. jge pred_loop
  1216. ;--------------------------------------------------------------------
  1217. ; SHAPE_PARTIAL: DWORD partial_pred_value (0-255)
  1218. ;--------------------------------------------------------------------
  1219. check_partial:
  1220. test [ flags ] , SHAPE_PARTIAL ; is this a partial pred?
  1221. jz setupfunc
  1222. mov eax , [ flags + edi ] ; pull the partial value
  1223. add edi , 4 ; next argument
  1224. and eax , 0ffh ; make sure 0-255
  1225. mov [ BFPartialPred ] , eax ; store it off
  1226. setupfunc:
  1227. mov ebx , [ jflags ] ; load flags value
  1228. and ebx , FLAG_MASK ; clip high bits
  1229. add ebx , ebx ; mult by 4 to get DWORD offset
  1230. add ebx , ebx
  1231. mov ebx , dword ptr [ BufferFrameTable + ebx ] ; get table value
  1232. mov dword ptr [ BufferFrameRout ] , ebx ; store it in the function pointer
  1233. ; Clip dest Rectangle against source Window boundaries.
  1234. mov [ scr_x ] , 0
  1235. mov [ scr_y ] , 0
  1236. mov esi , [ dest ] ; get ptr to dest
  1237. xor ecx , ecx
  1238. xor edx , edx
  1239. mov edi , [esi].GraphicViewPort.GVPWidth ; get width into register
  1240. mov ebx , [ x_pixel ]
  1241. mov eax , [ x_pixel ]
  1242. add ebx , [ pixel_width ]
  1243. shld ecx , eax , 1
  1244. mov [ x1_pixel ] , ebx
  1245. inc edi
  1246. shld edx , ebx , 1
  1247. sub eax , edi
  1248. sub ebx , edi
  1249. shld ecx , eax , 1
  1250. shld edx , ebx , 1
  1251. mov edi,[esi].GraphicViewPort.GVPHeight ; get height into register
  1252. mov ebx , [ y_pixel ]
  1253. mov eax , [ y_pixel ]
  1254. add ebx , [ pixel_height ]
  1255. shld ecx , eax , 1
  1256. mov [ y1_pixel ] , ebx
  1257. inc edi
  1258. shld edx , ebx , 1
  1259. sub eax , edi
  1260. sub ebx , edi
  1261. shld ecx , eax , 1
  1262. shld edx , ebx , 1
  1263. xor cl , 5
  1264. xor dl , 5
  1265. mov al , cl
  1266. test dl , cl
  1267. jnz real_out
  1268. or al , dl
  1269. jz do_blit
  1270. mov [use_old_draw],1
  1271. test cl , 1000b
  1272. jz dest_left_ok
  1273. mov eax , [ x_pixel ]
  1274. neg eax
  1275. mov [ x_pixel ] , 0
  1276. mov [ scr_x ] , eax
  1277. dest_left_ok:
  1278. test cl , 0010b
  1279. jz dest_bottom_ok
  1280. mov eax , [ y_pixel ]
  1281. neg eax
  1282. mov [ y_pixel ] , 0
  1283. mov [ scr_y ] , eax
  1284. dest_bottom_ok:
  1285. test dl , 0100b
  1286. jz dest_right_ok
  1287. mov eax , [esi].GraphicViewPort.GVPWidth ; get width into register
  1288. mov [ x1_pixel ] , eax
  1289. dest_right_ok:
  1290. test dl , 0001b
  1291. jz do_blit
  1292. mov eax , [esi].GraphicViewPort.GVPHeight ; get width into register
  1293. mov [ y1_pixel ] , eax
  1294. do_blit:
  1295. cld
  1296. mov eax , [esi].GraphicViewPort.GVPXAdd
  1297. add eax , [esi].GraphicViewPort.GVPPitch
  1298. add eax , [esi].GraphicViewPort.GVPWidth
  1299. mov edi , [esi].GraphicViewPort.GVPOffset
  1300. mov ecx , eax
  1301. mul [ y_pixel ]
  1302. add edi , [ x_pixel ]
  1303. add edi , eax
  1304. add ecx , [ x_pixel ]
  1305. sub ecx , [ x1_pixel ]
  1306. mov [ dest_adjust_width ] , ecx
  1307. mov esi , [ src ]
  1308. mov eax , [ pixel_width ]
  1309. sub eax , [ x1_pixel ]
  1310. add eax , [ x_pixel ]
  1311. mov [ scr_adjust_width ] , eax
  1312. mov eax , [ scr_y ]
  1313. mul [ pixel_width ]
  1314. add eax , [ scr_x ]
  1315. add esi , eax
  1316. ;
  1317. ; If the shape needs to be clipped then we cant handle it with the new header systen
  1318. ; so draw it with the old shape drawer
  1319. ;
  1320. cmp [use_old_draw],0
  1321. jnz use_old_stuff
  1322. add [header_pointer],size ShapeHeaderType
  1323. mov edx,[pixel_height]
  1324. mov ecx,[pixel_width]
  1325. mov eax,[header_pointer]
  1326. mov al,[eax]
  1327. mov [save_ecx],ecx
  1328. inc [header_pointer]
  1329. and eax,BLIT_ALL
  1330. shl eax,2
  1331. add eax,[ShapeJumpTableAddress]
  1332. jmp dword ptr [eax]
  1333. use_old_stuff:
  1334. mov edx , [ y1_pixel ]
  1335. mov eax , [ x1_pixel ]
  1336. sub edx , [ y_pixel ]
  1337. jle real_out
  1338. sub eax , [ x_pixel ]
  1339. jle real_out
  1340. jmp [ BufferFrameRout ] ; buffer frame to viewport routine
  1341. real_out:
  1342. cmp [MMXAvailable],0
  1343. jz no_mmx_cleanup
  1344. call MMX_Done
  1345. no_mmx_cleanup:
  1346. epilogue
  1347. ret
  1348. ; ********************************************************************
  1349. ; Forward bitblit only
  1350. ; the inner loop is so efficient that
  1351. ; the optimal consept no longer apply because
  1352. ; the optimal byte have to by a number greather than 9 bytes
  1353. ; ********************************************************************
  1354. ;extern BF_Copy:near
  1355. BF_Copy:
  1356. prologue
  1357. cmp eax , 10
  1358. jl forward_loop_bytes
  1359. forward_loop_dword:
  1360. mov ecx , edi
  1361. mov ebx , eax
  1362. neg ecx
  1363. and ecx , 3
  1364. sub ebx , ecx
  1365. rep movsb
  1366. mov ecx , ebx
  1367. shr ecx , 2
  1368. rep movsd
  1369. mov ecx , ebx
  1370. and ecx , 3
  1371. rep movsb
  1372. add esi , [ scr_adjust_width ]
  1373. add edi , [ dest_adjust_width ]
  1374. dec edx
  1375. jnz forward_loop_dword
  1376. ret
  1377. forward_loop_bytes:
  1378. mov ecx , eax
  1379. rep movsb
  1380. add esi , [ scr_adjust_width ]
  1381. add edi , [ dest_adjust_width ]
  1382. dec edx ; decrement the height
  1383. jnz forward_loop_bytes
  1384. epilogue
  1385. ret
  1386. ;********************************************************************
  1387. ;********************************************************************
  1388. ; segment code page public use32 'code' ; Need stricter segment alignment
  1389. ; for pentium optimisations
  1390. ;
  1391. ; Expand the 'next_line' macro so we can jump to it
  1392. ;
  1393. ;
  1394. ; ST - 12/20/2018 3:48PM
  1395. Next_Line:: next_line
  1396. ;*****************************************************************************
  1397. ; Draw a single line with transparent pixels
  1398. ;
  1399. ; 11/29/95 10:21AM - ST
  1400. ;
  1401. ;align 32
  1402. Single_Line_Trans::
  1403. prologue
  1404. Single_Line_Trans_Entry::
  1405. slt_mask_map_lp: ; Pentium pipeline usage
  1406. ;Pipe Cycles
  1407. mov al,[esi] ;U 1
  1408. inc esi ;Vee 1
  1409. test al,al ;U 1
  1410. jz slt_skip ;Vee 1/5
  1411. slt_not_trans:mov [edi],al ;u 1
  1412. inc edi ;vee 1
  1413. dec ecx ;u 1
  1414. jnz slt_mask_map_lp ;vee (maybe) 1
  1415. slt_end_line: epilogue
  1416. next_line
  1417. ;align 32
  1418. slt_skip: inc edi
  1419. dec ecx
  1420. jz slt_skip_end_line
  1421. mov al,[esi]
  1422. inc esi
  1423. test al,al
  1424. jz slt_skip2
  1425. mov [edi],al
  1426. inc edi
  1427. dec ecx
  1428. jnz slt_mask_map_lp
  1429. epilogue
  1430. next_line
  1431. ;align 32
  1432. slt_skip2: inc edi
  1433. dec ecx
  1434. jz slt_end_line
  1435. ;
  1436. ; If we have hit two transparent pixels in a row then we go into
  1437. ; the transparent optimised bit
  1438. ;
  1439. slt_round_again:
  1440. rept 64
  1441. mov al,[esi] ; ;pipe 1
  1442. inc esi ;1 ;pipe 2
  1443. test al,al ; ;pipe 1
  1444. jnz slt_not_trans;pipe 2 (not pairable in 1)
  1445. ;2
  1446. inc edi ; ;pipe 1
  1447. dec ecx ;3 ;pipe 2
  1448. jz slt_end_line ;4 ;pipe 1 (not pairable)
  1449. endm ; best case is 4 cycles per iteration
  1450. jmp slt_round_again
  1451. slt_skip_end_line:
  1452. epilogue
  1453. next_line
  1454. ;*****************************************************************************
  1455. ; Draw a single line with no transparent pixels
  1456. ;
  1457. ; 11/29/95 10:21AM - ST
  1458. ;
  1459. ; We have to align the destination for cards that dont bankswitch correctly
  1460. ; when you write non-aligned data.
  1461. ;
  1462. ;align 32
  1463. Long_Single_Line_Copy:
  1464. prologue
  1465. rept 3
  1466. test edi,3
  1467. jz LSLC_aligned
  1468. movsb
  1469. dec ecx
  1470. endm
  1471. LSLC_aligned:
  1472. mov ebx,ecx
  1473. shr ecx,2
  1474. rep movsd
  1475. and ebx,3
  1476. jz proc_out
  1477. movsb
  1478. dec bl
  1479. jz proc_out
  1480. movsb
  1481. dec bl
  1482. jz proc_out
  1483. movsb
  1484. proc_out: epilogue
  1485. next_line
  1486. ;*****************************************************************************
  1487. ; Draw a single short line with no transparent pixels
  1488. ;
  1489. ; 11/29/95 10:21AM - ST
  1490. ;
  1491. ;align 32
  1492. Short_Single_Line_Copy:
  1493. prologue
  1494. cmp ecx,16
  1495. jge Long_Single_Line_Copy
  1496. mov ebx,ecx
  1497. rep movsb
  1498. mov ecx,ebx
  1499. epilogue
  1500. next_line
  1501. ;*****************************************************************************
  1502. ; Skip a line of source that is all transparent
  1503. ;
  1504. ; 11/29/95 10:21AM - ST
  1505. ;
  1506. ;align 32
  1507. Single_Line_Skip:
  1508. prologue
  1509. add esi,ecx
  1510. add edi,ecx
  1511. epilogue
  1512. next_line
  1513. ;*****************************************************************************
  1514. ; Draw a single line with ghosting
  1515. ;
  1516. ; 11/29/95 10:21AM - ST
  1517. ;
  1518. ;align 32
  1519. Single_Line_Ghost:
  1520. prologue
  1521. xor eax,eax
  1522. slg_loop: mov al,[esi]
  1523. mov ebx,[IsTranslucent]
  1524. inc esi
  1525. mov bh,[eax+ebx]
  1526. cmp bh,-1
  1527. jz slg_store_pixel
  1528. and ebx,0ff00h
  1529. mov al,[edi]
  1530. add ebx,[Translucent]
  1531. mov al,[eax+ebx]
  1532. slg_store_pixel:
  1533. mov [edi],al
  1534. inc edi
  1535. dec ecx
  1536. jnz slg_loop
  1537. epilogue
  1538. next_line
  1539. ;*****************************************************************************
  1540. ; Draw a single line with transparent pixels and ghosting
  1541. ;
  1542. ; 11/29/95 10:21AM - ST
  1543. ;
  1544. ;align 32
  1545. Single_Line_Ghost_Trans:
  1546. prologue
  1547. xor eax,eax
  1548. ; cmp ecx,3
  1549. ; ja slgt4
  1550. slgt_loop: mov al,[esi]
  1551. inc esi
  1552. test al,al
  1553. jz slgt_transparent
  1554. slgt_not_transparent:
  1555. mov ebx,[IsTranslucent]
  1556. mov bh,[eax+ebx]
  1557. cmp bh,-1
  1558. jz slgt_store_pixel
  1559. and ebx,0ff00h
  1560. mov al,[edi]
  1561. add ebx,[Translucent]
  1562. mov al,[eax+ebx]
  1563. slgt_store_pixel:
  1564. mov [edi],al
  1565. inc edi
  1566. dec ecx
  1567. jnz slgt_loop
  1568. epilogue
  1569. next_line
  1570. ;align 32
  1571. slgt_transparent:
  1572. inc edi ;1
  1573. dec ecx ;2
  1574. jz slgt_out ;1 (not pairable)
  1575. slgt_round_again:
  1576. rept 64
  1577. mov al,[esi] ; ;pipe 1
  1578. inc esi ;1 ;pipe 2
  1579. test al,al ; ;pipe 1
  1580. jnz slgt_not_transparent ;pipe 2 (not pairable in 1)
  1581. ;2
  1582. inc edi ; ;pipe 1
  1583. dec ecx ;3 ;pipe 2
  1584. jz slgt_out ;4 ;pipe 1 (not pairable)
  1585. endm ; best case is 4 cycles per iteration
  1586. jmp slgt_round_again
  1587. slgt_out: epilogue
  1588. next_line
  1589. ;
  1590. ; Optimised video memory access version
  1591. ;
  1592. ;align 32
  1593. slgt4: push edx
  1594. mov edx,[edi]
  1595. rept 4
  1596. local slgt4_store1
  1597. local slgt4_trans1
  1598. mov al,[esi]
  1599. inc esi
  1600. test al,al
  1601. jz slgt4_trans1
  1602. mov ebx,[IsTranslucent]
  1603. mov bh,[eax+ebx]
  1604. cmp bh,-1
  1605. jz slgt4_store1
  1606. and ebx,0ff00h
  1607. mov al,dl
  1608. add ebx,[Translucent]
  1609. mov al,[eax+ebx]
  1610. slgt4_store1: mov dl,al
  1611. slgt4_trans1: ror edx,8
  1612. endm
  1613. mov [edi],edx
  1614. pop edx
  1615. lea edi,[edi+4]
  1616. lea ecx,[ecx+0fffffffch]
  1617. cmp ecx,3
  1618. ja slgt4
  1619. test ecx,ecx
  1620. jnz slgt_loop
  1621. epilogue
  1622. next_line
  1623. ;*****************************************************************************
  1624. ; Draw a single line with fading (colour remapping)
  1625. ;
  1626. ; 11/29/95 10:21AM - ST
  1627. ;
  1628. ;align 32
  1629. Single_Line_Fading:
  1630. prologue
  1631. xor eax,eax
  1632. mov ebx,[FadingTable]
  1633. push ebp
  1634. mov ebp,[FadingNum]
  1635. push ebp
  1636. slf_loop: mov al,[esi]
  1637. inc esi
  1638. mov ebp,[esp]
  1639. slf_fade_loop:mov al,[ebx+eax]
  1640. dec ebp
  1641. jnz slf_fade_loop
  1642. mov [edi],al
  1643. inc edi
  1644. dec ecx
  1645. jnz slf_loop
  1646. add esp,4
  1647. pop ebp
  1648. epilogue
  1649. next_line
  1650. ;*****************************************************************************
  1651. ; Draw a single line with transparent pixels and fading (colour remapping)
  1652. ;
  1653. ; 11/29/95 10:21AM - ST
  1654. ;
  1655. ;align 32
  1656. Single_Line_Fading_Trans:
  1657. prologue
  1658. xor eax,eax
  1659. mov ebx,[FadingTable]
  1660. push ebp
  1661. mov ebp,[FadingNum]
  1662. push ebp
  1663. slft_loop: mov al,[esi]
  1664. inc esi
  1665. test al,al
  1666. jz slft_transparent
  1667. mov ebp,[esp]
  1668. slft_fade_loop:
  1669. mov al,[ebx+eax]
  1670. dec ebp
  1671. jnz slft_fade_loop
  1672. mov [edi],al
  1673. slft_transparent:
  1674. inc edi
  1675. dec ecx
  1676. jnz slft_loop
  1677. add esp,4
  1678. pop ebp
  1679. epilogue
  1680. next_line
  1681. ;*****************************************************************************
  1682. ; Draw a single line with a single fade level (colour remap)
  1683. ;
  1684. ; 11/29/95 10:21AM - ST
  1685. ;
  1686. ;align 32
  1687. Single_Line_Single_Fade:
  1688. prologue
  1689. xor eax,eax
  1690. mov ebx,[FadingTable]
  1691. slsf_loop: mov al,[esi]
  1692. mov al,[ebx+eax]
  1693. mov [edi],al
  1694. inc esi
  1695. inc edi
  1696. dec ecx
  1697. jnz slsf_loop
  1698. epilogue
  1699. next_line
  1700. ;*****************************************************************************
  1701. ; Draw a single line with transparent pixels and a single fade level (colour remap)
  1702. ;
  1703. ; 11/29/95 10:21AM - ST
  1704. ;
  1705. ;align 32
  1706. Single_Line_Single_Fade_Trans:
  1707. prologue
  1708. xor eax,eax
  1709. mov ebx,[FadingTable]
  1710. slsft_loop: mov al,[esi]
  1711. inc esi
  1712. test al,al
  1713. jz slsft_transparent
  1714. mov al,[ebx+eax]
  1715. mov [edi],al
  1716. inc edi
  1717. dec ecx
  1718. jnz slsft_loop
  1719. epilogue
  1720. next_line
  1721. ;align 32
  1722. slsft_transparent:
  1723. inc edi
  1724. dec ecx
  1725. jz slsft_next_line
  1726. mov al,[esi]
  1727. inc esi
  1728. test al,al
  1729. jz slsft_transparent
  1730. mov al,[ebx+eax]
  1731. mov [edi],al
  1732. inc edi
  1733. dec ecx
  1734. jnz slsft_loop
  1735. slsft_next_line:
  1736. epilogue
  1737. next_line
  1738. ;*****************************************************************************
  1739. ; Draw a single line with ghosting and fading (colour remapping)
  1740. ;
  1741. ; 11/29/95 10:21AM - ST
  1742. ;
  1743. ;align 32
  1744. Single_Line_Ghost_Fading:
  1745. prologue
  1746. mov [StashECX],ecx
  1747. SLGF_loop: xor eax,eax
  1748. mov al,[esi]
  1749. mov ebx,[IsTranslucent]
  1750. mov bh,[eax+ebx]
  1751. cmp bh,-1
  1752. jz slgf_do_fading
  1753. and ebx,0ff00h
  1754. mov al,[edi]
  1755. add ebx,[Translucent]
  1756. mov al,[ebx+eax]
  1757. slgf_do_fading:
  1758. mov ebx,[FadingTable]
  1759. mov ecx,[FadingNum]
  1760. slgf_fade_loop:
  1761. mov al,[eax+ebx]
  1762. dec ecx
  1763. jnz slgf_fade_loop
  1764. mov [edi],al
  1765. inc esi
  1766. inc edi
  1767. dec [StashECX]
  1768. jnz SLGF_loop
  1769. epilogue
  1770. next_line
  1771. ;*****************************************************************************
  1772. ; Draw a single line with transparent pixels, ghosting and fading
  1773. ;
  1774. ; 11/29/95 10:21AM - ST
  1775. ;
  1776. ;align 32
  1777. Single_Line_Ghost_Fading_Trans:
  1778. prologue
  1779. mov [StashECX],ecx
  1780. xor eax,eax
  1781. ; cmp ecx,3
  1782. ; ja slgft4
  1783. SLGFT_loop: mov al,[esi]
  1784. inc esi
  1785. test al,al
  1786. jz slgft_trans_pixel
  1787. mov ebx,[IsTranslucent]
  1788. mov bh,[eax+ebx]
  1789. cmp bh,-1
  1790. jz slgft_do_fading
  1791. and ebx,0ff00h
  1792. mov al,[edi]
  1793. add ebx,[Translucent]
  1794. mov al,[ebx+eax]
  1795. slgft_do_fading:
  1796. mov ebx,[FadingTable]
  1797. mov ecx,[FadingNum]
  1798. slgft_fade_loop:
  1799. mov al,[eax+ebx]
  1800. dec ecx
  1801. jnz slgft_fade_loop
  1802. mov [edi],al
  1803. slgft_trans_pixel:
  1804. inc edi
  1805. dec [StashECX]
  1806. jnz SLGFT_loop
  1807. epilogue
  1808. next_line
  1809. ;align 32
  1810. slgft4: push edx
  1811. mov edx,[edi]
  1812. rept 4
  1813. local slgft4_fade
  1814. local slgft4_fade_lp
  1815. local slgft4_trans
  1816. mov al,[esi]
  1817. inc esi
  1818. test al,al
  1819. jz slgft4_trans
  1820. mov ebx,[IsTranslucent]
  1821. mov bh,[eax+ebx]
  1822. cmp bh,-1
  1823. jz slgft4_fade
  1824. and ebx,0ff00h
  1825. mov al,dl
  1826. add ebx,[Translucent]
  1827. mov al,[ebx+eax]
  1828. slgft4_fade: mov ebx,[FadingTable]
  1829. mov ecx,[FadingNum]
  1830. slgft4_fade_lp: mov al,[eax+ebx]
  1831. dec ecx
  1832. jnz slgft4_fade_lp
  1833. mov dl,al
  1834. slgft4_trans: ror edx,8
  1835. endm
  1836. mov [edi],edx
  1837. pop edx
  1838. lea edi,[edi+4]
  1839. sub [StashECX],4
  1840. jz slgft4_out
  1841. cmp [StashECX],3
  1842. ja slgft4
  1843. jmp SLGFT_loop
  1844. slgft4_out: epilogue
  1845. next_line
  1846. ;*****************************************************************************
  1847. ; Draw a single line with predator effect
  1848. ;
  1849. ; 11/29/95 10:21AM - ST
  1850. ;
  1851. ;align 32
  1852. Single_Line_Predator:
  1853. prologue
  1854. slp_loop: mov al,[esi]
  1855. mov ebx,[BFPartialCount]
  1856. add ebx,[BFPartialPred]
  1857. or bh,bh
  1858. jnz slp_get_pred
  1859. mov [BFPartialCount] , ebx
  1860. jmp slp_skip_pixel
  1861. slp_get_pred: xor bh , bh
  1862. mov eax,[BFPredOffset]
  1863. mov [BFPartialCount] , ebx
  1864. add byte ptr [BFPredOffset],2
  1865. mov eax, dword ptr [BFPredTable+eax]
  1866. and byte ptr [BFPredOffset],PRED_MASK
  1867. and eax,0ffffh
  1868. mov al,[edi+eax]
  1869. mov [edi],al
  1870. slp_skip_pixel:
  1871. inc esi
  1872. inc edi
  1873. dec ecx
  1874. jnz slp_loop
  1875. epilogue
  1876. next_line
  1877. ;*****************************************************************************
  1878. ; Draw a single line with transparent pixels and predator effect
  1879. ;
  1880. ; 11/29/95 10:21AM - ST
  1881. ;
  1882. ;align 32
  1883. Single_Line_Predator_Trans:
  1884. prologue
  1885. slpt_loop: mov al,[esi]
  1886. inc esi
  1887. test al,al
  1888. jz slpt_skip_pixel
  1889. mov ebx,[BFPartialCount]
  1890. add ebx,[BFPartialPred]
  1891. or bh,bh
  1892. jnz slpt_get_pred
  1893. mov [BFPartialCount] , ebx
  1894. jmp slpt_skip_pixel
  1895. slpt_get_pred:xor bh , bh
  1896. mov eax,[BFPredOffset]
  1897. mov [BFPartialCount] , ebx
  1898. add byte ptr [BFPredOffset],2
  1899. mov eax,dword ptr [BFPredTable+eax]
  1900. and byte ptr [BFPredOffset ] , PRED_MASK
  1901. and eax,0ffffh
  1902. mov al,[edi+eax]
  1903. mov [edi],al
  1904. slpt_skip_pixel:
  1905. inc edi
  1906. dec ecx
  1907. jnz slpt_loop
  1908. epilogue
  1909. next_line
  1910. ;*****************************************************************************
  1911. ; Draw a single line with predator and ghosting
  1912. ;
  1913. ; 11/29/95 10:21AM - ST
  1914. ;
  1915. ;align 32
  1916. Single_Line_Predator_Ghost:
  1917. prologue
  1918. slpg_loop: mov al,[esi]
  1919. mov ebx,[BFPartialCount]
  1920. add ebx,[BFPartialPred]
  1921. test bh,bh
  1922. jnz slpg_get_pred ; is this a predator pixel?
  1923. mov [BFPartialCount],ebx
  1924. jmp slpg_check_ghost
  1925. slpg_get_pred:
  1926. xor bh,bh
  1927. mov eax,[BFPredOffset]
  1928. mov [BFPartialCount],ebx
  1929. add byte ptr [BFPredOffset],2
  1930. mov eax,dword ptr [BFPredTable+eax ]
  1931. and byte ptr [BFPredOffset],PRED_MASK
  1932. and eax,0ffffh
  1933. mov al,[edi+eax]
  1934. slpg_check_ghost:
  1935. mov ebx,[IsTranslucent]
  1936. mov bh,[ebx+eax]
  1937. cmp bh,0ffh
  1938. je slpg_store_pixel
  1939. xor eax,eax
  1940. and ebx,0FF00h
  1941. mov al,[edi]
  1942. add ebx,[Translucent]
  1943. mov al,[ebx+eax]
  1944. slpg_store_pixel:
  1945. mov [edi],al
  1946. inc esi
  1947. inc edi
  1948. dec ecx
  1949. jnz slpg_loop
  1950. epilogue
  1951. next_line
  1952. ;*****************************************************************************
  1953. ; Draw a single line with transparent pixels, predator and ghosting
  1954. ;
  1955. ; 11/29/95 10:21AM - ST
  1956. ;
  1957. ;align 32
  1958. Single_Line_Predator_Ghost_Trans:
  1959. prologue
  1960. slpgt_loop: mov al,[esi]
  1961. inc esi
  1962. test al,al
  1963. jz slpgt_transparent
  1964. mov ebx,[BFPartialCount]
  1965. add ebx,[BFPartialPred]
  1966. test bh,bh
  1967. jnz slpgt_get_pred ; is this a predator pixel?
  1968. mov [BFPartialCount],ebx
  1969. jmp slpgt_check_ghost
  1970. slpgt_get_pred:
  1971. xor bh,bh
  1972. mov eax,[BFPredOffset]
  1973. mov [BFPartialCount],ebx
  1974. add byte ptr [BFPredOffset],2
  1975. mov eax,dword ptr [BFPredTable+eax ]
  1976. and byte ptr [BFPredOffset],PRED_MASK
  1977. and eax,0ffffh
  1978. mov al,[edi+eax]
  1979. slpgt_check_ghost:
  1980. mov ebx,[IsTranslucent]
  1981. mov bh,[ebx+eax]
  1982. cmp bh,0ffh
  1983. je slpgt_store_pixel
  1984. xor eax,eax
  1985. and ebx,0FF00h
  1986. mov al,[edi]
  1987. add ebx,[Translucent]
  1988. mov al,[ebx+eax]
  1989. slpgt_store_pixel:
  1990. mov [edi],al
  1991. slpgt_transparent:
  1992. inc edi
  1993. dec ecx
  1994. jnz slpgt_loop
  1995. pop ecx
  1996. epilogue
  1997. next_line
  1998. ;*****************************************************************************
  1999. ; Draw a single line with predator and fading
  2000. ;
  2001. ; 11/29/95 10:21AM - ST
  2002. ;
  2003. ;align 32
  2004. Single_Line_Predator_Fading:
  2005. prologue
  2006. mov [StashECX],ecx
  2007. slpf_loop: mov al,[esi]
  2008. mov ebx,[BFPartialCount]
  2009. inc esi
  2010. add ebx,[BFPartialPred]
  2011. test bh,bh
  2012. jnz slpf_get_pred
  2013. mov [BFPartialCount],ebx
  2014. jmp slpf_do_fading
  2015. slpf_get_pred:xor bh,bh
  2016. mov eax,[BFPredOffset]
  2017. mov [BFPartialCount],ebx
  2018. and byte ptr [BFPredOffset],2
  2019. mov eax,dword ptr [BFPredTable+eax]
  2020. and byte ptr [BFPredOffset],PRED_MASK
  2021. and eax,0ffffh
  2022. mov al,[eax+edi]
  2023. slpf_do_fading:
  2024. and eax,255
  2025. mov ebx,[FadingTable]
  2026. mov ecx,[FadingNum]
  2027. slpf_fade_loop:
  2028. mov al,[eax+ebx]
  2029. dec ecx
  2030. jnz slpf_fade_loop
  2031. mov [edi],al
  2032. inc edi
  2033. dec [StashECX]
  2034. jnz slpf_loop
  2035. epilogue
  2036. next_line
  2037. ;*****************************************************************************
  2038. ; Draw a single line with transparent pixels, fading and predator
  2039. ;
  2040. ; 11/29/95 10:21AM - ST
  2041. ;
  2042. ;align 32
  2043. Single_Line_Predator_Fading_Trans:
  2044. prologue
  2045. mov [StashECX],ecx
  2046. slpft_loop: mov al,[esi]
  2047. inc esi
  2048. test al,al
  2049. jz slpft_transparent
  2050. mov ebx,[BFPartialCount]
  2051. add ebx,[BFPartialPred]
  2052. test bh,bh
  2053. jnz slpft_get_pred
  2054. mov [BFPartialCount],ebx
  2055. jmp slpft_do_fading
  2056. slpft_get_pred:
  2057. xor bh,bh
  2058. mov eax,[BFPredOffset]
  2059. mov [BFPartialCount],ebx
  2060. and byte ptr [BFPredOffset],2
  2061. mov eax,dword ptr [BFPredTable+eax]
  2062. and byte ptr [BFPredOffset],PRED_MASK
  2063. and eax,0ffffh
  2064. mov al,[eax+edi]
  2065. slpft_do_fading:
  2066. and eax,255
  2067. mov ebx,[FadingTable]
  2068. mov ecx,[FadingNum]
  2069. slpft_fade_loop:
  2070. mov al,[eax+ebx]
  2071. dec ecx
  2072. jnz slpft_fade_loop
  2073. mov [edi],al
  2074. slpft_transparent:
  2075. inc edi
  2076. dec [StashECX]
  2077. jnz slpft_loop
  2078. epilogue
  2079. next_line
  2080. ;*****************************************************************************
  2081. ; Draw a single line with predator, ghosting and fading
  2082. ;
  2083. ; 11/29/95 10:21AM - ST
  2084. ;
  2085. ;align 32
  2086. Single_Line_Predator_Ghost_Fading:
  2087. prologue
  2088. mov [StashECX],ecx
  2089. slpgf_loop: mov al,[esi]
  2090. mov ebx,[BFPartialCount]
  2091. inc esi
  2092. add ebx,[BFPartialPred]
  2093. test bh , bh
  2094. jnz slpgf_get_pred ; is this a predator pixel?
  2095. mov [BFPartialCount],ebx
  2096. jmp slpgf_check_ghost
  2097. slpgf_get_pred:
  2098. xor bh,bh
  2099. mov eax,[BFPredOffset]
  2100. mov [BFPartialCount],ebx
  2101. add byte ptr [BFPredOffset],2
  2102. mov eax,dword ptr [BFPredTable+eax]
  2103. and byte ptr [BFPredOffset],PRED_MASK
  2104. and eax,0ffffh
  2105. mov al,[edi+eax]
  2106. slpgf_check_ghost:
  2107. and eax,255
  2108. mov ebx,[IsTranslucent]
  2109. mov bh,[ebx+eax]
  2110. cmp bh,0ffh
  2111. je slpgf_do_fading
  2112. and ebx , 0FF00h
  2113. mov al,[edi]
  2114. add ebx,[Translucent]
  2115. mov al,[ebx+eax]
  2116. slpgf_do_fading:
  2117. xor eax,eax
  2118. mov ebx,[FadingTable]
  2119. mov ecx,[FadingNum]
  2120. slpgf_fade_loop:
  2121. mov al,[ebx+eax]
  2122. dec ecx
  2123. jnz slpgf_fade_loop
  2124. slpgf_store_pixel:
  2125. mov [edi],al
  2126. inc edi
  2127. dec [StashECX]
  2128. jnz slpgf_loop
  2129. epilogue
  2130. next_line
  2131. ;*****************************************************************************
  2132. ; Draw a single line with transparent pixels, predator, ghosting and fading
  2133. ;
  2134. ; 11/29/95 10:21AM - ST
  2135. ;
  2136. ;align 32
  2137. Single_Line_Predator_Ghost_Fading_Trans:
  2138. prologue
  2139. mov [StashECX],ecx
  2140. slpgft_loop: mov al,[esi]
  2141. inc esi
  2142. test al,al
  2143. jz slpgft_transparent
  2144. mov ebx,[BFPartialCount]
  2145. add ebx,[BFPartialPred]
  2146. test bh , bh
  2147. jnz slpgft_get_pred ; is this a predator pixel?
  2148. mov [BFPartialCount],ebx
  2149. jmp slpgft_check_ghost
  2150. slpgft_get_pred:
  2151. xor bh,bh
  2152. mov eax,[BFPredOffset]
  2153. mov [BFPartialCount],ebx
  2154. add byte ptr [BFPredOffset],2
  2155. mov eax,dword ptr [BFPredTable+eax]
  2156. and byte ptr [BFPredOffset],PRED_MASK
  2157. and eax,0ffffh
  2158. mov al,[edi+eax]
  2159. slpgft_check_ghost:
  2160. and eax,255
  2161. mov ebx,[IsTranslucent]
  2162. mov bh,[ebx+eax]
  2163. cmp bh,0ffh
  2164. je slpgft_do_fading
  2165. and ebx , 0FF00h
  2166. mov al,[edi]
  2167. add ebx,[Translucent]
  2168. mov al,[ebx+eax]
  2169. slpgft_do_fading:
  2170. xor eax,eax
  2171. mov ebx,[FadingTable]
  2172. mov ecx,[FadingNum]
  2173. slpgft_fade_loop:
  2174. mov al,[ebx+eax]
  2175. dec ecx
  2176. jnz slpgft_fade_loop
  2177. slpgft_store_pixel:
  2178. mov [edi],al
  2179. slpgft_transparent:
  2180. inc edi
  2181. dec [StashECX]
  2182. jnz slpgft_loop
  2183. epilogue
  2184. next_line
  2185. ; ends ;end of strict alignment segment
  2186. ; codeseg
  2187. ;extern BF_Trans:near
  2188. BF_Trans:
  2189. prologue
  2190. ; calc the code location to skip to 10 bytes per REPT below!!!!
  2191. mov ecx , eax
  2192. and ecx , 01fh
  2193. lea ecx , [ ecx + ecx * 4 ] ; quick multiply by 5
  2194. neg ecx
  2195. shr eax , 5
  2196. lea ecx , [ trans_reference + ecx * 2 ] ; next multiply by 2
  2197. mov [ loop_cnt ] , eax
  2198. mov [ jmp_loc ] , ecx
  2199. trans_loop:
  2200. mov ecx , [ loop_cnt ]
  2201. jmp [ jmp_loc ]
  2202. ; the following code should NOT be changed without changing the calculation
  2203. ; above!!!!!!
  2204. trans_line:
  2205. REPT 32
  2206. local trans_pixel
  2207. mov bl , [ esi ]
  2208. inc esi
  2209. test bl , bl
  2210. jz trans_pixel
  2211. mov [ edi ] , bl
  2212. trans_pixel:
  2213. inc edi
  2214. ENDM
  2215. trans_reference:
  2216. dec ecx
  2217. jge trans_line
  2218. add esi , [ scr_adjust_width ]
  2219. add edi , [ dest_adjust_width ]
  2220. dec edx
  2221. jnz trans_loop
  2222. epilogue
  2223. ret
  2224. ;********************************************************************
  2225. ;********************************************************************
  2226. ;extern BF_Ghost:near
  2227. BF_Ghost:
  2228. prologue
  2229. mov ebx , eax ; width
  2230. ; NOTE: the below calculation assumes a group of instructions is
  2231. ; less than 256 bytes
  2232. ; get length of the 32 groups of instructions
  2233. lea ecx, [offset ghost_reference]
  2234. sub ecx, [offset ghost_line]
  2235. shr ebx , 5 ; width / 32
  2236. shr ecx , 5 ; length of instructions / 32
  2237. and eax , 01fh ; mod of width / 32
  2238. mul cl ; calc offset to start of group
  2239. neg eax ; inverse of width
  2240. mov [ loop_cnt ] , ebx ; save width / 32
  2241. lea ecx , [ ghost_reference + eax ]
  2242. mov eax , 0
  2243. mov [ jmp_loc ] , ecx
  2244. ghost_loop:
  2245. mov ecx , [ loop_cnt ]
  2246. jmp [ jmp_loc ]
  2247. ghost_line:
  2248. REPT 32
  2249. local store_pixel
  2250. mov al , [ esi ]
  2251. inc esi
  2252. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  2253. mov bh , BYTE PTR [ ebx + eax ]
  2254. cmp bh , 0ffh
  2255. je store_pixel
  2256. and ebx , 0FF00h ; clear all of ebx except bh
  2257. ; we have the index to the translation table
  2258. ; ((trans_colour * 256) + dest colour)
  2259. mov al , [ edi ] ; mov pixel at destination to al
  2260. add ebx , [ Translucent ] ; get the ptr to it!
  2261. ; Add the (trans_color * 256) of the translation equ.
  2262. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  2263. store_pixel:
  2264. mov [ edi ] , al
  2265. inc edi
  2266. ENDM
  2267. ghost_reference:
  2268. dec ecx
  2269. jge ghost_line
  2270. add esi , [ scr_adjust_width ]
  2271. add edi , [ dest_adjust_width ]
  2272. dec edx
  2273. jnz ghost_loop
  2274. epilogue
  2275. ret
  2276. ;********************************************************************
  2277. ;********************************************************************
  2278. ;extern BF_Ghost_Trans:near
  2279. BF_Ghost_Trans:
  2280. prologue
  2281. mov ebx , eax ; width
  2282. ; NOTE: the below calculation assumes a group of instructions is
  2283. ; less than 256 bytes
  2284. ; get length of the 32 groups of instructions
  2285. lea ecx , [ offset ghost_t_reference ]
  2286. sub ecx, [ offset ghost_t_line ]
  2287. shr ebx , 5 ; width / 32
  2288. shr ecx , 5 ; length of instructions / 32
  2289. and eax , 01fh ; mod of width / 32
  2290. mul cl ; calc offset to start of group
  2291. neg eax ; inverse of width
  2292. mov [ loop_cnt ] , ebx ; save width / 32
  2293. lea ecx , [ ghost_t_reference + eax ]
  2294. mov eax , 0
  2295. mov [ jmp_loc ] , ecx
  2296. ghost_t_loop:
  2297. mov ecx , [ loop_cnt ]
  2298. jmp [ jmp_loc ]
  2299. ghost_t_line:
  2300. REPT 32
  2301. local transp_pixel
  2302. local store_pixel
  2303. mov al , [ esi ]
  2304. inc esi
  2305. test al , al
  2306. jz transp_pixel
  2307. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  2308. mov bh , BYTE PTR [ ebx + eax ]
  2309. cmp bh , 0ffh
  2310. je store_pixel
  2311. and ebx , 0FF00h ; clear all of ebx except bh
  2312. ; we have the index to the translation table
  2313. ; ((trans_colour * 256) + dest colour)
  2314. mov al , [ edi ] ; mov pixel at destination to al
  2315. add ebx , [ Translucent ] ; get the ptr to it!
  2316. ; Add the (trans_color * 256) of the translation equ.
  2317. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  2318. store_pixel:
  2319. mov [ edi ] , al
  2320. transp_pixel:
  2321. inc edi
  2322. ENDM
  2323. ghost_t_reference:
  2324. dec ecx
  2325. jge ghost_t_line
  2326. add esi , [ scr_adjust_width ]
  2327. add edi , [ dest_adjust_width ]
  2328. dec edx
  2329. jnz ghost_t_loop
  2330. epilogue
  2331. ret
  2332. ;********************************************************************
  2333. ;********************************************************************
  2334. ;extern BF_Fading:near
  2335. BF_Fading:
  2336. prologue
  2337. mov ebx , eax ; width
  2338. ; NOTE: the below calculation assumes a group of instructions is
  2339. ; less than 256 bytes
  2340. ; get length of the 32 groups of instructions
  2341. lea ecx , [ offset fading_reference ]
  2342. sub ecx, [ offset fading_line ]
  2343. shr ebx , 5 ; width / 32
  2344. shr ecx , 5 ; length of instructions / 32
  2345. and eax , 01fh ; mod of width / 32
  2346. mul cl ; calc offset to start of group
  2347. neg eax ; inverse of width
  2348. mov [ loop_cnt ] , ebx ; save width / 32
  2349. lea ecx , [ fading_reference + eax ]
  2350. mov eax , 0
  2351. mov [ jmp_loc ] , ecx
  2352. fading_loop:
  2353. mov ecx , [ loop_cnt ]
  2354. mov [ StashECX ] , ecx ; preserve ecx for later
  2355. mov ebx , [ FadingTable ] ; run color through fading table
  2356. jmp [ jmp_loc ]
  2357. fading_line_begin:
  2358. mov [ StashECX ] , ecx ; preserve ecx for later
  2359. fading_line:
  2360. REPT 32
  2361. local fade_loop
  2362. mov al , [ esi ]
  2363. inc esi
  2364. mov ecx , [ FadingNum ]
  2365. fade_loop:
  2366. mov al, byte ptr [ebx + eax]
  2367. dec ecx
  2368. jnz fade_loop
  2369. mov [ edi ] , al
  2370. inc edi
  2371. ENDM
  2372. fading_reference:
  2373. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2374. dec ecx
  2375. jge fading_line_begin
  2376. add esi , [ scr_adjust_width ]
  2377. add edi , [ dest_adjust_width ]
  2378. dec edx
  2379. jnz fading_loop
  2380. epilogue
  2381. ret
  2382. ;********************************************************************
  2383. ;********************************************************************
  2384. ;extern BF_Fading_Trans:near
  2385. BF_Fading_Trans:
  2386. prologue
  2387. mov ebx , eax ; width
  2388. ; NOTE: the below calculation assumes a group of instructions is
  2389. ; less than 256 bytes
  2390. ; get length of the 32 groups of instructions
  2391. lea ecx , [ offset fading_t_reference ]
  2392. sub ecx, [ offset fading_t_line ]
  2393. shr ebx , 5 ; width / 32
  2394. shr ecx , 5 ; length of instructions / 32
  2395. and eax , 01fh ; mod of width / 32
  2396. mul cl ; calc offset to start of group
  2397. neg eax ; inverse of width
  2398. mov [ loop_cnt ] , ebx ; save width / 32
  2399. lea ecx , [ fading_t_reference + eax ]
  2400. mov eax , 0
  2401. mov [ jmp_loc ] , ecx
  2402. fading_t_loop:
  2403. mov ecx , [ loop_cnt ]
  2404. mov [ StashECX ] , ecx ; preserve ecx for later
  2405. mov ebx , [ FadingTable ] ; run color through fading table
  2406. jmp [ jmp_loc ]
  2407. fading_t_line_begin:
  2408. mov [ StashECX ] , ecx ; preserve ecx for later
  2409. fading_t_line:
  2410. REPT 32
  2411. local transp_pixel
  2412. local fade_loop
  2413. mov al , [ esi ]
  2414. inc esi
  2415. test al , al
  2416. jz transp_pixel
  2417. mov ecx , [ FadingNum ]
  2418. fade_loop:
  2419. mov al, byte ptr [ebx + eax]
  2420. dec ecx
  2421. jnz fade_loop
  2422. mov [ edi ] , al
  2423. transp_pixel:
  2424. inc edi
  2425. ENDM
  2426. fading_t_reference:
  2427. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2428. dec ecx
  2429. jge fading_t_line_begin
  2430. add esi , [ scr_adjust_width ]
  2431. add edi , [ dest_adjust_width ]
  2432. dec edx
  2433. jnz fading_t_loop
  2434. epilogue
  2435. ret
  2436. ;********************************************************************
  2437. ;********************************************************************
  2438. ;extern BF_Ghost_Fading:near
  2439. BF_Ghost_Fading:
  2440. prologue
  2441. mov ebx , eax ; width
  2442. ; NOTE: the below calculation assumes a group of instructions is
  2443. ; less than 256 bytes
  2444. ; get length of the 32 groups of instructions
  2445. lea ecx , [ offset ghost_f_reference ]
  2446. sub ecx, [ offset ghost_f_line ]
  2447. shr ebx , 5 ; width / 32
  2448. shr ecx , 5 ; length of instructions / 32
  2449. and eax , 01fh ; mod of width / 32
  2450. mul cl ; calc offset to start of group
  2451. neg eax ; inverse of width
  2452. mov [ loop_cnt ] , ebx ; save width / 32
  2453. lea ecx , [ ghost_f_reference + eax ]
  2454. mov eax , 0
  2455. mov [ jmp_loc ] , ecx
  2456. ghost_f_loop:
  2457. mov ecx , [ loop_cnt ]
  2458. mov [ StashECX ] , ecx ; preserve ecx for later
  2459. jmp [ jmp_loc ]
  2460. ghost_f_line_begin:
  2461. mov [ StashECX ] , ecx ; preserve ecx for later
  2462. ghost_f_line:
  2463. REPT 32
  2464. local store_pixel
  2465. local do_fading
  2466. local fade_loop
  2467. mov al , [ esi ]
  2468. inc esi
  2469. mov ebx , [ IsTranslucent ] ; is it a lucent color?
  2470. mov bh , byte ptr [ ebx + eax ]
  2471. cmp bh , 0ffh
  2472. je do_fading
  2473. and ebx , 0FF00h ; clear all of ebx except bh
  2474. ; we have the index to the lation table
  2475. ; ((_colour * 256) + dest colour)
  2476. mov al , [ edi ] ; mov pixel at destination to al
  2477. add ebx , [ Translucent ] ; get the ptr to it!
  2478. ; Add the (_color * 256) of the lation equ.
  2479. mov al , byte ptr [ ebx + eax ] ; get new pixel in al
  2480. ; DRD jmp store_pixel
  2481. do_fading:
  2482. mov ebx , [ FadingTable ] ; run color through fading table
  2483. mov ecx , [ FadingNum ]
  2484. fade_loop:
  2485. mov al, byte ptr [ebx + eax]
  2486. dec ecx
  2487. jnz fade_loop
  2488. store_pixel:
  2489. mov [ edi ] , al
  2490. inc edi
  2491. ENDM
  2492. ghost_f_reference:
  2493. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2494. dec ecx
  2495. jge ghost_f_line_begin
  2496. add esi , [ scr_adjust_width ]
  2497. add edi , [ dest_adjust_width ]
  2498. dec edx
  2499. jnz ghost_f_loop
  2500. epilogue
  2501. ret
  2502. ;********************************************************************
  2503. ;********************************************************************
  2504. ;extern BF_Ghost_Fading_Trans:near
  2505. BF_Ghost_Fading_Trans:
  2506. prologue
  2507. mov ebx , eax ; width
  2508. ; NOTE: the below calculation assumes a group of instructions is
  2509. ; less than 256 bytes
  2510. ; get length of the 32 groups of instructions
  2511. lea ecx , [ offset ghost_f_t_reference ]
  2512. sub ecx, [ offset ghost_f_t_line ]
  2513. shr ebx , 5 ; width / 32
  2514. shr ecx , 5 ; length of instructions / 32
  2515. and eax , 01fh ; mod of width / 32
  2516. mul cl ; calc offset to start of group
  2517. neg eax ; inverse of width
  2518. mov [ loop_cnt ] , ebx ; save width / 32
  2519. lea ecx , [ ghost_f_t_reference + eax ]
  2520. mov eax , 0
  2521. mov [ jmp_loc ] , ecx
  2522. ghost_f_t_loop:
  2523. mov ecx , [ loop_cnt ]
  2524. mov [ StashECX ] , ecx ; preserve ecx for later
  2525. jmp [ jmp_loc ]
  2526. ghost_f_t_line_begin:
  2527. mov [ StashECX ] , ecx ; preserve ecx for later
  2528. ghost_f_t_line:
  2529. REPT 32
  2530. local transp_pixel
  2531. local store_pixel
  2532. local do_fading
  2533. local fade_loop
  2534. mov al , [ esi ]
  2535. inc esi
  2536. test al , al
  2537. jz transp_pixel
  2538. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  2539. mov bh , byte ptr [ ebx + eax ]
  2540. cmp bh , 0ffh
  2541. je do_fading
  2542. and ebx , 0FF00h ; clear all of ebx except bh
  2543. ; we have the index to the translation table
  2544. ; ((trans_colour * 256) + dest colour)
  2545. mov al , [ edi ] ; mov pixel at destination to al
  2546. add ebx , [ Translucent ] ; get the ptr to it!
  2547. ; Add the (trans_color * 256) of the translation equ.
  2548. mov al , byte ptr [ ebx + eax ] ; get new pixel in al
  2549. ; DRD jmp store_pixel
  2550. do_fading:
  2551. mov ebx , [ FadingTable ] ; run color through fading table
  2552. mov ecx , [ FadingNum ]
  2553. fade_loop:
  2554. mov al, byte ptr [ebx + eax]
  2555. dec ecx
  2556. jnz fade_loop
  2557. store_pixel:
  2558. mov [ edi ] , al
  2559. transp_pixel:
  2560. inc edi
  2561. ENDM
  2562. ghost_f_t_reference:
  2563. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2564. dec ecx
  2565. jge ghost_f_t_line_begin
  2566. add esi , [ scr_adjust_width ]
  2567. add edi , [ dest_adjust_width ]
  2568. dec edx
  2569. jnz ghost_f_t_loop
  2570. epilogue
  2571. ret
  2572. ;********************************************************************
  2573. ;********************************************************************
  2574. ;extern BF_Predator:near
  2575. BF_Predator:
  2576. prologue
  2577. mov ebx , eax ; width
  2578. ; NOTE: the below calculation assumes a group of instructions is
  2579. ; less than 256 bytes
  2580. ; get length of the 32 groups of instructions
  2581. lea ecx , [ offset predator_reference ]
  2582. sub ecx, [offset predator_line ]
  2583. shr ebx , 5 ; width / 32
  2584. shr ecx , 5 ; length of instructions / 32
  2585. and eax , 01fh ; mod of width / 32
  2586. mul cl ; calc offset to start of group
  2587. neg eax ; inverse of width
  2588. mov [ loop_cnt ] , ebx ; save width / 32
  2589. lea ecx , [ predator_reference + eax ]
  2590. mov eax , 0
  2591. mov [ jmp_loc ] , ecx
  2592. predator_loop:
  2593. mov ecx , [ loop_cnt ]
  2594. jmp [ jmp_loc ]
  2595. predator_line:
  2596. REPT 32
  2597. local get_pred
  2598. local skip_pixel
  2599. mov al , [ esi ]
  2600. inc esi
  2601. mov ebx , [ BFPartialCount ]
  2602. add ebx , [ BFPartialPred ]
  2603. or bh , bh
  2604. jnz get_pred ; is this a predator pixel?
  2605. mov [ BFPartialCount ] , ebx
  2606. jmp skip_pixel
  2607. get_pred:
  2608. xor bh , bh
  2609. mov eax, [ BFPredOffset ]
  2610. mov [ BFPartialCount ] , ebx
  2611. add BYTE PTR [ BFPredOffset ] , 2
  2612. movzx eax , WORD PTR [ BFPredTable + eax ]
  2613. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2614. ; pick up a color offset a pseudo-
  2615. ; random amount from the current
  2616. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2617. ; xor bh , bh
  2618. ; mov eax , [ BFPredValue ] ; pick up a color offset a pseudo-
  2619. ; ; random amount from the current
  2620. ; mov [ BFPartialCount ] , ebx
  2621. ; mov al , [ edi + eax ] ; viewport address
  2622. mov [ edi ] , al
  2623. skip_pixel:
  2624. inc edi
  2625. ENDM
  2626. predator_reference:
  2627. dec ecx
  2628. jge predator_line
  2629. add esi , [ scr_adjust_width ]
  2630. add edi , [ dest_adjust_width ]
  2631. dec edx
  2632. jnz predator_loop
  2633. epilogue
  2634. ret
  2635. ;********************************************************************
  2636. ;********************************************************************
  2637. ;extern BF_Predator_Trans:near
  2638. BF_Predator_Trans:
  2639. prologue
  2640. mov ebx , eax ; width
  2641. ; NOTE: the below calculation assumes a group of instructions is
  2642. ; less than 256 bytes
  2643. ; get length of the 32 groups of instructions
  2644. lea ecx , [ offset predator_t_reference ]
  2645. sub ecx, [ offset predator_t_line ]
  2646. shr ebx , 5 ; width / 32
  2647. shr ecx , 5 ; length of instructions / 32
  2648. and eax , 01fh ; mod of width / 32
  2649. mul cl ; calc offset to start of group
  2650. neg eax ; inverse of width
  2651. mov [ loop_cnt ] , ebx ; save width / 32
  2652. lea ecx , [ predator_t_reference + eax ]
  2653. mov eax , 0
  2654. mov [ jmp_loc ] , ecx
  2655. predator_t_loop:
  2656. mov ecx , [ loop_cnt ]
  2657. jmp [ jmp_loc ]
  2658. predator_t_line:
  2659. REPT 32
  2660. local trans_pixel
  2661. local get_pred
  2662. local store_pixel
  2663. mov al , [ esi ]
  2664. inc esi
  2665. test al , al
  2666. jz trans_pixel
  2667. mov ebx , [ BFPartialCount ]
  2668. add ebx , [ BFPartialPred ]
  2669. or bh , bh
  2670. jnz get_pred ; is this a predator pixel?
  2671. mov [ BFPartialCount ] , ebx
  2672. jmp store_pixel
  2673. get_pred:
  2674. xor bh , bh
  2675. mov eax, [ BFPredOffset ]
  2676. mov [ BFPartialCount ] , ebx
  2677. add BYTE PTR [ BFPredOffset ] , 2
  2678. movzx eax , WORD PTR [ BFPredTable + eax ]
  2679. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2680. ; pick up a color offset a pseudo-
  2681. ; random amount from the current
  2682. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2683. store_pixel:
  2684. mov [ edi ] , al
  2685. trans_pixel:
  2686. inc edi
  2687. ENDM
  2688. predator_t_reference:
  2689. dec ecx
  2690. jge predator_t_line
  2691. add esi , [ scr_adjust_width ]
  2692. add edi , [ dest_adjust_width ]
  2693. dec edx
  2694. jnz predator_t_loop
  2695. epilogue
  2696. ret
  2697. ;********************************************************************
  2698. ;********************************************************************
  2699. ;extern BF_Predator_Ghost:near
  2700. BF_Predator_Ghost:
  2701. prologue
  2702. mov ebx , eax ; width
  2703. ; NOTE: the below calculation assumes a group of instructions is
  2704. ; less than 256 bytes
  2705. ; get length of the 32 groups of instructions
  2706. lea ecx , [ offset predator_g_reference ]
  2707. sub ecx, [ offset predator_g_line ]
  2708. shr ebx , 5 ; width / 32
  2709. shr ecx , 5 ; length of instructions / 32
  2710. and eax , 01fh ; mod of width / 32
  2711. mul cl ; calc offset to start of group
  2712. neg eax ; inverse of width
  2713. mov [ loop_cnt ] , ebx ; save width / 32
  2714. lea ecx , [ predator_g_reference + eax ]
  2715. mov eax , 0
  2716. mov [ jmp_loc ] , ecx
  2717. predator_g_loop:
  2718. mov ecx , [ loop_cnt ]
  2719. jmp [ jmp_loc ]
  2720. predator_g_line:
  2721. REPT 32
  2722. local get_pred
  2723. local check_ghost
  2724. local store_pixel
  2725. mov al , [ esi ]
  2726. mov ebx , [ BFPartialCount ]
  2727. inc esi
  2728. add ebx , [ BFPartialPred ]
  2729. or bh , bh
  2730. jnz get_pred ; is this a predator pixel?
  2731. mov [ BFPartialCount ] , ebx
  2732. jmp check_ghost
  2733. get_pred:
  2734. xor bh , bh
  2735. mov eax, [ BFPredOffset ]
  2736. mov [ BFPartialCount ] , ebx
  2737. add BYTE PTR [ BFPredOffset ] , 2
  2738. movzx eax , WORD PTR [ BFPredTable + eax ]
  2739. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2740. ; pick up a color offset a pseudo-
  2741. ; random amount from the current
  2742. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2743. check_ghost:
  2744. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  2745. mov bh , BYTE PTR [ ebx + eax ]
  2746. cmp bh , 0ffh
  2747. je store_pixel
  2748. and ebx , 0FF00h ; clear all of ebx except bh
  2749. ; we have the index to the translation table
  2750. ; ((trans_colour * 256) + dest colour)
  2751. mov al , [ edi ] ; mov pixel at destination to al
  2752. add ebx , [ Translucent ] ; get the ptr to it!
  2753. ; Add the (trans_color * 256) of the translation equ.
  2754. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  2755. store_pixel:
  2756. mov [ edi ] , al
  2757. inc edi
  2758. ENDM
  2759. predator_g_reference:
  2760. dec ecx
  2761. jge predator_g_line
  2762. add esi , [ scr_adjust_width ]
  2763. add edi , [ dest_adjust_width ]
  2764. dec edx
  2765. jnz predator_g_loop
  2766. epilogue
  2767. ret
  2768. ;********************************************************************
  2769. ;********************************************************************
  2770. ;extern BF_Predator_Ghost_Trans:near
  2771. BF_Predator_Ghost_Trans:
  2772. prologue
  2773. mov ebx , eax ; width
  2774. ; NOTE: the below calculation assumes a group of instructions is
  2775. ; less than 256 bytes
  2776. ; get length of the 32 groups of instructions
  2777. lea ecx , [ offset predator_g_t_reference ]
  2778. sub ecx, [ offset predator_g_t_line ]
  2779. shr ebx , 5 ; width / 32
  2780. shr ecx , 5 ; length of instructions / 32
  2781. and eax , 01fh ; mod of width / 32
  2782. mul cl ; calc offset to start of group
  2783. neg eax ; inverse of width
  2784. mov [ loop_cnt ] , ebx ; save width / 32
  2785. lea ecx , [ predator_g_t_reference + eax ]
  2786. mov eax , 0
  2787. mov [ jmp_loc ] , ecx
  2788. predator_g_t_loop:
  2789. mov ecx , [ loop_cnt ]
  2790. jmp [ jmp_loc ]
  2791. predator_g_t_line:
  2792. REPT 32
  2793. local trans_pixel
  2794. local get_pred
  2795. local check_ghost
  2796. local store_pixel
  2797. mov al , [ esi ]
  2798. inc esi
  2799. test al , al
  2800. jz trans_pixel
  2801. mov ebx , [ BFPartialCount ]
  2802. add ebx , [ BFPartialPred ]
  2803. or bh , bh
  2804. jnz get_pred ; is this a predator pixel?
  2805. mov [ BFPartialCount ] , ebx
  2806. jmp check_ghost
  2807. get_pred:
  2808. xor bh , bh
  2809. mov eax, [ BFPredOffset ]
  2810. mov [ BFPartialCount ] , ebx
  2811. add BYTE PTR [ BFPredOffset ] , 2
  2812. movzx eax , WORD PTR [ BFPredTable + eax ]
  2813. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2814. ; pick up a color offset a pseudo-
  2815. ; random amount from the current
  2816. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2817. check_ghost:
  2818. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  2819. mov bh , BYTE PTR [ ebx + eax ]
  2820. cmp bh , 0ffh
  2821. je store_pixel
  2822. and ebx , 0FF00h ; clear all of ebx except bh
  2823. ; we have the index to the translation table
  2824. ; ((trans_colour * 256) + dest colour)
  2825. mov al , [ edi ] ; mov pixel at destination to al
  2826. add ebx , [ Translucent ] ; get the ptr to it!
  2827. ; Add the (trans_color * 256) of the translation equ.
  2828. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  2829. store_pixel:
  2830. mov [ edi ] , al
  2831. trans_pixel:
  2832. inc edi
  2833. ENDM
  2834. predator_g_t_reference:
  2835. dec ecx
  2836. jge predator_g_t_line
  2837. add esi , [ scr_adjust_width ]
  2838. add edi , [ dest_adjust_width ]
  2839. dec edx
  2840. jnz predator_g_t_loop
  2841. epilogue
  2842. ret
  2843. ;********************************************************************
  2844. ;********************************************************************
  2845. ;extern BF_Predator_Fading:near
  2846. BF_Predator_Fading:
  2847. prologue
  2848. mov ebx , eax ; width
  2849. ; NOTE: the below calculation assumes a group of instructions is
  2850. ; less than 256 bytes
  2851. ; get length of the 32 groups of instructions
  2852. lea ecx , [ offset predator_f_reference ]
  2853. sub ecx, [ offset predator_f_line ]
  2854. shr ebx , 5 ; width / 32
  2855. shr ecx , 5 ; length of instructions / 32
  2856. and eax , 01fh ; mod of width / 32
  2857. mul cl ; calc offset to start of group
  2858. neg eax ; inverse of width
  2859. mov [ loop_cnt ] , ebx ; save width / 32
  2860. lea ecx , [ predator_f_reference + eax ]
  2861. mov eax , 0
  2862. mov [ jmp_loc ] , ecx
  2863. predator_f_loop:
  2864. mov ecx , [ loop_cnt ]
  2865. mov [ StashECX ] , ecx ; preserve ecx for later
  2866. jmp [ jmp_loc ]
  2867. predator_f_line_begin:
  2868. mov [ StashECX ] , ecx ; preserve ecx for later
  2869. predator_f_line:
  2870. REPT 32
  2871. local get_pred
  2872. local do_fading
  2873. local fade_loop
  2874. mov al , [ esi ]
  2875. mov ebx , [ BFPartialCount ]
  2876. inc esi
  2877. add ebx , [ BFPartialPred ]
  2878. or bh , bh
  2879. jnz get_pred ; is this a predator pixel?
  2880. mov [ BFPartialCount ] , ebx
  2881. jmp do_fading
  2882. get_pred:
  2883. xor bh , bh
  2884. mov eax, [ BFPredOffset ]
  2885. mov [ BFPartialCount ] , ebx
  2886. add BYTE PTR [ BFPredOffset ] , 2
  2887. movzx eax , WORD PTR [ BFPredTable + eax ]
  2888. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2889. ; pick up a color offset a pseudo-
  2890. ; random amount from the current
  2891. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2892. do_fading:
  2893. mov ebx , [ FadingTable ] ; run color through fading table
  2894. mov ecx , [ FadingNum ]
  2895. fade_loop:
  2896. mov al, byte ptr [ebx + eax]
  2897. dec ecx
  2898. jnz fade_loop
  2899. mov [ edi ] , al
  2900. inc edi
  2901. ENDM
  2902. predator_f_reference:
  2903. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2904. dec ecx
  2905. jge predator_f_line_begin
  2906. add esi , [ scr_adjust_width ]
  2907. add edi , [ dest_adjust_width ]
  2908. dec edx
  2909. jnz predator_f_loop
  2910. epilogue
  2911. ret
  2912. ;********************************************************************
  2913. ;********************************************************************
  2914. ;extern BF_Predator_Fading_Trans:near
  2915. BF_Predator_Fading_Trans:
  2916. prologue
  2917. mov ebx , eax ; width
  2918. ; NOTE: the below calculation assumes a group of instructions is
  2919. ; less than 256 bytes
  2920. ; get length of the 32 groups of instructions
  2921. lea ecx , [ offset predator_f_t_reference ]
  2922. sub ecx, [ offset predator_f_t_line ]
  2923. shr ebx , 5 ; width / 32
  2924. shr ecx , 5 ; length of instructions / 32
  2925. and eax , 01fh ; mod of width / 32
  2926. mul cl ; calc offset to start of group
  2927. neg eax ; inverse of width
  2928. mov [ loop_cnt ] , ebx ; save width / 32
  2929. lea ecx , [ predator_f_t_reference + eax ]
  2930. mov eax , 0
  2931. mov [ jmp_loc ] , ecx
  2932. predator_f_t_loop:
  2933. mov ecx , [ loop_cnt ]
  2934. mov [ StashECX ] , ecx ; preserve ecx for later
  2935. jmp [ jmp_loc ]
  2936. predator_f_t_line_begin:
  2937. mov [ StashECX ] , ecx ; preserve ecx for later
  2938. predator_f_t_line:
  2939. REPT 32
  2940. local trans_pixel
  2941. local get_pred
  2942. local do_fading
  2943. local fade_loop
  2944. mov al , [ esi ]
  2945. inc esi
  2946. test al , al
  2947. jz trans_pixel
  2948. mov ebx , [ BFPartialCount ]
  2949. add ebx , [ BFPartialPred ]
  2950. or bh , bh
  2951. jnz get_pred ; is this a predator pixel?
  2952. mov [ BFPartialCount ] , ebx
  2953. jmp do_fading
  2954. get_pred:
  2955. xor bh , bh
  2956. mov eax, [ BFPredOffset ]
  2957. mov [ BFPartialCount ] , ebx
  2958. add BYTE PTR [ BFPredOffset ] , 2
  2959. movzx eax , WORD PTR [ BFPredTable + eax ]
  2960. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  2961. ; pick up a color offset a pseudo-
  2962. ; random amount from the current
  2963. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  2964. do_fading:
  2965. mov ebx , [ FadingTable ] ; run color through fading table
  2966. mov ecx , [ FadingNum ]
  2967. fade_loop:
  2968. mov al, byte ptr [ebx + eax]
  2969. dec ecx
  2970. jnz fade_loop
  2971. mov [ edi ] , al
  2972. trans_pixel:
  2973. inc edi
  2974. ENDM
  2975. predator_f_t_reference:
  2976. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  2977. dec ecx
  2978. jge predator_f_t_line_begin
  2979. add esi , [ scr_adjust_width ]
  2980. add edi , [ dest_adjust_width ]
  2981. dec edx
  2982. jnz predator_f_t_loop
  2983. epilogue
  2984. ret
  2985. ;********************************************************************
  2986. ;********************************************************************
  2987. ;extern BF_Predator_Ghost_Fading:near
  2988. BF_Predator_Ghost_Fading:
  2989. prologue
  2990. mov ebx , eax ; width
  2991. ; NOTE: the below calculation assumes a group of instructions is
  2992. ; less than 256 bytes
  2993. ; get length of the 32 groups of instructions
  2994. lea ecx , [ offset predator_g_f_reference ]
  2995. sub ecx, [ offset predator_g_f_line ]
  2996. shr ebx , 5 ; width / 32
  2997. shr ecx , 5 ; length of instructions / 32
  2998. and eax , 01fh ; mod of width / 32
  2999. mul cl ; calc offset to start of group
  3000. neg eax ; inverse of width
  3001. mov [ loop_cnt ] , ebx ; save width / 32
  3002. lea ecx , [ predator_g_f_reference + eax ]
  3003. mov eax , 0
  3004. mov [ jmp_loc ] , ecx
  3005. predator_g_f_loop:
  3006. mov ecx , [ loop_cnt ]
  3007. mov [ StashECX ] , ecx ; preserve ecx for later
  3008. jmp [ jmp_loc ]
  3009. predator_g_f_line_begin:
  3010. mov [ StashECX ] , ecx ; preserve ecx for later
  3011. predator_g_f_line:
  3012. REPT 32
  3013. local get_pred
  3014. local check_ghost
  3015. local store_pixel
  3016. local do_fading
  3017. local fade_loop
  3018. mov al , [ esi ]
  3019. mov ebx , [ BFPartialCount ]
  3020. inc esi
  3021. add ebx , [ BFPartialPred ]
  3022. or bh , bh
  3023. jnz get_pred ; is this a predator pixel?
  3024. mov [ BFPartialCount ] , ebx
  3025. jmp check_ghost
  3026. get_pred:
  3027. xor bh , bh
  3028. mov eax, [ BFPredOffset ]
  3029. mov [ BFPartialCount ] , ebx
  3030. add BYTE PTR [ BFPredOffset ] , 2
  3031. movzx eax , WORD PTR [ BFPredTable + eax ]
  3032. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  3033. ; pick up a color offset a pseudo-
  3034. ; random amount from the current
  3035. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  3036. check_ghost:
  3037. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  3038. mov bh , BYTE PTR [ ebx + eax ]
  3039. cmp bh , 0ffh
  3040. je do_fading
  3041. and ebx , 0FF00h ; clear all of ebx except bh
  3042. ; we have the index to the translation table
  3043. ; ((trans_colour * 256) + dest colour)
  3044. mov al , [ edi ] ; mov pixel at destination to al
  3045. add ebx , [ Translucent ] ; get the ptr to it!
  3046. ; Add the (trans_color * 256) of the translation equ.
  3047. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  3048. ; DRD jmp store_pixel
  3049. do_fading:
  3050. mov ebx , [ FadingTable ] ; run color through fading table
  3051. mov ecx , [ FadingNum ]
  3052. fade_loop:
  3053. mov al, byte ptr [ebx + eax]
  3054. dec ecx
  3055. jnz fade_loop
  3056. store_pixel:
  3057. mov [ edi ] , al
  3058. inc edi
  3059. ENDM
  3060. predator_g_f_reference:
  3061. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  3062. dec ecx
  3063. jge predator_g_f_line_begin
  3064. add esi , [ scr_adjust_width ]
  3065. add edi , [ dest_adjust_width ]
  3066. dec edx
  3067. jnz predator_g_f_loop
  3068. epilogue
  3069. ret
  3070. ;********************************************************************
  3071. ;********************************************************************
  3072. ;extern BF_Predator_Ghost_Fading_Trans:near
  3073. BF_Predator_Ghost_Fading_Trans:
  3074. prologue
  3075. mov ebx , eax ; width
  3076. ; NOTE: the below calculation assumes a group of instructions is
  3077. ; less than 256 bytes
  3078. ; get length of the 32 groups of instructions
  3079. lea ecx , [ offset predator_g_f_t_reference ]
  3080. sub ecx, [ offset predator_g_f_t_line ]
  3081. shr ebx , 5 ; width / 32
  3082. shr ecx , 5 ; length of instructions / 32
  3083. and eax , 01fh ; mod of width / 32
  3084. mul cl ; calc offset to start of group
  3085. neg eax ; inverse of width
  3086. mov [ loop_cnt ] , ebx ; save width / 32
  3087. lea ecx , [ predator_g_f_t_reference + eax ]
  3088. mov eax , 0
  3089. mov [ jmp_loc ] , ecx
  3090. predator_g_f_t_loop:
  3091. mov ecx , [ loop_cnt ]
  3092. mov [ StashECX ] , ecx ; preserve ecx for later
  3093. jmp [ jmp_loc ]
  3094. predator_g_f_t_line_begin:
  3095. mov [ StashECX ] , ecx ; preserve ecx for later
  3096. predator_g_f_t_line:
  3097. REPT 32
  3098. local trans_pixel
  3099. local get_pred
  3100. local check_ghost
  3101. local store_pixel
  3102. local do_fading
  3103. local fade_loop
  3104. mov al , [ esi ]
  3105. inc esi
  3106. test al , al
  3107. jz trans_pixel
  3108. mov ebx , [ BFPartialCount ]
  3109. add ebx , [ BFPartialPred ]
  3110. or bh , bh
  3111. jnz get_pred ; is this a predator pixel?
  3112. mov [ BFPartialCount ] , ebx
  3113. jmp check_ghost
  3114. get_pred:
  3115. xor bh , bh
  3116. mov eax, [ BFPredOffset ]
  3117. mov [ BFPartialCount ] , ebx
  3118. add BYTE PTR [ BFPredOffset ] , 2
  3119. movzx eax , WORD PTR [ BFPredTable + eax ]
  3120. and BYTE PTR [ BFPredOffset ] , PRED_MASK
  3121. ; pick up a color offset a pseudo-
  3122. ; random amount from the current
  3123. movzx eax , BYTE PTR [ edi + eax ] ; viewport address
  3124. check_ghost:
  3125. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  3126. mov bh , BYTE PTR [ ebx + eax ]
  3127. cmp bh , 0ffh
  3128. je do_fading
  3129. and ebx , 0FF00h ; clear all of ebx except bh
  3130. ; we have the index to the translation table
  3131. ; ((trans_colour * 256) + dest colour)
  3132. mov al , [ edi ] ; mov pixel at destination to al
  3133. add ebx , [ Translucent ] ; get the ptr to it!
  3134. ; Add the (trans_color * 256) of the translation equ.
  3135. mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al
  3136. ; DRD jmp store_pixel
  3137. do_fading:
  3138. mov ebx , [ FadingTable ] ; run color through fading table
  3139. mov ecx , [ FadingNum ]
  3140. fade_loop:
  3141. mov al, byte ptr [ebx + eax]
  3142. dec ecx
  3143. jnz fade_loop
  3144. store_pixel:
  3145. mov [ edi ] , al
  3146. trans_pixel:
  3147. inc edi
  3148. ENDM
  3149. predator_g_f_t_reference:
  3150. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  3151. dec ecx
  3152. jge predator_g_f_t_line_begin
  3153. add esi , [ scr_adjust_width ]
  3154. add edi , [ dest_adjust_width ]
  3155. dec edx
  3156. jnz predator_g_f_t_loop
  3157. epilogue
  3158. ret
  3159. ;********************************************************************
  3160. ;********************************************************************
  3161. Not_Supported:
  3162. ret
  3163. Buffer_Frame_To_Page ENDP
  3164. end
  3165. externdef C CPUType:byte
  3166. ;*********************************************************************************************
  3167. ;* Detect_MMX_Availability -- Detect the presence of MMX technology. *
  3168. ;* *
  3169. ;* *
  3170. ;* INPUT: Nothing *
  3171. ;* *
  3172. ;* OUTPUT: True if MMX technology is available. *
  3173. ;* *
  3174. ;* Warnings: *
  3175. ;* *
  3176. ;* Note: Based in part on CPUID32.ASM by Intel *
  3177. ;* *
  3178. ;* HISTORY: *
  3179. ;* 05/19/96 ST : Created. *
  3180. ;*===========================================================================================*
  3181. Detect_MMX_Availability proc C
  3182. local idflag:byte
  3183. local local_cputype:byte
  3184. ;assume processor is at least 386
  3185. ;
  3186. ;check whether AC bit in eflags can be toggled.
  3187. ;If not then processor is 386
  3188. mov [idflag],0
  3189. pushfd ;get Eflags in EAX
  3190. pop eax
  3191. mov ecx,eax ;save eflags
  3192. xor eax,40000h ;toggle AC bit in eflags
  3193. push eax ;new eflags on stack
  3194. popfd ;move new value into eflags
  3195. pushfd ;get new eflags back into eax
  3196. pop eax
  3197. xor eax,ecx ;if AC bit not toggled then CPU=386
  3198. mov [local_cputype],3
  3199. jz @@end_get_cpu ;cpu is 386
  3200. push ecx
  3201. popfd ;restore AC bit in eflags
  3202. ;processor is at least 486
  3203. ;
  3204. ;Check for ability to set/clear ID flag in EFLAGS
  3205. ;ID flag indicates ability of processor to execute the CPUID instruction.
  3206. ;486 not guaranteed to have CPUID inst?
  3207. ;
  3208. mov [local_cputype],4
  3209. mov eax,ecx ;original EFLAGS
  3210. xor eax,200000h ;toggle ID bit
  3211. push eax
  3212. popfd
  3213. pushfd
  3214. pop eax
  3215. xor eax,ecx ;check if still toggled
  3216. jz @@end_get_cpu
  3217. ; Execute CPUID instruction to determine vendor, family,
  3218. ; model and stepping.
  3219. ;
  3220. mov [idflag],1 ;flag ID is available
  3221. xor eax,eax
  3222. cpuid
  3223. mov dword ptr [VendorID],ebx
  3224. mov dword ptr [VendorID+4],edx
  3225. mov dword ptr [VendorID+8],ecx
  3226. mov dword ptr [VendorID+12]," "
  3227. cmp eax,1 ;check if 1 is valid
  3228. jl @@end_get_cpu ;inp for cpuid inst.
  3229. xor eax,eax
  3230. inc eax
  3231. cpuid ;get stepping, model and family
  3232. and ax,0f00H
  3233. shr ax,08H
  3234. mov [local_cputype],al
  3235. @@end_get_cpu: mov al,[local_cputype]
  3236. mov [CPUType],al
  3237. ;
  3238. ; We have the CPU type in al now.
  3239. ; If we arent on at least a pentium then we can assume there is no MMX
  3240. ;
  3241. cmp al,5
  3242. jl @@no_mmx
  3243. mov eax,1
  3244. cpuid
  3245. test edx,00800000h
  3246. jz @@no_mmx
  3247. ;
  3248. ; MMX detected - return true
  3249. ;
  3250. mov eax,1
  3251. ret
  3252. @@no_mmx: xor eax,eax
  3253. ret
  3254. Detect_MMX_Availability endp
  3255. ;*********************************************************************************************
  3256. ;* Init_MMX -- Do any special inits required for MMX support *
  3257. ;* *
  3258. ;* *
  3259. ;* INPUT: Nothing *
  3260. ;* *
  3261. ;* OUTPUT: None *
  3262. ;* *
  3263. ;* Warnings: *
  3264. ;* *
  3265. ;* HISTORY: *
  3266. ;* 05/19/96 ST : Created. *
  3267. ;*===========================================================================================*
  3268. Init_MMX proc C
  3269. mov edi,offset NewShapeJumpTable
  3270. mov ecx,offset EndNewShapeJumpTable
  3271. sub ecx,edi
  3272. shr ecx,2
  3273. mov eax,offset Single_Line_Trans
  3274. mov ebx,offset MMX_Single_Line_Trans
  3275. cld
  3276. @@patch_loop: repnz scasd
  3277. jnz @@done
  3278. mov [edi-4],ebx
  3279. test ecx,ecx
  3280. jnz @@patch_loop
  3281. @@done: ret
  3282. Init_MMX endp
  3283. ;*********************************************************************************************
  3284. ;* MMX_Done -- Restores floating point capability after MMX usage *
  3285. ;* *
  3286. ;* *
  3287. ;* INPUT: Nothing *
  3288. ;* *
  3289. ;* OUTPUT: None *
  3290. ;* *
  3291. ;* Warnings: *
  3292. ;* *
  3293. ;* HISTORY: *
  3294. ;* 05/19/96 ST : Created. *
  3295. ;*===========================================================================================*
  3296. MMX_Done proc C
  3297. emms
  3298. ret
  3299. MMX_Done endp
  3300. code segment page public use32 'code' ; Need stricter segment alignment
  3301. ; for pentium optimisations
  3302. ;*********************************************************************************************
  3303. ;* MMX_Single_Line_Trans -- draw a single line of transparent pixels using MMX technology *
  3304. ;* *
  3305. ;* *
  3306. ;* INPUT: Esi - ptr to source data *
  3307. ;* Edi - ptr to destination data *
  3308. ;* Ecx - width to draw in bytes *
  3309. ;* *
  3310. ;* OUTPUT: None *
  3311. ;* *
  3312. ;* Warnings: *
  3313. ;* *
  3314. ;* HISTORY: *
  3315. ;* 05/19/96 ST : Created. *
  3316. ;*===========================================================================================*
  3317. align 16
  3318. MMX_Single_Line_Trans proc near
  3319. ;
  3320. ; If we are doing less than 8 bytes then dont use MMX
  3321. ;
  3322. cmp ecx,8
  3323. jge @@mmx_loop
  3324. push offset Single_Line_Trans_Entry
  3325. ret
  3326. ;
  3327. ; Use MMX instructions to mask 8 bytes at once
  3328. ;
  3329. ; Creates a bitmask based on the source bytes equality with zero and then uses this to mask
  3330. ; out the source bytes in the destination data. The advatage that MMX gives us is that there is
  3331. ; no 'test for zero then jump' required to mask.
  3332. ;
  3333. align 64 ;MMX instructions like 64 byte alignment!
  3334. @@mmx_loop:
  3335. movq mm0,[esi] ; move 8 bytes of source into mm0
  3336. pxor mm1,mm1 ; zero out mm1
  3337. pcmpeqb mm1,mm0 ; compare mm0 with 0. Bits get set in mm1
  3338. lea esi,[esi+8] ; adjust the source data pointer
  3339. pand mm1,[edi] ; and in the destination data to throw away the bytes which arent zero in the source
  3340. sub ecx,8 ; adjust the byte counter
  3341. por mm1,mm0 ; or in the source with the destination data
  3342. movq [edi],mm1 ; write back the destination data
  3343. lea edi,[edi+8] ; adjust the destination pointer
  3344. cmp ecx,8
  3345. jg @@mmx_loop
  3346. ;
  3347. ; Jump to the approprite code for drawing the end of this line or going to the next one
  3348. ;
  3349. push offset Next_Line
  3350. jcxz @@next_line
  3351. push offset Single_Line_Trans_Entry
  3352. @@next_line: ret
  3353. MMX_Single_Line_Trans endp
  3354. code ends
  3355. .data
  3356. CPUType db 0
  3357. VendorID db "Not available",0,0,0,0,0,0
  3358. END
  3359. ;***************************************************************************
  3360. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  3361. ;***************************************************************************
  3362. ;* *
  3363. ;* Project Name : Westwood Library *
  3364. ;* *
  3365. ;* File Name : KEYFBUFF.ASM *
  3366. ;* *
  3367. ;* Programmer : Phil W. Gorrow *
  3368. ;* *
  3369. ;* Start Date : July 16, 1992 *
  3370. ;* *
  3371. ;* Last Update : October 2, 1994 [JLB] *
  3372. ;* *
  3373. ;*-------------------------------------------------------------------------*
  3374. ;* Functions: *
  3375. ;* BUFFER_FRAME_TO_LOGICPAGE -- *
  3376. ;* Normal_Draw -- Function that writes a normal pixel line *
  3377. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  3378. ; IDEAL
  3379. ; P386
  3380. ;IDEAL_MODE EQU 1
  3381. ; INCLUDE "wwlib.i"
  3382. ;-------------------------------------------------------------------
  3383. ; Extern all the library variables that this module requires
  3384. ;-------------------------------------------------------------------
  3385. EXTRN C MaskPage:WORD
  3386. EXTRN C BackGroundPage:WORD
  3387. ;-------------------------------------------------------------------
  3388. ; Define all the equates that this module requires
  3389. ;-------------------------------------------------------------------
  3390. WIN_X EQU 0 ; offset for the x coordinate
  3391. WIN_Y EQU 2 ; offset for the y coordinate
  3392. WIN_WIDTH EQU 4 ; offset for the window width
  3393. WIN_HEIGHT EQU 6 ; offset for the window height
  3394. BYTESPERROW EQU 320 ; number of bytes per row
  3395. FLAG_NORMAL EQU 0 ; flag for normal draw
  3396. FLAG_GHOST EQU 1 ; This flag enables the ghost
  3397. FLAG_PRIORITY_TRANS EQU 2 ; flag for priority and transparent
  3398. FLAG_TRANS EQU 4 ; flag for transparent draw
  3399. FLAG_PRIORITY EQU 8 ; flag for priority draw
  3400. ; fx on the above flags
  3401. FLAG_MASK EQU 15 ; used to and of uneeded bits
  3402. SHAPE_NORMAL EQU 0000h ; Standard shape.
  3403. ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally.
  3404. ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically.
  3405. ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y)
  3406. SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute.
  3407. SHAPE_CENTER EQU 0020h ; Coordinates are based on shape's center point.
  3408. SHAPE_TRANS EQU 0040h ; has transparency
  3409. ;SHAPE_FADING EQU 0100h ; Fading effect active (VOID * fading_table, WORD fading_num).
  3410. ;SHAPE_PREDATOR EQU 0200h ; Transparent warping effect.
  3411. ;SHAPE_COMPACT EQU 0400h ; Never use this bit.
  3412. SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing.
  3413. SHAPE_GHOST EQU 1000h ; Transluscent table process.
  3414. ;SHAPE_SHADOW EQU 2000h ;
  3415. ;SHAPE_PARTIAL EQU 4000h ;
  3416. ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors (VOID * color_table).
  3417. ; MBL MOD 12.1.92
  3418. CLEAR_NON_WALK_BIT_AND_SCALE_BITS EQU 7 ; Makes it one AND per pixel in Priority_Trans display
  3419. CLEAR_NON_WALK_BIT EQU 7fh ; and with 0111-1111 to clear non-walkable high bit
  3420. CLEAR_SCALE_BITS EQU 87h ; and with 1000-0111 to clear scaling id bits
  3421. NON_WALKABLE_BIT EQU 80h ; and with 1000-0000 to clear all but non-walkable bit
  3422. ; END MBL MOD
  3423. CODESEG
  3424. ; 1 = GHOST (all odd entrys are prefixed with Ghost_)
  3425. ; 2 = BLAAAH
  3426. ; 4 = Trans (prfx)
  3427. ; 8 = Prior (prfx)
  3428. ;---------------------------------------------------------------------------
  3429. ; Define the table of different line draw types
  3430. ;---------------------------------------------------------------------------
  3431. LineTable DW WSA_Normal_Draw ;0
  3432. DW Ghost_Normal_Draw ;1
  3433. DW 0 ;2
  3434. DW 0 ;3
  3435. DW Transparent_Draw ;4
  3436. DW Ghost_Transparent_Draw ;5
  3437. DW 0 ;6
  3438. DW 0 ;7
  3439. DW Priority_Draw ;8
  3440. DW Ghost_Priority_Draw ;9
  3441. DW 0 ;10
  3442. DW 0 ;11
  3443. DW Priority_Transparent_Draw ;12
  3444. DW Ghost_Priority_Transparent_Draw ;13
  3445. DW 0 ;14
  3446. DW 0 ;15
  3447. ;***************************************************************************
  3448. ;* BUFFER_FRAME_TO_LOGICPAGE -- *
  3449. ;* *
  3450. ;* *
  3451. ;* *
  3452. ;* INPUT: *
  3453. ;* *
  3454. ;* OUTPUT: *
  3455. ;* *
  3456. ;* WARNINGS: *
  3457. ;* *
  3458. ;* HISTORY: *
  3459. ;* 07/16/1992 PWG : Created. *
  3460. ;*=========================================================================*
  3461. PUBLIC C Buffer_Frame_To_LogicPage
  3462. PROC C Buffer_Frame_To_LogicPage FAR USES ax bx ecx dx ds esi es edi
  3463. ;-------------------------------------------------------------------
  3464. ; Define the arguements that our program takes.
  3465. ;-------------------------------------------------------------------
  3466. ARG x_pixel:WORD ; x pixel position to draw at
  3467. ARG y_pixel:WORD ; y pixel position to draw at
  3468. ARG pixel_w:WORD ; pixel width of draw region
  3469. ARG pixel_h:WORD ; pixel height of draw region
  3470. ARG win:WORD ; window to clip around
  3471. ARG flags:WORD ; flags that this routine will take
  3472. ARG buffer:DWORD ; pointer to the buffer with data
  3473. ARG args:WORD
  3474. ;-------------------------------------------------------------------
  3475. ; Define the local variables that our program uses
  3476. ;-------------------------------------------------------------------
  3477. LOCAL IsTranslucent:DWORD ; ptr to the is_translucent table
  3478. LOCAL Translucent:DWORD ; ptr to the actual translucent table
  3479. LOCAL win_x1:WORD ; clip window left x pixel position
  3480. LOCAL win_x2:WORD ; clip window right x pixel position
  3481. LOCAL win_y1:WORD ; clip window top y pixel position
  3482. LOCAL win_y2:WORD ; clip window bottom y pixel position
  3483. LOCAL clipleft:WORD ; number of pixels to clip on left
  3484. LOCAL clipright:WORD ; number of pixels to clip on right
  3485. LOCAL nextline:WORD ; offset to the next line
  3486. LOCAL putmiddle:WORD ; routine to call to put the middle
  3487. LOCAL maskpage:WORD ; location of the depth masks
  3488. LOCAL background:WORD ; location of the background data
  3489. LOCAL jflags:WORD ; location of the background data
  3490. LOCAL priority:BYTE ; the priority level of the back
  3491. push fs
  3492. xor ecx,ecx
  3493. ;--------------------------------------------------------------------
  3494. ; Check to see if we have supplied any GHOST tables.
  3495. ;--------------------------------------------------------------------
  3496. push di
  3497. mov di,6
  3498. mov [jflags],0
  3499. ghost:
  3500. test [flags],SHAPE_GHOST ; are we ghosting this shape
  3501. jz short no_ghost ; if not then skip and do more
  3502. or [jflags],FLAG_GHOST
  3503. les ax,dword ptr [buffer + di]
  3504. ; get the "are we really translucent?" table
  3505. mov [WORD PTR IsTranslucent],ax
  3506. mov [WORD PTR IsTranslucent + 2],es
  3507. add ax,0100h ; add to offset for tables
  3508. ; get the "ok we are translucent!!" table
  3509. mov [WORD PTR Translucent],ax
  3510. mov [WORD PTR Translucent + 2],es
  3511. add di,4
  3512. no_ghost:
  3513. pop di
  3514. ;-------------------------------------------------------------------
  3515. ; See if we need to center the frame
  3516. ;-------------------------------------------------------------------
  3517. test [flags],SHAPE_CENTER ; does this need to be centered?
  3518. je short no_centering ; if not the skip over this stuff
  3519. mov ax,[pixel_w]
  3520. mov bx,[pixel_h]
  3521. sar ax,1
  3522. sar bx,1
  3523. sub [x_pixel],ax
  3524. sub [y_pixel],bx
  3525. no_centering:
  3526. mov ax,[flags]
  3527. and ax,SHAPE_PRIORITY+SHAPE_TRANS
  3528. cmp ax,SHAPE_PRIORITY+SHAPE_TRANS
  3529. jne short test_trans
  3530. or [jflags],FLAG_PRIORITY_TRANS
  3531. jmp short priority
  3532. ;-------------------------------------------------------------------
  3533. ; Get the trans information if we need to get it
  3534. ;-------------------------------------------------------------------
  3535. test_trans:
  3536. test [flags],SHAPE_TRANS ; does this draw use transparencies?
  3537. je short test_priority ; if not the skip over this junk
  3538. or [jflags],FLAG_TRANS
  3539. test_priority:
  3540. ;-------------------------------------------------------------------
  3541. ; Get the priority information if we need to get it
  3542. ;-------------------------------------------------------------------
  3543. test [flags],SHAPE_PRIORITY ; does this draw use priorities?
  3544. je short no_priority ; if not the skip over this junk
  3545. or [jflags],FLAG_PRIORITY
  3546. priority:
  3547. mov ax,[BackGroundPage] ; get the background page from ds
  3548. mov [background],ax ; and store it on the stack
  3549. mov ax,[MaskPage] ; get the mask page from ds
  3550. mov [maskpage],ax ; and store it on the stack
  3551. mov ax,[WORD PTR buffer + 4]; get the priority level from args
  3552. mov [priority],al ; and store it in a local
  3553. ;-------------------------------------------------------------------
  3554. ; Get the draw routine that we are going to draw with
  3555. ;-------------------------------------------------------------------
  3556. no_priority:
  3557. ; mov bx,[flags] ; load in the current flags byte
  3558. ; and bx,FLAG_MASK ; prevent lockup on bad value
  3559. mov bx,[jflags] ; load in the jump table flags
  3560. shl bx,1
  3561. mov ax,[WORD PTR LineTable + bx] ; get the offset of the skip table
  3562. mov [putmiddle],ax ; store off the new offset
  3563. ;-------------------------------------------------------------------
  3564. ; Get a pointer to the logic page to where we will draw our buffer
  3565. ;-------------------------------------------------------------------
  3566. push [LogicPage] ; push the current logic page
  3567. call FAR PTR Get_Page ; get the physical page address
  3568. add sp,2 ; pull the parameter from the stack
  3569. mov es,dx ; store the address in the dest
  3570. ;--------------------------------------------------------------------
  3571. ; Point DI to the beginning of the window that we need to look at.
  3572. ; that way we can access all of the info through di.
  3573. ;--------------------------------------------------------------------
  3574. mov si,OFFSET WindowList ; get the offset of the window list
  3575. mov cl,4 ; shift 3 times = multiply by 16
  3576. mov ax,[win] ; get the window number we are using
  3577. shl ax,cl ; each window is 8 words long
  3578. add si,ax ; add that into the offset of window
  3579. ;--------------------------------------------------------------------
  3580. ; Place all the clipping values on the stack so our function will
  3581. ; be truly re-entrant and will not need to shadow these values.
  3582. ;--------------------------------------------------------------------
  3583. mov cl,3 ; to convert x to pixel mult by 8
  3584. mov ax,[si + WIN_X] ; get the left clip position
  3585. shl ax,cl ; convert to a pixel x position
  3586. mov [win_x1],ax ; store the left edge of window
  3587. mov [win_x2],ax
  3588. mov ax,[si + WIN_WIDTH] ; get the width of the window
  3589. shl ax,cl ; convert to a pixel width
  3590. add [win_x2],ax ; add to get the right window edge
  3591. mov ax,[si + WIN_Y] ; get the win y coordinate to clip
  3592. mov [win_y1],ax ; and save it onto the stack
  3593. add ax,[si + WIN_HEIGHT] ; calculate the bottom win y coord
  3594. mov [win_y2],ax ; and save it onto the stack
  3595. test [flags],SHAPE_WIN_REL ; is this window relative?
  3596. je short get_buffer ; if not the skip over
  3597. mov ax,[win_x1] ; get left edge of window
  3598. add [x_pixel],ax ; add to x pixel position
  3599. mov ax,[win_y1] ; get top edge of window
  3600. add [y_pixel],ax ; add to y pixel position
  3601. ;--------------------------------------------------------------------
  3602. ; Get a pointer to the source buffer so we can handle the clipping
  3603. ;--------------------------------------------------------------------
  3604. get_buffer:
  3605. lds si,[buffer] ; get a pointer to the buffer
  3606. ;--------------------------------------------------------------------
  3607. ; Check the top of our shape and clip any lines that are necessary
  3608. ;--------------------------------------------------------------------
  3609. mov ax,[y_pixel] ; get the y_pixel draw position
  3610. sub ax,[win_y1] ; subtract out the window y top
  3611. jns short check_bottom ; skip if y below window top
  3612. add ax,[pixel_h] ; add in the height of the region
  3613. jg short clip_top ; if positive then clip top lines
  3614. jump_exit:
  3615. jmp proc_exit ; otherwise completely clipped
  3616. clip_top:
  3617. xchg [pixel_h],ax
  3618. sub ax,[pixel_h]
  3619. add [y_pixel],ax
  3620. mul [pixel_w] ; convert to number of bytes to skip
  3621. add si,ax ; skip past the necessary bytes
  3622. ;--------------------------------------------------------------------
  3623. ; Check the bottom of our shape and clip it if necessary
  3624. ;--------------------------------------------------------------------
  3625. check_bottom:
  3626. mov ax,[win_y2] ; get the bottom y of the window
  3627. sub ax,[y_pixel] ; subtract of the y to draw at
  3628. js jump_exit ; if its signed then nothing to draw
  3629. jz jump_exit ; if its zero then nothing to draw
  3630. cmp ax,[pixel_h] ; if more room to draw then height
  3631. jae short clip_x_left ; then go check the left clip
  3632. mov [pixel_h],ax ; clip all but amount that will fit
  3633. clip_x_left:
  3634. mov [clipleft],0 ; clear clip on left of region
  3635. mov ax,[x_pixel] ; get the pixel x of draw region
  3636. sub ax,[win_x1] ; pull out the window coordinate
  3637. jns short clip_x_right
  3638. neg ax ; negate to get amnt to skip in buf
  3639. mov [clipleft],ax ; store it in the left clip info
  3640. add [x_pixel],ax ; move to the edge of the window
  3641. sub [pixel_w],ax ; pull it out of the pixel width
  3642. clip_x_right:
  3643. mov [clipright],0 ; clear clip on right of region
  3644. mov ax,[win_x2] ; get the window x of clip region
  3645. sub ax,[x_pixel] ; subtract the draw edge of region
  3646. js jump_exit ; if its negative then get out
  3647. jz jump_exit ; if its zero then get out
  3648. cmp ax,[pixel_w] ; is space available larger than w
  3649. jae short draw_prep ; if so then go get drawing
  3650. xchg [pixel_w],ax ; amt to draw in pixel_w (wid in ax)
  3651. sub ax,[pixel_w] ; pull out the amount to draw
  3652. mov [clipright],ax ; this is the amount to clip on right
  3653. draw_prep:
  3654. push si ; save off source pos in buffer
  3655. push ds ; both offset and segment
  3656. mov ax,@data
  3657. mov ds,ax
  3658. mov bx,[y_pixel]
  3659. shl bx,1 ; shift left by 1 for word table look
  3660. lds si,[YTable] ; get the address of the ytable
  3661. mov di,[ds:si+bx] ; look up the multiplied value
  3662. pop ds ; restore source pos in buffer
  3663. pop si ; both offset and segment
  3664. add di,[x_pixel] ; add in the x pixel position
  3665. mov [nextline],di ; save it off in the next line
  3666. ;--------------------------------------------------------------------
  3667. ; Now determine the type of the shape and process it in the proper
  3668. ; way.
  3669. ;--------------------------------------------------------------------
  3670. mov dx,[pixel_h]
  3671. ; Check to see if the WSA is the screen width and there is no
  3672. ; clipping. In this case, then a special single call to the
  3673. ; line processing routine is possible.
  3674. mov ax,[clipleft]
  3675. add ax,[clipright]
  3676. jne short top_of_loop
  3677. cmp [pixel_w],BYTESPERROW
  3678. jne short top_of_loop
  3679. ;------------------------------------
  3680. ; The width of the WSA is the screen width, so just process as
  3681. ; one large WSA line.
  3682. mov ax,BYTESPERROW
  3683. imul dx
  3684. mov cx,ax
  3685. call [putmiddle]
  3686. jmp short proc_exit
  3687. ;------------------------------------
  3688. ; Process line by line.
  3689. top_of_loop:
  3690. add si,[clipleft] ; skip whats necessary on left edge
  3691. mov cx,[pixel_w] ; get the width we need to draw
  3692. ; Copy the source to the destination as appropriate. This routine can
  3693. ; trash AX, BX, CX, and DI. It must properly modify SI to point one byte past
  3694. ; the end of the data.
  3695. call [putmiddle]
  3696. add si,[clipright] ; skip past the left clip
  3697. add [nextline],BYTESPERROW
  3698. mov di,[nextline]
  3699. dec dx
  3700. jnz top_of_loop
  3701. proc_exit:
  3702. pop fs
  3703. ret
  3704. ENDP
  3705. ;***************************************************************************
  3706. ;* NORMAL_DRAW -- Function that writes a normal pixel line *
  3707. ;* *
  3708. ;* INPUT: cx - number of pixels to write *
  3709. ;* ds:si - buffer which holds the pixels to write *
  3710. ;* es:di - place to put the pixels we are writing *
  3711. ;* *
  3712. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3713. ;* es:di - points to next pixel past last pixel written *
  3714. ;* *
  3715. ;* WARNINGS: none *
  3716. ;* *
  3717. ;* HISTORY: *
  3718. ;* 07/17/1992 PWG : Created. *
  3719. ;*=========================================================================*
  3720. PROC NOLANGUAGE WSA_Normal_Draw NEAR
  3721. IF 1
  3722. ; This version is marginally faster than the later version.
  3723. mov ax,cx
  3724. shr cx,2
  3725. rep movsd
  3726. and ax,011b
  3727. mov cx,ax
  3728. shr cx,1
  3729. rep movsw
  3730. adc cx,cx
  3731. rep movsb
  3732. ret
  3733. ELSE
  3734. shr cx,1 ; convert to words (odd pix in carry)
  3735. rep movsw ; write out the needed words
  3736. adc cx,0 ; add the carry into cx
  3737. rep movsb ; write out the odd byte if any
  3738. ret
  3739. ENDIF
  3740. ENDP
  3741. ;***************************************************************************
  3742. ;* TRANSPARENT_DRAW -- Function that writes a transparent pixel line *
  3743. ;* *
  3744. ;* INPUT: cx - number of pixels to write *
  3745. ;* ds:si - buffer which holds the pixels to write *
  3746. ;* es:di - place to put the pixels we are writing *
  3747. ;* *
  3748. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3749. ;* es:di - points to next pixel past last pixel written *
  3750. ;* *
  3751. ;* WARNINGS: none *
  3752. ;* *
  3753. ;* HISTORY: *
  3754. ;* 07/17/1992 PWG : Created. *
  3755. ;* 10/02/1994 JLB : Optimized for 250% speed improvement. *
  3756. ;*=========================================================================*
  3757. PROC NOLANGUAGE Transparent_Draw NEAR
  3758. IF 1
  3759. ; Preserve DX since it is used as a scratch register.
  3760. push dx
  3761. loop:
  3762. ; Swap DS:SI and ES:DI back in preparation for the REP SCASB
  3763. ; instruction.
  3764. xchg di,si
  3765. mov dx,es
  3766. mov ax,ds
  3767. mov ds,dx
  3768. mov es,ax
  3769. ; Remember the bytes remaining in order to calculate the position
  3770. ; of the scan when it stops.
  3771. mov bx,cx
  3772. ; Scan looking for a non-zero value in the source buffer.
  3773. xor al,al
  3774. repe scasb
  3775. ; When the loop ends, if the EQ flag is set then the scanning is
  3776. ; complete. Jump to the end of the routine in order to fixup the
  3777. ; pointers.
  3778. je short fini
  3779. ; Advance the destination pointer by the amount necessary to match
  3780. ; the source movement. DS:SI points to where data should be written.
  3781. add si,bx
  3782. inc cx ; SCASB leaves CX one too low, fix it.
  3783. dec di ; SCASB leaves DI one byte too far, fix it.
  3784. sub si,cx
  3785. ; Scan for the duration of non-zero pixels. This yields a count which
  3786. ; is used to copy the source data to the destination. Preserve DI.
  3787. mov dx,di
  3788. mov bx,cx
  3789. repne scasb
  3790. mov di,dx
  3791. ; Set BX to equal the number of bytes to copy from source to dest.
  3792. inc cx ; SCASB leaves CX one too low, fix it.
  3793. sub bx,cx
  3794. ; Move the data from ES:DI to DS:SI for BX bytes.
  3795. xchg cx,bx ; Make CX=bytes to move, BX=bytes remaining.
  3796. ; Swap DS:SI and ES:DI in preparation for the REP MOV instruction.
  3797. xchg di,si
  3798. mov dx,es
  3799. mov ax,ds
  3800. mov ds,dx
  3801. mov es,ax
  3802. ; Move the data from source to dest. First try to move double
  3803. ; words. Then copy the remainder bytes (if any). Putting jumps in
  3804. ; this section doesn't result in any savings -- oh well.
  3805. mov ax,cx
  3806. shr cx,2
  3807. rep movsd
  3808. and ax,0011b
  3809. mov cx,ax
  3810. shr cx,1
  3811. rep movsw
  3812. adc cx,cx
  3813. rep movsb
  3814. ; Restore CX with the remaining bytes to process.
  3815. mov cx,bx
  3816. ; If there are more bytes to process, then loop back.
  3817. or cx,cx
  3818. jne short loop
  3819. fini:
  3820. ; Swap ES:DI and DS:SI back to original orientation.
  3821. mov ax,ds
  3822. mov bx,es
  3823. mov es,ax
  3824. mov ds,bx
  3825. xchg di,si
  3826. ; Restore DX and return.
  3827. pop dx
  3828. ret
  3829. ELSE
  3830. loop_top:
  3831. lodsb
  3832. or al,al
  3833. jz short skip
  3834. mov [es:di],al ; store the pixel to the screen
  3835. skip:
  3836. inc di
  3837. loop loop_top
  3838. ret
  3839. ENDIF
  3840. ENDP
  3841. ;***************************************************************************
  3842. ;* PRIORITY_DRAW -- Function that writes a pixels if they are in front of *
  3843. ;* the given plate. *
  3844. ;* *
  3845. ;* INPUT: cx - number of pixels to write *
  3846. ;* ds:si - buffer which holds the pixels to write *
  3847. ;* es:di - place to put the pixels we are writing *
  3848. ;* *
  3849. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3850. ;* es:di - points to next pixel past last pixel written *
  3851. ;* *
  3852. ;* WARNINGS: none *
  3853. ;* *
  3854. ;* HISTORY: *
  3855. ;* 07/17/1992 PWG : Created. *
  3856. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  3857. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  3858. ;*=========================================================================*
  3859. PROC NOLANGUAGE Priority_Draw NEAR
  3860. mov fs,[background] ; get the SEG of the background page
  3861. mov gs,[maskpage] ; get the SEG of the mask info
  3862. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  3863. loop_top:
  3864. lodsb ; get the pixel to draw on the screen
  3865. ; get the mask byte for our pixel
  3866. mov bl,[ds:di]
  3867. ; get rid of non-walkable bit and
  3868. ; get rid of scaling id bits
  3869. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  3870. cmp ah,bl ; are we more toward the front?
  3871. jge short out_pixel ; if so then write the pixel
  3872. mov al,[fs:di] ; get the pixel to write
  3873. out_pixel:
  3874. stosb ; write the pixel and inc the DI
  3875. loop loop_top
  3876. ret
  3877. ENDP
  3878. ;***************************************************************************
  3879. ;* PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they are *
  3880. ;* in front of the given plate. It also deals with *
  3881. ;* transparent pixels. *
  3882. ;* *
  3883. ;* INPUT: cx - number of pixels to write *
  3884. ;* ds:si - buffer which holds the pixels to write *
  3885. ;* es:di - place to put the pixels we are writing *
  3886. ;* *
  3887. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3888. ;* es:di - points to next pixel past last pixel written *
  3889. ;* *
  3890. ;* WARNINGS: none *
  3891. ;* *
  3892. ;* HISTORY: *
  3893. ;* 07/17/1992 PWG : Created. *
  3894. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  3895. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  3896. ;*=========================================================================*
  3897. PROC NOLANGUAGE Priority_Transparent_Draw NEAR
  3898. mov fs,[background] ; get the SEG of the background page
  3899. mov gs,[maskpage] ; get the SEG of the mask info
  3900. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  3901. loop_top:
  3902. lodsb ; get the pixel on the screen
  3903. or al,al ; check to see if al is transparent
  3904. je short write_back ; if it is go write background
  3905. mov bl,[gs:di] ; get the mask byte for our pixel
  3906. ; get rid of non-walkable bit and
  3907. ; get rid of scaling id bits
  3908. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  3909. cmp ah,bl ; are we more toward the front?
  3910. jge short out_pixel ; if so then write the pixel
  3911. write_back:
  3912. mov al,[fs:di] ; get the pixel to write
  3913. out_pixel:
  3914. stosb ; write the pixel
  3915. loop loop_top
  3916. ret
  3917. ENDP
  3918. ;***************************************************************************
  3919. ;* GHOST_NORMAL_DRAW -- Function that writes a normal pixel line *
  3920. ;* *
  3921. ;* INPUT: cx - number of pixels to write *
  3922. ;* ds:si - buffer which holds the pixels to write *
  3923. ;* es:di - place to put the pixels we are writing *
  3924. ;* *
  3925. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3926. ;* es:di - points to next pixel past last pixel written *
  3927. ;* *
  3928. ;* WARNINGS: none *
  3929. ;* *
  3930. ;* HISTORY: *
  3931. ;* 05/27/1993 MCC : Created. *
  3932. ;*=========================================================================*
  3933. PROC NOLANGUAGE Ghost_Normal_Draw NEAR
  3934. loop_top:
  3935. lodsb
  3936. ;---
  3937. ; Ok, find out if the colour is a Translucent colour
  3938. push ax
  3939. push ds
  3940. lds bx,[IsTranslucent]
  3941. mov ah,al ; preserve real pixel
  3942. xlat ; get new al (transluecent pixel
  3943. xchg ah,al ; get real pixel back into AL just in case
  3944. cmp ah,255
  3945. je short normal_pixel ; is it a translucent ?
  3946. ; if we get passed here value in
  3947. ; AH should be 0-15
  3948. ; yes, it is a translucent colour so goto our translucent translation
  3949. ; table and set up a ptr to the correct table
  3950. mov al,[es:di]
  3951. ; mov pixel at destination to al and we have
  3952. ; the index to the translation table
  3953. ; ((trans_colour * 256) + dest colour)
  3954. lds bx,[Translucent] ; get the ptr to it!
  3955. add bh,ah ; Add the (trans_color * 256) of the translation equ.
  3956. ; XLAT only uses AL so no need to clear AH
  3957. xlat ; get new pixel in AL
  3958. normal_pixel:
  3959. pop ds
  3960. pop bx
  3961. mov ah,bh
  3962. ;---
  3963. mov [es:di],al ; store the pixel to the screen
  3964. skip:
  3965. inc di
  3966. loop loop_top
  3967. ret
  3968. ENDP
  3969. ;***************************************************************************
  3970. ;* GHOST_TRANSPARENT_DRAW -- Function that writes a transparent pixel line *
  3971. ;* *
  3972. ;* INPUT: cx - number of pixels to write *
  3973. ;* ds:si - buffer which holds the pixels to write *
  3974. ;* es:di - place to put the pixels we are writing *
  3975. ;* *
  3976. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  3977. ;* es:di - points to next pixel past last pixel written *
  3978. ;* *
  3979. ;* WARNINGS: none *
  3980. ;* *
  3981. ;* HISTORY: *
  3982. ;* 05/27/1993 MCC : Created. *
  3983. ;*=========================================================================*
  3984. PROC NOLANGUAGE Ghost_Transparent_Draw NEAR
  3985. loop_top:
  3986. lodsb
  3987. or al,al
  3988. jz short skip
  3989. ;---
  3990. ; Ok, find out if the colour is a Translucent colour
  3991. push ax
  3992. push ds
  3993. lds bx,[IsTranslucent]
  3994. mov ah,al ; preserve real pixel
  3995. xlat ; get new al (transluecent pixel
  3996. xchg ah,al ; get real pixel back into AL just in case
  3997. cmp ah,255
  3998. je short normal_pixel ; is it a translucent ?
  3999. ; if we get passed here value in
  4000. ; AH should be 0-15
  4001. ; yes, it is a translucent colour so goto our translucent translation
  4002. ; table and set up a ptr to the correct table
  4003. mov al,[es:di]
  4004. ; mov pixel at destination to al and we have
  4005. ; the index to the translation table
  4006. ; ((trans_colour * 256) + dest colour)
  4007. lds bx,[Translucent] ; get the ptr to it!
  4008. add bh,ah ; Add the (trans_color * 256) of the translation equ.
  4009. ; XLAT only uses AL so no need to clear AH
  4010. xlat ; get new pixel in AL
  4011. normal_pixel:
  4012. pop ds
  4013. pop bx
  4014. mov ah,bh
  4015. ;---
  4016. mov [es:di],al ; store the pixel to the screen
  4017. skip:
  4018. inc di
  4019. loop loop_top
  4020. ret
  4021. ENDP
  4022. ;***************************************************************************
  4023. ;* GHOST_PRIORITY_DRAW -- Function that writes a pixels if they are in fron*
  4024. ;* the given plate. *
  4025. ;* *
  4026. ;* INPUT: cx - number of pixels to write *
  4027. ;* ds:si - buffer which holds the pixels to write *
  4028. ;* es:di - place to put the pixels we are writing *
  4029. ;* *
  4030. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  4031. ;* es:di - points to next pixel past last pixel written *
  4032. ;* *
  4033. ;* WARNINGS: none *
  4034. ;* *
  4035. ;* HISTORY: *
  4036. ;* 07/17/1992 PWG : Created. *
  4037. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  4038. ;* 05/27/1993 MCC : Updated to use the new Ghosting fx *
  4039. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  4040. ;*=========================================================================*
  4041. PROC NOLANGUAGE Ghost_Priority_Draw NEAR
  4042. mov fs,[background] ; get the SEG of the background page
  4043. mov gs,[maskpage] ; get the SEG of the mask info
  4044. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  4045. loop_top:
  4046. lodsb ; get the pixel to draw on the screen
  4047. ; get the mask byte for our pixel
  4048. mov bl,[ds:di]
  4049. ; get rid of non-walkable bit and
  4050. ; get rid of scaling id bits
  4051. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  4052. cmp ah,bl ; are we more toward the front?
  4053. jge short out_pixel ; if so then write the pixel
  4054. mov al,[fs:di] ; get the pixel to write
  4055. out_pixel:
  4056. stosb ; write the pixel and inc the DI
  4057. loop loop_top
  4058. ret
  4059. ENDP
  4060. ;***************************************************************************
  4061. ;* GHOST_PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they*
  4062. ;* in front of the given plate. It also deals with *
  4063. ;* transparent pixels. *
  4064. ;* *
  4065. ;* INPUT: cx - number of pixels to write *
  4066. ;* ds:si - buffer which holds the pixels to write *
  4067. ;* es:di - place to put the pixels we are writing *
  4068. ;* *
  4069. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  4070. ;* es:di - points to next pixel past last pixel written *
  4071. ;* *
  4072. ;* WARNINGS: none *
  4073. ;* *
  4074. ;* HISTORY: *
  4075. ;* 07/17/1992 PWG : Created. *
  4076. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  4077. ;* 05/27/1993 MCC : Updated to use the new Ghosting fx *
  4078. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  4079. ;*=========================================================================*
  4080. PROC NOLANGUAGE Ghost_Priority_Transparent_Draw NEAR
  4081. mov fs,[background] ; get the SEG of the background page
  4082. mov gs,[maskpage] ; get the SEG of the mask info
  4083. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  4084. loop_top:
  4085. lodsb ; get the pixel on the screen
  4086. or al,al ; check to see if al is transparent
  4087. je short write_back ; if it is go write background
  4088. mov bl,[gs:di] ; get the mask byte for our pixel
  4089. ; get rid of non-walkable bit and
  4090. ; get rid of scaling id bits
  4091. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  4092. cmp ah,bl ; are we more toward the front?
  4093. jge short out_pixel ; if so then write the pixel
  4094. write_back:
  4095. mov al,[fs:di] ; get the pixel to write
  4096. out_pixel:
  4097. stosb ; write the pixel
  4098. loop loop_top
  4099. ret
  4100. ENDP
  4101. END