MV_MIX3.ASM 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. .386
  2. .MODEL flat
  3. .data
  4. .code
  5. SEGMENT text USE32
  6. ALIGN 16
  7. ;================
  8. ;
  9. ; MV_Mix8BitMonoFast
  10. ;
  11. ;================
  12. ; eax - position
  13. ; edx - rate
  14. ; ebx - Harsh clip table
  15. ; edi - to
  16. ; esi - start
  17. ; ecx - Volume table
  18. MixBufferSize equ 256
  19. PROC MV_Mix8BitMonoFast_
  20. PUBLIC MV_Mix8BitMonoFast_
  21. ; Two at once
  22. push ebp
  23. mov ebp, eax
  24. ; Volume table ptr
  25. mov eax,OFFSET apatch1+3 ; convice tasm to modify code...
  26. mov [eax],ecx
  27. mov eax,OFFSET apatch2+3 ; convice tasm to modify code...
  28. mov [eax],ecx
  29. ; Harsh Clip table ptr
  30. add ebx,128
  31. mov eax,OFFSET apatch3+2 ; convice tasm to modify code...
  32. mov [eax],ebx
  33. mov eax,OFFSET apatch4+2 ; convice tasm to modify code...
  34. mov [eax],ebx
  35. ; Rate scale ptr
  36. mov eax,OFFSET apatch5+2 ; convice tasm to modify code...
  37. mov [eax],edx
  38. mov eax,OFFSET apatch6+2 ; convice tasm to modify code...
  39. mov [eax],edx
  40. mov ecx, MixBufferSize / 2 ; double pixel count
  41. ; eax - scratch
  42. ; ebx - scratch
  43. ; edx - scratch
  44. ; ecx - count
  45. ; edi - destination
  46. ; esi - source
  47. ; ebp - frac pointer
  48. ; apatch1 - volume table
  49. ; apatch2 - volume table
  50. ; apatch3 - harsh clip table
  51. ; apatch4 - harsh clip table
  52. ; apatch5 - sample rate
  53. ; apatch6 - sample rate
  54. mov eax,ebp ; begin calculating first sample
  55. add ebp,edx ; advance frac pointer
  56. shr eax,16 ; finish calculation for first sample
  57. mov ebx,ebp ; begin calculating second sample
  58. add ebp,edx ; advance frac pointer
  59. shr ebx,16 ; finish calculation for second sample
  60. movzx eax, byte ptr [esi+eax] ; get first sample
  61. movzx ebx, byte ptr [esi+ebx] ; get second sample
  62. ALIGN 16
  63. mix8Mloop:
  64. movzx edx, byte ptr [edi] ; get current sample from destination
  65. apatch1:
  66. movsx eax, byte ptr [eax+12345678h] ; volume translate first sample
  67. apatch2:
  68. movsx ebx, byte ptr [ebx+12345678h] ; volume translate second sample
  69. add eax, edx ; mix first sample
  70. movzx edx, byte ptr [edi + 1] ; get current sample from destination
  71. apatch3:
  72. mov eax, [eax + 12345678h] ; harsh clip new sample
  73. add ebx, edx ; mix second sample
  74. mov [edi], al ; write new sample to destination
  75. mov edx, ebp ; begin calculating third sample
  76. apatch4:
  77. mov ebx, [ebx + 12345678h] ; harsh clip new sample
  78. apatch5:
  79. add ebp,12345678h ; advance frac pointer
  80. shr edx, 16 ; finish calculation for third sample
  81. mov eax, ebp ; begin calculating fourth sample
  82. inc edi ; move destination to second sample
  83. shr eax, 16 ; finish calculation for fourth sample
  84. mov [edi], bl ; write new sample to destination
  85. apatch6:
  86. add ebp,12345678h ; advance frac pointer
  87. movzx ebx, byte ptr [esi+eax] ; get fourth sample
  88. movzx eax, byte ptr [esi+edx] ; get third sample
  89. inc edi ; move destination to third sample
  90. dec ecx ; decrement count
  91. jnz mix8Mloop ; loop
  92. pop ebp
  93. ret
  94. ENDP MV_Mix8BitMonoFast_
  95. ;================
  96. ;
  97. ; MV_Mix8BitStereoFast
  98. ;
  99. ;================
  100. ; eax - position
  101. ; edx - rate
  102. ; ebx - Harsh clip table
  103. ; edi - to
  104. ; esi - start
  105. ; ecx - Left Volume table
  106. ; esp + 8 - Right Volume table
  107. PROC MV_Mix8BitStereoFast_
  108. PUBLIC MV_Mix8BitStereoFast_
  109. push ebp
  110. mov ebp, eax
  111. ; Volume table ptr
  112. mov eax,OFFSET bpatch1+3 ; convice tasm to modify code...
  113. mov [eax],ecx
  114. mov ecx, [ esp + 8 ]
  115. mov eax,OFFSET bpatch2+3 ; convice tasm to modify code...
  116. mov [eax],ecx
  117. ; Rate scale ptr
  118. mov eax,OFFSET bpatch3+2 ; convice tasm to modify code...
  119. mov [eax],edx
  120. ; Harsh Clip table ptr
  121. add ebx,128
  122. mov eax,OFFSET bpatch4+2 ; convice tasm to modify code...
  123. mov [eax],ebx
  124. mov eax,OFFSET bpatch5+2 ; convice tasm to modify code...
  125. mov [eax],ebx
  126. mov ecx, MixBufferSize
  127. ; eax - scratch
  128. ; ebx - scratch
  129. ; edx - scratch
  130. ; ecx - count
  131. ; edi - destination
  132. ; esi - source
  133. ; ebp - frac pointer
  134. ; bpatch1 - left volume table
  135. ; bpatch2 - right volume table
  136. ; bpatch3 - sample rate
  137. ; bpatch4 - harsh clip table
  138. ; bpatch5 - harsh clip table
  139. mov eax,ebp ; begin calculating first sample
  140. shr eax,16 ; finish calculation for first sample
  141. movzx ebx, byte ptr [esi+eax] ; get first sample
  142. ALIGN 16
  143. mix8Sloop:
  144. bpatch1:
  145. movsx eax, byte ptr [ebx+12345678h] ; volume translate left sample
  146. movzx edx, byte ptr [edi] ; get current sample from destination
  147. bpatch2:
  148. movsx ebx, byte ptr [ebx+12345678h] ; volume translate right sample
  149. add eax, edx ; mix left sample
  150. bpatch3:
  151. add ebp,12345678h ; advance frac pointer
  152. movzx edx, byte ptr [edi+1] ; get current sample from destination
  153. bpatch4:
  154. mov eax, [eax + 12345678h] ; harsh clip left sample
  155. add ebx, edx ; mix right sample
  156. mov [edi], al ; write left sample to destination
  157. bpatch5:
  158. mov ebx, [ebx + 12345678h] ; harsh clip right sample
  159. inc edi ; move destination to second sample
  160. mov edx, ebp ; begin calculating second sample
  161. mov [edi], bl ; write right sample to destination
  162. shr edx, 16 ; finish calculation for second sample
  163. inc edi ; move destination to second sample
  164. movzx ebx, byte ptr [esi+edx] ; get second sample
  165. dec ecx ; decrement count
  166. jnz mix8Sloop ; loop
  167. pop ebp
  168. ret
  169. ENDP MV_Mix8BitStereoFast_
  170. ;================
  171. ;
  172. ; MV_Mix8Bit1ChannelFast
  173. ;
  174. ;================
  175. ; eax - position
  176. ; edx - rate
  177. ; ebx - Harsh clip table
  178. ; edi - to
  179. ; esi - start
  180. ; ecx - Volume table
  181. PROC MV_Mix8Bit1ChannelFast_
  182. PUBLIC MV_Mix8Bit1ChannelFast_
  183. ; Two at once
  184. push ebp
  185. mov ebp, eax
  186. ; Volume table ptr
  187. mov eax,OFFSET epatch1+3 ; convice tasm to modify code...
  188. mov [eax],ecx
  189. mov eax,OFFSET epatch2+3 ; convice tasm to modify code...
  190. mov [eax],ecx
  191. ; Harsh Clip table ptr
  192. add ebx,128
  193. mov eax,OFFSET epatch3+2 ; convice tasm to modify code...
  194. mov [eax],ebx
  195. mov eax,OFFSET epatch4+2 ; convice tasm to modify code...
  196. mov [eax],ebx
  197. ; Rate scale ptr
  198. mov eax,OFFSET epatch5+2 ; convice tasm to modify code...
  199. mov [eax],edx
  200. mov eax,OFFSET epatch6+2 ; convice tasm to modify code...
  201. mov [eax],edx
  202. mov ecx, MixBufferSize / 2 ; double pixel count
  203. ; eax - scratch
  204. ; ebx - scratch
  205. ; edx - scratch
  206. ; ecx - count
  207. ; edi - destination
  208. ; esi - source
  209. ; ebp - frac pointer
  210. ; apatch1 - volume table
  211. ; apatch2 - volume table
  212. ; apatch3 - harsh clip table
  213. ; apatch4 - harsh clip table
  214. ; apatch5 - sample rate
  215. ; apatch6 - sample rate
  216. mov eax,ebp ; begin calculating first sample
  217. add ebp,edx ; advance frac pointer
  218. shr eax,16 ; finish calculation for first sample
  219. mov ebx,ebp ; begin calculating second sample
  220. add ebp,edx ; advance frac pointer
  221. shr ebx,16 ; finish calculation for second sample
  222. movzx eax, byte ptr [esi+eax] ; get first sample
  223. movzx ebx, byte ptr [esi+ebx] ; get second sample
  224. ALIGN 16
  225. mix81Cloop:
  226. movzx edx, byte ptr [edi] ; get current sample from destination
  227. epatch1:
  228. movsx eax, byte ptr [eax+12345678h] ; volume translate first sample
  229. epatch2:
  230. movsx ebx, byte ptr [ebx+12345678h] ; volume translate second sample
  231. add eax, edx ; mix first sample
  232. movzx edx, byte ptr [edi + 2] ; get current sample from destination
  233. epatch3:
  234. mov eax, [eax + 12345678h] ; harsh clip new sample
  235. add ebx, edx ; mix second sample
  236. mov [edi], al ; write new sample to destination
  237. mov edx, ebp ; begin calculating third sample
  238. epatch4:
  239. mov ebx, [ebx + 12345678h] ; harsh clip new sample
  240. epatch5:
  241. add ebp,12345678h ; advance frac pointer
  242. shr edx, 16 ; finish calculation for third sample
  243. mov eax, ebp ; begin calculating fourth sample
  244. add edi, 2 ; move destination to second sample
  245. shr eax, 16 ; finish calculation for fourth sample
  246. mov [edi], bl ; write new sample to destination
  247. epatch6:
  248. add ebp,12345678h ; advance frac pointer
  249. movzx ebx, byte ptr [esi+eax] ; get fourth sample
  250. movzx eax, byte ptr [esi+edx] ; get third sample
  251. add edi, 2 ; move destination to third sample
  252. dec ecx ; decrement count
  253. jnz mix81Cloop ; loop
  254. pop ebp
  255. ret
  256. ENDP MV_Mix8Bit1ChannelFast_
  257. ;================
  258. ;
  259. ; MV_Mix16BitMonoFast
  260. ;
  261. ;================
  262. ; eax - position
  263. ; edx - rate
  264. ; edi - to
  265. ; esi - start
  266. ; ecx - Volume table
  267. MixBufferSize equ 256
  268. PROC MV_Mix16BitMonoFast_
  269. PUBLIC MV_Mix16BitMonoFast_
  270. ; Two at once
  271. push ebp
  272. mov ebp, eax
  273. ; Volume table ptr
  274. mov eax,OFFSET cpatch1+4 ; convice tasm to modify code...
  275. mov [eax],ecx
  276. mov eax,OFFSET cpatch2+4 ; convice tasm to modify code...
  277. mov [eax],ecx
  278. ; Rate scale ptr
  279. mov eax,OFFSET cpatch3+2 ; convice tasm to modify code...
  280. mov [eax],edx
  281. mov eax,OFFSET cpatch4+2 ; convice tasm to modify code...
  282. mov [eax],edx
  283. mov ecx, MixBufferSize / 2 ; double pixel count
  284. ; eax - scratch
  285. ; ebx - scratch
  286. ; edx - scratch
  287. ; ecx - count
  288. ; edi - destination
  289. ; esi - source
  290. ; ebp - frac pointer
  291. ; cpatch1 - volume table
  292. ; cpatch2 - volume table
  293. ; cpatch3 - sample rate
  294. ; cpatch4 - sample rate
  295. mov eax,ebp ; begin calculating first sample
  296. add ebp,edx ; advance frac pointer
  297. shr eax,16 ; finish calculation for first sample
  298. mov ebx,ebp ; begin calculating second sample
  299. add ebp,edx ; advance frac pointer
  300. shr ebx,16 ; finish calculation for second sample
  301. movzx eax, byte ptr [esi+eax] ; get first sample
  302. movzx ebx, byte ptr [esi+ebx] ; get second sample
  303. ALIGN 16
  304. mix16Mloop:
  305. movsx edx, word ptr [edi] ; get current sample from destination
  306. cpatch1:
  307. movsx eax, word ptr [2*eax+12345678h] ; volume translate first sample
  308. cpatch2:
  309. movsx ebx, word ptr [2*ebx+12345678h] ; volume translate second sample
  310. add eax, edx ; mix first sample
  311. movsx edx, word ptr [edi + 2] ; get current sample from destination
  312. cmp eax, -32768 ; Harsh clip sample
  313. jge short m16skip1
  314. mov eax, -32768
  315. jmp short m16skip2
  316. m16skip1:
  317. cmp eax, 32767
  318. jle short m16skip2
  319. mov eax, 32767
  320. m16skip2:
  321. add ebx, edx ; mix second sample
  322. mov [edi], ax ; write new sample to destination
  323. mov edx, ebp ; begin calculating third sample
  324. cmp ebx, -32768 ; Harsh clip sample
  325. jge short m16skip3
  326. mov ebx, -32768
  327. jmp short m16skip4
  328. m16skip3:
  329. cmp ebx, 32767
  330. jle short m16skip4
  331. mov ebx, 32767
  332. m16skip4:
  333. cpatch3:
  334. add ebp,12345678h ; advance frac pointer
  335. shr edx, 16 ; finish calculation for third sample
  336. mov eax, ebp ; begin calculating fourth sample
  337. mov [edi + 2], bx ; write new sample to destination
  338. shr eax, 16 ; finish calculation for fourth sample
  339. cpatch4:
  340. add ebp,12345678h ; advance frac pointer
  341. movzx ebx, byte ptr [esi+eax] ; get fourth sample
  342. add edi, 4 ; move destination to third sample
  343. movzx eax, byte ptr [esi+edx] ; get third sample
  344. dec ecx ; decrement count
  345. jnz mix16Mloop ; loop
  346. pop ebp
  347. ret
  348. ENDP MV_Mix16BitMonoFast_
  349. ;================
  350. ;
  351. ; MV_Mix16BitStereoFast
  352. ;
  353. ;================
  354. ; eax - position
  355. ; edx - rate
  356. ; edi - to
  357. ; esi - start
  358. ; ecx - Left Volume table
  359. ; ebx - Right Volume table
  360. PROC MV_Mix16BitStereoFast_
  361. PUBLIC MV_Mix16BitStereoFast_
  362. push ebp
  363. mov ebp, eax
  364. ; Volume table ptr
  365. mov eax,OFFSET dpatch1+4 ; convice tasm to modify code...
  366. mov [eax],ecx
  367. mov ecx, ebx
  368. mov eax,OFFSET dpatch2+4 ; convice tasm to modify code...
  369. mov [eax],ecx
  370. ; Rate scale ptr
  371. mov eax,OFFSET dpatch3+2 ; convice tasm to modify code...
  372. mov [eax],edx
  373. mov ecx, MixBufferSize
  374. ; eax - scratch
  375. ; ebx - scratch
  376. ; edx - scratch
  377. ; ecx - count
  378. ; edi - destination
  379. ; esi - source
  380. ; ebp - frac pointer
  381. ; dpatch1 - left volume table
  382. ; dpatch2 - right volume table
  383. ; dpatch3 - sample rate
  384. mov eax,ebp ; begin calculating first sample
  385. shr eax,16 ; finish calculation for first sample
  386. movzx ebx, byte ptr [esi+eax] ; get first sample
  387. ALIGN 16
  388. mix16Sloop:
  389. dpatch1:
  390. movsx eax, word ptr [2*ebx+12345678h] ; volume translate left sample
  391. movsx edx, word ptr [edi] ; get current sample from destination
  392. dpatch2:
  393. movsx ebx, word ptr [2*ebx+12345678h] ; volume translate right sample
  394. add eax, edx ; mix left sample
  395. dpatch3:
  396. add ebp,12345678h ; advance frac pointer
  397. movsx edx, word ptr [edi+2] ; get current sample from destination
  398. cmp eax, -32768 ; Harsh clip sample
  399. jge short s16skip1
  400. mov eax, -32768
  401. jmp short s16skip2
  402. s16skip1:
  403. cmp eax, 32767
  404. jle short s16skip2
  405. mov eax, 32767
  406. s16skip2:
  407. add ebx, edx ; mix right sample
  408. mov [edi], ax ; write left sample to destination
  409. cmp ebx, -32768 ; Harsh clip sample
  410. jge short s16skip3
  411. mov ebx, -32768
  412. jmp short s16skip4
  413. s16skip3:
  414. cmp ebx, 32767
  415. jle short s16skip4
  416. mov ebx, 32767
  417. s16skip4:
  418. mov edx, ebp ; begin calculating second sample
  419. mov [edi+2], bx ; write right sample to destination
  420. shr edx, 16 ; finish calculation for second sample
  421. add edi, 4 ; move destination to second sample
  422. movzx ebx, byte ptr [esi+edx] ; get second sample
  423. dec ecx ; decrement count
  424. jnz mix16Sloop ; loop
  425. pop ebp
  426. ret
  427. ENDP MV_Mix16BitStereoFast_
  428. ;================
  429. ;
  430. ; MV_Mix16Bit1ChannelFast
  431. ;
  432. ;================
  433. ; eax - position
  434. ; edx - rate
  435. ; edi - to
  436. ; esi - start
  437. ; ecx - Volume table
  438. MixBufferSize equ 256
  439. PROC MV_Mix16Bit1ChannelFast_
  440. PUBLIC MV_Mix16Bit1ChannelFast_
  441. ; Two at once
  442. push ebp
  443. mov ebp, eax
  444. ; Volume table ptr
  445. mov eax,OFFSET fpatch1+4 ; convice tasm to modify code...
  446. mov [eax],ecx
  447. mov eax,OFFSET fpatch2+4 ; convice tasm to modify code...
  448. mov [eax],ecx
  449. ; Rate scale ptr
  450. mov eax,OFFSET fpatch3+2 ; convice tasm to modify code...
  451. mov [eax],edx
  452. mov eax,OFFSET fpatch4+2 ; convice tasm to modify code...
  453. mov [eax],edx
  454. mov ecx, MixBufferSize / 2 ; double pixel count
  455. ; eax - scratch
  456. ; ebx - scratch
  457. ; edx - scratch
  458. ; ecx - count
  459. ; edi - destination
  460. ; esi - source
  461. ; ebp - frac pointer
  462. ; cpatch1 - volume table
  463. ; cpatch2 - volume table
  464. ; cpatch3 - sample rate
  465. ; cpatch4 - sample rate
  466. mov eax,ebp ; begin calculating first sample
  467. add ebp,edx ; advance frac pointer
  468. shr eax,16 ; finish calculation for first sample
  469. mov ebx,ebp ; begin calculating second sample
  470. add ebp,edx ; advance frac pointer
  471. shr ebx,16 ; finish calculation for second sample
  472. movzx eax, byte ptr [esi+eax] ; get first sample
  473. movzx ebx, byte ptr [esi+ebx] ; get second sample
  474. ALIGN 16
  475. mix161Cloop:
  476. movsx edx, word ptr [edi] ; get current sample from destination
  477. fpatch1:
  478. movsx eax, word ptr [2*eax+12345678h] ; volume translate first sample
  479. fpatch2:
  480. movsx ebx, word ptr [2*ebx+12345678h] ; volume translate second sample
  481. add eax, edx ; mix first sample
  482. movsx edx, word ptr [edi + 4] ; get current sample from destination
  483. cmp eax, -32768 ; Harsh clip sample
  484. jge short m16c1skip1
  485. mov eax, -32768
  486. jmp short m16c1skip2
  487. m16c1skip1:
  488. cmp eax, 32767
  489. jle short m16c1skip2
  490. mov eax, 32767
  491. m16c1skip2:
  492. add ebx, edx ; mix second sample
  493. mov [edi], ax ; write new sample to destination
  494. mov edx, ebp ; begin calculating third sample
  495. cmp ebx, -32768 ; Harsh clip sample
  496. jge short m16c1skip3
  497. mov ebx, -32768
  498. jmp short m16c1skip4
  499. m16c1skip3:
  500. cmp ebx, 32767
  501. jle short m16c1skip4
  502. mov ebx, 32767
  503. m16c1skip4:
  504. fpatch3:
  505. add ebp,12345678h ; advance frac pointer
  506. shr edx, 16 ; finish calculation for third sample
  507. mov eax, ebp ; begin calculating fourth sample
  508. mov [edi + 4], bx ; write new sample to destination
  509. shr eax, 16 ; finish calculation for fourth sample
  510. fpatch4:
  511. add ebp,12345678h ; advance frac pointer
  512. movzx ebx, byte ptr [esi+eax] ; get fourth sample
  513. add edi, 8 ; move destination to third sample
  514. movzx eax, byte ptr [esi+edx] ; get third sample
  515. dec ecx ; decrement count
  516. jnz mix161Cloop ; loop
  517. pop ebp
  518. ret
  519. ENDP MV_Mix16Bit1ChannelFast_
  520. ENDS
  521. END