// File: 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
subq $0x10, %rsp
movl $0xa, %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xc9436
movl $0xa, %edi
callq 0x2b610
jmp 0xc95e5
movl $0xa, %edi
callq 0x2bd30
callq 0x79fc0
movb %al, -0x1(%rbp)
leaq 0x1b0d79(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0xc947a
movzbl -0x1(%rbp), %eax
cmpl $0x3, %eax
jne 0xc9478
leaq 0x1b0d74(%rip), %rax    # 0x27a1d8
cmpl $0x0, (%rax)
je 0xc9473
movl $0x1, 0x301b39(%rip)    # 0x3cafac
jmp 0xc95e5
jmp 0xc947a
leaq 0x2a403f(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xc9498
leaq 0x2a402f(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
leaq 0x2cdf97(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xc94e9
leaq 0x2cdf84(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2cdf7a(%rip), %rax    # 0x397434
movw $0x0, (%rax)
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
je 0xc94d1
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
jne 0xc94d6
jmp 0xc95e5
leaq 0x2cdf59(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
jmp 0xc94fe
leaq 0x2cdf46(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xc958d
jmp 0xc94fe
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
jne 0xc950c
jmp 0xc95e5
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xc951a
jmp 0xc959e
leaq 0x2cdf11(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jge 0xc9571
movb -0x1(%rbp), %dl
leaq 0x2cdefd(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2cdeec(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2ccedb(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
leaq 0x2cded3(%rip), %rax    # 0x397432
movzwl (%rax), %eax
movl %eax, %ecx
leaq 0x2ccec5(%rip), %rax    # 0x396430
movb $0x0, (%rax,%rcx)
jmp 0xc958b
leaq 0x1d4bd8(%rip), %rax    # 0x29e150
movl (%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
leaq 0x1d4bc9(%rip), %rax    # 0x29e150
movl %ecx, (%rax)
jmp 0xc95c9
jmp 0xc95e3
leaq 0x2cdea2(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x3, %eax
jne 0xc95c7
jmp 0xc959e
callq 0xc8c50
movl $0x1, 0x3018c7(%rip)    # 0x3cae74
leaq 0x2cde7e(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2cde76(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xc95e1
jmp 0xc95c9
leaq 0x2cde62(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2cde5a(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xc95e3
jmp 0xc95e5
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)