// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0x2673(%rip), %rsi      # 0x6091
callq 0x32a0
movb $0x0, -0x31(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x780e, -0xc(%rbp)     # imm = 0x780E
jne 0x3f5b
movl -0x14(%rbp), %edi
movl $0x10, %esi
movl $0x17, %edx
callq 0x32e0
movl %eax, -0x17c(%rbp)
jmp 0x3a63
movl -0x17c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
leaq 0x2660(%rip), %rsi      # 0x60d9
leaq -0x68(%rbp), %rdi
callq 0x32a0
jmp 0x3a84
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x31a0
jmp 0x3a91
movzbl -0x31(%rbp), %eax
cvtsi2sd %eax, %xmm0
callq 0x30b0
movsd %xmm0, -0x188(%rbp)
jmp 0x3aa8
movsd -0x188(%rbp), %xmm0
callq 0x3170
movq %rax, -0x190(%rbp)
jmp 0x3abe
movq -0x190(%rbp), %rax
movl $0x2, %edx
subl %eax, %edx
leaq -0x80(%rbp), %rdi
movl $0x30, %esi
callq 0x32b0
movq %rax, -0x198(%rbp)
jmp 0x3ae3
movzbl -0x31(%rbp), %eax
movl %eax, %esi
leaq -0x98(%rbp), %rdi
callq 0x30f0
jmp 0x3af7
movq -0x198(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x30a0
movq %rax, -0x1a0(%rbp)
jmp 0x3b13
movq -0x1a0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3130
jmp 0x3b29
leaq -0x98(%rbp), %rdi
callq 0x3190
leaq -0x80(%rbp), %rdi
callq 0x3190
leaq -0x68(%rbp), %rdi
callq 0x3190
leaq 0x258e(%rip), %rsi      # 0x60dc
leaq -0xb0(%rbp), %rdi
callq 0x32a0
jmp 0x3b5c
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
callq 0x31a0
jmp 0x3b6c
cvtsi2sdl -0x38(%rbp), %xmm0
callq 0x30b0
movsd %xmm0, -0x1a8(%rbp)
jmp 0x3b80
movsd -0x1a8(%rbp), %xmm0
callq 0x3170
movq %rax, -0x1b0(%rbp)
jmp 0x3b96
movq -0x1b0(%rbp), %rax
movl $0x4, %edx
subl %eax, %edx
leaq -0xc8(%rbp), %rdi
movl $0x30, %esi
callq 0x32b0
movq %rax, -0x1b8(%rbp)
jmp 0x3bbe
movslq -0x38(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x30f0
jmp 0x3bd0
movq -0x1b8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x30a0
movq %rax, -0x1c0(%rbp)
jmp 0x3bec
movq -0x1c0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3130
jmp 0x3c05
leaq -0xe0(%rbp), %rdi
callq 0x3190
leaq -0xc8(%rbp), %rdi
callq 0x3190
leaq -0xb0(%rbp), %rdi
callq 0x3190
leaq 0x24af(%rip), %rsi      # 0x60df
leaq -0xf8(%rbp), %rdi
callq 0x32a0
jmp 0x3c3e
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
callq 0x31a0
jmp 0x3c4e
cvtsi2sdl -0x3c(%rbp), %xmm0
callq 0x30b0
movsd %xmm0, -0x1c8(%rbp)
jmp 0x3c62
movsd -0x1c8(%rbp), %xmm0
callq 0x3170
movq %rax, -0x1d0(%rbp)
jmp 0x3c78
movq -0x1d0(%rbp), %rax
movl $0x2, %edx
subl %eax, %edx
leaq -0x110(%rbp), %rdi
movl $0x30, %esi
callq 0x32b0
movq %rax, -0x1d8(%rbp)
jmp 0x3ca0
movslq -0x3c(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x30f0
jmp 0x3cb2
movq -0x1d8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x30a0
movq %rax, -0x1e0(%rbp)
jmp 0x3cce
movq -0x1e0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3130
jmp 0x3ce7
leaq -0x128(%rbp), %rdi
callq 0x3190
leaq -0x110(%rbp), %rdi
callq 0x3190
leaq -0xf8(%rbp), %rdi
callq 0x3190
leaq 0x23c4(%rip), %rsi      # 0x60d6
leaq -0x140(%rbp), %rdi
callq 0x32a0
jmp 0x3d20
leaq -0x158(%rbp), %rdi
xorl %esi, %esi
callq 0x31a0
jmp 0x3d30
cvtsi2sdl -0x40(%rbp), %xmm0
callq 0x30b0
movsd %xmm0, -0x1e8(%rbp)
jmp 0x3d44
movsd -0x1e8(%rbp), %xmm0
callq 0x3170
movq %rax, -0x1f0(%rbp)
jmp 0x3d5a
movq -0x1f0(%rbp), %rax
movl $0x2, %edx
subl %eax, %edx
leaq -0x158(%rbp), %rdi
movl $0x30, %esi
callq 0x32b0
movq %rax, -0x1f8(%rbp)
jmp 0x3d82
movslq -0x40(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x30f0
jmp 0x3d94
movq -0x1f8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x30a0
movq %rax, -0x200(%rbp)
jmp 0x3db0
movq -0x200(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3130
jmp 0x3dc9
leaq -0x170(%rbp), %rdi
callq 0x3190
leaq -0x158(%rbp), %rdi
callq 0x3190
leaq -0x140(%rbp), %rdi
callq 0x3190
movq -0x178(%rbp), %rax
movq 0x5c8(%rax), %rdi
movq (%rdi), %rax
movq 0xa0(%rax), %rax
leaq -0x30(%rbp), %rsi
callq *%rax
jmp 0x3e0d
jmp 0x3f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3e60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3e57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3190
leaq -0x80(%rbp), %rdi
callq 0x3190
leaq -0x68(%rbp), %rdi
callq 0x3190
jmp 0x3f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3eae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3ea2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3190
leaq -0xc8(%rbp), %rdi
callq 0x3190
leaq -0xb0(%rbp), %rdi
callq 0x3190
jmp 0x3f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3eff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3ef3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3190
leaq -0x110(%rbp), %rdi
callq 0x3190
leaq -0xf8(%rbp), %rdi
callq 0x3190
jmp 0x3f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3f4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3f41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x3190
leaq -0x158(%rbp), %rdi
callq 0x3190
leaq -0x140(%rbp), %rdi
callq 0x3190
jmp 0x3f6d
leaq -0x30(%rbp), %rdi
callq 0x3190
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3190
movq -0x48(%rbp), %rdi
callq 0x3100
nop