Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # from xmddecode.dll (sh_sounds_explorer_1.7)
- # some parts (*) where reordered to simplify logic
- sub_10006F50
- arg_0 = dword ptr 4
- arg_4 = dword ptr 8
- arg_8 = dword ptr 0Ch
- arg_C = dword ptr 10h
- arg_10 = dword ptr 14h
- # esp: pointer table?
- * push ebp # (save external value)
- * push edi # (save external value)
- * push ebx # (save external value)
- * push esi # (save external value)
- * xor ebp, ebp # (scale = 0)
- mov eax, [esp+arg_C] # load p_hist1
- mov edx, [esp+arg_10] # load p_hist2
- * movsx ecx, word ptr [eax] # hist1 = (int16)*p_hist1
- * movsx eax, word ptr [edx] # hist2 = (int16)*p_hist2
- # (frame hist2/1 is already consumed)
- mov edi, [esp+8+arg_4] # load p_frame
- mov bp, [edi] # scale = (uint16)*p_frame
- * shl ebp, 0Eh # scale <<= 14
- mov edx, [esp+8+arg_8] # load bytes_left
- test edx, edx # check if bytes_left == 0
- jle loc_10007007 # end if true
- * add edi, 2 # p_frame += 2 //skip scale
- mov esi, [esp+10h+arg_0] # load p_buffer
- mov [esp+10h+arg_C], edx # save bytes_left
- loc_10006F85: # (loop location)
- ****** nibble1 ******
- mov dl, [edi] # byte = (uint8)*p_frame
- and edx, 0Fh # byte &= 0xF //get lower nibble
- test dl, 8 # check sign
- jz short loc_10006F92 # JUMP: not signed
- or edx, 0FFFFFFF0h # NOJM: signed, sign extend
- loc_10006F92:
- mov ebx, ebp # (copy scale)
- add esi, 2 # p_buffer += 2
- imul ebx, edx # sample *= scale
- mov edx, ecx # (copy hist1)
- imul edx, 7298h # hist1 *= 0x7298 //coef1
- add ebx, edx # sample += hist1
- lea edx, [eax+eax*4] # hist2b = hist2 + hist2*4
- lea edx, [eax+edx*8] # hist2b = hist2 + hist2b*8
- lea edx, [edx+edx*4] # hist2b = hist2b + hist2b*4
- lea eax, [eax+edx*4] # hist2 = hist2 + hist2b*4
- shl eax, 4 # hist2 <<= 4
- # AKA: (hist2 + (((hist2*5 + hist2)*8)*5)*4) << 4
- # AKA: (hist2 + ((5*8+1)*5*4+1)) << 4 = hist2 * 0x335*10
- # hist2 *= 0x3350 //coef2
- sub ebx, eax # sample -= hist2
- sar ebx, 0Eh # sample >>= 14
- mov eax, ebx # (copy sample)
- mov [esi-2], ax # *p_buffer-2 = (int16)sample
- * xor edx, edx # byte = 0 //clean upper bits
- ****** nibble2 ******
- mov dl, [edi] # byte = *p_frame
- shr edx, 4 # byte >> 4 //get upper nibble
- test dl, 8 # (check sign)
- jz short loc_10006FCD # JUMP: not signed
- or edx, 0FFFFFFF0h # NOJM: signed, sign extend
- loc_10006FCD:
- mov ebx, ebp # (copy scale)
- add esi, 2 # p_buffer += 2
- imul ebx, edx # sample *= scale
- mov edx, eax # (copy hist1 = sample)
- imul edx, 7298h # hist1 *= 0x7298
- add ebx, edx # sample += hist1
- lea edx, [ecx+ecx*4] # hist2b = hist2 + hist2*4
- lea edx, [ecx+edx*8] # hist2b = hist2 + hist2b*8
- lea edx, [edx+edx*4] # hist2b = hist2b + hist2b*4
- lea ecx, [ecx+edx*4] # hist2 = hist2 + hist2b*4
- # AKA: hist2 + (((hist2*5 + hist2)*8)*5)*4
- # AKA: hist2 * ((5*8+1)*5*4+1) = hist2 * 0x335
- shl ecx, 4 # hist2 <<= 4
- # AKA: hist2 * 0x3350
- sub ebx, ecx # sample -= hist2
- sar ebx, 0Eh # sample >>= 14
- mov ecx, ebx # (copy sample)
- mov [esi-2], cx # *p_buffer-2 = (int16)sample
- * inc edi # p_frame += 1
- * mov edx, [esp+10h+arg_C] # load bytes_left
- dec edx # bytes_left--
- mov [esp+10h+arg_C], edx # save bytes_left
- jnz short loc_10006F85 # JUMP (process next byte)
- ***
- loc_10007007:
- * pop esi # (restore external value)
- * pop ebx # (restore external value)
- pop edi # (restore external value)
- pop ebp # (restore external value)
- retn
- endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement