// File: tjohnman[P]sfxr-sdl2/build/../src/main.cpp
// Function: Slider(int, int, float&, bool, char const*)
bool Slider(int x, int y, float& value, bool bipolar, const char* text)
{
	bool result = false;
	if(MouseInBox(x, y, 100, 10))
	{
		if(mouse_rightclick)
		{
			value=0.0f;
			result = true;
		}
		if(mouse_leftclick)
		{
			if(dragOnLeftClick)
				vselected=&value;
			else
			{
				if(bipolar)
					value = (mouse_x - x)/50.0f - 1.0f;
				else
					value = (mouse_x - x)/100.0f;
				result = true;
			}
		}
	}
	float mv=(float)(mouse_x-mouse_px);
	if(vselected!=&value)
		mv=0.0f;
	if(bipolar)
	{
		value+=mv*0.005f;
		if(value<-1.0f) value=-1.0f;
		if(value>1.0f) value=1.0f;
	}
	else
	{
		value+=mv*0.0025f;
		if(value<0.0f) value=0.0f;
		if(value>1.0f) value=1.0f;
	}
	DrawBar(x-1, y, 102, 10, 0x000000);
	int ival=(int)(value*99);
	if(bipolar)
		ival=(int)(value*49.5f+49.5f);
	DrawBar(x, y+1, ival, 8, 0xF0C090);
	DrawBar(x+ival, y+1, 100-ival, 8, 0x807060);
	DrawBar(x+ival, y+1, 1, 8, 0xFFFFFF);
	if(bipolar)
	{
		DrawBar(x+50, y-1, 1, 3, 0x000000);
		DrawBar(x+50, y+8, 1, 3, 0x000000);
	}
	DWORD tcol=0x000000;
	if(wave_type!=0 && (&value==&p_duty || &value==&p_duty_ramp))
		tcol=0x808080;
	DrawText(font, x-4-strlen(text)*8, y+1, tcol, text);
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %r8, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl $0x64, %edx
movl $0xa, %ecx
callq 0xd270
testb $0x1, %al
jne 0x53cf
jmp 0x5470
leaq 0xf34a(%rip), %rax      # 0x14720
testb $0x1, (%rax)
je 0x53ea
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movb $0x1, -0x21(%rbp)
leaq 0xf32e(%rip), %rax      # 0x1471f
testb $0x1, (%rax)
je 0x546e
testb $0x1, 0xf2b3(%rip)      # 0x146b0
je 0x540c
movq -0x10(%rbp), %rax
movq %rax, 0xf26e(%rip)      # 0x14678
jmp 0x546c
testb $0x1, -0x11(%rbp)
je 0x5444
leaq 0xf2f3(%rip), %rax      # 0x1470c
movl (%rax), %eax
subl -0x4(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x8c4e(%rip), %xmm1     # 0xe078
divss %xmm1, %xmm0
movss 0x8bd2(%rip), %xmm1     # 0xe008
subss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, (%rax)
jmp 0x5468
leaq 0xf2c1(%rip), %rax      # 0x1470c
movl (%rax), %eax
subl -0x4(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x8c18(%rip), %xmm1     # 0xe074
divss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, (%rax)
movb $0x1, -0x21(%rbp)
jmp 0x546e
jmp 0x5470
leaq 0xf295(%rip), %rax      # 0x1470c
movl (%rax), %eax
leaq 0xf294(%rip), %rcx      # 0x14714
subl (%rcx), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x28(%rbp)
movq 0xf1e6(%rip), %rax      # 0x14678
cmpq -0x10(%rbp), %rax
je 0x54a0
xorps %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
testb $0x1, -0x11(%rbp)
je 0x550f
movss -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss (%rax), %xmm1
movss 0x8bc5(%rip), %xmm2     # 0xe080
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
movq -0x10(%rbp), %rax
movss 0x8b85(%rip), %xmm0     # 0xe058
ucomiss (%rax), %xmm0
jbe 0x54e8
movq -0x10(%rbp), %rax
movss 0x8b74(%rip), %xmm0     # 0xe058
movss %xmm0, (%rax)
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
movss 0x8b10(%rip), %xmm1     # 0xe008
ucomiss %xmm1, %xmm0
jbe 0x550d
movq -0x10(%rbp), %rax
movss 0x8aff(%rip), %xmm0     # 0xe008
movss %xmm0, (%rax)
jmp 0x556e
movss -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss (%rax), %xmm1
movss 0x8b58(%rip), %xmm2     # 0xe07c
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss (%rax), %xmm0
jbe 0x5547
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
movss 0x8ab1(%rip), %xmm1     # 0xe008
ucomiss %xmm1, %xmm0
jbe 0x556c
movq -0x10(%rbp), %rax
movss 0x8aa0(%rip), %xmm0     # 0xe008
movss %xmm0, (%rax)
jmp 0x556e
movl -0x4(%rbp), %edi
subl $0x1, %edi
movl -0x8(%rbp), %esi
movl $0x66, %edx
movl $0xa, %ecx
xorl %r8d, %r8d
callq 0xcdd0
movq -0x10(%rbp), %rax
movss 0x8aef(%rip), %xmm0     # 0xe084
mulss (%rax), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
testb $0x1, -0x11(%rbp)
je 0x55c5
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
movss 0x8ad2(%rip), %xmm1     # 0xe088
mulss %xmm1, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
addl $0x1, %esi
movl -0x2c(%rbp), %edx
movl $0x8, %ecx
movl $0xf0c090, %r8d         # imm = 0xF0C090
callq 0xcdd0
movl -0x4(%rbp), %edi
addl -0x2c(%rbp), %edi
movl -0x8(%rbp), %esi
addl $0x1, %esi
movl $0x64, %edx
subl -0x2c(%rbp), %edx
movl $0x8, %ecx
movl $0x807060, %r8d         # imm = 0x807060
callq 0xcdd0
movl -0x4(%rbp), %edi
addl -0x2c(%rbp), %edi
movl -0x8(%rbp), %esi
addl $0x1, %esi
movl $0x1, %edx
movl $0x8, %ecx
movl $0xffffff, %r8d         # imm = 0xFFFFFF
callq 0xcdd0
testb $0x1, -0x11(%rbp)
je 0x5668
movl -0x4(%rbp), %edi
addl $0x32, %edi
movl -0x8(%rbp), %esi
subl $0x1, %esi
movl $0x1, %edx
movl $0x3, %ecx
xorl %r8d, %r8d
callq 0xcdd0
movl -0x4(%rbp), %edi
addl $0x32, %edi
movl -0x8(%rbp), %esi
addl $0x8, %esi
movl $0x1, %edx
movl $0x3, %ecx
xorl %r8d, %r8d
callq 0xcdd0
movl $0x0, -0x30(%rbp)
cmpl $0x0, 0xde6a(%rip)      # 0x134e0
je 0x5699
leaq 0xde75(%rip), %rax      # 0x134f4
cmpq %rax, -0x10(%rbp)
je 0x5692
leaq 0xde6c(%rip), %rax      # 0x134f8
cmpq %rax, -0x10(%rbp)
jne 0x5699
movl $0x808080, -0x30(%rbp)  # imm = 0x808080
movl -0x4(%rbp), %eax
subl $0x4, %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3150
movq %rax, %rcx
movq -0x38(%rbp), %rax
shlq $0x3, %rcx
subq %rcx, %rax
movl %eax, %esi
movl -0x8(%rbp), %edx
addl $0x1, %edx
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %r8
leaq 0xdc96(%rip), %rdi      # 0x13368
movb $0x0, %al
callq 0xd150
movb -0x21(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)