// File: /workspace/github_cpp_makefile_star2_O3/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 0x8b78e(%rip), %rdi     # 0x124b78
callq 0x58dc2
callq 0x58964
callq 0x588d2
callq 0x588d2
movl %eax, %r15d
callq 0x588d2
callq 0x58964
callq 0x58964
callq 0x588d2
callq 0x588d2
movl %eax, %r14d
callq 0x588d2
callq 0x588d2
callq 0x588d2
movl %eax, %ebx
callq 0x58964
callq 0x58964
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x6fcc1(%rip), %xmm0    # 0x109108
leaq 0x27336a(%rip), %rax    # 0x30c7b8
movsd %xmm0, (%rax)
leaq 0x273ddf(%rip), %rax    # 0x30d238
movl $0x4, %ecx
movl %ecx, (%rax)
leaq 0x273ddd(%rip), %rax    # 0x30d244
movl %ecx, (%rax)
leaq 0x273d68(%rip), %rax    # 0x30d1d8
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x21, %edx
movl %edx, (%rax)
cmpw $0x2, %r15w
je 0x9949a
movzwl %r15w, %edx
cmpl $0x1, %edx
je 0x99496
testl %edx, %edx
jne 0x9949e
orl $0x20, %ecx
movl %ecx, (%rax)
movb $0xb, %al
jmp 0x994a0
movb $0x7, %al
jmp 0x994a0
movb $0x4, %al
jmp 0x994a0
movb $0x63, %al
leaq 0x273c29(%rip), %rcx    # 0x30d0d0
movb %al, (%rcx)
xorl %eax, %eax
testb $0x2, %r14b
sete %al
leaq 0x273feb(%rip), %rcx    # 0x30d4a4
movl (%rcx), %edx
andl $-0x2, %edx
orl %eax, %edx
leal (%rax,%rax,2), %eax
movl %edx, (%rcx)
leaq 0x273ff1(%rip), %rcx    # 0x30d4bd
movb %al, (%rcx)
leaq 0x273ef7(%rip), %rax    # 0x30d3cc
movl $0x1, %ecx
movl %ecx, (%rax)
leaq 0x273eed(%rip), %rax    # 0x30d3d0
movl %ecx, (%rax)
xorl %eax, %eax
cmpw $0x3, %bx
sete %al
leal (%rax,%rax,2), %eax
leaq 0x181bd0(%rip), %rcx    # 0x21b0c8
movl %eax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq