Files
Work/engine/SAMPLE.BAK
2024-08-07 09:16:27 -04:00

129 lines
6.9 KiB
Plaintext

;*************************************************************************************
; MODULE: UTIL.ASM DATE: MAY 15, 1998
; AUTHOR: SEAN M. KESSLER
; TARGET: 32 BIT TARGET
; FUNCTION : RESAMPLE FUNCTIONS
;*************************************************************************************
SMART
.386
.MODEL FLAT
.DATA
.CODE
LOCALS
INCLUDE ..\COMMON\COMMON.INC
INCLUDE ..\COMMON\MATH.INC
_resampleClip proc near ; short resampleClip(char *lpIn,char *lpOut,DWORD inLen,DWORD outLen,DWORD outClamp)
LOCAL sampleFactor:DWORD,runningFactor:DWORD=LocalLength
push ebp ; save stack frame
mov ebp,esp ; create new stack frame
sub esp,LocalLength ; adjust stack for local
push esi ; save source index register
push edi ; save destination
push ebx ; save ebx register
mov eax,[ebp+10h] ; move inLen to eax register
cmp eax,0000h ; compare inLen to zero
jle @@errorExit ; if it's less or equal then exit
mov ebx,[ebp+14h] ; move outLen to ebx register
cmp ebx,0000h ; compare outLen to zero
jle @@errorExit ; if it's less or equal then exit
dec eax ; decrement inLen
shl eax,10h ; multiply inLen by 65536L
divide eax,ebx ; divide ((inLen-1L)*65536L)/outLen
mov sampleFactor,eax ; store the factor
dec ebx ; ebx has (outLen-1)
mov ecx,ebx ; copy (outLen-1) to ecx
mov eax,[ebp+18h] ; move outClip to eax register
sub ebx,eax ; subtract (outLen-1L)-outClip, this is clipping region
mov edi,[ebp+0Ch] ; move lpOut to destination index register
add edi,ecx ; edi=lpOut+(outLen-1L)
mov esi,[ebp+08h] ; move lpIn to source index register
multiply ecx,sampleFactor ; multiply (outLen-1)*sampleFactor
mov runningFactor,eax ; save this into runningFactor
@@loopControl: ; loop control sync address
cmp ecx,0000h ; make sure we're within boundary
jl @@exit ; if not then we exit
cmp ecx,ebx ; compare ecx to clipping region
je @@exit ; if it's equal then we're done
mov eax,runningFactor ; move last running factor into eax
round ; round it off
mov dl,byte ptr[esi+eax] ; move source byte to dl register
mov byte ptr[edi],dl ; move source byte to destination address
mov eax,sampleFactor ; move sampleFactor into eax register
sub runningFactor,eax ; subtract from running factor
dec ecx ; decrement counter
dec edi ; advance (backwards) along lpOut array
jmp @@loopControl ; continue processing
@@errorExit: ; error exit return sync address
xor ax,ax ; clear ax register on error
jmp @@endProcedure ; jump to end procedure
@@exit: ; exit sync address
mov ax,01h ; set ax register on success
@@endProcedure: ; end procedure sync address
pop ebx ; restore ebx register
pop edi ; restore destination index register
pop esi ; restore source index register
add esp,LocalLength ; remove locals off stack
pop ebp ; restore previous stack frame
retn ; return near to caller
_resampleClip endp
if 0
_resampleClip proc near ; void resampleClip(char *lpIn,char *lpOut,int inLen,int outLen,int outClip)
rc@@sampleFactor EQU dword ptr[ebp - size dword]
rc@@runningFactor EQU dword ptr[ebp - ( size dword + size dword)]
rc@@localLength EQU size dword + size dword
push ebp ; save stack frame
mov ebp,esp ; create new stack frame
sub esp,rc@@localLength ; adjust stack for local
push esi ; save source index register
push edi ; save destination
push ebx ; save ebx register
mov eax,[ebp+10h] ; move inLen to eax register
cmp eax,0000h ; compare inLen to zero
jle @@errorExit ; if it's less or equal then exit
mov ebx,[ebp+14h] ; move outLen to ebx register
cmp ebx,0000h ; compare outLen to zero
jle @@errorExit ; if it's less or equal then exit
dec eax ; decrement inLen
shl eax,10h ; multiply inLen by 65536L
divide eax,ebx ; divide ((inLen-1L)*65536L)/outLen
mov rc@@sampleFactor,eax ; store the factor
dec ebx ; ebx has (outLen-1)
mov ecx,ebx ; copy (outLen-1) to ecx
mov eax,[ebp+18h] ; move outClip to eax register
sub ebx,eax ; subtract (outLen-1L)-outClip, this is clipping region
mov edi,[ebp+0Ch] ; move lpOut to destination index register
add edi,ecx ; edi=lpOut+(outLen-1L)
mov esi,[ebp+08h] ; move lpIn to source index register
multiply ecx,rc@@sampleFactor ; multiply (outLen-1)*sampleFactor
mov rc@@runningFactor,eax ; save this into runningFactor
@@loopControl: ; loop control sync address
cmp ecx,0000h ; make sure we're within boundary
jl @@exit ; if not then we exit
cmp ecx,ebx ; compare ecx to clipping region
je @@exit ; if it's equal then we're done
mov eax,rc@@runningFactor ; move last running factor into eax
round ; round it off
mov dl,byte ptr[esi+eax] ; move source byte to dl register
mov byte ptr[edi],dl ; move source byte to destination address
mov eax,rc@@sampleFactor ; move sampleFactor into eax register
sub rc@@runningFactor,eax ; subtract from running factor
dec ecx ; decrement counter
dec edi ; advance (backwards) along lpOut array
jmp @@loopControl ; continue processing
@@errorExit: ; error exit return sync address
xor ax,ax ; clear ax register on error
jmp @@endProcedure ; jump to end procedure
@@exit: ; exit sync address
mov ax,01h ; set ax register on success
@@endProcedure: ; end procedure sync address
pop ebx ; restore ebx register
pop edi ; restore destination index register
pop esi ; restore source index register
add esp,rc@@localLength ; remove locals off stack
pop ebp ; restore previous stack frame
retn ; return near to caller
_resampleClip endp
endif
public _resampleClip
END