// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/samples/testkey/testkey.cpp
// Function: TestKey::EventProc(int, int, int)
Void TestKey::EventProc(Int message, Int wParam, Int lParam)
{
	String		 newText	= "ASCII code: %1\nUnicode character: %2\n\nScan code: %3\nVirtual keycode: %4";
	UnsignedByte	 asciiCode	= 0;
	wchar_t		 unicode	= 0;
	Int		 scanCode	= 0;
	Int		 vkCode		= 0;

	if (message == SM_KEYDOWN)
	{
#ifdef __WIN32__
		Byte	 keys[256];

		GetKeyboardState((UnsignedByte *) &keys);
		ToAscii(wParam, Binary::GetBits(lParam, 16, 23), (UnsignedByte *) &keys, (UnsignedShort *) &asciiCode, 0);
		ToUnicode(wParam, Binary::GetBits(lParam, 16, 23), (UnsignedByte *) &keys, &unicode, 1, 0);
#endif

		scanCode = Binary::GetBits(lParam, 16, 23);
		vkCode	 = wParam;

		newText.Replace("%1", String().FillN('0', 2 - Math::Floor(Math::Log10(asciiCode))).Append(String::FromInt(asciiCode)));
		newText.Replace("%2", String().FillN('0', 4 - Math::Floor(Math::Log10(unicode))).Append(String::FromInt(unicode)));
		newText.Replace("%3", String().FillN('0', 2 - Math::Floor(Math::Log10(scanCode))).Append(String::FromInt(scanCode)));
		newText.Replace("%4", String().FillN('0', 2 - Math::Floor(Math::Log10(vkCode))).Append(String::FromInt(vkCode)));

		text->SetText(newText);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movl %ecx, %r14d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x1965(%rip), %rsi      # 0x5091
leaq 0x48(%rsp), %rdi
callq 0x32a0
cmpl $0x780e, %r15d          # imm = 0x780E
jne 0x397d
pushq $0x10
popq %rsi
pushq $0x17
popq %rdx
movl %r14d, %edi
callq 0x32e0
movl %eax, %r15d
leaq 0x197e(%rip), %rsi      # 0x50d9
leaq 0x30(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorpd %xmm0, %xmm0
callq 0x30b0
callq 0x3170
pushq $0x2
popq %r14
movl %r14d, %edx
subl %eax, %edx
leaq 0x18(%rsp), %rdi
pushq $0x30
popq %rsi
callq 0x32b0
movq %rax, %r12
movq %rsp, %rdi
xorl %esi, %esi
callq 0x30f0
movq %rsp, %rsi
movq %r12, %rdi
callq 0x30a0
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
movq %rsp, %rdi
callq 0x3180
leaq 0x18(%rsp), %rdi
callq 0x3180
leaq 0x30(%rsp), %rdi
callq 0x3180
leaq 0x18fa(%rip), %rsi      # 0x50dc
leaq 0x30(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorpd %xmm0, %xmm0
callq 0x30b0
callq 0x3170
pushq $0x4
popq %rdx
subl %eax, %edx
leaq 0x18(%rsp), %rdi
pushq $0x30
popq %rsi
callq 0x32b0
movq %rax, %r12
movq %rsp, %rdi
xorl %esi, %esi
callq 0x30f0
movq %rsp, %rsi
movq %r12, %rdi
callq 0x30a0
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
movq %rsp, %rdi
callq 0x3180
leaq 0x18(%rsp), %rdi
callq 0x3180
leaq 0x30(%rsp), %rdi
callq 0x3180
leaq 0x187a(%rip), %rsi      # 0x50df
leaq 0x30(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
cvtsi2sd %r15d, %xmm0
callq 0x30b0
callq 0x3170
movl %r14d, %edx
subl %eax, %edx
leaq 0x18(%rsp), %rdi
pushq $0x30
popq %rsi
callq 0x32b0
movq %rax, %r12
movslq %r15d, %rsi
movq %rsp, %rdi
callq 0x30f0
movq %rsp, %rsi
movq %r12, %rdi
callq 0x30a0
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
movq %rsp, %rdi
callq 0x3180
leaq 0x18(%rsp), %rdi
callq 0x3180
leaq 0x30(%rsp), %rdi
callq 0x3180
leaq 0x17ec(%rip), %rsi      # 0x50d6
leaq 0x30(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
cvtsi2sd %ebp, %xmm0
callq 0x30b0
callq 0x3170
subl %eax, %r14d
leaq 0x18(%rsp), %rdi
pushq $0x30
popq %rsi
movl %r14d, %edx
callq 0x32b0
movq %rax, %r14
movslq %ebp, %rsi
movq %rsp, %rdi
callq 0x30f0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x30a0
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
movq %rsp, %rdi
callq 0x3180
leaq 0x18(%rsp), %rdi
callq 0x3180
leaq 0x30(%rsp), %rdi
callq 0x3180
movq 0x5c8(%rbx), %rdi
movq (%rdi), %rax
leaq 0x48(%rsp), %rsi
callq *0xa0(%rax)
leaq 0x48(%rsp), %rdi
callq 0x3180
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x39cd
jmp 0x39a8
jmp 0x39b3
jmp 0x39cd
jmp 0x39a8
jmp 0x39b3
jmp 0x39cd
jmp 0x39a8
jmp 0x39b3
jmp 0x39cd
movq %rax, %rbx
jmp 0x39da
jmp 0x39b3
jmp 0x39ba
jmp 0x39ba
movq %rax, %rbx
jmp 0x39e4
jmp 0x39ba
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3180
jmp 0x39d0
jmp 0x39cd
jmp 0x39cd
jmp 0x39cd
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3180
leaq 0x30(%rsp), %rdi
callq 0x3180
leaq 0x48(%rsp), %rdi
callq 0x3180
movq %rbx, %rdi
callq 0x3100