// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x40648(%rdi), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rax, %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x8cb18(%rip), %xmm0    # 0xf4760
divsd 0x8c8a0(%rip), %xmm0    # 0xf44f0
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm1
cmpltsd %xmm2, %xmm1
movsd 0x8c72b(%rip), %xmm3    # 0xf4390
movapd %xmm1, %xmm2
andpd %xmm3, %xmm2
movsd 0x8c723(%rip), %xmm3    # 0xf4398
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15
movq %r14, %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x8caca(%rip), %xmm0    # 0xf4768
divsd 0x8c84a(%rip), %xmm0    # 0xf44f0
movapd %xmm0, %xmm1
cmpltsd 0x8cad5(%rip), %xmm1    # 0xf4788
movapd %xmm1, %xmm2
movsd 0x8c6d1(%rip), %xmm3    # 0xf4390
andpd %xmm3, %xmm2
movsd 0x8c6cd(%rip), %xmm3    # 0xf4398
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r12
addl %r15d, %r12d
movl %r12d, 0x30(%rsp)
movl 0x5fc(%rbx), %eax
movl %eax, 0x34(%rsp)
movq %r14, %rdi
callq 0x58930
movsd 0x8c692(%rip), %xmm3    # 0xf4390
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x8ca6a(%rip), %xmm0    # 0xf4778
divsd 0x8c7da(%rip), %xmm0    # 0xf44f0
movapd %xmm0, %xmm1
cmpltsd 0x8ca65(%rip), %xmm1    # 0xf4788
movapd %xmm1, %xmm2
andpd %xmm3, %xmm2
movsd 0x8c665(%rip), %xmm4    # 0xf4398
andnpd %xmm4, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
leal 0x1(%rax,%r12), %eax
movl %eax, 0x38(%rsp)
movl 0x34(%rsp), %eax
leal 0x1(%rax,%r15), %eax
movl %eax, 0x3c(%rsp)
movl 0x5f8(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x20(%rsp)
movl 0x5fc(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rsp)
leal 0x1(%rax,%r15), %eax
movl %eax, 0x28(%rsp)
leal (%rcx,%r15), %eax
incl %eax
movl %eax, 0x2c(%rsp)
cmpl $0x7800, %ebp           # imm = 0x7800
je 0x67e05
cmpl $0x7802, %ebp           # imm = 0x7802
je 0x67dc8
cmpl $0x7801, %ebp           # imm = 0x7801
jne 0x6845e
movq 0x40648(%rbx), %rdi
leaq 0x30(%rsp), %rsi
callq 0x578a0
testb %al, %al
je 0x68435
movb $0x1, 0x600(%rbx)
jmp 0x68451
cmpb $0x1, 0x600(%rbx)
jne 0x6807e
movb $0x0, 0x600(%rbx)
movq 0x40648(%rbx), %rax
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x5ec(%rax)
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x591e0
cmpb $0x1, 0x600(%rbx)
jne 0x68097
movq 0x40648(%rbx), %rdi
callq 0x56b50
shrq $0x20, %rax
movl 0x5fc(%rbx), %ecx
movl %ecx, %edx
notl %edx
addl %eax, %edx
leal -0x1(%r15), %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 %r15d, %xmm1
movsd 0x8c91b(%rip), %xmm2    # 0xf4770
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm2, %xmm0
seta %al
leaq 0x8c91f(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm2
cvttsd2si %xmm2, %rsi
movl 0x614(%rbx), %eax
movl $0xff, %edx
subl %esi, %edx
cmpl %eax, %edx
je 0x6845e
movl %eax, 0x608(%rbx)
movl %edx, 0x614(%rbx)
movq 0x40648(%rbx), %rax
movl 0x5f8(%rbx), %edx
leal (%rdx,%r15), %esi
incl %esi
incl %edx
movl %ecx, %edi
incl %edi
addl %r15d, %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 0x48(%rsp), %r14
movq %rax, 0x8(%r14)
movl $0x2, %ebp
movl %ebp, (%r14)
leaq 0x8(%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)
leaq 0x8(%rsp), %r14
leaq 0x48(%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)
leaq 0x8(%rsp), %r14
leaq 0x48(%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
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
jmp 0x6840f
cmpb $0x1, 0x601(%rbx)
jne 0x6845e
movb $0x0, 0x601(%rbx)
jmp 0x6845e
cmpb $0x1, 0x601(%rbx)
jne 0x6845e
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(%r15), %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 %r15d, %xmm1
movsd 0x8c67a(%rip), %xmm2    # 0xf4770
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm3
cmpltsd %xmm1, %xmm3
movapd %xmm3, %xmm4
movsd 0x8c279(%rip), %xmm6    # 0xf4390
andpd %xmm6, %xmm4
movsd 0x8c275(%rip), %xmm5    # 0xf4398
andnpd %xmm5, %xmm3
orpd %xmm4, %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
movapd %xmm6, %xmm1
andpd %xmm2, %xmm1
andnpd %xmm5, %xmm2
orpd %xmm1, %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 0x6818e
cmpl %esi, %ecx
je 0x6845e
movl %edx, 0x610(%rbx)
movl %esi, 0x60c(%rbx)
movl %eax, 0x61c(%rbx)
movl %ecx, 0x618(%rbx)
movq 0x40670(%rbx), %r12
shll $0x10, %eax
shll $0x8, %ecx
orl %eax, %ecx
orl 0x614(%rbx), %ecx
movslq %ecx, %rax
leaq 0x48(%rsp), %rbp
movq %rax, 0x8(%rbp)
movl $0x2, %eax
movl %eax, (%rbp)
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x57d10
movq %r12, %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,%r15), %eax
movl %eax, 0x8(%r13)
leal 0x1(%rcx,%r15), %eax
movl %eax, 0xc(%r13)
leaq 0x8(%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(%rbp)
movl $0x2, %r12d
movl %r12d, (%rbp)
leaq 0x8(%rsp), %r14
leaq 0x48(%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 %r12d, (%r15)
movl $0x2, %ebp
leaq 0x8(%rsp), %r14
leaq 0x48(%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)
leaq 0x8(%rsp), %r14
leaq 0x48(%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
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x406f0(%rbx), %r14
movslq 0x618(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40700(%rbx), %r14
movslq 0x620(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40708(%rbx), %r14
movslq 0x624(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40710(%rbx), %r14
movslq 0x628(%rbx), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x56cf0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0xa0(%rax)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x40718(%rbx), %rdi
addq $0x40630, %rbx          # imm = 0x40630
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xa0(%rax)
jmp 0x6845e
movq 0x40648(%rbx), %rdi
leaq 0x20(%rsp), %rsi
callq 0x578a0
testb %al, %al
je 0x6845e
movb $0x1, 0x601(%rbx)
movq %rbx, %rdi
movl $0x7800, %esi           # imm = 0x7800
callq 0x59158
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
jmp 0x6847d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090