// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heather.cpp
// Function: echo_term(unsigned int, int, int, int)
void echo_term(unsigned port, int i, int hex, int highlight)
{
char s[UNIT_LEN+1];
int color;

   // put a character into the terminal image buffer.  Handle CR and LF chars
   if(port >= NUM_COM_PORTS) return;

   if(pause_monitor) return;

   color = 0x00;
   if((zoom_screen == 'O') || (zoom_screen == 'H')) {
      if(highlight) color = 0x80;
if(hex == 0) i &= 0x7F;
   }

   if(hex) {  // hex terminal display
      sprintf(s, "%02X", i);

      if(zoom_screen == 'O') ;
      else if(zoom_screen == 'H') ;
      else if(i == pkt_end1)   color = 0x80;  // highlight possible packet boundaries
      else if(i == pkt_end2)   color = 0x80;
      else if(i == pkt_start1) color = 0x80;
      else if(i == pkt_start2) color = 0x80;

      term_screen[term_row][term_col+0] = s[0] | color;
      term_screen[term_row][term_col+1] = s[1] | color;
      term_screen[term_row][term_col+2] = ' ';
      term_screen[term_row][term_col+3] = 0;
      term_col += 3;
      term_changed = 1;

      if(SCREEN_WIDTH < (36*3*TEXT_WIDTH)) {  // small screen - 16 vals per line
         if(term_col > (16*3)) {
            term_col = 0;
            scroll_up(port);
         }
      }
      else { // wide screen
         if(term_col == (16*3)) { // two groups of 16 vals per line
            term_screen[term_row][term_col++] = ' ';
            term_screen[term_row][term_col] = 0;
         }

         if(term_col > (16*6+1)) {
            term_col = 0;
            scroll_up(port);
         }
      }
   }
   else if((i & 0x7F) == 0x0D) {  // carriage return
      term_col = 0;
      if(term_crlf) scroll_up(port);
else if(rcvr_type == UCCM_RCVR) scroll_up(port);  // piss
else if(CRLF_RCVR) scroll_up(port);
else if(port == THERMO_PORT) scroll_up(port);
   }
   else if((i & 0x7F) == 0x0A) {  // line feed
      if(term_crlf) term_col = 0;
//else if(rcvr_type == UCCM_RCVR) term_col = 0;  // piss
else if(CRLF_RCVR) term_col = 0;
else if(port == THERMO_PORT) term_col = 0;
else if(port == TRACK_PORT) term_col = 0;
else if(zoom_screen == 'H') term_col = 0;
      scroll_up(port);
   }
   else if(((i & 0x7F) >= ' ') && ((i & 0x7F) < 0x7F)) { // add char to terminal image buffser
      term_screen[term_row][term_col+0] = ((i & 0xFF) | color);
      term_screen[term_row][term_col+1] = 0;
      term_changed = 1;

      if(++term_col >= term_cols) {
         term_col = 0;
         scroll_up(port);
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
cmpl $0x12, %edi
ja 0xae58
cmpl $0x0, 0x2337f9(%rip)    # 0x23e43c
jne 0xae58
movl %esi, %r14d
movl %edi, %ebx
movzbl 0x301b53(%rip), %eax    # 0x30c7a8
cmpl $0x4f, %eax
je 0xac62
xorl %r15d, %r15d
cmpl $0x48, %eax
jne 0xac7b
xorl %r15d, %r15d
testl %ecx, %ecx
setne %r15b
shll $0x7, %r15d
movl %r14d, %ecx
andl $0x7f, %ecx
testl %edx, %edx
cmovel %ecx, %r14d
testl %edx, %edx
je 0xad42
leaq 0x11fd26(%rip), %rsi    # 0x12a9b0
leaq -0x30(%rbp), %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x9060
movzbl 0x301b09(%rip), %eax    # 0x30c7a8
cmpl $0x48, %eax
je 0xacd4
cmpl $0x4f, %eax
je 0xacd4
movl $0x80, %eax
cmpl 0x210387(%rip), %r14d   # 0x21b03c
je 0xacd7
cmpl 0x210382(%rip), %r14d   # 0x21b040
je 0xacd7
cmpl 0x21037d(%rip), %r14d   # 0x21b044
je 0xacd7
cmpl 0x210378(%rip), %r14d   # 0x21b048
cmovel %eax, %r15d
movl %r15d, %eax
movb -0x30(%rbp), %dil
orb %al, %dil
movslq 0x23374b(%rip), %rcx    # 0x23e430
movslq 0x233748(%rip), %rsi    # 0x23e434
imulq $0x85, %rcx, %rcx
leaq 0x335936(%rip), %rdx    # 0x340630
leaq (%rdx,%rcx), %r8
movb %dil, (%rsi,%r8)
orb -0x2f(%rbp), %al
movb %al, 0x1(%rsi,%r8)
movw $0x20, 0x2(%rsi,%r8)
leal 0x3(%rsi), %eax
movl %eax, 0x233719(%rip)    # 0x23e434
movl $0x1, 0x337a53(%rip)    # 0x342778
imull $0x6c, 0x20dae4(%rip), %edi # 0x218810
cmpl %edi, 0x20dace(%rip)    # 0x218800
jge 0xadaa
cmpl $0x2d, %esi
jle 0xae58
jmp 0xae63
movl %r14d, %ecx
andl $0x7f, %ecx
cmpl $0xa, %ecx
je 0xadd2
cmpl $0xd, %ecx
jne 0xae02
movl $0x0, 0x2336d0(%rip)    # 0x23e434
cmpl $0x0, 0x337a1d(%rip)    # 0x342788
jne 0xae6d
movq 0x20db58(%rip), %rax    # 0x2188d0
cmpq $0x8, %rax
sete %cl
movabsq $0x151b0f1010, %rdx     # imm = 0x151B0F1010
testq %rdx, %rax
setne %al
orb %cl, %al
jne 0xae6d
cmpl $0xf, %ebx
movl $0xf, %ebx
jne 0xae58
jmp 0xae6d
cmpl $0x30, %eax
jne 0xadc0
movl $0x31, 0x23367b(%rip)   # 0x23e434
movw $0x20, 0x30(%rcx,%rdx)
cmpl $0x61, 0x23366d(%rip)   # 0x23e434
jle 0xae58
jmp 0xae63
cmpl $0x0, 0x3379af(%rip)    # 0x342788
jne 0xae63
movabsq $0x151b0f1010, %rcx     # imm = 0x151B0F1010
testq %rcx, 0x20dae0(%rip)    # 0x2188d0
jne 0xae63
cmpl $0xf, %ebx
je 0xae63
cmpl $0x12, %ebx
je 0xae63
cmpb $0x48, %al
je 0xae63
jmp 0xae6d
cmpl $0x20, %ecx
setb %al
cmpl $0x7f, %ecx
sete %cl
orb %al, %cl
jne 0xae58
orl %r14d, %r15d
movslq 0x233614(%rip), %rax    # 0x23e430
movslq 0x233611(%rip), %rcx    # 0x23e434
imulq $0x85, %rax, %rax
leaq 0x3357ff(%rip), %rdx    # 0x340630
addq %rax, %rdx
movb %r15b, (%rcx,%rdx)
movb $0x0, 0x1(%rcx,%rdx)
incq %rcx
movl $0x1, 0x33792e(%rip)    # 0x342778
movl %ecx, 0x2335e4(%rip)    # 0x23e434
cmpl 0x33791e(%rip), %ecx    # 0x342774
jge 0xae63
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x2335c7(%rip)    # 0x23e434
movl %ebx, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1ee81