// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_ubx_pps()
void parse_ubx_pps()
{
u08 status;
u08 flags;
u08 rsvd;
u32 rate;
u32 width;

   // get timepulse1 info
   log_packet_id("UBX_TP1");
   saw_ubx_tp = 1;

   rate = tsip_dword();  // interval in usec
   if     (rate == 1000000) pps_rate = RATE_1PPS;    // 1pps
   else if(rate == 10000)   pps_rate = RATE_100PPS;  // 100 pps
   else if(rate == 1000)    pps_rate = RATE_1000PPS; // 1000 pps
   else                     pps_rate = RATE_USER;    // user defined rate
   have_pps_rate = 3;
//sprintf(debug_text, "ubxpps: rate:%d", rate);

   width = tsip_dword();  // width in us

   status = tsip_byte();
   if(status == 0) pps_enabled = 0;
   else {
      pps_enabled = 1;
      if(status & 0x80) pps_polarity = 1; // falling
      else              pps_polarity = 0; // rising
      have_pps_polarity = 2;
   }
   have_pps_enable = 2;

   tsip_byte();   // align 0=UTC 1=GPS 2=LOCAL
   flags = tsip_byte();  // 1=always on, 0=when tracking
   rsvd = tsip_byte();   // rsvd

   cable_delay = (double) (s16) tsip_word();
   cable_delay /= 1.0E9;
// if(have_cable_delay == 0) need_redraw = 2020;
   have_cable_delay = 1;

   tsip_word();   // rf group delay
   pps1_delay = (double) (S32) tsip_dword();
   have_pps_delay |= 0x01;

   show_cable_delay();
// sprintf(debug_text2, "UBXPPS: rate:%d  width:%d  ofs:%f  mode:%d flags:%d rcvd:%02X", rate,width, pps1_delay, status,flags,rsvd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0xbca72(%rip), %rdi     # 0x187a81
callq 0x7add0
leaq 0x2a15f5(%rip), %rax    # 0x36c610
movl $0x1, (%rax)
callq 0x7a680
movl %eax, -0x8(%rbp)
cmpl $0xf4240, -0x8(%rbp)    # imm = 0xF4240
jne 0xcb03e
leaq 0x2a1eca(%rip), %rax    # 0x36cf03
movb $0x2, (%rax)
jmp 0xcb076
cmpl $0x2710, -0x8(%rbp)     # imm = 0x2710
jne 0xcb053
leaq 0x2a1eb5(%rip), %rax    # 0x36cf03
movb $-0x7e, (%rax)
jmp 0xcb074
cmpl $0x3e8, -0x8(%rbp)      # imm = 0x3E8
jne 0xcb068
leaq 0x2a1ea0(%rip), %rax    # 0x36cf03
movb $-0x7d, (%rax)
jmp 0xcb072
leaq 0x2a1e94(%rip), %rax    # 0x36cf03
movb $0x0, (%rax)
jmp 0xcb074
jmp 0xcb076
leaq 0x2a1433(%rip), %rax    # 0x36c4b0
movl $0x3, (%rax)
callq 0x7a680
movl %eax, -0xc(%rbp)
callq 0x7a510
movb %al, -0x1(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x0, %eax
jne 0xcb0a8
leaq 0x2a1e5d(%rip), %rax    # 0x36cf00
movb $0x0, (%rax)
jmp 0xcb0e9
leaq 0x2a1e51(%rip), %rax    # 0x36cf00
movb $0x1, (%rax)
movzbl -0x1(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xcb0cf
leaq 0x2a1e31(%rip), %rax    # 0x36cef8
movl $0x1, (%rax)
jmp 0xcb0dc
leaq 0x2a1e22(%rip), %rax    # 0x36cef8
movl $0x0, (%rax)
leaq 0x2a13dd(%rip), %rax    # 0x36c4c0
movl $0x2, (%rax)
leaq 0x2a13cc(%rip), %rax    # 0x36c4bc
movl $0x2, (%rax)
callq 0x7a510
callq 0x7a510
movb %al, -0x2(%rbp)
callq 0x7a510
movb %al, -0x3(%rbp)
callq 0x7a560
cwtl
cvtsi2sd %eax, %xmm0
leaq 0x2a1e8c(%rip), %rax    # 0x36cfa8
movsd %xmm0, (%rax)
leaq 0x2a1e81(%rip), %rax    # 0x36cfa8
movsd (%rax), %xmm0
movsd 0xa3ef5(%rip), %xmm1    # 0x16f028
divsd %xmm1, %xmm0
leaq 0x2a1e6a(%rip), %rax    # 0x36cfa8
movsd %xmm0, (%rax)
leaq 0x2a134b(%rip), %rax    # 0x36c494
movl $0x1, (%rax)
callq 0x7a560
callq 0x7a680
cvtsi2sd %eax, %xmm0
leaq 0x2a1e54(%rip), %rax    # 0x36cfb8
movsd %xmm0, (%rax)
leaq 0x2a1329(%rip), %rax    # 0x36c498
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2a131d(%rip), %rax    # 0x36c498
movl %ecx, (%rax)
callq 0xa0f60
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)