// File: /workspace/github_cpp_makefile_star2_O1/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 0x2ce696(%rip), %rax    # 0x33701a
leaq 0x1d65b3(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x68f87
movl %edi, %ebx
leaq 0x1aff32(%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 0x68f87
andb %cl, %dl
jne 0x68f87
cmpq $0x20, %rax
je 0x68ae7
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x68a5f
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x68b65
leaq 0x2a46ef(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a46ea(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68c16
leaq 0x2a537d(%rip), %r11    # 0x30dd88
movl (%r11), %r14d
leaq 0x2a5377(%rip), %r15    # 0x30dd8c
movl (%r15), %r10d
leaq 0x2a5375(%rip), %r12    # 0x30dd94
movl (%r12), %edi
leaq 0x2a536e(%rip), %rdx    # 0x30dd98
movl (%rdx), %r13d
leaq 0x2a535c(%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
jg 0x68c2b
decl %ebx
movl %ebx, %ecx
movq %r11, %rax
jmp 0x68c52
leaq 0x2a4676(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4671(%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 0x2d3795(%rip), %rbx    # 0x33c220
leaq 0xb8030(%rip), %rsi     # 0x120ac2
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5f070
movl $0x218, %eax            # imm = 0x218
leaq 0x1d64fd(%rip), %rcx    # 0x23efb0
movl %r14d, (%rcx,%rax)
movl %r14d, -0x1fc(%rcx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x68ab3
leaq 0xb7f1d(%rip), %rdi     # 0x1209f1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f070
leaq 0x2a45ee(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a45e9(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
leaq 0xb7faf(%rip), %rdi     # 0x120ab3
callq 0x61694
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x591af
leal -0x1(%rbx), %ecx
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
roll %cl, %edi
testl %ebx, %ebx
cmovel %ebx, %edi
callq 0x593b5
callq 0x6170f
movl $0x218, %eax            # imm = 0x218
leaq 0x1d6478(%rip), %rcx    # 0x23efb0
movl %r14d, (%rcx,%rax)
movl %r14d, -0x1fc(%rcx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x68b38
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6879a
cmpq $0x10, %rax
jne 0x68bb6
leaq 0x1b246e(%rip), %rcx    # 0x21afe0
cmpl $0x4e, (%rcx)
jne 0x68bb6
leaq 0x2a455e(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4559(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68d47
leaq 0xb7f32(%rip), %rdi     # 0x120ace
movl $0x1e, %esi
callq 0x5ee52
leaq 0x2d3673(%rip), %r14    # 0x33c220
leaq 0xb7f30(%rip), %rsi     # 0x120ae4
jmp 0x68bfd
cmpq $0x10, %rax
jne 0x68cd9
leaq 0x2a4515(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4510(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68e2a
leaq 0xb7fcf(%rip), %rdi     # 0x120bb4
movl $0x1e, %esi
callq 0x5ee52
leaq 0x2d362a(%rip), %r14    # 0x33c220
leaq 0xb7fcd(%rip), %rsi     # 0x120bca
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
movl $0x20, %esi
jmp 0x68e58
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x68ffe
leal -0x41(%rbx), %ecx
movq %r15, %rax
cmpl $0x1c, %ecx
jb 0x68c52
leal -0x5d(%rbx), %ecx
movq %r12, %rax
cmpl $0x7, %ecx
jb 0x68c52
cmpl $0x33, %ebx
jg 0x68f64
addl $-0x21, %ebx
movl %ebx, %ecx
movq %rdx, %rax
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
roll %cl, %edx
movl %edx, (%rax)
leaq 0x2a4456(%rip), %rax    # 0x30d0b8
movss (%rax), %xmm1
movss 0xa4362(%rip), %xmm0    # 0x10cfd0
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 0x5d081
leaq 0x2a50f1(%rip), %rax    # 0x30dd88
movl %r14d, (%rax)
leaq 0x2a50eb(%rip), %rax    # 0x30dd8c
movl %r15d, (%rax)
leaq 0x2a50e9(%rip), %rax    # 0x30dd94
movl %ebx, (%rax)
leaq 0x2a50e4(%rip), %rax    # 0x30dd98
movl %r13d, (%rax)
leaq 0x2a50d2(%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 0x66617
cmpq $0xff, %rax
jg 0x68d8b
cmpq $0x1, %rax
je 0x68e7c
cmpq $0x8, %rax
jne 0x68f87
leaq 0x2a43dc(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a43d7(%rip), %rax    # 0x30d0e0
movl $0x1, (%rax)
testl %ebx, %ebx
je 0x68f96
leaq 0xb7e97(%rip), %rdi     # 0x120bb5
movl $0x1e, %esi
callq 0x5ee52
leaq 0x2d34f1(%rip), %r14    # 0x33c220
leaq 0xb7e95(%rip), %rsi     # 0x120bcb
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x9060
jmp 0x68f9d
leaq 0xb7dae(%rip), %rdi     # 0x120afc
movl $0x20, %esi
callq 0x5ee52
leaq 0xb7dd0(%rip), %rdi     # 0x120b2f
movl $0x20, %esi
callq 0x5ee52
leaq 0xb7df2(%rip), %rdi     # 0x120b62
movl $0x20, %esi
callq 0x5ee52
leaq 0xb7e11(%rip), %rdi     # 0x120b92
movl $0x21, %esi
jmp 0x68e58
cmpq $0x100, %rax            # imm = 0x100
je 0x68f2e
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x68f87
leaq 0x2a4fff(%rip), %r14    # 0x30ddb0
movl (%r14), %r15d
leaq 0x2a4ff9(%rip), %r12    # 0x30ddb4
movl (%r12), %r13d
testl %ebx, %ebx
je 0x68fb6
cmpl $0x20, %ebx
jg 0x68fbf
decb %bl
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %ebx, %ecx
roll %cl, %eax
movl %eax, (%r14)
movl $0x5a, %edi
movl $0x10, %esi
callq 0x653a5
leaq 0xb7976(%rip), %rdi     # 0x12076a
callq 0x653eb
movzbl (%r14), %edi
callq 0x591af
movzbl 0x1(%r14), %edi
callq 0x591af
movzbl 0x2(%r14), %edi
callq 0x591af
movzbl 0x3(%r14), %edi
callq 0x591af
callq 0x65433
jmp 0x68fbf
leaq 0xb7daf(%rip), %rdi     # 0x120be0
movl $0x1e, %esi
callq 0x5ee52
leaq 0xb7db5(%rip), %rdi     # 0x120bf7
movl $0x20, %esi
callq 0x5ee52
leaq 0xb7dbb(%rip), %rdi     # 0x120c0e
movl $0x16, %esi
callq 0x5ee52
leaq 0xb7d3d(%rip), %rdi     # 0x120ba1
movl $0x1e, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5ee52
leaq 0x2a4259(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a4254(%rip), %rax    # 0x30d0e0
sete %dl
leaq 0x1b213e(%rip), %r15    # 0x21afd4
cmpl $0x41, (%r15)
movl $0x1, (%rax)
sete %cl
andb %dl, %cl
leaq 0x1afa4c(%rip), %rax    # 0x2188f8
movl (%rax), %eax
cmpl $0x47, %eax
sete %dl
testb %dl, %cl
jne 0x68edd
testb %cl, %cl
je 0x68ec6
cmpl $0x33, %eax
je 0x68edd
cmpl $0x47, %eax
je 0x68edd
movl $0x34, %edi
callq 0x5e740
movzbl %bl, %edi
callq 0x591af
callq 0x5e7c0
cmpq $0x1, (%r14)
jne 0x68f87
movl (%r15), %eax
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x68f87
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jae 0x68f87
testl %ebx, %ebx
jne 0x68fcb
leaq 0x2a41bd(%rip), %rax    # 0x30d0d0
cmpb $0x1, (%rax)
jne 0x68fcb
movss 0xa40ac(%rip), %xmm0    # 0x10cfd0
movl $0x7, %edi
jmp 0x68fd8
leaq 0x2a41a7(%rip), %rax    # 0x30d0dc
movl %ebx, (%rax)
leaq 0x2a41a2(%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 0x6970f
leaq 0x2a4e1d(%rip), %rax    # 0x30dd88
movl %r14d, (%rax)
leaq 0x2a4e17(%rip), %rax    # 0x30dd8c
movl %r10d, (%rax)
leaq 0x2a4e15(%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
leaq 0xb7c5b(%rip), %r14     # 0x120bf8
movq %r14, %rdi
movl $0x20, %esi
callq 0x5ee52
leaq 0xb7bf1(%rip), %rdi     # 0x120ba2
jmp 0x68e64
xorl %eax, %eax
movl %eax, (%r14)
movl %eax, (%r12)
movl %r15d, (%r14)
movl %r13d, (%r12)
jmp 0x68cc1
movss 0xa3ffd(%rip), %xmm0    # 0x10cfd0
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 0x5d081