KEYFBUFF.ASM 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;***************************************************************************
  19. ;** 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 **
  20. ;***************************************************************************
  21. ;* *
  22. ;* Project Name : Command & Conquer *
  23. ;* *
  24. ;* File Name : KEYFBUFF.ASM *
  25. ;* *
  26. ;* Programmer : David R. Dettmer *
  27. ;* *
  28. ;* Start Date : March 3, 1995 *
  29. ;* *
  30. ;* Last Update : *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* Buffer_Frame_To_Page -- Copies a linear buffer to a virtual viewport *
  35. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  36. ;********************** Model & Processor Directives ***********************
  37. IDEAL
  38. P386
  39. MODEL USE32 FLAT
  40. ;******************************** Includes *********************************
  41. INCLUDE "gbuffer.inc"
  42. ;******************************** Equates **********************************
  43. TRUE equ 1 ; Boolean 'true' value
  44. FALSE equ 0 ; Boolean 'false' value
  45. ;*=========================================================================*/
  46. ;* The following are defines used to control what functions are linked *
  47. ;* in for Buffer_Frame_To_Page. *
  48. ;*=========================================================================*/
  49. ;USE_NORMAL EQU TRUE
  50. ;USE_HORZ_REV EQU TRUE
  51. ;USE_VERT_REV EQU TRUE
  52. ;USE_SCALING EQU TRUE
  53. FLAG_NORMAL EQU 0
  54. FLAG_TRANS EQU 1
  55. FLAG_GHOST EQU 2
  56. FLAG_FADING EQU 4
  57. FLAG_PREDATOR EQU 8
  58. FLAG_MASK EQU 0Fh
  59. SHAPE_NORMAL EQU 0000h ; Standard shape
  60. ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally
  61. ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically
  62. ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y)
  63. ;SHAPE_VIEWPORT_REL EQU 0010h ; Coords are window-relative
  64. ;SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute.
  65. SHAPE_CENTER EQU 0020h ; Coords are based on shape's center pt
  66. SHAPE_TRANS EQU 0040h ; has transparency
  67. SHAPE_FADING EQU 0100h ; Fading effect (VOID * fading_table,
  68. ; WORD fading_num)
  69. SHAPE_PREDATOR EQU 0200h ; Transparent warping effect
  70. ;SHAPE_COMPACT EQU 0400h ; Never use this bit
  71. ;SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing
  72. SHAPE_GHOST EQU 1000h ; Shape is drawn ghosted
  73. ;SHAPE_SHADOW EQU 2000h
  74. SHAPE_PARTIAL EQU 4000h
  75. ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors
  76. ; (VOID * color_table)
  77. ;
  78. ;.......................... Shadow Effect ..................................
  79. ;
  80. SHADOW_COL EQU 00FFh ; magic number for shadows
  81. ;......................... Priority System .................................
  82. ;
  83. CLEAR_UNUSED_BITS EQU 0007h ; and with 0000-0111 to clear
  84. ; non-walkable high bit and
  85. ; scaling id bits
  86. NON_WALKABLE_BIT EQU 0080h ; and with 1000-0000 to clear all
  87. ; but non-walkable bit
  88. ;
  89. ;......................... Predator Effect .................................
  90. ;
  91. ;PRED_MASK EQU 0007h ; mask used for predator pixel puts
  92. PRED_MASK EQU 000Eh ; mask used for predator pixel puts
  93. ;---------------------------------------------------------------------------
  94. ;
  95. ; Use a macro to make code a little cleaner.
  96. ; The parameter varname is optional.
  97. ; Syntax to use macro is :
  98. ; WANT equ expression
  99. ; USE func [,varname]
  100. ; If the 'varname' is defined, a table declaration is created like:
  101. ; GLOBAL TableName:DWORD
  102. ; Then, the table entry is created:
  103. ; If WANT is true, the table entry is created for the given function:
  104. ; varname DD func
  105. ; If WANT is not TRUE, a Not_Supported entry is put in the table:
  106. ; varname DD Not_Supported
  107. ; The resulting tables look like:
  108. ;
  109. ; GLOBAL ExampTable:DWORD
  110. ; ExampTable DD routine1
  111. ; DD routine2
  112. ; DD routine3
  113. ; ...
  114. ; Thus, each table is an array of function pointers.
  115. ;
  116. ;---------------------------------------------------------------------------
  117. MACRO USE func, varname
  118. IF WANT
  119. varname DD func
  120. ELSE
  121. varname DD Not_Supported
  122. ENDIF
  123. ENDM
  124. ; IFNB <varname>
  125. ; GLOBAL varname:DWORD
  126. ; ENDIF
  127. ;---------------------------------------------------------------------------
  128. DATASEG
  129. ;---------------------------------------------------------------------------
  130. ; Predator effect variables
  131. ;---------------------------------------------------------------------------
  132. ; make table for negative offset and use the used space for other variables
  133. BFPredNegTable DW -1, -3, -2, -5, -2, -4, -3, -1
  134. ; 8 words below calculated
  135. DW 0, 0, 0, 0, 0, 0, 0, 0 ; index ffffff00
  136. DD 0, 0, 0, 0 ; index ffffff10
  137. BFPredOffset DD 0, 0, 0, 0 ; index ffffff20
  138. DD 0, 0, 0, 0 ; index ffffff30
  139. ; partially faded predator effect value
  140. BFPartialPred DD 0, 0, 0, 0 ; index ffffff40
  141. BFPartialCount DD 0, 0, 0, 0 ; index ffffff50
  142. DD 0, 0, 0, 0 ; index ffffff60
  143. DD 0, 0, 0, 0 ; index ffffff70
  144. DD 0, 0, 0, 0 ; index ffffff80
  145. DD 0, 0, 0, 0 ; index ffffff90
  146. DD 0, 0, 0, 0 ; index ffffffa0
  147. DD 0, 0, 0, 0 ; index ffffffb0
  148. DD 0, 0, 0, 0 ; index ffffffc0
  149. DD 0, 0, 0, 0 ; index ffffffd0
  150. DD 0, 0, 0, 0 ; index ffffffe0
  151. DD 0, 0, 0, 0 ; index fffffff0
  152. BFPredTable DW 1, 3, 2, 5, 2, 3, 4, 1
  153. ;BFPredTable DB 1, 3, 2, 5, 4, 3, 2, 1
  154. CODESEG
  155. ;---------------------------------------------------------------------------
  156. ; Code Segment Tables:
  157. ; This code uses the USE macro to set up tables of function addresses.
  158. ; The tables have the following format:
  159. ; Tables defined are:
  160. ; BufferFrameTable
  161. ;---------------------------------------------------------------------------
  162. WANT equ <TRUE>
  163. USE BF_Copy, BufferFrameTable
  164. WANT equ <TRUE>
  165. USE BF_Trans
  166. WANT equ <TRUE>
  167. USE BF_Ghost
  168. WANT equ <TRUE>
  169. USE BF_Ghost_Trans
  170. WANT equ <TRUE>
  171. USE BF_Fading
  172. WANT equ <TRUE>
  173. USE BF_Fading_Trans
  174. WANT equ <TRUE>
  175. USE BF_Ghost_Fading
  176. WANT equ <TRUE>
  177. USE BF_Ghost_Fading_Trans
  178. WANT equ <TRUE>
  179. USE BF_Predator
  180. WANT equ <TRUE>
  181. USE BF_Predator_Trans
  182. WANT equ <TRUE>
  183. USE BF_Predator_Ghost
  184. WANT equ <TRUE>
  185. USE BF_Predator_Ghost_Trans
  186. WANT equ <TRUE>
  187. USE BF_Predator_Fading
  188. WANT equ <TRUE>
  189. USE BF_Predator_Fading_Trans
  190. WANT equ <TRUE>
  191. USE BF_Predator_Ghost_Fading
  192. WANT equ <TRUE>
  193. USE BF_Predator_Ghost_Fading_Trans
  194. ;---------------------------------------------------------------------------
  195. global _Int3:near
  196. proc _Int3 near
  197. int 3
  198. ret
  199. endp
  200. ;***************************************************************************
  201. ;* VVC::TOPAGE -- Copies a linear buffer to a virtual viewport *
  202. ;* *
  203. ;* INPUT: WORD x_pixel - x pixel on viewport to copy from *
  204. ;* WORD y_pixel - y pixel on viewport to copy from *
  205. ;* WORD pixel_width - the width of copy region *
  206. ;* WORD pixel_height - the height of copy region *
  207. ;* BYTE * src - buffer to copy from *
  208. ;* VVPC * dest - virtual viewport to copy to *
  209. ;* *
  210. ;* OUTPUT: none *
  211. ;* *
  212. ;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
  213. ;* the boundaries. In the event that no adjustment is *
  214. ;* possible this routine will abort. If the size of the *
  215. ;* region to copy exceeds the size passed in for the buffer *
  216. ;* the routine will automatically abort. *
  217. ;* *
  218. ;* HISTORY: *
  219. ;* 06/15/1994 PWG : Created. *
  220. ;*=========================================================================*
  221. GLOBAL C Buffer_Frame_To_Page:NEAR
  222. PROC Buffer_Frame_To_Page C near
  223. USES eax,ebx,ecx,edx,esi,edi
  224. ;*===================================================================
  225. ;* define the arguements that our function takes.
  226. ;*===================================================================
  227. ARG x_pixel :DWORD ; x pixel position in source
  228. ARG y_pixel :DWORD ; y pixel position in source
  229. ARG pixel_width :DWORD ; width of rectangle to blit
  230. ARG pixel_height:DWORD ; height of rectangle to blit
  231. ARG src :DWORD ; this is a member function
  232. ARG dest :DWORD ; what are we blitting to
  233. ARG flags :DWORD ; flags passed
  234. ;*===================================================================
  235. ; Define some locals so that we can handle things quickly
  236. ;*===================================================================
  237. LOCAL IsTranslucent :DWORD ; ptr to the is_translucent table
  238. LOCAL Translucent :DWORD ; ptr to the actual translucent table
  239. LOCAL FadingTable :DWORD ; extracted fading table pointer
  240. LOCAL FadingNum :DWORD ; get the number of times to fade
  241. LOCAL StashECX :DWORD ; temp variable for ECX register
  242. LOCAL jflags :DWORD ; flags used to goto correct buff frame routine
  243. LOCAL BufferFrameRout :DWORD ; ptr to the buffer frame routine
  244. LOCAL jmp_loc :DWORD ; calculated jump location
  245. LOCAL loop_cnt :DWORD
  246. LOCAL x1_pixel :DWORD
  247. LOCAL y1_pixel :DWORD
  248. LOCAL scr_x :DWORD
  249. LOCAL scr_y :DWORD
  250. LOCAL dest_adjust_width :DWORD
  251. LOCAL scr_adjust_width :DWORD
  252. cmp [ src ] , 0
  253. jz ??real_out
  254. ;====================================================================
  255. ; Pull off optional arguments:
  256. ; EDI is used as an offset from the 'flags' parameter, to point
  257. ; to the optional argument currently being processed.
  258. ;====================================================================
  259. ??do_args:
  260. mov edi , 4 ; optional params start past flags
  261. mov [ jflags ] , 0 ; clear jump flags
  262. ??check_centering:
  263. ;-------------------------------------------------------------------
  264. ; See if we need to center the frame
  265. ;-------------------------------------------------------------------
  266. test [ flags ] , SHAPE_CENTER ; does this need to be centered?
  267. je ??check_trans ; if not the skip over this stuff
  268. mov eax , [ pixel_width ]
  269. mov ebx , [ pixel_height ]
  270. sar eax , 1
  271. sar ebx , 1
  272. sub [ x_pixel ] , eax
  273. sub [ y_pixel ] , ebx
  274. ??check_trans:
  275. test [ flags ] , SHAPE_TRANS
  276. jz ??check_ghost
  277. or [ jflags ] , FLAG_TRANS
  278. ;--------------------------------------------------------------------
  279. ; SHAPE_GHOST: DWORD is_translucent tbl
  280. ;--------------------------------------------------------------------
  281. ??check_ghost:
  282. test [ flags ] , SHAPE_GHOST ; are we ghosting this shape
  283. jz ??check_fading
  284. mov eax , [ flags + edi ]
  285. or [ jflags ] , FLAG_GHOST
  286. mov [ IsTranslucent ] , eax ; save ptr to is_trans. tbl
  287. add eax , 0100h ; add 256 for first table
  288. add edi , 4 ; next argument
  289. mov [ Translucent ] , eax ; save ptr to translucent tbl
  290. ;--------------------------------------------------------------------
  291. ; SHAPE_FADING: DWORD fade_table[256], DWORD fade_count
  292. ;--------------------------------------------------------------------
  293. ??check_fading:
  294. test [ flags ] , SHAPE_FADING ; are we fading this shape
  295. jz ??check_predator
  296. mov eax , [ flags + edi ]
  297. mov [ FadingTable ] , eax ; save address of fading tbl
  298. mov eax , [ flags + edi + 4 ] ; get fade num
  299. or [ jflags ] , FLAG_FADING
  300. and eax , 03fh ; no need for more than 63
  301. add edi , 8 ; next argument
  302. cmp eax , 0 ; check if it's 0
  303. jnz ??set_fading ; if not, store fade num
  304. and [ flags ] , NOT SHAPE_FADING ; otherwise, don't fade
  305. ??set_fading:
  306. mov [ FadingNum ] , eax
  307. ;--------------------------------------------------------------------
  308. ; SHAPE_PREDATOR: DWORD init_pred_lookup_offset (0-7)
  309. ;--------------------------------------------------------------------
  310. ??check_predator:
  311. test [ flags ] , SHAPE_PREDATOR ; is predator effect on
  312. jz ??check_partial
  313. mov eax , [ flags + edi ] ; pull the partial value
  314. or [ jflags ] , FLAG_PREDATOR
  315. shl eax , 1
  316. cmp eax , 0
  317. jge ??check_range
  318. neg eax
  319. mov ebx , -1
  320. and eax , PRED_MASK ; keep entries within bounds
  321. mov bl , al
  322. mov eax , ebx ; will be ffffff00-ffffff07
  323. jmp ??pred_cont
  324. ??check_range:
  325. and eax , PRED_MASK ; keep entries within bounds
  326. ??pred_cont:
  327. add edi , 4 ; next argument
  328. mov [ BFPredOffset ] , eax
  329. mov [ BFPartialCount ] , 0 ; clear the partial count
  330. mov [ BFPartialPred ] , 100h ; init partial to off
  331. ??pred_neg_init:
  332. mov esi , [ dest ] ; get ptr to dest
  333. mov ebx, 7 * 2
  334. ??pred_loop:
  335. movzx eax , [ WORD PTR BFPredNegTable + ebx ]
  336. add eax , [ (GraphicViewPort esi) . GVPWidth ] ; add width
  337. add eax , [ (GraphicViewPort esi) . GVPXAdd ] ; add x add
  338. mov [ WORD PTR BFPredNegTable + 16 + ebx ] , ax
  339. dec ebx
  340. dec ebx
  341. jge ??pred_loop
  342. ;--------------------------------------------------------------------
  343. ; SHAPE_PARTIAL: DWORD partial_pred_value (0-255)
  344. ;--------------------------------------------------------------------
  345. ??check_partial:
  346. test [ flags ] , SHAPE_PARTIAL ; is this a partial pred?
  347. jz ??setupfunc
  348. mov eax , [ flags + edi ] ; pull the partial value
  349. add edi , 4 ; next argument
  350. and eax , 0ffh ; make sure 0-255
  351. mov [ BFPartialPred ] , eax ; store it off
  352. ??setupfunc:
  353. mov ebx , [ jflags ] ; load flags value
  354. and ebx , FLAG_MASK ; clip high bits
  355. add ebx , ebx ; mult by 4 to get DWORD offset
  356. add ebx , ebx
  357. mov ebx , [ BufferFrameTable + ebx ] ; get table value
  358. mov [ BufferFrameRout ] , ebx ; store it in the function pointer
  359. ; Clip dest Rectangle against source Window boundaries.
  360. mov [ scr_x ] , 0
  361. mov [ scr_y ] , 0
  362. mov esi , [ dest ] ; get ptr to dest
  363. xor ecx , ecx
  364. xor edx , edx
  365. mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
  366. mov ebx , [ x_pixel ]
  367. mov eax , [ x_pixel ]
  368. add ebx , [ pixel_width ]
  369. shld ecx , eax , 1
  370. mov [ x1_pixel ] , ebx
  371. inc edi
  372. shld edx , ebx , 1
  373. sub eax , edi
  374. sub ebx , edi
  375. shld ecx , eax , 1
  376. shld edx , ebx , 1
  377. mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
  378. mov ebx , [ y_pixel ]
  379. mov eax , [ y_pixel ]
  380. add ebx , [ pixel_height ]
  381. shld ecx , eax , 1
  382. mov [ y1_pixel ] , ebx
  383. inc edi
  384. shld edx , ebx , 1
  385. sub eax , edi
  386. sub ebx , edi
  387. shld ecx , eax , 1
  388. shld edx , ebx , 1
  389. xor cl , 5
  390. xor dl , 5
  391. mov al , cl
  392. test dl , cl
  393. jnz ??real_out
  394. or al , dl
  395. jz ??do_blit
  396. test cl , 1000b
  397. jz ??dest_left_ok
  398. mov eax , [ x_pixel ]
  399. neg eax
  400. mov [ x_pixel ] , 0
  401. mov [ scr_x ] , eax
  402. ??dest_left_ok:
  403. test cl , 0010b
  404. jz ??dest_bottom_ok
  405. mov eax , [ y_pixel ]
  406. neg eax
  407. mov [ y_pixel ] , 0
  408. mov [ scr_y ] , eax
  409. ??dest_bottom_ok:
  410. test dl , 0100b
  411. jz ??dest_right_ok
  412. mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
  413. mov [ x1_pixel ] , eax
  414. ??dest_right_ok:
  415. test dl , 0001b
  416. jz ??do_blit
  417. mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
  418. mov [ y1_pixel ] , eax
  419. ??do_blit:
  420. cld
  421. mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
  422. add eax , [ (GraphicViewPort esi) . GVPWidth ]
  423. mov edi , [ (GraphicViewPort esi) . GVPOffset ]
  424. mov ecx , eax
  425. mul [ y_pixel ]
  426. add edi , [ x_pixel ]
  427. add edi , eax
  428. add ecx , [ x_pixel ]
  429. sub ecx , [ x1_pixel ]
  430. mov [ dest_adjust_width ] , ecx
  431. mov esi , [ src ]
  432. mov eax , [ pixel_width ]
  433. sub eax , [ x1_pixel ]
  434. add eax , [ x_pixel ]
  435. mov [ scr_adjust_width ] , eax
  436. mov eax , [ scr_y ]
  437. mul [ pixel_width ]
  438. add eax , [ scr_x ]
  439. add esi , eax
  440. mov edx , [ y1_pixel ]
  441. mov eax , [ x1_pixel ]
  442. sub edx , [ y_pixel ]
  443. jle ??real_out
  444. sub eax , [ x_pixel ]
  445. jle ??real_out
  446. jmp [ BufferFrameRout ] ; buffer frame to viewport routine
  447. ??real_out:
  448. ret
  449. ; ********************************************************************
  450. ; Forward bitblit only
  451. ; the inner loop is so efficient that
  452. ; the optimal consept no longer apply because
  453. ; the optimal byte have to by a number greather than 9 bytes
  454. ; ********************************************************************
  455. BF_Copy:
  456. cmp eax , 10
  457. jl ??forward_loop_bytes
  458. ??forward_loop_dword:
  459. mov ecx , edi
  460. mov ebx , eax
  461. neg ecx
  462. and ecx , 3
  463. sub ebx , ecx
  464. rep movsb
  465. mov ecx , ebx
  466. shr ecx , 2
  467. rep movsd
  468. mov ecx , ebx
  469. and ecx , 3
  470. rep movsb
  471. add esi , [ scr_adjust_width ]
  472. add edi , [ dest_adjust_width ]
  473. dec edx
  474. jnz ??forward_loop_dword
  475. ret
  476. ??forward_loop_bytes:
  477. mov ecx , eax
  478. rep movsb
  479. add esi , [ scr_adjust_width ]
  480. add edi , [ dest_adjust_width ]
  481. dec edx ; decrement the height
  482. jnz ??forward_loop_bytes
  483. ret
  484. ;********************************************************************
  485. ;********************************************************************
  486. BF_Trans:
  487. ; calc the code location to skip to 10 bytes per REPT below!!!!
  488. mov ecx , eax
  489. and ecx , 01fh
  490. lea ecx , [ ecx + ecx * 4 ] ; quick multiply by 5
  491. neg ecx
  492. shr eax , 5
  493. lea ecx , [ ??trans_reference + ecx * 2 ] ; next multiply by 2
  494. mov [ loop_cnt ] , eax
  495. mov [ jmp_loc ] , ecx
  496. ??trans_loop:
  497. mov ecx , [ loop_cnt ]
  498. jmp [ jmp_loc ]
  499. ; the following code should NOT be changed without changing the calculation
  500. ; above!!!!!!
  501. ??trans_line:
  502. REPT 32
  503. local trans_pixel
  504. mov bl , [ esi ]
  505. inc esi
  506. test bl , bl
  507. jz trans_pixel
  508. mov [ edi ] , bl
  509. trans_pixel:
  510. inc edi
  511. ENDM
  512. ??trans_reference:
  513. dec ecx
  514. jge ??trans_line
  515. add esi , [ scr_adjust_width ]
  516. add edi , [ dest_adjust_width ]
  517. dec edx
  518. jnz ??trans_loop
  519. ret
  520. ;********************************************************************
  521. ;********************************************************************
  522. BF_Ghost:
  523. mov ebx , eax ; width
  524. ; NOTE: the below calculation assumes a group of instructions is
  525. ; less than 256 bytes
  526. ; get length of the 32 groups of instructions
  527. lea ecx , [ ??ghost_reference - ??ghost_line ]
  528. shr ebx , 5 ; width / 32
  529. shr ecx , 5 ; length of instructions / 32
  530. and eax , 01fh ; mod of width / 32
  531. mul cl ; calc offset to start of group
  532. neg eax ; inverse of width
  533. mov [ loop_cnt ] , ebx ; save width / 32
  534. lea ecx , [ ??ghost_reference + eax ]
  535. mov eax , 0
  536. mov [ jmp_loc ] , ecx
  537. ??ghost_loop:
  538. mov ecx , [ loop_cnt ]
  539. jmp [ jmp_loc ]
  540. ??ghost_line:
  541. REPT 32
  542. local store_pixel
  543. mov al , [ esi ]
  544. inc esi
  545. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  546. mov bh , [ BYTE PTR ebx + eax ]
  547. cmp bh , 0ffh
  548. je store_pixel
  549. and ebx , 0FF00h ; clear all of ebx except bh
  550. ; we have the index to the translation table
  551. ; ((trans_colour * 256) + dest colour)
  552. mov al , [ edi ] ; mov pixel at destination to al
  553. add ebx , [ Translucent ] ; get the ptr to it!
  554. ; Add the (trans_color * 256) of the translation equ.
  555. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  556. store_pixel:
  557. mov [ edi ] , al
  558. inc edi
  559. ENDM
  560. ??ghost_reference:
  561. dec ecx
  562. jge ??ghost_line
  563. add esi , [ scr_adjust_width ]
  564. add edi , [ dest_adjust_width ]
  565. dec edx
  566. jnz ??ghost_loop
  567. ret
  568. ;********************************************************************
  569. ;********************************************************************
  570. BF_Ghost_Trans:
  571. mov ebx , eax ; width
  572. ; NOTE: the below calculation assumes a group of instructions is
  573. ; less than 256 bytes
  574. ; get length of the 32 groups of instructions
  575. lea ecx , [ ??ghost_t_reference - ??ghost_t_line ]
  576. shr ebx , 5 ; width / 32
  577. shr ecx , 5 ; length of instructions / 32
  578. and eax , 01fh ; mod of width / 32
  579. mul cl ; calc offset to start of group
  580. neg eax ; inverse of width
  581. mov [ loop_cnt ] , ebx ; save width / 32
  582. lea ecx , [ ??ghost_t_reference + eax ]
  583. mov eax , 0
  584. mov [ jmp_loc ] , ecx
  585. ??ghost_t_loop:
  586. mov ecx , [ loop_cnt ]
  587. jmp [ jmp_loc ]
  588. ??ghost_t_line:
  589. REPT 32
  590. local transp_pixel
  591. local store_pixel
  592. mov al , [ esi ]
  593. inc esi
  594. test al , al
  595. jz transp_pixel
  596. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  597. mov bh , [ BYTE PTR ebx + eax ]
  598. cmp bh , 0ffh
  599. je store_pixel
  600. and ebx , 0FF00h ; clear all of ebx except bh
  601. ; we have the index to the translation table
  602. ; ((trans_colour * 256) + dest colour)
  603. mov al , [ edi ] ; mov pixel at destination to al
  604. add ebx , [ Translucent ] ; get the ptr to it!
  605. ; Add the (trans_color * 256) of the translation equ.
  606. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  607. store_pixel:
  608. mov [ edi ] , al
  609. transp_pixel:
  610. inc edi
  611. ENDM
  612. ??ghost_t_reference:
  613. dec ecx
  614. jge ??ghost_t_line
  615. add esi , [ scr_adjust_width ]
  616. add edi , [ dest_adjust_width ]
  617. dec edx
  618. jnz ??ghost_t_loop
  619. ret
  620. ;********************************************************************
  621. ;********************************************************************
  622. BF_Fading:
  623. mov ebx , eax ; width
  624. ; NOTE: the below calculation assumes a group of instructions is
  625. ; less than 256 bytes
  626. ; get length of the 32 groups of instructions
  627. lea ecx , [ ??fading_reference - ??fading_line ]
  628. shr ebx , 5 ; width / 32
  629. shr ecx , 5 ; length of instructions / 32
  630. and eax , 01fh ; mod of width / 32
  631. mul cl ; calc offset to start of group
  632. neg eax ; inverse of width
  633. mov [ loop_cnt ] , ebx ; save width / 32
  634. lea ecx , [ ??fading_reference + eax ]
  635. mov eax , 0
  636. mov [ jmp_loc ] , ecx
  637. ??fading_loop:
  638. mov ecx , [ loop_cnt ]
  639. mov [ StashECX ] , ecx ; preserve ecx for later
  640. mov ebx , [ FadingTable ] ; run color through fading table
  641. jmp [ jmp_loc ]
  642. ??fading_line_begin:
  643. mov [ StashECX ] , ecx ; preserve ecx for later
  644. ??fading_line:
  645. REPT 32
  646. local fade_loop
  647. mov al , [ esi ]
  648. inc esi
  649. mov ecx , [ FadingNum ]
  650. fade_loop:
  651. mov al, [BYTE PTR ebx + eax]
  652. dec ecx
  653. jnz fade_loop
  654. mov [ edi ] , al
  655. inc edi
  656. ENDM
  657. ??fading_reference:
  658. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  659. dec ecx
  660. jge ??fading_line_begin
  661. add esi , [ scr_adjust_width ]
  662. add edi , [ dest_adjust_width ]
  663. dec edx
  664. jnz ??fading_loop
  665. ret
  666. ;********************************************************************
  667. ;********************************************************************
  668. BF_Fading_Trans:
  669. mov ebx , eax ; width
  670. ; NOTE: the below calculation assumes a group of instructions is
  671. ; less than 256 bytes
  672. ; get length of the 32 groups of instructions
  673. lea ecx , [ ??fading_t_reference - ??fading_t_line ]
  674. shr ebx , 5 ; width / 32
  675. shr ecx , 5 ; length of instructions / 32
  676. and eax , 01fh ; mod of width / 32
  677. mul cl ; calc offset to start of group
  678. neg eax ; inverse of width
  679. mov [ loop_cnt ] , ebx ; save width / 32
  680. lea ecx , [ ??fading_t_reference + eax ]
  681. mov eax , 0
  682. mov [ jmp_loc ] , ecx
  683. ??fading_t_loop:
  684. mov ecx , [ loop_cnt ]
  685. mov [ StashECX ] , ecx ; preserve ecx for later
  686. mov ebx , [ FadingTable ] ; run color through fading table
  687. jmp [ jmp_loc ]
  688. ??fading_t_line_begin:
  689. mov [ StashECX ] , ecx ; preserve ecx for later
  690. ??fading_t_line:
  691. REPT 32
  692. local transp_pixel
  693. local fade_loop
  694. mov al , [ esi ]
  695. inc esi
  696. test al , al
  697. jz transp_pixel
  698. mov ecx , [ FadingNum ]
  699. fade_loop:
  700. mov al, [BYTE PTR ebx + eax]
  701. dec ecx
  702. jnz fade_loop
  703. mov [ edi ] , al
  704. transp_pixel:
  705. inc edi
  706. ENDM
  707. ??fading_t_reference:
  708. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  709. dec ecx
  710. jge ??fading_t_line_begin
  711. add esi , [ scr_adjust_width ]
  712. add edi , [ dest_adjust_width ]
  713. dec edx
  714. jnz ??fading_t_loop
  715. ret
  716. ;********************************************************************
  717. ;********************************************************************
  718. BF_Ghost_Fading:
  719. mov ebx , eax ; width
  720. ; NOTE: the below calculation assumes a group of instructions is
  721. ; less than 256 bytes
  722. ; get length of the 32 groups of instructions
  723. lea ecx , [ ??ghost_f_reference - ??ghost_f_line ]
  724. shr ebx , 5 ; width / 32
  725. shr ecx , 5 ; length of instructions / 32
  726. and eax , 01fh ; mod of width / 32
  727. mul cl ; calc offset to start of group
  728. neg eax ; inverse of width
  729. mov [ loop_cnt ] , ebx ; save width / 32
  730. lea ecx , [ ??ghost_f_reference + eax ]
  731. mov eax , 0
  732. mov [ jmp_loc ] , ecx
  733. ??ghost_f_loop:
  734. mov ecx , [ loop_cnt ]
  735. mov [ StashECX ] , ecx ; preserve ecx for later
  736. jmp [ jmp_loc ]
  737. ??ghost_f_line_begin:
  738. mov [ StashECX ] , ecx ; preserve ecx for later
  739. ??ghost_f_line:
  740. REPT 32
  741. local store_pixel
  742. local do_fading
  743. local fade_loop
  744. mov al , [ esi ]
  745. inc esi
  746. mov ebx , [ IsTranslucent ] ; is it a lucent color?
  747. mov bh , [ BYTE PTR ebx + eax ]
  748. cmp bh , 0ffh
  749. je do_fading
  750. and ebx , 0FF00h ; clear all of ebx except bh
  751. ; we have the index to the lation table
  752. ; ((_colour * 256) + dest colour)
  753. mov al , [ edi ] ; mov pixel at destination to al
  754. add ebx , [ Translucent ] ; get the ptr to it!
  755. ; Add the (_color * 256) of the lation equ.
  756. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  757. ; DRD jmp store_pixel
  758. do_fading:
  759. mov ebx , [ FadingTable ] ; run color through fading table
  760. mov ecx , [ FadingNum ]
  761. fade_loop:
  762. mov al, [BYTE PTR ebx + eax]
  763. dec ecx
  764. jnz fade_loop
  765. store_pixel:
  766. mov [ edi ] , al
  767. inc edi
  768. ENDM
  769. ??ghost_f_reference:
  770. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  771. dec ecx
  772. jge ??ghost_f_line_begin
  773. add esi , [ scr_adjust_width ]
  774. add edi , [ dest_adjust_width ]
  775. dec edx
  776. jnz ??ghost_f_loop
  777. ret
  778. ;********************************************************************
  779. ;********************************************************************
  780. BF_Ghost_Fading_Trans:
  781. mov ebx , eax ; width
  782. ; NOTE: the below calculation assumes a group of instructions is
  783. ; less than 256 bytes
  784. ; get length of the 32 groups of instructions
  785. lea ecx , [ ??ghost_f_t_reference - ??ghost_f_t_line ]
  786. shr ebx , 5 ; width / 32
  787. shr ecx , 5 ; length of instructions / 32
  788. and eax , 01fh ; mod of width / 32
  789. mul cl ; calc offset to start of group
  790. neg eax ; inverse of width
  791. mov [ loop_cnt ] , ebx ; save width / 32
  792. lea ecx , [ ??ghost_f_t_reference + eax ]
  793. mov eax , 0
  794. mov [ jmp_loc ] , ecx
  795. ??ghost_f_t_loop:
  796. mov ecx , [ loop_cnt ]
  797. mov [ StashECX ] , ecx ; preserve ecx for later
  798. jmp [ jmp_loc ]
  799. ??ghost_f_t_line_begin:
  800. mov [ StashECX ] , ecx ; preserve ecx for later
  801. ??ghost_f_t_line:
  802. REPT 32
  803. local transp_pixel
  804. local store_pixel
  805. local do_fading
  806. local fade_loop
  807. mov al , [ esi ]
  808. inc esi
  809. test al , al
  810. jz transp_pixel
  811. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  812. mov bh , [ BYTE PTR ebx + eax ]
  813. cmp bh , 0ffh
  814. je do_fading
  815. and ebx , 0FF00h ; clear all of ebx except bh
  816. ; we have the index to the translation table
  817. ; ((trans_colour * 256) + dest colour)
  818. mov al , [ edi ] ; mov pixel at destination to al
  819. add ebx , [ Translucent ] ; get the ptr to it!
  820. ; Add the (trans_color * 256) of the translation equ.
  821. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  822. ; DRD jmp store_pixel
  823. do_fading:
  824. mov ebx , [ FadingTable ] ; run color through fading table
  825. mov ecx , [ FadingNum ]
  826. fade_loop:
  827. mov al, [BYTE PTR ebx + eax]
  828. dec ecx
  829. jnz fade_loop
  830. store_pixel:
  831. mov [ edi ] , al
  832. transp_pixel:
  833. inc edi
  834. ENDM
  835. ??ghost_f_t_reference:
  836. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  837. dec ecx
  838. jge ??ghost_f_t_line_begin
  839. add esi , [ scr_adjust_width ]
  840. add edi , [ dest_adjust_width ]
  841. dec edx
  842. jnz ??ghost_f_t_loop
  843. ret
  844. ;********************************************************************
  845. ;********************************************************************
  846. BF_Predator:
  847. mov ebx , eax ; width
  848. ; NOTE: the below calculation assumes a group of instructions is
  849. ; less than 256 bytes
  850. ; get length of the 32 groups of instructions
  851. lea ecx , [ ??predator_reference - ??predator_line ]
  852. shr ebx , 5 ; width / 32
  853. shr ecx , 5 ; length of instructions / 32
  854. and eax , 01fh ; mod of width / 32
  855. mul cl ; calc offset to start of group
  856. neg eax ; inverse of width
  857. mov [ loop_cnt ] , ebx ; save width / 32
  858. lea ecx , [ ??predator_reference + eax ]
  859. mov eax , 0
  860. mov [ jmp_loc ] , ecx
  861. ??predator_loop:
  862. mov ecx , [ loop_cnt ]
  863. jmp [ jmp_loc ]
  864. ??predator_line:
  865. REPT 32
  866. local get_pred
  867. local skip_pixel
  868. mov al , [ esi ]
  869. inc esi
  870. mov ebx , [ BFPartialCount ]
  871. add ebx , [ BFPartialPred ]
  872. or bh , bh
  873. jnz get_pred ; is this a predator pixel?
  874. mov [ BFPartialCount ] , ebx
  875. jmp skip_pixel
  876. get_pred:
  877. xor bh , bh
  878. mov eax, [ BFPredOffset ]
  879. mov [ BFPartialCount ] , ebx
  880. add [ BYTE PTR BFPredOffset ] , 2
  881. movzx eax , [ WORD PTR BFPredTable + eax ]
  882. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  883. ; pick up a color offset a pseudo-
  884. ; random amount from the current
  885. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  886. ; xor bh , bh
  887. ; mov eax , [ BFPredValue ] ; pick up a color offset a pseudo-
  888. ; ; random amount from the current
  889. ; mov [ BFPartialCount ] , ebx
  890. ; mov al , [ edi + eax ] ; viewport address
  891. mov [ edi ] , al
  892. skip_pixel:
  893. inc edi
  894. ENDM
  895. ??predator_reference:
  896. dec ecx
  897. jge ??predator_line
  898. add esi , [ scr_adjust_width ]
  899. add edi , [ dest_adjust_width ]
  900. dec edx
  901. jnz ??predator_loop
  902. ret
  903. ;********************************************************************
  904. ;********************************************************************
  905. BF_Predator_Trans:
  906. mov ebx , eax ; width
  907. ; NOTE: the below calculation assumes a group of instructions is
  908. ; less than 256 bytes
  909. ; get length of the 32 groups of instructions
  910. lea ecx , [ ??predator_t_reference - ??predator_t_line ]
  911. shr ebx , 5 ; width / 32
  912. shr ecx , 5 ; length of instructions / 32
  913. and eax , 01fh ; mod of width / 32
  914. mul cl ; calc offset to start of group
  915. neg eax ; inverse of width
  916. mov [ loop_cnt ] , ebx ; save width / 32
  917. lea ecx , [ ??predator_t_reference + eax ]
  918. mov eax , 0
  919. mov [ jmp_loc ] , ecx
  920. ??predator_t_loop:
  921. mov ecx , [ loop_cnt ]
  922. jmp [ jmp_loc ]
  923. ??predator_t_line:
  924. REPT 32
  925. local trans_pixel
  926. local get_pred
  927. local store_pixel
  928. mov al , [ esi ]
  929. inc esi
  930. test al , al
  931. jz trans_pixel
  932. mov ebx , [ BFPartialCount ]
  933. add ebx , [ BFPartialPred ]
  934. or bh , bh
  935. jnz get_pred ; is this a predator pixel?
  936. mov [ BFPartialCount ] , ebx
  937. jmp store_pixel
  938. get_pred:
  939. xor bh , bh
  940. mov eax, [ BFPredOffset ]
  941. mov [ BFPartialCount ] , ebx
  942. add [ BYTE PTR BFPredOffset ] , 2
  943. movzx eax , [ WORD PTR BFPredTable + eax ]
  944. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  945. ; pick up a color offset a pseudo-
  946. ; random amount from the current
  947. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  948. store_pixel:
  949. mov [ edi ] , al
  950. trans_pixel:
  951. inc edi
  952. ENDM
  953. ??predator_t_reference:
  954. dec ecx
  955. jge ??predator_t_line
  956. add esi , [ scr_adjust_width ]
  957. add edi , [ dest_adjust_width ]
  958. dec edx
  959. jnz ??predator_t_loop
  960. ret
  961. ;********************************************************************
  962. ;********************************************************************
  963. BF_Predator_Ghost:
  964. mov ebx , eax ; width
  965. ; NOTE: the below calculation assumes a group of instructions is
  966. ; less than 256 bytes
  967. ; get length of the 32 groups of instructions
  968. lea ecx , [ ??predator_g_reference - ??predator_g_line ]
  969. shr ebx , 5 ; width / 32
  970. shr ecx , 5 ; length of instructions / 32
  971. and eax , 01fh ; mod of width / 32
  972. mul cl ; calc offset to start of group
  973. neg eax ; inverse of width
  974. mov [ loop_cnt ] , ebx ; save width / 32
  975. lea ecx , [ ??predator_g_reference + eax ]
  976. mov eax , 0
  977. mov [ jmp_loc ] , ecx
  978. ??predator_g_loop:
  979. mov ecx , [ loop_cnt ]
  980. jmp [ jmp_loc ]
  981. ??predator_g_line:
  982. REPT 32
  983. local get_pred
  984. local check_ghost
  985. local store_pixel
  986. mov al , [ esi ]
  987. mov ebx , [ BFPartialCount ]
  988. inc esi
  989. add ebx , [ BFPartialPred ]
  990. or bh , bh
  991. jnz get_pred ; is this a predator pixel?
  992. mov [ BFPartialCount ] , ebx
  993. jmp check_ghost
  994. get_pred:
  995. xor bh , bh
  996. mov eax, [ BFPredOffset ]
  997. mov [ BFPartialCount ] , ebx
  998. add [ BYTE PTR BFPredOffset ] , 2
  999. movzx eax , [ WORD PTR BFPredTable + eax ]
  1000. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1001. ; pick up a color offset a pseudo-
  1002. ; random amount from the current
  1003. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1004. check_ghost:
  1005. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  1006. mov bh , [ BYTE PTR ebx + eax ]
  1007. cmp bh , 0ffh
  1008. je store_pixel
  1009. and ebx , 0FF00h ; clear all of ebx except bh
  1010. ; we have the index to the translation table
  1011. ; ((trans_colour * 256) + dest colour)
  1012. mov al , [ edi ] ; mov pixel at destination to al
  1013. add ebx , [ Translucent ] ; get the ptr to it!
  1014. ; Add the (trans_color * 256) of the translation equ.
  1015. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  1016. store_pixel:
  1017. mov [ edi ] , al
  1018. inc edi
  1019. ENDM
  1020. ??predator_g_reference:
  1021. dec ecx
  1022. jge ??predator_g_line
  1023. add esi , [ scr_adjust_width ]
  1024. add edi , [ dest_adjust_width ]
  1025. dec edx
  1026. jnz ??predator_g_loop
  1027. ret
  1028. ;********************************************************************
  1029. ;********************************************************************
  1030. BF_Predator_Ghost_Trans:
  1031. mov ebx , eax ; width
  1032. ; NOTE: the below calculation assumes a group of instructions is
  1033. ; less than 256 bytes
  1034. ; get length of the 32 groups of instructions
  1035. lea ecx , [ ??predator_g_t_reference - ??predator_g_t_line ]
  1036. shr ebx , 5 ; width / 32
  1037. shr ecx , 5 ; length of instructions / 32
  1038. and eax , 01fh ; mod of width / 32
  1039. mul cl ; calc offset to start of group
  1040. neg eax ; inverse of width
  1041. mov [ loop_cnt ] , ebx ; save width / 32
  1042. lea ecx , [ ??predator_g_t_reference + eax ]
  1043. mov eax , 0
  1044. mov [ jmp_loc ] , ecx
  1045. ??predator_g_t_loop:
  1046. mov ecx , [ loop_cnt ]
  1047. jmp [ jmp_loc ]
  1048. ??predator_g_t_line:
  1049. REPT 32
  1050. local trans_pixel
  1051. local get_pred
  1052. local check_ghost
  1053. local store_pixel
  1054. mov al , [ esi ]
  1055. inc esi
  1056. test al , al
  1057. jz trans_pixel
  1058. mov ebx , [ BFPartialCount ]
  1059. add ebx , [ BFPartialPred ]
  1060. or bh , bh
  1061. jnz get_pred ; is this a predator pixel?
  1062. mov [ BFPartialCount ] , ebx
  1063. jmp check_ghost
  1064. get_pred:
  1065. xor bh , bh
  1066. mov eax, [ BFPredOffset ]
  1067. mov [ BFPartialCount ] , ebx
  1068. add [ BYTE PTR BFPredOffset ] , 2
  1069. movzx eax , [ WORD PTR BFPredTable + eax ]
  1070. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1071. ; pick up a color offset a pseudo-
  1072. ; random amount from the current
  1073. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1074. check_ghost:
  1075. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  1076. mov bh , [ BYTE PTR ebx + eax ]
  1077. cmp bh , 0ffh
  1078. je store_pixel
  1079. and ebx , 0FF00h ; clear all of ebx except bh
  1080. ; we have the index to the translation table
  1081. ; ((trans_colour * 256) + dest colour)
  1082. mov al , [ edi ] ; mov pixel at destination to al
  1083. add ebx , [ Translucent ] ; get the ptr to it!
  1084. ; Add the (trans_color * 256) of the translation equ.
  1085. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  1086. store_pixel:
  1087. mov [ edi ] , al
  1088. trans_pixel:
  1089. inc edi
  1090. ENDM
  1091. ??predator_g_t_reference:
  1092. dec ecx
  1093. jge ??predator_g_t_line
  1094. add esi , [ scr_adjust_width ]
  1095. add edi , [ dest_adjust_width ]
  1096. dec edx
  1097. jnz ??predator_g_t_loop
  1098. ret
  1099. ;********************************************************************
  1100. ;********************************************************************
  1101. BF_Predator_Fading:
  1102. mov ebx , eax ; width
  1103. ; NOTE: the below calculation assumes a group of instructions is
  1104. ; less than 256 bytes
  1105. ; get length of the 32 groups of instructions
  1106. lea ecx , [ ??predator_f_reference - ??predator_f_line ]
  1107. shr ebx , 5 ; width / 32
  1108. shr ecx , 5 ; length of instructions / 32
  1109. and eax , 01fh ; mod of width / 32
  1110. mul cl ; calc offset to start of group
  1111. neg eax ; inverse of width
  1112. mov [ loop_cnt ] , ebx ; save width / 32
  1113. lea ecx , [ ??predator_f_reference + eax ]
  1114. mov eax , 0
  1115. mov [ jmp_loc ] , ecx
  1116. ??predator_f_loop:
  1117. mov ecx , [ loop_cnt ]
  1118. mov [ StashECX ] , ecx ; preserve ecx for later
  1119. jmp [ jmp_loc ]
  1120. ??predator_f_line_begin:
  1121. mov [ StashECX ] , ecx ; preserve ecx for later
  1122. ??predator_f_line:
  1123. REPT 32
  1124. local get_pred
  1125. local do_fading
  1126. local fade_loop
  1127. mov al , [ esi ]
  1128. mov ebx , [ BFPartialCount ]
  1129. inc esi
  1130. add ebx , [ BFPartialPred ]
  1131. or bh , bh
  1132. jnz get_pred ; is this a predator pixel?
  1133. mov [ BFPartialCount ] , ebx
  1134. jmp do_fading
  1135. get_pred:
  1136. xor bh , bh
  1137. mov eax, [ BFPredOffset ]
  1138. mov [ BFPartialCount ] , ebx
  1139. add [ BYTE PTR BFPredOffset ] , 2
  1140. movzx eax , [ WORD PTR BFPredTable + eax ]
  1141. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1142. ; pick up a color offset a pseudo-
  1143. ; random amount from the current
  1144. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1145. do_fading:
  1146. mov ebx , [ FadingTable ] ; run color through fading table
  1147. mov ecx , [ FadingNum ]
  1148. fade_loop:
  1149. mov al, [BYTE PTR ebx + eax]
  1150. dec ecx
  1151. jnz fade_loop
  1152. mov [ edi ] , al
  1153. inc edi
  1154. ENDM
  1155. ??predator_f_reference:
  1156. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  1157. dec ecx
  1158. jge ??predator_f_line_begin
  1159. add esi , [ scr_adjust_width ]
  1160. add edi , [ dest_adjust_width ]
  1161. dec edx
  1162. jnz ??predator_f_loop
  1163. ret
  1164. ;********************************************************************
  1165. ;********************************************************************
  1166. BF_Predator_Fading_Trans:
  1167. mov ebx , eax ; width
  1168. ; NOTE: the below calculation assumes a group of instructions is
  1169. ; less than 256 bytes
  1170. ; get length of the 32 groups of instructions
  1171. lea ecx , [ ??predator_f_t_reference - ??predator_f_t_line ]
  1172. shr ebx , 5 ; width / 32
  1173. shr ecx , 5 ; length of instructions / 32
  1174. and eax , 01fh ; mod of width / 32
  1175. mul cl ; calc offset to start of group
  1176. neg eax ; inverse of width
  1177. mov [ loop_cnt ] , ebx ; save width / 32
  1178. lea ecx , [ ??predator_f_t_reference + eax ]
  1179. mov eax , 0
  1180. mov [ jmp_loc ] , ecx
  1181. ??predator_f_t_loop:
  1182. mov ecx , [ loop_cnt ]
  1183. mov [ StashECX ] , ecx ; preserve ecx for later
  1184. jmp [ jmp_loc ]
  1185. ??predator_f_t_line_begin:
  1186. mov [ StashECX ] , ecx ; preserve ecx for later
  1187. ??predator_f_t_line:
  1188. REPT 32
  1189. local trans_pixel
  1190. local get_pred
  1191. local do_fading
  1192. local fade_loop
  1193. mov al , [ esi ]
  1194. inc esi
  1195. test al , al
  1196. jz trans_pixel
  1197. mov ebx , [ BFPartialCount ]
  1198. add ebx , [ BFPartialPred ]
  1199. or bh , bh
  1200. jnz get_pred ; is this a predator pixel?
  1201. mov [ BFPartialCount ] , ebx
  1202. jmp do_fading
  1203. get_pred:
  1204. xor bh , bh
  1205. mov eax, [ BFPredOffset ]
  1206. mov [ BFPartialCount ] , ebx
  1207. add [ BYTE PTR BFPredOffset ] , 2
  1208. movzx eax , [ WORD PTR BFPredTable + eax ]
  1209. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1210. ; pick up a color offset a pseudo-
  1211. ; random amount from the current
  1212. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1213. do_fading:
  1214. mov ebx , [ FadingTable ] ; run color through fading table
  1215. mov ecx , [ FadingNum ]
  1216. fade_loop:
  1217. mov al, [BYTE PTR ebx + eax]
  1218. dec ecx
  1219. jnz fade_loop
  1220. mov [ edi ] , al
  1221. trans_pixel:
  1222. inc edi
  1223. ENDM
  1224. ??predator_f_t_reference:
  1225. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  1226. dec ecx
  1227. jge ??predator_f_t_line_begin
  1228. add esi , [ scr_adjust_width ]
  1229. add edi , [ dest_adjust_width ]
  1230. dec edx
  1231. jnz ??predator_f_t_loop
  1232. ret
  1233. ;********************************************************************
  1234. ;********************************************************************
  1235. BF_Predator_Ghost_Fading:
  1236. mov ebx , eax ; width
  1237. ; NOTE: the below calculation assumes a group of instructions is
  1238. ; less than 256 bytes
  1239. ; get length of the 32 groups of instructions
  1240. lea ecx , [ ??predator_g_f_reference - ??predator_g_f_line ]
  1241. shr ebx , 5 ; width / 32
  1242. shr ecx , 5 ; length of instructions / 32
  1243. and eax , 01fh ; mod of width / 32
  1244. mul cl ; calc offset to start of group
  1245. neg eax ; inverse of width
  1246. mov [ loop_cnt ] , ebx ; save width / 32
  1247. lea ecx , [ ??predator_g_f_reference + eax ]
  1248. mov eax , 0
  1249. mov [ jmp_loc ] , ecx
  1250. ??predator_g_f_loop:
  1251. mov ecx , [ loop_cnt ]
  1252. mov [ StashECX ] , ecx ; preserve ecx for later
  1253. jmp [ jmp_loc ]
  1254. ??predator_g_f_line_begin:
  1255. mov [ StashECX ] , ecx ; preserve ecx for later
  1256. ??predator_g_f_line:
  1257. REPT 32
  1258. local get_pred
  1259. local check_ghost
  1260. local store_pixel
  1261. local do_fading
  1262. local fade_loop
  1263. mov al , [ esi ]
  1264. mov ebx , [ BFPartialCount ]
  1265. inc esi
  1266. add ebx , [ BFPartialPred ]
  1267. or bh , bh
  1268. jnz get_pred ; is this a predator pixel?
  1269. mov [ BFPartialCount ] , ebx
  1270. jmp check_ghost
  1271. get_pred:
  1272. xor bh , bh
  1273. mov eax, [ BFPredOffset ]
  1274. mov [ BFPartialCount ] , ebx
  1275. add [ BYTE PTR BFPredOffset ] , 2
  1276. movzx eax , [ WORD PTR BFPredTable + eax ]
  1277. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1278. ; pick up a color offset a pseudo-
  1279. ; random amount from the current
  1280. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1281. check_ghost:
  1282. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  1283. mov bh , [ BYTE PTR ebx + eax ]
  1284. cmp bh , 0ffh
  1285. je do_fading
  1286. and ebx , 0FF00h ; clear all of ebx except bh
  1287. ; we have the index to the translation table
  1288. ; ((trans_colour * 256) + dest colour)
  1289. mov al , [ edi ] ; mov pixel at destination to al
  1290. add ebx , [ Translucent ] ; get the ptr to it!
  1291. ; Add the (trans_color * 256) of the translation equ.
  1292. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  1293. ; DRD jmp store_pixel
  1294. do_fading:
  1295. mov ebx , [ FadingTable ] ; run color through fading table
  1296. mov ecx , [ FadingNum ]
  1297. fade_loop:
  1298. mov al, [BYTE PTR ebx + eax]
  1299. dec ecx
  1300. jnz fade_loop
  1301. store_pixel:
  1302. mov [ edi ] , al
  1303. inc edi
  1304. ENDM
  1305. ??predator_g_f_reference:
  1306. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  1307. dec ecx
  1308. jge ??predator_g_f_line_begin
  1309. add esi , [ scr_adjust_width ]
  1310. add edi , [ dest_adjust_width ]
  1311. dec edx
  1312. jnz ??predator_g_f_loop
  1313. ret
  1314. ;********************************************************************
  1315. ;********************************************************************
  1316. BF_Predator_Ghost_Fading_Trans:
  1317. mov ebx , eax ; width
  1318. ; NOTE: the below calculation assumes a group of instructions is
  1319. ; less than 256 bytes
  1320. ; get length of the 32 groups of instructions
  1321. lea ecx , [ ??predator_g_f_t_reference - ??predator_g_f_t_line ]
  1322. shr ebx , 5 ; width / 32
  1323. shr ecx , 5 ; length of instructions / 32
  1324. and eax , 01fh ; mod of width / 32
  1325. mul cl ; calc offset to start of group
  1326. neg eax ; inverse of width
  1327. mov [ loop_cnt ] , ebx ; save width / 32
  1328. lea ecx , [ ??predator_g_f_t_reference + eax ]
  1329. mov eax , 0
  1330. mov [ jmp_loc ] , ecx
  1331. ??predator_g_f_t_loop:
  1332. mov ecx , [ loop_cnt ]
  1333. mov [ StashECX ] , ecx ; preserve ecx for later
  1334. jmp [ jmp_loc ]
  1335. ??predator_g_f_t_line_begin:
  1336. mov [ StashECX ] , ecx ; preserve ecx for later
  1337. ??predator_g_f_t_line:
  1338. REPT 32
  1339. local trans_pixel
  1340. local get_pred
  1341. local check_ghost
  1342. local store_pixel
  1343. local do_fading
  1344. local fade_loop
  1345. mov al , [ esi ]
  1346. inc esi
  1347. test al , al
  1348. jz trans_pixel
  1349. mov ebx , [ BFPartialCount ]
  1350. add ebx , [ BFPartialPred ]
  1351. or bh , bh
  1352. jnz get_pred ; is this a predator pixel?
  1353. mov [ BFPartialCount ] , ebx
  1354. jmp check_ghost
  1355. get_pred:
  1356. xor bh , bh
  1357. mov eax, [ BFPredOffset ]
  1358. mov [ BFPartialCount ] , ebx
  1359. add [ BYTE PTR BFPredOffset ] , 2
  1360. movzx eax , [ WORD PTR BFPredTable + eax ]
  1361. and [ BYTE PTR BFPredOffset ] , PRED_MASK
  1362. ; pick up a color offset a pseudo-
  1363. ; random amount from the current
  1364. movzx eax , [ BYTE PTR edi + eax ] ; viewport address
  1365. check_ghost:
  1366. mov ebx , [ IsTranslucent ] ; is it a translucent color?
  1367. mov bh , [ BYTE PTR ebx + eax ]
  1368. cmp bh , 0ffh
  1369. je do_fading
  1370. and ebx , 0FF00h ; clear all of ebx except bh
  1371. ; we have the index to the translation table
  1372. ; ((trans_colour * 256) + dest colour)
  1373. mov al , [ edi ] ; mov pixel at destination to al
  1374. add ebx , [ Translucent ] ; get the ptr to it!
  1375. ; Add the (trans_color * 256) of the translation equ.
  1376. mov al , [ BYTE PTR ebx + eax ] ; get new pixel in al
  1377. ; DRD jmp store_pixel
  1378. do_fading:
  1379. mov ebx , [ FadingTable ] ; run color through fading table
  1380. mov ecx , [ FadingNum ]
  1381. fade_loop:
  1382. mov al, [BYTE PTR ebx + eax]
  1383. dec ecx
  1384. jnz fade_loop
  1385. store_pixel:
  1386. mov [ edi ] , al
  1387. trans_pixel:
  1388. inc edi
  1389. ENDM
  1390. ??predator_g_f_t_reference:
  1391. mov ecx , [ StashECX ] ; restore ecx for main draw loop
  1392. dec ecx
  1393. jge ??predator_g_f_t_line_begin
  1394. add esi , [ scr_adjust_width ]
  1395. add edi , [ dest_adjust_width ]
  1396. dec edx
  1397. jnz ??predator_g_f_t_loop
  1398. ret
  1399. ;********************************************************************
  1400. ;********************************************************************
  1401. Not_Supported:
  1402. ret
  1403. ENDP Buffer_Frame_To_Page
  1404. END
  1405. ;***************************************************************************
  1406. ;** 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 **
  1407. ;***************************************************************************
  1408. ;* *
  1409. ;* Project Name : Westwood Library *
  1410. ;* *
  1411. ;* File Name : KEYFBUFF.ASM *
  1412. ;* *
  1413. ;* Programmer : Phil W. Gorrow *
  1414. ;* *
  1415. ;* Start Date : July 16, 1992 *
  1416. ;* *
  1417. ;* Last Update : October 2, 1994 [JLB] *
  1418. ;* *
  1419. ;*-------------------------------------------------------------------------*
  1420. ;* Functions: *
  1421. ;* BUFFER_FRAME_TO_LOGICPAGE -- *
  1422. ;* Normal_Draw -- Function that writes a normal pixel line *
  1423. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  1424. IDEAL
  1425. P386
  1426. IDEAL_MODE EQU 1
  1427. INCLUDE "wwlib.i"
  1428. ;-------------------------------------------------------------------
  1429. ; Extern all the library variables that this module requires
  1430. ;-------------------------------------------------------------------
  1431. EXTRN C MaskPage:WORD
  1432. EXTRN C BackGroundPage:WORD
  1433. ;-------------------------------------------------------------------
  1434. ; Define all the equates that this module requires
  1435. ;-------------------------------------------------------------------
  1436. WIN_X EQU 0 ; offset for the x coordinate
  1437. WIN_Y EQU 2 ; offset for the y coordinate
  1438. WIN_WIDTH EQU 4 ; offset for the window width
  1439. WIN_HEIGHT EQU 6 ; offset for the window height
  1440. BYTESPERROW EQU 320 ; number of bytes per row
  1441. FLAG_NORMAL EQU 0 ; flag for normal draw
  1442. FLAG_GHOST EQU 1 ; This flag enables the ghost
  1443. FLAG_PRIORITY_TRANS EQU 2 ; flag for priority and transparent
  1444. FLAG_TRANS EQU 4 ; flag for transparent draw
  1445. FLAG_PRIORITY EQU 8 ; flag for priority draw
  1446. ; fx on the above flags
  1447. FLAG_MASK EQU 15 ; used to and of uneeded bits
  1448. SHAPE_NORMAL EQU 0000h ; Standard shape.
  1449. ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally.
  1450. ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically.
  1451. ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y)
  1452. SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute.
  1453. SHAPE_CENTER EQU 0020h ; Coordinates are based on shape's center point.
  1454. SHAPE_TRANS EQU 0040h ; has transparency
  1455. ;SHAPE_FADING EQU 0100h ; Fading effect active (VOID * fading_table, WORD fading_num).
  1456. ;SHAPE_PREDATOR EQU 0200h ; Transparent warping effect.
  1457. ;SHAPE_COMPACT EQU 0400h ; Never use this bit.
  1458. SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing.
  1459. SHAPE_GHOST EQU 1000h ; Transluscent table process.
  1460. ;SHAPE_SHADOW EQU 2000h ; ????
  1461. ;SHAPE_PARTIAL EQU 4000h ; ????
  1462. ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors (VOID * color_table).
  1463. ; MBL MOD 12.1.92
  1464. CLEAR_NON_WALK_BIT_AND_SCALE_BITS EQU 7 ; Makes it one AND per pixel in Priority_Trans display
  1465. CLEAR_NON_WALK_BIT EQU 7fh ; and with 0111-1111 to clear non-walkable high bit
  1466. CLEAR_SCALE_BITS EQU 87h ; and with 1000-0111 to clear scaling id bits
  1467. NON_WALKABLE_BIT EQU 80h ; and with 1000-0000 to clear all but non-walkable bit
  1468. ; END MBL MOD
  1469. CODESEG
  1470. ; 1 = GHOST (all odd entrys are prefixed with Ghost_)
  1471. ; 2 = BLAAAH
  1472. ; 4 = Trans (prfx)
  1473. ; 8 = Prior (prfx)
  1474. ;---------------------------------------------------------------------------
  1475. ; Define the table of different line draw types
  1476. ;---------------------------------------------------------------------------
  1477. LineTable DW WSA_Normal_Draw ;0
  1478. DW Ghost_Normal_Draw ;1
  1479. DW 0 ;2
  1480. DW 0 ;3
  1481. DW Transparent_Draw ;4
  1482. DW Ghost_Transparent_Draw ;5
  1483. DW 0 ;6
  1484. DW 0 ;7
  1485. DW Priority_Draw ;8
  1486. DW Ghost_Priority_Draw ;9
  1487. DW 0 ;10
  1488. DW 0 ;11
  1489. DW Priority_Transparent_Draw ;12
  1490. DW Ghost_Priority_Transparent_Draw ;13
  1491. DW 0 ;14
  1492. DW 0 ;15
  1493. ;***************************************************************************
  1494. ;* BUFFER_FRAME_TO_LOGICPAGE -- *
  1495. ;* *
  1496. ;* *
  1497. ;* *
  1498. ;* INPUT: *
  1499. ;* *
  1500. ;* OUTPUT: *
  1501. ;* *
  1502. ;* WARNINGS: *
  1503. ;* *
  1504. ;* HISTORY: *
  1505. ;* 07/16/1992 PWG : Created. *
  1506. ;*=========================================================================*
  1507. PUBLIC C Buffer_Frame_To_LogicPage
  1508. PROC C Buffer_Frame_To_LogicPage FAR USES ax bx ecx dx ds esi es edi
  1509. ;-------------------------------------------------------------------
  1510. ; Define the arguements that our program takes.
  1511. ;-------------------------------------------------------------------
  1512. ARG x_pixel:WORD ; x pixel position to draw at
  1513. ARG y_pixel:WORD ; y pixel position to draw at
  1514. ARG pixel_w:WORD ; pixel width of draw region
  1515. ARG pixel_h:WORD ; pixel height of draw region
  1516. ARG win:WORD ; window to clip around
  1517. ARG flags:WORD ; flags that this routine will take
  1518. ARG buffer:DWORD ; pointer to the buffer with data
  1519. ARG args:WORD
  1520. ;-------------------------------------------------------------------
  1521. ; Define the local variables that our program uses
  1522. ;-------------------------------------------------------------------
  1523. LOCAL IsTranslucent:DWORD ; ptr to the is_translucent table
  1524. LOCAL Translucent:DWORD ; ptr to the actual translucent table
  1525. LOCAL win_x1:WORD ; clip window left x pixel position
  1526. LOCAL win_x2:WORD ; clip window right x pixel position
  1527. LOCAL win_y1:WORD ; clip window top y pixel position
  1528. LOCAL win_y2:WORD ; clip window bottom y pixel position
  1529. LOCAL clipleft:WORD ; number of pixels to clip on left
  1530. LOCAL clipright:WORD ; number of pixels to clip on right
  1531. LOCAL nextline:WORD ; offset to the next line
  1532. LOCAL putmiddle:WORD ; routine to call to put the middle
  1533. LOCAL maskpage:WORD ; location of the depth masks
  1534. LOCAL background:WORD ; location of the background data
  1535. LOCAL jflags:WORD ; location of the background data
  1536. LOCAL priority:BYTE ; the priority level of the back
  1537. push fs
  1538. xor ecx,ecx
  1539. ;--------------------------------------------------------------------
  1540. ; Check to see if we have supplied any GHOST tables.
  1541. ;--------------------------------------------------------------------
  1542. push di
  1543. mov di,6
  1544. mov [jflags],0
  1545. ??ghost:
  1546. test [flags],SHAPE_GHOST ; are we ghosting this shape
  1547. jz short ??no_ghost ; if not then skip and do more
  1548. or [jflags],FLAG_GHOST
  1549. les ax,[DWORD PTR buffer + di]
  1550. ; get the "are we really translucent?" table
  1551. mov [WORD PTR IsTranslucent],ax
  1552. mov [WORD PTR IsTranslucent + 2],es
  1553. add ax,0100h ; add to offset for tables
  1554. ; get the "ok we are translucent!!" table
  1555. mov [WORD PTR Translucent],ax
  1556. mov [WORD PTR Translucent + 2],es
  1557. add di,4
  1558. ??no_ghost:
  1559. pop di
  1560. ;-------------------------------------------------------------------
  1561. ; See if we need to center the frame
  1562. ;-------------------------------------------------------------------
  1563. test [flags],SHAPE_CENTER ; does this need to be centered?
  1564. je short ??no_centering ; if not the skip over this stuff
  1565. mov ax,[pixel_w]
  1566. mov bx,[pixel_h]
  1567. sar ax,1
  1568. sar bx,1
  1569. sub [x_pixel],ax
  1570. sub [y_pixel],bx
  1571. ??no_centering:
  1572. mov ax,[flags]
  1573. and ax,SHAPE_PRIORITY+SHAPE_TRANS
  1574. cmp ax,SHAPE_PRIORITY+SHAPE_TRANS
  1575. jne short ??test_trans
  1576. or [jflags],FLAG_PRIORITY_TRANS
  1577. jmp short ??priority
  1578. ;-------------------------------------------------------------------
  1579. ; Get the trans information if we need to get it
  1580. ;-------------------------------------------------------------------
  1581. ??test_trans:
  1582. test [flags],SHAPE_TRANS ; does this draw use transparencies?
  1583. je short ??test_priority ; if not the skip over this junk
  1584. or [jflags],FLAG_TRANS
  1585. ??test_priority:
  1586. ;-------------------------------------------------------------------
  1587. ; Get the priority information if we need to get it
  1588. ;-------------------------------------------------------------------
  1589. test [flags],SHAPE_PRIORITY ; does this draw use priorities?
  1590. je short ??no_priority ; if not the skip over this junk
  1591. or [jflags],FLAG_PRIORITY
  1592. ??priority:
  1593. mov ax,[BackGroundPage] ; get the background page from ds
  1594. mov [background],ax ; and store it on the stack
  1595. mov ax,[MaskPage] ; get the mask page from ds
  1596. mov [maskpage],ax ; and store it on the stack
  1597. mov ax,[WORD PTR buffer + 4]; get the priority level from args
  1598. mov [priority],al ; and store it in a local
  1599. ;-------------------------------------------------------------------
  1600. ; Get the draw routine that we are going to draw with
  1601. ;-------------------------------------------------------------------
  1602. ??no_priority:
  1603. ; mov bx,[flags] ; load in the current flags byte
  1604. ; and bx,FLAG_MASK ; prevent lockup on bad value
  1605. mov bx,[jflags] ; load in the jump table flags
  1606. shl bx,1
  1607. mov ax,[WORD PTR LineTable + bx] ; get the offset of the skip table
  1608. mov [putmiddle],ax ; store off the new offset
  1609. ;-------------------------------------------------------------------
  1610. ; Get a pointer to the logic page to where we will draw our buffer
  1611. ;-------------------------------------------------------------------
  1612. push [LogicPage] ; push the current logic page
  1613. call FAR PTR Get_Page ; get the physical page address
  1614. add sp,2 ; pull the parameter from the stack
  1615. mov es,dx ; store the address in the dest
  1616. ;--------------------------------------------------------------------
  1617. ; Point DI to the beginning of the window that we need to look at.
  1618. ; that way we can access all of the info through di.
  1619. ;--------------------------------------------------------------------
  1620. mov si,OFFSET WindowList ; get the offset of the window list
  1621. mov cl,4 ; shift 3 times = multiply by 16
  1622. mov ax,[win] ; get the window number we are using
  1623. shl ax,cl ; each window is 8 words long
  1624. add si,ax ; add that into the offset of window
  1625. ;--------------------------------------------------------------------
  1626. ; Place all the clipping values on the stack so our function will
  1627. ; be truly re-entrant and will not need to shadow these values.
  1628. ;--------------------------------------------------------------------
  1629. mov cl,3 ; to convert x to pixel mult by 8
  1630. mov ax,[si + WIN_X] ; get the left clip position
  1631. shl ax,cl ; convert to a pixel x position
  1632. mov [win_x1],ax ; store the left edge of window
  1633. mov [win_x2],ax
  1634. mov ax,[si + WIN_WIDTH] ; get the width of the window
  1635. shl ax,cl ; convert to a pixel width
  1636. add [win_x2],ax ; add to get the right window edge
  1637. mov ax,[si + WIN_Y] ; get the win y coordinate to clip
  1638. mov [win_y1],ax ; and save it onto the stack
  1639. add ax,[si + WIN_HEIGHT] ; calculate the bottom win y coord
  1640. mov [win_y2],ax ; and save it onto the stack
  1641. test [flags],SHAPE_WIN_REL ; is this window relative?
  1642. je short ??get_buffer ; if not the skip over
  1643. mov ax,[win_x1] ; get left edge of window
  1644. add [x_pixel],ax ; add to x pixel position
  1645. mov ax,[win_y1] ; get top edge of window
  1646. add [y_pixel],ax ; add to y pixel position
  1647. ;--------------------------------------------------------------------
  1648. ; Get a pointer to the source buffer so we can handle the clipping
  1649. ;--------------------------------------------------------------------
  1650. ??get_buffer:
  1651. lds si,[buffer] ; get a pointer to the buffer
  1652. ;--------------------------------------------------------------------
  1653. ; Check the top of our shape and clip any lines that are necessary
  1654. ;--------------------------------------------------------------------
  1655. mov ax,[y_pixel] ; get the y_pixel draw position
  1656. sub ax,[win_y1] ; subtract out the window y top
  1657. jns short ??check_bottom ; skip if y below window top
  1658. add ax,[pixel_h] ; add in the height of the region
  1659. jg short ??clip_top ; if positive then clip top lines
  1660. ??jump_exit:
  1661. jmp ??exit ; otherwise completely clipped
  1662. ??clip_top:
  1663. xchg [pixel_h],ax
  1664. sub ax,[pixel_h]
  1665. add [y_pixel],ax
  1666. mul [pixel_w] ; convert to number of bytes to skip
  1667. add si,ax ; skip past the necessary bytes
  1668. ;--------------------------------------------------------------------
  1669. ; Check the bottom of our shape and clip it if necessary
  1670. ;--------------------------------------------------------------------
  1671. ??check_bottom:
  1672. mov ax,[win_y2] ; get the bottom y of the window
  1673. sub ax,[y_pixel] ; subtract of the y to draw at
  1674. js ??jump_exit ; if its signed then nothing to draw
  1675. jz ??jump_exit ; if its zero then nothing to draw
  1676. cmp ax,[pixel_h] ; if more room to draw then height
  1677. jae short ??clip_x_left ; then go check the left clip
  1678. mov [pixel_h],ax ; clip all but amount that will fit
  1679. ??clip_x_left:
  1680. mov [clipleft],0 ; clear clip on left of region
  1681. mov ax,[x_pixel] ; get the pixel x of draw region
  1682. sub ax,[win_x1] ; pull out the window coordinate
  1683. jns short ??clip_x_right
  1684. neg ax ; negate to get amnt to skip in buf
  1685. mov [clipleft],ax ; store it in the left clip info
  1686. add [x_pixel],ax ; move to the edge of the window
  1687. sub [pixel_w],ax ; pull it out of the pixel width
  1688. ??clip_x_right:
  1689. mov [clipright],0 ; clear clip on right of region
  1690. mov ax,[win_x2] ; get the window x of clip region
  1691. sub ax,[x_pixel] ; subtract the draw edge of region
  1692. js ??jump_exit ; if its negative then get out
  1693. jz ??jump_exit ; if its zero then get out
  1694. cmp ax,[pixel_w] ; is space available larger than w
  1695. jae short ??draw_prep ; if so then go get drawing
  1696. xchg [pixel_w],ax ; amt to draw in pixel_w (wid in ax)
  1697. sub ax,[pixel_w] ; pull out the amount to draw
  1698. mov [clipright],ax ; this is the amount to clip on right
  1699. ??draw_prep:
  1700. push si ; save off source pos in buffer
  1701. push ds ; both offset and segment
  1702. mov ax,@data
  1703. mov ds,ax
  1704. mov bx,[y_pixel]
  1705. shl bx,1 ; shift left by 1 for word table look
  1706. lds si,[YTable] ; get the address of the ytable
  1707. mov di,[ds:si+bx] ; look up the multiplied value
  1708. pop ds ; restore source pos in buffer
  1709. pop si ; both offset and segment
  1710. add di,[x_pixel] ; add in the x pixel position
  1711. mov [nextline],di ; save it off in the next line
  1712. ;--------------------------------------------------------------------
  1713. ; Now determine the type of the shape and process it in the proper
  1714. ; way.
  1715. ;--------------------------------------------------------------------
  1716. mov dx,[pixel_h]
  1717. ; Check to see if the WSA is the screen width and there is no
  1718. ; clipping. In this case, then a special single call to the
  1719. ; line processing routine is possible.
  1720. mov ax,[clipleft]
  1721. add ax,[clipright]
  1722. jne short ??top_of_loop
  1723. cmp [pixel_w],BYTESPERROW
  1724. jne short ??top_of_loop
  1725. ;------------------------------------
  1726. ; The width of the WSA is the screen width, so just process as
  1727. ; one large WSA line.
  1728. mov ax,BYTESPERROW
  1729. imul dx
  1730. mov cx,ax
  1731. call [putmiddle]
  1732. jmp short ??exit
  1733. ;------------------------------------
  1734. ; Process line by line.
  1735. ??top_of_loop:
  1736. add si,[clipleft] ; skip whats necessary on left edge
  1737. mov cx,[pixel_w] ; get the width we need to draw
  1738. ; Copy the source to the destination as appropriate. This routine can
  1739. ; trash AX, BX, CX, and DI. It must properly modify SI to point one byte past
  1740. ; the end of the data.
  1741. call [putmiddle]
  1742. add si,[clipright] ; skip past the left clip
  1743. add [nextline],BYTESPERROW
  1744. mov di,[nextline]
  1745. dec dx
  1746. jnz ??top_of_loop
  1747. ??exit:
  1748. pop fs
  1749. ret
  1750. ENDP
  1751. ;***************************************************************************
  1752. ;* NORMAL_DRAW -- Function that writes a normal pixel line *
  1753. ;* *
  1754. ;* INPUT: cx - number of pixels to write *
  1755. ;* ds:si - buffer which holds the pixels to write *
  1756. ;* es:di - place to put the pixels we are writing *
  1757. ;* *
  1758. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  1759. ;* es:di - points to next pixel past last pixel written *
  1760. ;* *
  1761. ;* WARNINGS: none *
  1762. ;* *
  1763. ;* HISTORY: *
  1764. ;* 07/17/1992 PWG : Created. *
  1765. ;*=========================================================================*
  1766. PROC NOLANGUAGE WSA_Normal_Draw NEAR
  1767. IF 1
  1768. ; This version is marginally faster than the later version.
  1769. mov ax,cx
  1770. shr cx,2
  1771. rep movsd
  1772. and ax,011b
  1773. mov cx,ax
  1774. shr cx,1
  1775. rep movsw
  1776. adc cx,cx
  1777. rep movsb
  1778. ret
  1779. ELSE
  1780. shr cx,1 ; convert to words (odd pix in carry)
  1781. rep movsw ; write out the needed words
  1782. adc cx,0 ; add the carry into cx
  1783. rep movsb ; write out the odd byte if any
  1784. ret
  1785. ENDIF
  1786. ENDP
  1787. ;***************************************************************************
  1788. ;* TRANSPARENT_DRAW -- Function that writes a transparent pixel line *
  1789. ;* *
  1790. ;* INPUT: cx - number of pixels to write *
  1791. ;* ds:si - buffer which holds the pixels to write *
  1792. ;* es:di - place to put the pixels we are writing *
  1793. ;* *
  1794. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  1795. ;* es:di - points to next pixel past last pixel written *
  1796. ;* *
  1797. ;* WARNINGS: none *
  1798. ;* *
  1799. ;* HISTORY: *
  1800. ;* 07/17/1992 PWG : Created. *
  1801. ;* 10/02/1994 JLB : Optimized for 250% speed improvement. *
  1802. ;*=========================================================================*
  1803. PROC NOLANGUAGE Transparent_Draw NEAR
  1804. IF 1
  1805. ; Preserve DX since it is used as a scratch register.
  1806. push dx
  1807. ??loop:
  1808. ; Swap DS:SI and ES:DI back in preparation for the REP SCASB
  1809. ; instruction.
  1810. xchg di,si
  1811. mov dx,es
  1812. mov ax,ds
  1813. mov ds,dx
  1814. mov es,ax
  1815. ; Remember the bytes remaining in order to calculate the position
  1816. ; of the scan when it stops.
  1817. mov bx,cx
  1818. ; Scan looking for a non-zero value in the source buffer.
  1819. xor al,al
  1820. repe scasb
  1821. ; When the loop ends, if the EQ flag is set then the scanning is
  1822. ; complete. Jump to the end of the routine in order to fixup the
  1823. ; pointers.
  1824. je short ??fini
  1825. ; Advance the destination pointer by the amount necessary to match
  1826. ; the source movement. DS:SI points to where data should be written.
  1827. add si,bx
  1828. inc cx ; SCASB leaves CX one too low, fix it.
  1829. dec di ; SCASB leaves DI one byte too far, fix it.
  1830. sub si,cx
  1831. ; Scan for the duration of non-zero pixels. This yields a count which
  1832. ; is used to copy the source data to the destination. Preserve DI.
  1833. mov dx,di
  1834. mov bx,cx
  1835. repne scasb
  1836. mov di,dx
  1837. ; Set BX to equal the number of bytes to copy from source to dest.
  1838. inc cx ; SCASB leaves CX one too low, fix it.
  1839. sub bx,cx
  1840. ; Move the data from ES:DI to DS:SI for BX bytes.
  1841. xchg cx,bx ; Make CX=bytes to move, BX=bytes remaining.
  1842. ; Swap DS:SI and ES:DI in preparation for the REP MOV instruction.
  1843. xchg di,si
  1844. mov dx,es
  1845. mov ax,ds
  1846. mov ds,dx
  1847. mov es,ax
  1848. ; Move the data from source to dest. First try to move double
  1849. ; words. Then copy the remainder bytes (if any). Putting jumps in
  1850. ; this section doesn't result in any savings -- oh well.
  1851. mov ax,cx
  1852. shr cx,2
  1853. rep movsd
  1854. and ax,0011b
  1855. mov cx,ax
  1856. shr cx,1
  1857. rep movsw
  1858. adc cx,cx
  1859. rep movsb
  1860. ; Restore CX with the remaining bytes to process.
  1861. mov cx,bx
  1862. ; If there are more bytes to process, then loop back.
  1863. or cx,cx
  1864. jne short ??loop
  1865. ??fini:
  1866. ; Swap ES:DI and DS:SI back to original orientation.
  1867. mov ax,ds
  1868. mov bx,es
  1869. mov es,ax
  1870. mov ds,bx
  1871. xchg di,si
  1872. ; Restore DX and return.
  1873. pop dx
  1874. ret
  1875. ELSE
  1876. ??loop_top:
  1877. lodsb
  1878. or al,al
  1879. jz short ??skip
  1880. mov [es:di],al ; store the pixel to the screen
  1881. ??skip:
  1882. inc di
  1883. loop ??loop_top
  1884. ret
  1885. ENDIF
  1886. ENDP
  1887. ;***************************************************************************
  1888. ;* PRIORITY_DRAW -- Function that writes a pixels if they are in front of *
  1889. ;* the given plate. *
  1890. ;* *
  1891. ;* INPUT: cx - number of pixels to write *
  1892. ;* ds:si - buffer which holds the pixels to write *
  1893. ;* es:di - place to put the pixels we are writing *
  1894. ;* *
  1895. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  1896. ;* es:di - points to next pixel past last pixel written *
  1897. ;* *
  1898. ;* WARNINGS: none *
  1899. ;* *
  1900. ;* HISTORY: *
  1901. ;* 07/17/1992 PWG : Created. *
  1902. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  1903. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  1904. ;*=========================================================================*
  1905. PROC NOLANGUAGE Priority_Draw NEAR
  1906. mov fs,[background] ; get the SEG of the background page
  1907. mov gs,[maskpage] ; get the SEG of the mask info
  1908. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  1909. ??loop_top:
  1910. lodsb ; get the pixel to draw on the screen
  1911. ; get the mask byte for our pixel
  1912. mov bl,[ds:di]
  1913. ; get rid of non-walkable bit and
  1914. ; get rid of scaling id bits
  1915. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  1916. cmp ah,bl ; are we more toward the front?
  1917. jge short ??out_pixel ; if so then write the pixel
  1918. mov al,[fs:di] ; get the pixel to write
  1919. ??out_pixel:
  1920. stosb ; write the pixel and inc the DI
  1921. loop ??loop_top
  1922. ret
  1923. ENDP
  1924. ;***************************************************************************
  1925. ;* PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they are *
  1926. ;* in front of the given plate. It also deals with *
  1927. ;* transparent pixels. *
  1928. ;* *
  1929. ;* INPUT: cx - number of pixels to write *
  1930. ;* ds:si - buffer which holds the pixels to write *
  1931. ;* es:di - place to put the pixels we are writing *
  1932. ;* *
  1933. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  1934. ;* es:di - points to next pixel past last pixel written *
  1935. ;* *
  1936. ;* WARNINGS: none *
  1937. ;* *
  1938. ;* HISTORY: *
  1939. ;* 07/17/1992 PWG : Created. *
  1940. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  1941. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  1942. ;*=========================================================================*
  1943. PROC NOLANGUAGE Priority_Transparent_Draw NEAR
  1944. mov fs,[background] ; get the SEG of the background page
  1945. mov gs,[maskpage] ; get the SEG of the mask info
  1946. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  1947. ??loop_top:
  1948. lodsb ; get the pixel on the screen
  1949. or al,al ; check to see if al is transparent
  1950. je short ??write_back ; if it is go write background
  1951. mov bl,[gs:di] ; get the mask byte for our pixel
  1952. ; get rid of non-walkable bit and
  1953. ; get rid of scaling id bits
  1954. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  1955. cmp ah,bl ; are we more toward the front?
  1956. jge short ??out_pixel ; if so then write the pixel
  1957. ??write_back:
  1958. mov al,[fs:di] ; get the pixel to write
  1959. ??out_pixel:
  1960. stosb ; write the pixel
  1961. loop ??loop_top
  1962. ret
  1963. ENDP
  1964. ;***************************************************************************
  1965. ;* GHOST_NORMAL_DRAW -- Function that writes a normal pixel line *
  1966. ;* *
  1967. ;* INPUT: cx - number of pixels to write *
  1968. ;* ds:si - buffer which holds the pixels to write *
  1969. ;* es:di - place to put the pixels we are writing *
  1970. ;* *
  1971. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  1972. ;* es:di - points to next pixel past last pixel written *
  1973. ;* *
  1974. ;* WARNINGS: none *
  1975. ;* *
  1976. ;* HISTORY: *
  1977. ;* 05/27/1993 MCC : Created. *
  1978. ;*=========================================================================*
  1979. PROC NOLANGUAGE Ghost_Normal_Draw NEAR
  1980. ??loop_top:
  1981. lodsb
  1982. ;---
  1983. ; Ok, find out if the colour is a Translucent colour
  1984. push ax
  1985. push ds
  1986. lds bx,[IsTranslucent]
  1987. mov ah,al ; preserve real pixel
  1988. xlat ; get new al (transluecent pixel
  1989. xchg ah,al ; get real pixel back into AL just in case
  1990. cmp ah,255
  1991. je short ??normal_pixel ; is it a translucent ?
  1992. ; if we get passed here value in
  1993. ; AH should be 0-15
  1994. ; yes, it is a translucent colour so goto our translucent translation
  1995. ; table and set up a ptr to the correct table
  1996. mov al,[es:di]
  1997. ; mov pixel at destination to al and we have
  1998. ; the index to the translation table
  1999. ; ((trans_colour * 256) + dest colour)
  2000. lds bx,[Translucent] ; get the ptr to it!
  2001. add bh,ah ; Add the (trans_color * 256) of the translation equ.
  2002. ; XLAT only uses AL so no need to clear AH
  2003. xlat ; get new pixel in AL
  2004. ??normal_pixel:
  2005. pop ds
  2006. pop bx
  2007. mov ah,bh
  2008. ;---
  2009. mov [es:di],al ; store the pixel to the screen
  2010. ??skip:
  2011. inc di
  2012. loop ??loop_top
  2013. ret
  2014. ENDP
  2015. ;***************************************************************************
  2016. ;* GHOST_TRANSPARENT_DRAW -- Function that writes a transparent pixel line *
  2017. ;* *
  2018. ;* INPUT: cx - number of pixels to write *
  2019. ;* ds:si - buffer which holds the pixels to write *
  2020. ;* es:di - place to put the pixels we are writing *
  2021. ;* *
  2022. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  2023. ;* es:di - points to next pixel past last pixel written *
  2024. ;* *
  2025. ;* WARNINGS: none *
  2026. ;* *
  2027. ;* HISTORY: *
  2028. ;* 05/27/1993 MCC : Created. *
  2029. ;*=========================================================================*
  2030. PROC NOLANGUAGE Ghost_Transparent_Draw NEAR
  2031. ??loop_top:
  2032. lodsb
  2033. or al,al
  2034. jz short ??skip
  2035. ;---
  2036. ; Ok, find out if the colour is a Translucent colour
  2037. push ax
  2038. push ds
  2039. lds bx,[IsTranslucent]
  2040. mov ah,al ; preserve real pixel
  2041. xlat ; get new al (transluecent pixel
  2042. xchg ah,al ; get real pixel back into AL just in case
  2043. cmp ah,255
  2044. je short ??normal_pixel ; is it a translucent ?
  2045. ; if we get passed here value in
  2046. ; AH should be 0-15
  2047. ; yes, it is a translucent colour so goto our translucent translation
  2048. ; table and set up a ptr to the correct table
  2049. mov al,[es:di]
  2050. ; mov pixel at destination to al and we have
  2051. ; the index to the translation table
  2052. ; ((trans_colour * 256) + dest colour)
  2053. lds bx,[Translucent] ; get the ptr to it!
  2054. add bh,ah ; Add the (trans_color * 256) of the translation equ.
  2055. ; XLAT only uses AL so no need to clear AH
  2056. xlat ; get new pixel in AL
  2057. ??normal_pixel:
  2058. pop ds
  2059. pop bx
  2060. mov ah,bh
  2061. ;---
  2062. mov [es:di],al ; store the pixel to the screen
  2063. ??skip:
  2064. inc di
  2065. loop ??loop_top
  2066. ret
  2067. ENDP
  2068. ;***************************************************************************
  2069. ;* GHOST_PRIORITY_DRAW -- Function that writes a pixels if they are in fron*
  2070. ;* the given plate. *
  2071. ;* *
  2072. ;* INPUT: cx - number of pixels to write *
  2073. ;* ds:si - buffer which holds the pixels to write *
  2074. ;* es:di - place to put the pixels we are writing *
  2075. ;* *
  2076. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  2077. ;* es:di - points to next pixel past last pixel written *
  2078. ;* *
  2079. ;* WARNINGS: none *
  2080. ;* *
  2081. ;* HISTORY: *
  2082. ;* 07/17/1992 PWG : Created. *
  2083. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  2084. ;* 05/27/1993 MCC : Updated to use the new Ghosting fx *
  2085. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  2086. ;*=========================================================================*
  2087. PROC NOLANGUAGE Ghost_Priority_Draw NEAR
  2088. mov fs,[background] ; get the SEG of the background page
  2089. mov gs,[maskpage] ; get the SEG of the mask info
  2090. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  2091. ??loop_top:
  2092. lodsb ; get the pixel to draw on the screen
  2093. ; get the mask byte for our pixel
  2094. mov bl,[ds:di]
  2095. ; get rid of non-walkable bit and
  2096. ; get rid of scaling id bits
  2097. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  2098. cmp ah,bl ; are we more toward the front?
  2099. jge short ??out_pixel ; if so then write the pixel
  2100. mov al,[fs:di] ; get the pixel to write
  2101. ??out_pixel:
  2102. stosb ; write the pixel and inc the DI
  2103. loop ??loop_top
  2104. ret
  2105. ENDP
  2106. ;***************************************************************************
  2107. ;* GHOST_PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they*
  2108. ;* in front of the given plate. It also deals with *
  2109. ;* transparent pixels. *
  2110. ;* *
  2111. ;* INPUT: cx - number of pixels to write *
  2112. ;* ds:si - buffer which holds the pixels to write *
  2113. ;* es:di - place to put the pixels we are writing *
  2114. ;* *
  2115. ;* OUTPUT: ds:si - points to next pixel past last pixel read *
  2116. ;* es:di - points to next pixel past last pixel written *
  2117. ;* *
  2118. ;* WARNINGS: none *
  2119. ;* *
  2120. ;* HISTORY: *
  2121. ;* 07/17/1992 PWG : Created. *
  2122. ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. *
  2123. ;* 05/27/1993 MCC : Updated to use the new Ghosting fx *
  2124. ;* 17/01/1993 MCC : Updated for 386, and optimized *
  2125. ;*=========================================================================*
  2126. PROC NOLANGUAGE Ghost_Priority_Transparent_Draw NEAR
  2127. mov fs,[background] ; get the SEG of the background page
  2128. mov gs,[maskpage] ; get the SEG of the mask info
  2129. mov ah,[priority] ; keep a copy of priority varible for faster cmp
  2130. ??loop_top:
  2131. lodsb ; get the pixel on the screen
  2132. or al,al ; check to see if al is transparent
  2133. je short ??write_back ; if it is go write background
  2134. mov bl,[gs:di] ; get the mask byte for our pixel
  2135. ; get rid of non-walkable bit and
  2136. ; get rid of scaling id bits
  2137. and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS
  2138. cmp ah,bl ; are we more toward the front?
  2139. jge short ??out_pixel ; if so then write the pixel
  2140. ??write_back:
  2141. mov al,[fs:di] ; get the pixel to write
  2142. ??out_pixel:
  2143. stosb ; write the pixel
  2144. loop ??loop_top
  2145. ret
  2146. ENDP
  2147. END