// File: /workspace/github_cpp_makefile_star2_O2/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 0xb771
testl %eax, %eax
je 0x9ddc4
movl %r14d, %edi
callq 0x1d93f
cmpl $0xa, %r14d
jne 0x9ddd6
callq 0x51891
movl %eax, %ebx
leaq 0x25a52d(%rip), %rax    # 0x2f82e0
cmpb $0x0, 0x17a12(%rax)
je 0x9de04
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0x9de01
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1d61b
callq 0x518f0
movl %eax, %ebx
movl %r14d, %eax
imulq $0x2260, %rax, %rax     # imm = 0x2260
leaq 0x25a4f2(%rip), %rcx    # 0x2f82e0
cmpb $0x0, 0x2252(%rcx,%rax)
je 0x9de04
addq %rcx, %rax
addq $0x2252, %rax           # imm = 0x2252
movb $0x0, (%rax)
leaq 0x28444b(%rip), %r15    # 0x322256
movzwl (%r15), %eax
cmpl $0x1, %eax
je 0x9de4b
testl %eax, %eax
jne 0x9de6e
cmpb $0xd, %bl
je 0x9de25
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0x9de30
movw $0x1, (%r15)
callq 0x51a2f
leaq 0x28441b(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x284412(%rip), %rax    # 0x322254
andw $0x0, (%rax)
jmp 0x9df17
cmpb $0xd, %bl
je 0x9de5c
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0x9def5
leaq 0x2843ef(%rip), %rax    # 0x322252
cmpw $0x0, (%rax)
jne 0x9de7b
jmp 0x9df17
leaq 0x2843dd(%rip), %rax    # 0x322252
cmpw $0x0, (%rax)
je 0x9dec3
leaq 0x258e8a(%rip), %rax    # 0x2f6d0c
cmpl $0x49, (%rax)
sete %al
leaq 0x167225(%rip), %rcx    # 0x2050b4
movl (%rcx), %ecx
testl %ecx, %ecx
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x9deb1
leaq 0x167214(%rip), %rdx    # 0x2050b8
movl (%rdx), %eax
incl %eax
movl %eax, (%rdx)
cltd
idivl %ecx
testl %edx, %edx
jne 0x9deb9
movl %r14d, %edi
callq 0x6e33e
movl $0x1, 0x2b7dd1(%rip)    # 0x355c94
leaq 0x284388(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x28437f(%rip), %rax    # 0x322254
andw $0x0, (%rax)
cmpb $0xd, %bl
je 0x9dee6
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0x9deee
movw $0x1, (%r15)
jmp 0x9df17
andw $0x0, (%r15)
jmp 0x9df17
leaq 0x284356(%rip), %rcx    # 0x322252
movzwl (%rcx), %eax
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0x9df22
leal 0x1(%rax), %edx
movw %dx, (%rcx)
leaq 0x28333c(%rip), %rcx    # 0x321250
movb %bl, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18b047(%rip), %rax    # 0x228f70
orb $-0x80, 0x1(%rax)
jmp 0x9dec3