snd_mixa.asm 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. public _SND_PaintChannelFrom8
  236. _SND_PaintChannelFrom8:
  237. push esi
  238. push edi
  239. push ebx
  240. push ebp
  241. mov ebx,ds:dword ptr[4+16+esp]
  242. mov esi,ds:dword ptr[8+16+esp]
  243. mov eax,ds:dword ptr[4+ebx]
  244. mov edx,ds:dword ptr[8+ebx]
  245. cmp eax,255
  246. jna LLeftSet
  247. mov eax,255
  248. LLeftSet:
  249. cmp edx,255
  250. jna LRightSet
  251. mov edx,255
  252. LRightSet:
  253. and eax,0F8h
  254. add esi,20
  255. and edx,0F8h
  256. mov edi,ds:dword ptr[16+ebx]
  257. mov ecx,ds:dword ptr[12+16+esp]
  258. add esi,edi
  259. shl eax,7
  260. add edi,ecx
  261. shl edx,7
  262. mov ds:dword ptr[16+ebx],edi
  263. add eax,offset _snd_scaletable
  264. add edx,offset _snd_scaletable
  265. sub ebx,ebx
  266. mov bl,ds:byte ptr[-1+esi+ecx*1]
  267. test ecx,1
  268. jz LMix8Loop
  269. mov edi,ds:dword ptr[eax+ebx*4]
  270. mov ebp,ds:dword ptr[edx+ebx*4]
  271. add edi,ds:dword ptr[_paintbuffer+0-8+ecx*8]
  272. add ebp,ds:dword ptr[_paintbuffer+4-8+ecx*8]
  273. mov ds:dword ptr[_paintbuffer+0-8+ecx*8],edi
  274. mov ds:dword ptr[_paintbuffer+4-8+ecx*8],ebp
  275. mov bl,ds:byte ptr[-2+esi+ecx*1]
  276. dec ecx
  277. jz LDone
  278. LMix8Loop:
  279. mov edi,ds:dword ptr[eax+ebx*4]
  280. mov ebp,ds:dword ptr[edx+ebx*4]
  281. add edi,ds:dword ptr[_paintbuffer+0-8+ecx*8]
  282. add ebp,ds:dword ptr[_paintbuffer+4-8+ecx*8]
  283. mov bl,ds:byte ptr[-2+esi+ecx*1]
  284. mov ds:dword ptr[_paintbuffer+0-8+ecx*8],edi
  285. mov ds:dword ptr[_paintbuffer+4-8+ecx*8],ebp
  286. mov edi,ds:dword ptr[eax+ebx*4]
  287. mov ebp,ds:dword ptr[edx+ebx*4]
  288. mov bl,ds:byte ptr[-3+esi+ecx*1]
  289. add edi,ds:dword ptr[_paintbuffer+0-8*2+ecx*8]
  290. add ebp,ds:dword ptr[_paintbuffer+4-8*2+ecx*8]
  291. mov ds:dword ptr[_paintbuffer+0-8*2+ecx*8],edi
  292. mov ds:dword ptr[_paintbuffer+4-8*2+ecx*8],ebp
  293. sub ecx,2
  294. jnz LMix8Loop
  295. LDone:
  296. pop ebp
  297. pop ebx
  298. pop edi
  299. pop esi
  300. ret
  301. public _Snd_WriteLinearBlastStereo16
  302. _Snd_WriteLinearBlastStereo16:
  303. push esi
  304. push edi
  305. push ebx
  306. mov ecx,ds:dword ptr[_snd_linear_count]
  307. mov ebx,ds:dword ptr[_snd_p]
  308. mov esi,ds:dword ptr[_snd_vol]
  309. mov edi,ds:dword ptr[_snd_out]
  310. LWLBLoopTop:
  311. mov eax,ds:dword ptr[-8+ebx+ecx*4]
  312. imul eax,esi
  313. sar eax,8
  314. cmp eax,07FFFh
  315. jg LClampHigh
  316. cmp eax,0FFFF8000h
  317. jnl LClampDone
  318. mov eax,0FFFF8000h
  319. jmp LClampDone
  320. LClampHigh:
  321. mov eax,07FFFh
  322. LClampDone:
  323. mov edx,ds:dword ptr[-4+ebx+ecx*4]
  324. imul edx,esi
  325. sar edx,8
  326. cmp edx,07FFFh
  327. jg LClampHigh2
  328. cmp edx,0FFFF8000h
  329. jnl LClampDone2
  330. mov edx,0FFFF8000h
  331. jmp LClampDone2
  332. LClampHigh2:
  333. mov edx,07FFFh
  334. LClampDone2:
  335. shl edx,16
  336. and eax,0FFFFh
  337. or edx,eax
  338. mov ds:dword ptr[-4+edi+ecx*2],edx
  339. sub ecx,2
  340. jnz LWLBLoopTop
  341. pop ebx
  342. pop edi
  343. pop esi
  344. ret
  345. _TEXT ENDS
  346. END