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

   // This routine buffers up an incoming 5071A message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_cs_msg()

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

   c = get_com_char();

   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 message, search for a '>'
      if(c == '>') {
         tsip_sync = 1;
         get_sync_time();
      }
      else {
         tsip_sync = 1;
         get_sync_time();
      }

      rst_msg:
      tsip_wptr = 0;
      tsip_rptr = 0;
      return;
   }
   else if(tsip_sync == 1) { // '>' has been seen, now build the message
      if(c == 0x0D) goto cs_end; 
      else if(c == 0x0A) goto cs_end; 
      else if(c == '>')  {  // null response to command
         decode_cs_msg();
         packet_end = 1;
         tsip_sync = 1; 
         tsip_rptr = 0;
         tsip_wptr = 0;
         return;
      }

      if(tsip_wptr < MAX_TSIP) {  // so add it to the message buffer
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_sync = 0;
         goto rst_msg;
      }
   }
   else {
      cs_end:
      decode_cs_msg();
      packet_end = 1;
      tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0xa, %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xdb9d6
movl $0xa, %edi
callq 0x2b610
jmp 0xdbb44
movl $0xa, %edi
callq 0x2bd30
callq 0x79fc0
movb %al, -0x1(%rbp)
leaq 0x291ad1(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xdba06
leaq 0x291ac1(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
leaq 0x2bba29(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xdba61
movzbl -0x1(%rbp), %eax
cmpl $0x3e, %eax
jne 0xdba31
leaq 0x2bba11(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
jmp 0xdba42
leaq 0x2bb9fe(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
jmp 0xdba44
leaq 0x2bb9e7(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2bb9dd(%rip), %rax    # 0x397434
movw $0x0, (%rax)
jmp 0xdbb44
leaq 0x2bb9ce(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xdbb25
movzbl -0x1(%rbp), %eax
cmpl $0xd, %eax
jne 0xdba82
jmp 0xdbb27
movzbl -0x1(%rbp), %eax
cmpl $0xa, %eax
jne 0xdba90
jmp 0xdbb27
movzbl -0x1(%rbp), %eax
cmpl $0x3e, %eax
jne 0xdbace
callq 0xdbb50
movl $0x1, 0x2ef3cc(%rip)    # 0x3cae74
leaq 0x2bb987(%rip), %rax    # 0x397436
movw $0x1, (%rax)
leaq 0x2bb979(%rip), %rax    # 0x397434
movw $0x0, (%rax)
leaq 0x2bb96b(%rip), %rax    # 0x397432
movw $0x0, (%rax)
jmp 0xdbb44
jmp 0xdbad0
jmp 0xdbad2
leaq 0x2bb959(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jge 0xdbb12
movb -0x1(%rbp), %dl
leaq 0x2bb945(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2bb934(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2ba923(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
jmp 0xdbb23
leaq 0x2bb91d(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xdba44
jmp 0xdbb42
jmp 0xdbb27
callq 0xdbb50
movl $0x1, 0x2ef33e(%rip)    # 0x3cae74
leaq 0x2bb8f9(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xdbb44
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)