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

   // This routine buffers up an incoming NMEA 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_vfy_cksum = 0;  // the calculated message checksum
      nmea_msg_cksum = 0;  // the checksum in the message
      return;
   }
   else if(tsip_sync == 1) { // '$' has been seen, now build the message
//if((c == 0x0D) || (c == 0x0A)) goto nmea_end;
      if(c == 0x0D) return;
      if(c == 0x0A) goto nmea_end;

      if(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 == 0x0D) || (c == 0x0A)) goto nmea_end;
      if(c == 0x0D) return;
      if(c == 0x0A) goto nmea_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
      nmea_end:
      if((tsip_sync == 2) && (nmea_vfy_cksum != nmea_msg_cksum)) { // checksum error
         tsip_error |= CKSUM_ERROR;
         goto rst_msg;
      }

      if(rcvr_type == ZYFER_RCVR)     decode_zyfer_message(); // message checksum matches, process the message
      else if(rcvr_type == TRUE_RCVR) decode_true_message();
      else                            decode_nmea_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 %rbx
pushq %rax
pushq $0xa
popq %rdi
callq 0xb771
pushq $0xa
popq %rdi
testl %eax, %eax
je 0x7a780
callq 0x1d93f
callq 0x51891
leaq 0x27dbcc(%rip), %rcx    # 0x2f82e0
cmpb $0x0, 0x17a12(%rcx)
je 0x7a724
movb $0x0, 0x17a12(%rcx)
leaq 0x2a7b2b(%rip), %rbx    # 0x322256
movzwl (%rbx), %ecx
cmpq $0x3, %rcx
ja 0x7a895
leaq 0x8e985(%rip), %rdx     # 0x1090c4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x24, %eax
jne 0x7a757
movw $0x1, (%rbx)
callq 0x51a2f
leaq 0x2a7af4(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x2a7aeb(%rip), %rax    # 0x322254
andw $0x0, (%rax)
xorl %eax, %eax
movb %al, 0x2dc33f(%rip)     # 0x356ab4
movb %al, 0x2dc33a(%rip)     # 0x356ab5
jmp 0x7a8b9
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1d61b
cmpb $0xa, %al
je 0x7a7f1
movzbl %al, %ecx
cmpl $0xd, %ecx
je 0x7a8b9
cmpl $0x2a, %ecx
jne 0x7a839
movw $0x2, (%rbx)
jmp 0x7a8b9
cmpb $0xa, %al
je 0x7a7de
movzbl %al, %ecx
cmpl $0xd, %ecx
je 0x7a8b9
leal -0x30(%rax), %ecx
cmpl $0x9, %ecx
ja 0x7a874
movzbl 0x2dc2e4(%rip), %ecx    # 0x356ab5
shll $0x4, %ecx
addl $0xd0, %eax
jmp 0x7a88b
movb 0x2dc2d0(%rip), %al     # 0x356ab4
movl $0x4000, %esi           # imm = 0x4000
cmpb 0x2dc2c6(%rip), %al     # 0x356ab5
jne 0x7a869
leaq 0x1880d8(%rip), %rax    # 0x2028d0
movq (%rax), %rax
cmpq $0x200000, %rax         # imm = 0x200000
je 0x7a812
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x7a819
callq 0x7a8c0
jmp 0x7a81e
callq 0x7b03c
jmp 0x7a81e
callq 0x792a9
leaq 0x2a7a2d(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%rbx)
movl $0x1, 0x2db45d(%rip)    # 0x355c94
jmp 0x7a8b2
leaq 0x2a7a12(%rip), %rdx    # 0x322252
movzwl (%rdx), %ecx
movl $0x8000, %esi           # imm = 0x8000
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x7a869
xorb %al, 0x2dc25d(%rip)     # 0x356ab4
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2a69ec(%rip), %rdx    # 0x321250
movb %al, (%rdx,%rcx)
jmp 0x7a8b9
leaq 0x1ae700(%rip), %rax    # 0x228f70
orl %esi, (%rax)
jmp 0x7a895
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x7a895
movzbl 0x2dc232(%rip), %ecx    # 0x356ab5
shll $0x4, %ecx
addl $0xc9, %eax
orl %ecx, %eax
movb %al, 0x2dc222(%rip)     # 0x356ab5
jmp 0x7a8b9
leaq 0x2a79b6(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%rbx)
xorl %eax, %eax
movb %al, 0x2dc209(%rip)     # 0x356ab5
movb %al, 0x2dc202(%rip)     # 0x356ab4
andl $0x0, 0x2dc22b(%rip)    # 0x356ae4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq