// File: /workspace/github_c_makefile_star2_O2/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
cmpq $0x356, %rax            # imm = 0x356
je 0xa57a
movw %ax, 0x40(%rsp,%rax,4)
incq %rax
jmp 0xa568
callq 0xaf9a
leaq 0x91aa(%rip), %rbx      # 0x13730
xorl %r15d, %r15d
movss 0x2efb(%rip), %xmm2     # 0xd48c
movl $0x1900, %r12d          # imm = 0x1900
movq %rsp, %rbp
movss 0x2ede(%rip), %xmm3     # 0xd480
movss 0x2eda(%rip), %xmm4     # 0xd484
negq %rbp
movq %rbx, %r14
xorl %r13d, %r13d
cmpq $0x4, %r13
je 0xa6dd
movl $0x2ea, %ecx            # imm = 0x2EA
cmpq $0x3, %r13
je 0xa671
imulq $0x1900, %r13, %rax     # imm = 0x1900
addq %rbx, %rax
addq $0x6ac, %rax            # imm = 0x6AC
movl $0x6b0, %ecx            # imm = 0x6B0
movq %rsp, %rdx
cmpq $0x1250, %rcx           # imm = 0x1250
jge 0xa605
leaq (%r15,%rcx), %rsi
movss (%rbx,%rsi), %xmm0
ucomiss %xmm3, %xmm0
ja 0xa605
addq $0x4, %rcx
jmp 0xa5e4
addq $0x4, %rcx
cmpq $0x124f, %rcx           # imm = 0x124F
jg 0xa633
ucomiss (%r14,%rcx), %xmm4
jbe 0xa601
leaq (%r14,%rcx), %rdi
leaq 0x8(%rdx), %rsi
movq %rdi, (%rdx)
leaq (%rdx,%rbp), %rdi
addq $0x8, %rdi
movq %rsi, %rdx
cmpq $0x40, %rdi
jb 0xa5e4
jmp 0xa636
movq %rdx, %rsi
pushq $-0x1
popq %rcx
movss 0x2e47(%rip), %xmm0     # 0xd488
movq %rsp, %rdx
cmpq %rsi, %rdx
jae 0xa66b
movq (%rdx), %rdi
movss (%rdi), %xmm1
subq %rax, %rdi
sarq $0x2, %rdi
ucomiss %xmm1, %xmm0
cmovaq %rdi, %rcx
minss %xmm0, %xmm1
addq $0x8, %rdx
movaps %xmm1, %xmm0
jmp 0xa644
cmpq $-0x1, %rcx
je 0xa6cf
imulq $0x78, %r13, %rax
addq $0x3c, %rax
cvtsi2ss %rax, %xmm0
leaq (%r14,%rcx,4), %rax
xorl %ecx, %ecx
cmpq $0x356, %rcx            # imm = 0x356
je 0xa6a8
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %edx
movw %dx, 0x42(%rsp,%rcx,4)
incq %rcx
jmp 0xa684
movl $0x6ac, %esi            # imm = 0x6AC
leaq 0x40(%rsp), %rdi
callq 0xafdd
movss 0x2dc5(%rip), %xmm4     # 0xd484
movss 0x2db9(%rip), %xmm3     # 0xd480
movss 0x2dbd(%rip), %xmm2     # 0xd48c
incq %r13
addq %r12, %r15
addq %r12, %r14
jmp 0xa5b3
callq 0xb01b
leaq 0x7d5f(%rip), %rax      # 0x12448
cmpb $0x0, 0x5(%rax)
jne 0xa7cf
cmpl $0x0, 0x8f66(%rip)      # 0x13660
jle 0xa75c
movq 0x78cd(%rip), %rbx      # 0x11fd0
movq (%rbx), %rdi
movl 0x2c(%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movl 0x8f48(%rip), %eax      # 0x13660
movl %eax, %ecx
decl %ecx
movl %ecx, 0x8f3e(%rip)      # 0x13660
je 0xa7b8
cmpl $0x11, %eax
jl 0xa73c
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52b0
leaq 0x1d24(%rip), %rdi      # 0xc467
leaq 0x8e96(%rip), %rsi      # 0x135e0
xorl %eax, %eax
callq 0x54e0
cmpl $0x10, 0x8f08(%rip)     # 0x13660
jge 0xa7a7
jmp 0xa7c0
cmpb $0x1, 0xf3cd(%rip)      # 0x19b30
jne 0xa7c0
movq 0x7864(%rip), %rbx      # 0x11fd0
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 0x2f92(%rip), %rdi      # 0xd72b
leaq 0xf3a0(%rip), %rsi      # 0x19b40
xorl %eax, %eax
callq 0x54e0
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x55a0
jmp 0xa7c0
movq (%rbx), %rdi
callq 0x5220
movq 0x7809(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
callq 0x52c0
addq $0xd98, %rsp            # imm = 0xD98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq