// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_nvs_timescale()
void parse_nvs_timescale()
{
double scale_shift;
u08 flags;
int gps_flags;
int glo_flags;

   // !!!! qqqqq do we need anything from here?
   // 0x74 packet
   log_packet_id("nvs_timescale");

   scale_shift = tsip_fp80();
   tsip_fp80();
   tsip_fp80();
   tsip_fp80();
   tsip_fp80();
   flags = tsip_byte();

   gps_flags = glo_flags = TFLAGS_NULL;
   if(!have_gnss_mask) {
      gps_flags |= TFLAGS_INVALID;
      glo_flags |= TFLAGS_INVALID;
   }

   if(time_flags & TFLAGS_UTC) {  // UTC time
      if(gnss_mask & GPS) {
         if((flags & 0x04) == 0) gps_flags |= TFLAGS_INVALID;
      }
      if(gnss_mask & GLONASS) {
         if((flags & 0x08) == 0) glo_flags |= TFLAGS_INVALID;
      }
   }
   else { // GPS time
      if(gnss_mask & GPS) {
         if((flags & 0x01) == 0) gps_flags |= TFLAGS_INVALID;
      }
      if(gnss_mask & GLONASS) {
         if((flags & 0x02) == 0) glo_flags |= TFLAGS_INVALID;
      }
   }
   if((gnss_mask & GPS) && (gnss_mask & GLONASS)) {  // see if we have valid time from at least one system
      if(gps_flags == 0) glo_flags = TFLAGS_NULL;  // we have GPS time
      if(glo_flags == 0) gps_flags = TFLAGS_NULL;  // we have GLONASS time
   }


   time_flags &= (~TFLAGS_INVALID);
   time_flags |= (gps_flags | glo_flags);
//sprintf(plot_title, "shift:%.10f  flags:%02X  tflags:%04X  gnss:%04X  have_utc:%d", 
//scale_shift, flags, time_flags, gnss_mask, have_utc_ofs);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0xa4892(%rip), %rdi     # 0x1892e1
callq 0x7add0
callq 0x7aa80
movsd %xmm0, -0x8(%rbp)
callq 0x7aa80
callq 0x7aa80
callq 0x7aa80
callq 0x7aa80
callq 0x7a510
movb %al, -0x9(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
leaq 0xeb3c9(%rip), %rax     # 0x1cfe58
cmpl $0x0, (%rax)
jne 0xe4aa6
movl -0x10(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x14(%rbp)
leaq 0x287bd7(%rip), %rax    # 0x36c684
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe4b09
leaq 0xeb396(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe4adf
movzbl -0x9(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0xe4add
movl -0x10(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x10(%rbp)
jmp 0xe4adf
leaq 0xeb36e(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe4b07
movzbl -0x9(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xe4b05
movl -0x14(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x14(%rbp)
jmp 0xe4b07
jmp 0xe4b5b
leaq 0xeb344(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe4b31
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xe4b2f
movl -0x10(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x10(%rbp)
jmp 0xe4b31
leaq 0xeb31c(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe4b59
movzbl -0x9(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xe4b57
movl -0x14(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x14(%rbp)
jmp 0xe4b59
jmp 0xe4b5b
leaq 0xeb2f2(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xe4b99
leaq 0xeb2e1(%rip), %rax     # 0x1cfe54
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe4b99
cmpl $0x0, -0x10(%rbp)
jne 0xe4b8a
movl $0x0, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xe4b97
movl $0x0, -0x10(%rbp)
jmp 0xe4b99
leaq 0x287ae4(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x287ad8(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
movl -0x10(%rbp), %ecx
orl -0x14(%rbp), %ecx
leaq 0x287ac9(%rip), %rax    # 0x36c684
orl (%rax), %ecx
leaq 0x287ac0(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)