d_draw.asm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  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. _TEXT SEGMENT
  235. LClampHigh0:
  236. mov esi,ds:dword ptr[_bbextents]
  237. jmp LClampReentry0
  238. LClampHighOrLow0:
  239. jg LClampHigh0
  240. xor esi,esi
  241. jmp LClampReentry0
  242. LClampHigh1:
  243. mov edx,ds:dword ptr[_bbextentt]
  244. jmp LClampReentry1
  245. LClampHighOrLow1:
  246. jg LClampHigh1
  247. xor edx,edx
  248. jmp LClampReentry1
  249. LClampLow2:
  250. mov ebp,2048
  251. jmp LClampReentry2
  252. LClampHigh2:
  253. mov ebp,ds:dword ptr[_bbextents]
  254. jmp LClampReentry2
  255. LClampLow3:
  256. mov ecx,2048
  257. jmp LClampReentry3
  258. LClampHigh3:
  259. mov ecx,ds:dword ptr[_bbextentt]
  260. jmp LClampReentry3
  261. LClampLow4:
  262. mov eax,2048
  263. jmp LClampReentry4
  264. LClampHigh4:
  265. mov eax,ds:dword ptr[_bbextents]
  266. jmp LClampReentry4
  267. LClampLow5:
  268. mov ebx,2048
  269. jmp LClampReentry5
  270. LClampHigh5:
  271. mov ebx,ds:dword ptr[_bbextentt]
  272. jmp LClampReentry5
  273. align 4
  274. public _D_DrawSpans8
  275. _D_DrawSpans8:
  276. push ebp
  277. push edi
  278. push esi
  279. push ebx
  280. fld ds:dword ptr[_d_sdivzstepu]
  281. fmul ds:dword ptr[fp_8]
  282. mov edx,ds:dword ptr[_cacheblock]
  283. fld ds:dword ptr[_d_tdivzstepu]
  284. fmul ds:dword ptr[fp_8]
  285. mov ebx,ds:dword ptr[4+16+esp]
  286. fld ds:dword ptr[_d_zistepu]
  287. fmul ds:dword ptr[fp_8]
  288. mov ds:dword ptr[pbase],edx
  289. fstp ds:dword ptr[zi8stepu]
  290. fstp ds:dword ptr[tdivz8stepu]
  291. fstp ds:dword ptr[sdivz8stepu]
  292. LSpanLoop:
  293. fild ds:dword ptr[4+ebx]
  294. fild ds:dword ptr[0+ebx]
  295. fld st(1)
  296. fmul ds:dword ptr[_d_sdivzstepv]
  297. fld st(1)
  298. fmul ds:dword ptr[_d_sdivzstepu]
  299. fld st(2)
  300. fmul ds:dword ptr[_d_tdivzstepu]
  301. fxch st(1)
  302. faddp st(2),st(0)
  303. fxch st(1)
  304. fld st(3)
  305. fmul ds:dword ptr[_d_tdivzstepv]
  306. fxch st(1)
  307. fadd ds:dword ptr[_d_sdivzorigin]
  308. fxch st(4)
  309. fmul ds:dword ptr[_d_zistepv]
  310. fxch st(1)
  311. faddp st(2),st(0)
  312. fxch st(2)
  313. fmul ds:dword ptr[_d_zistepu]
  314. fxch st(1)
  315. fadd ds:dword ptr[_d_tdivzorigin]
  316. fxch st(2)
  317. faddp st(1),st(0)
  318. fld ds:dword ptr[fp_64k]
  319. fxch st(1)
  320. fadd ds:dword ptr[_d_ziorigin]
  321. fdiv st(1),st(0)
  322. mov ecx,ds:dword ptr[_d_viewbuffer]
  323. mov eax,ds:dword ptr[4+ebx]
  324. mov ds:dword ptr[pspantemp],ebx
  325. mov edx,ds:dword ptr[_tadjust]
  326. mov esi,ds:dword ptr[_sadjust]
  327. mov edi,ds:dword ptr[_d_scantable+eax*4]
  328. add edi,ecx
  329. mov ecx,ds:dword ptr[0+ebx]
  330. add edi,ecx
  331. mov ecx,ds:dword ptr[8+ebx]
  332. cmp ecx,8
  333. ja LSetupNotLast1
  334. dec ecx
  335. jz LCleanup1
  336. mov ds:dword ptr[spancountminus1],ecx
  337. fxch st(1)
  338. fld st(0)
  339. fmul st(0),st(4)
  340. fxch st(1)
  341. fmul st(0),st(3)
  342. fxch st(1)
  343. fistp ds:dword ptr[s]
  344. fistp ds:dword ptr[t]
  345. fild ds:dword ptr[spancountminus1]
  346. fld ds:dword ptr[_d_tdivzstepu]
  347. fld ds:dword ptr[_d_zistepu]
  348. fmul st(0),st(2)
  349. fxch st(1)
  350. fmul st(0),st(2)
  351. fxch st(2)
  352. fmul ds:dword ptr[_d_sdivzstepu]
  353. fxch st(1)
  354. faddp st(3),st(0)
  355. fxch st(1)
  356. faddp st(3),st(0)
  357. faddp st(3),st(0)
  358. fld ds:dword ptr[fp_64k]
  359. fdiv st(0),st(1)
  360. jmp LFDIVInFlight1
  361. LCleanup1:
  362. fxch st(1)
  363. fld st(0)
  364. fmul st(0),st(4)
  365. fxch st(1)
  366. fmul st(0),st(3)
  367. fxch st(1)
  368. fistp ds:dword ptr[s]
  369. fistp ds:dword ptr[t]
  370. jmp LFDIVInFlight1
  371. align 4
  372. LSetupNotLast1:
  373. fxch st(1)
  374. fld st(0)
  375. fmul st(0),st(4)
  376. fxch st(1)
  377. fmul st(0),st(3)
  378. fxch st(1)
  379. fistp ds:dword ptr[s]
  380. fistp ds:dword ptr[t]
  381. fadd ds:dword ptr[zi8stepu]
  382. fxch st(2)
  383. fadd ds:dword ptr[sdivz8stepu]
  384. fxch st(2)
  385. fld ds:dword ptr[tdivz8stepu]
  386. faddp st(2),st(0)
  387. fld ds:dword ptr[fp_64k]
  388. fdiv st(0),st(1)
  389. LFDIVInFlight1:
  390. add esi,ds:dword ptr[s]
  391. add edx,ds:dword ptr[t]
  392. mov ebx,ds:dword ptr[_bbextents]
  393. mov ebp,ds:dword ptr[_bbextentt]
  394. cmp esi,ebx
  395. ja LClampHighOrLow0
  396. LClampReentry0:
  397. mov ds:dword ptr[s],esi
  398. mov ebx,ds:dword ptr[pbase]
  399. shl esi,16
  400. cmp edx,ebp
  401. mov ds:dword ptr[sfracf],esi
  402. ja LClampHighOrLow1
  403. LClampReentry1:
  404. mov ds:dword ptr[t],edx
  405. mov esi,ds:dword ptr[s]
  406. shl edx,16
  407. mov eax,ds:dword ptr[t]
  408. sar esi,16
  409. mov ds:dword ptr[tfracf],edx
  410. sar eax,16
  411. mov edx,ds:dword ptr[_cachewidth]
  412. imul eax,edx
  413. add esi,ebx
  414. add esi,eax
  415. cmp ecx,8
  416. jna LLastSegment
  417. LNotLastSegment:
  418. fld st(0)
  419. fmul st(0),st(4)
  420. fxch st(1)
  421. fmul st(0),st(3)
  422. fxch st(1)
  423. fistp ds:dword ptr[snext]
  424. fistp ds:dword ptr[tnext]
  425. mov eax,ds:dword ptr[snext]
  426. mov edx,ds:dword ptr[tnext]
  427. mov bl,ds:byte ptr[esi]
  428. sub ecx,8
  429. mov ebp,ds:dword ptr[_sadjust]
  430. mov ds:dword ptr[counttemp],ecx
  431. mov ecx,ds:dword ptr[_tadjust]
  432. mov ds:byte ptr[edi],bl
  433. add ebp,eax
  434. add ecx,edx
  435. mov eax,ds:dword ptr[_bbextents]
  436. mov edx,ds:dword ptr[_bbextentt]
  437. cmp ebp,2048
  438. jl LClampLow2
  439. cmp ebp,eax
  440. ja LClampHigh2
  441. LClampReentry2:
  442. cmp ecx,2048
  443. jl LClampLow3
  444. cmp ecx,edx
  445. ja LClampHigh3
  446. LClampReentry3:
  447. mov ds:dword ptr[snext],ebp
  448. mov ds:dword ptr[tnext],ecx
  449. sub ebp,ds:dword ptr[s]
  450. sub ecx,ds:dword ptr[t]
  451. mov eax,ecx
  452. mov edx,ebp
  453. sar eax,19
  454. jz LZero
  455. sar edx,19
  456. mov ebx,ds:dword ptr[_cachewidth]
  457. imul eax,ebx
  458. jmp LSetUp1
  459. LZero:
  460. sar edx,19
  461. mov ebx,ds:dword ptr[_cachewidth]
  462. LSetUp1:
  463. add eax,edx
  464. mov edx,ds:dword ptr[tfracf]
  465. mov ds:dword ptr[advancetable+4],eax
  466. add eax,ebx
  467. shl ebp,13
  468. mov ebx,ds:dword ptr[sfracf]
  469. shl ecx,13
  470. mov ds:dword ptr[advancetable],eax
  471. mov ds:dword ptr[tstep],ecx
  472. add edx,ecx
  473. sbb ecx,ecx
  474. add ebx,ebp
  475. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  476. add edx,ds:dword ptr[tstep]
  477. sbb ecx,ecx
  478. mov al,ds:byte ptr[esi]
  479. add ebx,ebp
  480. mov ds:byte ptr[1+edi],al
  481. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  482. add edx,ds:dword ptr[tstep]
  483. sbb ecx,ecx
  484. add ebx,ebp
  485. mov al,ds:byte ptr[esi]
  486. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  487. add edx,ds:dword ptr[tstep]
  488. sbb ecx,ecx
  489. mov ds:byte ptr[2+edi],al
  490. add ebx,ebp
  491. mov al,ds:byte ptr[esi]
  492. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  493. add edx,ds:dword ptr[tstep]
  494. sbb ecx,ecx
  495. mov ds:byte ptr[3+edi],al
  496. add ebx,ebp
  497. mov al,ds:byte ptr[esi]
  498. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  499. mov ecx,ds:dword ptr[counttemp]
  500. cmp ecx,8
  501. ja LSetupNotLast2
  502. dec ecx
  503. jz LFDIVInFlight2
  504. mov ds:dword ptr[spancountminus1],ecx
  505. fild ds:dword ptr[spancountminus1]
  506. fld ds:dword ptr[_d_zistepu]
  507. fmul st(0),st(1)
  508. fld ds:dword ptr[_d_tdivzstepu]
  509. fmul st(0),st(2)
  510. fxch st(1)
  511. faddp st(3),st(0)
  512. fxch st(1)
  513. fmul ds:dword ptr[_d_sdivzstepu]
  514. fxch st(1)
  515. faddp st(3),st(0)
  516. fld ds:dword ptr[fp_64k]
  517. fxch st(1)
  518. faddp st(4),st(0)
  519. fdiv st(0),st(1)
  520. jmp LFDIVInFlight2
  521. align 4
  522. LSetupNotLast2:
  523. fadd ds:dword ptr[zi8stepu]
  524. fxch st(2)
  525. fadd ds:dword ptr[sdivz8stepu]
  526. fxch st(2)
  527. fld ds:dword ptr[tdivz8stepu]
  528. faddp st(2),st(0)
  529. fld ds:dword ptr[fp_64k]
  530. fdiv st(0),st(1)
  531. LFDIVInFlight2:
  532. mov ds:dword ptr[counttemp],ecx
  533. add edx,ds:dword ptr[tstep]
  534. sbb ecx,ecx
  535. mov ds:byte ptr[4+edi],al
  536. add ebx,ebp
  537. mov al,ds:byte ptr[esi]
  538. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  539. add edx,ds:dword ptr[tstep]
  540. sbb ecx,ecx
  541. mov ds:byte ptr[5+edi],al
  542. add ebx,ebp
  543. mov al,ds:byte ptr[esi]
  544. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  545. add edx,ds:dword ptr[tstep]
  546. sbb ecx,ecx
  547. mov ds:byte ptr[6+edi],al
  548. add ebx,ebp
  549. mov al,ds:byte ptr[esi]
  550. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  551. add edi,8
  552. mov ds:dword ptr[tfracf],edx
  553. mov edx,ds:dword ptr[snext]
  554. mov ds:dword ptr[sfracf],ebx
  555. mov ebx,ds:dword ptr[tnext]
  556. mov ds:dword ptr[s],edx
  557. mov ds:dword ptr[t],ebx
  558. mov ecx,ds:dword ptr[counttemp]
  559. cmp ecx,8
  560. mov ds:byte ptr[-1+edi],al
  561. ja LNotLastSegment
  562. LLastSegment:
  563. test ecx,ecx
  564. jz LNoSteps
  565. fld st(0)
  566. fmul st(0),st(4)
  567. fxch st(1)
  568. fmul st(0),st(3)
  569. fxch st(1)
  570. fistp ds:dword ptr[snext]
  571. fistp ds:dword ptr[tnext]
  572. mov al,ds:byte ptr[esi]
  573. mov ebx,ds:dword ptr[_tadjust]
  574. mov ds:byte ptr[edi],al
  575. mov eax,ds:dword ptr[_sadjust]
  576. add eax,ds:dword ptr[snext]
  577. add ebx,ds:dword ptr[tnext]
  578. mov ebp,ds:dword ptr[_bbextents]
  579. mov edx,ds:dword ptr[_bbextentt]
  580. cmp eax,2048
  581. jl LClampLow4
  582. cmp eax,ebp
  583. ja LClampHigh4
  584. LClampReentry4:
  585. mov ds:dword ptr[snext],eax
  586. cmp ebx,2048
  587. jl LClampLow5
  588. cmp ebx,edx
  589. ja LClampHigh5
  590. LClampReentry5:
  591. cmp ecx,1
  592. je LOnlyOneStep
  593. sub eax,ds:dword ptr[s]
  594. sub ebx,ds:dword ptr[t]
  595. add eax,eax
  596. add ebx,ebx
  597. imul ds:dword ptr[reciprocal_table-8+ecx*4]
  598. mov ebp,edx
  599. mov eax,ebx
  600. imul ds:dword ptr[reciprocal_table-8+ecx*4]
  601. LSetEntryvec:
  602. mov ebx,ds:dword ptr[entryvec_table+ecx*4]
  603. mov eax,edx
  604. mov ds:dword ptr[jumptemp],ebx
  605. mov ecx,ebp
  606. sar edx,16
  607. mov ebx,ds:dword ptr[_cachewidth]
  608. sar ecx,16
  609. imul edx,ebx
  610. add edx,ecx
  611. mov ecx,ds:dword ptr[tfracf]
  612. mov ds:dword ptr[advancetable+4],edx
  613. add edx,ebx
  614. shl ebp,16
  615. mov ebx,ds:dword ptr[sfracf]
  616. shl eax,16
  617. mov ds:dword ptr[advancetable],edx
  618. mov ds:dword ptr[tstep],eax
  619. mov edx,ecx
  620. add edx,eax
  621. sbb ecx,ecx
  622. add ebx,ebp
  623. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  624. jmp dword ptr[jumptemp]
  625. LNoSteps:
  626. mov al,ds:byte ptr[esi]
  627. sub edi,7
  628. jmp LEndSpan
  629. LOnlyOneStep:
  630. sub eax,ds:dword ptr[s]
  631. sub ebx,ds:dword ptr[t]
  632. mov ebp,eax
  633. mov edx,ebx
  634. jmp LSetEntryvec
  635. public Entry2_8
  636. Entry2_8:
  637. sub edi,6
  638. mov al,ds:byte ptr[esi]
  639. jmp LLEntry2_8
  640. public Entry3_8
  641. Entry3_8:
  642. sub edi,5
  643. add edx,eax
  644. mov al,ds:byte ptr[esi]
  645. sbb ecx,ecx
  646. add ebx,ebp
  647. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  648. jmp LLEntry3_8
  649. public Entry4_8
  650. Entry4_8:
  651. sub edi,4
  652. add edx,eax
  653. mov al,ds:byte ptr[esi]
  654. sbb ecx,ecx
  655. add ebx,ebp
  656. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  657. add edx,ds:dword ptr[tstep]
  658. jmp LLEntry4_8
  659. public Entry5_8
  660. Entry5_8:
  661. sub edi,3
  662. add edx,eax
  663. mov al,ds:byte ptr[esi]
  664. sbb ecx,ecx
  665. add ebx,ebp
  666. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  667. add edx,ds:dword ptr[tstep]
  668. jmp LLEntry5_8
  669. public Entry6_8
  670. Entry6_8:
  671. sub edi,2
  672. add edx,eax
  673. mov al,ds:byte ptr[esi]
  674. sbb ecx,ecx
  675. add ebx,ebp
  676. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  677. add edx,ds:dword ptr[tstep]
  678. jmp LLEntry6_8
  679. public Entry7_8
  680. Entry7_8:
  681. dec edi
  682. add edx,eax
  683. mov al,ds:byte ptr[esi]
  684. sbb ecx,ecx
  685. add ebx,ebp
  686. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  687. add edx,ds:dword ptr[tstep]
  688. jmp LLEntry7_8
  689. public Entry8_8
  690. Entry8_8:
  691. add edx,eax
  692. mov al,ds:byte ptr[esi]
  693. sbb ecx,ecx
  694. add ebx,ebp
  695. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  696. add edx,ds:dword ptr[tstep]
  697. sbb ecx,ecx
  698. mov ds:byte ptr[1+edi],al
  699. add ebx,ebp
  700. mov al,ds:byte ptr[esi]
  701. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  702. add edx,ds:dword ptr[tstep]
  703. LLEntry7_8:
  704. sbb ecx,ecx
  705. mov ds:byte ptr[2+edi],al
  706. add ebx,ebp
  707. mov al,ds:byte ptr[esi]
  708. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  709. add edx,ds:dword ptr[tstep]
  710. LLEntry6_8:
  711. sbb ecx,ecx
  712. mov ds:byte ptr[3+edi],al
  713. add ebx,ebp
  714. mov al,ds:byte ptr[esi]
  715. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  716. add edx,ds:dword ptr[tstep]
  717. LLEntry5_8:
  718. sbb ecx,ecx
  719. mov ds:byte ptr[4+edi],al
  720. add ebx,ebp
  721. mov al,ds:byte ptr[esi]
  722. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  723. add edx,ds:dword ptr[tstep]
  724. LLEntry4_8:
  725. sbb ecx,ecx
  726. mov ds:byte ptr[5+edi],al
  727. add ebx,ebp
  728. mov al,ds:byte ptr[esi]
  729. adc esi,ds:dword ptr[advancetable+4+ecx*4]
  730. LLEntry3_8:
  731. mov ds:byte ptr[6+edi],al
  732. mov al,ds:byte ptr[esi]
  733. LLEntry2_8:
  734. LEndSpan:
  735. fstp st(0)
  736. fstp st(0)
  737. fstp st(0)
  738. mov ebx,ds:dword ptr[pspantemp]
  739. mov ebx,ds:dword ptr[12+ebx]
  740. test ebx,ebx
  741. mov ds:byte ptr[7+edi],al
  742. jnz LSpanLoop
  743. pop ebx
  744. pop esi
  745. pop edi
  746. pop ebp
  747. ret
  748. LClamp:
  749. mov edx,040000000h
  750. xor ebx,ebx
  751. fstp st(0)
  752. jmp LZDraw
  753. LClampNeg:
  754. mov edx,040000000h
  755. xor ebx,ebx
  756. fstp st(0)
  757. jmp LZDrawNeg
  758. public _D_DrawZSpans
  759. _D_DrawZSpans:
  760. push ebp
  761. push edi
  762. push esi
  763. push ebx
  764. fld ds:dword ptr[_d_zistepu]
  765. mov eax,ds:dword ptr[_d_zistepu]
  766. mov esi,ds:dword ptr[4+16+esp]
  767. test eax,eax
  768. jz LFNegSpan
  769. fmul ds:dword ptr[Float2ToThe31nd]
  770. fistp ds:dword ptr[izistep]
  771. mov ebx,ds:dword ptr[izistep]
  772. LFSpanLoop:
  773. fild ds:dword ptr[4+esi]
  774. fild ds:dword ptr[0+esi]
  775. mov ecx,ds:dword ptr[4+esi]
  776. mov edi,ds:dword ptr[_d_pzbuffer]
  777. fmul ds:dword ptr[_d_zistepu]
  778. fxch st(1)
  779. fmul ds:dword ptr[_d_zistepv]
  780. fxch st(1)
  781. fadd ds:dword ptr[_d_ziorigin]
  782. imul ecx,ds:dword ptr[_d_zrowbytes]
  783. faddp st(1),st(0)
  784. fcom ds:dword ptr[float_point5]
  785. add edi,ecx
  786. mov edx,ds:dword ptr[0+esi]
  787. add edx,edx
  788. mov ecx,ds:dword ptr[8+esi]
  789. add edi,edx
  790. push esi
  791. fnstsw ax
  792. test ah,045h
  793. jz LClamp
  794. fmul ds:dword ptr[Float2ToThe31nd]
  795. fistp ds:dword ptr[izi]
  796. mov edx,ds:dword ptr[izi]
  797. LZDraw:
  798. test edi,2
  799. jz LFMiddle
  800. mov eax,edx
  801. add edx,ebx
  802. shr eax,16
  803. dec ecx
  804. mov ds:word ptr[edi],ax
  805. add edi,2
  806. LFMiddle:
  807. push ecx
  808. shr ecx,1
  809. jz LFLast
  810. shr ecx,1
  811. jnc LFMiddleLoop
  812. mov eax,edx
  813. add edx,ebx
  814. shr eax,16
  815. mov esi,edx
  816. add edx,ebx
  817. and esi,0FFFF0000h
  818. or eax,esi
  819. mov ds:dword ptr[edi],eax
  820. add edi,4
  821. and ecx,ecx
  822. jz LFLast
  823. LFMiddleLoop:
  824. mov eax,edx
  825. add edx,ebx
  826. shr eax,16
  827. mov esi,edx
  828. add edx,ebx
  829. and esi,0FFFF0000h
  830. or eax,esi
  831. mov ebp,edx
  832. mov ds:dword ptr[edi],eax
  833. add edx,ebx
  834. shr ebp,16
  835. mov esi,edx
  836. add edx,ebx
  837. and esi,0FFFF0000h
  838. or ebp,esi
  839. mov ds:dword ptr[4+edi],ebp
  840. add edi,8
  841. dec ecx
  842. jnz LFMiddleLoop
  843. LFLast:
  844. pop ecx
  845. pop esi
  846. and ecx,1
  847. jz LFSpanDone
  848. shr edx,16
  849. mov ds:word ptr[edi],dx
  850. LFSpanDone:
  851. mov esi,ds:dword ptr[12+esi]
  852. test esi,esi
  853. jnz LFSpanLoop
  854. jmp LFDone
  855. LFNegSpan:
  856. fmul ds:dword ptr[FloatMinus2ToThe31nd]
  857. fistp ds:dword ptr[izistep]
  858. mov ebx,ds:dword ptr[izistep]
  859. LFNegSpanLoop:
  860. fild ds:dword ptr[4+esi]
  861. fild ds:dword ptr[0+esi]
  862. mov ecx,ds:dword ptr[4+esi]
  863. mov edi,ds:dword ptr[_d_pzbuffer]
  864. fmul ds:dword ptr[_d_zistepu]
  865. fxch st(1)
  866. fmul ds:dword ptr[_d_zistepv]
  867. fxch st(1)
  868. fadd ds:dword ptr[_d_ziorigin]
  869. imul ecx,ds:dword ptr[_d_zrowbytes]
  870. faddp st(1),st(0)
  871. fcom ds:dword ptr[float_point5]
  872. add edi,ecx
  873. mov edx,ds:dword ptr[0+esi]
  874. add edx,edx
  875. mov ecx,ds:dword ptr[8+esi]
  876. add edi,edx
  877. push esi
  878. fnstsw ax
  879. test ah,045h
  880. jz LClampNeg
  881. fmul ds:dword ptr[Float2ToThe31nd]
  882. fistp ds:dword ptr[izi]
  883. mov edx,ds:dword ptr[izi]
  884. LZDrawNeg:
  885. test edi,2
  886. jz LFNegMiddle
  887. mov eax,edx
  888. sub edx,ebx
  889. shr eax,16
  890. dec ecx
  891. mov ds:word ptr[edi],ax
  892. add edi,2
  893. LFNegMiddle:
  894. push ecx
  895. shr ecx,1
  896. jz LFNegLast
  897. shr ecx,1
  898. jnc LFNegMiddleLoop
  899. mov eax,edx
  900. sub edx,ebx
  901. shr eax,16
  902. mov esi,edx
  903. sub edx,ebx
  904. and esi,0FFFF0000h
  905. or eax,esi
  906. mov ds:dword ptr[edi],eax
  907. add edi,4
  908. and ecx,ecx
  909. jz LFNegLast
  910. LFNegMiddleLoop:
  911. mov eax,edx
  912. sub edx,ebx
  913. shr eax,16
  914. mov esi,edx
  915. sub edx,ebx
  916. and esi,0FFFF0000h
  917. or eax,esi
  918. mov ebp,edx
  919. mov ds:dword ptr[edi],eax
  920. sub edx,ebx
  921. shr ebp,16
  922. mov esi,edx
  923. sub edx,ebx
  924. and esi,0FFFF0000h
  925. or ebp,esi
  926. mov ds:dword ptr[4+edi],ebp
  927. add edi,8
  928. dec ecx
  929. jnz LFNegMiddleLoop
  930. LFNegLast:
  931. pop ecx
  932. pop esi
  933. and ecx,1
  934. jz LFNegSpanDone
  935. shr edx,16
  936. mov ds:word ptr[edi],dx
  937. LFNegSpanDone:
  938. mov esi,ds:dword ptr[12+esi]
  939. test esi,esi
  940. jnz LFNegSpanLoop
  941. LFDone:
  942. pop ebx
  943. pop esi
  944. pop edi
  945. pop ebp
  946. ret
  947. _TEXT ENDS
  948. END