// File: /workspace/github_c_makefile_star2_O1/baines[P]MiniGBS/ui.c
// Function: ui_refresh
void ui_refresh(void){
	struct point {
		int16_t x, y;
	} points[OSC_W];

	for(size_t i = 0; i < OSC_W; ++i){
		points[i].x = i;
	}

	const int off_start = OSC_W / 2;
	const int off_end   = OSC_SAMPLES - off_start;
	const int height    = 120;

	x11_draw_begin();

	for(size_t i = 0; i < 4; ++i){
		struct osc_chan* c = osc_chans + i;

		const float y_mid = height / 2 + height * i;
		const ssize_t off = i == 3 ? OSC_SAMPLES - OSC_W : osc_find_transition(c->samples + off_start, c->samples + off_end);

		if(off != -1){
			for(size_t j = 0; j < OSC_W; ++j){
				points[j].y = y_mid + c->samples[j+off] * height;
			}
			x11_draw_lines((int16_t*)&points, OSC_W*2);
		}
	}

	x11_draw_end();
	if(cfg.hide_ui) return;

	ui_msg_draw();
	refresh();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd98, %rsp            # imm = 0xD98
xorl %eax, %eax
movw %ax, 0x40(%rsp,%rax,4)
incq %rax
cmpq $0x356, %rax            # imm = 0x356
jne 0xac67
callq 0xb73d
leaq 0x7ab1(%rip), %r14      # 0x12734
leaq 0x7aa6(%rip), %r15      # 0x12730
xorl %r12d, %r12d
movss 0x27db(%rip), %xmm2     # 0xd470
movq %rsp, %rbp
movss 0x27c4(%rip), %xmm3     # 0xd464
movss 0x27c0(%rip), %xmm4     # 0xd468
movq %r15, %rbx
xorl %r13d, %r13d
movl $0x2ea, %edx            # imm = 0x2EA
cmpq $0x3, %r13
je 0xad8b
imulq $0x1900, %r13, %rax     # imm = 0x1900
addq %r15, %rax
movl $0x6b0, %edx            # imm = 0x6B0
movq %rbp, %rcx
cmpq $0x124f, %rdx           # imm = 0x124F
jg 0xacf9
leaq (%r12,%rdx), %rsi
movss (%r15,%rsi), %xmm0
ucomiss %xmm3, %xmm0
ja 0xacf9
leaq 0x4(%rdx), %rsi
cmpq $0x124c, %rdx           # imm = 0x124C
movq %rsi, %rdx
jl 0xacd8
jmp 0xacfc
movq %rdx, %rsi
cmpq $0x1250, %rsi           # imm = 0x1250
setl %dil
jge 0xad35
ucomiss (%rax,%rsi), %xmm4
ja 0xad2a
leaq 0x4(%rsi), %rdx
cmpq $0x124c, %rsi           # imm = 0x124C
setl %dil
jge 0xad38
ucomiss (%r14,%rsi), %xmm4
movq %rdx, %rsi
jbe 0xad0f
leaq (%rax,%rsi), %rdx
movq %rdx, (%rcx)
addq $0x8, %rcx
movq %rsi, %rdx
testb %dil, %dil
je 0xad49
movq %rcx, %rsi
subq %rbp, %rsi
cmpq $0x40, %rsi
jb 0xaccf
movq $-0x1, %rdx
cmpq %rcx, %rbp
jae 0xad8b
addq $0x6ac, %rax            # imm = 0x6AC
movq %rbp, %rsi
movss 0x2706(%rip), %xmm0     # 0xd46c
movq (%rsi), %rdi
movss (%rdi), %xmm1
subq %rax, %rdi
sarq $0x2, %rdi
ucomiss %xmm1, %xmm0
cmovaq %rdi, %rdx
minss %xmm0, %xmm1
addq $0x8, %rsi
movaps %xmm1, %xmm0
cmpq %rcx, %rsi
jb 0xad66
cmpq $-0x1, %rdx
je 0xadf0
imulq $0x78, %r13, %rax
addq $0x3c, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
leaq (%rbx,%rdx,4), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %edx
movw %dx, 0x42(%rsp,%rcx,4)
incq %rcx
cmpq $0x356, %rcx            # imm = 0x356
jne 0xada7
movl $0x6ac, %esi            # imm = 0x6AC
leaq 0x40(%rsp), %rdi
callq 0xb780
movss 0x2690(%rip), %xmm2     # 0xd470
movss 0x267c(%rip), %xmm3     # 0xd464
movss 0x2678(%rip), %xmm4     # 0xd468
incq %r13
movl $0x1900, %eax           # imm = 0x1900
addq %rax, %r12
addq %rax, %r14
addq %rax, %rbx
cmpq $0x4, %r13
jne 0xacae
callq 0xb7be
leaq 0x6631(%rip), %rax      # 0x11448
cmpb $0x0, 0x5(%rax)
jne 0xaefd
cmpl $0x0, 0x7838(%rip)      # 0x12660
jle 0xae8a
movq 0x619f(%rip), %rbx      # 0x10fd0
movq (%rbx), %rdi
movl 0x2c(%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movl 0x781a(%rip), %eax      # 0x12660
movl %eax, %ecx
decl %ecx
movl %ecx, 0x7810(%rip)      # 0x12660
je 0xaee6
cmpl $0x11, %eax
jl 0xae6a
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52b0
leaq 0x15a6(%rip), %rdi      # 0xc417
leaq 0x7768(%rip), %rsi      # 0x125e0
xorl %eax, %eax
callq 0x54d0
cmpl $0x10, 0x77da(%rip)     # 0x12660
jge 0xaed5
jmp 0xaeee
cmpb $0x1, 0xdc9f(%rip)      # 0x18b30
jne 0xaeee
movq 0x6136(%rip), %rbx      # 0x10fd0
movq (%rbx), %rdi
movl 0x2c(%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movq (%rbx), %rdi
callq 0x5220
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52b0
leaq 0x2844(%rip), %rdi      # 0xd70b
leaq 0xdc72(%rip), %rsi      # 0x18b40
xorl %eax, %eax
callq 0x54d0
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5590
jmp 0xaeee
movq (%rbx), %rdi
callq 0x5220
movq 0x60db(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
callq 0x52c0
addq $0xd98, %rsp            # imm = 0xD98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq