// File: /workspace/github_cpp_makefile_star2_O2/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 0xad01
cmpl $0x0, 0x21d946(%rip)    # 0x22843c
jne 0xad01
movl %esi, %r14d
movl %edi, %ebx
movzbl 0x2ebca0(%rip), %eax    # 0x2f67a8
cmpl $0x4f, %eax
je 0xab15
xorl %r15d, %r15d
cmpl $0x48, %eax
jne 0xab2e
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 0xabf5
leaq 0x109e83(%rip), %rsi    # 0x1149c0
leaq -0x30(%rbp), %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x9060
movzbl 0x2ebc56(%rip), %eax    # 0x2f67a8
cmpl $0x48, %eax
je 0xab87
cmpl $0x4f, %eax
je 0xab87
movl $0x80, %eax
cmpl 0x1fa4d4(%rip), %r14d   # 0x20503c
je 0xab8a
cmpl 0x1fa4cf(%rip), %r14d   # 0x205040
je 0xab8a
cmpl 0x1fa4ca(%rip), %r14d   # 0x205044
je 0xab8a
cmpl 0x1fa4c5(%rip), %r14d   # 0x205048
cmovel %eax, %r15d
movl %r15d, %eax
movb -0x30(%rbp), %dil
orb %al, %dil
movslq 0x21d898(%rip), %rdx    # 0x228430
movslq 0x21d895(%rip), %rcx    # 0x228434
imulq $0x85, %rdx, %rdx
leaq 0x31fa83(%rip), %rsi    # 0x32a630
leaq (%rsi,%rdx), %r8
movb %dil, (%rcx,%r8)
orb -0x2f(%rbp), %al
movb %al, 0x1(%rcx,%r8)
movw $0x20, 0x2(%rcx,%r8)
leal 0x3(%rcx), %eax
movl %eax, 0x21d866(%rip)    # 0x228434
movl $0x1, 0x321ba0(%rip)    # 0x32c778
imull $0x6c, 0x1f7c31(%rip), %edi # 0x202810
cmpl %edi, 0x1f7c1b(%rip)    # 0x202800
jge 0xac52
cmpl $0x2e, %ecx
jl 0xad01
jmp 0xad0c
movl %r14d, %ecx
andl $0x7f, %ecx
cmpl $0xa, %ecx
je 0xac7b
cmpl $0xd, %ecx
jne 0xacab
andl $0x0, 0x21d824(%rip)    # 0x228434
cmpl $0x0, 0x321b71(%rip)    # 0x32c788
jne 0xad13
movq 0x1f7cac(%rip), %rax    # 0x2028d0
cmpq $0x8, %rax
je 0xad13
movabsq $0x151b0f1010, %rcx     # imm = 0x151B0F1010
testq %rcx, %rax
jne 0xad13
cmpl $0xf, %ebx
jne 0xad01
pushq $0xf
popq %rdi
jmp 0xad15
cmpl $0x30, %eax
jne 0xac6d
movl $0x31, 0x21d7d3(%rip)   # 0x228434
movw $0x20, 0x30(%rdx,%rsi)
jmp 0xad01
cmpl $0x5f, %ecx
jl 0xad01
jmp 0xad0c
cmpl $0x0, 0x321b06(%rip)    # 0x32c788
jne 0xad0c
movabsq $0x151b0f1010, %rcx     # imm = 0x151B0F1010
testq %rcx, 0x1f7c37(%rip)    # 0x2028d0
jne 0xad0c
cmpl $0xf, %ebx
je 0xad0c
cmpl $0x12, %ebx
je 0xad0c
cmpb $0x48, %al
je 0xad0c
jmp 0xad13
cmpl $0x20, %ecx
setb %al
cmpl $0x7f, %ecx
sete %cl
orb %al, %cl
jne 0xad01
orl %r14d, %r15d
movslq 0x21d76b(%rip), %rax    # 0x228430
movslq 0x21d768(%rip), %rcx    # 0x228434
imulq $0x85, %rax, %rax
leaq 0x31f956(%rip), %rdx    # 0x32a630
addq %rax, %rdx
movb %r15b, (%rcx,%rdx)
movb $0x0, 0x1(%rcx,%rdx)
incq %rcx
movl $0x1, 0x321a85(%rip)    # 0x32c778
movl %ecx, 0x21d73b(%rip)    # 0x228434
cmpl 0x321a75(%rip), %ecx    # 0x32c774
jge 0xad0c
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
andl $0x0, 0x21d721(%rip)    # 0x228434
movl %ebx, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1dd24