// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x68, %rsp
movl %ecx, %r14d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x195f(%rip), %rsi      # 0x5091
leaq 0x50(%rsp), %rdi
callq 0x3290
cmpl $0x780e, %r15d          # imm = 0x780E
jne 0x39b0
movl %r14d, %edi
movl $0x10, %esi
movl $0x17, %edx
callq 0x32d0
movl %eax, %r14d
leaq 0x1974(%rip), %rsi      # 0x50d9
leaq 0x38(%rsp), %rdi
callq 0x3290
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorpd %xmm0, %xmm0
callq 0x30b0
callq 0x3170
movl $0x2, %edx
subl %eax, %edx
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
callq 0x32a0
movq %rax, %r15
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x30f0
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x30a0
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
leaq 0x8(%rsp), %rdi
callq 0x3180
leaq 0x20(%rsp), %rdi
callq 0x3180
leaq 0x38(%rsp), %rdi
callq 0x3180
leaq 0x18ea(%rip), %rsi      # 0x50dc
leaq 0x38(%rsp), %rdi
callq 0x3290
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorpd %xmm0, %xmm0
callq 0x30b0
callq 0x3170
movl $0x4, %edx
subl %eax, %edx
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
callq 0x32a0
movq %rax, %r15
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x30f0
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x30a0
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
leaq 0x8(%rsp), %rdi
callq 0x3180
leaq 0x20(%rsp), %rdi
callq 0x3180
leaq 0x38(%rsp), %rdi
callq 0x3180
leaq 0x1860(%rip), %rsi      # 0x50df
leaq 0x38(%rsp), %rdi
callq 0x3290
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
callq 0x30b0
callq 0x3170
movl $0x2, %edx
subl %eax, %edx
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
callq 0x32a0
movq %rax, %r15
movslq %r14d, %rsi
leaq 0x8(%rsp), %rdi
callq 0x30f0
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x30a0
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
leaq 0x8(%rsp), %rdi
callq 0x3180
leaq 0x20(%rsp), %rdi
callq 0x3180
leaq 0x38(%rsp), %rdi
callq 0x3180
leaq 0x17c5(%rip), %rsi      # 0x50d6
leaq 0x38(%rsp), %rdi
callq 0x3290
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x3190
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
callq 0x30b0
callq 0x3170
movl $0x2, %edx
subl %eax, %edx
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
callq 0x32a0
movq %rax, %r14
movslq %ebp, %rsi
leaq 0x8(%rsp), %rdi
callq 0x30f0
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x30a0
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0x3130
leaq 0x8(%rsp), %rdi
callq 0x3180
leaq 0x20(%rsp), %rdi
callq 0x3180
leaq 0x38(%rsp), %rdi
callq 0x3180
movq 0x5c8(%rbx), %rdi
movq (%rdi), %rax
leaq 0x50(%rsp), %rsi
callq *0xa0(%rax)
leaq 0x50(%rsp), %rdi
callq 0x3180
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a00
jmp 0x39d9
jmp 0x39e4
jmp 0x3a00
jmp 0x39d9
jmp 0x39e4
jmp 0x3a00
jmp 0x39d9
jmp 0x39e4
jmp 0x3a00
movq %rax, %rbx
jmp 0x3a0d
jmp 0x39e4
jmp 0x39eb
jmp 0x39eb
movq %rax, %rbx
jmp 0x3a17
jmp 0x39eb
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3180
jmp 0x3a03
jmp 0x3a00
jmp 0x3a00
jmp 0x3a00
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3180
leaq 0x38(%rsp), %rdi
callq 0x3180
leaq 0x50(%rsp), %rdi
callq 0x3180
movq %rbx, %rdi
callq 0x3100
nop