📄 mv_mix16.wasm
字号:
.586PEXTRN _MV_HarshClipTable:DWORDEXTRN _MV_MixDestination:DWORDEXTRN _MV_MixPosition:DWORDEXTRN _MV_LeftVolume:DWORDEXTRN _MV_RightVolume:DWORDEXTRN _MV_SampleSize:DWORDEXTRN _MV_RightChannelOffset:DWORDCODE SEGMENT PUBLIC USE32 'DATA'ASSUME cs:CODE,ds:CODE;================;; MV_Mix8BitMono16;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mixALIGN 16PUBLIC MV_Mix8BitMono16_MV_Mix8BitMono16_:; Two at once pushad ; Thanks to Lauri Liinat for spotting this lunacy ;mov eax, dword ptr [esp + 0*4 + 9*4] ;mov edx, dword ptr [esp + 1*4 + 9*4] ;mov ebx, dword ptr [esp + 2*4 + 9*4] ;mov ecx, dword ptr [esp + 3*4 + 9*4] mov ebp, eax mov esi, ebx ; Source pointer inc esi ; Sample size mov ebx, _MV_SampleSize mov byte ptr [apatch7+2],bl mov byte ptr [apatch8+2],bl mov byte ptr [apatch9+3],bl ; Volume table ptr mov ebx, _MV_LeftVolume ; Since we're mono, use left volume mov dword ptr [apatch1+4],ebx mov dword ptr [apatch2+4],ebx ; Harsh Clip table ptr mov ebx, _MV_HarshClipTable add ebx, 128 mov dword ptr [apatch3+2],ebx mov dword ptr [apatch4+2],ebx ; Rate scale ptr mov dword ptr [apatch5+2],edx mov dword ptr [apatch6+2],edx mov edi, _MV_MixDestination ; Get the position to write to ; Number of samples to mix shr ecx, 1 ; double sample count cmp ecx, 0 je exit8m; eax - scratch; ebx - scratch; edx - scratch; ecx - count; edi - destination; esi - source; ebp - frac pointer; apatch1 - volume table; apatch2 - volume table; apatch3 - harsh clip table; apatch4 - harsh clip table; apatch5 - sample rate; apatch6 - sample rate mov eax,ebp ; begin calculating first sample add ebp,edx ; advance frac pointer shr eax,16 ; finish calculation for first sample mov ebx,ebp ; begin calculating second sample add ebp,edx ; advance frac pointer shr ebx,16 ; finish calculation for second sample movsx eax, byte ptr [esi+2*eax] ; get first sample movsx ebx, byte ptr [esi+2*ebx] ; get second sample add eax, 80h add ebx, 80h;ALIGN 4mix8Mloop: movzx edx, byte ptr [edi] ; get current sample from destinationapatch1: movsx eax, byte ptr [2*eax+12345678h] ; volume translate first sampleapatch2: movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate second sample add eax, edx ; mix first sampleapatch9: movzx edx, byte ptr [edi + 1] ; get current sample from destinationapatch3: mov eax, [eax + 12345678h] ; harsh clip new sample add ebx, edx ; mix second sample mov [edi], al ; write new sample to destination mov edx, ebp ; begin calculating third sampleapatch4: mov ebx, [ebx + 12345678h] ; harsh clip new sampleapatch5: add ebp,12345678h ; advance frac pointer shr edx, 16 ; finish calculation for third sample mov eax, ebp ; begin calculating fourth sampleapatch7: add edi, 2 ; move destination to second sample shr eax, 16 ; finish calculation for fourth sample mov [edi], bl ; write new sample to destinationapatch6: add ebp,12345678h ; advance frac pointer movsx ebx, byte ptr [esi+2*eax] ; get fourth sample movsx eax, byte ptr [esi+2*edx] ; get third sample add ebx, 80h add eax, 80hapatch8: add edi, 2 ; move destination to third sample dec ecx ; decrement count jnz mix8Mloop ; loop mov _MV_MixDestination, edi ; Store the current write position mov _MV_MixPosition, ebp ; return positionexit8m: popad ret;================;; MV_Mix8BitStereo16;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mixALIGN 16PUBLIC MV_Mix8BitStereo16_MV_Mix8BitStereo16_: pushad ; Thanks to Lauri Liinat for spotting this lunacy ;mov eax, dword ptr [esp + 0*4 + 9*4] ;mov edx, dword ptr [esp + 1*4 + 9*4] ;mov ebx, dword ptr [esp + 2*4 + 9*4] ;mov ecx, dword ptr [esp + 3*4 + 9*4] mov ebp, eax mov esi, ebx ; Source pointer inc esi ; Sample size mov ebx, _MV_SampleSize mov byte ptr [bpatch8+2],bl ; mov byte ptr [bpatch9+2],bl ; Right channel offset mov ebx, _MV_RightChannelOffset mov dword ptr [bpatch6+3],ebx mov dword ptr [bpatch7+2],ebx ; Volume table ptr mov ebx, _MV_LeftVolume mov dword ptr [bpatch1+4],ebx mov ebx, _MV_RightVolume mov dword ptr [bpatch2+4],ebx ; Rate scale ptr mov dword ptr [bpatch3+2],edx ; Harsh Clip table ptr mov ebx, _MV_HarshClipTable add ebx,128 mov dword ptr [bpatch4+2],ebx mov dword ptr [bpatch5+2],ebx mov edi, _MV_MixDestination ; Get the position to write to ; Number of samples to mix cmp ecx, 0 je short exit8S; eax - scratch; ebx - scratch; edx - scratch; ecx - count; edi - destination; esi - source; ebp - frac pointer; bpatch1 - left volume table; bpatch2 - right volume table; bpatch3 - sample rate; bpatch4 - harsh clip table; bpatch5 - harsh clip table mov eax,ebp ; begin calculating first sample shr eax,16 ; finish calculation for first sample movsx ebx, byte ptr [esi+2*eax] ; get first sample add ebx, 80h;ALIGN 4mix8Sloop:bpatch1: movsx eax, byte ptr [2*ebx+12345678h] ; volume translate left sample movzx edx, byte ptr [edi] ; get current sample from destinationbpatch2: movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate right sample add eax, edx ; mix left samplebpatch3: add ebp,12345678h ; advance frac pointerbpatch6: movzx edx, byte ptr [edi+12345678h] ; get current sample from destinationbpatch4: mov eax, [eax + 12345678h] ; harsh clip left sample add ebx, edx ; mix right sample mov [edi], al ; write left sample to destinationbpatch5: mov ebx, [ebx + 12345678h] ; harsh clip right sample mov edx, ebp ; begin calculating second samplebpatch7: mov [edi+12345678h], bl ; write right sample to destination shr edx, 16 ; finish calculation for second samplebpatch8: add edi, 1 ; move destination to second sample movsx ebx, byte ptr [esi+2*edx] ; get second sample add ebx, 80h dec ecx ; decrement count jnz mix8Sloop ; loop mov _MV_MixDestination, edi ; Store the current write position mov _MV_MixPosition, ebp ; return positionEXIT8S: popad ret;================;; MV_Mix16BitMono16
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -