// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x7f2b8
leaq 0x2ac866(%rip), %r13    # 0x33b830
movb $0x0, (%r13)
leaq 0x2a927c(%rip), %r12    # 0x338252
leaq 0x1aff93(%rip), %r14    # 0x23ef70
movzwl (%r12), %eax
cmpq %rax, %r15
jae 0x8f00d
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x8eff7
orb $0x8, (%r14)
movb %al, (%r15,%r13)
movb $0x0, 0x1(%r15,%r13)
incq %r15
cmpq $0x1f6, %r15            # imm = 0x1F6
jne 0x8efdd
leaq 0x2a9240(%rip), %rax    # 0x338254
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r12)
leaq 0x2a9231(%rip), %rax    # 0x338256
movw %cx, (%rax)
movl $0x0, (%r14)
leaq 0x2ac7fa(%rip), %rdi    # 0x33b830
callq 0x9899
leaq 0x1af34e(%rip), %r14    # 0x23e390
movq (%r14), %rdi
testq %rdi, %rdi
je 0x8f068
movl 0x2ddb90(%rip), %edx    # 0x36cbe0
leaq 0x94cc8(%rip), %rsi     # 0x123d1f
leaq 0x2ac7d2(%rip), %rcx    # 0x33b830
movl %ebx, %r8d
xorl %eax, %eax
callq 0x9560
leaq 0x2ac7c1(%rip), %rbx    # 0x33b830
leaq 0x94cc9(%rip), %rsi     # 0x123d3f
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x8f092
movl $0x0, 0x2ddb53(%rip)    # 0x36cbe0
jmp 0x8f1f4
cmpb $0x0, (%rbx)
je 0x8f1f4
movl 0x2ddb3f(%rip), %eax    # 0x36cbe0
leal -0x2bc(%rax), %ecx
cmpl $0x11, %ecx
ja 0x8f0c6
leaq 0x905e9(%rip), %rax     # 0x11f69c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x2bc, %edi            # imm = 0x2BC
jmp 0x8f1a9
cmpl $0x25, %eax
je 0x8f169
testl %eax, %eax
jne 0x8f17e
movq (%r14), %rdi
testq %rdi, %rdi
je 0x8f0fa
movl 0x2e0eff(%rip), %ecx    # 0x36ffe4
leaq 0x94c56(%rip), %rsi     # 0x123d42
leaq 0x2ac73d(%rip), %rdx    # 0x33b830
xorl %eax, %eax
callq 0x9560
leaq 0x2ac72f(%rip), %rdi    # 0x33b830
movl $0x41, %esi
callq 0x9100
testq %rax, %rax
je 0x8f203
movl $0x2bc, 0x2ddac2(%rip)  # imm = 0x2BC
jmp 0x8f1f4
movl $0x2cc, %edi            # imm = 0x2CC
jmp 0x8f1a9
movl $0x2ca, %edi            # imm = 0x2CA
jmp 0x8f1a9
movl $0x2c7, %edi            # imm = 0x2C7
jmp 0x8f1a9
movl $0x2c0, %edi            # imm = 0x2C0
jmp 0x8f1a9
movl $0x2c8, %edi            # imm = 0x2C8
jmp 0x8f1a9
movl $0x2c5, %edi            # imm = 0x2C5
jmp 0x8f1a9
movl $0x2bd, %edi            # imm = 0x2BD
jmp 0x8f1a9
movl $0x2cb, %edi            # imm = 0x2CB
jmp 0x8f1a9
movl $0x2be, %edi            # imm = 0x2BE
jmp 0x8f1a9
movl $0x2c3, %edi            # imm = 0x2C3
jmp 0x8f1a9
movl $0x25, %edi
jmp 0x8f1a9
movl $0x2cd, %edi            # imm = 0x2CD
jmp 0x8f1a9
movl $0x2c1, %edi            # imm = 0x2C1
jmp 0x8f1a9
movl $0x0, 0x2dda58(%rip)    # 0x36cbe0
callq 0x70000
jmp 0x8f1b8
movl $0x2c9, %edi            # imm = 0x2C9
jmp 0x8f1a9
movl $0x2c2, %edi            # imm = 0x2C2
jmp 0x8f1a9
movl $0x2c6, %edi            # imm = 0x2C6
jmp 0x8f1a9
movl $0x2c4, %edi            # imm = 0x2C4
callq 0x8e09f
movl $0x0, 0x2dda28(%rip)    # 0x36cbe0
callq 0x8df68
leaq 0x1af1fc(%rip), %rax    # 0x23e3c0
cmpq $0x0, (%rax)
setne %al
leaq 0x19442e(%rip), %rcx    # 0x223600
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8f1e7
callq 0xafe8
leaq 0x1afdb2(%rip), %rax    # 0x23efa0
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ac626(%rip), %rdi    # 0x33b830
movl $0x46, %esi
callq 0x9100
testq %rax, %rax
je 0x8f225
movl $0x2bd, 0x2dd9bd(%rip)  # imm = 0x2BD
jmp 0x8f1f4
leaq 0x2ac604(%rip), %rdi    # 0x33b830
movl $0x47, %esi
callq 0x9100
testq %rax, %rax
je 0x8f247
movl $0x2be, 0x2dd99b(%rip)  # imm = 0x2BE
jmp 0x8f1f4
leaq 0x2ac5e2(%rip), %rdi    # 0x33b830
movl $0x48, %esi
callq 0x9100
testq %rax, %rax
je 0x8f269
movl $0x2bf, 0x2dd979(%rip)  # imm = 0x2BF
jmp 0x8f1f4
leaq 0x2ac5c0(%rip), %rdi    # 0x33b830
movl $0x49, %esi
callq 0x9100
testq %rax, %rax
je 0x8f28e
movl $0x2c0, 0x2dd957(%rip)  # imm = 0x2C0
jmp 0x8f1f4
leaq 0x2ac59b(%rip), %rdi    # 0x33b830
movl $0x4a, %esi
callq 0x9100
testq %rax, %rax
je 0x8f2b3
movl $0x2c1, 0x2dd932(%rip)  # imm = 0x2C1
jmp 0x8f1f4
leaq 0x2ac576(%rip), %rdi    # 0x33b830
movl $0x4b, %esi
callq 0x9100
testq %rax, %rax
je 0x8f2d8
movl $0x2c2, 0x2dd90d(%rip)  # imm = 0x2C2
jmp 0x8f1f4
leaq 0x2ac551(%rip), %rdi    # 0x33b830
movl $0x4c, %esi
callq 0x9100
testq %rax, %rax
je 0x8f2fd
movl $0x2c3, 0x2dd8e8(%rip)  # imm = 0x2C3
jmp 0x8f1f4
leaq 0x2ac52c(%rip), %rdi    # 0x33b830
movl $0x4f, %esi
callq 0x9100
testq %rax, %rax
je 0x8f322
movl $0x2c4, 0x2dd8c3(%rip)  # imm = 0x2C4
jmp 0x8f1f4
leaq 0x2ac507(%rip), %rdi    # 0x33b830
movl $0x50, %esi
callq 0x9100
testq %rax, %rax
je 0x8f347
movl $0x2c5, 0x2dd89e(%rip)  # imm = 0x2C5
jmp 0x8f1f4
leaq 0x2ac4e2(%rip), %rdi    # 0x33b830
movl $0x51, %esi
callq 0x9100
testq %rax, %rax
je 0x8f36c
movl $0x2c6, 0x2dd879(%rip)  # imm = 0x2C6
jmp 0x8f1f4
leaq 0x2ac4bd(%rip), %rdi    # 0x33b830
movl $0x52, %esi
callq 0x9100
testq %rax, %rax
je 0x8f391
movl $0x2c7, 0x2dd854(%rip)  # imm = 0x2C7
jmp 0x8f1f4
leaq 0x2ac498(%rip), %rdi    # 0x33b830
movl $0x54, %esi
callq 0x9100
testq %rax, %rax
je 0x8f3b6
movl $0x2c8, 0x2dd82f(%rip)  # imm = 0x2C8
jmp 0x8f1f4
leaq 0x2ac473(%rip), %rdi    # 0x33b830
movl $0x57, %esi
callq 0x9100
testq %rax, %rax
je 0x8f3db
movl $0x2c9, 0x2dd80a(%rip)  # imm = 0x2C9
jmp 0x8f1f4
leaq 0x2ac44e(%rip), %rdi    # 0x33b830
movl $0x58, %esi
callq 0x9100
testq %rax, %rax
je 0x8f400
movl $0x2ca, 0x2dd7e5(%rip)  # imm = 0x2CA
jmp 0x8f1f4
leaq 0x2ac429(%rip), %rdi    # 0x33b830
movl $0x59, %esi
callq 0x9100
testq %rax, %rax
je 0x8f425
movl $0x2cb, 0x2dd7c0(%rip)  # imm = 0x2CB
jmp 0x8f1f4
leaq 0x2ac404(%rip), %rdi    # 0x33b830
movl $0x5a, %esi
callq 0x9100
testq %rax, %rax
je 0x8f1f4
movl $0x2cd, 0x2dd797(%rip)  # imm = 0x2CD
jmp 0x8f1f4