mv_mix16.nasm

来自「An interactive water fountain. A realis」· NASM 代码 · 共 545 行 · 第 1/2 页

NASM
545
字号
        mov     ebx, dword [ebx + 12345678h]    ; harsh clip right sample        mov     edx, ebp                        ; begin calculating second samplebpatch7:        mov     byte [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 [esi+2*edx]           ; get second sample        add     ebx, 80h        dec     ecx                             ; decrement count        jnz     mix8Sloop                       ; loop        mov     dword [_MV_MixDestination], edi ; Store the current write position        mov     dword [_MV_MixPosition], ebp    ; return positionEXIT8S:        popad        ret;================;; MV_Mix16BitMono16;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mix	ALIGN 4MV_Mix16BitMono16:        pushad	mov     eax, dword [esp + 0*4 + 9*4]	mov     edx, dword [esp + 1*4 + 9*4]	mov     ebx, dword [esp + 2*4 + 9*4]	mov     ecx, dword [esp + 3*4 + 9*4]	        mov     ebp, eax        mov     esi, ebx                        ; Source pointer        ; Sample size        mov     ebx, dword [_MV_SampleSize]        mov     byte [cpatch4+2],bl        mov     byte [cpatch5+3],bl        ; Volume table ptr        mov     ebx, dword [_MV_LeftVolume]        mov     dword [cpatch2+4],ebx        inc     ebx        mov     dword [cpatch1+4],ebx        ; Rate scale ptr        mov     dword [cpatch3+2],edx        mov     edi, dword [_MV_MixDestination] ; Get the position to write to        ; Number of samples to mix        cmp     ecx, 0        je near 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     ebx,ebp                         ; begin calculating first sample        add     ebp,edx                         ; advance frac pointer        shr     ebx,16                          ; finish calculation for first sample        movzx   eax, word [esi+2*ebx]           ; get low byte of sample        xor     eax, 8000h        movzx   ebx, ah        sub     ah, ah        movsx   edx, word [edi]                 ; get current sample from destination        ALIGN 4mix16Mloop:cpatch1:        movsx   eax, byte [2*eax+12345678h]     ; volume translate low byte of samplecpatch2:        movsx   ebx, word [2*ebx+12345678h]     ; volume translate high byte of sample        lea     eax, [ eax + ebx + 80h ]        ; mix high byte of sample        add     eax, edx                        ; mix low byte of samplecpatch5:        movsx   edx, word [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:        mov     ebx, ebp                        ; begin calculating second sample        mov     word [edi], ax                  ; write new sample to destination        shr     ebx, 16                         ; finish calculation for second samplecpatch3:        add     ebp, 12345678h                  ; advance frac pointer        movzx   eax, word [esi+2*ebx]           ; get second samplecpatch4:        add     edi, 2                          ; move destination to second sample        xor     eax, 8000h        movzx   ebx, ah        sub     ah, ah        dec     ecx                             ; decrement count        jnz     mix16Mloop                      ; loop        mov     dword [_MV_MixDestination], edi ; Store the current write position        mov     dword [_MV_MixPosition], ebp    ; return positionEXIT16M:        popad        ret;================;; MV_Mix16BitStereo16;;================; eax - position; edx - rate; ebx - start; ecx - number of samples to mix	ALIGN 4MV_Mix16BitStereo16:        pushad	mov     eax, dword [esp + 0*4 + 9*4]	mov     edx, dword [esp + 1*4 + 9*4]	mov     ebx, dword [esp + 2*4 + 9*4]	mov     ecx, dword [esp + 3*4 + 9*4]	        mov     ebp, eax        mov     esi, ebx                        ; Source pointer        ; Sample size        mov     ebx, dword [_MV_SampleSize]        mov     byte [dpatch9+2],bl        ; Right channel offset        mov     ebx, dword [_MV_RightChannelOffset]        mov     dword [dpatch7+3],ebx        mov     dword [dpatch8+3],ebx        ; Volume table ptr        mov     ebx, dword [_MV_LeftVolume]        mov     dword [dpatch1+4],ebx        inc     ebx        mov     dword [dpatch2+4],ebx        mov     ebx, dword [_MV_RightVolume]        mov     dword [dpatch3+4],ebx        inc     ebx        mov     dword [dpatch4+4],ebx        ; Rate scale ptr        mov     dword [dpatch5+2],edx        ; Source ptr        mov     dword [dpatch6+4],esi        mov     edi, dword [_MV_MixDestination] ; Get the position to write to        ; Number of samples to mix        cmp     ecx, 0        je      near exit16S;     eax - scratch;     ebx - scratch;     edx - scratch;     esi - scratch;     ecx - count;     edi - destination;     ebp - frac pointer; dpatch1 - left volume table; dpatch2 - right volume table; dpatch3 - sample rate        mov     ebx,ebp                         ; begin calculating first sample        shr     ebx,16                          ; finish calculation for first sample        movzx   edx, word [esi+2*ebx]           ; get first sample        xor     edx, 8000h                      ; Change from signed to unsigned        movzx   esi, dh                         ; put high byte in esi        sub     dh, dh                          ; lo byte in edx        ALIGN 4mix16Sloop:        ; Left channeldpatch1:        movsx   eax, word [2*esi+12345678h]     ; volume translate high byte of sampledpatch2:        movsx   ebx, byte [2*edx+12345678h]     ; volume translate low byte of sample        lea     eax, [ eax + ebx + 80h ]        ; mix high byte of sample        ; Right channeldpatch3:        movsx   esi, word [2*esi+12345678h]     ; volume translate high byte of sampledpatch4:        movsx   ebx, byte [2*edx+12345678h]     ; volume translate low byte of sample        lea     ebx, [ esi + ebx + 80h ]        ; mix high byte of sampledpatch7:        movsx   edx, word [edi+12345678h]       ; get current sample from destinationdpatch5:        add     ebp,12345678h                   ; advance frac pointer        add     eax, edx                        ; mix left sample        cmp     eax, -32768                     ; Harsh clip sample        jge     short s16skip1        mov     eax, -32768        jmp     short s16skip2s16skip1:        cmp     eax, 32767        jle     short s16skip2        mov     eax, 32767s16skip2:        movsx   edx, word [edi+2]               ; get current sample from destination        mov     word [edi], ax                  ; write left sample to destination        add     ebx, edx                        ; mix right sample        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 sampledpatch8:        mov     word [edi+12345678h], bx        ; write right sample to destination        shr     edx, 16                         ; finish calculation for second sampledpatch9:        add     edi, 4                          ; move destination to second sampledpatch6:        movzx   edx, word [2*edx+12345678h]     ; get second sample        xor     edx, 8000h                      ; Change from signed to unsigned        movzx   esi, dh                         ; put high byte in esi        sub     dh, dh                          ; lo byte in edx        dec     ecx                             ; decrement count        jnz     mix16Sloop                      ; loop        mov     dword [_MV_MixDestination], edi ; Store the current write position        mov     dword [_MV_MixPosition], ebp    ; return positionexit16S:        popad        ret

⌨️ 快捷键说明

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