surf16.asm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. .386P
  2. .model FLAT
  3. externdef _d_zistepu:dword
  4. externdef _d_pzbuffer:dword
  5. externdef _d_zistepv:dword
  6. externdef _d_zrowbytes:dword
  7. externdef _d_ziorigin:dword
  8. externdef _r_turb_s:dword
  9. externdef _r_turb_t:dword
  10. externdef _r_turb_pdest:dword
  11. externdef _r_turb_spancount:dword
  12. externdef _r_turb_turb:dword
  13. externdef _r_turb_pbase:dword
  14. externdef _r_turb_sstep:dword
  15. externdef _r_turb_tstep:dword
  16. externdef _r_bmodelactive:dword
  17. externdef _d_sdivzstepu:dword
  18. externdef _d_tdivzstepu:dword
  19. externdef _d_sdivzstepv:dword
  20. externdef _d_tdivzstepv:dword
  21. externdef _d_sdivzorigin:dword
  22. externdef _d_tdivzorigin:dword
  23. externdef _sadjust:dword
  24. externdef _tadjust:dword
  25. externdef _bbextents:dword
  26. externdef _bbextentt:dword
  27. externdef _cacheblock:dword
  28. externdef _d_viewbuffer:dword
  29. externdef _cachewidth:dword
  30. externdef _d_pzbuffer:dword
  31. externdef _d_zrowbytes:dword
  32. externdef _d_zwidth:dword
  33. externdef _d_scantable:dword
  34. externdef _r_lightptr:dword
  35. externdef _r_numvblocks:dword
  36. externdef _prowdestbase:dword
  37. externdef _pbasesource:dword
  38. externdef _r_lightwidth:dword
  39. externdef _lightright:dword
  40. externdef _lightrightstep:dword
  41. externdef _lightdeltastep:dword
  42. externdef _lightdelta:dword
  43. externdef _lightright:dword
  44. externdef _lightdelta:dword
  45. externdef _sourcetstep:dword
  46. externdef _surfrowbytes:dword
  47. externdef _lightrightstep:dword
  48. externdef _lightdeltastep:dword
  49. externdef _r_sourcemax:dword
  50. externdef _r_stepback:dword
  51. externdef _colormap:dword
  52. externdef _blocksize:dword
  53. externdef _sourcesstep:dword
  54. externdef _lightleft:dword
  55. externdef _blockdivshift:dword
  56. externdef _blockdivmask:dword
  57. externdef _lightleftstep:dword
  58. externdef _r_origin:dword
  59. externdef _r_ppn:dword
  60. externdef _r_pup:dword
  61. externdef _r_pright:dword
  62. externdef _ycenter:dword
  63. externdef _xcenter:dword
  64. externdef _d_vrectbottom_particle:dword
  65. externdef _d_vrectright_particle:dword
  66. externdef _d_vrecty:dword
  67. externdef _d_vrectx:dword
  68. externdef _d_pix_shift:dword
  69. externdef _d_pix_min:dword
  70. externdef _d_pix_max:dword
  71. externdef _d_y_aspect_shift:dword
  72. externdef _screenwidth:dword
  73. externdef _vright:dword
  74. externdef _vup:dword
  75. externdef _vpn:dword
  76. externdef _BOPS_Error:dword
  77. externdef _snd_scaletable:dword
  78. externdef _paintbuffer:dword
  79. externdef _snd_linear_count:dword
  80. externdef _snd_p:dword
  81. externdef _snd_vol:dword
  82. externdef _snd_out:dword
  83. externdef _r_leftclipped:dword
  84. externdef _r_leftenter:dword
  85. externdef _r_rightclipped:dword
  86. externdef _r_rightenter:dword
  87. externdef _modelorg:dword
  88. externdef _xscale:dword
  89. externdef _r_refdef:dword
  90. externdef _yscale:dword
  91. externdef _r_leftexit:dword
  92. externdef _r_rightexit:dword
  93. externdef _r_lastvertvalid:dword
  94. externdef _cacheoffset:dword
  95. externdef _newedges:dword
  96. externdef _removeedges:dword
  97. externdef _r_pedge:dword
  98. externdef _r_framecount:dword
  99. externdef _r_u1:dword
  100. externdef _r_emitted:dword
  101. externdef _edge_p:dword
  102. externdef _surface_p:dword
  103. externdef _surfaces:dword
  104. externdef _r_lzi1:dword
  105. externdef _r_v1:dword
  106. externdef _r_ceilv1:dword
  107. externdef _r_nearzi:dword
  108. externdef _r_nearzionly:dword
  109. externdef _edge_aftertail:dword
  110. externdef _edge_tail:dword
  111. externdef _current_iv:dword
  112. externdef _edge_head_u_shift20:dword
  113. externdef _span_p:dword
  114. externdef _edge_head:dword
  115. externdef _fv:dword
  116. externdef _edge_tail_u_shift20:dword
  117. externdef _r_apverts:dword
  118. externdef _r_anumverts:dword
  119. externdef _aliastransform:dword
  120. externdef _r_avertexnormals:dword
  121. externdef _r_plightvec:dword
  122. externdef _r_ambientlight:dword
  123. externdef _r_shadelight:dword
  124. externdef _aliasxcenter:dword
  125. externdef _aliasycenter:dword
  126. externdef _a_sstepxfrac:dword
  127. externdef _r_affinetridesc:dword
  128. externdef _acolormap:dword
  129. externdef _d_pcolormap:dword
  130. externdef _r_affinetridesc:dword
  131. externdef _d_sfrac:dword
  132. externdef _d_ptex:dword
  133. externdef _d_pedgespanpackage:dword
  134. externdef _d_tfrac:dword
  135. externdef _d_light:dword
  136. externdef _d_zi:dword
  137. externdef _d_pdest:dword
  138. externdef _d_pz:dword
  139. externdef _d_aspancount:dword
  140. externdef _erroradjustup:dword
  141. externdef _errorterm:dword
  142. externdef _d_xdenom:dword
  143. externdef _r_p0:dword
  144. externdef _r_p1:dword
  145. externdef _r_p2:dword
  146. externdef _a_tstepxfrac:dword
  147. externdef _r_sstepx:dword
  148. externdef _r_tstepx:dword
  149. externdef _a_ststepxwhole:dword
  150. externdef _zspantable:dword
  151. externdef _skintable:dword
  152. externdef _r_zistepx:dword
  153. externdef _erroradjustdown:dword
  154. externdef _d_countextrastep:dword
  155. externdef _ubasestep:dword
  156. externdef _a_ststepxwhole:dword
  157. externdef _a_tstepxfrac:dword
  158. externdef _r_lstepx:dword
  159. externdef _a_spans:dword
  160. externdef _erroradjustdown:dword
  161. externdef _d_pdestextrastep:dword
  162. externdef _d_pzextrastep:dword
  163. externdef _d_sfracextrastep:dword
  164. externdef _d_ptexextrastep:dword
  165. externdef _d_countextrastep:dword
  166. externdef _d_tfracextrastep:dword
  167. externdef _d_lightextrastep:dword
  168. externdef _d_ziextrastep:dword
  169. externdef _d_pdestbasestep:dword
  170. externdef _d_pzbasestep:dword
  171. externdef _d_sfracbasestep:dword
  172. externdef _d_ptexbasestep:dword
  173. externdef _ubasestep:dword
  174. externdef _d_tfracbasestep:dword
  175. externdef _d_lightbasestep:dword
  176. externdef _d_zibasestep:dword
  177. externdef _zspantable:dword
  178. externdef _r_lstepy:dword
  179. externdef _r_sstepy:dword
  180. externdef _r_tstepy:dword
  181. externdef _r_zistepy:dword
  182. externdef _D_PolysetSetEdgeTable:dword
  183. externdef _D_RasterizeAliasPolySmooth:dword
  184. externdef float_point5:dword
  185. externdef Float2ToThe31nd:dword
  186. externdef izistep:dword
  187. externdef izi:dword
  188. externdef FloatMinus2ToThe31nd:dword
  189. externdef float_1:dword
  190. externdef float_particle_z_clip:dword
  191. externdef float_minus_1:dword
  192. externdef float_0:dword
  193. externdef fp_16:dword
  194. externdef fp_64k:dword
  195. externdef fp_1m:dword
  196. externdef fp_1m_minus_1:dword
  197. externdef fp_8:dword
  198. externdef entryvec_table:dword
  199. externdef advancetable:dword
  200. externdef sstep:dword
  201. externdef tstep:dword
  202. externdef pspantemp:dword
  203. externdef counttemp:dword
  204. externdef jumptemp:dword
  205. externdef reciprocal_table:dword
  206. externdef DP_Count:dword
  207. externdef DP_u:dword
  208. externdef DP_v:dword
  209. externdef DP_32768:dword
  210. externdef DP_Color:dword
  211. externdef DP_Pix:dword
  212. externdef DP_EntryTable:dword
  213. externdef pbase:dword
  214. externdef s:dword
  215. externdef t:dword
  216. externdef sfracf:dword
  217. externdef tfracf:dword
  218. externdef snext:dword
  219. externdef tnext:dword
  220. externdef spancountminus1:dword
  221. externdef zi16stepu:dword
  222. externdef sdivz16stepu:dword
  223. externdef tdivz16stepu:dword
  224. externdef zi8stepu:dword
  225. externdef sdivz8stepu:dword
  226. externdef tdivz8stepu:dword
  227. externdef reciprocal_table_16:dword
  228. externdef entryvec_table_16:dword
  229. externdef ceil_cw:dword
  230. externdef single_cw:dword
  231. externdef fp_64kx64k:dword
  232. externdef pz:dword
  233. externdef spr8entryvec_table:dword
  234. _DATA SEGMENT
  235. k dd 0
  236. loopentry dd 0
  237. align 4
  238. blockjumptable16:
  239. dd LEnter2_16
  240. dd LEnter4_16
  241. dd 0, LEnter8_16
  242. dd 0, 0, 0, LEnter16_16
  243. _DATA ENDS
  244. _TEXT SEGMENT
  245. align 4
  246. public _R_Surf16Start
  247. _R_Surf16Start:
  248. align 4
  249. public _R_DrawSurfaceBlock16
  250. _R_DrawSurfaceBlock16:
  251. push ebp
  252. push edi
  253. push esi
  254. push ebx
  255. mov eax,ds:dword ptr[_blocksize]
  256. mov edi,ds:dword ptr[_prowdestbase]
  257. mov esi,ds:dword ptr[_pbasesource]
  258. mov ebx,ds:dword ptr[_sourcesstep]
  259. mov ecx,ds:dword ptr[blockjumptable16-4+eax*2]
  260. mov ds:dword ptr[k],eax
  261. mov ds:dword ptr[loopentry],ecx
  262. mov edx,ds:dword ptr[_lightleft]
  263. mov ebp,ds:dword ptr[_lightright]
  264. Lblockloop16:
  265. sub ebp,edx
  266. mov cl,ds:byte ptr[_blockdivshift]
  267. sar ebp,cl
  268. jns Lp1_16
  269. test ebp,ds:dword ptr[_blockdivmask]
  270. jz Lp1_16
  271. inc ebp
  272. Lp1_16:
  273. sub eax,eax
  274. sub ecx,ecx
  275. jmp dword ptr[loopentry]
  276. align 4
  277. LEnter16_16:
  278. mov al,ds:byte ptr[esi]
  279. mov cl,ds:byte ptr[esi+ebx]
  280. mov ah,dh
  281. add edx,ebp
  282. mov ch,dh
  283. lea esi,ds:dword ptr[esi+ebx*2]
  284. mov ax,ds:word ptr[12345678h+eax*2]
  285. LBPatch0:
  286. add edx,ebp
  287. mov ds:word ptr[edi],ax
  288. mov cx,ds:word ptr[12345678h+ecx*2]
  289. LBPatch1:
  290. mov ds:word ptr[2+edi],cx
  291. add edi,04h
  292. mov al,ds:byte ptr[esi]
  293. mov cl,ds:byte ptr[esi+ebx]
  294. mov ah,dh
  295. add edx,ebp
  296. mov ch,dh
  297. lea esi,ds:dword ptr[esi+ebx*2]
  298. mov ax,ds:word ptr[12345678h+eax*2]
  299. LBPatch2:
  300. add edx,ebp
  301. mov ds:word ptr[edi],ax
  302. mov cx,ds:word ptr[12345678h+ecx*2]
  303. LBPatch3:
  304. mov ds:word ptr[2+edi],cx
  305. add edi,04h
  306. mov al,ds:byte ptr[esi]
  307. mov cl,ds:byte ptr[esi+ebx]
  308. mov ah,dh
  309. add edx,ebp
  310. mov ch,dh
  311. lea esi,ds:dword ptr[esi+ebx*2]
  312. mov ax,ds:word ptr[12345678h+eax*2]
  313. LBPatch4:
  314. add edx,ebp
  315. mov ds:word ptr[edi],ax
  316. mov cx,ds:word ptr[12345678h+ecx*2]
  317. LBPatch5:
  318. mov ds:word ptr[2+edi],cx
  319. add edi,04h
  320. mov al,ds:byte ptr[esi]
  321. mov cl,ds:byte ptr[esi+ebx]
  322. mov ah,dh
  323. add edx,ebp
  324. mov ch,dh
  325. lea esi,ds:dword ptr[esi+ebx*2]
  326. mov ax,ds:word ptr[12345678h+eax*2]
  327. LBPatch6:
  328. add edx,ebp
  329. mov ds:word ptr[edi],ax
  330. mov cx,ds:word ptr[12345678h+ecx*2]
  331. LBPatch7:
  332. mov ds:word ptr[2+edi],cx
  333. add edi,04h
  334. LEnter8_16:
  335. mov al,ds:byte ptr[esi]
  336. mov cl,ds:byte ptr[esi+ebx]
  337. mov ah,dh
  338. add edx,ebp
  339. mov ch,dh
  340. lea esi,ds:dword ptr[esi+ebx*2]
  341. mov ax,ds:word ptr[12345678h+eax*2]
  342. LBPatch8:
  343. add edx,ebp
  344. mov ds:word ptr[edi],ax
  345. mov cx,ds:word ptr[12345678h+ecx*2]
  346. LBPatch9:
  347. mov ds:word ptr[2+edi],cx
  348. add edi,04h
  349. mov al,ds:byte ptr[esi]
  350. mov cl,ds:byte ptr[esi+ebx]
  351. mov ah,dh
  352. add edx,ebp
  353. mov ch,dh
  354. lea esi,ds:dword ptr[esi+ebx*2]
  355. mov ax,ds:word ptr[12345678h+eax*2]
  356. LBPatch10:
  357. add edx,ebp
  358. mov ds:word ptr[edi],ax
  359. mov cx,ds:word ptr[12345678h+ecx*2]
  360. LBPatch11:
  361. mov ds:word ptr[2+edi],cx
  362. add edi,04h
  363. LEnter4_16:
  364. mov al,ds:byte ptr[esi]
  365. mov cl,ds:byte ptr[esi+ebx]
  366. mov ah,dh
  367. add edx,ebp
  368. mov ch,dh
  369. lea esi,ds:dword ptr[esi+ebx*2]
  370. mov ax,ds:word ptr[12345678h+eax*2]
  371. LBPatch12:
  372. add edx,ebp
  373. mov ds:word ptr[edi],ax
  374. mov cx,ds:word ptr[12345678h+ecx*2]
  375. LBPatch13:
  376. mov ds:word ptr[2+edi],cx
  377. add edi,04h
  378. LEnter2_16:
  379. mov al,ds:byte ptr[esi]
  380. mov cl,ds:byte ptr[esi+ebx]
  381. mov ah,dh
  382. add edx,ebp
  383. mov ch,dh
  384. lea esi,ds:dword ptr[esi+ebx*2]
  385. mov ax,ds:word ptr[12345678h+eax*2]
  386. LBPatch14:
  387. add edx,ebp
  388. mov ds:word ptr[edi],ax
  389. mov cx,ds:word ptr[12345678h+ecx*2]
  390. LBPatch15:
  391. mov ds:word ptr[2+edi],cx
  392. add edi,04h
  393. mov esi,ds:dword ptr[_pbasesource]
  394. mov edx,ds:dword ptr[_lightleft]
  395. mov ebp,ds:dword ptr[_lightright]
  396. mov eax,ds:dword ptr[_sourcetstep]
  397. mov ecx,ds:dword ptr[_lightrightstep]
  398. mov edi,ds:dword ptr[_prowdestbase]
  399. add esi,eax
  400. add ebp,ecx
  401. mov eax,ds:dword ptr[_lightleftstep]
  402. mov ecx,ds:dword ptr[_surfrowbytes]
  403. add edx,eax
  404. add edi,ecx
  405. mov ds:dword ptr[_pbasesource],esi
  406. mov ds:dword ptr[_lightright],ebp
  407. mov eax,ds:dword ptr[k]
  408. mov ds:dword ptr[_lightleft],edx
  409. dec eax
  410. mov ds:dword ptr[_prowdestbase],edi
  411. mov ds:dword ptr[k],eax
  412. jnz Lblockloop16
  413. pop ebx
  414. pop esi
  415. pop edi
  416. pop ebp
  417. ret
  418. public _R_Surf16End
  419. _R_Surf16End:
  420. _TEXT ENDS
  421. _DATA SEGMENT
  422. align 4
  423. LPatchTable16:
  424. dd LBPatch0-4
  425. dd LBPatch1-4
  426. dd LBPatch2-4
  427. dd LBPatch3-4
  428. dd LBPatch4-4
  429. dd LBPatch5-4
  430. dd LBPatch6-4
  431. dd LBPatch7-4
  432. dd LBPatch8-4
  433. dd LBPatch9-4
  434. dd LBPatch10-4
  435. dd LBPatch11-4
  436. dd LBPatch12-4
  437. dd LBPatch13-4
  438. dd LBPatch14-4
  439. dd LBPatch15-4
  440. _DATA ENDS
  441. _TEXT SEGMENT
  442. align 4
  443. public _R_Surf16Patch
  444. _R_Surf16Patch:
  445. push ebx
  446. mov eax,ds:dword ptr[_colormap]
  447. mov ebx,offset LPatchTable16
  448. mov ecx,16
  449. LPatchLoop16:
  450. mov edx,ds:dword ptr[ebx]
  451. add ebx,4
  452. mov ds:dword ptr[edx],eax
  453. dec ecx
  454. jnz LPatchLoop16
  455. pop ebx
  456. ret
  457. _TEXT ENDS
  458. END