// File: 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
subq $0x10, %rsp
movl $0xa, %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xdeb16
movl $0xa, %edi
callq 0x2b610
jmp 0xdedd1
movl $0xa, %edi
callq 0x2bd30
callq 0x79fc0
movb %al, -0x1(%rbp)
leaq 0x28e991(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xdeb46
leaq 0x28e981(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
leaq 0x2b88e9(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xdebad
movzbl -0x1(%rbp), %eax
cmpl $0x3e, %eax
jne 0xdeb6f
leaq 0x2b88d1(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
leaq 0x2b88bc(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b88b2(%rip), %rax    # 0x397434
movw $0x0, (%rax)
movb $0x0, 0x2ed107(%rip)    # 0x3cbc95
movb $0x0, 0x2ed0ff(%rip)    # 0x3cbc94
movzbl -0x1(%rbp), %ecx
movzbl 0x2ed0f4(%rip), %eax    # 0x3cbc94
xorl %ecx, %eax
movb %al, 0x2ed0ec(%rip)     # 0x3cbc94
jmp 0xdedd1
leaq 0x2b8882(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xdec81
movzbl -0x1(%rbp), %eax
cmpl $0x3c, %eax
je 0xdebdb
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
je 0xdebdb
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xdebe0
jmp 0xded2b
movzbl -0x1(%rbp), %eax
cmpl $0x2a, %eax
jne 0xdec0a
movzbl -0x1(%rbp), %ecx
movzbl 0x2ed0a0(%rip), %eax    # 0x3cbc94
xorl %ecx, %eax
movb %al, 0x2ed098(%rip)     # 0x3cbc94
leaq 0x2b8833(%rip), %rax    # 0x397436
movw $0x2, (%rax)
jmp 0xdec7c
leaq 0x2b8821(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jge 0xdec5d
movzbl -0x1(%rbp), %ecx
movzbl 0x2ed06e(%rip), %eax    # 0x3cbc94
xorl %ecx, %eax
movb %al, 0x2ed066(%rip)     # 0x3cbc94
movb -0x1(%rbp), %dl
leaq 0x2b87fa(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2b87e9(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2b77d8(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
jmp 0xdec7a
leaq 0x1bf4ec(%rip), %rax    # 0x29e150
movl (%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
leaq 0x1bf4dd(%rip), %rax    # 0x29e150
movl %ecx, (%rax)
jmp 0xded9b
jmp 0xdec7c
jmp 0xdedcf
leaq 0x2b87ae(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x2, %eax
jne 0xded1a
movzbl -0x1(%rbp), %eax
cmpl $0x3c, %eax
je 0xdecaf
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
je 0xdecaf
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xdecb1
jmp 0xded2b
movzbl -0x1(%rbp), %eax
cmpl $0x30, %eax
jl 0xdecde
movzbl -0x1(%rbp), %eax
cmpl $0x39, %eax
jg 0xdecde
movzbl 0x2ecfcb(%rip), %eax    # 0x3cbc95
shll $0x4, %eax
movzbl -0x1(%rbp), %ecx
subl $0x30, %ecx
orl %ecx, %eax
movb %al, 0x2ecfb9(%rip)     # 0x3cbc95
jmp 0xded15
movzbl -0x1(%rbp), %eax
cmpl $0x41, %eax
jl 0xded0e
movzbl -0x1(%rbp), %eax
cmpl $0x46, %eax
jg 0xded0e
movzbl 0x2ecf9e(%rip), %eax    # 0x3cbc95
shll $0x4, %eax
movzbl -0x1(%rbp), %ecx
subl $0x41, %ecx
addl $0xa, %ecx
orl %ecx, %eax
movb %al, 0x2ecf89(%rip)     # 0x3cbc95
jmp 0xded13
jmp 0xded9b
jmp 0xded15
jmp 0xdedcd
leaq 0x2b8715(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x3, %eax
jne 0xded99
jmp 0xded2b
leaq 0x2b8704(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x2, %eax
jne 0xded66
movzbl 0x2ecf53(%rip), %eax    # 0x3cbc94
movzbl 0x2ecf4d(%rip), %ecx    # 0x3cbc95
cmpl %ecx, %eax
je 0xded66
leaq 0x1bf3fd(%rip), %rax    # 0x29e150
movl (%rax), %ecx
orl $0x4000, %ecx           # imm = 0x4000
leaq 0x1bf3ee(%rip), %rax    # 0x29e150
movl %ecx, (%rax)
jmp 0xded9b
callq 0xde7e0
movl $0x1, 0x2ec0ff(%rip)    # 0x3cae74
leaq 0x2b86b6(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b86ae(%rip), %rax    # 0x397436
movw $0x0, (%rax)
movl $0x0, 0x2ecf2d(%rip)    # 0x3cbcc4
jmp 0xdedcb
jmp 0xded9b
leaq 0x2b8690(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b8688(%rip), %rax    # 0x397436
movw $0x0, (%rax)
movb $0x0, 0x2ecedb(%rip)    # 0x3cbc95
movb $0x0, 0x2eced3(%rip)    # 0x3cbc94
movl $0x0, 0x2ecef9(%rip)    # 0x3cbcc4
jmp 0xdedcd
jmp 0xdedcf
jmp 0xdedd1
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)