// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/dialogs/colordlg.cpp
// Function: smooth::GUI::Dialogs::ColorSelection::ColorDlgMessageProc(int, int, int)
void S::GUI::Dialogs::ColorSelection::ColorDlgMessageProc(Int message, Int wparam, Int lparam)
{
	Surface	*surface    = dlgwnd->GetDrawSurface();
	Rect	 huerect;
	Rect	 vsrect;
	Int	 hssize	    = Math::Round(205.0 * surface->GetSurfaceDPI() / 96.0);
	Int	 huexoffset = hssize + Math::Round(14.0 * surface->GetSurfaceDPI() / 96.0);

	huerect.left	= huexoffset;
	huerect.top	= yoffset;
	huerect.right	= huerect.left + Math::Round(16.0 * surface->GetSurfaceDPI() / 96.0) + 1;
	huerect.bottom	= huerect.top + hssize + 1;

	vsrect.left	= xoffset + 1;
	vsrect.top	= yoffset + 1;
	vsrect.right	= vsrect.left + hssize;
	vsrect.bottom	= vsrect.top + hssize;

	switch (message)
	{
		case SM_LBUTTONDOWN:
			if (dlgwnd->IsMouseOn(huerect))
			{
				huecapt = True;

				ColorDlgMessageProc(SM_MOUSEMOVE, 0, 0);
			}
			else if (dlgwnd->IsMouseOn(vsrect))
			{
				vscapt = True;

				ColorDlgMessageProc(SM_MOUSEMOVE, 0, 0);
			}

			break;
		case SM_LBUTTONUP:
			if (huecapt)
			{
				huecapt = False;

				dlgwnd->SetUpdateRect(vsrect);
				ColorDlgPaintProc();
			}
			else if (vscapt)
			{
				vscapt = False;
			}

			break;
		case SM_MOUSEMOVE:
			if (huecapt)
			{
				Int	 newhue = 255 - Math::Round(Math::Max(Math::Min(dlgwnd->GetMousePosition().y - (yoffset + 1), hssize - 1), 0) * (256.0 / hssize));

				if (newhue != acthue)
				{
					lasthue	= acthue;
					acthue	= newhue;

					dlgwnd->SetUpdateRect(Rect(Point(xoffset + 1, yoffset + 1), Size(hssize, hssize)));
					ColorDlgPaintProc();

					actred	 = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetRed();
					actgreen = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetGreen();
					actblue	 = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetBlue();

					ColorDlgUpdateHexValue();

					hueedit->SetText(String::FromInt(acthue));
					rededit->SetText(String::FromInt(actred));
					greenedit->SetText(String::FromInt(actgreen));
					blueedit->SetText(String::FromInt(actblue));
					hexedit->SetText(hexval);
				}
			}
			else if (vscapt)
			{
				Point	 mousePos = dlgwnd->GetMousePosition();

				Int	 newval = 	Math::Round(Math::Max(Math::Min(mousePos.x - (xoffset + 1), hssize - 1), 0) * (256.0 / hssize));
				Int	 newsat = 255 - Math::Round(Math::Max(Math::Min(mousePos.y - (yoffset + 1), hssize - 1), 0) * (256.0 / hssize));

				if ((newval != actval) || (newsat != actsat))
				{
					lastval	= actval;
					lastsat	= actsat;
					actval	= newval;
					actsat	= newsat;

					ncarea->SetColor(Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB));

					surface->StartPaint(Rect(Point(xoffset - 4, yoffset - 4), Size(hssize + 5, hssize + 5)));

					ColorDlgUpdatePickers();

					surface->EndPaint();

					actred	 = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetRed();
					actgreen = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetGreen();
					actblue	 = Color(acthue, actsat, actval, Color::HSV).ConvertTo(Color::RGB).GetBlue();

					ColorDlgUpdateHexValue();

					valedit->SetText(String::FromInt(actval));
					satedit->SetText(String::FromInt(actsat));
					rededit->SetText(String::FromInt(actred));
					greenedit->SetText(String::FromInt(actgreen));
					blueedit->SetText(String::FromInt(actblue));
					hexedit->SetText(hexval);
				}
			}

			break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x40648(%rdi), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, %r14
movq %rax, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
mulsd 0x7b140(%rip), %xmm0    # 0xe3780
divsd 0x7aec8(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
movsd 0x7ad1b(%rip), %xmm3    # 0xe3378
movapd %xmm2, %xmm1
andpd %xmm3, %xmm1
movsd 0x7ad13(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm2
orpd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %r12
movq %r14, %rdi
callq 0x59c60
movl %eax, %r15d
movl 0x5fc(%rbx), %r13d
movl %r13d, 0x3c(%rsp)
movq %r14, %rdi
callq 0x59c60
movsd 0x7acd3(%rip), %xmm3    # 0xe3378
xorpd %xmm0, %xmm0
pinsrw $0x1, %eax, %xmm0
pinsrw $0x3, %r15d, %xmm0
psrad $0x10, %xmm0
cvtdq2pd %xmm0, %xmm0
mulpd 0x7b11b(%rip), %xmm0    # 0xe37e0
xorpd %xmm1, %xmm1
divpd 0x7b11f(%rip), %xmm0    # 0xe37f0
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movmskpd %xmm2, %eax
movapd %xmm3, %xmm1
testb $0x2, %al
jne 0x686ee
movsd 0x7ac92(%rip), %xmm1    # 0xe3380
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %rcx
addl %r12d, %ecx
movl %ecx, 0x38(%rsp)
testb $0x1, %al
jne 0x68712
movsd 0x7ac6e(%rip), %xmm3    # 0xe3380
addsd %xmm3, %xmm0
cvttsd2si %xmm0, %rax
addl %ecx, %eax
incl %eax
movl %eax, 0x40(%rsp)
leal 0x1(%r13,%r12), %eax
movl %eax, 0x44(%rsp)
movl 0x5f8(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x28(%rsp)
movl 0x5fc(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x2c(%rsp)
leal 0x1(%rax,%r12), %eax
movl %eax, 0x30(%rsp)
leal (%rcx,%r12), %eax
incl %eax
movl %eax, 0x34(%rsp)
cmpl $0x7800, %ebp           # imm = 0x7800
je 0x687d7
cmpl $0x7802, %ebp           # imm = 0x7802
je 0x6879a
cmpl $0x7801, %ebp           # imm = 0x7801
jne 0x68de0
movq 0x40648(%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0x58ae0
testb %al, %al
je 0x68db7
movb $0x1, 0x600(%rbx)
jmp 0x68dd3
cmpb $0x1, 0x600(%rbx)
jne 0x68a35
movb $0x0, 0x600(%rbx)
movq 0x40648(%rbx), %rax
movups 0x28(%rsp), %xmm0
movups %xmm0, 0x5ec(%rax)
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5a568
cmpb $0x1, 0x600(%rbx)
jne 0x68a4e
movq 0x40648(%rbx), %rdi
callq 0x57cc0
shrq $0x20, %rax
movl 0x5fc(%rbx), %ecx
movl %ecx, %edx
notl %edx
addl %eax, %edx
leal -0x1(%r12), %eax
cmpl %eax, %edx
cmovgel %eax, %edx
xorl %eax, %eax
testl %edx, %edx
cmovgl %edx, %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %r12d, %xmm1
movsd 0x7af6e(%rip), %xmm2    # 0xe3790
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm2, %xmm0
seta %al
leaq 0x7af72(%rip), %rdx     # 0xe37b0
addsd (%rdx,%rax,8), %xmm2
cvttsd2si %xmm2, %rsi
movl 0x614(%rbx), %eax
movl $0xff, %edx
subl %esi, %edx
cmpl %eax, %edx
je 0x68de0
movl %eax, 0x608(%rbx)
movl %edx, 0x614(%rbx)
movq 0x40648(%rbx), %rax
movl 0x5f8(%rbx), %edx
leal (%rdx,%r12), %esi
incl %esi
incl %edx
movl %ecx, %edi
incl %edi
addl %r12d, %ecx
incl %ecx
movl %edx, 0x5ec(%rax)
movl %edi, 0x5f0(%rax)
movl %esi, 0x5f4(%rax)
movl %ecx, 0x5f8(%rax)
movq %rbx, %rdi
callq 0x5a568
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
leaq 0x18(%rsp), %r14
movq %rax, 0x8(%r14)
pushq $0x2
popq %rbp
movl %ebp, (%r14)
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x58f90
movzbl 0x8(%r15), %eax
movl %eax, 0x620(%rbx)
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
movq %rax, 0x8(%r14)
movl %ebp, (%r14)
movq %rsp, %r14
leaq 0x18(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x58f90
movzbl 0x9(%r14), %eax
movl %eax, 0x624(%rbx)
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
movq %rax, 0x8(%r15)
movl %ebp, (%r15)
movq %rsp, %r14
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x58f90
movzbl 0xa(%r14), %eax
movl %eax, 0x628(%rbx)
movq %rbx, %rdi
callq 0x59de0
movq 0x406e8(%rbx), %r14
movslq 0x614(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
jmp 0x68d93
cmpb $0x1, 0x601(%rbx)
jne 0x68de0
movb $0x0, 0x601(%rbx)
jmp 0x68de0
cmpb $0x1, 0x601(%rbx)
jne 0x68de0
movq 0x40648(%rbx), %rdi
callq 0x57cc0
movl 0x5f8(%rbx), %r8d
notl %r8d
addl %eax, %r8d
movq %rax, %rdx
shrq $0x20, %rdx
movl 0x5fc(%rbx), %ecx
leal -0x1(%r12), %esi
cmpl %esi, %r8d
cmovgel %esi, %r8d
xorl %edi, %edi
testl %r8d, %r8d
cmovlel %edi, %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sd %r12d, %xmm1
movsd 0x7ace8(%rip), %xmm2    # 0xe3790
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm3
cmpltsd %xmm1, %xmm3
movsd 0x7a8b3(%rip), %xmm4    # 0xe3378
movapd %xmm3, %xmm5
andpd %xmm4, %xmm5
movsd 0x7a8ab(%rip), %xmm6    # 0xe3380
andnpd %xmm6, %xmm3
orpd %xmm5, %xmm3
addsd %xmm0, %xmm3
cvttsd2si %xmm3, %rax
notl %ecx
addl %edx, %ecx
cmpl %esi, %ecx
cmovgel %esi, %ecx
testl %ecx, %ecx
cmovlel %edi, %ecx
cvtsi2sd %ecx, %xmm0
mulsd %xmm2, %xmm0
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm4
andnpd %xmm6, %xmm2
orpd %xmm4, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %rdx
movl $0xff, %ecx
subl %edx, %ecx
movl 0x61c(%rbx), %edx
movl 0x618(%rbx), %esi
cmpl %eax, %edx
jne 0x68b39
cmpl %esi, %ecx
je 0x68de0
movl %edx, 0x610(%rbx)
movl %esi, 0x60c(%rbx)
movl %eax, 0x61c(%rbx)
movl %ecx, 0x618(%rbx)
movq 0x40670(%rbx), %rbp
shll $0x10, %eax
shll $0x8, %ecx
orl %eax, %ecx
orl 0x614(%rbx), %ecx
movslq %ecx, %rax
leaq 0x18(%rsp), %r15
movq %rax, 0x8(%r15)
pushq $0x2
popq %rax
movl %eax, (%r15)
movq %rsp, %r13
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x58f90
movq %rbp, %rdi
movq %r13, %rsi
callq 0x59070
movl 0x5f8(%rbx), %eax
movl 0x5fc(%rbx), %ecx
leal -0x4(%rax), %edx
leal -0x4(%rcx), %esi
movl %edx, (%r13)
movl %esi, 0x4(%r13)
leal 0x1(%rax,%r12), %eax
movl %eax, 0x8(%r13)
leal 0x1(%rcx,%r12), %eax
movl %eax, 0xc(%r13)
movq %rsp, %rsi
movq %r14, %rdi
callq 0x56160
movq %rbx, %rdi
callq 0x59640
movq %r14, %rdi
callq 0x59a80
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
movq %rax, 0x8(%r15)
pushq $0x2
popq %rbp
movl %ebp, (%r15)
movq %rsp, %r14
leaq 0x18(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x58f90
movzbl 0x8(%r14), %eax
movl %eax, 0x620(%rbx)
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
movq %rax, 0x8(%r15)
movl %ebp, (%r15)
movq %rsp, %r14
leaq 0x18(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x58f90
movzbl 0x9(%r14), %eax
movl %eax, 0x624(%rbx)
movl 0x618(%rbx), %eax
movl 0x61c(%rbx), %ecx
shll $0x10, %ecx
shll $0x8, %eax
orl 0x614(%rbx), %eax
orl %ecx, %eax
cltq
movq %rax, 0x8(%r15)
movl %ebp, (%r15)
movq %rsp, %r14
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x58f90
movzbl 0xa(%r14), %eax
movl %eax, 0x628(%rbx)
movq %rbx, %rdi
callq 0x59de0
movq 0x406f8(%rbx), %r14
movslq 0x61c(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x406f0(%rbx), %r14
movslq 0x618(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x57e80
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x5a588
movq 0x40718(%rbx), %rdi
addq $0x40630, %rbx          # imm = 0x40630
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xa0(%rax)
jmp 0x68de0
movq 0x40648(%rbx), %rdi
leaq 0x28(%rsp), %rsi
callq 0x58ae0
testb %al, %al
je 0x68de0
movb $0x1, 0x601(%rbx)
movq %rbx, %rdi
movl $0x7800, %esi           # imm = 0x7800
callq 0x5a4d8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
jmp 0x68dff
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260