// File: /workspace/github_cpp_makefile_star2_O2/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 0x2c1089(%rip), %rax    # 0x32101a
leaq 0x1c8fa6(%rip), %rcx    # 0x228f3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x604e8
movl %edi, %ebx
leaq 0x1a2925(%rip), %r14    # 0x2028d0
movq (%r14), %rax
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
cmpl $0x21, %edi
setge %dl
testl %edi, %edi
js 0x604e8
andb %cl, %dl
jne 0x604e8
cmpq $0x20, %rax
je 0x600c9
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x60067
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x60121
leaq 0x2970e2(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x2970dd(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x601cc
leaq 0x297d70(%rip), %rax    # 0x2f7d88
movl (%rax), %r8d
leaq 0x297d6a(%rip), %r10    # 0x2f7d8c
movl (%r10), %edi
leaq 0x297d68(%rip), %r14    # 0x2f7d94
movl (%r14), %esi
leaq 0x297d62(%rip), %rdx    # 0x2f7d98
orl $-0x1, (%rax)
movl (%rdx), %r13d
orl $-0x1, (%r10)
leaq 0x297d49(%rip), %r11    # 0x2f7d90
orl $-0x1, (%r14)
movl (%r11), %r12d
orl $-0x1, (%rdx)
orl $-0x1, (%r11)
cmpl $0x20, %ebx
ja 0x601e1
decl %ebx
movl %ebx, %ecx
jmp 0x60208
leaq 0x29706e(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x297069(%rip), %rax    # 0x2f70e0
leal -0x1(%rbx), %ecx
pushq $-0x2
popq %rdx
roll %cl, %edx
movl $0x1, (%rax)
testl %ebx, %ebx
cmovel %ebx, %edx
leaq 0x2c618f(%rip), %rbx    # 0x326220
leaq 0xaaa52(%rip), %rsi     # 0x10aaea
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x578d5
callq 0x56b1c
leaq 0xaa963(%rip), %rdi     # 0x10aa19
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x578d5
leaq 0x29700c(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x297007(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
leaq 0xaa9f5(%rip), %rdi     # 0x10aadb
callq 0x59a28
xorl %edi, %edi
callq 0x523f2
leal -0x1(%rbx), %ecx
pushq $-0x2
popq %rdi
roll %cl, %edi
testl %ebx, %ebx
cmovel %ebx, %edi
callq 0x525e2
callq 0x59aab
callq 0x56b1c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5fe46
cmpq $0x10, %rax
jne 0x60170
leaq 0x1a4eb2(%rip), %rcx    # 0x204fe0
cmpl $0x4e, (%rcx)
jne 0x60170
leaq 0x296fa2(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x296f9d(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x60338
leaq 0xaa99e(%rip), %rdi     # 0x10aaf6
pushq $0x1e
popq %rsi
callq 0x576d4
leaq 0x2c60b9(%rip), %r14    # 0x326220
leaq 0xaa99e(%rip), %rsi     # 0x10ab0c
jmp 0x601b5
cmpq $0x10, %rax
jne 0x6028d
leaq 0x296f5b(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x296f56(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x60370
leaq 0xaaa3d(%rip), %rdi     # 0x10abdc
pushq $0x1e
popq %rsi
callq 0x576d4
leaq 0x2c6072(%rip), %r14    # 0x326220
leaq 0xaaa3d(%rip), %rsi     # 0x10abf2
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
pushq $0x20
popq %rsi
movq %r14, %rdi
jmp 0x60398
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x60546
leal -0x41(%rbx), %ecx
movq %r10, %rax
cmpl $0x1c, %ecx
jb 0x60208
leal -0x5d(%rbx), %ecx
movq %r14, %rax
cmpl $0x7, %ecx
jb 0x60208
cmpl $0x33, %ebx
ja 0x604c6
addl $-0x21, %ebx
movl %ebx, %ecx
movq %rdx, %rax
pushq $-0x2
popq %rdx
roll %cl, %edx
movl %edx, (%rax)
leaq 0x296ea2(%rip), %rax    # 0x2f70b8
movss (%rax), %xmm1
movss 0x96ec6(%rip), %xmm0    # 0xf70e8
movl %edi, %r15d
movl $0xff, %edi
movl %esi, %ebx
movl $0xff, %esi
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
movl %r8d, %r14d
callq 0x55b65
leaq 0x297b3d(%rip), %rax    # 0x2f7d88
movl %r14d, (%rax)
leaq 0x297b37(%rip), %rax    # 0x2f7d8c
movl %r15d, (%rax)
leaq 0x297b35(%rip), %rax    # 0x2f7d94
movl %ebx, (%rax)
leaq 0x297b30(%rip), %rax    # 0x2f7d98
movl %r13d, (%rax)
leaq 0x297b1e(%rip), %rax    # 0x2f7d90
movl %r12d, (%rax)
movl $0x225f, %edi           # imm = 0x225F
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5e18e
cmpq $0x1, %rax
je 0x6043c
cmpq $0x8, %rax
je 0x603ba
cmpq $0x100, %rax            # imm = 0x100
je 0x60406
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x604e8
leaq 0x297ae9(%rip), %r14    # 0x2f7db0
movl (%r14), %r15d
leaq 0x297ae3(%rip), %r12    # 0x2f7db4
movl (%r12), %r13d
leal -0x1(%rbx), %eax
cmpl $0x1f, %eax
ja 0x6032c
decb %bl
pushq $-0x2
popq %rax
movl %ebx, %ecx
roll %cl, %eax
movl %eax, (%r14)
pushq $0x5a
popq %rdi
pushq $0x10
popq %rsi
callq 0x5d27d
leaq 0xaa497(%rip), %rdi     # 0x10a792
callq 0x5d2c0
movzbl (%r14), %edi
callq 0x523f2
movzbl 0x1(%r14), %edi
callq 0x523f2
movzbl 0x2(%r14), %edi
callq 0x523f2
movzbl 0x3(%r14), %edi
callq 0x523f2
callq 0x5d2f6
movl %r15d, (%r14)
movl %r13d, (%r12)
jmp 0x60275
leaq 0xaa7e5(%rip), %rdi     # 0x10ab24
pushq $0x20
popq %rbx
movl %ebx, %esi
callq 0x576d4
leaq 0xaa807(%rip), %rdi     # 0x10ab57
movl %ebx, %esi
callq 0x576d4
leaq 0xaa82c(%rip), %rdi     # 0x10ab8a
movl %ebx, %esi
callq 0x576d4
leaq 0xaa84e(%rip), %rdi     # 0x10abba
pushq $0x21
jmp 0x60397
leaq 0xaa891(%rip), %rdi     # 0x10ac08
pushq $0x1e
popq %rsi
callq 0x576d4
leaq 0xaa899(%rip), %rdi     # 0x10ac1f
pushq $0x20
popq %rsi
callq 0x576d4
leaq 0xaa8a1(%rip), %rdi     # 0x10ac36
pushq $0x16
popq %rsi
callq 0x576d4
leaq 0xaa825(%rip), %rdi     # 0x10abc9
pushq $0x1e
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x576d4
leaq 0x296d1b(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x296d16(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x60528
leaq 0xaa7fe(%rip), %rdi     # 0x10abdd
pushq $0x1e
popq %rsi
callq 0x576d4
leaq 0x2c5e32(%rip), %r14    # 0x326220
leaq 0xaa7fe(%rip), %rsi     # 0x10abf3
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
jmp 0x6052f
leaq 0x296ccf(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x296cca(%rip), %rax    # 0x2f70e0
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 0x60bb7
leaq 0x296c99(%rip), %rax    # 0x2f70dc
movl %ebx, (%rax)
leaq 0x296c94(%rip), %rax    # 0x2f70e0
movl $0x1, (%rax)
leaq 0x1a4b7b(%rip), %r15    # 0x204fd4
movl (%r15), %ecx
movl %ecx, %edx
xorl $0x41, %edx
leaq 0x1a2490(%rip), %rax    # 0x2028f8
movl (%rax), %eax
movl %eax, %esi
xorl $0x47, %esi
orl %edx, %esi
je 0x604b2
cmpl $0x41, %ecx
jne 0x60482
cmpl $0x33, %eax
je 0x6049d
cmpl $0x47, %eax
je 0x6049d
pushq $0x34
popq %rdi
callq 0x5707f
movzbl %bl, %edi
callq 0x523f2
callq 0x570f8
cmpq $0x1, (%r14)
jne 0x604e8
movl (%r15), %eax
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x604e8
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jae 0x604e8
testl %ebx, %ebx
jne 0x604f7
leaq 0x296c13(%rip), %rax    # 0x2f70d0
cmpb $0x1, (%rax)
jne 0x604f7
pushq $0x7
jmp 0x604f9
leaq 0x2978bb(%rip), %rax    # 0x2f7d88
movl %r8d, (%rax)
leaq 0x2978b5(%rip), %rax    # 0x2f7d8c
movl %edi, (%rax)
leaq 0x2978b4(%rip), %rax    # 0x2f7d94
movl %esi, (%rax)
movl %r13d, (%rdx)
movl %r12d, (%r11)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
movss 0x96be6(%rip), %xmm0    # 0xf70e8
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 0x55b65
leaq 0xaa6f1(%rip), %r14     # 0x10ac20
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x576d4
leaq 0xaa689(%rip), %rdi     # 0x10abca
jmp 0x603a4