// File: /workspace/github_cpp_makefile_star2_O3/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 0xae49
cmpl $0x0, 0x233807(%rip)    # 0x23e43c
jne 0xae49
movl %esi, %r14d
movl %edi, %ebx
movzbl 0x301b61(%rip), %eax    # 0x30c7a8
cmpl $0x4f, %eax
je 0xac54
xorl %r15d, %r15d
cmpl $0x48, %eax
jne 0xac6d
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 0xad34
leaq 0x11fdff(%rip), %rsi    # 0x12aa7b
leaq -0x30(%rbp), %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x9060
movzbl 0x301b17(%rip), %eax    # 0x30c7a8
cmpl $0x48, %eax
je 0xacc6
cmpl $0x4f, %eax
je 0xacc6
movl $0x80, %eax
cmpl 0x210395(%rip), %r14d   # 0x21b03c
je 0xacc9
cmpl 0x210390(%rip), %r14d   # 0x21b040
je 0xacc9
cmpl 0x21038b(%rip), %r14d   # 0x21b044
je 0xacc9
cmpl 0x210386(%rip), %r14d   # 0x21b048
cmovel %eax, %r15d
movl %r15d, %eax
movb -0x30(%rbp), %dil
orb %al, %dil
movslq 0x233759(%rip), %rdx    # 0x23e430
movslq 0x233756(%rip), %rcx    # 0x23e434
imulq $0x85, %rdx, %rdx
leaq 0x335944(%rip), %rsi    # 0x340630
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, 0x233727(%rip)    # 0x23e434
movl $0x1, 0x337a61(%rip)    # 0x342778
imull $0x6c, 0x20daf2(%rip), %edi # 0x218810
cmpl %edi, 0x20dadc(%rip)    # 0x218800
jge 0xad9a
cmpl $0x2e, %ecx
jl 0xae49
jmp 0xae54
movl %r14d, %ecx
andl $0x7f, %ecx
cmpl $0xa, %ecx
je 0xadc3
cmpl $0xd, %ecx
jne 0xadf3
movl $0x0, 0x2336de(%rip)    # 0x23e434
cmpl $0x0, 0x337a2b(%rip)    # 0x342788
jne 0xae5e
movq 0x20db66(%rip), %rax    # 0x2188d0
cmpq $0x8, %rax
je 0xae5e
movabsq $0x151b0f1010, %rcx     # imm = 0x151B0F1010
testq %rcx, %rax
jne 0xae5e
cmpl $0xf, %ebx
jne 0xae49
movl $0xf, %edi
jmp 0xae60
cmpl $0x30, %eax
jne 0xadb5
movl $0x31, 0x23368b(%rip)   # 0x23e434
movw $0x20, 0x30(%rdx,%rsi)
jmp 0xae49
cmpl $0x5f, %ecx
jl 0xae49
jmp 0xae54
cmpl $0x0, 0x3379be(%rip)    # 0x342788
jne 0xae54
movabsq $0x151b0f1010, %rcx     # imm = 0x151B0F1010
testq %rcx, 0x20daef(%rip)    # 0x2188d0
jne 0xae54
cmpl $0xf, %ebx
je 0xae54
cmpl $0x12, %ebx
je 0xae54
cmpb $0x48, %al
je 0xae54
jmp 0xae5e
cmpl $0x20, %ecx
setb %al
cmpl $0x7f, %ecx
sete %cl
orb %al, %cl
jne 0xae49
orl %r14d, %r15d
movslq 0x233623(%rip), %rax    # 0x23e430
movslq 0x233620(%rip), %rcx    # 0x23e434
imulq $0x85, %rax, %rax
leaq 0x33580e(%rip), %rdx    # 0x340630
addq %rax, %rdx
movb %r15b, (%rcx,%rdx)
movb $0x0, 0x1(%rcx,%rdx)
incq %rcx
movl $0x1, 0x33793d(%rip)    # 0x342778
movl %ecx, 0x2335f3(%rip)    # 0x23e434
cmpl 0x33792d(%rip), %ecx    # 0x342774
jge 0xae54
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x2335d6(%rip)    # 0x23e434
movl %ebx, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1ee63