⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mv_mix.wasm

📁 An interactive water fountain. A realistic water source in your pocket with full control. Contro
💻 WASM
📖 第 1 页 / 共 2 页
字号:
;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mixALIGN 16PUBLIC  MV_Mix16BitMono_MV_Mix16BitMono_:; 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        ; Sample size        mov     ebx, _MV_SampleSize        mov     byte ptr [cpatch5+3],bl        mov     byte ptr [cpatch6+3],bl        add     bl,bl        mov     byte ptr [cpatch7+2],bl        ; Volume table ptr        mov     ebx, _MV_LeftVolume        mov     dword ptr [cpatch1+4],ebx        mov     dword ptr [cpatch2+4],ebx        ; Rate scale ptr        mov     dword ptr [cpatch3+2],edx        mov     dword ptr [cpatch4+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      exit16M;     eax - scratch;     ebx - scratch;     edx - scratch;     ecx - count;     edi - destination;     esi - source;     ebp - frac pointer; cpatch1 - volume table; cpatch2 - volume table; cpatch3 - sample rate; cpatch4 - 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        movzx   eax, byte ptr [esi+eax]         ; get first sample        movzx   ebx, byte ptr [esi+ebx]         ; get second sample;ALIGN 4mix16Mloop:        movsx   edx, word ptr [edi]             ; get current sample from destinationcpatch1:        movsx   eax, word ptr [2*eax+12345678h] ; volume translate first samplecpatch2:        movsx   ebx, word ptr [2*ebx+12345678h] ; volume translate second sample        add     eax, edx                        ; mix first samplecpatch5:        movsx   edx, word ptr [edi + 2]         ; get current sample from destination        cmp     eax, -32768                     ; Harsh clip sample        jge     short m16skip1        mov     eax, -32768        jmp     short m16skip2m16skip1:        cmp     eax, 32767        jle     short m16skip2        mov     eax, 32767m16skip2:        add     ebx, edx                        ; mix second sample        mov     [edi], ax                       ; write new sample to destination        mov     edx, ebp                        ; begin calculating third sample        cmp     ebx, -32768                     ; Harsh clip sample        jge     short m16skip3        mov     ebx, -32768        jmp     short m16skip4m16skip3:        cmp     ebx, 32767        jle     short m16skip4        mov     ebx, 32767m16skip4:cpatch3:        add     ebp,12345678h                   ; advance frac pointer        shr     edx, 16                         ; finish calculation for third sample        mov     eax, ebp                        ; begin calculating fourth samplecpatch6:        mov     [edi + 2], bx                   ; write new sample to destination        shr     eax, 16                         ; finish calculation for fourth samplecpatch4:        add     ebp,12345678h                   ; advance frac pointer        movzx   ebx, byte ptr [esi+eax]         ; get fourth samplecpatch7:        add     edi, 4                          ; move destination to third sample        movzx   eax, byte ptr [esi+edx]         ; get third sample        dec     ecx                             ; decrement count        jnz     mix16Mloop                      ; loop        mov     _MV_MixDestination, edi         ; Store the current write position        mov     _MV_MixPosition, ebp            ; return positionEXIT16M:        popad        ret;================;; MV_Mix16BitStereo;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mixALIGN 16PUBLIC  MV_Mix16BitStereo_MV_Mix16BitStereo_:        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        ; Sample size        mov     ebx, _MV_SampleSize        mov     byte ptr [dpatch6+2],bl        ; Right channel offset        mov     ebx, _MV_RightChannelOffset        mov     dword ptr [dpatch4+3],ebx        mov     dword ptr [dpatch5+3],ebx        ; Volume table ptr        mov     ebx, _MV_LeftVolume        mov     dword ptr [dpatch1+4],ebx        mov     ebx, _MV_RightVolume        mov     dword ptr [dpatch2+4],ebx        ; Rate scale ptr        mov     dword ptr [dpatch3+2],edx        mov     edi, _MV_MixDestination         ; Get the position to write to        ; Number of samples to mix        cmp     ecx, 0        je      exit16S;     eax - scratch;     ebx - scratch;     edx - scratch;     ecx - count;     edi - destination;     esi - source;     ebp - frac pointer; dpatch1 - left volume table; dpatch2 - right volume table; dpatch3 - sample rate        mov     eax,ebp                         ; begin calculating first sample        shr     eax,16                          ; finish calculation for first sample        movzx   ebx, byte ptr [esi+eax]         ; get first sample;ALIGN 4mix16Sloop:dpatch1:        movsx   eax, word ptr [2*ebx+12345678h] ; volume translate left sample        movsx   edx, word ptr [edi]             ; get current sample from destinationdpatch2:        movsx   ebx, word ptr [2*ebx+12345678h] ; volume translate right sample        add     eax, edx                        ; mix left sampledpatch3:        add     ebp,12345678h                   ; advance frac pointerdpatch4:        movsx   edx, word ptr [edi+12345678h]   ; get current sample from destination        cmp     eax, -32768                     ; Harsh clip sample        jge     short s16skip1        mov     eax, -32768        jmp     short s16skip2s16skip1:        cmp     eax, 32767        jle     short s16skip2        mov     eax, 32767s16skip2:        add     ebx, edx                        ; mix right sample        mov     [edi], ax                       ; write left sample to destination        cmp     ebx, -32768                     ; Harsh clip sample        jge     short s16skip3        mov     ebx, -32768        jmp     short s16skip4s16skip3:        cmp     ebx, 32767        jle     short s16skip4        mov     ebx, 32767s16skip4:        mov     edx, ebp                        ; begin calculating second sampledpatch5:        mov     [edi+12345678h], bx             ; write right sample to destination        shr     edx, 16                         ; finish calculation for second sampledpatch6:        add     edi, 4                          ; move destination to second sample        movzx   ebx, byte ptr [esi+edx]         ; get second sample        dec     ecx                             ; decrement count        jnz     mix16Sloop                      ; loop        mov     _MV_MixDestination, edi         ; Store the current write position        mov     _MV_MixPosition, ebp            ; return positionexit16S:        popad        retCODE ENDSEND

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -