// File: /workspace/github_cpp_makefile_star2_O1/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, %r14d
leaq 0x89065(%rip), %rdi     # 0x124d77
callq 0x58e77
leaq 0x17f306(%rip), %rax    # 0x21b024
cmpl $0xc, (%rax)
je 0x9bd2e
movl $0xc, (%rax)
callq 0x47650
movl $0x1, %edi
callq 0x9a094
callq 0x589b0
cvtsi2sd %eax, %xmm0
divsd 0x6d2df(%rip), %xmm0    # 0x109028
leaq 0x271790(%rip), %rax    # 0x30d4e0
movsd %xmm0, (%rax)
leaq 0x2717bd(%rip), %rax    # 0x30d518
movsd %xmm0, (%rax)
callq 0x99ffb
callq 0x589b0
testl %r14d, %r14d
je 0x9bd82
callq 0x589b0
callq 0x589b0
callq 0x589b0
callq 0x589b0
callq 0x588f0
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x6d2c7(%rip), %xmm0    # 0x109060
leaq 0x271280(%rip), %rax    # 0x30d020
movsd %xmm0, (%rax)
callq 0x588f0
callq 0x588f0
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x6d2e8(%rip), %xmm0    # 0x1090a8
leaq 0x271261(%rip), %rax    # 0x30d028
movsd %xmm0, (%rax)
leaq 0x271562(%rip), %rax    # 0x30d334
movl $0x2, %ecx
movl %ecx, (%rax)
leaq 0x271558(%rip), %rax    # 0x30d338
movl %ecx, (%rax)
callq 0x588f0
movl %eax, %r12d
leaq 0x1876f3(%rip), %r15    # 0x2234e4
movl $0x0, (%r15)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x9be0e
leaq 0x1a3165(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x1a30f4(%rip), %rcx    # 0x23ef0c
movl %eax, (%rcx)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x9be30
leaq 0x1a3143(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x1a30c6(%rip), %rcx    # 0x23ef00
movl %eax, (%rcx)
leaq 0x2714d5(%rip), %rax    # 0x30d318
movl $0x6, (%rax)
testl %r14d, %r14d
je 0x9c026
movw %r12w, -0x2a(%rbp)
movl %r14d, -0x34(%rbp)
movl $0x218, %eax            # imm = 0x218
leaq 0x1a3149(%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 0x9be69
leaq 0x1a3084(%rip), %rax    # 0x23ef0c
movl $0x0, (%rax)
movl $0xc, %r12d
callq 0x587d1
movl %eax, %r13d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9bead
leaq 0x1a30c6(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, -0x30(%rbp)
cmpl $0x100, %eax            # imm = 0x100
jb 0x9bec6
leaq 0x1a30ad(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0x9bede
leaq 0x1a3095(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x9bef7
leaq 0x1a307c(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588f0
testb %r13b, %r13b
je 0x9bfff
movzbl %r13b, %edx
movzwl %ax, %r15d
movzbl %bl, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movl -0x30(%rbp), %eax
movl $0xff, %ecx
andl %ecx, %eax
andl %ecx, %r13d
imulq $0x348, %r13, %rbx      # imm = 0x348
leaq 0x1a307e(%rip), %r13    # 0x23efb0
movss %xmm0, 0x20(%r13,%rbx)
movl $0xd, 0x1c(%r13,%rbx)
movl %eax, 0x18(%r13,%rbx)
movb %r14b, 0x1f1(%r13,%rbx)
movl %edx, %r14d
movl %edx, %edi
callq 0xdbb74
leaq 0x2713ec(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %r15d, -0x38(%rbp)
andl $0xf, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x82d30
movss %xmm0, 0x1fc(%r13,%rbx)
leaq 0x2713b6(%rip), %rax    # 0x30d33c
cmpl $0x0, (%rax)
jne 0x9bf98
leaq 0x17c8b2(%rip), %rcx    # 0x218844
movl $0x7fc, (%rcx)          # imm = 0x7FC
movl $0x2, (%rax)
leaq 0x27141b(%rip), %rcx    # 0x30d3c0
cmpl $0x0, (%rcx)
jne 0x9bfb7
leaq 0x17c893(%rip), %rax    # 0x218844
movl $0x7fd, (%rax)          # imm = 0x7FD
addq %r13, %rbx
movl $0x1, (%rcx)
testl $0x880, -0x38(%rbp)     # imm = 0x880
sete %al
cmpb $0x8, -0x30(%rbp)
setne %cl
orb %al, %cl
movzbl %cl, %eax
negl %eax
orl $0x1, %eax
movl %eax, 0x218(%rbx)
movl %r14d, %edi
callq 0x5ced3
leaq 0x1a2f1c(%rip), %rax    # 0x23ef0c
incl (%rax)
leaq 0x27131f(%rip), %rax    # 0x30d318
movl $0x17, (%rax)
decl %r12d
jne 0x9be94
leaq 0x1a2efd(%rip), %rax    # 0x23ef0c
movl (%rax), %edi
callq 0x5e411
movl -0x34(%rbp), %r14d
leaq 0x1874c3(%rip), %r15    # 0x2234e4
movzwl -0x2a(%rbp), %r12d
callq 0x588f0
movl %eax, %ebx
movzwl %ax, %edi
callq 0x9a2f2
movl $0x0, (%r15)
movl $0xe000, %eax           # imm = 0xE000
andl %eax, %ebx
movzwl %r12w, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
divss 0x70f8a(%rip), %xmm0    # 0x10cfe0
cvtss2sd %xmm0, %xmm0
cmpl %eax, %ebx
je 0x9c06d
cmpl $0x6000, %ebx           # imm = 0x6000
jne 0x9c07b
movl $0x2, %eax
jmp 0x9c08b
movl $0x1, %eax
leaq 0x18746f(%rip), %rcx    # 0x2234e8
jmp 0x9c092
leaq 0x187466(%rip), %rax    # 0x2234e8
movsd %xmm0, (%rax)
movl $0x3, %eax
leaq 0x18745e(%rip), %rcx    # 0x2234f0
movsd %xmm0, (%rcx)
movl %eax, (%r15)
callq 0x588f0
testl %r14d, %r14d
je 0x9c1b7
callq 0x588f0
movl %eax, %ebx
callq 0x589b0
movswl %bx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x2706fc(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x271165(%rip), %rax    # 0x30d234
movl $0x6, %ecx
movl %ecx, (%rax)
leaq 0x27116b(%rip), %rax    # 0x30d248
movl %ecx, (%rax)
callq 0x588f0
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x70ef0(%rip), %xmm0    # 0x10cfe4
leaq 0x271151(%rip), %rax    # 0x30d24c
cmpl $0x0, (%rax)
jne 0x9c10a
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x9c10a
jnp 0x9c11f
cvtss2sd %xmm0, %xmm0
leaq 0x270903(%rip), %rcx    # 0x30ca18
movsd %xmm0, (%rcx)
movl $0x6c, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x9c135
leaq 0x1a2e3e(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x271368(%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 0x2715d3(%rip), %rcx    # 0x30d734
cmpl $0x0, (%rcx)
jne 0x9c1b2
andl $0x1f, %eax
leaq 0x2715b8(%rip), %rcx    # 0x30d728
movl %eax, (%rcx)
leaq 0x2711a3(%rip), %rcx    # 0x30d31c
cmpl $0x0, (%rcx)
jne 0x9c1b2
leaq 0x27138f(%rip), %rdx    # 0x30d514
cmpl $0x7e1, (%rdx)          # imm = 0x7E1
setge %dl
cmpl $0x12, %eax
setb %sil
cmpl $0x11, %eax
jb 0x9c1b2
andb %dl, %sil
jne 0x9c1b2
leaq 0x17c69e(%rip), %rax    # 0x218844
movl $0x7d9, (%rax)          # imm = 0x7D9
movl $0x9, (%rcx)
callq 0x9a222
callq 0x9a400
leaq 0x85a37(%rip), %rax     # 0x121bfa
leaq 0x1a2d2e(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7327e