// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_sat_solutions()
void get_sat_solutions()
{   //not available on ThunderBolt-E
u08 format;
u32 time_of_week;
float clock_bias;
float clock_bias_rate;
float sat_bias;
int prn;
int i;

   log_packet_id("Packet 0x8F.A7 (Satellite solutions)");

   if(tsip_type == STARLOC_TYPE) {  // !!!! who knows what garbage this device craps out?
      // some of these are 9 bytes long, some are 13... we just ignore this message
      return;
   }

   format = tsip_byte();
   time_of_week = tsip_dword();

   if(format == 0) {     // floating point
      clock_bias = tsip_single();
      clock_bias_rate = tsip_single();
   }
   else if(format == 1) {   // integer values
      clock_bias = (float) (int) tsip_word();
      clock_bias *= 100.0e-12F;
      clock_bias_rate = (float) (int) tsip_word();
      clock_bias_rate *= 1.0e-12F;
   }
   else {  // invalid format
      check_tsip_end(1);
      if(tsip_error) return;
      return;
   }

   for(i=1; i<=MAX_PRN; i++) {  // reset current bias flags
      sat[i].last_bias_msg = 0;
   }

   for(i=0; i<8; i++) {  // get bias info from all satellites
      prn = tsip_byte();
      if(prn > MAX_PRN) prn = 0;  // put any bogus data in unused entry in array
      if(format == 0) {
         sat_bias = tsip_single();
      }
      else {
         sat_bias = (float) (int) tsip_word();
         sat_bias *= 100.0e-12F;
      }

      sat[prn].time_of_fix = (float) time_of_week;
      sat[prn].sat_bias = sat_bias;
      sat[prn].last_bias_msg = 1;

      if(have_bias == 0) need_redraw = 2006;
      have_bias = 1;
   }
   check_tsip_end(1);
   if(tsip_error) return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0xe3fd2(%rip), %rdi     # 0x185331
callq 0x7add0
leaq 0x1d8e49(%rip), %rax    # 0x27a1b4
cmpl $0x53, (%rax)
jne 0xa1375
jmp 0xa1561
callq 0x7a510
movb %al, -0x1(%rbp)
callq 0x7a680
movl %eax, -0x8(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x0, %eax
jne 0xa13a4
callq 0x7a860
movss %xmm0, -0xc(%rbp)
callq 0x7a860
movss %xmm0, -0x10(%rbp)
jmp 0xa1417
movzbl -0x1(%rbp), %eax
cmpl $0x1, %eax
jne 0xa13f5
callq 0x7a560
movzwl %ax, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0xc(%rbp)
movss 0xe1f76(%rip), %xmm0    # 0x18333c
mulss -0xc(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
callq 0x7a560
movzwl %ax, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x10(%rbp)
movss 0xe1f4f(%rip), %xmm0    # 0x183338
mulss -0x10(%rbp), %xmm0
movss %xmm0, -0x10(%rbp)
jmp 0xa1415
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fcd4a(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1410
jmp 0xa1561
jmp 0xa1561
jmp 0xa1417
movl $0x1, -0x1c(%rbp)
cmpl $0x3e7, -0x1c(%rbp)     # imm = 0x3E7
jg 0xa144e
movslq -0x1c(%rbp), %rcx
leaq 0x1fcd5e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movb $0x0, 0x240(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa141e
movl $0x0, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jge 0xa1549
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0x3e7, -0x18(%rbp)     # imm = 0x3E7
jle 0xa147a
movl $0x0, -0x18(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x0, %eax
jne 0xa148f
callq 0x7a860
movss %xmm0, -0x14(%rbp)
jmp 0xa14b2
callq 0x7a560
movzwl %ax, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x14(%rbp)
movss 0xe1e94(%rip), %xmm0    # 0x18333c
mulss -0x14(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
movl -0x8(%rbp), %eax
cvtsi2ss %rax, %xmm0
movslq -0x18(%rbp), %rcx
leaq 0x1fcccb(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0x23c(%rax)
movss -0x14(%rbp), %xmm0
movslq -0x18(%rbp), %rcx
leaq 0x1fcca9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0x238(%rax)
movslq -0x18(%rbp), %rcx
leaq 0x1fcc8c(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movb $0x1, 0x240(%rax)
leaq 0x2cb080(%rip), %rax    # 0x36c59c
cmpl $0x0, (%rax)
jne 0xa152e
leaq 0x1d64fc(%rip), %rax    # 0x277a24
movl $0x7d6, (%rax)          # imm = 0x7D6
leaq 0x2cb067(%rip), %rax    # 0x36c59c
movl $0x1, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa1455
movl $0x1, %edi
callq 0x7aee0
leaq 0x1fcbf6(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0xa1561
jmp 0xa1561
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)