Advertisement
Guest User

xmd

a guest
Jul 27th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. # from xmddecode.dll (sh_sounds_explorer_1.7)
  2.  
  3. # some parts (*) where reordered to simplify logic
  4. sub_10006F50
  5. arg_0 = dword ptr 4
  6. arg_4 = dword ptr 8
  7. arg_8 = dword ptr 0Ch
  8. arg_C = dword ptr 10h
  9. arg_10 = dword ptr 14h
  10. # esp: pointer table?
  11. * push ebp # (save external value)
  12. * push edi # (save external value)
  13. * push ebx # (save external value)
  14. * push esi # (save external value)
  15. * xor ebp, ebp # (scale = 0)
  16.  
  17. mov eax, [esp+arg_C] # load p_hist1
  18. mov edx, [esp+arg_10] # load p_hist2
  19. * movsx ecx, word ptr [eax] # hist1 = (int16)*p_hist1
  20. * movsx eax, word ptr [edx] # hist2 = (int16)*p_hist2
  21.  
  22. # (frame hist2/1 is already consumed)
  23. mov edi, [esp+8+arg_4] # load p_frame
  24. mov bp, [edi] # scale = (uint16)*p_frame
  25. * shl ebp, 0Eh # scale <<= 14
  26.  
  27. mov edx, [esp+8+arg_8] # load bytes_left
  28. test edx, edx # check if bytes_left == 0
  29. jle loc_10007007 # end if true
  30.  
  31. * add edi, 2 # p_frame += 2 //skip scale
  32. mov esi, [esp+10h+arg_0] # load p_buffer
  33. mov [esp+10h+arg_C], edx # save bytes_left
  34.  
  35.  
  36. loc_10006F85: # (loop location)
  37.  
  38. ****** nibble1 ******
  39. mov dl, [edi] # byte = (uint8)*p_frame
  40. and edx, 0Fh # byte &= 0xF //get lower nibble
  41. test dl, 8 # check sign
  42. jz short loc_10006F92 # JUMP: not signed
  43. or edx, 0FFFFFFF0h # NOJM: signed, sign extend
  44. loc_10006F92:
  45. mov ebx, ebp # (copy scale)
  46. add esi, 2 # p_buffer += 2
  47. imul ebx, edx # sample *= scale
  48. mov edx, ecx # (copy hist1)
  49. imul edx, 7298h # hist1 *= 0x7298 //coef1
  50. add ebx, edx # sample += hist1
  51.  
  52. lea edx, [eax+eax*4] # hist2b = hist2 + hist2*4
  53. lea edx, [eax+edx*8] # hist2b = hist2 + hist2b*8
  54. lea edx, [edx+edx*4] # hist2b = hist2b + hist2b*4
  55. lea eax, [eax+edx*4] # hist2 = hist2 + hist2b*4
  56. shl eax, 4 # hist2 <<= 4
  57. # AKA: (hist2 + (((hist2*5 + hist2)*8)*5)*4) << 4
  58. # AKA: (hist2 + ((5*8+1)*5*4+1)) << 4 = hist2 * 0x335*10
  59. # hist2 *= 0x3350 //coef2
  60.  
  61. sub ebx, eax # sample -= hist2
  62. sar ebx, 0Eh # sample >>= 14
  63. mov eax, ebx # (copy sample)
  64. mov [esi-2], ax # *p_buffer-2 = (int16)sample
  65.  
  66. * xor edx, edx # byte = 0 //clean upper bits
  67.  
  68. ****** nibble2 ******
  69. mov dl, [edi] # byte = *p_frame
  70. shr edx, 4 # byte >> 4 //get upper nibble
  71. test dl, 8 # (check sign)
  72. jz short loc_10006FCD # JUMP: not signed
  73. or edx, 0FFFFFFF0h # NOJM: signed, sign extend
  74. loc_10006FCD:
  75. mov ebx, ebp # (copy scale)
  76. add esi, 2 # p_buffer += 2
  77. imul ebx, edx # sample *= scale
  78. mov edx, eax # (copy hist1 = sample)
  79. imul edx, 7298h # hist1 *= 0x7298
  80. add ebx, edx # sample += hist1
  81.  
  82. lea edx, [ecx+ecx*4] # hist2b = hist2 + hist2*4
  83. lea edx, [ecx+edx*8] # hist2b = hist2 + hist2b*8
  84. lea edx, [edx+edx*4] # hist2b = hist2b + hist2b*4
  85. lea ecx, [ecx+edx*4] # hist2 = hist2 + hist2b*4
  86. # AKA: hist2 + (((hist2*5 + hist2)*8)*5)*4
  87. # AKA: hist2 * ((5*8+1)*5*4+1) = hist2 * 0x335
  88. shl ecx, 4 # hist2 <<= 4
  89. # AKA: hist2 * 0x3350
  90.  
  91. sub ebx, ecx # sample -= hist2
  92. sar ebx, 0Eh # sample >>= 14
  93. mov ecx, ebx # (copy sample)
  94. mov [esi-2], cx # *p_buffer-2 = (int16)sample
  95.  
  96. * inc edi # p_frame += 1
  97. * mov edx, [esp+10h+arg_C] # load bytes_left
  98. dec edx # bytes_left--
  99. mov [esp+10h+arg_C], edx # save bytes_left
  100. jnz short loc_10006F85 # JUMP (process next byte)
  101.  
  102. ***
  103. loc_10007007:
  104. * pop esi # (restore external value)
  105. * pop ebx # (restore external value)
  106. pop edi # (restore external value)
  107. pop ebp # (restore external value)
  108. retn
  109. endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement