// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_moto_Ha(int)
void parse_moto_Ha(int long_msg)
{
int i;
int prn;
int mode;
int sig;
int iode;
int status;
int r_status;
int dop;
int bias;
u16 tword;
S32 ofs;
int utc;
int acc;
float t;
S32 frac;

//max_sats = 12;
//ebolt = 1;
   log_packet_id("position/satellite info");
   if(moto_chans != 12) {
      moto_chans = 12;
      config_msg_ofs();
   }

   get_moto_time(1);
   frac = (S32) tsip_dword();  // !!!! fractional time in nsec 
   pri_frac = raw_frac = ((double) frac) / 1.0E9;

   get_moto_lla();
   tsip_dword();  // msl altitude

   if(long_msg) {
      tsip_dword();  // unfiltered posn
      tsip_dword();
      tsip_dword();
      tsip_dword();  // msl altitude
   }

   speed = ((double) tsip_word()) / 100.0;   // 3d speed
   tsip_word();                              // 2d speed
   heading = ((double) tsip_word()) / 10.0;  // heading

   have_heading = 2;
   have_speed = 2;

   dop = tsip_word();
   have_dops = 0;

   sat_count = tsip_byte();    // visible
   track_count = tsip_byte();  // tracked
   have_count = 6;

   if(long_msg) {
      reset_sat_tracking();
      sat_count = 0;
      for(i=0; i<12; i++) {
         prn = tsip_byte();
         mode = tsip_byte();
         sig = tsip_byte();
         iode = tsip_byte();
         status = tsip_word();
         if((prn >= 1) && (prn <= MAX_PRN)) { 
            if(0 && (sig >= 2)) sat[prn].sig_level = (float) (20.0*log10((double) sig)+6.00);
            else sat[prn].sig_level = ((float) sig);

            sat[prn].level_msg = 13;

            sat[prn].state = mode;
            sat[prn].iode = (u08) iode;

            have_snr |= rinex_gnss(prn);

            acc = (status & 0x000F);
            sat[prn].sv_accuracy = ura_to_dist(prn, acc);

            if(have_state == 0) need_redraw = 2044;
            have_state = MOTO_STATE;  // STATE

            if(have_accu == 0) need_redraw = 2045;
            have_accu = 1;

            sat[prn].tracking = (-1);
            if(status & 0x0880) {
               if(0 || (mode == 8)) {
                  sat[prn].tracking = 1;
               }
            }

            record_sig_levels(prn);
            ++sat_count;
            have_count = 23;
         }
      }
      config_sat_count(sat_count);
   }

   r_status = get_moto_status();

   have_dops = 0;
   if((r_status & 0xE000) == 0xE000) {
      pdop = ((float) dop) / 10.0F;  // 3D fix
      have_dops |= PDOP;
   }
   else if((r_status & 0xE000) == 0x6000) {
      hdop = ((float) dop) / 10.0F;  // 2D fix
      have_dops |= HDOP;
   }
   else {
      hdop = pdop = ((float) dop) / 10.0F;  // 2D fix
      have_dops |= (HDOP | PDOP);  // !!!!
   }

   tsip_word();  // reserved

   if(long_msg) {
      bias = (int) (s16) tsip_word();  // nanoseconds
      ofs = tsip_dword();
      osc_offset = bias;  // !!!! zzzzz
      have_osc_offset = 6;
      have_rcvr_osc = 6;
//adadad      if(jitter_adev == 0) do_osc_adev(osc_offset);

      tword = tsip_word();  // temperature
      t = ((float) (s16) tword) / 2.0F;  // temperature
//sprintf(debug_text2, "tword:%d %04X  t=%g", tword,tword,t);
      if(have_temperature || (t != 0.0)) {
         temperature = t;
         have_temperature = 108;
      }

      utc = tsip_byte();  // time mode 
      if(utc & 0x80) time_flags |= TFLAGS_UTC;     // utc time
      else           time_flags &= (~TFLAGS_UTC);  // gps time

      if(utc & 0x40) time_flags &= (~TFLAGS_NO_UTC_OFS);  // utc offset avail
      else           time_flags |= (TFLAGS_NO_UTC_OFS);

      if(!user_set_utc_ofs) {
         utc_offset = utc & 0x1F;
         check_utc_ofs(9);
      }

      get_moto_tz();
   }

   get_moto_tag();

//sprintf(plot_title, "r_status:%04X  bias:%d  ofs:%d  t:%f  utc:%02X  tag:%s  tmode:%d thresh:%d", 
//r_status, bias, ofs, t, utc, id_tag, traim_mode,traim_threshold);

   level_type = "dBc"; 

   update_gps_screen(1005);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq 0x81a3f(%rip), %rdi     # 0x10ed9f
callq 0x520bf
leaq 0x177cb8(%rip), %rax    # 0x205024
cmpl $0xc, (%rax)
je 0x8d37c
movl $0xc, (%rax)
callq 0x43898
pushq $0x1
popq %r14
movl %r14d, %edi
callq 0x8bdf5
callq 0x51cf3
cvtsi2sd %eax, %xmm0
divsd 0x65c8f(%rip), %xmm0    # 0xf3028
leaq 0x26a140(%rip), %rax    # 0x2f74e0
movsd %xmm0, (%rax)
leaq 0x26a16d(%rip), %rax    # 0x2f7518
movsd %xmm0, (%rax)
callq 0x8bd62
callq 0x51cf3
movl %ebx, -0x34(%rbp)
testl %ebx, %ebx
je 0x8d3d4
callq 0x51cf3
callq 0x51cf3
callq 0x51cf3
callq 0x51cf3
callq 0x51c63
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x65c78(%rip), %xmm0    # 0xf3060
leaq 0x269c31(%rip), %rax    # 0x2f7020
movsd %xmm0, (%rax)
callq 0x51c63
callq 0x51c63
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x65c9c(%rip), %xmm0    # 0xf30a8
leaq 0x269c15(%rip), %rax    # 0x2f7028
movsd %xmm0, (%rax)
leaq 0x269f16(%rip), %rax    # 0x2f7334
pushq $0x2
popq %r12
movl %r12d, (%rax)
leaq 0x269f0c(%rip), %rax    # 0x2f7338
movl %r12d, (%rax)
callq 0x51c63
movl %eax, %r13d
leaq 0x1800a6(%rip), %r15    # 0x20d4e4
andl $0x0, (%r15)
callq 0x51c47
movzbl %al, %eax
leaq 0x19babb(%rip), %rbx    # 0x228f0c
movl %eax, (%rbx)
callq 0x51c47
movzbl %al, %eax
leaq 0x19ba9e(%rip), %rcx    # 0x228f00
movl %eax, (%rcx)
leaq 0x269ead(%rip), %rax    # 0x2f7318
movl $0x6, (%rax)
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x8d5e1
movw %r13w, -0x2c(%rbp)
callq 0x56b1c
andl $0x0, (%rbx)
pushq $0xc
popq %r12
movq %rbx, %r15
subl $0x1, %r12d
jb 0x8d5c2
callq 0x51c47
movl %eax, %r13d
callq 0x51c47
movl %eax, %ebx
callq 0x51c47
movl %eax, %r14d
callq 0x51c47
movb %al, -0x2a(%rbp)
callq 0x51c63
testb %r13b, %r13b
je 0x8d490
movzbl %r13b, %r13d
movzbl %r14b, %ecx
cvtsi2ss %ecx, %xmm0
movw %ax, -0x2e(%rbp)
movzwl %ax, %r14d
movb %bl, -0x29(%rbp)
movzbl %bl, %eax
movl %r13d, %ecx
imulq $0x348, %rcx, %r15      # imm = 0x348
leaq 0x19bac2(%rip), %rbx    # 0x228fb0
movss %xmm0, 0x20(%rbx,%r15)
movl $0xd, 0x1c(%rbx,%r15)
movl %eax, 0x18(%rbx,%r15)
movb -0x2a(%rbp), %al
movb %al, 0x1f1(%rbx,%r15)
movl %r13d, %edi
callq 0xca4da
leaq 0x269e2f(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
andl $0xf, %r14d
movl %r13d, %edi
movl %r14d, %esi
callq 0x771c5
movss %xmm0, 0x1fc(%rbx,%r15)
leaq 0x269dfd(%rip), %rax    # 0x2f733c
cmpl $0x0, (%rax)
jne 0x8d551
leaq 0x1752f9(%rip), %rcx    # 0x202844
movl $0x7fc, (%rcx)          # imm = 0x7FC
movl $0x2, (%rax)
leaq 0x269e62(%rip), %rcx    # 0x2f73c0
cmpl $0x0, (%rcx)
jne 0x8d570
leaq 0x1752da(%rip), %rax    # 0x202844
movl $0x7fd, (%rax)          # imm = 0x7FD
addq 0xac9d1(%rip), %r15     # 0x139f48
movl $0x1, (%rcx)
testw $0x880, -0x2e(%rbp)     # imm = 0x880
sete %al
cmpb $0x8, -0x29(%rbp)
setne %cl
orb %al, %cl
movzbl %cl, %eax
negl %eax
orl $0x1, %eax
movl %eax, 0x218(%r15)
movl %r13d, %edi
callq 0x559ba
leaq 0x19b95f(%rip), %r15    # 0x228f0c
incl (%r15)
leaq 0x269d61(%rip), %rax    # 0x2f7318
movl $0x17, (%rax)
jmp 0x8d490
movl (%r15), %edi
callq 0x56d93
movl -0x34(%rbp), %eax
pushq $0x1
popq %r14
leaq 0x17ff0c(%rip), %r15    # 0x20d4e4
pushq $0x2
popq %r12
movzwl -0x2c(%rbp), %r13d
movl %eax, %ebx
callq 0x8c064
movzwl %r13w, %ecx
cvtsi2ss %ecx, %xmm0
divss 0x69ad8(%rip), %xmm0    # 0xf70d0
cvtss2sd %xmm0, %xmm0
movl %eax, %ecx
notl %ecx
testw $0xe000, %cx            # imm = 0xE000
je 0x8d61f
andl $0xe000, %eax           # imm = 0xE000
cmpl $0x6000, %eax           # imm = 0x6000
jne 0x8d628
leaq 0x17fed6(%rip), %rax    # 0x20d4f0
movl %r12d, %r14d
jmp 0x8d63e
leaq 0x17fec2(%rip), %rax    # 0x20d4e8
jmp 0x8d63e
leaq 0x17feb9(%rip), %rax    # 0x20d4e8
movsd %xmm0, (%rax)
pushq $0x3
popq %r14
leaq 0x17feb2(%rip), %rax    # 0x20d4f0
movsd %xmm0, (%rax)
movl %r14d, (%r15)
callq 0x51c63
testl %ebx, %ebx
je 0x8d716
callq 0x51c63
movl %eax, %ebx
callq 0x51cf3
movswl %bx, %eax
cvtsi2sd %eax, %xmm0
leaq 0x269154(%rip), %rax    # 0x2f67c0
movsd %xmm0, (%rax)
leaq 0x269bbd(%rip), %rax    # 0x2f7234
pushq $0x6
popq %rcx
movl %ecx, (%rax)
leaq 0x269bc5(%rip), %rax    # 0x2f7248
movl %ecx, (%rax)
callq 0x51c63
cwtl
cvtsi2ss %eax, %xmm0
mulss 0x69a61(%rip), %xmm0    # 0xf70f8
leaq 0x269bae(%rip), %rax    # 0x2f724c
cmpl $0x0, (%rax)
jne 0x8d6ad
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x8d6ad
jnp 0x8d6c2
cvtss2sd %xmm0, %xmm0
leaq 0x269360(%rip), %rcx    # 0x2f6a18
movsd %xmm0, (%rcx)
movl $0x6c, (%rax)
callq 0x51c47
movzbl %al, %eax
leaq 0x269dd3(%rip), %rcx    # 0x2f74a4
movl (%rcx), %edx
andl $-0xa, %edx
movl %eax, %esi
shrb $0x7, %sil
movzbl %sil, %esi
orl %edx, %esi
movl %eax, %edx
shrl $0x3, %edx
andl $0x8, %edx
orl %esi, %edx
xorl $0x8, %edx
movl %edx, (%rcx)
leaq 0x26a03c(%rip), %rcx    # 0x2f7734
cmpl $0x0, (%rcx)
jne 0x8d711
andl $0x1f, %eax
leaq 0x26a021(%rip), %rcx    # 0x2f7728
movl %eax, (%rcx)
pushq $0x9
popq %rdi
callq 0x51a91
callq 0x8bedd
callq 0x8c082
leaq 0x7e500(%rip), %rax     # 0x10bc22
leaq 0x19b7cf(%rip), %rcx    # 0x228ef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x694f6