// File: jkingan[P]ladyheather/heathgps.cpp
// Function: set_cs_time(char)
void set_cs_time(char mode)
{
double mjd;

   // sets the H5071 date and time from the system clock.
   // The 5071A must be in REMOTE mode for this to work
   if(read_only) return;

   if(rcvr_type == CS_RCVR) {
      need_cs_timeset = 0;
      get_clock_time();   // get system clock time in UTC

      if(mode == 'L') {  // set to local (displayed) time
         adjust_tz(987);
         clk_year = pri_year;
         clk_month = pri_month;
         clk_day = pri_day;
         clk_hours = pri_hours;
         clk_minutes = pri_minutes;
         clk_seconds = pri_seconds;
         clk_frac = pri_frac;
      }
      else if(mode == 'U') {  // set to UTC time
      }
      else return;

      mjd = jdate(clk_year,clk_month,clk_day) - JD_MJD;

      sprintf(out, "PTIM:TIME %d,%d,%d", clk_hours,clk_minutes,clk_seconds);
      send_polled_cmd(out, CS_TIME_MSG);

      sprintf(out, "PTIM:MJD %d", (int) (mjd+0.50));
      send_polled_cmd(out, CS_MJD_MSG);

      BEEP(511);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x1(%rbp)
leaq 0x2b99d5(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0xdc82f
jmp 0xdc9b3
leaq 0x19b27a(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0xdc9b3
leaq 0x19d3a6(%rip), %rax    # 0x279bf0
movb $0x0, (%rax)
callq 0xa750
movsbl -0x1(%rbp), %eax
cmpl $0x4c, %eax
jne 0xdc8ed
movl $0x3db, %edi            # imm = 0x3DB
callq 0x1355f0
leaq 0x28fe84(%rip), %rax    # 0x36c6f4
movl (%rax), %ecx
leaq 0x29002f(%rip), %rax    # 0x36c8a8
movl %ecx, (%rax)
leaq 0x28fe6e(%rip), %rax    # 0x36c6f0
movl (%rax), %ecx
leaq 0x290015(%rip), %rax    # 0x36c8a0
movl %ecx, (%rax)
leaq 0x28fe58(%rip), %rax    # 0x36c6ec
movl (%rax), %ecx
leaq 0x290007(%rip), %rax    # 0x36c8a4
movl %ecx, (%rax)
leaq 0x28fe42(%rip), %rax    # 0x36c6e8
movl (%rax), %ecx
leaq 0x28fffd(%rip), %rax    # 0x36c8ac
movl %ecx, (%rax)
leaq 0x28fe2c(%rip), %rax    # 0x36c6e4
movl (%rax), %ecx
leaq 0x28ffef(%rip), %rax    # 0x36c8b0
movl %ecx, (%rax)
leaq 0x28fe16(%rip), %rax    # 0x36c6e0
movl (%rax), %ecx
leaq 0x28ffe1(%rip), %rax    # 0x36c8b4
movl %ecx, (%rax)
leaq 0x28fe1c(%rip), %rax    # 0x36c6f8
movsd (%rax), %xmm0
leaq 0x28ffd1(%rip), %rax    # 0x36c8b8
movsd %xmm0, (%rax)
jmp 0xdc8ff
movsbl -0x1(%rbp), %eax
cmpl $0x55, %eax
jne 0xdc8f8
jmp 0xdc8fd
jmp 0xdc9b3
jmp 0xdc8ff
leaq 0x28ffa2(%rip), %rax    # 0x36c8a8
movl (%rax), %edi
leaq 0x28ff91(%rip), %rax    # 0x36c8a0
movl (%rax), %esi
leaq 0x28ff8c(%rip), %rax    # 0x36c8a4
movl (%rax), %edx
callq 0x122140
movsd 0x94ce9(%rip), %xmm1    # 0x171610
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x28ff75(%rip), %rax    # 0x36c8ac
movl (%rax), %edx
leaq 0x28ff70(%rip), %rax    # 0x36c8b0
movl (%rax), %ecx
leaq 0x28ff6b(%rip), %rax    # 0x36c8b4
movl (%rax), %r8d
leaq 0x2beaad(%rip), %rdi    # 0x39b400
leaq 0xac3fa(%rip), %rsi     # 0x188d54
movb $0x0, %al
callq 0x9060
leaq 0x2bea98(%rip), %rdi    # 0x39b400
movl $0x12c, %esi            # imm = 0x12C
callq 0x96370
movsd 0x92716(%rip), %xmm0    # 0x16f090
addsd -0x10(%rbp), %xmm0
cvttsd2si %xmm0, %edx
leaq 0x2bea76(%rip), %rdi    # 0x39b400
leaq 0xac3d6(%rip), %rsi     # 0x188d67
movb $0x0, %al
callq 0x9060
leaq 0x2bea61(%rip), %rdi    # 0x39b400
movl $0x12d, %esi            # imm = 0x12D
callq 0x96370
movl $0x1ff, %edi            # imm = 0x1FF
callq 0x9ec0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)