// File: /workspace/github_c_makefile_star2_O3/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 0x58930
cwtl
cvtsi2sd %eax, %xmm0
mulsd 0x8bb60(%rip), %xmm0    # 0xf37c0
divsd 0x8ba50(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
movsd 0x8b713(%rip), %xmm3    # 0xf3390
movapd %xmm2, %xmm1
andpd %xmm3, %xmm1
movsd 0x8b70b(%rip), %xmm3    # 0xf3398
andnpd %xmm3, %xmm2
orpd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %r12
movq %r14, %rdi
callq 0x58930
movl %eax, %r15d
movl 0x5fc(%rbx), %r13d
movl %r13d, 0x3c(%rsp)
movq %r14, %rdi
callq 0x58930
movsd 0x8b6cb(%rip), %xmm3    # 0xf3390
xorpd %xmm0, %xmm0
pinsrw $0x1, %eax, %xmm0
pinsrw $0x3, %r15d, %xmm0
psrad $0x10, %xmm0
cvtdq2pd %xmm0, %xmm0
mulpd 0x8bb2b(%rip), %xmm0    # 0xf3810
xorpd %xmm1, %xmm1
divpd 0x8b82f(%rip), %xmm0    # 0xf3520
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movmskpd %xmm2, %eax
movapd %xmm3, %xmm1
testb $0x2, %al
jne 0x67d0e
movsd 0x8b68a(%rip), %xmm1    # 0xf3398
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 0x67d32
movsd 0x8b666(%rip), %xmm3    # 0xf3398
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 0x67df7
cmpl $0x7802, %ebp           # imm = 0x7802
je 0x67dba
cmpl $0x7801, %ebp           # imm = 0x7801
jne 0x6841a
movq 0x40648(%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0x578a0
testb %al, %al
je 0x683f1
movb $0x1, 0x600(%rbx)
jmp 0x6840d
cmpb $0x1, 0x600(%rbx)
jne 0x6805d
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 0x591e0
cmpb $0x1, 0x600(%rbx)
jne 0x68076
movq 0x40648(%rbx), %rdi
callq 0x56b50
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
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
movsd 0x8b988(%rip), %xmm2    # 0xf37d0
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm2, %xmm0
seta %al
leaq 0x8b98c(%rip), %rdx     # 0xf37f0
addsd (%rdx,%rax,8), %xmm2
cvttsd2si %xmm2, %rsi
movl 0x614(%rbx), %eax
movl $0xff, %edx
subl %esi, %edx
cmpl %eax, %edx
je 0x6841a
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 0x591e0
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)
movl $0x2, %ebp
movl %ebp, (%r14)
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x57d10
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 0x57d10
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 0x57d10
movzbl 0xa(%r14), %eax
movl %eax, 0x628(%rbx)
movq %rbx, %rdi
callq 0x58aa0
movq 0x406e8(%rbx), %r14
movslq 0x614(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
jmp 0x683cd
cmpb $0x1, 0x601(%rbx)
jne 0x6841a
movb $0x0, 0x601(%rbx)
jmp 0x6841a
cmpb $0x1, 0x601(%rbx)
jne 0x6841a
movq 0x40648(%rbx), %rdi
callq 0x56b50
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
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
movsd 0x8b6fa(%rip), %xmm2    # 0xf37d0
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm3
cmpltsd %xmm1, %xmm3
movsd 0x8b29d(%rip), %xmm4    # 0xf3390
movapd %xmm3, %xmm5
andpd %xmm4, %xmm5
movsd 0x8b295(%rip), %xmm6    # 0xf3398
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
xorps %xmm0, %xmm0
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 0x6816a
cmpl %esi, %ecx
je 0x6841a
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)
movl $0x2, %eax
movl %eax, (%r15)
movq %rsp, %r13
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x57d10
movq %rbp, %rdi
movq %r13, %rsi
callq 0x57de0
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 0x55160
movq %rbx, %rdi
callq 0x58380
movq %r14, %rdi
callq 0x58780
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 $0x2, %ebp
movl %ebp, (%r15)
movq %rsp, %r14
leaq 0x18(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x57d10
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)
movl $0x2, %ebp
movq %rsp, %r14
leaq 0x18(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x57d10
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 0x57d10
movzbl 0xa(%r14), %eax
movl %eax, 0x628(%rbx)
movq %rbx, %rdi
callq 0x58aa0
movq 0x406f8(%rbx), %r14
movslq 0x61c(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x406f0(%rbx), %r14
movslq 0x618(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
movq %rsp, %rdi
callq 0x59200
movq 0x40718(%rbx), %rdi
addq $0x40630, %rbx          # imm = 0x40630
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xa0(%rax)
jmp 0x6841a
movq 0x40648(%rbx), %rdi
leaq 0x28(%rsp), %rsi
callq 0x578a0
testb %al, %al
je 0x6841a
movb $0x1, 0x601(%rbx)
movq %rbx, %rdi
movl $0x7800, %esi           # imm = 0x7800
callq 0x59158
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x68439
jmp 0x68439
jmp 0x68439
jmp 0x68439
jmp 0x68439
jmp 0x68439
jmp 0x68439
jmp 0x68439
movq %rax, %rbx
movq %rsp, %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090