// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_venus_pps()
void parse_venus_pps()
{
u08 sub_code;
u32 freq;
u32 width;

pps_enabled = pps_mode = 1; // zzzzz
   have_pps_enable = 4;
   have_pps_mode = 4;
   sub_code = tsip_byte();
   freq = width = 0;

   if(sub_code == 0x80) {   // width (us) 1..100000us
      log_packet_id("pps width");
      width = tsip_dword();
      if(saw_timing_msg & 0x08) {
         pps2_duty = 0.50;
         have_pps_duty |= 0x02;
      }
      else {
         if(pps1_freq) {
            pps1_duty = (((double) (width)) / 1.0E6) /  (1.0 / pps1_freq);
            have_pps_duty |= 0x01;
         }
      }
   }
   else if(sub_code == 0x81) {  // freq (not all firmware does this)
      log_packet_id("pps freq");
      freq = tsip_dword();
      if(saw_timing_msg & 0x08) {
         pps2_freq = (double) freq;
         have_pps_freq |= 0x02;
      }
      else {
//!!!!   pps1_freq = (double) freq;
         pps1_freq = 1.0;        // only does 1PPS, can't set the freq
         have_pps_freq |= 0x01;
      }
   }
   else {
      log_packet_id("unsupported pps subcode");
   }
//sprintf(debug_text, "freq %d:%d  width %d:%d  duty:%f", have_pps_freq,freq,  have_pps_duty,width,pps1_duty); // qqqqqqqq
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x29ef13(%rip), %rax    # 0x36cf02
movb $0x1, (%rax)
leaq 0x29ef07(%rip), %rax    # 0x36cf00
movb $0x1, (%rax)
leaq 0x29e4b9(%rip), %rax    # 0x36c4bc
movl $0x4, (%rax)
leaq 0x29e4bc(%rip), %rax    # 0x36c4cc
movl $0x4, (%rax)
callq 0x7a510
movb %al, -0x1(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x80, %eax
jne 0xce0f4
leaq 0xb9bff(%rip), %rdi     # 0x187c41
callq 0x7add0
callq 0x7a680
movl %eax, -0xc(%rbp)
leaq 0x29e5b2(%rip), %rax    # 0x36c608
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xce08a
leaq 0x29eec1(%rip), %rax    # 0x36cf28
movsd 0xa1021(%rip), %xmm0    # 0x16f090
movsd %xmm0, (%rax)
leaq 0x29eeca(%rip), %rax    # 0x36cf44
movl (%rax), %ecx
orl $0x2, %ecx
leaq 0x29eebe(%rip), %rax    # 0x36cf44
movl %ecx, (%rax)
jmp 0xce0ef
leaq 0x29ee77(%rip), %rax    # 0x36cf08
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xce0a2
jp 0xce0a2
jmp 0xce0ed
movl -0xc(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xa0f8e(%rip), %xmm1    # 0x16f040
divsd %xmm1, %xmm0
movsd 0xa0faa(%rip), %xmm1    # 0x16f068
leaq 0x29ee43(%rip), %rax    # 0x36cf08
divsd (%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x29ee3c(%rip), %rax    # 0x36cf10
movsd %xmm0, (%rax)
leaq 0x29ee65(%rip), %rax    # 0x36cf44
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x29ee59(%rip), %rax    # 0x36cf44
movl %ecx, (%rax)
jmp 0xce0ef
jmp 0xce186
movzbl -0x1(%rbp), %eax
cmpl $0x81, %eax
jne 0xce178
leaq 0xb9b45(%rip), %rdi     # 0x187c4b
callq 0x7add0
callq 0x7a680
movl %eax, -0x8(%rbp)
leaq 0x29e4ee(%rip), %rax    # 0x36c608
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xce14e
movl -0x8(%rbp), %eax
cvtsi2sd %rax, %xmm0
leaq 0x29eded(%rip), %rax    # 0x36cf20
movsd %xmm0, (%rax)
leaq 0x29ee02(%rip), %rax    # 0x36cf40
movl (%rax), %ecx
orl $0x2, %ecx
leaq 0x29edf6(%rip), %rax    # 0x36cf40
movl %ecx, (%rax)
jmp 0xce176
leaq 0x29edb3(%rip), %rax    # 0x36cf08
movsd 0xa0f0b(%rip), %xmm0    # 0x16f068
movsd %xmm0, (%rax)
leaq 0x29edd8(%rip), %rax    # 0x36cf40
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x29edcc(%rip), %rax    # 0x36cf40
movl %ecx, (%rax)
jmp 0xce184
leaq 0xb9ad5(%rip), %rdi     # 0x187c54
callq 0x7add0
jmp 0xce186
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)