// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_ss_message()
void get_ss_message()
{
u08 c;
static u08 id;
static u08 cid;
static int msg_len;

   // This routine buffers up an incoming Novatel message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_ss_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 SOH
      if(c == 0x01) {      // SOH seen
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      ss_vfy_cksum = 0;  // the calculated message checksum
      ss_msg_cksum = 0;  // the checksum in the message
      id = 0;
      cid = 0;
      msg_len = 0;
      return;
   }
   else if(tsip_sync == 1) { // SOH has been seen, get message id
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      id = c;
      ++tsip_sync;
   }
   else if(tsip_sync == 2) { // message id inverted
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      cid = c ^ 0xFF;
//BEEP(5555);  // piss3
//sprintf(out, "id:%02X(%d)  c:%02X  cinv:%02x    ", id,id, c, cid);
//DEBUGSTR(out);
//refresh_page();
      if(id != cid) goto rst_msg;
      ++tsip_sync;
   }
   else if(tsip_sync == 3) { // message len
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
      msg_len = c;
      ++tsip_sync;
      if(msg_len == 0) ++tsip_sync;
   }
   else if(tsip_sync == 4) { // message body
      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         ss_vfy_cksum += c;
         tsip_buf[tsip_wptr++] = c;
      }
      --msg_len;
      if(msg_len <= 0) ++tsip_sync;
   }
   else if(tsip_sync == 5) {  // low byte of checksum
      ss_msg_cksum = c;
      ++tsip_sync;
   }
   else if(tsip_sync == 6) {  // high byte of checksum
      ss_msg_cksum += ((int) c) * 256;
      if(ss_msg_cksum == ss_vfy_cksum) decode_ss_msg();
      packet_end = 1;
      tsip_sync = 0;
      tsip_wptr = 0;
      tsip_sync = 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
movl $0xa, %edi
callq 0xb9ad
movl $0xa, %edi
testl %eax, %eax
je 0x884c9
callq 0x1ea0b
callq 0x584bd
leaq 0x285e94(%rip), %rcx    # 0x30e2e0
cmpb $0x0, 0x17a12(%rcx)
je 0x8845c
movb $0x0, 0x17a12(%rcx)
leaq 0x2afdf3(%rip), %rbx    # 0x338256
movzwl (%rbx), %ecx
cmpq $0x6, %rcx
ja 0x885ec
leaq 0x96dd1(%rip), %rdx     # 0x11f248
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, %eax
jne 0x8848f
movw $0x1, (%rbx)
callq 0x58672
leaq 0x2afdbc(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x2afdb2(%rip), %rax    # 0x338254
movw %cx, (%rax)
movw %cx, 0x2e460c(%rip)     # 0x36cab8
movw %cx, 0x2e4607(%rip)     # 0x36caba
movb $0x0, 0x2e99c6(%rip)    # 0x371e80
movl $0x0, 0x2e99c0(%rip)    # 0x371e84
jmp 0x88659
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1e66a
leaq 0x2afd77(%rip), %rdx    # 0x338252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x884fe
addw %ax, 0x2e45ca(%rip)     # 0x36cab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2aed55(%rip), %rdx    # 0x337250
movb %al, (%rdx,%rcx)
movl 0x2e9980(%rip), %eax    # 0x371e84
leal -0x1(%rax), %ecx
movl %ecx, 0x2e9977(%rip)    # 0x371e84
cmpl $0x1, %eax
jg 0x88659
movw $0x5, (%rbx)
jmp 0x88659
leaq 0x2afd2b(%rip), %rdx    # 0x338252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x885e1
addw %ax, 0x2e457a(%rip)     # 0x36cab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2aed05(%rip), %rdx    # 0x337250
movb %al, (%rdx,%rcx)
movzbl 0x2e992b(%rip), %ecx    # 0x371e80
xorl %ecx, %eax
cmpl $0xff, %eax
jne 0x885ec
movw $0x3, (%rbx)
jmp 0x88659
leaq 0x2afcdf(%rip), %rdx    # 0x338252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x885e1
addw %ax, 0x2e4532(%rip)     # 0x36cab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2aecbd(%rip), %rdx    # 0x337250
movb %al, (%rdx,%rcx)
movl %eax, 0x2e98e8(%rip)    # 0x371e84
xorl %ecx, %ecx
cmpl $0x1, %eax
adcw $0x4, %cx
jmp 0x88656
leaq 0x2afca1(%rip), %rdx    # 0x338252
movzwl (%rdx), %ecx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x885e1
addw %ax, 0x2e44f4(%rip)     # 0x36cab8
leal 0x1(%rcx), %esi
movw %si, (%rdx)
leaq 0x2aec7f(%rip), %rdx    # 0x337250
movb %al, (%rdx,%rcx)
movb %al, 0x2e98a6(%rip)     # 0x371e80
movw $0x2, (%rbx)
jmp 0x88659
leaq 0x1b6988(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
leaq 0x2afc5f(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%rbx)
movb %cl, 0x2e44b4(%rip)     # 0x36cab5
movb %cl, 0x2e44ad(%rip)     # 0x36cab4
movl $0x0, 0x2e44d3(%rip)    # 0x36cae4
jmp 0x88659
movw %ax, 0x2e44a0(%rip)     # 0x36caba
movw $0x6, (%rbx)
jmp 0x88659
shll $0x8, %eax
addw 0x2e448f(%rip), %ax     # 0x36caba
movw %ax, 0x2e4488(%rip)     # 0x36caba
cmpw 0x2e447f(%rip), %ax     # 0x36cab8
jne 0x88640
callq 0x88116
movl $0x1, 0x2e364a(%rip)    # 0x36bc94
leaq 0x2afc01(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq