// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: get_taip_message()
void get_taip_message()
{
u08 c;

   // This routine buffers up an incoming TAIP message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_nmea_msg()

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

   c = get_com_char();
   if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
      com[RCVR_PORT].rcv_error = 0;
//!!!!!qqqq    goto rst_msg;
   }

   if(tsip_sync == 0) {    // syncing to start of message, search for a '$'
      if(c == '>') {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      nmea_msg_cksum = 0;  // the checksum in the message
      nmea_vfy_cksum = 0;  // the calculated message checksum
      nmea_vfy_cksum ^= c;
      return;
   }
   else if(tsip_sync == 1) { // '>' has been seen, now build the message
      if((c == '<') || (c == 0x0D) || (c == 0x0A)) goto taip_end;  // message has no checksum

      if(c == '*') {
         nmea_vfy_cksum ^= c;
         tsip_sync = 2;  // message checksum follows
      }
      else if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         nmea_vfy_cksum ^= c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else if(tsip_sync == 2) {  // getting message checksum chars
      if((c == '<') || (c == 0x0D) || (c == 0x0A)) goto taip_end;

      if     ((c >= '0') && (c <= '9')) nmea_msg_cksum = (nmea_msg_cksum << 4) | (c-'0');
      else if((c >= 'A') && (c <= 'F')) nmea_msg_cksum = (nmea_msg_cksum << 4) | ((c-'A')+10);
      else goto rst_msg;
   }
   else if(tsip_sync == 3) {  // end of message
      taip_end:
      if((tsip_sync == 2) && (nmea_vfy_cksum != nmea_msg_cksum)) { // checksum error
         tsip_error |= CKSUM_ERROR;
         goto rst_msg;
      }
      decode_taip_msg(); // message checksum matches, process the message
      packet_end = 1;
      tsip_wptr = 0;     // prepare for next message
      tsip_sync = 0;
      venus_nmea = 0;
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_sync = 0;
      nmea_vfy_cksum = nmea_msg_cksum = 0; // init received message checksum
      venus_nmea = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
pushq $0xa
popq %rdi
callq 0xb771
pushq $0xa
popq %rdi
testl %eax, %eax
je 0x94ee1
callq 0x1d93f
callq 0x51891
movl %eax, %ebx
leaq 0x26346c(%rip), %rax    # 0x2f82e0
cmpb $0x0, 0x17a12(%rax)
je 0x94e84
movb $0x0, 0x17a12(%rax)
leaq 0x28d3cb(%rip), %r14    # 0x322256
movzwl (%r14), %eax
cmpq $0x3, %rax
ja 0x94fb1
leaq 0x74bb8(%rip), %rcx     # 0x109a58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x3e, %ebx
jne 0x94eb9
movw $0x1, (%r14)
callq 0x51a2f
leaq 0x28d392(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x28d389(%rip), %rax    # 0x322254
andw $0x0, (%rax)
movb $0x0, 0x2c1bdf(%rip)    # 0x356ab5
movb %bl, 0x2c1bd8(%rip)     # 0x356ab4
jmp 0x94fd6
popq %rbx
popq %r14
popq %rbp
jmp 0x1d61b
cmpb $0xa, %bl
je 0x94f3e
movzbl %bl, %eax
cmpl $0xd, %eax
je 0x94f3e
cmpl $0x3c, %eax
je 0x94f3e
cmpl $0x2a, %eax
jne 0x94f79
xorb $0x2a, 0x2c1bac(%rip)   # 0x356ab4
movw $0x2, (%r14)
jmp 0x94fd6
cmpb $0x3c, %bl
ja 0x94f5f
movzbl %bl, %eax
movabsq $0x1000000000002400, %rcx # imm = 0x1000000000002400
btq %rax, %rcx
jae 0x94f5f
movb 0x2c1b83(%rip), %al     # 0x356ab4
movl $0x4000, %edx           # imm = 0x4000
cmpb 0x2c1b79(%rip), %al     # 0x356ab5
jne 0x94fa8
callq 0x94d5c
leaq 0x28d308(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%r14)
movl $0x1, 0x2c0d37(%rip)    # 0x355c94
jmp 0x94fcf
leal -0x30(%rbx), %eax
cmpl $0x9, %eax
ja 0x94fdb
movzbl 0x2c1b47(%rip), %eax    # 0x356ab5
shll $0x4, %eax
addl $0xd0, %ebx
jmp 0x94ff3
leaq 0x28d2d2(%rip), %rcx    # 0x322252
movzwl (%rcx), %eax
movl $0x8000, %edx           # imm = 0x8000
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0x94fa8
xorb %bl, 0x2c1b1e(%rip)     # 0x356ab4
leal 0x1(%rax), %edx
movw %dx, (%rcx)
leaq 0x28c2ad(%rip), %rcx    # 0x321250
movb %bl, (%rcx,%rax)
jmp 0x94fd6
leaq 0x193fc1(%rip), %rax    # 0x228f70
orl %edx, (%rax)
leaq 0x28d29a(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%r14)
xorl %eax, %eax
movb %al, 0x2c1aec(%rip)     # 0x356ab5
movb %al, 0x2c1ae5(%rip)     # 0x356ab4
andl $0x0, 0x2c1b0e(%rip)    # 0x356ae4
popq %rbx
popq %r14
popq %rbp
retq
leal -0x41(%rbx), %eax
cmpl $0x5, %eax
ja 0x94fb1
movzbl 0x2c1acb(%rip), %eax    # 0x356ab5
shll $0x4, %eax
addl $0xc9, %ebx
orl %eax, %ebx
movb %bl, 0x2c1aba(%rip)     # 0x356ab5
jmp 0x94fd6