; ********************************************************* ; * ; * COMPRESSION/EXPANSION routine ; * ; * ECX = buffer size ; * EDI = source/target buffer ; * ; ********************************************************* section .text bits 32 %define KC_THRESHOLD 0*4 %define KC_RATIO 1*4 %define KC_GAIN 2*4 global _KZG_comp@0 _KZG_comp@0: ; ret %ifdef DEBUG mov ebp,_KZG_comp_paramstart %endif _KZG_comp_onesample: mov ebx,dword [edi] push ebx fld dword [esp] fabs fsub dword [ebp+KC_THRESHOLD] fldz fcomip st1 ja _KZG_comp_lowsignal fdiv dword [ebp+KC_RATIO] _KZG_comp_lowsignal: fadd dword [ebp+KC_THRESHOLD] fmul dword [ebp+KC_GAIN] fstp dword [esp] pop eax and ebx,0x80000000 or eax,ebx stosd loop _KZG_comp_onesample ret %ifdef DEBUG section .data _KZG_comp_paramstart: global _KZG_comp_threshold _KZG_comp_threshold dd 0.4 global _KZG_comp_ratio _KZG_comp_ratio dd 32.0 global _KZG_comp_gain _KZG_comp_gain dd 2.0 %endif