// File: jkingan[P]ladyheather/heathgps.cpp
// Function: update_gps_screen(int)
void update_gps_screen(int why)
{
double jd0;

   // this routine handles the primary_timing() function for non-TSIP receivers
   // It drives the main screen update cycle

   // once a Venus receiver has NMEA messages enabled, it stops sending the
   // NAV message, so we need to fake the tow and gps week numbers from the
   // NMEA date/time
//if(debug_file) fprintf(debug_file, "ugs(%d)  msg:%d  line:%d\n", why, star_msg, star_line);

   if(TOW_AND_WEEK) {  // synthesize the GPS week and time-of-week
      tow = fake_tow(jd_utc);
      if(timing_mode != TMODE_GPS) tow += utc_offset;
      tow %= (7L*24L*60L*60L);
      this_tow = survey_tow = pri_tow = tow;
      have_tow = 999;

      jd0 = jd_utc;
      if(timing_mode != TMODE_GPS) jd0 += jtime(0,0,utc_offset,0.0);  // we are in UTC time, convert to GPS time

      jd0 -= GPS_EPOCH;
      gps_week = (int) (jd0 / 7.0);
      if(have_week == 0) need_redraw = 2054;
      have_week = 999;
      faked_tow = 1;
//sprintf(plot_title, "fake week:%d  jd0:%f  tmode:%d  ofs:%d", gps_week,jd0, timing_mode, utc_offset);
   }
   else if(!have_tow) {
      tow = this_tow = survey_tow = pri_tow = fake_tow(jd_utc) % (7L*24L*60L*60L);
      faked_tow = 2;
   }
   else faked_tow = 0;

   if(RCVR_SENDS_ID) ;
   else { // force log header dump
      have_info |= ALL_ID_INFO;
   }

   primary_timing(0);     // show time and lla info
   secondary_timing(0);   // validate receiver time, etc values and update screen
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x2ced6a(%rip), %rax    # 0x36c50c
cmpl $0x0, (%rax)
je 0x9d7ba
leaq 0x2ced5e(%rip), %rax    # 0x36c50c
cmpl $0x3e7, (%rax)          # imm = 0x3E7
jne 0x9d8fe
leaq 0x2cef4f(%rip), %rax    # 0x36c710
movsd (%rax), %xmm0
callq 0x11b780
movl %eax, %ecx
leaq 0x2cf149(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2ceec1(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x9d7ff
leaq 0x2cf11d(%rip), %rax    # 0x36c908
movl (%rax), %ecx
leaq 0x2cf128(%rip), %rax    # 0x36c91c
addl (%rax), %ecx
leaq 0x2cf11f(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2cf116(%rip), %rax    # 0x36c91c
movl (%rax), %eax
movl $0x93a80, %ecx          # imm = 0x93A80
cqto
idivq %rcx
movl %edx, %ecx
leaq 0x2cf101(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2cf0f8(%rip), %rax    # 0x36c91c
movl (%rax), %eax
leaq 0x2cf0f7(%rip), %rcx    # 0x36c924
movl %eax, (%rcx)
movl %eax, %eax
leaq 0x2cf0f8(%rip), %rcx    # 0x36c930
movq %rax, (%rcx)
movl %eax, %ecx
leaq 0x2cf0dc(%rip), %rax    # 0x36c920
movl %ecx, (%rax)
leaq 0x2cecbb(%rip), %rax    # 0x36c508
movl $0x3e7, (%rax)          # imm = 0x3E7
leaq 0x2ceeb6(%rip), %rax    # 0x36c710
movsd (%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x2cee33(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x9d891
leaq 0x2cf08f(%rip), %rax    # 0x36c908
movl (%rax), %edx
xorl %esi, %esi
xorps %xmm0, %xmm0
movl %esi, %edi
callq 0x122210
addsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0xd3d7a(%rip), %xmm1    # 0x171618
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0xd3dd4(%rip), %xmm1    # 0x171688
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, %cx
leaq 0x2cf052(%rip), %rax    # 0x36c918
movw %cx, (%rax)
leaq 0x2cec3c(%rip), %rax    # 0x36c50c
cmpl $0x0, (%rax)
jne 0x9d8e2
leaq 0x1da148(%rip), %rax    # 0x277a24
movl $0x806, (%rax)          # imm = 0x806
leaq 0x2cec23(%rip), %rax    # 0x36c50c
movl $0x3e7, (%rax)          # imm = 0x3E7
leaq 0x2cf032(%rip), %rax    # 0x36c928
movl $0x1, (%rax)
jmp 0x9d96f
leaq 0x2cec03(%rip), %rax    # 0x36c508
cmpl $0x0, (%rax)
jne 0x9d960
leaq 0x2cedff(%rip), %rax    # 0x36c710
movsd (%rax), %xmm0
callq 0x11b780
movl %eax, %eax
movl $0x93a80, %ecx          # imm = 0x93A80
cqto
idivq %rcx
movl %edx, %eax
leaq 0x2ceff5(%rip), %rcx    # 0x36c924
movl %eax, (%rcx)
movl %eax, %eax
leaq 0x2ceff6(%rip), %rcx    # 0x36c930
movq %rax, (%rcx)
movl %eax, %ecx
leaq 0x2cefda(%rip), %rax    # 0x36c920
movl %ecx, (%rax)
leaq 0x2cefcd(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2cefd0(%rip), %rax    # 0x36c928
movl $0x2, (%rax)
jmp 0x9d96d
leaq 0x2cefc1(%rip), %rax    # 0x36c928
movl $0x0, (%rax)
jmp 0x9d96f
leaq 0x1da13a(%rip), %rcx    # 0x277ab0
movabsq $0x19bb7b9bfc, %rax     # imm = 0x19BB7B9BFC
andq (%rcx), %rax
cmpq $0x0, %rax
je 0x9d98b
jmp 0x9d9a0
leaq 0x2cf1c2(%rip), %rax    # 0x36cb54
movl (%rax), %ecx
orl $0xf, %ecx
leaq 0x2cf1b6(%rip), %rax    # 0x36cb54
movl %ecx, (%rax)
xorl %edi, %edi
callq 0xa2560
xorl %edi, %edi
callq 0xa3470
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)