// File: 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
subq $0x10, %rsp
leaq 0xca2d8(%rip), %rdi     # 0x186a37
callq 0x7add0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbc770
jmp 0xbc770
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbc7f0
cmpl $0x0, 0x30f64b(%rip)    # 0x3cbdcc
je 0xbc7ee
leaq 0x2de496(%rip), %rdi    # 0x39ac20
leaq 0xc6356(%rip), %rsi     # 0x182ae7
leaq 0x2aff50(%rip), %rdx    # 0x36c6e8
leaq -0x1(%rbp), %r9
leaq 0x2aff41(%rip), %r8     # 0x36c6e4
leaq 0x2aff36(%rip), %rax    # 0x36c6e0
movq %r9, %rcx
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9370
leaq 0x2aff29(%rip), %rax    # 0x36c6e8
movl (%rax), %ecx
leaq 0x2afee8(%rip), %rax    # 0x36c6b0
movl %ecx, (%rax)
leaq 0x2aff13(%rip), %rax    # 0x36c6e4
movl (%rax), %ecx
leaq 0x2afed2(%rip), %rax    # 0x36c6ac
movl %ecx, (%rax)
leaq 0x2afefd(%rip), %rax    # 0x36c6e0
movl (%rax), %ecx
leaq 0x2afebc(%rip), %rax    # 0x36c6a8
movl %ecx, (%rax)
jmp 0xbc7f0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbc8b6
cmpl $0x0, 0x30f5c7(%rip)    # 0x3cbdcc
je 0xbc8b4
leaq 0x2de40e(%rip), %rdi    # 0x39ac20
leaq 0xc62ce(%rip), %rsi     # 0x182ae7
leaq 0x2afecc(%rip), %rdx    # 0x36c6ec
leaq -0x1(%rbp), %r9
leaq 0x2afec5(%rip), %r8     # 0x36c6f0
leaq 0x2afec2(%rip), %rax    # 0x36c6f4
movq %r9, %rcx
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9370
leaq 0x2afead(%rip), %rax    # 0x36c6f4
cmpl $0x50, (%rax)
jge 0xbc866
leaq 0x2afea1(%rip), %rax    # 0x36c6f4
movl (%rax), %ecx
addl $0x7d0, %ecx            # imm = 0x7D0
leaq 0x2afe92(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
jmp 0xbc87e
leaq 0x2afe87(%rip), %rax    # 0x36c6f4
movl (%rax), %ecx
addl $0x76c, %ecx            # imm = 0x76C
leaq 0x2afe78(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
leaq 0x2afe6b(%rip), %rax    # 0x36c6f0
movl (%rax), %ecx
leaq 0x2afe2a(%rip), %rax    # 0x36c6b8
movl %ecx, (%rax)
leaq 0x2afe55(%rip), %rax    # 0x36c6ec
movl (%rax), %ecx
leaq 0x2afe14(%rip), %rax    # 0x36c6b4
movl %ecx, (%rax)
leaq 0x2afe4b(%rip), %rax    # 0x36c6f4
movl (%rax), %ecx
leaq 0x2afe0a(%rip), %rax    # 0x36c6bc
movl %ecx, (%rax)
jmp 0xbc8b6
leaq 0x2afde0(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xbc8d5
cmpl $0x0, 0x30f500(%rip)    # 0x3cbdcc
je 0xbc8d3
callq 0x7fc70
jmp 0xbc8d5
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbc938
leaq 0x2de33a(%rip), %rdi    # 0x39ac20
callq 0x98d0
movl %eax, -0x8(%rbp)
leaq 0x2afd8f(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x2afd83(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xbc925
leaq 0x2afd6f(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x2afd63(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xbc927
jmp 0xbc927
movl -0x8(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xbc934
jmp 0xbc936
jmp 0xbc936
jmp 0xbc938
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbc97c
leaq 0x2de2d7(%rip), %rax    # 0x39ac20
movsbl (%rax), %edi
callq 0x9330
cmpl $0x0, %eax
je 0xbc97a
leaq 0x2de2c3(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x2b0701(%rip), %rax    # 0x36d06c
movl %ecx, (%rax)
leaq 0x2b06fc(%rip), %rax    # 0x36d070
movl $0x2, (%rax)
jmp 0xbc97c
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbca21
leaq 0x2de28f(%rip), %rax    # 0x39ac20
movb (%rax), %al
movb %al, -0x1(%rbp)
leaq 0x2afa1b(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x21, %ecx
leaq 0x2afa0f(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
movsbl -0x1(%rbp), %eax
cmpl $0x30, %eax
jne 0xbc9ca
leaq 0x2af8f5(%rip), %rax    # 0x36c2b0
movb $0x4, (%rax)
leaq 0x2afc28(%rip), %rax    # 0x36c5ed
movb $0x16, (%rax)
jmp 0xbca1f
movsbl -0x1(%rbp), %eax
cmpl $0x31, %eax
jne 0xbc9fe
leaq 0x2af8d6(%rip), %rax    # 0x36c2b0
movb $0xb, (%rax)
leaq 0x2af9d4(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x20, %ecx
leaq 0x2af9c8(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2afbf4(%rip), %rax    # 0x36c5ed
movb $0x16, (%rax)
jmp 0xbca1d
movsbl -0x1(%rbp), %eax
cmpl $0x32, %eax
jne 0xbca1b
leaq 0x2af8a2(%rip), %rax    # 0x36c2b0
movb $0x7, (%rax)
leaq 0x2afbd5(%rip), %rax    # 0x36c5ed
movb $0x16, (%rax)
jmp 0xbca1d
jmp 0xbca1f
jmp 0xbca21
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbca70
leaq 0x2de1ee(%rip), %rdi    # 0x39ac20
callq 0x98d0
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xbca56
leaq 0x2af3ea(%rip), %rax    # 0x36be38
movl $0x2, (%rax)
jmp 0xbca63
leaq 0x2af3db(%rip), %rax    # 0x36be38
movl $0x0, (%rax)
leaq 0x2af3d2(%rip), %rax    # 0x36be3c
movl $0x21, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcbb5
leaq 0x2de19b(%rip), %rdi    # 0x39ac20
callq 0x98d0
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xbcaaf
leaq 0x2af919(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2af90d(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
jmp 0xbcac4
leaq 0x2af902(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x2, %ecx
leaq 0x2af8f6(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2af945(%rip), %rax    # 0x36c410
movl $0x22c, (%rax)          # imm = 0x22C
movl -0x8(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xbcaf3
leaq 0x2af8d5(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x8, %ecx
leaq 0x2af8c9(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
jmp 0xbcb08
leaq 0x2af8be(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x9, %ecx
leaq 0x2af8b2(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2af961(%rip), %rax    # 0x36c470
movl $0x1, (%rax)
movl -0x8(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xbcb37
leaq 0x2af889(%rip), %rax    # 0x36c3b0
movl (%rax), %ecx
orl $0x10, %ecx
leaq 0x2af87d(%rip), %rax    # 0x36c3b0
movl %ecx, (%rax)
jmp 0xbcb4c
leaq 0x2af872(%rip), %rax    # 0x36c3b0
movl (%rax), %ecx
andl $-0x11, %ecx
leaq 0x2af866(%rip), %rax    # 0x36c3b0
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xbcb70
leaq 0x2af850(%rip), %rax    # 0x36c3b0
movl (%rax), %ecx
orl $0x8, %ecx
leaq 0x2af844(%rip), %rax    # 0x36c3b0
movl %ecx, (%rax)
jmp 0xbcb85
leaq 0x2af839(%rip), %rax    # 0x36c3b0
movl (%rax), %ecx
andl $-0x9, %ecx
leaq 0x2af82d(%rip), %rax    # 0x36c3b0
movl %ecx, (%rax)
leaq 0x2af8fc(%rip), %rax    # 0x36c488
movl $0x4d, (%rax)
movl -0x8(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xbcba9
leaq 0x2afad3(%rip), %rax    # 0x36c677
movb $0xa, (%rax)
jmp 0xbcbb3
leaq 0x2afac7(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
jmp 0xbcbb5
cmpl $0x0, 0x30f210(%rip)    # 0x3cbdcc
je 0xbcbcd
movl $0x1, %edi
movl $0x22ad, %esi           # imm = 0x22AD
callq 0xb1ef0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)