// File: jkingan[P]ladyheather/heathgps.cpp
// Function: decode_tserve_msg()
void decode_tserve_msg()
{
int i;
char c;
int doy;
int hh,mm,ss;
int q;
double jd;
int last_tick = 999;

   start_msg_decode(1);

   nmea_msg[0] = 0;
   for(i=0; i<tsip_wptr; i++) {  // copy message from tsip buffer to nmea buffer
      c = tsip_byte();
      nmea_msg[i] = c;
      nmea_msg[i+1] = 0;
      if(i >= ((int)sizeof(nmea_msg)-12)) break;
   }
   strupr(nmea_msg);
if(debug_file) fprintf(debug_file, "{%s}\n", nmea_msg);

   doy = 0;
   hh = mm = ss = 0;
   q = 0;

   msg_col = 0;
   if(get_msg_field()) {
      doy = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      hh = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      mm = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      time_flags &= (~TFLAGS_INVALID);
      discipline_mode = DIS_MODE_NORMAL;

      ss = atoi(msg_field);
if(debug_file) fprintf(debug_file, "  %03d:%02d:%02d:%02d  %s\n", doy,hh,mm,ss, msg_field);

      if(strchr(msg_field, 'X')) {  // no time avail
         time_flags |= TFLAGS_INVALID;
      }
      else if(strchr(msg_field, 'F')) {  // flywheeling
         discipline_mode = DIS_MODE_AUTO_HOLD;
      }
      else {
      }
   }
   else return;

   get_clock_time();   // in UTC
   jd = jdate(clk_year, 1, 1) + (double) (doy) - 1.0;
   jd += jtime(hh,mm,ss, 0.0);

   set_gregorian_time(jd);  // convert julian date to gregorian

   if(timing_mode == TMODE_GPS) {     // convert utc time to gps time
      utc_to_gps();
   }
   else {
      adjust_rcvr_time(0.0);  // incorporarte possibly negative fractional second into time variables
   }
   
   if(last_tick != ss) {
      last_tick = ss;
      update_gps_screen(1555);
   }
   saw_rcvr_msg = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x3e7, -0x2c(%rbp)     # imm = 0x3E7
movl $0x1, %edi
callq 0xae4a0
leaq 0x2bbc10(%rip), %rax    # 0x39aa10
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
leaq 0x2b861e(%rip), %rcx    # 0x397432
movzwl (%rcx), %ecx
cmpl %ecx, %eax
jge 0xdee60
callq 0x7a510
movb %al, -0x5(%rbp)
movb -0x5(%rbp), %dl
movslq -0x4(%rbp), %rcx
leaq 0x2bbbdf(%rip), %rax    # 0x39aa10
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x2bbbcc(%rip), %rax    # 0x39aa10
movb $0x0, (%rax,%rcx)
cmpl $0x1f5, -0x4(%rbp)      # imm = 0x1F5
jl 0xdee53
jmp 0xdee60
jmp 0xdee55
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xdee0a
leaq 0x2bbba9(%rip), %rdi    # 0x39aa10
callq 0x9890
leaq 0x1be6fd(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xdee98
leaq 0x1be6f0(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0xa4581(%rip), %rsi     # 0x18340b
leaq 0x2bbb7f(%rip), %rdx    # 0x39aa10
movb $0x0, %al
callq 0x9550
movl $0x0, -0xc(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
leaq 0x2bbf62(%rip), %rax    # 0x39ae24
movl $0x0, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xdeee3
leaq 0x2bbd47(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0xc(%rbp)
jmp 0xdeee8
jmp 0xdf09a
callq 0xb0bd0
cmpl $0x0, %eax
je 0xdef03
leaq 0x2bbd27(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x10(%rbp)
jmp 0xdef08
jmp 0xdf09a
callq 0xb0bd0
cmpl $0x0, %eax
je 0xdef23
leaq 0x2bbd07(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x14(%rbp)
jmp 0xdef28
jmp 0xdf09a
callq 0xb0bd0
cmpl $0x0, %eax
je 0xdeff9
leaq 0x28d747(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x28d73b(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x28d725(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
leaq 0x2bbcc4(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x18(%rbp)
leaq 0x1be605(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xdefa2
leaq 0x1be5f8(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movl -0x14(%rbp), %r8d
movl -0x18(%rbp), %r9d
leaq 0xa9e58(%rip), %rsi     # 0x188de8
leaq 0x2bbc89(%rip), %rax    # 0x39ac20
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9550
leaq 0x2bbc77(%rip), %rdi    # 0x39ac20
movl $0x58, %esi
callq 0x9100
cmpq $0x0, %rax
je 0xdefd0
leaq 0x28d6c4(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x28d6b8(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xdeff7
leaq 0x2bbc49(%rip), %rdi    # 0x39ac20
movl $0x46, %esi
callq 0x9100
cmpq $0x0, %rax
je 0xdeff3
leaq 0x28d689(%rip), %rax    # 0x36c677
movb $0x2, (%rax)
jmp 0xdeff5
jmp 0xdeff5
jmp 0xdeff7
jmp 0xdeffe
jmp 0xdf09a
callq 0xa750
leaq 0x28d89e(%rip), %rax    # 0x36c8a8
movl (%rax), %edi
movl $0x1, %edx
movl %edx, %esi
callq 0x122140
cvtsi2sdl -0xc(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd 0x9003f(%rip), %xmm1    # 0x16f068
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x10(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
xorps %xmm0, %xmm0
callq 0x122210
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x7fb00
leaq 0x28d63f(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xdf06d
callq 0x7fc70
jmp 0xdf075
xorps %xmm0, %xmm0
callq 0x7fbf0
movl -0x2c(%rbp), %eax
cmpl -0x18(%rbp), %eax
je 0xdf08d
movl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x613, %edi            # imm = 0x613
callq 0x9d790
leaq 0x1bf0ec(%rip), %rax    # 0x29e180
movl $0x1, (%rax)
addq $0x40, %rsp
popq %rbp
retq