// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: get_ebolt_version()
void get_ebolt_version()
{   // ThunderBolt-E only
u08 rsvd1;
u08 major;
u08 minor;
u08 build;
u08 len;
int i;

   log_packet_id("Packet 0x1C (Tbolt-E version)");

   rev_month = rev_day = rev_hour = 0;
   rev_year = 0;

   subcode = tsip_byte();
   if(subcode == 0x81) {  // firmware version
      rsvd1 = tsip_byte();
      major = tsip_byte();
      minor = tsip_byte();
      build = tsip_byte();
      rev_month = tsip_byte();
      rev_day = tsip_byte();
      rev_year = tsip_word();
      len = tsip_byte();
  
      out[0] = 0;
      for(i=0; i<len; i++) {
         if(i >= MAX_TEXT_COLS) {
            tsip_byte();
            continue;
         }
         out[i] = tsip_byte();
         out[i+1] = 0;
      }
  
      strupr(out);
   }
   else if(subcode == 0x83) {  // hardware version
      ebolt_serno = tsip_dword();
      rev_day = tsip_byte();
      rev_month = tsip_byte();
      rev_year = tsip_word();
      rev_hour = tsip_byte();
      hw_code = tsip_word();
      len = tsip_byte();

      for(i=0; i<UNIT_LEN; i++) unit_name[i] = ' ';
      unit_name[UNIT_LEN] = 0;

      out[0] = 0;
      for(i=0; i<len; i++) {   // get hardware id
         if(i >= MAX_TEXT_COLS) {
            tsip_byte();
            continue;
         }
         out[i] = tsip_byte();  // string can have: ICM, RES SMT, RES360, ACUTIME
         out[i+1] = 0;
         if(i < UNIT_LEN) {
            unit_name[i] = out[i];
         }
      }

      strupr(out);
      if(ACU_GG) ;
      else if(ACU_360) ;       // ACUTIME GG/360 already detected
      else if(ACUTIME) ;  // ACUTIME already detected
      else if(PALISADE) ; // PALISADE already detected
      else if(res_t) ;    // res_t already detected
      else if(saw_icm) ;  // icm already detected
      else { // attempt to identify TSIP receiver type
         if(strstr(out, "ACUTIME")) {
            tsip_type = ACUTIME_TYPE;
            acu_type = '1';
            if(strstr(out, "360")) {  // Acutime 360
               acu_type = '3';
            }
            else if(strstr(out, "GG")) {  // Acutime GG
               acu_type = 'G';
            }

            config_msg_ofs();
            config_rcvr_plots();
         }
         else if(strstr(out, "ICM")) { // !!!!!! ICM RES SMT
            saw_icm = 1;
            saw_gpsdo = 2;
            config_msg_ofs();
            config_rcvr_plots();
         }
         else if(strstr(out, "PALISADE")) {  // PALISADE does not actually output 0x1C-83 messages
            tsip_type = PALISADE_TYPE;
            config_msg_ofs();
            config_rcvr_plots();
         }
         else if(strstr(out, "RESOLUTION")) {
            if(user_set_res_t) ;
            else if(strstr(out, "SMT")) res_t = RES_T_SMT;
            else                        res_t = RES_T;
            config_msg_ofs();
            config_rcvr_plots();
         }
         else if(strstr(out, "RES SMT")) {
            if(!user_set_res_t) res_t = RES_T_RES;
            config_msg_ofs();
            config_rcvr_plots();
         }
         else if(strstr(out, "RES360")) {
            if(!user_set_res_t) res_t = RES_T_360;
            config_msg_ofs();
            config_rcvr_plots();
         }
      }

      if(mini_t == 0) {
         if(strstr(out, "MINI")) {
            mini_t = 1;
            saw_mini = 1;
            config_msg_ofs();
            config_rcvr_plots();
         }
      }

      strncpy(unit_name, out, UNIT_LEN);
      unit_name[UNIT_LEN-1] = 0;
   }
   else {  // unknown
      //!!! process packet contents
   }

   check_tsip_end(1);   
   if(tsip_error) return;

   saw_ebolt();
   tbolt_e |= 0x08;
   saw_version |= 0x02;

   if(1) {  //!!!!!
      if(rev_month > 12) return;
      if(rev_month == 0) return;
      if(rev_day > 31) return;
      if(rev_day == 0) return;
      if(rev_year < 1990) return;
      if(rev_year > 2100) return;
      if(rev_hour > 24) return;
   }

   if(text_mode && first_key) return;
   if(zoom_screen) return;
   if(luxor) return;
   if(just_read) return;

   if(0 && (subcode == 0x83)) {  // !!! disabled since hw_code clashes with sn_prefix
      show_ebolt_info();
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xafdb6(%rip), %rdi     # 0x121959
callq 0x58e77
xorl %eax, %eax
movb %al, 0x2fa250(%rip)     # 0x36be00
movb %al, 0x2fa247(%rip)     # 0x36bdfd
movb %al, 0x2fa240(%rip)     # 0x36bdfc
movw $0x0, 0x2fa239(%rip)    # 0x36bdfe
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71bdb
leaq 0x1cd398(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x1cd37c(%rip), %rcx    # 0x23ef5e
movb %al, (%rcx)
cmpb $-0x7d, %al
je 0x71cfe
movzbl %al, %eax
cmpl $0x81, %eax
jne 0x71fac
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c10
leaq 0x1cd363(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c26
leaq 0x1cd34d(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c3c
leaq 0x1cd337(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c52
leaq 0x1cd321(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c68
leaq 0x1cd30b(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movb %al, 0x2fa18e(%rip)     # 0x36bdfc
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71c84
leaq 0x1cd2ef(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movb %al, 0x2fa173(%rip)     # 0x36bdfd
callq 0x588f0
movw %ax, 0x2fa168(%rip)     # 0x36bdfe
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71cac
leaq 0x1cd2c7(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x2ca56d(%rip), %rbx    # 0x33c220
movb $0x0, (%rbx)
andl $0xff, %eax
je 0x71ced
movl %eax, %r14d
xorl %r15d, %r15d
leaq 0x1cd2a6(%rip), %r12    # 0x23ef70
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71cdb
orb $0x8, (%r12)
movb %al, (%r15,%rbx)
movb $0x0, 0x1(%r15,%rbx)
incq %r15
cmpq %r15, %r14
jne 0x71cca
leaq 0x2ca52c(%rip), %rdi    # 0x33c220
callq 0x9899
jmp 0x71fac
callq 0x589b0
movl %eax, 0x2fa0fb(%rip)    # 0x36be04
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71d1f
leaq 0x1cd254(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movb %al, 0x2fa0d8(%rip)     # 0x36bdfd
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71d3b
leaq 0x1cd238(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movb %al, 0x2fa0bb(%rip)     # 0x36bdfc
callq 0x588f0
movw %ax, 0x2fa0b1(%rip)     # 0x36bdfe
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71d63
leaq 0x1cd210(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movb %al, 0x2fa097(%rip)     # 0x36be00
callq 0x588f0
leaq 0x29bc2d(%rip), %rcx    # 0x30d9a2
movw %ax, (%rcx)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71d8e
leaq 0x1cd1e5(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movaps 0xacc5b(%rip), %xmm0    # 0x11e9f0
leaq 0x2ca8a4(%rip), %rbx    # 0x33c640
movaps %xmm0, (%rbx)
movw $0x2020, 0x10(%rbx)     # imm = 0x2020
xorl %ecx, %ecx
movb %cl, 0x12(%rbx)
leaq 0x2ca46f(%rip), %r14    # 0x33c220
movb %cl, (%r14)
andl $0xff, %eax
je 0x71df5
movl %eax, %r15d
xorl %r12d, %r12d
leaq 0x1cd1a8(%rip), %r13    # 0x23ef70
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x71dd9
orb $0x8, (%r13)
movb %al, (%r12,%r14)
movb $0x0, 0x1(%r12,%r14)
cmpq $0x11, %r12
ja 0x71ded
movb %al, (%rbx,%r12)
incq %r12
cmpq %r12, %r15
jne 0x71dc8
leaq 0x2ca424(%rip), %rdi    # 0x33c220
callq 0x9899
leaq 0x1a6ac8(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x1, %rax
sete %sil
leaq 0x1a91ba(%rip), %r15    # 0x21afd4
movl (%r15), %ecx
cmpl $0x41, %ecx
sete %dl
andb %sil, %dl
leaq 0x1a6acb(%rip), %r12    # 0x2188f8
movl (%r12), %esi
cmpl $0x47, %esi
sete %dil
testb %dil, %dl
jne 0x71f57
testb %dl, %dl
je 0x71e5f
cmpl $0x33, %esi
je 0x71f57
cmpl $0x47, %esi
je 0x71f57
testb %dl, %dl
jne 0x71f57
cmpq $0x1, %rax
sete %al
cmpl $0x50, %ecx
sete %cl
testb %cl, %al
jne 0x71f57
leaq 0x1a6a89(%rip), %r14    # 0x218904
cmpb $0x0, (%r14)
jne 0x71f57
leaq 0x1cd0a1(%rip), %r13    # 0x23ef2d
cmpb $0x0, (%r13)
jne 0x71f57
leaq 0x2ca382(%rip), %rdi    # 0x33c220
leaq 0xafad2(%rip), %rsi     # 0x121977
callq 0x9090
testq %rax, %rax
je 0x71efe
movl $0x41, (%r15)
movl $0x31, (%r12)
leaq 0x2ca35b(%rip), %rdi    # 0x33c220
leaq 0xbcdbb(%rip), %rsi     # 0x12ec87
callq 0x9090
movl $0x33, %ecx
testq %rax, %rax
jne 0x71ef8
leaq 0x2ca33e(%rip), %rdi    # 0x33c220
leaq 0xbcd78(%rip), %rsi     # 0x12ec61
callq 0x9090
movl $0x47, %ecx
testq %rax, %rax
je 0x71f4d
movl %ecx, (%r12)
jmp 0x71f4d
leaq 0x2ca31b(%rip), %rdi    # 0x33c220
leaq 0xafa73(%rip), %rsi     # 0x12197f
callq 0x9090
testq %rax, %rax
je 0x71f2a
movb $0x1, (%r13)
leaq 0x1a9116(%rip), %rax    # 0x21b038
movl $0x2, (%rax)
jmp 0x71f4d
leaq 0x2ca2ef(%rip), %rdi    # 0x33c220
leaq 0xafa4b(%rip), %rsi     # 0x121983
callq 0x9090
testq %rax, %rax
je 0x71fe7
movl $0x50, (%r15)
callq 0x47650
callq 0x47ade
leaq 0x1ccfda(%rip), %r14    # 0x23ef38
cmpb $0x0, (%r14)
jne 0x71f94
leaq 0x2ca2b5(%rip), %rdi    # 0x33c220
leaq 0xafa34(%rip), %rsi     # 0x1219a6
callq 0x9090
testq %rax, %rax
je 0x71f94
movb $0x1, %al
movb %al, (%r14)
leaq 0x1ccfb5(%rip), %rcx    # 0x23ef3d
movb %al, (%rcx)
callq 0x47650
callq 0x47ade
leaq 0x2ca285(%rip), %rsi    # 0x33c220
movl $0x12, %edx
movq %rbx, %rdi
callq 0x9170
movb $0x0, 0x11(%rbx)
xorl %edi, %edi
callq 0x58f50
leaq 0x1ccfb6(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x71fd8
callq 0x5e1a6
leaq 0x1a6935(%rip), %rax    # 0x218900
orb $0x8, (%rax)
leaq 0x29b433(%rip), %rax    # 0x30d408
orb $0x2, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ca232(%rip), %rdi    # 0x33c220
leaq 0xaf997(%rip), %rsi     # 0x12198c
callq 0x9090
testq %rax, %rax
je 0x72032
leaq 0x1ccf26(%rip), %rax    # 0x23ef2c
cmpb $0x0, (%rax)
jne 0x71f4d
leaq 0x2ca20a(%rip), %rdi    # 0x33c220
leaq 0xaf97e(%rip), %rsi     # 0x12199b
callq 0x9090
cmpq $0x1, %rax
movb $0x2, %al
sbbb $0x0, %al
movb %al, (%r14)
jmp 0x71f4d
leaq 0x2ca1e7(%rip), %rdi    # 0x33c220
leaq 0xaf957(%rip), %rsi     # 0x121997
callq 0x9090
testq %rax, %rax
je 0x72063
leaq 0x1ccedb(%rip), %rax    # 0x23ef2c
cmpb $0x0, (%rax)
jne 0x71f4d
movb $0x3, (%r14)
jmp 0x71f4d
leaq 0x2ca1b6(%rip), %rdi    # 0x33c220
leaq 0xaf92e(%rip), %rsi     # 0x12199f
callq 0x9090
testq %rax, %rax
je 0x71f57
leaq 0x1ccea6(%rip), %rax    # 0x23ef2c
cmpb $0x0, (%rax)
jne 0x71f4d
movb $0x4, (%r14)
jmp 0x71f4d