Function at 0x509220
Capabilities:
Print debug messages

Disassembly:
push ebp
push edi
push esi
push ebx
sub esp, 0x3c
mov dword [esp], 0
call sub.USER32.dll_GetDC
sub esp, 4
mov edx, dword [esp + 0x58]
mov dword [esp + 0x2c], eax
mov ecx, dword [esp + 0x2c]
movzx eax, byte [edx + 5]
mov byte [esp + 0x38], al
movzx eax, byte [edx + 7]
mov byte [esp + 0x39], al
movzx eax, byte [edx + 9]
mov byte [esp + 0x3b], 0
mov dword [esp], ecx
mov byte [esp + 0x3a], al
mov eax, 0x26
mov dword [esp + 4], eax
call sub.GDI32.dll_GetDeviceCaps
sub esp, 8
test ah, 1
je 0x5093b0
mov eax, 0x68
mov ebp, 1
mov dword [esp + 4], eax
mov eax, dword [esp + 0x2c]
mov dword [esp], eax
call sub.GDI32.dll_GetDeviceCaps
sub esp, 8
mov edx, dword [esp + 0x54]
mov dword [esp + 0x28], eax
movzx eax, byte [esp + 0x39]
movzx ebx, byte [esp + 0x38]
shl eax, 8
or ebx, eax
movzx eax, byte [esp + 0x3a]
shl eax, 0x10
or ebx, eax
mov dword [esp + 4], ebx
mov eax, dword [edx]
mov dword [esp], eax
call sub.GDI32.dll_GetNearestPaletteIndex
sub esp, 8
mov edx, dword [esp + 0x54]
mov dword [esp + 0x24], eax
mov ecx, dword [esp + 0x24]
lea eax, [esp + 0x34]
mov dword [esp + 8], ebp
mov dword [esp + 0xc], eax
mov dword [esp + 4], ecx
mov eax, dword [edx]
mov dword [esp], eax
call sub.GDI32.dll_GetPaletteEntries
sub esp, 0x10
movzx ecx, byte [esp + 0x35]
movzx ebp, byte [esp + 0x36]
movzx edi, byte [esp + 0x34]
mov dword [esp + 0x20], ecx
shl ecx, 8
mov eax, ebp
mov dword [esp + 0x1c], ecx
mov edx, ecx
shl eax, 0x10
or edx, edi
or edx, eax
mov eax, dword [esp + 0x54]
mov esi, dword [eax + 4]
cmp esi, dword [esp + 0x24]
setbe cl
cmp ebx, edx
setne al
or eax, ecx
test al, 1
jne 0x509440
movzx eax, byte [esp + 0x39]
mov ecx, dword [esp + 0x58]
movzx edx, byte [esp + 0x38]
shl eax, 8
or edx, eax
movzx eax, byte [esp + 0x3a]
shl eax, 0x10
or edx, eax
or edx, 0x2000000
lea eax, [esp + 0x30]
mov dword [ecx], edx
mov dword [esp + 8], eax
mov eax, dword [esp + 0x54]
mov dword [esp + 4], edx
mov edx, dword [esp + 0x54]
add eax, 0xc
mov dword [esp], eax
call dword [edx + 0x3c]
mov ebx, dword [esp + 0x30]
mov edx, 1
test ebx, ebx
jne 0x509389
mov edx, dword [eax + 0xc]
inc edx
mov dword [eax + 0xc], edx
mov eax, dword [esp + 0x2c]
mov dword [esp], 0
mov dword [esp + 4], eax
call sub.USER32.dll_ReleaseDC
sub esp, 8
mov eax, 1
add esp, 0x3c
pop ebx
pop esi
pop edi
pop ebp
ret
movzx eax, byte [esp + 0x39]
mov ecx, dword [esp + 0x2c]
movzx edx, byte [esp + 0x38]
shl eax, 8
mov dword [esp], ecx
or edx, eax
movzx eax, byte [esp + 0x3a]
shl eax, 0x10
or edx, eax
mov dword [esp + 4], edx
call sub.GDI32.dll_GetNearestColor
sub esp, 8
movzx ecx, al
mov edx, dword [esp + 0x58]
mov dword [edx], eax
mov edx, ecx
shl edx, 8
add edx, ecx
mov ecx, dword [esp + 0x58]
mov word [ecx + 4], dx
mov edx, eax
shr edx, 8
movzx ecx, dl
shr eax, 0x10
mov edx, ecx
shl edx, 8
movzx eax, al
add edx, ecx
mov ecx, dword [esp + 0x58]
mov word [ecx + 6], dx
mov edx, eax
shl edx, 8
add edx, eax
mov eax, dword [esp + 0x2c]
mov word [ecx + 8], dx
mov dword [esp], 0
mov dword [esp + 4], eax
call sub.USER32.dll_ReleaseDC
sub esp, 8
mov eax, 1
add esp, 0x3c
pop ebx
pop esi
pop edi
pop ebp
ret
cmp esi, dword [esp + 0x28]
je 0x509490
mov ecx, dword [esp + 0x54]
lea eax, [esi + 1]
mov esi, 1
mov dword [ecx + 4], eax
mov dword [esp + 4], eax
mov eax, dword [ecx]
mov dword [esp], eax
call sub.GDI32.dll_ResizePalette
sub esp, 8
mov edx, dword [esp + 0x54]
lea eax, [esp + 0x38]
mov dword [esp + 0xc], eax
mov dword [esp + 8], esi
mov eax, dword [edx + 4]
dec eax
mov dword [esp + 4], eax
mov eax, dword [edx]
mov dword [esp], eax
call sub.GDI32.dll_SetPaletteEntries
sub esp, 0x10
jmp 0x509336
mov edx, dword [esp + 0x58]
mov eax, edi
shl eax, 8
add eax, edi
mov edi, dword [esp + 0x20]
mov word [edx + 4], ax
mov eax, dword [esp + 0x1c]
add eax, edi
mov word [edx + 6], ax
mov eax, ebp
shl eax, 8
add eax, ebp
mov word [edx + 8], ax
mov eax, dword [esp + 0x34]
cmp esi, dword [esp + 0x24]
mov dword [esp + 0x38], eax
ja 0x509336
mov dword [esp], 0x5dbb30
call sub.KERNEL32.dll_OutputDebugStringA
sub esp, 4
jmp 0x509336