// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_nvs_rcvr_config()
void parse_nvs_rcvr_config()
{
u08 sub_code;
u16 flags;
u08 keep;
u08 scale;
float rate;

   // 0xE7 packet

   sub_code = tsip_byte();
   if(sub_code == 0x02) {
      log_packet_id("nav rate");
      rate = (float) tsip_byte();
      if(!pause_data) {
         nav_rate = rate;
         have_nav_rate = 3;
      }
   }
   else if(sub_code == 0x04) {  // solution filtration factor
      log_packet_id("solution filtration");
      nvs_filter = tsip_single();
   }
   else if(sub_code == 0x05) {  // pps info
      log_packet_id("pps info");
      flags = tsip_byte();
      keep = tsip_byte();
      nvs_pps_width = tsip_dword();

      if(flags & 0x08) pps_polarity = 0; // positive
      else             pps_polarity = 1; // inverted
      have_pps_polarity = 1;
      have_pps_freq = 0x01;

      if(nvs_pps_width) {
         last_nvs_pps_width = nvs_pps_width;
         pps_enabled = 1;
      }
      else pps_enabled = 0;
      have_pps_enable = 20;

      scale = flags & 0xF0;
      if((scale == 0x10) || (scale == 0x20)) {  // GPS/GLONASS time
         time_flags &= (~TFLAGS_UTC);
         timing_mode = TMODE_GPS;
         have_timing_mode = 1;
      }
      else if((scale == 0x30) || (scale == 0x40)) {  // UTC
         time_flags |= (TFLAGS_UTC);
         timing_mode = TMODE_UTC;
         have_timing_mode = 1;
      }
      have_rcvr_tmode = 1;
//sprintf(plot_title, "pps flags:%02X  keep:%02X  width:%d", flags,keep,nvs_pps_width);  // qqqqqqqqqqqqqq
   }
   else if(sub_code == 0x06) {  // cable delay
      log_packet_id("cable delay");
      cable_delay = tsip_double() / 1.0E6;
//    if(have_cable_delay == 0) need_redraw = 2237;
      have_cable_delay = 1;
   }
   else if(sub_code == 0x07) {  // TRAIM mode, 2D OK, single sat OK
      log_packet_id("traim mode");
      flags = tsip_word();
      nvs_traim = flags;
      traim_mode = flags & 0x03;
      have_traim = 1;
   }
   else {
      log_packet_id("unsupported config subcode");
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
callq 0x51c47
movzbl %al, %eax
addl $-0x2, %eax
cmpl $0x5, %eax
ja 0x993ce
leaq 0x7074c(%rip), %rcx     # 0x109acc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x76bb4(%rip), %rdi     # 0x10ff44
callq 0x520bf
callq 0x51c47
leaq 0x16be93(%rip), %rcx    # 0x205234
cmpb $0x0, (%rcx)
jne 0x99543
movzbl %al, %eax
cvtsi2sd %eax, %xmm0
leaq 0x16bfa0(%rip), %rax    # 0x205358
movsd %xmm0, (%rax)
leaq 0x25df09(%rip), %rax    # 0x2f72cc
movl $0x3, (%rax)
jmp 0x99543
leaq 0x76ba0(%rip), %rdi     # 0x10ff75
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x520bf
leaq 0x76b7a(%rip), %rdi     # 0x10ff61
callq 0x520bf
callq 0x51c47
movl %eax, %ebx
callq 0x51c47
callq 0x51cf3
leaq 0x25e964(%rip), %rcx    # 0x2f7d68
movl %eax, (%rcx)
xorl %ecx, %ecx
testb $0x8, %bl
sete %cl
leaq 0x25e903(%rip), %rdx    # 0x2f7d18
movl %ecx, (%rdx)
leaq 0x25dec2(%rip), %rcx    # 0x2f72e0
pushq $0x1
popq %rdx
movl %edx, (%rcx)
leaq 0x25e936(%rip), %rcx    # 0x2f7d60
movl %edx, (%rcx)
testl %eax, %eax
je 0x994cb
leaq 0x25e931(%rip), %rcx    # 0x2f7d6c
movl %eax, (%rcx)
movb $0x1, %al
jmp 0x994cd
leaq 0x76b02(%rip), %rdi     # 0x10ff4d
callq 0x520bf
callq 0x51dc3
cvtss2sd %xmm0, %xmm0
leaq 0x25dc40(%rip), %rax    # 0x2f70a0
movsd %xmm0, (%rax)
jmp 0x99543
leaq 0x75750(%rip), %rdi     # 0x10ebc0
callq 0x520bf
callq 0x51e6f
divsd 0x59bce(%rip), %xmm0    # 0xf3050
leaq 0x25e93f(%rip), %rax    # 0x2f7dc8
movsd %xmm0, (%rax)
leaq 0x25de20(%rip), %rax    # 0x2f72b4
jmp 0x9953d
leaq 0x76aca(%rip), %rdi     # 0x10ff6a
callq 0x520bf
callq 0x51c63
movzwl %ax, %eax
leaq 0x16bc18(%rip), %rcx    # 0x2050cc
movl %eax, (%rcx)
andl $0x3, %eax
leaq 0x16bc00(%rip), %rcx    # 0x2050c0
movl %eax, (%rcx)
leaq 0x25deff(%rip), %rax    # 0x2f73c8
jmp 0x9953d
xorl %eax, %eax
leaq 0x25e84c(%rip), %rcx    # 0x2f7d20
movb %al, (%rcx)
leaq 0x25ddff(%rip), %rax    # 0x2f72dc
movl $0x14, (%rax)
addb $-0x10, %bl
shrb $0x4, %bl
movzbl %bl, %eax
leal -0x2(%rax), %ecx
cmpl $0x2, %ecx
jb 0x99509
cmpl $0x1, %eax
ja 0x99536
leaq 0x25dfa4(%rip), %rax    # 0x2f74a4
movl (%rax), %eax
andl $-0x2, %eax
xorl %ecx, %ecx
jmp 0x99517
leaq 0x25df94(%rip), %rax    # 0x2f74a4
movl (%rax), %eax
orl $0x1, %eax
movb $0x3, %cl
leaq 0x25df86(%rip), %rdx    # 0x2f74a4
movl %eax, (%rdx)
leaq 0x25df96(%rip), %rax    # 0x2f74bd
movb %cl, (%rax)
leaq 0x25de9c(%rip), %rax    # 0x2f73cc
movl $0x1, (%rax)
leaq 0x25de93(%rip), %rax    # 0x2f73d0
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq