// File: /workspace/github_cpp_makefile_star2_O2/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 0x901d3(%rip), %rdi     # 0x10d698
callq 0x520bf
callq 0x75767
callq 0x75767
testl %eax, %eax
je 0x7d53f
cmpl $0x0, 0x2d971d(%rip)    # 0x356bfc
je 0x7d53f
leaq 0x27a018(%rip), %r15    # 0x2f7500
movq %r15, (%rsp)
leaq 0x2a854d(%rip), %rdi    # 0x325a40
leaq 0x8ac4d(%rip), %rsi     # 0x108147
leaq 0x27a007(%rip), %rbx    # 0x2f7508
leaq 0x279ffc(%rip), %r14    # 0x2f7504
leaq -0x19(%rbp), %rcx
movq %rbx, %rdx
movq %r14, %r8
movq %rcx, %r9
xorl %eax, %eax
callq 0x9350
movl (%rbx), %eax
leaq 0x279fab(%rip), %rcx    # 0x2f74d0
movl %eax, (%rcx)
movl (%r14), %eax
leaq 0x279f9b(%rip), %rcx    # 0x2f74cc
movl %eax, (%rcx)
movl (%r15), %eax
leaq 0x279f8b(%rip), %rcx    # 0x2f74c8
movl %eax, (%rcx)
callq 0x75767
testl %eax, %eax
setne %cl
movl 0x2d96ad(%rip), %eax    # 0x356bfc
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7d5d4
leaq 0x279fb2(%rip), %r15    # 0x2f7514
movq %r15, (%rsp)
leaq 0x2a84d3(%rip), %rdi    # 0x325a40
leaq 0x8abd3(%rip), %rsi     # 0x108147
leaq 0x279f91(%rip), %rbx    # 0x2f750c
leaq 0x279f8e(%rip), %r14    # 0x2f7510
leaq -0x19(%rbp), %rcx
movq %rbx, %rdx
movq %r14, %r8
movq %rcx, %r9
xorl %eax, %eax
callq 0x9350
movl (%r15), %eax
leal 0x76c(%rax), %ecx
leal 0x7d0(%rax), %edx
cmpl $0x50, %eax
cmovgel %ecx, %edx
movl %edx, (%r15)
movl (%r14), %eax
leaq 0x279f20(%rip), %rcx    # 0x2f74d8
movl %eax, (%rcx)
movl (%rbx), %eax
leaq 0x279f11(%rip), %rcx    # 0x2f74d4
movl %eax, (%rcx)
leaq 0x279f10(%rip), %rax    # 0x2f74dc
movl %edx, (%rax)
movl 0x2d9628(%rip), %eax    # 0x356bfc
leaq 0x279ee2(%rip), %rcx    # 0x2f74bd
cmpb $0x0, (%rcx)
jne 0x7d5e9
testl %eax, %eax
je 0x7d5e9
callq 0x554d3
callq 0x75767
testl %eax, %eax
je 0x7d608
leaq 0x2a8447(%rip), %rdi    # 0x325a40
callq 0x98b2
leaq 0x279e9f(%rip), %rax    # 0x2f74a4
andb $-0x5, (%rax)
callq 0x75767
testl %eax, %eax
je 0x7d645
leaq 0x2a8428(%rip), %rax    # 0x325a40
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x7d645
leaq 0x2a8416(%rip), %rdi    # 0x325a40
callq 0x95e0
leaq 0x27a856(%rip), %rcx    # 0x2f7e8c
movl %eax, (%rcx)
leaq 0x27a851(%rip), %rax    # 0x2f7e90
movl $0x2, (%rax)
callq 0x75767
testl %eax, %eax
je 0x7d6ab
leaq 0x2a83eb(%rip), %rax    # 0x325a40
movzbl (%rax), %edx
leaq 0x279b79(%rip), %rax    # 0x2f71d8
movl (%rax), %ecx
movl %ecx, %esi
andl $-0x21, %esi
movb %dl, -0x19(%rbp)
movl %esi, (%rax)
cmpl $0x32, %edx
je 0x7d697
cmpl $0x31, %edx
je 0x7d686
cmpl $0x30, %edx
jne 0x7d6ab
leaq 0x279a4f(%rip), %rax    # 0x2f70d0
movb $0x4, (%rax)
jmp 0x7d6a1
leaq 0x279a43(%rip), %rdx    # 0x2f70d0
movb $0xb, (%rdx)
orl $0x20, %ecx
movl %ecx, (%rax)
jmp 0x7d6a1
leaq 0x279a32(%rip), %rax    # 0x2f70d0
movb $0x7, (%rax)
leaq 0x279d65(%rip), %rax    # 0x2f740d
movb $0x16, (%rax)
callq 0x75767
testl %eax, %eax
je 0x7d6dc
leaq 0x2a8385(%rip), %rdi    # 0x325a40
callq 0x98b2
shrl $0x6, %eax
andl $0x2, %eax
leaq 0x27958b(%rip), %rcx    # 0x2f6c58
movl %eax, (%rcx)
leaq 0x279586(%rip), %rax    # 0x2f6c5c
movl $0x21, (%rax)
callq 0x75767
testl %eax, %eax
je 0x7d76d
leaq 0x2a8350(%rip), %rdi    # 0x325a40
callq 0x98b2
leaq 0x279adc(%rip), %rcx    # 0x2f71d8
movl (%rcx), %edx
andl $-0xa, %edx
movl %eax, %esi
shrl $0x4, %esi
movl %esi, %edi
andl $0x1, %edi
orl %edx, %edi
leaq 0x279b1c(%rip), %rdx    # 0x2f7230
movl $0x22c, (%rdx)          # imm = 0x22C
movl %eax, %edx
shrl $0x3, %edx
andl $0x8, %edx
orl %edi, %edx
movl %edx, (%rcx)
leaq 0x279b63(%rip), %rcx    # 0x2f7290
movl $0x1, (%rcx)
leaq 0x279a96(%rip), %rcx    # 0x2f71d0
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 0x279b53(%rip), %rcx    # 0x2f72a8
movl $0x4d, (%rcx)
andl $0x2, %eax
pushq $0xa
popq %rcx
cmovel %eax, %ecx
leaq 0x279d2c(%rip), %rax    # 0x2f7497
movb %cl, (%rax)
cmpl $0x0, 0x2d9488(%rip)    # 0x356bfc
je 0x7d77b
callq 0x7650a
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq