// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: set_single_sat(int)
void set_single_sat(int prn)
{
u32 val;
u32 old_gps;
u32 old_glonass;
u32 old_qzss;
u32 old_sbas;
u32 old_galileo;

   if(read_only) return;
   if(luxor) return;

   if(rcvr_type == ESIP_RCVR) ;
   else if(prn > 32) return;
   if(prn < 0) return;

   if(rcvr_type == ESIP_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn == 0) {
         exclude_sat(0);  // restore all sats
      }
      else {  // delete selected sat
         old_gps = esip_deleted_gps;
         old_glonass = esip_deleted_glonass;  
         old_qzss = esip_deleted_qzss;  
         old_sbas = esip_deleted_sbas;  
         old_galileo = esip_deleted_galileo;  

         esip_deleted_gps = 0xFFFFFFFF;
         esip_deleted_glonass = 0xFFFFFFFF;
         esip_deleted_qzss = 0xFFFFFFFF;
         esip_deleted_sbas = 0xFFFFFFFF;
         esip_deleted_galileo = 0xFFFFFFFF;

         if((prn >= 1) && (prn <= 32)) {  // delete gps sat
            esip_deleted_gps &= (~(1U << (prn-1)));
         }
         else if((prn >= 65) && (prn <= 92)) {  // delete glonass sat
            esip_deleted_glonass &= (~(1U << (prn-65)));
         }
         else if((prn >= 93) && (prn <= 99)) {  // delete qzss sat
            esip_deleted_qzss &= (~(1U << (prn-93)));
         }
         else if((prn >= 33) && (prn <= 51)) {  // delete sbas sat
            esip_deleted_sbas &= (~(1U << (prn-33)));
         }
         else if(0 && (prn >= 211) && (prn <= 230)) {  // delete galileo sat !!!!!! what are galileo PRN's?
            esip_deleted_galileo &= (~(1U << (prn-211)));
         }
         else {
            esip_deleted_gps = old_gps;
            esip_deleted_glonass = old_glonass;  
            esip_deleted_qzss = old_qzss;  
            esip_deleted_sbas = old_sbas;  
            esip_deleted_galileo = old_galileo;  
            return;
         }

         set_amu_mask(amu_mask);     // this will set the sat disable flags

         esip_deleted_gps = old_gps;
         esip_deleted_glonass = old_glonass;  
         esip_deleted_qzss = old_qzss;  
         esip_deleted_sbas = old_sbas;  
         esip_deleted_galileo = old_galileo;  

         request_rcvr_config(8799);
      }
   }
   else if(rcvr_type == FURUNO_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn) {
         val = 1 << (prn-1);
      }
      else {
         val = 0xFFFFFFFF;
      }
      val ^= 0xFFFFFFFF;

      sprintf(out, "GPset,U%08X", val);
      send_furuno_cmd(out);

      reset_sat_tracking();
      send_furuno_cmd("GPsrq");
   }
   else if(rcvr_type == MOTO_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      send_moto_start("Am");
      send_byte(0);
      if(prn) {
         val = 1 << (prn-1);
         val = (~val);
      }
      else {
         val = 0;
      }
      send_dword(val);
      send_moto_end();

      reset_sat_tracking();
      request_sat_health();
   }
   else if((rcvr_type == SCPI_RCVR) && (scpi_type == NORTEL_TYPE)) { 
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn) {
         queue_scpi_cmd("GPS:SAT:TRAC:IGNORE 0", SCPI_IGNORE_MSG);
         sprintf(out,"GPS:SAT:TRAC:INCLUDE %d", prn);
         queue_scpi_cmd(out,  SCPI_INCLUDE_MSG);
      }
      else {
         queue_scpi_cmd("GPS:SAT:TRAC:INCLUDE 1,2,3,4,5,6,7,8,9,10,11,12,13", SCPI_INCLUDE_MSG);
         queue_scpi_cmd("GPS:SAT:TRAC:INCLUDE 14,15,16,17,18,19,20,21,22,23", SCPI_INCLUDE_MSG);
         queue_scpi_cmd("GPS:SAT:TRAC:INCLUDE 24,25,26,27,28,29,30,31,32", SCPI_INCLUDE_MSG);
         queue_scpi_cmd("SYNC:IMMEDIATE", SCPI_JAMSYNC_MSG);
      }
      queue_scpi_cmd(":GPS:SAT:TRAC:IGN?", SCPI_IGNORE_MSG);
   }
   else if(rcvr_type == SCPI_RCVR) {  // no NORTEL_TYPE
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn) {
         queue_scpi_cmd(":GPS:SAT:TRAC:IGN:ALL", SCPI_IGNORE_MSG);
         sprintf(out,":GPS:SAT:TRAC:INCL %d", prn);
         queue_scpi_cmd(out,  SCPI_INCLUDE_MSG);
      }
      else {
         queue_scpi_cmd(":GPS:SAT:TRAC:IGN:NONE", SCPI_IGNORE_MSG);
         queue_scpi_cmd(":GPS:SAT:TRAC:INCL:ALL", SCPI_INCLUDE_MSG);
         queue_scpi_cmd(":SYNC:HOLD:REC:INIT", SCPI_HOLDOVER_MSG);    // ggggggg
      }
      queue_scpi_cmd(":GPS:SAT:TRAC:IGN?", SCPI_IGNORE_MSG);
   }
   else if(rcvr_type == SS_RCVR) {
      old_gps = ss_deleted_gps;
      old_sbas = ss_deleted_sbas;  

      if(prn <= 0) {  // restore all sats
         ss_deleted_gps = 0;
         ss_deleted_sbas = 0;  
      }
      else if((prn >= 1) && (prn <= 32)) {  // delete all byr one gps sat
         ss_deleted_gps = (1U << (prn-1));
         ss_deleted_gps = (~ss_deleted_gps);
         send_ss_start(90, 16);
         send_ss_string("UGPS-000");
         send_byte((ss_deleted_gps >> 0) & 0xFF);
         send_byte((ss_deleted_gps >> 8) & 0xFF);
         send_byte((ss_deleted_gps >> 16) & 0xFF);
         send_byte((ss_deleted_gps >> 24) & 0xFF);
         send_ss_end();
      }
      else if(0 && (prn >= 120) && (prn <= 138)) {  // !!!!! this needs work - delete sbas sat
         ss_deleted_sbas |= (1U << (prn-33));
         ss_deleted_sbas = (~ss_deleted_sbas);
         send_ss_start(90, 16);
         send_ss_string("UGPS-0G5");
         send_byte((ss_deleted_gps >> 0) & 0xFF);
         send_byte((ss_deleted_gps >> 8) & 0xFF);
         send_byte((ss_deleted_gps >> 16) & 0xFF);
         send_byte((ss_deleted_gps >> 24) & 0xFF);
         send_ss_end();
      }

      ss_deleted_gps = old_gps;
      ss_deleted_sbas = old_sbas;  
      request_rcvr_config(8799);
   }
   else if(rcvr_type == UCCM_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn) {
         queue_uccm_cmd("GPS:SAT:TRAC:IGN:ALL", SCPI_IGNORE_MSG);
         sprintf(out,"GPS:SAT:TRAC:INCL %d", prn);
         queue_uccm_cmd(out,  SCPI_INCLUDE_MSG);
      }
      else {
         queue_uccm_cmd("GPS:SAT:TRAC:INCL:ALL", SCPI_INCLUDE_MSG);
// queue_uccm_cmd("SYNC:HOLD:REC:INIT", SCPI_HOLDOVER_MSG);    // ggggggg
      }
      queue_uccm_cmd("GPS:SAT:TRAC:IGN?", SCPI_IGNORE_MSG);
   }
   else if(rcvr_type == TSIP_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      if(!ACU_GG && !ACU_360) {
         send_tsip_start(0x34);
         send_byte((u08) prn);
         send_tsip_end();
      }

      if(SV6_FAMILY) {
         if((prn == 0) && (rcvr_mode == RCVR_MODE_SINGLE)) { // exit single sat mode
            set_rcvr_mode(RCVR_MODE_HOLD);
         }
         else {
            set_rcvr_mode(RCVR_MODE_SINGLE);
         }
      }
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      single_sat_prn = prn;
      have_single_prn = 1;
      if(prn) {
         val = 1 << (prn-1);
      }
      else {
         val = 0xFFFFFFFF;
      }

      set_zod_sat_mask(val);
   }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x2ce4ac(%rip), %rax    # 0x33701a
leaq 0x1d63c9(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x69160
movl %edi, %ebx
leaq 0x1afd48(%rip), %r14    # 0x2188d0
movq (%r14), %rax
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
cmpl $0x21, %edi
setge %dl
testl %edi, %edi
js 0x69160
andb %cl, %dl
jne 0x69160
cmpq $0x20, %rax
je 0x68cd1
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x68c49
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x68d4f
leaq 0x2a4505(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4500(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68e00
leaq 0x2a5193(%rip), %r11    # 0x30dd88
movl (%r11), %r14d
leaq 0x2a518d(%rip), %r15    # 0x30dd8c
movl (%r15), %r10d
leaq 0x2a518b(%rip), %r12    # 0x30dd94
movl (%r12), %edi
leaq 0x2a5184(%rip), %rdx    # 0x30dd98
movl (%rdx), %r13d
leaq 0x2a5172(%rip), %rsi    # 0x30dd90
movl (%rsi), %r9d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%r11)
movl %eax, (%r15)
movl %eax, (%r12)
movl %eax, (%rdx)
movl %eax, (%rsi)
cmpl $0x20, %ebx
ja 0x68e15
decl %ebx
movl %ebx, %ecx
movq %r11, %rax
jmp 0x68e3c
leaq 0x2a448c(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4487(%rip), %rax    # 0x30d0e0
leal -0x1(%rbx), %ecx
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
roll %cl, %edx
movl $0x1, (%rax)
testl %ebx, %ebx
cmovel %ebx, %edx
leaq 0x2d35ab(%rip), %rbx    # 0x33c220
leaq 0xb7f26(%rip), %rsi     # 0x120ba2
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5eff8
movl $0x218, %eax            # imm = 0x218
leaq 0x1d6313(%rip), %rcx    # 0x23efb0
movl %r14d, (%rcx,%rax)
movl %r14d, -0x1fc(%rcx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x68c9d
leaq 0xb7e13(%rip), %rdi     # 0x120ad1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5eff8
leaq 0x2a4404(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a43ff(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
leaq 0xb7ea5(%rip), %rdi     # 0x120b93
callq 0x6160d
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x590f7
leal -0x1(%rbx), %ecx
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
roll %cl, %edi
testl %ebx, %ebx
cmovel %ebx, %edi
callq 0x592eb
callq 0x61688
movl $0x218, %eax            # imm = 0x218
leaq 0x1d628e(%rip), %rcx    # 0x23efb0
movl %r14d, (%rcx,%rax)
movl %r14d, -0x1fc(%rcx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x68d22
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x689df
cmpq $0x10, %rax
jne 0x68da0
leaq 0x1b2284(%rip), %rcx    # 0x21afe0
cmpl $0x4e, (%rcx)
jne 0x68da0
leaq 0x2a4374(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a436f(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68f31
leaq 0xb7e28(%rip), %rdi     # 0x120bae
movl $0x1e, %esi
callq 0x5edda
leaq 0x2d3489(%rip), %r14    # 0x33c220
leaq 0xb7e26(%rip), %rsi     # 0x120bc4
jmp 0x68de7
cmpq $0x10, %rax
jne 0x68ec3
leaq 0x2a432b(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4326(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x69012
leaq 0xb7ec5(%rip), %rdi     # 0x120c94
movl $0x1e, %esi
callq 0x5edda
leaq 0x2d3440(%rip), %r14    # 0x33c220
leaq 0xb7ec3(%rip), %rsi     # 0x120caa
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
movl $0x20, %esi
jmp 0x69040
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x691c2
leal -0x41(%rbx), %ecx
movq %r15, %rax
cmpl $0x1c, %ecx
jb 0x68e3c
leal -0x5d(%rbx), %ecx
movq %r12, %rax
cmpl $0x7, %ecx
jb 0x68e3c
cmpl $0x33, %ebx
ja 0x6913d
addl $-0x21, %ebx
movl %ebx, %ecx
movq %rdx, %rax
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
roll %cl, %edx
movl %edx, (%rax)
leaq 0x2a426c(%rip), %rax    # 0x30d0b8
movss (%rax), %xmm1
movss 0xa4210(%rip), %xmm0    # 0x10d068
movl %edi, %ebx
movl $0xff, %edi
movl $0xff, %esi
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
movl %r9d, %r12d
movl %r10d, %r15d
callq 0x5cf59
leaq 0x2a4f07(%rip), %rax    # 0x30dd88
movl %r14d, (%rax)
leaq 0x2a4f01(%rip), %rax    # 0x30dd8c
movl %r15d, (%rax)
leaq 0x2a4eff(%rip), %rax    # 0x30dd94
movl %ebx, (%rax)
leaq 0x2a4efa(%rip), %rax    # 0x30dd98
movl %r13d, (%rax)
leaq 0x2a4ee8(%rip), %rax    # 0x30dd90
movl %r12d, (%rax)
movl $0x225f, %edi           # imm = 0x225F
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x667f2
cmpq $0xff, %rax
jg 0x68f75
cmpq $0x1, %rax
je 0x69064
cmpq $0x8, %rax
jne 0x69160
leaq 0x2a41f2(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a41ed(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x691a2
leaq 0xb7d8d(%rip), %rdi     # 0x120c95
movl $0x1e, %esi
callq 0x5edda
leaq 0x2d3307(%rip), %r14    # 0x33c220
leaq 0xb7d8b(%rip), %rsi     # 0x120cab
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
jmp 0x691a9
leaq 0xb7ca4(%rip), %rdi     # 0x120bdc
movl $0x20, %esi
callq 0x5edda
leaq 0xb7cc6(%rip), %rdi     # 0x120c0f
movl $0x20, %esi
callq 0x5edda
leaq 0xb7ce8(%rip), %rdi     # 0x120c42
movl $0x20, %esi
callq 0x5edda
leaq 0xb7d07(%rip), %rdi     # 0x120c72
movl $0x21, %esi
jmp 0x69040
cmpq $0x100, %rax            # imm = 0x100
je 0x69107
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x69160
leaq 0x2a4e15(%rip), %r14    # 0x30ddb0
movl (%r14), %r15d
leaq 0x2a4e0f(%rip), %r12    # 0x30ddb4
movl (%r12), %r13d
leal -0x1(%rbx), %eax
cmpl $0x1f, %eax
ja 0x69006
decb %bl
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %ebx, %ecx
roll %cl, %eax
movl %eax, (%r14)
movl $0x5a, %edi
movl $0x10, %esi
callq 0x65608
leaq 0xb7875(%rip), %rdi     # 0x12084a
callq 0x6564e
movzbl (%r14), %edi
callq 0x590f7
movzbl 0x1(%r14), %edi
callq 0x590f7
movzbl 0x2(%r14), %edi
callq 0x590f7
movzbl 0x3(%r14), %edi
callq 0x590f7
callq 0x65696
movl %r15d, (%r14)
movl %r13d, (%r12)
jmp 0x68eab
leaq 0xb7ca7(%rip), %rdi     # 0x120cc0
movl $0x1e, %esi
callq 0x5edda
leaq 0xb7cad(%rip), %rdi     # 0x120cd7
movl $0x20, %esi
callq 0x5edda
leaq 0xb7cb3(%rip), %rdi     # 0x120cee
movl $0x16, %esi
callq 0x5edda
leaq 0xb7c35(%rip), %rdi     # 0x120c81
movl $0x1e, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5edda
leaq 0x2a4071(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a406c(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
leaq 0x1b1f53(%rip), %r15    # 0x21afd4
movl (%r15), %ecx
movl %ecx, %edx
xorl $0x41, %edx
leaq 0x1af868(%rip), %rax    # 0x2188f8
movl (%rax), %eax
movl %eax, %esi
xorl $0x47, %esi
orl %edx, %esi
je 0x690e4
cmpl $0x41, %ecx
jne 0x690aa
cmpl $0x33, %eax
je 0x690cb
cmpl $0x47, %eax
je 0x690cb
movl $0x34, %edi
callq 0x5e6be
movzbl %bl, %edi
callq 0x590f7
callq 0x5e73c
cmpq $0x1, (%r14)
jne 0x69160
movl (%r15), %eax
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x69160
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jae 0x69160
testl %ebx, %ebx
jne 0x6916f
leaq 0x2a3fdd(%rip), %rax    # 0x30d0d0
cmpb $0x1, (%rax)
jne 0x6916f
movss 0xa3f68(%rip), %xmm0    # 0x10d068
movl $0x7, %edi
jmp 0x6917c
leaq 0x2a3fce(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a3fc9(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
leal -0x1(%rbx), %eax
xorl %edi, %edi
cmpl $0x1, %ebx
sbbl %edi, %edi
btsl %eax, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x698b9
leaq 0x2a4c44(%rip), %rax    # 0x30dd88
movl %r14d, (%rax)
leaq 0x2a4c3e(%rip), %rax    # 0x30dd8c
movl %r10d, (%rax)
leaq 0x2a4c3c(%rip), %rax    # 0x30dd94
movl %edi, (%rax)
movl %r13d, (%rdx)
movl %r9d, (%rsi)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0xa3ef1(%rip), %xmm0    # 0x10d068
movl $0x1, %edi
movl $0xff, %esi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5cf59
leaq 0xb7b2f(%rip), %r14     # 0x120cd8
movq %r14, %rdi
movl $0x20, %esi
callq 0x5edda
leaq 0xb7ac5(%rip), %rdi     # 0x120c82
jmp 0x6904c