// File: /workspace/github_cpp_makefile_star2_O3/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 0x88f62(%rip), %rdi     # 0x124e57
callq 0x58dc2
leaq 0x17f123(%rip), %rax    # 0x21b024
cmpl $0xc, (%rax)
je 0x9bf11
movl $0xc, (%rax)
callq 0x4771f
movl $0x1, %edi
callq 0x9a242
callq 0x58964
cvtsi2sd %eax, %xmm0
divsd 0x6d0fc(%rip), %xmm0    # 0x109028
leaq 0x2715ad(%rip), %rax    # 0x30d4e0
movsd %xmm0, (%rax)
leaq 0x2715da(%rip), %rax    # 0x30d518
movsd %xmm0, (%rax)
callq 0x9a1a9
callq 0x58964
testl %ebx, %ebx
je 0x9bf64
callq 0x58964
callq 0x58964
callq 0x58964
callq 0x58964
callq 0x588d2
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x6d0e5(%rip), %xmm0    # 0x109060
leaq 0x27109e(%rip), %rax    # 0x30d020
movsd %xmm0, (%rax)
callq 0x588d2
callq 0x588d2
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x6d106(%rip), %xmm0    # 0x1090a8
leaq 0x27107f(%rip), %rax    # 0x30d028
movsd %xmm0, (%rax)
leaq 0x271380(%rip), %rax    # 0x30d334
movl $0x2, %ecx
movl %ecx, (%rax)
leaq 0x271376(%rip), %rax    # 0x30d338
movl %ecx, (%rax)
callq 0x588d2
movl %eax, %r12d
leaq 0x187511(%rip), %r15    # 0x2234e4
movl $0x0, (%r15)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9bff0
leaq 0x1a2f83(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x1a2f12(%rip), %rcx    # 0x23ef0c
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c012
leaq 0x1a2f61(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x1a2ee4(%rip), %rcx    # 0x23ef00
movl %eax, (%rcx)
leaq 0x2712f3(%rip), %rax    # 0x30d318
movl $0x6, (%rax)
testl %ebx, %ebx
je 0x9c1ff
movw %r12w, -0x2a(%rbp)
movl %ebx, -0x30(%rbp)
movl $0x218, %eax            # imm = 0x218
leaq 0x1a2f69(%rip), %rdx    # 0x23efb0
xorl %ecx, %ecx
movl %ecx, (%rdx,%rax)
movl %ecx, -0x1fc(%rdx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x9c049
leaq 0x1a2ea4(%rip), %rax    # 0x23ef0c
movl $0x0, (%rax)
movl $0xc, %ebx
callq 0x587be
movl %eax, %r15d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c08c
leaq 0x1a2ee7(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
movl %eax, %r12d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c0a5
leaq 0x1a2ece(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
movl %eax, %r13d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c0be
leaq 0x1a2eb5(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c0d7
leaq 0x1a2e9c(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
movzbl %r15b, %r15d
callq 0x588d2
testl %r15d, %r15d
je 0x9c1da
movzbl %r13b, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movzwl %ax, %edx
movzbl %r12b, %ecx
movl %r15d, %eax
imulq $0x348, %rax, %r12      # imm = 0x348
leaq 0x1a2ea4(%rip), %r13    # 0x23efb0
movss %xmm0, 0x20(%r13,%r12)
movl $0xd, 0x1c(%r13,%r12)
movl %ecx, -0x34(%rbp)
movl %ecx, 0x18(%r13,%r12)
movb %r14b, 0x1f1(%r13,%r12)
movl %edx, %r14d
movl %r15d, %edi
callq 0xdc1dd
leaq 0x27120e(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %r14d, %esi
andl $0xf, %esi
movl %r15d, %edi
callq 0x82c38
movss %xmm0, 0x1fc(%r13,%r12)
leaq 0x2711dd(%rip), %rcx    # 0x30d33c
cmpl $0x0, (%rcx)
jne 0x9c171
leaq 0x17c6d9(%rip), %rdx    # 0x218844
movl $0x7fc, (%rdx)          # imm = 0x7FC
movl $0x2, (%rcx)
leaq 0x271242(%rip), %rdx    # 0x30d3c0
cmpl $0x0, (%rdx)
jne 0x9c190
leaq 0x17c6ba(%rip), %rcx    # 0x218844
movl $0x7fd, (%rcx)          # imm = 0x7FD
addq %r13, %r12
movl $0x1, (%rdx)
testl $0x880, %r14d           # imm = 0x880
sete %al
cmpl $0x8, -0x34(%rbp)
setne %cl
orb %al, %cl
movzbl %cl, %eax
negl %eax
orl $0x1, %eax
movl %eax, 0x218(%r12)
movl %r15d, %edi
callq 0x5cdab
leaq 0x1a2d41(%rip), %rax    # 0x23ef0c
incl (%rax)
leaq 0x271144(%rip), %rax    # 0x30d318
movl $0x17, (%rax)
decl %ebx
jne 0x9c073
leaq 0x1a2d23(%rip), %rax    # 0x23ef0c
movl (%rax), %edi
callq 0x5e390
movl -0x30(%rbp), %ebx
leaq 0x1872ea(%rip), %r15    # 0x2234e4
movzwl -0x2a(%rbp), %r12d
callq 0x588d2
movl %eax, %r14d
movzwl %ax, %edi
callq 0x9a4a0
movl $0xe000, %eax           # imm = 0xE000
andl %eax, %r14d
movzwl %r12w, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
divss 0x70e26(%rip), %xmm0    # 0x10d050
cvtss2sd %xmm0, %xmm0
cmpl %eax, %r14d
je 0x9c243
cmpl $0x6000, %r14d          # imm = 0x6000
jne 0x9c251
movl $0x2, %eax
jmp 0x9c261
movl $0x1, %eax
leaq 0x187299(%rip), %rcx    # 0x2234e8
jmp 0x9c268
leaq 0x187290(%rip), %rax    # 0x2234e8
movsd %xmm0, (%rax)
movl $0x3, %eax
leaq 0x187288(%rip), %rcx    # 0x2234f0
movsd %xmm0, (%rcx)
movl %eax, (%r15)
callq 0x588d2
testl %ebx, %ebx
je 0x9c38c
callq 0x588d2
movl %eax, %ebx
callq 0x58964
movswl %bx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x270527(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x270f90(%rip), %rax    # 0x30d234
movl $0x6, %ecx
movl %ecx, (%rax)
leaq 0x270f96(%rip), %rax    # 0x30d248
movl %ecx, (%rax)
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x70daf(%rip), %xmm0    # 0x10d078
leaq 0x270f7c(%rip), %rax    # 0x30d24c
cmpl $0x0, (%rax)
jne 0x9c2df
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x9c2df
jnp 0x9c2f4
cvtss2sd %xmm0, %xmm0
leaq 0x27072e(%rip), %rcx    # 0x30ca18
movsd %xmm0, (%rcx)
movl $0x6c, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c30a
leaq 0x1a2c69(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x271193(%rip), %rcx    # 0x30d4a4
movl (%rcx), %edx
andl $-0xa, %edx
movl %eax, %esi
shrl $0x7, %esi
andl $0x1, %esi
movl %eax, %edi
shrl $0x3, %edi
andl $0x8, %edi
orl %esi, %edi
orl %edx, %edi
xorl $0x8, %edi
movl %edi, (%rcx)
leaq 0x2713fe(%rip), %rcx    # 0x30d734
cmpl $0x0, (%rcx)
jne 0x9c387
andl $0x1f, %eax
leaq 0x2713e3(%rip), %rcx    # 0x30d728
movl %eax, (%rcx)
leaq 0x270fce(%rip), %rcx    # 0x30d31c
cmpl $0x0, (%rcx)
jne 0x9c387
leaq 0x2711ba(%rip), %rdx    # 0x30d514
cmpl $0x7e1, (%rdx)          # imm = 0x7E1
setge %dl
cmpl $0x12, %eax
setb %sil
cmpl $0x11, %eax
jb 0x9c387
andb %dl, %sil
jne 0x9c387
leaq 0x17c4c9(%rip), %rax    # 0x218844
movl $0x7d9, (%rax)          # imm = 0x7D9
movl $0x9, (%rcx)
callq 0x9a3d0
callq 0x9a5a9
leaq 0x85942(%rip), %rax     # 0x121cda
leaq 0x1a2b59(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x730e8