// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_brandy_a()
void parse_brandy_a()
{
char c;
int val;

   // version and time info
   log_packet_id("version and time");

   if(get_msg_field()) {  // fw version (handled in version message)
   }

   if(get_msg_field()) {  // time - we get this from the "t" message
      if(use_a_time) {
         sscanf(msg_field, "%d%c%d%c%d", &pri_hours,&c,&pri_minutes,&c,&pri_seconds);
         hours = pri_hours;
         minutes = pri_minutes;
         seconds = pri_seconds;
      }
   }

   if(get_msg_field()) {  // date - we get this from the "t" message
      if(use_a_time) {
         sscanf(msg_field, "%d%c%d%c%d", &pri_day,&c,&pri_month,&c,&pri_year);
         if(pri_year < 80) pri_year += 2000;
         else              pri_year += 1900;
         month = pri_month;
         day = pri_day;
         year = pri_year;
      }
   }
//sprintf(debug_text, "%02d:%02d:%02d  %04d/%02d/%02d", hours,minutes,seconds, year,month,day);

   if(timing_mode == TMODE_GPS) {  // convert utc time to gps time
      if(use_a_time) utc_to_gps();
   }

   if(get_msg_field()) {  // status  (hex number)
      val = atohex(msg_field);
//sprintf(debug_text2, "status:%04X", val);
      time_flags &= (~TFLAGS_INVALID);
      if(val & 0x08) {  // time ok
         time_flags &= (~TFLAGS_INVALID);
      }
      else { // time bad
//!!!!!! time_flags |= (TFLAGS_INVALID);
      }

      if(val & 0x04) {  // GPS unlocked
      }
      else {  // GPS locked
      }
   }

   if(get_msg_field()) {  // position averaging count
      if(isdigit(msg_field[0])) {
         survey_progress = atoi(msg_field);
         have_progress = 2;
      }
   }

   if(get_msg_field()) {  // position averaging mode
      c = msg_field[0];
      minor_alarms &= (~MINOR_SURVEY);
      if(c == '0') {  // not averaging
         rcvr_mode = RCVR_MODE_3D;
         have_rcvr_mode = 22;
      }
      else if(c == '1') {  // averaging
         rcvr_mode = RCVR_MODE_SURVEY;
         minor_alarms |= MINOR_SURVEY;
         have_rcvr_mode = 22;
      }
      else if(c == '2') {  // position hold mode
         rcvr_mode = RCVR_MODE_HOLD;
         have_rcvr_mode = 22;
      }
   }

   if(get_msg_field()) {  // output status (hex number)
      val = atohex(msg_field);
      if(val & 0x0080) {  // pll unlocked  !!!!!
         ffom = 2;
      }
      else ffom = 0;
      have_ffom = 33;
   }

   if(get_msg_field()) {  // control status (hex number)
      val = atohex(msg_field);
      if(val & 0x0010) minor_alarms |= MINOR_OSC_AGE;
      else             minor_alarms &= (~MINOR_OSC_AGE);
      have_osc_age = 556;

      if(val & 0x0040) minor_alarms |= MINOR_NO_TRACK;
      else             minor_alarms &= (~MINOR_NO_TRACK);
      have_tracking = 1;

      if(val & 0x0008) critical_alarms |= (CRIT_OCXO);
      else             critical_alarms &= (~CRIT_OCXO);

      if(val & 0x0080) critical_alarms |= (CRIT_FPGA);
      else             critical_alarms &= (~CRIT_FPGA);
      have_critical_alarms = 77;

      if(val & 0x0002) discipline_mode = DIS_MODE_WARMUP;
      else             discipline_mode = DIS_MODE_NORMAL;
   }

   if(use_a_time)  {
      drive_nmea_screen(GPS, 8877);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x9980c(%rip), %rdi     # 0x123750
callq 0x58dc2
callq 0x810b1
callq 0x810b1
testl %eax, %eax
je 0x89fbe
cmpl $0x0, 0x2e2c9e(%rip)    # 0x36cbfc
je 0x89fbe
leaq 0x283599(%rip), %r15    # 0x30d500
movq %r15, (%rsp)
leaq 0x2b1ace(%rip), %rdi    # 0x33ba40
leaq 0x94153(%rip), %rsi     # 0x11e0cc
leaq 0x283588(%rip), %rbx    # 0x30d508
leaq 0x28357d(%rip), %r14    # 0x30d504
leaq -0x19(%rbp), %rcx
movq %rbx, %rdx
movq %r14, %r8
movq %rcx, %r9
xorl %eax, %eax
callq 0x9360
movl (%rbx), %eax
leaq 0x28352c(%rip), %rcx    # 0x30d4d0
movl %eax, (%rcx)
movl (%r14), %eax
leaq 0x28351c(%rip), %rcx    # 0x30d4cc
movl %eax, (%rcx)
movl (%r15), %eax
leaq 0x28350c(%rip), %rcx    # 0x30d4c8
movl %eax, (%rcx)
callq 0x810b1
testl %eax, %eax
setne %cl
movl 0x2e2c2e(%rip), %eax    # 0x36cbfc
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x8a053
leaq 0x283533(%rip), %r15    # 0x30d514
movq %r15, (%rsp)
leaq 0x2b1a54(%rip), %rdi    # 0x33ba40
leaq 0x940d9(%rip), %rsi     # 0x11e0cc
leaq 0x283512(%rip), %rbx    # 0x30d50c
leaq 0x28350f(%rip), %r14    # 0x30d510
leaq -0x19(%rbp), %rcx
movq %rbx, %rdx
movq %r14, %r8
movq %rcx, %r9
xorl %eax, %eax
callq 0x9360
movl (%r15), %eax
leal 0x76c(%rax), %ecx
leal 0x7d0(%rax), %edx
cmpl $0x50, %eax
cmovgel %ecx, %edx
movl %edx, (%r15)
movl (%r14), %eax
leaq 0x2834a1(%rip), %rcx    # 0x30d4d8
movl %eax, (%rcx)
movl (%rbx), %eax
leaq 0x283492(%rip), %rcx    # 0x30d4d4
movl %eax, (%rcx)
leaq 0x283491(%rip), %rax    # 0x30d4dc
movl %edx, (%rax)
movl 0x2e2ba9(%rip), %eax    # 0x36cbfc
leaq 0x283463(%rip), %rcx    # 0x30d4bd
cmpb $0x0, (%rcx)
jne 0x8a08a
testl %eax, %eax
je 0x8a08a
leaq 0x2836be(%rip), %rax    # 0x30d728
cvtsi2sdl (%rax), %xmm0
callq 0x5c7ed
leaq 0x28342a(%rip), %rax    # 0x30d4a4
andb $-0x2, (%rax)
leaq 0x283348(%rip), %rax    # 0x30d3cc
movl $0x1, (%rax)
callq 0x810b1
testl %eax, %eax
je 0x8a0a9
leaq 0x2b19a6(%rip), %rdi    # 0x33ba40
callq 0x98c6
leaq 0x2833fe(%rip), %rax    # 0x30d4a4
andb $-0x5, (%rax)
callq 0x810b1
testl %eax, %eax
je 0x8a0e6
leaq 0x2b1987(%rip), %rax    # 0x33ba40
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x8a0e6
leaq 0x2b1975(%rip), %rdi    # 0x33ba40
callq 0x95e0
leaq 0x283db5(%rip), %rcx    # 0x30de8c
movl %eax, (%rcx)
leaq 0x283db0(%rip), %rax    # 0x30de90
movl $0x2, (%rax)
callq 0x810b1
testl %eax, %eax
je 0x8a14c
leaq 0x2b194a(%rip), %rax    # 0x33ba40
movzbl (%rax), %edx
leaq 0x2830d8(%rip), %rax    # 0x30d1d8
movl (%rax), %ecx
movl %ecx, %esi
andl $-0x21, %esi
movb %dl, -0x19(%rbp)
movl %esi, (%rax)
cmpl $0x32, %edx
je 0x8a138
cmpl $0x31, %edx
je 0x8a127
cmpl $0x30, %edx
jne 0x8a14c
leaq 0x282fae(%rip), %rax    # 0x30d0d0
movb $0x4, (%rax)
jmp 0x8a142
leaq 0x282fa2(%rip), %rdx    # 0x30d0d0
movb $0xb, (%rdx)
orl $0x20, %ecx
movl %ecx, (%rax)
jmp 0x8a142
leaq 0x282f91(%rip), %rax    # 0x30d0d0
movb $0x7, (%rax)
leaq 0x2832c4(%rip), %rax    # 0x30d40d
movb $0x16, (%rax)
callq 0x810b1
testl %eax, %eax
je 0x8a17d
leaq 0x2b18e4(%rip), %rdi    # 0x33ba40
callq 0x98c6
shrl $0x6, %eax
andl $0x2, %eax
leaq 0x282aea(%rip), %rcx    # 0x30cc58
movl %eax, (%rcx)
leaq 0x282ae5(%rip), %rax    # 0x30cc5c
movl $0x21, (%rax)
callq 0x810b1
testl %eax, %eax
je 0x8a210
leaq 0x2b18af(%rip), %rdi    # 0x33ba40
callq 0x98c6
leaq 0x28303b(%rip), %rcx    # 0x30d1d8
movl (%rcx), %edx
andl $-0xa, %edx
movl %eax, %esi
shrl $0x4, %esi
movl %esi, %edi
andl $0x1, %edi
orl %edx, %edi
leaq 0x28307b(%rip), %rdx    # 0x30d230
movl $0x22c, (%rdx)          # imm = 0x22C
movl %eax, %edx
shrl $0x3, %edx
andl $0x8, %edx
orl %edi, %edx
movl %edx, (%rcx)
leaq 0x2830c2(%rip), %rcx    # 0x30d290
movl $0x1, (%rcx)
leaq 0x282ff5(%rip), %rcx    # 0x30d1d0
movl (%rcx), %edx
andl $-0x19, %edx
movl %eax, %edi
andl $0x8, %edi
andl $0x8, %esi
leal (%rsi,%rdi,2), %esi
orl %edx, %esi
movl %esi, (%rcx)
leaq 0x2830b2(%rip), %rcx    # 0x30d2a8
movl $0x4d, (%rcx)
andl $0x2, %eax
movl $0xa, %ecx
cmovel %eax, %ecx
leaq 0x283289(%rip), %rax    # 0x30d497
movb %cl, (%rax)
cmpl $0x0, 0x2e29e5(%rip)    # 0x36cbfc
je 0x8a21e
callq 0x81f3d
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq