r_edgea.asm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. Ltemp dd 0
  236. float_1_div_0100000h dd 035800000h
  237. float_point_999 dd 0.999
  238. float_1_point_001 dd 1.001
  239. _DATA ENDS
  240. _TEXT SEGMENT
  241. public _R_EdgeCodeStart
  242. _R_EdgeCodeStart:
  243. public _R_InsertNewEdges
  244. _R_InsertNewEdges:
  245. push edi
  246. push esi
  247. mov edx,ds:dword ptr[4+8+esp]
  248. push ebx
  249. mov ecx,ds:dword ptr[8+12+esp]
  250. LDoNextEdge:
  251. mov eax,ds:dword ptr[0+edx]
  252. mov edi,edx
  253. LContinueSearch:
  254. mov ebx,ds:dword ptr[0+ecx]
  255. mov esi,ds:dword ptr[12+ecx]
  256. cmp eax,ebx
  257. jle LAddedge
  258. mov ebx,ds:dword ptr[0+esi]
  259. mov ecx,ds:dword ptr[12+esi]
  260. cmp eax,ebx
  261. jle LAddedge2
  262. mov ebx,ds:dword ptr[0+ecx]
  263. mov esi,ds:dword ptr[12+ecx]
  264. cmp eax,ebx
  265. jle LAddedge
  266. mov ebx,ds:dword ptr[0+esi]
  267. mov ecx,ds:dword ptr[12+esi]
  268. cmp eax,ebx
  269. jg LContinueSearch
  270. LAddedge2:
  271. mov edx,ds:dword ptr[12+edx]
  272. mov ebx,ds:dword ptr[8+esi]
  273. mov ds:dword ptr[12+edi],esi
  274. mov ds:dword ptr[8+edi],ebx
  275. mov ds:dword ptr[12+ebx],edi
  276. mov ds:dword ptr[8+esi],edi
  277. mov ecx,esi
  278. cmp edx,0
  279. jnz LDoNextEdge
  280. jmp LDone
  281. align 4
  282. LAddedge:
  283. mov edx,ds:dword ptr[12+edx]
  284. mov ebx,ds:dword ptr[8+ecx]
  285. mov ds:dword ptr[12+edi],ecx
  286. mov ds:dword ptr[8+edi],ebx
  287. mov ds:dword ptr[12+ebx],edi
  288. mov ds:dword ptr[8+ecx],edi
  289. cmp edx,0
  290. jnz LDoNextEdge
  291. LDone:
  292. pop ebx
  293. pop esi
  294. pop edi
  295. ret
  296. public _R_RemoveEdges
  297. _R_RemoveEdges:
  298. push ebx
  299. mov eax,ds:dword ptr[4+4+esp]
  300. Lre_loop:
  301. mov ecx,ds:dword ptr[12+eax]
  302. mov ebx,ds:dword ptr[20+eax]
  303. mov edx,ds:dword ptr[8+eax]
  304. test ebx,ebx
  305. mov ds:dword ptr[8+ecx],edx
  306. jz Lre_done
  307. mov ds:dword ptr[12+edx],ecx
  308. mov ecx,ds:dword ptr[12+ebx]
  309. mov edx,ds:dword ptr[8+ebx]
  310. mov eax,ds:dword ptr[20+ebx]
  311. mov ds:dword ptr[8+ecx],edx
  312. test eax,eax
  313. mov ds:dword ptr[12+edx],ecx
  314. jnz Lre_loop
  315. pop ebx
  316. ret
  317. Lre_done:
  318. mov ds:dword ptr[12+edx],ecx
  319. pop ebx
  320. ret
  321. public _R_StepActiveU
  322. _R_StepActiveU:
  323. push edi
  324. mov edx,ds:dword ptr[4+4+esp]
  325. push esi
  326. push ebx
  327. mov esi,ds:dword ptr[8+edx]
  328. LNewEdge:
  329. mov edi,ds:dword ptr[0+esi]
  330. LNextEdge:
  331. mov eax,ds:dword ptr[0+edx]
  332. mov ebx,ds:dword ptr[4+edx]
  333. add eax,ebx
  334. mov esi,ds:dword ptr[12+edx]
  335. mov ds:dword ptr[0+edx],eax
  336. cmp eax,edi
  337. jl LPushBack
  338. mov edi,ds:dword ptr[0+esi]
  339. mov ebx,ds:dword ptr[4+esi]
  340. add edi,ebx
  341. mov edx,ds:dword ptr[12+esi]
  342. mov ds:dword ptr[0+esi],edi
  343. cmp edi,eax
  344. jl LPushBack2
  345. mov eax,ds:dword ptr[0+edx]
  346. mov ebx,ds:dword ptr[4+edx]
  347. add eax,ebx
  348. mov esi,ds:dword ptr[12+edx]
  349. mov ds:dword ptr[0+edx],eax
  350. cmp eax,edi
  351. jl LPushBack
  352. mov edi,ds:dword ptr[0+esi]
  353. mov ebx,ds:dword ptr[4+esi]
  354. add edi,ebx
  355. mov edx,ds:dword ptr[12+esi]
  356. mov ds:dword ptr[0+esi],edi
  357. cmp edi,eax
  358. jnl LNextEdge
  359. LPushBack2:
  360. mov ebx,edx
  361. mov eax,edi
  362. mov edx,esi
  363. mov esi,ebx
  364. LPushBack:
  365. mov ecx,ds:dword ptr[8+edx]
  366. mov ebx,ds:dword ptr[12+edx]
  367. cmp edx,offset _edge_aftertail
  368. jz LUDone
  369. mov edi,ds:dword ptr[8+ecx]
  370. mov ds:dword ptr[8+esi],ecx
  371. mov ds:dword ptr[12+ecx],ebx
  372. LPushBackLoop:
  373. mov ecx,ds:dword ptr[8+edi]
  374. mov ebx,ds:dword ptr[0+edi]
  375. cmp eax,ebx
  376. jnl LPushBackFound
  377. mov edi,ds:dword ptr[8+ecx]
  378. mov ebx,ds:dword ptr[0+ecx]
  379. cmp eax,ebx
  380. jl LPushBackLoop
  381. mov edi,ecx
  382. LPushBackFound:
  383. mov ebx,ds:dword ptr[12+edi]
  384. mov ds:dword ptr[8+edx],edi
  385. mov ds:dword ptr[12+edx],ebx
  386. mov ds:dword ptr[12+edi],edx
  387. mov ds:dword ptr[8+ebx],edx
  388. mov edx,esi
  389. mov esi,ds:dword ptr[8+esi]
  390. cmp edx,offset _edge_tail
  391. jnz LNewEdge
  392. LUDone:
  393. pop ebx
  394. pop esi
  395. pop edi
  396. ret
  397. align 4
  398. TrailingEdge:
  399. mov eax,ds:dword ptr[20+esi]
  400. dec eax
  401. jnz LInverted
  402. mov ds:dword ptr[20+esi],eax
  403. mov ecx,ds:dword ptr[40+esi]
  404. mov edx,ds:dword ptr[12345678h]
  405. LPatch0:
  406. mov eax,ds:dword ptr[_r_bmodelactive]
  407. sub eax,ecx
  408. cmp edx,esi
  409. mov ds:dword ptr[_r_bmodelactive],eax
  410. jnz LNoEmit
  411. mov eax,ds:dword ptr[0+ebx]
  412. shr eax,20
  413. mov edx,ds:dword ptr[16+esi]
  414. mov ecx,ds:dword ptr[0+esi]
  415. cmp eax,edx
  416. jle LNoEmit2
  417. mov ds:dword ptr[16+ecx],eax
  418. sub eax,edx
  419. mov ds:dword ptr[0+ebp],edx
  420. mov ds:dword ptr[8+ebp],eax
  421. mov eax,ds:dword ptr[_current_iv]
  422. mov ds:dword ptr[4+ebp],eax
  423. mov eax,ds:dword ptr[8+esi]
  424. mov ds:dword ptr[12+ebp],eax
  425. mov ds:dword ptr[8+esi],ebp
  426. add ebp,16
  427. mov edx,ds:dword ptr[0+esi]
  428. mov esi,ds:dword ptr[4+esi]
  429. mov ds:dword ptr[0+esi],edx
  430. mov ds:dword ptr[4+edx],esi
  431. ret
  432. LNoEmit2:
  433. mov ds:dword ptr[16+ecx],eax
  434. mov edx,ds:dword ptr[0+esi]
  435. mov esi,ds:dword ptr[4+esi]
  436. mov ds:dword ptr[0+esi],edx
  437. mov ds:dword ptr[4+edx],esi
  438. ret
  439. LNoEmit:
  440. mov edx,ds:dword ptr[0+esi]
  441. mov esi,ds:dword ptr[4+esi]
  442. mov ds:dword ptr[0+esi],edx
  443. mov ds:dword ptr[4+edx],esi
  444. ret
  445. LInverted:
  446. mov ds:dword ptr[20+esi],eax
  447. ret
  448. Lgs_trailing:
  449. push offset Lgs_nextedge
  450. jmp TrailingEdge
  451. public _R_GenerateSpans
  452. _R_GenerateSpans:
  453. push ebp
  454. push edi
  455. push esi
  456. push ebx
  457. mov eax,ds:dword ptr[_surfaces]
  458. mov edx,ds:dword ptr[_edge_head_u_shift20]
  459. add eax,64
  460. mov ebp,ds:dword ptr[_span_p]
  461. mov ds:dword ptr[_r_bmodelactive],0
  462. mov ds:dword ptr[0+eax],eax
  463. mov ds:dword ptr[4+eax],eax
  464. mov ds:dword ptr[16+eax],edx
  465. mov ebx,ds:dword ptr[_edge_head+12]
  466. cmp ebx,offset _edge_tail
  467. jz Lgs_lastspan
  468. Lgs_edgeloop:
  469. mov edi,ds:dword ptr[16+ebx]
  470. mov eax,ds:dword ptr[_surfaces]
  471. mov esi,edi
  472. and edi,0FFFF0000h
  473. and esi,0FFFFh
  474. jz Lgs_leading
  475. shl esi,6
  476. add esi,eax
  477. test edi,edi
  478. jz Lgs_trailing
  479. call near ptr TrailingEdge
  480. mov eax,ds:dword ptr[_surfaces]
  481. Lgs_leading:
  482. shr edi,16-6
  483. mov eax,ds:dword ptr[_surfaces]
  484. add edi,eax
  485. mov esi,ds:dword ptr[12345678h]
  486. LPatch2:
  487. mov edx,ds:dword ptr[20+edi]
  488. mov eax,ds:dword ptr[40+edi]
  489. test eax,eax
  490. jnz Lbmodel_leading
  491. test edx,edx
  492. jnz Lxl_done
  493. inc edx
  494. mov eax,ds:dword ptr[12+edi]
  495. mov ds:dword ptr[20+edi],edx
  496. mov ecx,ds:dword ptr[12+esi]
  497. cmp eax,ecx
  498. jl Lnewtop
  499. Lsortloopnb:
  500. mov esi,ds:dword ptr[0+esi]
  501. mov ecx,ds:dword ptr[12+esi]
  502. cmp eax,ecx
  503. jge Lsortloopnb
  504. jmp LInsertAndExit
  505. align 4
  506. Lbmodel_leading:
  507. test edx,edx
  508. jnz Lxl_done
  509. mov ecx,ds:dword ptr[_r_bmodelactive]
  510. inc edx
  511. inc ecx
  512. mov ds:dword ptr[20+edi],edx
  513. mov ds:dword ptr[_r_bmodelactive],ecx
  514. mov eax,ds:dword ptr[12+edi]
  515. mov ecx,ds:dword ptr[12+esi]
  516. cmp eax,ecx
  517. jl Lnewtop
  518. jz Lzcheck_for_newtop
  519. Lsortloop:
  520. mov esi,ds:dword ptr[0+esi]
  521. mov ecx,ds:dword ptr[12+esi]
  522. cmp eax,ecx
  523. jg Lsortloop
  524. jne LInsertAndExit
  525. mov eax,ds:dword ptr[0+ebx]
  526. sub eax,0FFFFFh
  527. mov ds:dword ptr[Ltemp],eax
  528. fild ds:dword ptr[Ltemp]
  529. fmul ds:dword ptr[float_1_div_0100000h]
  530. fld st(0)
  531. fmul ds:dword ptr[48+edi]
  532. fld ds:dword ptr[_fv]
  533. fmul ds:dword ptr[52+edi]
  534. fxch st(1)
  535. fadd ds:dword ptr[44+edi]
  536. fld ds:dword ptr[48+esi]
  537. fmul st(0),st(3)
  538. fxch st(1)
  539. faddp st(2),st(0)
  540. fld ds:dword ptr[_fv]
  541. fmul ds:dword ptr[52+esi]
  542. fld st(2)
  543. fmul ds:dword ptr[float_point_999]
  544. fxch st(2)
  545. fadd ds:dword ptr[44+esi]
  546. faddp st(1),st(0)
  547. fxch st(1)
  548. fcomp st(1)
  549. fxch st(1)
  550. fmul ds:dword ptr[float_1_point_001]
  551. fxch st(1)
  552. fnstsw ax
  553. test ah,001h
  554. jz Lgotposition_fpop3
  555. fcomp st(1)
  556. fnstsw ax
  557. test ah,045h
  558. jz Lsortloop_fpop2
  559. fld ds:dword ptr[48+edi]
  560. fcomp ds:dword ptr[48+esi]
  561. fnstsw ax
  562. test ah,001h
  563. jz Lgotposition_fpop2
  564. fstp st(0)
  565. fstp st(0)
  566. mov eax,ds:dword ptr[12+edi]
  567. jmp Lsortloop
  568. Lgotposition_fpop3:
  569. fstp st(0)
  570. Lgotposition_fpop2:
  571. fstp st(0)
  572. fstp st(0)
  573. jmp LInsertAndExit
  574. Lnewtop_fpop3:
  575. fstp st(0)
  576. Lnewtop_fpop2:
  577. fstp st(0)
  578. fstp st(0)
  579. mov eax,ds:dword ptr[12+edi]
  580. Lnewtop:
  581. mov eax,ds:dword ptr[0+ebx]
  582. mov edx,ds:dword ptr[16+esi]
  583. shr eax,20
  584. mov ds:dword ptr[16+edi],eax
  585. cmp eax,edx
  586. jle LInsertAndExit
  587. sub eax,edx
  588. mov ds:dword ptr[0+ebp],edx
  589. mov ds:dword ptr[8+ebp],eax
  590. mov eax,ds:dword ptr[_current_iv]
  591. mov ds:dword ptr[4+ebp],eax
  592. mov eax,ds:dword ptr[8+esi]
  593. mov ds:dword ptr[12+ebp],eax
  594. mov ds:dword ptr[8+esi],ebp
  595. add ebp,16
  596. LInsertAndExit:
  597. mov ds:dword ptr[0+edi],esi
  598. mov eax,ds:dword ptr[4+esi]
  599. mov ds:dword ptr[4+edi],eax
  600. mov ds:dword ptr[4+esi],edi
  601. mov ds:dword ptr[0+eax],edi
  602. Lgs_nextedge:
  603. mov ebx,ds:dword ptr[12+ebx]
  604. cmp ebx,offset _edge_tail
  605. jnz Lgs_edgeloop
  606. Lgs_lastspan:
  607. mov esi,ds:dword ptr[12345678h]
  608. LPatch3:
  609. mov eax,ds:dword ptr[_edge_tail_u_shift20]
  610. xor ecx,ecx
  611. mov edx,ds:dword ptr[16+esi]
  612. sub eax,edx
  613. jle Lgs_resetspanstate
  614. mov ds:dword ptr[0+ebp],edx
  615. mov ds:dword ptr[8+ebp],eax
  616. mov eax,ds:dword ptr[_current_iv]
  617. mov ds:dword ptr[4+ebp],eax
  618. mov eax,ds:dword ptr[8+esi]
  619. mov ds:dword ptr[12+ebp],eax
  620. mov ds:dword ptr[8+esi],ebp
  621. add ebp,16
  622. Lgs_resetspanstate:
  623. mov ds:dword ptr[20+esi],ecx
  624. mov esi,ds:dword ptr[0+esi]
  625. cmp esi,012345678h
  626. LPatch4:
  627. jnz Lgs_resetspanstate
  628. mov ds:dword ptr[_span_p],ebp
  629. pop ebx
  630. pop esi
  631. pop edi
  632. pop ebp
  633. ret
  634. align 4
  635. Lxl_done:
  636. inc edx
  637. mov ds:dword ptr[20+edi],edx
  638. jmp Lgs_nextedge
  639. align 4
  640. Lzcheck_for_newtop:
  641. mov eax,ds:dword ptr[0+ebx]
  642. sub eax,0FFFFFh
  643. mov ds:dword ptr[Ltemp],eax
  644. fild ds:dword ptr[Ltemp]
  645. fmul ds:dword ptr[float_1_div_0100000h]
  646. fld st(0)
  647. fmul ds:dword ptr[48+edi]
  648. fld ds:dword ptr[_fv]
  649. fmul ds:dword ptr[52+edi]
  650. fxch st(1)
  651. fadd ds:dword ptr[44+edi]
  652. fld ds:dword ptr[48+esi]
  653. fmul st(0),st(3)
  654. fxch st(1)
  655. faddp st(2),st(0)
  656. fld ds:dword ptr[_fv]
  657. fmul ds:dword ptr[52+esi]
  658. fld st(2)
  659. fmul ds:dword ptr[float_point_999]
  660. fxch st(2)
  661. fadd ds:dword ptr[44+esi]
  662. faddp st(1),st(0)
  663. fxch st(1)
  664. fcomp st(1)
  665. fxch st(1)
  666. fmul ds:dword ptr[float_1_point_001]
  667. fxch st(1)
  668. fnstsw ax
  669. test ah,001h
  670. jz Lnewtop_fpop3
  671. fcomp st(1)
  672. fnstsw ax
  673. test ah,045h
  674. jz Lsortloop_fpop2
  675. fld ds:dword ptr[48+edi]
  676. fcomp ds:dword ptr[48+esi]
  677. fnstsw ax
  678. test ah,001h
  679. jz Lnewtop_fpop2
  680. Lsortloop_fpop2:
  681. fstp st(0)
  682. fstp st(0)
  683. mov eax,ds:dword ptr[12+edi]
  684. jmp Lsortloop
  685. public _R_EdgeCodeEnd
  686. _R_EdgeCodeEnd:
  687. align 4
  688. public _R_SurfacePatch
  689. _R_SurfacePatch:
  690. mov eax,ds:dword ptr[_surfaces]
  691. add eax,64
  692. mov ds:dword ptr[LPatch4-4],eax
  693. add eax,0
  694. mov ds:dword ptr[LPatch0-4],eax
  695. mov ds:dword ptr[LPatch2-4],eax
  696. mov ds:dword ptr[LPatch3-4],eax
  697. ret
  698. _TEXT ENDS
  699. END