// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_venus_survey(int)
void parse_venus_survey(int msg)
{
u08 mode;
u32 len;
u32 sdev;
double slat,slon,salt;
u08 rtime;
u32 rlen;

   log_packet_id("venus_survey");

   if(saw_venus_raw == 0) config_venus_timing();
   saw_timing_msg |= 0x04;
   
   mode = tsip_byte();   // timing mode
   len = tsip_dword();   // survey length
   sdev = tsip_dword();  // std dev
   slat = tsip_double(); // saved lat
   slon = tsip_double(); // saved lon
   salt = (double) tsip_single(); // saved alt
   rtime = tsip_byte();  // run-time timing mode
   rlen = tsip_dword();  // run-time survey length

   if(do_survey > 0) survey_progress = 100 - ((100 * rlen) / do_survey);
   else              survey_progress = (-1);
   have_progress = 4;
//sprintf(debug_text, "mode:%d msg:%04X  len:%d  sdev:%d  lla:%f %f %f   rtime:%d  rlen:%d  prog:%d",
//mode, msg, len, sdev, slat,slon,salt, rtime, rlen, survey_progress);

   minor_alarms &= (~MINOR_SURVEY);
   venus_hold_mode = 0;
   if((rlen == 0) && (saw_venus_raw == 0)) ;  // survey completed
   else if(rtime == 0) { // PVT mode
      rcvr_mode = RCVR_MODE_3D;
   }
   else if(rtime == 1) {  // surveying
      minor_alarms |= (MINOR_SURVEY);
      rcvr_mode = RCVR_MODE_SURVEY;
   }
   else if(rtime == 2) {  // position hold
      venus_hold_mode = 1;
      rcvr_mode = RCVR_MODE_HOLD;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
leaq 0xb9dc2(%rip), %rdi     # 0x187c34
callq 0x7add0
leaq 0x2cf156(%rip), %rax    # 0x39cfd4
cmpl $0x0, (%rax)
jne 0xcde88
callq 0xb2f30
leaq 0x29e779(%rip), %rax    # 0x36c608
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x29e76d(%rip), %rax    # 0x36c608
movl %ecx, (%rax)
callq 0x7a510
movb %al, -0x5(%rbp)
callq 0x7a680
movl %eax, -0xc(%rbp)
callq 0x7a680
movl %eax, -0x10(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x18(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x20(%rbp)
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x7a510
movb %al, -0x29(%rbp)
callq 0x7a680
movl %eax, -0x30(%rbp)
leaq 0x29f16a(%rip), %rax    # 0x36d058
cmpq $0x0, (%rax)
jle 0xcdf1e
imull $0x64, -0x30(%rbp), %eax
movl %eax, %eax
leaq 0x29f157(%rip), %rcx    # 0x36d058
cqto
idivq (%rcx)
movq %rax, %rcx
movl $0x64, %eax
subq %rcx, %rax
movl %eax, %ecx
leaq 0x29f152(%rip), %rax    # 0x36d06c
movl %ecx, (%rax)
jmp 0xcdf2b
leaq 0x29f147(%rip), %rax    # 0x36d06c
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0x29f13e(%rip), %rax    # 0x36d070
movl $0x4, (%rax)
leaq 0x29e479(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x21, %ecx
leaq 0x29e46d(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x29e35f(%rip), %rax    # 0x36c2b3
movb $0x0, (%rax)
cmpl $0x0, -0x30(%rbp)
jne 0xcdf6b
leaq 0x2cf070(%rip), %rax    # 0x39cfd4
cmpl $0x0, (%rax)
jne 0xcdf6b
jmp 0xcdfcd
movzbl -0x29(%rbp), %eax
cmpl $0x0, %eax
jne 0xcdf80
leaq 0x29e335(%rip), %rax    # 0x36c2b0
movb $0x4, (%rax)
jmp 0xcdfcb
movzbl -0x29(%rbp), %eax
cmpl $0x1, %eax
jne 0xcdfaa
leaq 0x29e428(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x20, %ecx
leaq 0x29e41c(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x29e30b(%rip), %rax    # 0x36c2b0
movb $0xb, (%rax)
jmp 0xcdfc9
movzbl -0x29(%rbp), %eax
cmpl $0x2, %eax
jne 0xcdfc7
leaq 0x29e2f9(%rip), %rax    # 0x36c2b3
movb $0x1, (%rax)
leaq 0x29e2ec(%rip), %rax    # 0x36c2b0
movb $0x7, (%rax)
jmp 0xcdfc9
jmp 0xcdfcb
jmp 0xcdfcd
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)