MV_MIX2.ASM 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. ; ecx - Volume table
  15. ; ebx - Harsh clip table
  16. ; edi - to
  17. ; esi - start
  18. MixBufferSize equ 256
  19. PROC MV_Mix8BitMonoFast_
  20. PUBLIC MV_Mix8BitMonoFast_
  21. ; Two at once
  22. push ebp
  23. ; mov edi,[to]
  24. ; mov esi,[start]
  25. ; mov ebp,[position]
  26. ; mov edx,[Rate]
  27. mov ebp, eax
  28. ; Volume table ptr
  29. ; mov ecx,[VolumeTable]
  30. mov eax,OFFSET apatch1+3 ; convice tasm to modify code...
  31. mov [eax],ecx
  32. mov eax,OFFSET apatch2+3 ; convice tasm to modify code...
  33. mov [eax],ecx
  34. ; Harsh Clip table ptr
  35. ; mov ebx,HarshClipTable ; get harsh clip table address
  36. add ebx,128
  37. mov eax,OFFSET apatch3+2 ; convice tasm to modify code...
  38. mov [eax],ebx
  39. mov eax,OFFSET apatch4+2 ; convice tasm to modify code...
  40. mov [eax],ebx
  41. ; Rate scale ptr
  42. ; mov edx,[rate]
  43. mov eax,OFFSET apatch5+2 ; convice tasm to modify code...
  44. mov [eax],edx
  45. mov eax,OFFSET apatch6+2 ; convice tasm to modify code...
  46. mov [eax],edx
  47. mov ecx, MixBufferSize / 2 ; double pixel count
  48. ; eax - scratch
  49. ; ebx - scratch
  50. ; edx - scratch
  51. ; ecx - count
  52. ; edi - destination
  53. ; esi - source
  54. ; ebp - frac pointer
  55. ; apatch1 - volume table
  56. ; apatch2 - volume table
  57. ; apatch3 - harsh clip table
  58. ; apatch4 - harsh clip table
  59. ; apatch5 - sample rate
  60. ; apatch6 - sample rate
  61. mov eax,ebp ; begin calculating first sample
  62. add ebp,edx ; advance frac pointer
  63. shr eax,16 ; finish calculation for first sample
  64. mov ebx,ebp ; begin calculating second sample
  65. add ebp,edx ; advance frac pointer
  66. shr ebx,16 ; finish calculation for second sample
  67. movzx eax, byte ptr [esi+eax] ; get first sample
  68. movzx ebx, byte ptr [esi+ebx] ; get second sample
  69. ALIGN 16
  70. mix8Mloop:
  71. movzx edx, byte ptr [edi] ; get current sample from destination
  72. apatch1:
  73. movsx eax, byte ptr [eax+12345678h] ; volume translate first sample
  74. apatch2:
  75. movsx ebx, byte ptr [ebx+12345678h] ; volume translate second sample
  76. add eax, edx ; mix first sample
  77. movzx edx, byte ptr [edi + 1] ; get current sample from destination
  78. apatch3:
  79. mov eax, [eax + 12345678h] ; harsh clip new sample
  80. add ebx, edx ; mix second sample
  81. mov [edi], al ; write new sample to destination
  82. mov edx, ebp ; begin calculating third sample
  83. apatch4:
  84. mov ebx, [ebx + 12345678h] ; harsh clip new sample
  85. apatch5:
  86. add ebp,12345678h ; advance frac pointer
  87. shr edx, 16 ; finish calculation for third sample
  88. mov eax, ebp ; begin calculating fourth sample
  89. inc edi ; move destination to second sample
  90. shr eax, 16 ; finish calculation for fourth sample
  91. mov [edi], bl ; write new sample to destination
  92. apatch6:
  93. add ebp,12345678h ; advance frac pointer
  94. movzx ebx, byte ptr [esi+eax] ; get fourth sample
  95. movzx eax, byte ptr [esi+edx] ; get third sample
  96. inc edi ; move destination to third sample
  97. dec ecx ; decrement count
  98. jnz mix8Mloop ; loop
  99. pop ebp
  100. ret
  101. ENDP
  102. ENDS
  103. END