// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_rcvr_ticc_message(unsigned int)
void get_rcvr_ticc_message(unsigned port)
{
u08 c;
static u08 last_c = 0;

   // This routine buffers up an incoming tsip message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_tsip_msg()
   // Messages can end with 0x0D, 0x0A, or both.

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

   if(port == RCVR_PORT) {  // TICC on the main input decice (/rxi)
      c = get_com_char();
      if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
         com[RCVR_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }
   else {  // TICC on the auxiliary input device (/ei=)
      c = get_ticc_char();  // aaattt
      if(com[port].rcv_error) {      // parity/framing/overrun errors
         com[port].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }


   last_c = c;

   if(tsip_sync == 0) {    // syncing to start of message, search for a line feed
      if((c == 0x0D) || (c == 0x0A)) {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      return;
   }
   else if(tsip_sync == 1) { // 0x0A has been seen, now build the message
      if((c == 0x0D) || (c == 0x0A)) {
         if(tsip_wptr == 0) return; // end-of-line with no data in the message buffer
         goto tsip_end;  // end of message
      }

      if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         tsip_buf[tsip_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else {  // end of message
      tsip_end:
      if(tsip_wptr) {           // we have a message
         if((ticc_mode == 'I') && plm_freq && (++plm_cycles % plm_freq)) ;   // decimate ticc input
         else decode_ticc_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      tsip_wptr = 0;     // prepare for next message
      tsip_rptr = 0;
      if((c == 0x0D) || (c == 0x0A)) tsip_sync = 1;
      else tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %edi
callq 0xcad0
cmpl $0x0, %eax
jne 0xec015
movl -0x4(%rbp), %edi
callq 0x2b610
jmp 0xec22c
movl -0x4(%rbp), %edi
callq 0x2bd30
cmpl $0xa, -0x4(%rbp)
jne 0xec04b
callq 0x79fc0
movb %al, -0x5(%rbp)
leaq 0x28148e(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xec049
leaq 0x28147e(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
jmp 0xec091
callq 0x7a030
movb %al, -0x5(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x281461(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpb $0x0, 0x2252(%rax)
je 0xec08f
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x281442(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movb $0x0, 0x2252(%rax)
jmp 0xec091
movb -0x5(%rbp), %al
movb %al, 0x2e57f3(%rip)     # 0x3d188d
leaq 0x2ab395(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xec0e9
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xec0bb
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xec0cc
leaq 0x2ab374(%rip), %rax    # 0x397436
movw $0x1, (%rax)
callq 0x7a1d0
leaq 0x2ab35f(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2ab355(%rip), %rax    # 0x397434
movw $0x0, (%rax)
jmp 0xec22c
leaq 0x2ab346(%rip), %rax    # 0x397436
movzwl (%rax), %eax
cmpl $0x1, %eax
jne 0xec183
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xec10e
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xec124
leaq 0x2ab31d(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xec122
jmp 0xec22c
jmp 0xec185
leaq 0x2ab307(%rip), %rax    # 0x397432
movzwl (%rax), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jge 0xec164
movb -0x5(%rbp), %dl
leaq 0x2ab2f3(%rip), %rax    # 0x397432
movw (%rax), %ax
movw %ax, %si
addw $0x1, %si
leaq 0x2ab2e2(%rip), %rcx    # 0x397432
movw %si, (%rcx)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2aa2d1(%rip), %rax    # 0x396430
movb %dl, (%rax,%rcx)
jmp 0xec17e
leaq 0x1b1fe5(%rip), %rax    # 0x29e150
movl (%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
leaq 0x1b1fd6(%rip), %rax    # 0x29e150
movl %ecx, (%rax)
jmp 0xec1e4
jmp 0xec22a
jmp 0xec185
leaq 0x2ab2a6(%rip), %rax    # 0x397432
cmpw $0x0, (%rax)
je 0xec1e2
leaq 0x27fd53(%rip), %rax    # 0x36beec
cmpl $0x49, (%rax)
jne 0xec1d0
leaq 0x18e0ef(%rip), %rax    # 0x27a294
cmpl $0x0, (%rax)
je 0xec1d0
leaq 0x18e0e7(%rip), %rax    # 0x27a298
movl (%rax), %eax
addl $0x1, %eax
leaq 0x18e0db(%rip), %rcx    # 0x27a298
movl %eax, (%rcx)
leaq 0x18e0ce(%rip), %rcx    # 0x27a294
cltd
idivl (%rcx)
cmpl $0x0, %edx
je 0xec1d0
jmp 0xec1d8
movl -0x4(%rbp), %edi
callq 0xa5990
movl $0x1, 0x2dec92(%rip)    # 0x3cae74
jmp 0xec1e4
leaq 0x2ab247(%rip), %rax    # 0x397432
movw $0x0, (%rax)
leaq 0x2ab23d(%rip), %rax    # 0x397434
movw $0x0, (%rax)
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xec20e
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xec21c
leaq 0x2ab221(%rip), %rax    # 0x397436
movw $0x1, (%rax)
jmp 0xec228
leaq 0x2ab213(%rip), %rax    # 0x397436
movw $0x0, (%rax)
jmp 0xec22a
jmp 0xec22c
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)