// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x83939(%rip), %rdi     # 0x10eac0
callq 0x520bf
xorl %edi, %edi
callq 0x8ab27
callq 0x51c63
movl %eax, %r15d
callq 0x51c63
callq 0x51cf3
callq 0x51cf3
callq 0x51c63
callq 0x51c63
movl %eax, %r14d
callq 0x51c63
callq 0x51c63
callq 0x51c63
movl %eax, %ebx
callq 0x51cf3
callq 0x51cf3
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x67f27(%rip), %xmm0    # 0xf3108
leaq 0x26b5d0(%rip), %rax    # 0x2f67b8
movsd %xmm0, (%rax)
leaq 0x26c045(%rip), %rax    # 0x2f7238
pushq $0x4
popq %rcx
movl %ecx, (%rax)
leaq 0x26c045(%rip), %rax    # 0x2f7244
movl %ecx, (%rax)
leaq 0x26bfd0(%rip), %rax    # 0x2f71d8
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x21, %edx
movl %edx, (%rax)
cmpw $0x2, %r15w
je 0x8b232
movzwl %r15w, %edx
cmpl $0x1, %edx
je 0x8b22e
testl %edx, %edx
jne 0x8b236
orl $0x20, %ecx
movl %ecx, (%rax)
movb $0xb, %al
jmp 0x8b238
movb $0x7, %al
jmp 0x8b238
movb $0x4, %al
jmp 0x8b238
movb $0x63, %al
leaq 0x26be91(%rip), %rcx    # 0x2f70d0
movb %al, (%rcx)
xorl %eax, %eax
testb $0x2, %r14b
sete %al
leaq 0x26c253(%rip), %rcx    # 0x2f74a4
movl (%rcx), %edx
andl $-0x2, %edx
orl %eax, %edx
leal (%rax,%rax,2), %eax
movl %edx, (%rcx)
leaq 0x26c259(%rip), %rcx    # 0x2f74bd
movb %al, (%rcx)
leaq 0x26c15f(%rip), %rax    # 0x2f73cc
pushq $0x1
popq %rcx
movl %ecx, (%rax)
leaq 0x26c157(%rip), %rax    # 0x2f73d0
movl %ecx, (%rax)
xorl %eax, %eax
cmpw $0x3, %bx
sete %al
leal (%rax,%rax,2), %eax
leaq 0x179e3a(%rip), %rcx    # 0x2050c8
movl %eax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq