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

   // This routine buffers up an incoming STAR4 message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_star_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(star_type == OSA_TYPE) {
      if(c == 0x03) {  // ETX
         if(star_line) saw_star_etx = 1;
         return;
      }
   }
   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
      tsip_wptr = 0;
      tsip_rptr = 0;
      if((c == 0x0A) || (c == 0x0D)) return;

      tsip_sync = 1;
      get_sync_time();
      goto star_msg;
   }
   else if(tsip_sync == 1) { // '$' has been seen, now build the message
      star_msg:
//    if((c == 0x0D) || (c == 0x0A)) goto star_end;  // message has no checksum
      if(c == 0x0D) return; // message has no checksum
      if(c == 0x0A) goto star_end;  // message has no checksum

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0xa, %edi
callq 0xb9c3
movl $0xa, %edi
testl %eax, %eax
je 0x93339
callq 0x1ea2c
callq 0x584d5
movl %eax, %ebx
cmpl $0x3, %eax
jne 0x93342
leaq 0x187cd3(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x93342
leaq 0x187cd7(%rip), %rax    # 0x21aff8
cmpl $0x0, (%rax)
je 0x933f0
movl $0x1, 0x2d8a98(%rip)    # 0x36bdcc
jmp 0x933f0
popq %rbx
popq %r14
popq %rbp
jmp 0x1e6a0
leaq 0x27af97(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0x93359
movb $0x0, 0x17a12(%rax)
leaq 0x2a4ef6(%rip), %r14    # 0x338256
movzwl (%r14), %eax
cmpl $0x3, %eax
je 0x933d1
cmpl $0x1, %eax
je 0x9339d
testl %eax, %eax
jne 0x933e0
leaq 0x2a4ed9(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x2a4ecf(%rip), %rax    # 0x338254
movw %cx, (%rax)
cmpl $0xa, %ebx
je 0x933f0
cmpl $0xd, %ebx
je 0x933f0
movw $0x1, (%r14)
callq 0x58682
cmpl $0xa, %ebx
je 0x933d1
cmpl $0xd, %ebx
je 0x933f0
leaq 0x2a4ea4(%rip), %rcx    # 0x338252
movzwl (%rcx), %eax
cmpq $0xffe, %rax            # imm = 0xFFE
ja 0x933f5
leaq 0x1(%rax), %rdx
movw %dx, (%rcx)
leaq 0x2a3e89(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0x933f0
callq 0x92b64
movl $0x1, 0x2d88b4(%rip)    # 0x36bc94
leaq 0x2a4e6b(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1abb74(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
jmp 0x933e0