section .text bits 32 ; ********************************************************* ; * ; * FILTER ; * ; * EAX = filter type ; * ; * cutoff = _sinf(f*cons); ; * low = low + cutoff * band; ; * high = q * input - low - q * band; ; * band = cutoff * high + band; ; * ; ********************************************************* %DEFINE KF_CUTOFF 4*0 %DEFINE KF_RESO 4*1 %DEFINE KF_LOW 4*2 %DEFINE KF_HIGH 4*3 %DEFINE KF_BAND 4*4 %DEFINE KF_SAMPLE 4*5 global _KZG_filter@0 _KZG_filter@0: ; cutoff = _sinf(cutoff*cons); pushad mov ebp,_KZG_filter_cutoff+KF_LOW push eax ;;Hack to truncate denormalized coefficients to 0 ;;TODO: direct offsets are faster, but are they smaller too? test dword [ebp], 0x7F000000 jne donttrunc1 and dword [ebp], byte 0 donttrunc1: add ebp, byte 4 test dword [ebp], 0x7F000000 jne donttrunc2 and dword [ebp], byte 0 donttrunc2: add ebp, byte 4 test dword [ebp], 0x7F000000 jne donttrunc3 and dword [ebp], byte 0 donttrunc3: add ebp, byte -KF_BAND %ifdef DEBUG fnop %endif fld dword [ebp+KF_CUTOFF] fmul dword [_KZG_filter_cutoff_const] fsin fstp dword [ebp+KF_CUTOFF] ; low = low + cutoff * band; %ifdef DEBUG fnop %endif fld dword [ebp+KF_BAND] fmul dword [ebp+KF_CUTOFF] fadd dword [ebp+KF_LOW] fstp dword [ebp+KF_LOW] ; high = q * input - low - q * band; %ifdef DEBUG fnop %endif fld dword [ebp+KF_SAMPLE] fsub dword [ebp+KF_BAND] fmul dword [ebp+KF_RESO] fsub dword [ebp+KF_LOW] fstp dword [ebp+KF_HIGH] ; band = cutoff * high + band; %ifdef DEBUG fnop %endif fld dword [ebp+KF_HIGH] fmul dword [ebp+KF_CUTOFF] fadd dword [ebp+KF_BAND] fstp dword [ebp+KF_BAND] pop eax %ifdef DEBUG fnop %endif fld dword [ebp+KF_LOW+eax*4] popad ret section .data _KZG_filter_cutoff_const dd 3.561896433e-5 global _KZG_filter_reso %ifdef DEBUG section .data _KZG_filter_cutoff dd 4000.0 _KZG_filter_reso dd 0.5 _KZG_filter_low dd 0.0 _KZG_filter_high dd 0.0 _KZG_filter_band dd 0.0 _KZG_filter_sample dd 0.0 %else section .bss _KZG_filter_cutoff resd 1 _KZG_filter_reso resd 1 _KZG_filter_low resd 1 _KZG_filter_high resd 1 _KZG_filter_band resd 1 _KZG_filter_sample resd 1 %endif