--- np2/win9x/x64/parts.x64 2006/12/30 16:43:14 1.1 +++ np2/win9x/x64/parts.x64 2006/12/30 16:43:14 1.1.2.1 @@ -0,0 +1,105 @@ + +section .text + + global rand_setseed + global rand_get + global AdjustAfterMultiply + global AdjustBeforeDivision + global sjis2jis + global jis2sjis + global satuation_s16 + global satuation_s16x + + align 16 +rand_get: mov eax, dword [_randseed] + imul eax, 343fdh + add eax, 269ec3h + mov dword [_randseed], eax + sar eax, 16 + ret + +rand_setseed: mov dword [_randseed], ecx + ret + + align 16 +AdjustAfterMultiply: + movzx r8d, cl + mov eax, 66666667h + imul r8d + sar edx, 2 + mov ecx, edx + shr ecx, 31 + add edx, ecx + lea ecx, dword [rdx+rdx*4] + shl edx, 4 + add ecx, ecx + sub r8d, ecx + lea eax, dword [r8+rdx] + ret + + align 16 +AdjustBeforeDivision: + movzx edx, cl + mov eax, edx + and edx, byte 15 + shr eax, 4 + lea ecx, dword [rax+rax*4] + lea eax, dword [rdx+rcx*2] + ret + + align 16 +sjis2jis: mov eax, ecx + shl ah, 1 + sub al, 1fh + js short .1a + cmp al, 61h + adc al, 0deh +.1a: add ax, 1fa1h + and eax, 7f7fh + ret + + align 16 +jis2sjis: mov eax, ecx + and eax, 7f7fh + add ah, 21h + shr ah, 1 + jnc short .1a + add al, 5eh +.1a: cmp al, 60h + sbb al, 0e0h + xor ah, 0a0h + ret + + align 16 +satuation_s16: shr r8d, 3 + je short .ed + xorpd xmm0, xmm0 +.lp: movdqa xmm1, [rdx] + lea rcx, [rcx+8] + packssdw xmm1, xmm0 + lea rdx, [rdx+16] + movq [rcx-8], xmm1 + dec r8d + jne short .lp +.ed: ret + + align 16 +satuation_s16x: shr r8d, 3 + je short .ed + xorpd xmm0, xmm0 +.lp: movdqa xmm1, [rdx] + lea rcx, [rcx+8] + packssdw xmm1, xmm0 + lea rdx, [rdx+16] + pshuflw xmm2, xmm1, 2*64+3*16+0*4+1*1 + dec r8d + movq [rcx-8], xmm2 + jne short .lp +.ed: ret + +section .data + +_randseed dd 1 + + ends +