// File: /workspace/github_cpp_makefile_star2_O1/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 0x996fb(%rip), %rdi     # 0x123670
callq 0x58e77
callq 0x811da
callq 0x811da
testl %eax, %eax
je 0x89fef
cmpl $0x0, 0x2e2c6d(%rip)    # 0x36cbfc
je 0x89fef
leaq 0x283568(%rip), %r15    # 0x30d500
movq %r15, (%rsp)
leaq 0x2b1a9d(%rip), %rdi    # 0x33ba40
leaq 0x94097(%rip), %rsi     # 0x11e041
leaq 0x283557(%rip), %rbx    # 0x30d508
leaq 0x28354c(%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 0x2834fb(%rip), %rcx    # 0x30d4d0
movl %eax, (%rcx)
movl (%r14), %eax
leaq 0x2834eb(%rip), %rcx    # 0x30d4cc
movl %eax, (%rcx)
movl (%r15), %eax
leaq 0x2834db(%rip), %rcx    # 0x30d4c8
movl %eax, (%rcx)
callq 0x811da
testl %eax, %eax
je 0x8a074
cmpl $0x0, 0x2e2bfd(%rip)    # 0x36cbfc
je 0x8a074
leaq 0x28350c(%rip), %r15    # 0x30d514
movq %r15, (%rsp)
leaq 0x2b1a2d(%rip), %rdi    # 0x33ba40
leaq 0x94027(%rip), %rsi     # 0x11e041
leaq 0x2834eb(%rip), %rbx    # 0x30d50c
leaq 0x2834e8(%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 0x28347a(%rip), %rcx    # 0x30d4d8
movl %eax, (%rcx)
movl (%rbx), %eax
leaq 0x28346b(%rip), %rcx    # 0x30d4d4
movl %eax, (%rcx)
leaq 0x28346a(%rip), %rax    # 0x30d4dc
movl %edx, (%rax)
leaq 0x283442(%rip), %rax    # 0x30d4bd
cmpb $0x0, (%rax)
jne 0x8a0b0
cmpl $0x0, 0x2e2b75(%rip)    # 0x36cbfc
je 0x8a0b0
leaq 0x283698(%rip), %rax    # 0x30d728
cvtsi2sdl (%rax), %xmm0
callq 0x5c907
leaq 0x283404(%rip), %rax    # 0x30d4a4
andb $-0x2, (%rax)
leaq 0x283322(%rip), %rax    # 0x30d3cc
movl $0x1, (%rax)
callq 0x811da
testl %eax, %eax
je 0x8a0cf
leaq 0x2b1980(%rip), %rdi    # 0x33ba40
callq 0x98c6
leaq 0x2833d8(%rip), %rax    # 0x30d4a4
andb $-0x5, (%rax)
callq 0x811da
testl %eax, %eax
je 0x8a10c
leaq 0x2b1961(%rip), %rax    # 0x33ba40
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x8a10c
leaq 0x2b194f(%rip), %rdi    # 0x33ba40
callq 0x95e0
leaq 0x283d8f(%rip), %rcx    # 0x30de8c
movl %eax, (%rcx)
leaq 0x283d8a(%rip), %rax    # 0x30de90
movl $0x2, (%rax)
callq 0x811da
testl %eax, %eax
je 0x8a172
leaq 0x2b1924(%rip), %rax    # 0x33ba40
movzbl (%rax), %edx
leaq 0x2830b2(%rip), %rax    # 0x30d1d8
movl (%rax), %ecx
movl %ecx, %esi
andl $-0x21, %esi
movb %dl, -0x19(%rbp)
movl %esi, (%rax)
cmpl $0x32, %edx
je 0x8a15e
cmpl $0x31, %edx
je 0x8a14d
cmpl $0x30, %edx
jne 0x8a172
leaq 0x282f88(%rip), %rax    # 0x30d0d0
movb $0x4, (%rax)
jmp 0x8a168
leaq 0x282f7c(%rip), %rdx    # 0x30d0d0
movb $0xb, (%rdx)
orl $0x20, %ecx
movl %ecx, (%rax)
jmp 0x8a168
leaq 0x282f6b(%rip), %rax    # 0x30d0d0
movb $0x7, (%rax)
leaq 0x28329e(%rip), %rax    # 0x30d40d
movb $0x16, (%rax)
callq 0x811da
testl %eax, %eax
je 0x8a1a3
leaq 0x2b18be(%rip), %rdi    # 0x33ba40
callq 0x98c6
shrl $0x6, %eax
andl $0x2, %eax
leaq 0x282ac4(%rip), %rcx    # 0x30cc58
movl %eax, (%rcx)
leaq 0x282abf(%rip), %rax    # 0x30cc5c
movl $0x21, (%rax)
callq 0x811da
testl %eax, %eax
je 0x8a236
leaq 0x2b1889(%rip), %rdi    # 0x33ba40
callq 0x98c6
leaq 0x283015(%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 0x283055(%rip), %rdx    # 0x30d230
movl $0x22c, (%rdx)          # imm = 0x22C
movl %eax, %edx
shrl $0x3, %edx
andl $0x8, %edx
orl %edi, %edx
movl %edx, (%rcx)
leaq 0x28309c(%rip), %rcx    # 0x30d290
movl $0x1, (%rcx)
leaq 0x282fcf(%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 0x28308c(%rip), %rcx    # 0x30d2a8
movl $0x4d, (%rcx)
andl $0x2, %eax
movl $0xa, %ecx
cmovel %eax, %ecx
leaq 0x283263(%rip), %rax    # 0x30d497
movb %cl, (%rax)
cmpl $0x0, 0x2e29bf(%rip)    # 0x36cbfc
je 0x8a244
callq 0x8201e
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq