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

   // This routine buffers up an incoming TSERVE 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 == 0x01) {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      return;
   }
   else if(tsip_sync == 1) { // '>' has been seen, now build the message
      if((c == 0x0D) || (c == 0x0A)) goto tserve_end;  // message has no checksum

      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else if(tsip_sync) {  // end of message
      tserve_end:
      decode_tserve_msg(); 
      packet_end = 1;
      tsip_wptr = 0;     // prepare for next message
      tsip_rptr = 0;
      tsip_sync = 0;
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_rptr = 0;
      tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0xa, %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xdf0c6
movl $0xa, %edi
callq 0x2b610
jmp 0xdf229
movl $0xa, %edi
callq 0x2bd30
callq 0x79fc0
movb %al, -0x1(%rbp)
leaq 0x28e3e1(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xdf0f6
leaq 0x28e3d1(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
leaq 0x2b8339(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xdf13c
movzbl -0x1(%rbp), %eax
cmpl $0x1, %eax
jne 0xdf11f
leaq 0x2b8321(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
leaq 0x2b830c(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b8302(%rip), %rax    # 0x397434
movw $0x0, (%rax)
jmp 0xdf229
leaq 0x2b82f3(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xdf1bb
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
je 0xdf15d
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xdf15f
jmp 0xdf1ca
leaq 0x2b82cc(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jge 0xdf19f
movb -0x1(%rbp), %dl
leaq 0x2b82b8(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2b82a7(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2b7296(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
jmp 0xdf1b9
leaq 0x1befaa(%rip), %rax    # 0x29e150
movl (%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
leaq 0x1bef9b(%rip), %rax    # 0x29e150
movl %ecx, (%rax)
jmp 0xdf201
jmp 0xdf227
leaq 0x2b8274(%rip), %rax    # 0x397436
cmpw $0x0, (%rax)
je 0xdf1ff
jmp 0xdf1ca
callq 0xdede0
movl $0x1, 0x2ebc9b(%rip)    # 0x3cae74
leaq 0x2b8252(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b8248(%rip), %rax    # 0x397434
movw $0x0, (%rax)
leaq 0x2b823e(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xdf225
jmp 0xdf201
leaq 0x2b822a(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2b8220(%rip), %rax    # 0x397434
movw $0x0, (%rax)
leaq 0x2b8216(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xdf227
jmp 0xdf229
addq $0x10, %rsp
popq %rbp
retq
nop