// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: decode_x72_msg(int)
void decode_x72_msg(int why)
{
char c;
int i;

   start_msg_decode(0);

   nmea_msg[0] = 0;
   for(i=0; i<tsip_wptr; i++) {  // copy message from tsip buffer to nmea buffer
      c = tsip_byte();
      nmea_msg[i] = c;
      nmea_msg[i+1] = 0;
      if(i >= ((int)sizeof(nmea_msg)-12)) break;
   }

   tsip_wptr = tsip_rptr = 0;
   tsip_sync = 0;
tsip_error = 0;

   // get the response from the receiver and pass it to (HOPEFULLY) the routine
   // that expects it...

   strupr(nmea_msg);

if(debug_file) fprintf(debug_file, "Decode x72 msg %d:(%s)  why:%d\n", x72_msg_id, nmea_msg, why);

   if(strstr(nmea_msg, "R>")) {  // >r prompt
      x72_msg_id = 0;
      return;
   }
   else if(nmea_msg[0] == 0) {  // empty line
      return;
   }
   else if(x72_msg_id == 0) {
if(debug_file) fprintf(debug_file, "response to:(%s) (status msg:%d) is next\n", nmea_msg, scpi_status);
      if     (strstr(nmea_msg, "A")) x72_msg_id = X72_SET_FC_MSG;
      else if(strstr(nmea_msg, "F")) x72_msg_id = X72_SET_DDS_MSG;
      else if(strstr(nmea_msg, "G")) x72_msg_id = X72_SET_DMODE_MSG;
      else if(strstr(nmea_msg, "H")) x72_msg_id = X72_HELP_MSG;
      else if(strstr(nmea_msg, "I")) x72_msg_id = X72_INFO_MSG;
      else if(strstr(nmea_msg, "J")) x72_msg_id = X72_GET_PPS_MSG;
      else if(strstr(nmea_msg, "K")) x72_msg_id = X72_SET_TIC_MSG;
      else if(strstr(nmea_msg, "L")) x72_msg_id = X72_SET_SRVC_MSG;
      else if(strstr(nmea_msg, "O")) x72_msg_id = X72_SET_FREQ_MSG;
      else if(strstr(nmea_msg, "P")) x72_msg_id = X72_GET_CREG_MSG;
      else if(strstr(nmea_msg, "Q")) x72_msg_id = X72_SET_CREG_MSG;
      else if(strstr(nmea_msg, "R")) x72_msg_id = X72_RUNR_MSG;
      else if(strstr(nmea_msg, "T")) x72_msg_id = X72_SAVE_TUNE_MSG;
      else if(strstr(nmea_msg, "W")) x72_msg_id = X72_HEALTH_MSG;
      else if(strstr(nmea_msg, "X")) x72_msg_id = X72_RUNX_MSG;
      else if(strstr(nmea_msg, "Y")) x72_msg_id = X72_TC_MSG;         // !!!! Y1
      else if(strstr(nmea_msg, "Y")) x72_msg_id = X72_DAMPING_MSG;    // !!!! Y2
      else if(strstr(nmea_msg, "Z")) x72_msg_id = X72_SAVE_DMODE_MSG; // !!!! Y2
      return;
   }

   if(x72_msg_id == X72_INFO_MSG) {  // multi-line response to the query
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_HEALTH_MSG) {  // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_GET_PPS_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_GET_CREG_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_HELP_MSG) { // multi-line response to the query 
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_CREG_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_TIC_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_FREQ_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_DMODE_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SAVE_TUNE_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_DDS_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_SRVC_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SET_FC_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_RUNR_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_RUNX_MSG) { // multi-line response to the query 
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_TC_MSG) {   // multi-line response to the query  
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_DAMPING_MSG) { // multi-line response to the query  
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == X72_SAVE_DMODE_MSG) { // multi-line response to the query  
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else if(x72_msg_id == SCPI_USER_MSG) {
      parse_x72_response(x72_msg_id);
      x72_msg_id = 0;
   }
   else {
      x72_msg_id = 0;
      poll_next_x72();
   }


// if(debug_file) fprintf(debug_file, "x72 %d response:%s\n", x72_msg_id, nmea_msg);
   update_x72_screen();

   if(sim_file && sim_delay) {  // throttle sim file messages
      Sleep(sim_delay);
   }
   saw_rcvr_msg = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebx
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x73dcb
leaq 0x2a3513(%rip), %r12    # 0x325830
movb $0x0, (%r12)
leaq 0x29ff29(%rip), %r15    # 0x322252
movzwl (%r15), %eax
cmpq %rax, %r14
jae 0x8234d
callq 0x51c47
movb %al, (%r14,%r12)
movb $0x0, 0x1(%r14,%r12)
incq %r14
cmpq $0x1f6, %r14            # imm = 0x1F6
jne 0x82329
leaq 0x29ff00(%rip), %rax    # 0x322254
andw $0x0, (%rax)
andw $0x0, (%r15)
leaq 0x29fef2(%rip), %rax    # 0x322256
andw $0x0, (%rax)
leaq 0x1a6c01(%rip), %rax    # 0x228f70
andl $0x0, (%rax)
leaq 0x2a34b7(%rip), %rdi    # 0x325830
callq 0x988f
leaq 0x1a600b(%rip), %r14    # 0x228390
movq (%r14), %rdi
testq %rdi, %rdi
je 0x823ab
movl 0x2d484d(%rip), %edx    # 0x356be0
leaq 0x8b8cd(%rip), %rsi     # 0x10dc67
leaq 0x2a348f(%rip), %rcx    # 0x325830
movl %ebx, %r8d
xorl %eax, %eax
callq 0x9560
leaq 0x2a347e(%rip), %rbx    # 0x325830
leaq 0x8b8ce(%rip), %rsi     # 0x10dc87
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x823d2
andl $0x0, 0x2d4813(%rip)    # 0x356be0
jmp 0x8252a
cmpb $0x0, (%rbx)
je 0x8252a
movl 0x2d47ff(%rip), %eax    # 0x356be0
leal -0x2bc(%rax), %ecx
cmpl $0x11, %ecx
ja 0x82406
leaq 0x871ed(%rip), %rax     # 0x1095e0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x2bc, %edi            # imm = 0x2BC
jmp 0x824e2
cmpl $0x25, %eax
je 0x824a7
testl %eax, %eax
jne 0x824ba
movq (%r14), %rdi
testq %rdi, %rdi
je 0x8243a
movl 0x2d7bbf(%rip), %ecx    # 0x359fe4
leaq 0x8b85e(%rip), %rsi     # 0x10dc8a
leaq 0x2a33fd(%rip), %rdx    # 0x325830
xorl %eax, %eax
callq 0x9560
leaq 0x2a33ef(%rip), %rdi    # 0x325830
pushq $0x41
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82533
movl $0x2bc, 0x2d4784(%rip)  # imm = 0x2BC
jmp 0x8252a
movl $0x2cc, %edi            # imm = 0x2CC
jmp 0x824e2
movl $0x2ca, %edi            # imm = 0x2CA
jmp 0x824e2
movl $0x2c7, %edi            # imm = 0x2C7
jmp 0x824e2
movl $0x2c0, %edi            # imm = 0x2C0
jmp 0x824e2
movl $0x2c8, %edi            # imm = 0x2C8
jmp 0x824e2
movl $0x2c5, %edi            # imm = 0x2C5
jmp 0x824e2
movl $0x2bd, %edi            # imm = 0x2BD
jmp 0x824e2
movl $0x2cb, %edi            # imm = 0x2CB
jmp 0x824e2
movl $0x2be, %edi            # imm = 0x2BE
jmp 0x824e2
movl $0x2c3, %edi            # imm = 0x2C3
jmp 0x824e2
pushq $0x25
popq %rdi
jmp 0x824e2
movl $0x2cd, %edi            # imm = 0x2CD
jmp 0x824e2
movl $0x2c1, %edi            # imm = 0x2C1
jmp 0x824e2
andl $0x0, 0x2d471f(%rip)    # 0x356be0
callq 0x6698e
jmp 0x824ee
movl $0x2c9, %edi            # imm = 0x2C9
jmp 0x824e2
movl $0x2c2, %edi            # imm = 0x2C2
jmp 0x824e2
movl $0x2c6, %edi            # imm = 0x2C6
jmp 0x824e2
movl $0x2c4, %edi            # imm = 0x2C4
callq 0x81441
andl $0x0, 0x2d46f2(%rip)    # 0x356be0
callq 0x8130d
leaq 0x1a5ec6(%rip), %rax    # 0x2283c0
cmpq $0x0, (%rax)
setne %al
leaq 0x18b0f8(%rip), %rcx    # 0x20d600
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8251d
callq 0xae83
leaq 0x1a6a7c(%rip), %rax    # 0x228fa0
movl $0x1, (%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2a32f6(%rip), %rdi    # 0x325830
pushq $0x46
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82553
movl $0x2bd, 0x2d468f(%rip)  # imm = 0x2BD
jmp 0x8252a
leaq 0x2a32d6(%rip), %rdi    # 0x325830
pushq $0x47
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82573
movl $0x2be, 0x2d466f(%rip)  # imm = 0x2BE
jmp 0x8252a
leaq 0x2a32b6(%rip), %rdi    # 0x325830
pushq $0x48
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82593
movl $0x2bf, 0x2d464f(%rip)  # imm = 0x2BF
jmp 0x8252a
leaq 0x2a3296(%rip), %rdi    # 0x325830
pushq $0x49
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x825b6
movl $0x2c0, 0x2d462f(%rip)  # imm = 0x2C0
jmp 0x8252a
leaq 0x2a3273(%rip), %rdi    # 0x325830
pushq $0x4a
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x825d9
movl $0x2c1, 0x2d460c(%rip)  # imm = 0x2C1
jmp 0x8252a
leaq 0x2a3250(%rip), %rdi    # 0x325830
pushq $0x4b
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x825fc
movl $0x2c2, 0x2d45e9(%rip)  # imm = 0x2C2
jmp 0x8252a
leaq 0x2a322d(%rip), %rdi    # 0x325830
pushq $0x4c
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x8261f
movl $0x2c3, 0x2d45c6(%rip)  # imm = 0x2C3
jmp 0x8252a
leaq 0x2a320a(%rip), %rdi    # 0x325830
pushq $0x4f
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82642
movl $0x2c4, 0x2d45a3(%rip)  # imm = 0x2C4
jmp 0x8252a
leaq 0x2a31e7(%rip), %rdi    # 0x325830
pushq $0x50
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82665
movl $0x2c5, 0x2d4580(%rip)  # imm = 0x2C5
jmp 0x8252a
leaq 0x2a31c4(%rip), %rdi    # 0x325830
pushq $0x51
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82688
movl $0x2c6, 0x2d455d(%rip)  # imm = 0x2C6
jmp 0x8252a
leaq 0x2a31a1(%rip), %rdi    # 0x325830
pushq $0x52
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x826ab
movl $0x2c7, 0x2d453a(%rip)  # imm = 0x2C7
jmp 0x8252a
leaq 0x2a317e(%rip), %rdi    # 0x325830
pushq $0x54
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x826ce
movl $0x2c8, 0x2d4517(%rip)  # imm = 0x2C8
jmp 0x8252a
leaq 0x2a315b(%rip), %rdi    # 0x325830
pushq $0x57
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x826f1
movl $0x2c9, 0x2d44f4(%rip)  # imm = 0x2C9
jmp 0x8252a
leaq 0x2a3138(%rip), %rdi    # 0x325830
pushq $0x58
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82714
movl $0x2ca, 0x2d44d1(%rip)  # imm = 0x2CA
jmp 0x8252a
leaq 0x2a3115(%rip), %rdi    # 0x325830
pushq $0x59
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x82737
movl $0x2cb, 0x2d44ae(%rip)  # imm = 0x2CB
jmp 0x8252a
leaq 0x2a30f2(%rip), %rdi    # 0x325830
pushq $0x5a
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x8252a
movl $0x2cd, 0x2d4487(%rip)  # imm = 0x2CD
jmp 0x8252a