// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_zod_traim_status()
void parse_zod_traim_status()
{
u16 mode;
u16 survey;
u32 surv_count;
u32 surv_dur;
u16 hold_status;
u16 pps_status;
u16 traim_alarm;
u16 traim_disable;
u16 t_status;
u32 excluded;

   log_packet_id("traim status");

   get_zod_seq(0);

   mode = tsip_word();         //0=survey  1=posn hold   2=nav
   survey = tsip_word(); 
   surv_count = tsip_dword(); 
   surv_dur = tsip_dword(); 
   hold_status = tsip_word(); 
   pps_status = tsip_word(); 
   traim_alarm = tsip_word(); 

   traim_disable = tsip_word();
   t_status = tsip_word();
   excluded = tsip_dword();

   pps_offset = (((double) tsip_dword()) * 0.10);
   have_pps_offset = 4;
   have_rcvr_pps = 4;
//adadad   if(jitter_adev == 0) do_pps_adev(pps_offset);

   minor_alarms &= (~MINOR_SURVEY);
   if(mode == 0) {  // survey mode
      minor_alarms |= MINOR_SURVEY;
      rcvr_mode = RCVR_MODE_SURVEY;
   }
   else if(mode == 1) {  // position hold  zorky
      rcvr_mode = RCVR_MODE_HOLD;
   }
   else if(mode == 2) {  // standard nav
      rcvr_mode = RCVR_MODE_3D;
   }
   else rcvr_mode = RCVR_MODE_UNKNOWN; 

   if(pps_status & 0x02) {  // gps time
      time_flags &= (~TFLAGS_UTC);  // GPS based time 
      timing_mode = TMODE_GPS;
      have_timing_mode = 1;
   }
   else {    // utc time
      time_flags |= TFLAGS_UTC;     // UTC based time
      timing_mode = TMODE_UTC;
      have_timing_mode = 1;
   }
   have_rcvr_tmode = 1;

   if(t_status == 3) traim_status = 3;
   else              traim_status = 0;
   // !!!! note pps status bit 1 is traim alarm flag - the documentation says
   //      1 is traim error... this appears to be wrong... 0=error !!!!
//sprintf(plot_title, "rcvr mode:%d  zod mode:%d  traim_disable:%d  t_status:%d  pps_status:%04X  tflags:%02X  exclude:%08X", rcvr_mode, mode,traim_disable,traim_status,pps_status, time_flags, excluded);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0xb75b5(%rip), %rdi     # 0x187e64
callq 0x7add0
xorl %edi, %edi
callq 0xd0040
callq 0x7a560
movw %ax, -0x2(%rbp)
callq 0x7a560
movw %ax, -0x4(%rbp)
callq 0x7a680
movl %eax, -0x8(%rbp)
callq 0x7a680
movl %eax, -0xc(%rbp)
callq 0x7a560
movw %ax, -0xe(%rbp)
callq 0x7a560
movw %ax, -0x10(%rbp)
callq 0x7a560
movw %ax, -0x12(%rbp)
callq 0x7a560
movw %ax, -0x14(%rbp)
callq 0x7a560
movw %ax, -0x16(%rbp)
callq 0x7a680
movl %eax, -0x1c(%rbp)
callq 0x7a680
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x9e802(%rip), %xmm1    # 0x16f128
mulsd %xmm1, %xmm0
leaq 0x29b067(%rip), %rax    # 0x36b998
movsd %xmm0, (%rax)
leaq 0x29badc(%rip), %rax    # 0x36c418
movl $0x4, (%rax)
leaq 0x29badb(%rip), %rax    # 0x36c424
movl $0x4, (%rax)
leaq 0x29ba62(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x21, %ecx
leaq 0x29ba56(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
movzwl -0x2(%rbp), %eax
cmpl $0x0, %eax
jne 0xd098e
leaq 0x29ba44(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x20, %ecx
leaq 0x29ba38(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x29b927(%rip), %rax    # 0x36c2b0
movb $0xb, (%rax)
jmp 0xd09c6
movzwl -0x2(%rbp), %eax
cmpl $0x1, %eax
jne 0xd09a3
leaq 0x29b912(%rip), %rax    # 0x36c2b0
movb $0x7, (%rax)
jmp 0xd09c4
movzwl -0x2(%rbp), %eax
cmpl $0x2, %eax
jne 0xd09b8
leaq 0x29b8fd(%rip), %rax    # 0x36c2b0
movb $0x4, (%rax)
jmp 0xd09c2
leaq 0x29b8f1(%rip), %rax    # 0x36c2b0
movb $0x63, (%rax)
jmp 0xd09c4
jmp 0xd09c6
movzwl -0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xd0a00
leaq 0x29bcab(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x2, %ecx
leaq 0x29bc9f(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x29bcaf(%rip), %rax    # 0x36c69d
movb $0x0, (%rax)
leaq 0x29bbb4(%rip), %rax    # 0x36c5ac
movl $0x1, (%rax)
jmp 0xd0a2c
leaq 0x29bc7d(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x29bc71(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x29bc81(%rip), %rax    # 0x36c69d
movb $0x3, (%rax)
leaq 0x29bb86(%rip), %rax    # 0x36c5ac
movl $0x1, (%rax)
leaq 0x29bb7d(%rip), %rax    # 0x36c5b0
movl $0x1, (%rax)
movzwl -0x16(%rbp), %eax
cmpl $0x3, %eax
jne 0xd0a51
leaq 0x1a985f(%rip), %rax    # 0x27a2a8
movl $0x3, (%rax)
jmp 0xd0a5e
leaq 0x1a9850(%rip), %rax    # 0x27a2a8
movl $0x0, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)