// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xac875(%rip), %rdi     # 0x121fc1
callq 0x58e77
leaq 0x1a587c(%rip), %rax    # 0x21afd4
cmpl $0x53, (%rax)
jne 0x7576c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x587d1
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0x75784
leaq 0x1c97ef(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x589b0
movl %eax, %r14d
testb %bl, %bl
je 0x757a5
cmpb $0x1, %bl
jne 0x75878
callq 0x588f0
callq 0x588f0
jmp 0x757af
callq 0x58aae
callq 0x58aae
movl $0x588, %eax            # imm = 0x588
leaq 0x1c97f5(%rip), %r15    # 0x23efb0
movb $0x0, (%r15,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd380, %rax          # imm = 0xCD380
jne 0x757bb
movl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x8, %r12d
leaq 0x297bd1(%rip), %r13    # 0x30d3bc
callq 0x587d1
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x75804
leaq 0x1c976f(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
testb %bl, %bl
je 0x75821
callq 0x588f0
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0xa9185(%rip), %xmm0    # 0x11e9a4
jmp 0x75826
callq 0x58aae
movzbl %r14b, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
movss -0x2c(%rbp), %xmm1
movss %xmm1, 0x23c(%r15,%rax)
movss %xmm0, 0x238(%r15,%rax)
movb $0x1, 0x240(%r15,%rax)
cmpl $0x0, (%r13)
jne 0x75867
leaq 0x1a2fe3(%rip), %rax    # 0x218844
movl $0x7d6, (%rax)          # imm = 0x7D6
movl $0x1, (%r13)
decl %r12d
jne 0x757eb
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x58f50