// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_prs_message()
void get_prs_message()
{
u08 c;
static int row=0;

   // This routine buffers up an incoming PRS-10 message.  It is also used
   // for the SA35 and Spectratime SRO100 and LPFRS devices.  When the end of
   // the message is seen, the message is parsed and decoded with 
   // decode_prs_msg(), etc.

   if(SERIAL_DATA_AVAILABLE(RCVR_PORT) == 0) {
      check_com_timer(RCVR_PORT);
      return;
   }
   else {
      reset_com_timer(RCVR_PORT);
   }

   c = get_com_char();
   if(c == 0x11) {    // we pretty much ignore XON/XOFF
      return;  // XON
   }
   else if(c == 0x13) {
      Sleep(200);
      return;  // XOFF
   }

   if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
      com[RCVR_PORT].rcv_error = 0;
//!!!!!qqqq    goto rst_msg;
   }

   if(tsip_sync == 0) {    // syncing to start of messaage
      tsip_sync = 1;
      get_sync_time();
      tsip_wptr = 0;
      tsip_rptr = 0;
      goto build_msg;
   }
   else if(tsip_sync == 1) { // build the message
      build_msg:
      if(c == 0x0D) goto prs_end; 
      else if(c == 0x0A) goto prs_end; 

      if(tsip_wptr < (MAX_TSIP-1)) {  // so add it to the message buffer
         tsip_buf[tsip_wptr++] = c;
         tsip_buf[tsip_wptr] = 0;
      }
      else {
         goto rst_msg;
      }
   }
   else {
      prs_end:
      if(rcvr_type == SA35_RCVR) {
         if(tsip_wptr) decode_sa35_msg();
      }
      else if(rcvr_type == SRO_RCVR) {
         if(tsip_wptr) decode_sro_msg();
      }
      else if(rcvr_type == LPFRS_RCVR) {
         if(tsip_wptr) decode_lpfrs_msg();
      }
      else decode_prs_msg();
      packet_end = 1;

      rst_msg:
      tsip_sync = 0;
      tsip_wptr = 0;
      tsip_rptr = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0xa, %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xc21e6
movl $0xa, %edi
callq 0x2b610
jmp 0xc23af
movl $0xa, %edi
callq 0x2bd30
callq 0x79fc0
movb %al, -0x1(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x11, %eax
jne 0xc2206
jmp 0xc23af
movzbl -0x1(%rbp), %eax
cmpl $0x13, %eax
jne 0xc221e
movl $0xc8, %edi
callq 0xb8b0
jmp 0xc23af
jmp 0xc2220
leaq 0x2ab299(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xc223e
leaq 0x2ab289(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
leaq 0x2d51f1(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xc2278
leaq 0x2d51e2(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
leaq 0x2d51cd(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2d51c3(%rip), %rax    # 0x397434
movw $0x0, (%rax)
jmp 0xc2289
leaq 0x2d51b7(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xc2302
jmp 0xc2289
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
jne 0xc2294
jmp 0xc2304
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xc229f
jmp 0xc2304
jmp 0xc22a1
leaq 0x2d518a(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jge 0xc22f8
movb -0x1(%rbp), %dl
leaq 0x2d5176(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2d5165(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2d4154(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
leaq 0x2d514c(%rip), %rax    # 0x397432
movzwl (%rax), %eax
movl %eax, %ecx
leaq 0x2d413e(%rip), %rax    # 0x396430
movb $0x0, (%rax,%rcx)
jmp 0xc22fd
jmp 0xc2389
jmp 0xc23ad
jmp 0xc2304
movabsq $0x1000000000, %rcx     # imm = 0x1000000000
leaq 0x1b579b(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0xc232e
leaq 0x2d5111(%rip), %rax    # 0x397432
cmpw $0x0, (%rax)
je 0xc232c
callq 0xbfb30
jmp 0xc237f
leaq 0x1b577b(%rip), %rax    # 0x277ab0
cmpq $0x8000000, (%rax)      # imm = 0x8000000
jne 0xc2352
leaq 0x2d50ed(%rip), %rax    # 0x397432
cmpw $0x0, (%rax)
je 0xc2350
callq 0xbf210
jmp 0xc237d
leaq 0x1b5757(%rip), %rax    # 0x277ab0
cmpq $0x10000000, (%rax)     # imm = 0x10000000
jne 0xc2376
leaq 0x2d50c9(%rip), %rax    # 0x397432
cmpw $0x0, (%rax)
je 0xc2374
callq 0xc0240
jmp 0xc237b
callq 0xc1980
jmp 0xc237d
jmp 0xc237f
movl $0x1, 0x308aeb(%rip)    # 0x3cae74
leaq 0x2d50a6(%rip), %rax    # 0x397436
movw $0x0, (%rax)
leaq 0x2d5096(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2d508c(%rip), %rax    # 0x397434
movw $0x0, (%rax)
jmp 0xc23af
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)