// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_rcvr_ticc_message(unsigned int)
void get_rcvr_ticc_message(unsigned port)
{
u08 c;
static u08 last_c = 0;

   // This routine buffers up an incoming tsip message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_tsip_msg()
   // Messages can end with 0x0D, 0x0A, or both.

   if(SERIAL_DATA_AVAILABLE(port) == 0) {
      check_com_timer(port);
      return;
   }
   else {
      reset_com_timer(port);
   }

   if(port == RCVR_PORT) {  // TICC on the main input decice (/rxi)
      c = get_com_char();
      if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
         com[RCVR_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }
   else {  // TICC on the auxiliary input device (/ei=)
      c = get_ticc_char();  // aaattt
      if(com[port].rcv_error) {      // parity/framing/overrun errors
         com[port].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }


   last_c = c;

   if(tsip_sync == 0) {    // syncing to start of message, search for a line feed
      if((c == 0x0D) || (c == 0x0A)) {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      return;
   }
   else if(tsip_sync == 1) { // 0x0A has been seen, now build the message
      if((c == 0x0D) || (c == 0x0A)) {
         if(tsip_wptr == 0) return; // end-of-line with no data in the message buffer
         goto tsip_end;  // end of message
      }

      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         tsip_buf[tsip_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else {  // end of message
      tsip_end:
      if(tsip_wptr) {           // we have a message
         if((ticc_mode == 'I') && plm_freq && (++plm_cycles % plm_freq)) ;   // decimate ticc input
         else decode_ticc_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      tsip_wptr = 0;     // prepare for next message
      tsip_rptr = 0;
      if((c == 0x0D) || (c == 0x0A)) tsip_sync = 1;
      else tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
callq 0xb9ad
testl %eax, %eax
je 0xade12
movl %r14d, %edi
callq 0x1ea0b
cmpl $0xa, %r14d
jne 0xade24
callq 0x584bd
movl %eax, %ebx
leaq 0x2604df(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xade52
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0xade4f
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1e66a
callq 0x5852c
movl %eax, %ebx
movl %r14d, %eax
imulq $0x2260, %rax, %rax     # imm = 0x2260
leaq 0x2604a4(%rip), %rcx    # 0x30e2e0
cmpb $0x0, 0x2252(%rcx,%rax)
je 0xade52
addq %rcx, %rax
addq $0x2252, %rax           # imm = 0x2252
movb $0x0, (%rax)
leaq 0x28a3fd(%rip), %r15    # 0x338256
movzwl (%r15), %eax
cmpl $0x1, %eax
je 0xade99
testl %eax, %eax
jne 0xadebc
cmpb $0xd, %bl
je 0xade73
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xade7e
movw $0x1, (%r15)
callq 0x58672
leaq 0x28a3cd(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x28a3c3(%rip), %rax    # 0x338254
movw %cx, (%rax)
jmp 0xadf66
cmpb $0xd, %bl
je 0xadeaa
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xadf44
leaq 0x28a3a1(%rip), %rax    # 0x338252
cmpw $0x0, (%rax)
jne 0xadec9
jmp 0xadf66
leaq 0x28a38f(%rip), %rax    # 0x338252
cmpw $0x0, (%rax)
je 0xadf11
leaq 0x25ee3c(%rip), %rax    # 0x30cd0c
cmpl $0x49, (%rax)
sete %al
leaq 0x16d1d7(%rip), %rcx    # 0x21b0b4
movl (%rcx), %ecx
testl %ecx, %ecx
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0xadeff
leaq 0x16d1c6(%rip), %rdx    # 0x21b0b8
movl (%rdx), %eax
incl %eax
movl %eax, (%rdx)
cltd
idivl %ecx
testl %edx, %edx
jne 0xadf07
movl %r14d, %edi
callq 0x788c6
movl $0x1, 0x2bdd83(%rip)    # 0x36bc94
leaq 0x28a33a(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x28a330(%rip), %rax    # 0x338254
movw %cx, (%rax)
cmpb $0xd, %bl
je 0xadf34
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xadf3c
movw $0x1, (%r15)
jmp 0xadf66
movw $0x0, (%r15)
jmp 0xadf66
leaq 0x28a307(%rip), %rcx    # 0x338252
movzwl (%rcx), %eax
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0xadf71
leal 0x1(%rax), %edx
movw %dx, (%rcx)
leaq 0x2892ed(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x190ff8(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
jmp 0xadf11