// File: jkingan[P]ladyheather/heathgps.cpp
// Function: set_pps_mode(int)
void set_pps_mode(int mode)
{
int old_rate;

   // mode 0x02 - 1PPS
   // mode 0x82 - PP2S / 100 pps mode (Motorola)
   // mode 0x83 - 10000 PPS mode / 100 pps mode (Brandywine)

   if(read_only) return;    // !!! Resolution-T only
   if(luxor) return;

   if(rcvr_type == BRANDY_RCVR) {
      if(brandy_pps_width < 0) {  // negative polarity
         if     (mode == 0x82) sprintf(out, "$PRCCG,C,P2000,%d", brandy_pps_width);  // PP2S
         else if(mode == 0x83) sprintf(out, "$PRCCG,C,P10,%d",   brandy_pps_width);  // 100 PPS
         else                  sprintf(out, "$PRCCG,C,P1000,%d", brandy_pps_width);
      }
      else {  // positive polarity
         if     (mode == 0x82) sprintf(out, "$PRCCG,C,P2000,+%d", brandy_pps_width);  // PP2S
         else if(mode == 0x83) sprintf(out, "$PRCCG,C,P10,+%d",   brandy_pps_width);  // 100 PPS
         else                  sprintf(out, "$PRCCG,C,P1000,+%d", brandy_pps_width);
      }
      queue_brandy_cmd(out, BRANDY_PULSE_MSG);
   }
   else if(rcvr_type == ESIP_RCVR) {
       old_rate = pps_rate;
       pps_rate = mode;
       set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 10);
       pps_rate = old_rate;
       have_pps_rate = 1;
   }
   else if(rcvr_type == MOTO_RCVR) {
//sprintf(debug_text, "set pps mode:%d  oldr:%d  oldm:%d", mode, pps_rate,pps_mode);
      send_moto_start("AP");
      if(mode == RATE_100PPS) send_byte(1);  // 100 pps
      else                    send_byte(0);  // 1 PPS
      send_moto_end();
   }
   else if(rcvr_type == STAR_RCVR) {  // !!!!! we use this to toggle the TOD output
      if(star_type == OSA_TYPE) {
         if(mode == RATE_NO_TOD) {  // disable TOD message
            queue_star_cmd("TOD_STATE=D", STAR_TOD_MSG);
         }
         else {
            queue_star_cmd("TOD_STATE=E", STAR_TOD_MSG);
         }
         queue_star_cmd("TOD_STATE", STAR_TOD_MSG);
      }
      else {
         if(mode == RATE_NO_TOD) {  // disable TOD message
            queue_star_cmd("TOD_STATE=0;", STAR_TOD_MSG);
         }
         else {
            queue_star_cmd("TOD_STATE=1;", STAR_TOD_MSG);
         }
         queue_star_cmd("TOD_STATE;", STAR_TOD_MSG);
      }
   }
   else if(rcvr_type == TSIP_RCVR) {
      if(ACU_GG) ;
      else if(ACU_360) ;
      else if(ACUTIME) ;
      else if(PALISADE) return;
      else if(SV6_FAMILY) return;
      send_tsip_start(0x8E);
      send_byte(0x4E);
      mode &= 0xFE;
      send_byte(mode);
      send_tsip_end();
   }
   else if(rcvr_type == UBX_RCVR) {
       old_rate = pps_rate;
       pps_rate = mode;
       set_pps(user_pps_enable, pps_polarity,  delay_value, pps1_delay,  pps_threshold, 10);
       pps_rate = old_rate;
       have_pps_rate = 1;
   }
   else if(rcvr_type == UCCM_RCVR) {
      if(mode == RATE_PP2S) queue_uccm_cmd("OUTP:TP:SEL PP2S", UCCM_RATE_MSG);
      else                  queue_uccm_cmd("OUTP:TP:SEL PP1S", UCCM_RATE_MSG);
      queue_uccm_cmd("OUTP:TP:SEL?", UCCM_RATE_MSG);
   }
   else if(rcvr_type == ZYFER_RCVR) {
      if(mode == RATE_PP2S) send_zyfer_cmd("$PULR,2");      // PP2S
      else if(mode == RATE_1PPS) send_zyfer_cmd("$PULR,1"); // PPS
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x302b98(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x9366c
jmp 0x93b57
leaq 0x20aaab(%rip), %rax    # 0x29e11e
cmpb $0x0, (%rax)
je 0x9367d
jmp 0x93b57
leaq 0x1e442c(%rip), %rax    # 0x277ab0
cmpq $0x40000, (%rax)        # imm = 0x40000
jne 0x9379b
leaq 0x3079a0(%rip), %rax    # 0x39b038
cmpl $0x0, (%rax)
jge 0x93711
cmpl $0x82, -0x4(%rbp)
jne 0x936c6
leaq 0x30798b(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307d4a(%rip), %rdi    # 0x39b400
leaq 0xf0dbb(%rip), %rsi     # 0x184478
movb $0x0, %al
callq 0x9060
jmp 0x9370f
cmpl $0x83, -0x4(%rbp)
jne 0x936ef
leaq 0x307962(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307d21(%rip), %rdi    # 0x39b400
leaq 0xf0da4(%rip), %rsi     # 0x18448a
movb $0x0, %al
callq 0x9060
jmp 0x9370d
leaq 0x307942(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307d01(%rip), %rdi    # 0x39b400
leaq 0xf0d94(%rip), %rsi     # 0x18449a
movb $0x0, %al
callq 0x9060
jmp 0x9370f
jmp 0x93785
cmpl $0x82, -0x4(%rbp)
jne 0x9373a
leaq 0x307917(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307cd6(%rip), %rdi    # 0x39b400
leaq 0xf0d7b(%rip), %rsi     # 0x1844ac
movb $0x0, %al
callq 0x9060
jmp 0x93783
cmpl $0x83, -0x4(%rbp)
jne 0x93763
leaq 0x3078ee(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307cad(%rip), %rdi    # 0x39b400
leaq 0xf0d65(%rip), %rsi     # 0x1844bf
movb $0x0, %al
callq 0x9060
jmp 0x93781
leaq 0x3078ce(%rip), %rax    # 0x39b038
movl (%rax), %edx
leaq 0x307c8d(%rip), %rdi    # 0x39b400
leaq 0xf0d56(%rip), %rsi     # 0x1844d0
movb $0x0, %al
callq 0x9060
jmp 0x93783
jmp 0x93785
leaq 0x307c74(%rip), %rdi    # 0x39b400
movl $0x191, %esi            # imm = 0x191
callq 0x82fd0
jmp 0x93b57
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x1e4309(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x9382a
leaq 0x2d9750(%rip), %rax    # 0x36cf03
movzbl (%rax), %eax
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %eax
movb %al, %cl
leaq 0x2d973e(%rip), %rax    # 0x36cf03
movb %cl, (%rax)
leaq 0x2d9733(%rip), %rax    # 0x36cf01
movb (%rax), %cl
leaq 0x2d9721(%rip), %rax    # 0x36cef8
movl (%rax), %eax
leaq 0x2d97c8(%rip), %rdx    # 0x36cfa8
movsd (%rdx), %xmm0
leaq 0x2d97cd(%rip), %rdx    # 0x36cfb8
movsd (%rdx), %xmm1
leaq 0x2d9706(%rip), %rdx    # 0x36cefc
movss (%rdx), %xmm2
movl $0xa, %edx
movzbl %cl, %edi
movzbl %al, %esi
callq 0x91b20
movl -0x8(%rbp), %eax
movb %al, %cl
leaq 0x2d96ed(%rip), %rax    # 0x36cf03
movb %cl, (%rax)
leaq 0x2d8c91(%rip), %rax    # 0x36c4b0
movl $0x1, (%rax)
jmp 0x93b55
leaq 0x1e427f(%rip), %rax    # 0x277ab0
cmpq $0x20, (%rax)
jne 0x93869
leaq 0xdd381(%rip), %rdi     # 0x170bbf
callq 0x86190
cmpl $0x82, -0x4(%rbp)
jne 0x93858
movl $0x1, %edi
callq 0x7b210
jmp 0x9385f
xorl %edi, %edi
callq 0x7b210
callq 0x86230
jmp 0x93b53
leaq 0x1e4240(%rip), %rax    # 0x277ab0
cmpq $0x1000, (%rax)         # imm = 0x1000
jne 0x9390c
leaq 0x1e6944(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0x938c9
cmpl $0x82, -0x4(%rbp)
jne 0x938a5
leaq 0xf0c4a(%rip), %rdi     # 0x1844e3
movl $0xd5, %esi
callq 0x82fd0
jmp 0x938b6
leaq 0xf0c43(%rip), %rdi     # 0x1844ef
movl $0xd5, %esi
callq 0x82fd0
leaq 0xf0c3e(%rip), %rdi     # 0x1844fb
movl $0xd5, %esi
callq 0x82fd0
jmp 0x93907
cmpl $0x82, -0x4(%rbp)
jne 0x938e5
leaq 0xf0c2c(%rip), %rdi     # 0x184505
movl $0xd5, %esi
callq 0x82fd0
jmp 0x938f6
leaq 0xf0c26(%rip), %rdi     # 0x184512
movl $0xd5, %esi
callq 0x82fd0
leaq 0xf0c22(%rip), %rdi     # 0x18451f
movl $0xd5, %esi
callq 0x82fd0
jmp 0x93b51
leaq 0x1e419d(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x93a34
leaq 0x1e418c(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x93947
leaq 0x1e6883(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x93947
leaq 0x1e419b(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x93947
jmp 0x93a00
leaq 0x1e4162(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9397d
leaq 0x1e6859(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9397d
leaq 0x1e4171(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x93978
leaq 0x1e4165(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x9397d
jmp 0x939fe
leaq 0x1e412c(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x93998
leaq 0x1e6823(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x93998
jmp 0x939fc
leaq 0x1e4111(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x939b6
leaq 0x1e6808(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
jne 0x939b6
jmp 0x93b57
leaq 0x1e40f3(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x939f8
leaq 0x1e67ea(%rip), %rax    # 0x27a1b4
cmpl $0x36, (%rax)
je 0x939f3
leaq 0x1e67de(%rip), %rax    # 0x27a1b4
cmpl $0x33, (%rax)
je 0x939f3
leaq 0x1e67d2(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
je 0x939f3
leaq 0x1e67c6(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x939f8
jmp 0x93b57
jmp 0x939fa
jmp 0x939fc
jmp 0x939fe
jmp 0x93a00
movl $0x8e, %edi
callq 0x824f0
movl $0x4e, %edi
callq 0x7b210
movl -0x4(%rbp), %eax
andl $0xfe, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movzbl %al, %edi
callq 0x7b210
callq 0x82590
jmp 0x93b4f
leaq 0x1e4075(%rip), %rax    # 0x277ab0
cmpq $0x4, (%rax)
jne 0x93abf
leaq 0x2d94bb(%rip), %rax    # 0x36cf03
movzbl (%rax), %eax
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %eax
movb %al, %cl
leaq 0x2d94a9(%rip), %rax    # 0x36cf03
movb %cl, (%rax)
leaq 0x2d949e(%rip), %rax    # 0x36cf01
movb (%rax), %cl
leaq 0x2d948c(%rip), %rax    # 0x36cef8
movl (%rax), %eax
leaq 0x2d952b(%rip), %rdx    # 0x36cfa0
movsd (%rdx), %xmm0
leaq 0x2d9538(%rip), %rdx    # 0x36cfb8
movsd (%rdx), %xmm1
leaq 0x2d9471(%rip), %rdx    # 0x36cefc
movss (%rdx), %xmm2
movl $0xa, %edx
movzbl %cl, %edi
movzbl %al, %esi
callq 0x91b20
movl -0x8(%rbp), %eax
movb %al, %cl
leaq 0x2d9458(%rip), %rax    # 0x36cf03
movb %cl, (%rax)
leaq 0x2d89fc(%rip), %rax    # 0x36c4b0
movl $0x1, (%rax)
jmp 0x93b4d
leaq 0x1e3fea(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0x93b0c
cmpl $0x82, -0x4(%rbp)
jne 0x93ae8
leaq 0xf0a4e(%rip), %rdi     # 0x18452a
movl $0x64, %esi
callq 0x82fd0
jmp 0x93af9
leaq 0xf0a4c(%rip), %rdi     # 0x18453b
movl $0x64, %esi
callq 0x82fd0
leaq 0xf0a4c(%rip), %rdi     # 0x18454c
movl $0x64, %esi
callq 0x82fd0
jmp 0x93b4b
leaq 0x1e3f9d(%rip), %rax    # 0x277ab0
cmpq $0x100000, (%rax)       # imm = 0x100000
jne 0x93b49
cmpl $0x82, -0x4(%rbp)
jne 0x93b33
leaq 0xf0a2d(%rip), %rdi     # 0x184559
callq 0x85d30
jmp 0x93b47
cmpl $0x2, -0x4(%rbp)
jne 0x93b45
leaq 0xf0a21(%rip), %rdi     # 0x184561
callq 0x85d30
jmp 0x93b47
jmp 0x93b49
jmp 0x93b4b
jmp 0x93b4d
jmp 0x93b4f
jmp 0x93b51
jmp 0x93b53
jmp 0x93b55
jmp 0x93b57
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)