// File: jkingan[P]ladyheather/heathgps.cpp
// Function: set_discipline_params(int)
void set_discipline_params(int save)
{
   if(read_only) return;
   if(luxor) return;

   if(rcvr_type == PRS_RCVR) {
      // !!!!!!! do something
      if(have_osc_params & PARAM_TC) {  // set time constant
         set_prs_pt((int) user_time_constant);
      }

      if(have_osc_params & PARAM_DAMP) {  // set damping factor
         set_prs_pf((int) user_damping_factor);
      }

      if(have_osc_params & PARAM_GAIN) {  // set gain factor
         set_prs_ga((int) user_damping_factor);
      }

      if(have_osc_params & PARAM_INITV) {  // set integrator factor
         set_prs_pi((int) user_initial_voltage);
      }
   }
   else if(rcvr_type == SRO_RCVR) {
      if(have_osc_params & PARAM_TC) {  // set time constant
         set_sro_tc((int) user_time_constant);
      }
   }
   else if(rcvr_type == STAR_RCVR) {
      if(have_osc_params & PARAM_TC) {
         sprintf(out, "TAU=%d;", (int) user_time_constant);
         queue_star_cmd(out, STAR_TAU_MSG);
         request_rcvr_config(4565);
      }
   }
   else if(rcvr_type == TSIP_RCVR) {
      if(ACU_GG) return;
      if(ACU_360) return;
      if(ACUTIME) return;
      if(PALISADE) return;
      if(SV6_FAMILY) return;

      if(have_osc_params & (PARAM_TC | PARAM_DAMP)) { 
         send_tsip_start(0x8E);
         send_byte(0xA8);
         send_byte(0x00);
         send_single((float) user_time_constant);
         send_single((float) user_damping_factor);
         send_tsip_end();
      }

      if(have_osc_params & (PARAM_GAIN | PARAM_MINV | PARAM_MAXV)) { 
         send_tsip_start(0x8E);
         send_byte(0xA8);
         send_byte(0x01);
         send_single((float) user_osc_gain);
         send_single((float) user_min_volts);
         send_single((float) user_max_volts);
         send_tsip_end();
      }

      if(have_osc_params & (PARAM_JAMSYNC | PARAM_MAXFREQ)) { 
         send_tsip_start(0x8E);
         send_byte(0xA8);
         send_byte(0x02);
         send_single((float) user_jam_sync);
         send_single((float) user_max_freq_offset);
         send_tsip_end();
      }

      if(have_osc_params & PARAM_INITV) { 
         send_tsip_start(0x8E);
         send_byte(0xA8);
         send_byte(0x03);
         send_single((float) user_initial_voltage);
         send_tsip_end();
      }

      if(have_osc_params & (PARAM_MINRANGE | PARAM_MAXRANGE)) { // !!!! undocumented - allowable dac range
         send_tsip_start(0x8E);
         send_byte(0xA8);
         send_byte(0x04);
         send_single((float) user_min_range);
         send_single((float) user_max_range);
         send_tsip_end();
      }

      if(save) {
         if((have_osc_params & PARAM_TBOLT) == PARAM_TBOLT) {  // !!!!! 0x0F: we have all osc params available
            save_segment(9, 25);
         }
         else if(saw_ntpx && ((have_osc_params & PARAM_NTPX) == PARAM_NTPX)) {
            save_segment(9, 26);
         }
      }
   }
   else if(rcvr_type == UCCM_RCVR) {
      if(have_osc_params & PARAM_PULLIN) {
         set_pullin_range(user_pullin);
      }
   }
   else if(rcvr_type == X72_RCVR) {
      if(have_osc_params & PARAM_MAXFREQ) {  // used to set DDS tuning word
         set_x72_dds(user_max_freq_offset);
      }

      if(have_osc_params & PARAM_JAMSYNC) {  // set time constant
         set_x72_jamthresh(user_jam_sync);
      }

      if(have_osc_params & PARAM_TC) {  // set time constant
         set_x72_tc((int) user_time_constant);
      }

      if(have_osc_params & PARAM_DAMP) {  // set damping factor
         set_x72_damping(user_damping_factor);
      }

      if(have_osc_params & PARAM_HOLDOVER) {  // set holdover analysis time
         set_x72_holdover(user_holdover_time);
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x2fc468(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x99d9c
jmp 0x9a2f6
leaq 0x20437b(%rip), %rax    # 0x29e11e
cmpb $0x0, (%rax)
je 0x99dad
jmp 0x9a2f6
leaq 0x1ddcfc(%rip), %rax    # 0x277ab0
cmpq $0x1000000, (%rax)      # imm = 0x1000000
jne 0x99e4a
leaq 0x2d3214(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x99de2
leaq 0x2d257f(%rip), %rax    # 0x36c358
cvttsd2si (%rax), %edi
callq 0x9a300
leaq 0x2d31f3(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x99e03
leaq 0x2d2566(%rip), %rax    # 0x36c360
cvttsd2si (%rax), %edi
callq 0x9a360
leaq 0x2d31d2(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x99e24
leaq 0x2d2545(%rip), %rax    # 0x36c360
cvttsd2si (%rax), %edi
callq 0x9a3c0
leaq 0x2d31b1(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x99e45
leaq 0x2d2564(%rip), %rax    # 0x36c3a0
cvttsd2si (%rax), %edi
callq 0x9a420
jmp 0x9a2f6
leaq 0x1ddc5f(%rip), %rax    # 0x277ab0
cmpq $0x8000000, (%rax)      # imm = 0x8000000
jne 0x99e80
leaq 0x2d317b(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x99e7b
leaq 0x2d24e6(%rip), %rax    # 0x36c358
cvttsd2si (%rax), %edi
callq 0x9a480
jmp 0x9a2f4
leaq 0x1ddc29(%rip), %rax    # 0x277ab0
cmpq $0x1000, (%rax)         # imm = 0x1000
jne 0x99ee1
leaq 0x2d3145(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x99edc
leaq 0x2d24b0(%rip), %rax    # 0x36c358
cvttsd2si (%rax), %edx
leaq 0x30154d(%rip), %rdi    # 0x39b400
leaq 0xead2b(%rip), %rsi     # 0x184be5
movb $0x0, %al
callq 0x9060
leaq 0x301538(%rip), %rdi    # 0x39b400
movl $0xfa, %esi
callq 0x82fd0
movl $0x11d5, %edi           # imm = 0x11D5
callq 0x8c270
jmp 0x9a2f2
leaq 0x1ddbc8(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9a1fa
leaq 0x1ddbb7(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x99f1c
leaq 0x1e02ae(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x99f1c
leaq 0x1ddbc6(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x99f1c
jmp 0x9a2f6
leaq 0x1ddb8d(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x99f52
leaq 0x1e0284(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x99f52
leaq 0x1ddb9c(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x99f4d
leaq 0x1ddb90(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x99f52
jmp 0x9a2f6
leaq 0x1ddb57(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x99f70
leaq 0x1e024e(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x99f70
jmp 0x9a2f6
leaq 0x1ddb39(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x99f8e
leaq 0x1e0230(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
jne 0x99f8e
jmp 0x9a2f6
leaq 0x1ddb1b(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x99fd0
leaq 0x1e0212(%rip), %rax    # 0x27a1b4
cmpl $0x36, (%rax)
je 0x99fcb
leaq 0x1e0206(%rip), %rax    # 0x27a1b4
cmpl $0x33, (%rax)
je 0x99fcb
leaq 0x1e01fa(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
je 0x99fcb
leaq 0x1e01ee(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x99fd0
jmp 0x9a2f6
leaq 0x2d3005(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x9a029
movl $0x8e, %edi
callq 0x824f0
movl $0xa8, %edi
callq 0x7b210
xorl %edi, %edi
callq 0x7b210
leaq 0x2d2355(%rip), %rax    # 0x36c358
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
leaq 0x2d2349(%rip), %rax    # 0x36c360
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
leaq 0x2d2fac(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x34, %eax
cmpl $0x0, %eax
je 0x9a099
movl $0x8e, %edi
callq 0x824f0
movl $0xa8, %edi
callq 0x7b210
movl $0x1, %edi
callq 0x7b210
leaq 0x2d2309(%rip), %rax    # 0x36c368
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
leaq 0x2d22fd(%rip), %rax    # 0x36c370
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
leaq 0x2d22f1(%rip), %rax    # 0x36c378
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
leaq 0x2d2f3c(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x600, %eax            # imm = 0x600
cmpl $0x0, %eax
je 0x9a0f7
movl $0x8e, %edi
callq 0x824f0
movl $0xa8, %edi
callq 0x7b210
movl $0x2, %edi
callq 0x7b210
leaq 0x2d22bf(%rip), %rax    # 0x36c390
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
leaq 0x2d22b3(%rip), %rax    # 0x36c398
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
leaq 0x2d2ede(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9a13f
movl $0x8e, %edi
callq 0x824f0
movl $0xa8, %edi
callq 0x7b210
movl $0x3, %edi
callq 0x7b210
leaq 0x2d2273(%rip), %rax    # 0x36c3a0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
leaq 0x2d2e96(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x1800, %eax           # imm = 0x1800
cmpl $0x0, %eax
je 0x9a19d
movl $0x8e, %edi
callq 0x824f0
movl $0xa8, %edi
callq 0x7b210
movl $0x4, %edi
callq 0x7b210
leaq 0x2d2209(%rip), %rax    # 0x36c380
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
leaq 0x2d21fd(%rip), %rax    # 0x36c388
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
cmpl $0x0, -0x4(%rbp)
je 0x9a1f5
leaq 0x2d2e32(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x3f, %eax
cmpl $0x3f, %eax
jne 0x9a1c5
movl $0x9, %edi
movl $0x19, %esi
callq 0x90d70
jmp 0x9a1f3
leaq 0x203f50(%rip), %rax    # 0x29e11c
cmpb $0x0, (%rax)
je 0x9a1f1
leaq 0x2d2e04(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x37, %eax
cmpl $0x37, %eax
jne 0x9a1f1
movl $0x9, %edi
movl $0x1a, %esi
callq 0x90d70
jmp 0x9a1f3
jmp 0x9a1f5
jmp 0x9a2f0
leaq 0x1dd8af(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0x9a22d
leaq 0x2d2dce(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x9a228
leaq 0x2d218b(%rip), %rax    # 0x36c3ac
movl (%rax), %edi
callq 0x99d10
jmp 0x9a2ee
leaq 0x1dd87c(%rip), %rax    # 0x277ab0
cmpq $0x2000000, (%rax)      # imm = 0x2000000
jne 0x9a2ec
leaq 0x2d2d94(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x9a264
leaq 0x2d213d(%rip), %rax    # 0x36c398
movsd (%rax), %xmm0
callq 0x9a4f0
leaq 0x2d2d71(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x9a287
leaq 0x2d2112(%rip), %rax    # 0x36c390
movsd (%rax), %xmm0
callq 0x9a6c0
leaq 0x2d2d4e(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x9a2a8
leaq 0x2d20b9(%rip), %rax    # 0x36c358
cvttsd2si (%rax), %edi
callq 0x9a7a0
leaq 0x2d2d2d(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x9a2c9
leaq 0x2d20a0(%rip), %rax    # 0x36c360
movsd (%rax), %xmm0
callq 0x9a890
leaq 0x2d2d0c(%rip), %rax    # 0x36cfdc
movl (%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x9a2ea
leaq 0x2d20c5(%rip), %rax    # 0x36c3a8
movl (%rax), %edi
callq 0x9a950
jmp 0x9a2ec
jmp 0x9a2ee
jmp 0x9a2f0
jmp 0x9a2f2
jmp 0x9a2f4
jmp 0x9a2f6
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)