// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_gpzda(int)
void parse_gpzda(int system)
{
int tz_hours;
int tz_minutes;
double tz_adjust;
double jd;


   if((rcvr_type == Z12_RCVR) && ZDA_TIME) {
      get_norcvr_message();
      return;
   }

   if((system & system_mask) == 0) return;

   have_gpzda = system;

   tz_hours = 0;      // time zone adjustment
   tz_minutes = 0;
   tz_adjust = 0.0;

   last_was_gsv = 0;

   // Note: OSX45xx corrupts the ZDA message if the receiver has rollover issues
   get_nmea_time();
   if(get_msg_field()) {
      pri_day = day = atoi(msg_field);
      if((pri_day < 1) || (pri_day > 31)) ;
      else have_nmea_date |= 0x01;
   }
   if(get_msg_field()) {
      pri_month = month = atoi(msg_field);
      if((pri_month < 1) || (pri_month > 12)) ;
      else have_nmea_date |= 0x02;
   }
   if(get_msg_field()) {
      pri_year = year = atoi(msg_field);
      if((pri_year < ROLLOVER_YEAR) || (pri_year > (ROLLOVER_YEAR+50)));  // piss3 bogus year, use sys clock
      else have_nmea_date |= 0x04;
   }

   check_nmea_date();

   if(get_msg_field()) {  // time zone hours
      tz_hours = atoi(msg_field);
      if(get_msg_field()) {  // time zone minutes
         tz_minutes = atoi(msg_field);
         if((tz_hours < 0) && (tz_minutes > 0)) tz_minutes = 0 - tz_minutes;
      }
      // !!!!!! we should adjust receiver time for time zone if not UTC
      tz_adjust = jtime(tz_hours,tz_minutes,0,0.0);
      if(tz_adjust) {
         jd = jdate(pri_year,pri_month,pri_day) + jtime(pri_hours,pri_minutes,pri_seconds,pri_frac);   
         jd -= tz_adjust;

         set_gregorian_time(jd);
      }
   }

   drive_nmea_screen(system, NMEA_ZDA);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movabsq $0x100000000, %rcx      # imm = 0x100000000
leaq 0x1c5704(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0xb23bb
callq 0xb2630
jmp 0xb261e
movl -0x4(%rbp), %eax
leaq 0x11da8b(%rip), %rcx    # 0x1cfe50
andl (%rcx), %eax
cmpl $0x0, %eax
jne 0xb23d1
jmp 0xb261e
movl -0x4(%rbp), %ecx
leaq 0x1c7ee5(%rip), %rax    # 0x27a2c0
movl %ecx, (%rax)
movl $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
movl $0x0, 0x31ebf7(%rip)    # 0x3d0ff4
callq 0xb1730
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb245d
leaq 0x2e880d(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x2ba293(%rip), %rax    # 0x36c6b4
movl %ecx, (%rax)
leaq 0x2ba2c2(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
leaq 0x2ba2b9(%rip), %rax    # 0x36c6ec
cmpl $0x1, (%rax)
jl 0xb2444
leaq 0x2ba2ad(%rip), %rax    # 0x36c6ec
cmpl $0x1f, (%rax)
jle 0xb2446
jmp 0xb245b
leaq 0x1c7e7b(%rip), %rax    # 0x27a2c8
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x1c7e6f(%rip), %rax    # 0x27a2c8
movl %ecx, (%rax)
jmp 0xb245d
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb24b8
leaq 0x2e87b2(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x2ba23c(%rip), %rax    # 0x36c6b8
movl %ecx, (%rax)
leaq 0x2ba26b(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
leaq 0x2ba262(%rip), %rax    # 0x36c6f0
cmpl $0x1, (%rax)
jl 0xb249f
leaq 0x2ba256(%rip), %rax    # 0x36c6f0
cmpl $0xc, (%rax)
jle 0xb24a1
jmp 0xb24b6
leaq 0x1c7e20(%rip), %rax    # 0x27a2c8
movl (%rax), %ecx
orl $0x2, %ecx
leaq 0x1c7e14(%rip), %rax    # 0x27a2c8
movl %ecx, (%rax)
jmp 0xb24b8
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb2519
leaq 0x2e8757(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x2ba1e5(%rip), %rax    # 0x36c6bc
movl %ecx, (%rax)
leaq 0x2ba214(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
leaq 0x2ba20b(%rip), %rax    # 0x36c6f4
cmpl $0x7e2, (%rax)          # imm = 0x7E2
jl 0xb2500
leaq 0x2ba1fc(%rip), %rax    # 0x36c6f4
cmpl $0x814, (%rax)          # imm = 0x814
jle 0xb2502
jmp 0xb2517
leaq 0x1c7dbf(%rip), %rax    # 0x27a2c8
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x1c7db3(%rip), %rax    # 0x27a2c8
movl %ecx, (%rax)
jmp 0xb2519
callq 0xb19e0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb2611
leaq 0x2e86ed(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x8(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb256a
leaq 0x2e86d4(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0x8(%rbp)
jge 0xb2568
cmpl $0x0, -0xc(%rbp)
jle 0xb2568
xorl %eax, %eax
subl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0xb256a
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
xorl %edx, %edx
xorps %xmm0, %xmm0
callq 0x122210
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb2591
jp 0xb2591
jmp 0xb260f
leaq 0x2ba15c(%rip), %rax    # 0x36c6f4
movl (%rax), %edi
leaq 0x2ba14f(%rip), %rax    # 0x36c6f0
movl (%rax), %esi
leaq 0x2ba142(%rip), %rax    # 0x36c6ec
movl (%rax), %edx
callq 0x122140
movsd %xmm0, -0x28(%rbp)
leaq 0x2ba12b(%rip), %rax    # 0x36c6e8
movl (%rax), %edi
leaq 0x2ba11e(%rip), %rax    # 0x36c6e4
movl (%rax), %esi
leaq 0x2ba111(%rip), %rax    # 0x36c6e0
movl (%rax), %edx
leaq 0x2ba120(%rip), %rax    # 0x36c6f8
movsd (%rax), %xmm0
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x28(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x7fb00
jmp 0xb2611
movl -0x4(%rbp), %edi
movl $0x1, %esi
callq 0xb1ef0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)