// File: /workspace/github_cpp_makefile_star2_O3/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 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8ed0
leaq 0x1960a3(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
addl $-0x2, %eax
cmpl $0x5, %eax
ja 0xa8f41
leaq 0x76ca6(%rip), %rcx     # 0x11fb88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7d10d(%rip), %rdi     # 0x125fff
callq 0x58dc2
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8f0d
leaq 0x196066(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x172320(%rip), %rcx    # 0x21b234
cmpb $0x0, (%rcx)
jne 0xa90da
movzbl %al, %eax
cvtsi2sd %eax, %xmm0
leaq 0x17242d(%rip), %rax    # 0x21b358
movsd %xmm0, (%rax)
leaq 0x264396(%rip), %rax    # 0x30d2cc
movl $0x3, (%rax)
jmp 0xa90da
leaq 0x7d0e8(%rip), %rdi     # 0x126030
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x58dc2
leaq 0x7d0c2(%rip), %rdi     # 0x12601c
callq 0x58dc2
callq 0x587be
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8f77
leaq 0x195ffc(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8f8d
leaq 0x195fe6(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x58964
leaq 0x264dcf(%rip), %rcx    # 0x30dd68
movl %eax, (%rcx)
xorl %ecx, %ecx
testb $0x8, %bl
sete %cl
leaq 0x264d6e(%rip), %rdx    # 0x30dd18
movl %ecx, (%rdx)
leaq 0x26432d(%rip), %rcx    # 0x30d2e0
movl $0x1, %edx
movl %edx, (%rcx)
leaq 0x264d9f(%rip), %rcx    # 0x30dd60
movl %edx, (%rcx)
testl %eax, %eax
je 0xa9062
leaq 0x264d9a(%rip), %rcx    # 0x30dd6c
movl %eax, (%rcx)
movb $0x1, %al
jmp 0xa9064
leaq 0x7d026(%rip), %rdi     # 0x126008
callq 0x58dc2
callq 0x58a30
cvtss2sd %xmm0, %xmm0
leaq 0x2640a9(%rip), %rax    # 0x30d0a0
movsd %xmm0, (%rax)
jmp 0xa90da
leaq 0x7bc71(%rip), %rdi     # 0x124c78
callq 0x58dc2
callq 0x58b08
divsd 0x60037(%rip), %xmm0    # 0x109050
leaq 0x264da8(%rip), %rax    # 0x30ddc8
movsd %xmm0, (%rax)
leaq 0x264289(%rip), %rax    # 0x30d2b4
jmp 0xa90d4
leaq 0x7cfee(%rip), %rdi     # 0x126025
callq 0x58dc2
callq 0x588d2
movzwl %ax, %eax
leaq 0x172081(%rip), %rcx    # 0x21b0cc
movl %eax, (%rcx)
andl $0x3, %eax
leaq 0x172069(%rip), %rcx    # 0x21b0c0
movl %eax, (%rcx)
leaq 0x264368(%rip), %rax    # 0x30d3c8
jmp 0xa90d4
xorl %eax, %eax
leaq 0x264cb5(%rip), %rcx    # 0x30dd20
movb %al, (%rcx)
leaq 0x264268(%rip), %rax    # 0x30d2dc
movl $0x14, (%rax)
leal -0x10(%rbx), %eax
shrb $0x4, %al
movzbl %al, %eax
leal -0x2(%rax), %ecx
cmpl $0x2, %ecx
jb 0xa90a0
cmpl $0x1, %eax
ja 0xa90cd
leaq 0x26440d(%rip), %rax    # 0x30d4a4
movl (%rax), %eax
andl $-0x2, %eax
xorl %ecx, %ecx
jmp 0xa90ae
leaq 0x2643fd(%rip), %rax    # 0x30d4a4
movl (%rax), %eax
orl $0x1, %eax
movb $0x3, %cl
leaq 0x2643ef(%rip), %rdx    # 0x30d4a4
movl %eax, (%rdx)
leaq 0x2643ff(%rip), %rax    # 0x30d4bd
movb %cl, (%rax)
leaq 0x264305(%rip), %rax    # 0x30d3cc
movl $0x1, (%rax)
leaq 0x2642fc(%rip), %rax    # 0x30d3d0
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq