MVREVERB.ASM 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. IDEAL
  2. p386
  3. MODEL flat
  4. dataseg
  5. CODESEG
  6. MASM
  7. ALIGN 4
  8. ;================
  9. ;
  10. ; MV_16BitReverb
  11. ;
  12. ;================
  13. ; eax - source position
  14. ; edx - destination position
  15. ; ebx - Volume table
  16. ; ecx - number of samples
  17. PROC MV_16BitReverb_
  18. PUBLIC MV_16BitReverb_
  19. mov esi, eax
  20. lea edi, [edx - 2]
  21. ALIGN 4
  22. rev16loop:
  23. movzx eax, word ptr [esi] ; get sample
  24. add edi, 2
  25. movzx edx, ah
  26. sub ah, ah
  27. movsx eax, byte ptr [2*eax+ebx+1] ; volume translate low byte of sample
  28. xor edx, 80h
  29. movsx edx, word ptr [2*edx+ebx] ; volume translate high byte of sample
  30. add esi, 2
  31. lea eax, [ eax + edx + 80h ] ; mix high byte of sample
  32. dec ecx ; decrement count
  33. mov [edi], ax ; write new sample to destination
  34. jnz rev16loop ; loop
  35. ret
  36. ENDP MV_16BitReverb_
  37. ;================
  38. ;
  39. ; MV_8BitReverb
  40. ;
  41. ;================
  42. ; eax - source position
  43. ; edx - destination position
  44. ; ebx - Volume table
  45. ; ecx - number of samples
  46. PROC MV_8BitReverb_
  47. PUBLIC MV_8BitReverb_
  48. mov esi, eax
  49. lea edi, [edx - 1]
  50. xor eax, eax
  51. ALIGN 4
  52. rev8loop:
  53. ; movzx eax, byte ptr [esi] ; get sample
  54. mov al, byte ptr [esi] ; get sample
  55. inc edi
  56. ; movsx eax, byte ptr [2*eax+ebx] ; volume translate sample
  57. mov al, byte ptr [2*eax+ebx] ; volume translate sample
  58. inc esi
  59. ; add eax, 80h
  60. add al, 80h
  61. dec ecx ; decrement count
  62. mov [edi], al ; write new sample to destination
  63. jnz rev8loop ; loop
  64. ret
  65. ENDP MV_8BitReverb_
  66. ;================
  67. ;
  68. ; MV_16BitReverbFast
  69. ;
  70. ;================
  71. ; eax - source position
  72. ; edx - destination position
  73. ; ebx - number of samples
  74. ; ecx - shift
  75. PROC MV_16BitReverbFast_
  76. PUBLIC MV_16BitReverbFast_
  77. mov esi, eax
  78. mov eax,OFFSET rpatch16+3
  79. mov [eax],cl
  80. lea edi, [edx - 2]
  81. ALIGN 4
  82. frev16loop:
  83. mov ax, word ptr [esi] ; get sample
  84. add edi, 2
  85. rpatch16:
  86. sar ax, 5 ;;;;Add 1 before shift
  87. add esi, 2
  88. mov [edi], ax ; write new sample to destination
  89. dec ebx ; decrement count
  90. jnz frev16loop ; loop
  91. ret
  92. ENDP MV_16BITREVERBFAST_
  93. ;================
  94. ;
  95. ; MV_8BitReverbFast
  96. ;
  97. ;================
  98. ; eax - source position
  99. ; edx - destination position
  100. ; ebx - number of samples
  101. ; ecx - shift
  102. PROC MV_8BitReverbFast_
  103. PUBLIC MV_8BitReverbFast_
  104. mov esi, eax
  105. mov eax,OFFSET rpatch8+2
  106. mov edi, edx
  107. mov edx, 80h
  108. mov [eax],cl
  109. mov eax, 80h
  110. shr eax, cl
  111. dec edi
  112. sub edx, eax
  113. ALIGN 4
  114. frev8loop:
  115. mov al, byte ptr [esi] ; get sample
  116. inc esi
  117. mov ecx, eax
  118. inc edi
  119. rpatch8:
  120. shr eax, 3
  121. xor ecx, 80h ; flip the sign bit
  122. shr ecx, 7 ; shift the sign down to 1
  123. add eax, edx
  124. add eax, ecx ; add sign bit to round to 0
  125. dec ebx ; decrement count
  126. mov [edi], al ; write new sample to destination
  127. jnz frev8loop ; loop
  128. ret
  129. ENDP MV_8BITREVERBFAST_
  130. ENDS
  131. END