// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_gpsd_tpv(char*)
void parse_gpsd_tpv(char *s)
{
int i;
int old_yy;
int old_mm;
int old_dd;
int old_hh;
int old_min;
int old_sec;
double old_frac;

   // decode the TPV message - used to get the time, lat, lon, and altitude
   // info.  This message is used to drive the display... without it nothing
   // gets done.


   old_yy = year;      // used to skip duplicate time stamps
   old_mm = month;
   old_dd = day;
   old_hh = hours;
   old_min = minutes;
   old_sec = seconds;
   old_frac = raw_frac;

   while(s) {
      s = get_json_field(s);
      strcpy(gpsd_cmd, msg_field);
      if(gpsd_cmd[0] == 0) continue; 

      s = get_json_field(s);
log_gpsd_cmd();

      if(!strcmp(gpsd_cmd, "\"TIME\"")) {
         time_ptr = 1;

         get_time_field(4);
         year = atoi(time_field);
         get_time_field(1);

         get_time_field(2);
         month = atoi(time_field);
         get_time_field(1);

         get_time_field(2);
         day = atoi(time_field);
         get_time_field(1);        // eat the 'T'

         get_time_field(2);
         hours = atoi(time_field);
         get_time_field(1);        // eat the ':'

         get_time_field(2);
         minutes = atoi(time_field);
         get_time_field(1);        // eat the ':'

         get_time_field(2);
         seconds = atoi(time_field);
         get_time_field(1);        // eat the 'Z'

         get_time_field(4);
         raw_frac = atof(time_field);
         get_time_field(1);        // eat the ':'

         pri_year = year;
         pri_month = month;
         pri_day = day;
         pri_hours = hours;
         pri_minutes = minutes;
         pri_seconds = seconds;
         pri_frac = raw_frac;

//gggg
if(debug_file) fprintf(debug_file, "nema_field:%s\n", msg_field);
if(debug_file) fprintf(debug_file, "time:%04d-%02d-%02d  %02d:%02d:%02d %f\n", 
year,month,day, hours,minutes,seconds,raw_frac);

         time_flags |= TFLAGS_UTC;  // UTC based time
      }
      else if(!strcmp(gpsd_cmd, "\"LAT\"")) {
         lat = atof(msg_field) * PI / 180.0;
      }
      else if(!strcmp(gpsd_cmd, "\"LON\"")) {
         lon = atof(msg_field) * PI / 180.0;
      }
      else if(!strcmp(gpsd_cmd, "\"ALT\"")) {
         alt = atof(msg_field);
      }
      else if(!strcmp(gpsd_cmd, "\"TRACK\"")) {
         heading = atof(msg_field);
         have_heading = 20;
      }
      else if(!strcmp(gpsd_cmd, "\"SPEED\"")) {
         speed = atof(msg_field);
         have_speed = 20;
      }
      else if(!strcmp(gpsd_cmd, "\"MODE\"")) {
         i = atoi(msg_field);
         if     (i == 3) rcvr_mode = RCVR_MODE_3D;
         else if(i == 2) rcvr_mode = RCVR_MODE_2D;
         else if(i == 1) rcvr_mode = RCVR_MODE_ACQUIRE;
         else            rcvr_mode = RCVR_MODE_UNKNOWN;
      }
   }


   if(old_yy != year) ;            // gpsd can generate duplicate time stamps
   else if(old_mm != month) ;
   else if(old_dd != day) ;
   else if(old_hh != hours) ;
   else if(old_min != minutes) ;
   else if(old_sec != seconds) ;
   else return;

   update_gps_screen(1008);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x28a769(%rip), %rax    # 0x36c6bc
movl (%rax), %eax
movl %eax, -0x10(%rbp)
leaq 0x28a759(%rip), %rax    # 0x36c6b8
movl (%rax), %eax
movl %eax, -0x14(%rbp)
leaq 0x28a749(%rip), %rax    # 0x36c6b4
movl (%rax), %eax
movl %eax, -0x18(%rbp)
leaq 0x28a739(%rip), %rax    # 0x36c6b0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
leaq 0x28a729(%rip), %rax    # 0x36c6ac
movl (%rax), %eax
movl %eax, -0x20(%rbp)
leaq 0x28a719(%rip), %rax    # 0x36c6a8
movl (%rax), %eax
movl %eax, -0x24(%rbp)
leaq 0x28a725(%rip), %rax    # 0x36c6c0
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xe2444
movq -0x8(%rbp), %rdi
callq 0xe1c20
movq %rax, -0x8(%rbp)
leaq 0x2ef24d(%rip), %rdi    # 0x3d1210
leaq 0x2b8c56(%rip), %rsi    # 0x39ac20
callq 0x9350
movsbl 0x2ef23a(%rip), %eax    # 0x3d1210
cmpl $0x0, %eax
jne 0xe1fdd
jmp 0xe1fa4
movq -0x8(%rbp), %rdi
callq 0xe1c20
movq %rax, -0x8(%rbp)
callq 0xe1e70
leaq 0x2ef21a(%rip), %rdi    # 0x3d1210
leaq 0xa7099(%rip), %rsi     # 0x189096
callq 0x9510
cmpl $0x0, %eax
jne 0xe227b
movl $0x1, 0x2ef42b(%rip)    # 0x3d1440
movl $0x4, %edi
callq 0xe1ed0
leaq 0x2ef3fa(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a688(%rip), %rax    # 0x36c6bc
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x2, %edi
callq 0xe1ed0
leaq 0x2ef3cf(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a659(%rip), %rax    # 0x36c6b8
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x2, %edi
callq 0xe1ed0
leaq 0x2ef3a4(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a62a(%rip), %rax    # 0x36c6b4
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x2, %edi
callq 0xe1ed0
leaq 0x2ef379(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a5fb(%rip), %rax    # 0x36c6b0
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x2, %edi
callq 0xe1ed0
leaq 0x2ef34e(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a5cc(%rip), %rax    # 0x36c6ac
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x2, %edi
callq 0xe1ed0
leaq 0x2ef323(%rip), %rdi    # 0x3d1420
callq 0x95c0
movl %eax, %ecx
leaq 0x28a59d(%rip), %rax    # 0x36c6a8
movl %ecx, (%rax)
movl $0x1, %edi
callq 0xe1ed0
movl $0x4, %edi
callq 0xe1ed0
leaq 0x2ef2f8(%rip), %rdi    # 0x3d1420
callq 0x9480
leaq 0x28a58c(%rip), %rax    # 0x36c6c0
movsd %xmm0, (%rax)
movl $0x1, %edi
callq 0xe1ed0
leaq 0x28a573(%rip), %rax    # 0x36c6bc
movl (%rax), %ecx
leaq 0x28a5a2(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
leaq 0x28a55d(%rip), %rax    # 0x36c6b8
movl (%rax), %ecx
leaq 0x28a58c(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
leaq 0x28a547(%rip), %rax    # 0x36c6b4
movl (%rax), %ecx
leaq 0x28a576(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
leaq 0x28a531(%rip), %rax    # 0x36c6b0
movl (%rax), %ecx
leaq 0x28a560(%rip), %rax    # 0x36c6e8
movl %ecx, (%rax)
leaq 0x28a51b(%rip), %rax    # 0x36c6ac
movl (%rax), %ecx
leaq 0x28a54a(%rip), %rax    # 0x36c6e4
movl %ecx, (%rax)
leaq 0x28a505(%rip), %rax    # 0x36c6a8
movl (%rax), %ecx
leaq 0x28a534(%rip), %rax    # 0x36c6e0
movl %ecx, (%rax)
leaq 0x28a50b(%rip), %rax    # 0x36c6c0
movsd (%rax), %xmm0
leaq 0x28a538(%rip), %rax    # 0x36c6f8
movsd %xmm0, (%rax)
leaq 0x1bb3a5(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xe21f0
leaq 0x1bb398(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0xa6ebb(%rip), %rsi     # 0x18909d
leaq 0x2b8a37(%rip), %rdx    # 0x39ac20
movb $0x0, %al
callq 0x9550
leaq 0x1bb379(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xe2261
leaq 0x1bb36c(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x28a4ae(%rip), %rax    # 0x36c6bc
movl (%rax), %edx
leaq 0x28a4a1(%rip), %rax    # 0x36c6b8
movl (%rax), %ecx
leaq 0x28a494(%rip), %rax    # 0x36c6b4
movl (%rax), %r8d
leaq 0x28a486(%rip), %rax    # 0x36c6b0
movl (%rax), %r9d
leaq 0x28a478(%rip), %rax    # 0x36c6ac
movl (%rax), %r10d
leaq 0x28a46a(%rip), %rax    # 0x36c6a8
movl (%rax), %eax
leaq 0x28a479(%rip), %rsi    # 0x36c6c0
movsd (%rsi), %xmm0
leaq 0xa6e5a(%rip), %rsi     # 0x1890ac
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x1, %al
callq 0x9550
leaq 0x28a41c(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x28a410(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xe243f
leaq 0x2eef8e(%rip), %rdi    # 0x3d1210
leaq 0xa6e4b(%rip), %rsi     # 0x1890d4
callq 0x9510
cmpl $0x0, %eax
jne 0xe22c7
leaq 0x2b8986(%rip), %rdi    # 0x39ac20
callq 0x9480
movsd 0x8f321(%rip), %xmm1    # 0x1715c8
mulsd %xmm1, %xmm0
movsd 0x8cdc5(%rip), %xmm1    # 0x16f078
divsd %xmm1, %xmm0
leaq 0x289ef2(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
jmp 0xe243d
leaq 0x2eef42(%rip), %rdi    # 0x3d1210
leaq 0xa6e05(%rip), %rsi     # 0x1890da
callq 0x9510
cmpl $0x0, %eax
jne 0xe2313
leaq 0x2b893a(%rip), %rdi    # 0x39ac20
callq 0x9480
movsd 0x8f2d5(%rip), %xmm1    # 0x1715c8
mulsd %xmm1, %xmm0
movsd 0x8cd79(%rip), %xmm1    # 0x16f078
divsd %xmm1, %xmm0
leaq 0x289eae(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
jmp 0xe243b
leaq 0x2eeef6(%rip), %rdi    # 0x3d1210
leaq 0xa6dbf(%rip), %rsi     # 0x1890e0
callq 0x9510
cmpl $0x0, %eax
jne 0xe2347
leaq 0x2b88ee(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x289e82(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
jmp 0xe2439
leaq 0x2eeec2(%rip), %rdi    # 0x3d1210
leaq 0xa6d91(%rip), %rsi     # 0x1890e6
callq 0x9510
cmpl $0x0, %eax
jne 0xe2388
leaq 0x2b88ba(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x289e96(%rip), %rax    # 0x36c208
movsd %xmm0, (%rax)
leaq 0x28a197(%rip), %rax    # 0x36c514
movl $0x14, (%rax)
jmp 0xe2437
leaq 0x2eee81(%rip), %rdi    # 0x3d1210
leaq 0xa6d58(%rip), %rsi     # 0x1890ee
callq 0x9510
cmpl $0x0, %eax
jne 0xe23c6
leaq 0x2b8879(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x289e4d(%rip), %rax    # 0x36c200
movsd %xmm0, (%rax)
leaq 0x28a15a(%rip), %rax    # 0x36c518
movl $0x14, (%rax)
jmp 0xe2435
leaq 0x2eee43(%rip), %rdi    # 0x3d1210
leaq 0xa6d22(%rip), %rsi     # 0x1890f6
callq 0x9510
cmpl $0x0, %eax
jne 0xe2433
leaq 0x2b883b(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jne 0xe23ff
leaq 0x289eb6(%rip), %rax    # 0x36c2b0
movb $0x4, (%rax)
jmp 0xe2431
cmpl $0x2, -0xc(%rbp)
jne 0xe2411
leaq 0x289ea4(%rip), %rax    # 0x36c2b0
movb $0x3, (%rax)
jmp 0xe242f
cmpl $0x1, -0xc(%rbp)
jne 0xe2423
leaq 0x289e92(%rip), %rax    # 0x36c2b0
movb $0x9, (%rax)
jmp 0xe242d
leaq 0x289e86(%rip), %rax    # 0x36c2b0
movb $0x63, (%rax)
jmp 0xe242f
jmp 0xe2431
jmp 0xe2433
jmp 0xe2435
jmp 0xe2437
jmp 0xe2439
jmp 0xe243b
jmp 0xe243d
jmp 0xe243f
jmp 0xe1fa4
movl -0x10(%rbp), %eax
leaq 0x28a26e(%rip), %rcx    # 0x36c6bc
cmpl (%rcx), %eax
je 0xe2454
jmp 0xe24b0
movl -0x14(%rbp), %eax
leaq 0x28a25a(%rip), %rcx    # 0x36c6b8
cmpl (%rcx), %eax
je 0xe2464
jmp 0xe24ae
movl -0x18(%rbp), %eax
leaq 0x28a246(%rip), %rcx    # 0x36c6b4
cmpl (%rcx), %eax
je 0xe2474
jmp 0xe24ac
movl -0x1c(%rbp), %eax
leaq 0x28a232(%rip), %rcx    # 0x36c6b0
cmpl (%rcx), %eax
je 0xe2484
jmp 0xe24aa
movl -0x20(%rbp), %eax
leaq 0x28a21e(%rip), %rcx    # 0x36c6ac
cmpl (%rcx), %eax
je 0xe2494
jmp 0xe24a8
movl -0x24(%rbp), %eax
leaq 0x28a20a(%rip), %rcx    # 0x36c6a8
cmpl (%rcx), %eax
je 0xe24a4
jmp 0xe24a6
jmp 0xe24ba
jmp 0xe24a8
jmp 0xe24aa
jmp 0xe24ac
jmp 0xe24ae
jmp 0xe24b0
movl $0x3f0, %edi            # imm = 0x3F0
callq 0x9d790
addq $0x40, %rsp
popq %rbp
retq