// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/tv.c
// Function: sendupdate
void
sendupdate(TV *tv, FBuffer *buffer, uint16 addr)
{
	uint8 buf[7];
	int i;
	int osw;
	int n1, n2;
	word w1, w2;
	word bw1, bw2;

	/* Don't tell screen to update anything not visible */
	if(addr >= (TVHI-TVLO)/2)
		return;

	msgheader(buf, MSG_WD, 5);
	w2b(buf+3, addr);

//	printf("sending update of %o: %o\n", addr, tv->curbuf->fb[addr]);

	/* Again do the mixing thing for no reason */
	for(i = 0; i < buffer->nosw; i++){
		osw = buffer->osw[i];
		if(osw < 0 || tv->omap[osw] < 0)
			continue;
		n1 = dpymap[0][tv->vswsect[0][osw]];
		n2 = dpymap[1][tv->vswsect[1][osw]];
		w1 = n1 < 0 ? 0 : tv->buffers[n1].fb[addr];
		w2 = n2 < 0 ? 0 : tv->buffers[n2].fb[addr];
		bw1 = n1 < 0 ? 0 : tv->buffers[n1].mask;
		bw2 = n2 < 0 ? 0 : tv->buffers[n2].mask;
		w2b(buf+5, w1^bw1 | w2^bw2);
		writen(tv->cons[tv->omap[osw]].fd, buf, 7);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
cmpl $0x3fd8, %eax           # imm = 0x3FD8
jl 0x3c17
jmp 0x3dfa
leaq -0x19(%rbp), %rdi
movl $0x3, %esi
movl $0x5, %edx
callq 0x4770
leaq -0x19(%rbp), %rdi
addq $0x3, %rdi
movzwl -0x12(%rbp), %esi
callq 0x4740
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8084(%rcx), %eax
jge 0x3dfa
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl 0x8004(%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x3c7f
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, 0x80a60(%rax,%rcx,4)
jge 0x3c84
jmp 0x3dec
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl 0x8088c(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0xa6d3(%rip), %rax      # 0xe370
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl 0x808ac(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0xa6b4(%rip), %rax      # 0xe370
movl 0x40(%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0x3cd0
xorl %eax, %eax
movl %eax, -0x38(%rbp)
jmp 0x3cf1
movq -0x8(%rbp), %rax
addq $0x8, %rax
movslq -0x28(%rbp), %rcx
imulq $0x8088, %rcx, %rcx     # imm = 0x8088
addq %rcx, %rax
movzwl -0x12(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movw %ax, -0x2e(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x3d05
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3d26
movq -0x8(%rbp), %rax
addq $0x8, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x8088, %rcx, %rcx     # imm = 0x8088
addq %rcx, %rax
movzwl -0x12(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x30(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0x3d3a
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x3d5a
movq -0x8(%rbp), %rax
addq $0x8, %rax
movslq -0x28(%rbp), %rcx
imulq $0x8088, %rcx, %rcx     # imm = 0x8088
addq %rcx, %rax
movzwl 0x8000(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movw %ax, -0x32(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x3d6e
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x3d8e
movq -0x8(%rbp), %rax
addq $0x8, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x8088, %rcx, %rcx     # imm = 0x8088
addq %rcx, %rax
movzwl 0x8000(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movw %ax, -0x34(%rbp)
leaq -0x19(%rbp), %rdi
addq $0x5, %rdi
movzwl -0x2e(%rbp), %eax
movzwl -0x32(%rbp), %ecx
xorl %ecx, %eax
movzwl -0x30(%rbp), %ecx
movzwl -0x34(%rbp), %edx
xorl %edx, %ecx
orl %ecx, %eax
movzwl %ax, %esi
callq 0x4740
movq -0x8(%rbp), %rax
addq $0x808e0, %rax          # imm = 0x808E0
movq -0x8(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movslq 0x80a60(%rcx,%rdx,4), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
leaq -0x19(%rbp), %rsi
movl $0x7, %edx
callq 0xa6c0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3c42
addq $0x50, %rsp
popq %rbp
retq