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

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

   if(ticc_sim_file) {  //lfs
      return;
   }

   i = SERIAL_DATA_AVAILABLE(port);
   if(i == 0) {
      i = check_com_timer(port);
      
      if(i || (i == DATA_LOSS_REINIT)) {
         com[port].com_data_lost = DATA_LOSS_NO_INIT;  // prevents futile re-init attempts
         reset_com_timer(port);
         init_com(port, 127);
////com[port].com_running = 4;
if(com[port].com_running > 0) com[port].process_com = 4;
//lfs com[port].process_com = 4;
///      set_ticc_config(port, 0);   // get current config from menu header
BEEP(514);
      }
      return;
   }
   else {
      reset_com_timer(port);
   }

   if(port == RCVR_PORT) {  // TICC is 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 is auxiliary input device (/ei=)
      c = get_ticc_char();  // aaattt
      if(com[TICC_PORT].rcv_error) {      // parity/framing/overrun errors
         com[TICC_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }

   last_c = c;

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

      if(ticc_wptr < MAX_TSIP) {   // add char to the message buffer
         ticc_buf[ticc_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
//         ticc_error |= 0x8000;  // aaattt
         goto rst_msg;
      }
   }
   else {  // end of message
      ticc_end:
      if(ticc_wptr) {           // we have a message
         if((ticc_mode == 'I') && plm_freq && (++plm_cycles % plm_freq)) ;   //lfs decimate ticc input
         else decode_ticc_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      ticc_wptr = 0;     // prepare for next message
      ticc_rptr = 0;
      if((c == 0x0D) || (c == 0x0A)) ticc_sync = 1;
      else ticc_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x1907bf(%rip), %rax    # 0x23e398
cmpq $0x0, (%rax)
je 0xadbea
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %edi, %ebx
callq 0xb9ad
movl %ebx, %edi
testl %eax, %eax
je 0xadc2c
callq 0x1ea0b
cmpl $0xa, %ebx
jne 0xadc8e
callq 0x584bd
movl %eax, %r14d
leaq 0x2606cc(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xadcaf
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0xadcac
callq 0x1e66a
testl %eax, %eax
je 0xadbdf
movl %ebx, %eax
imulq $0x2260, %rax, %r15     # imm = 0x2260
leaq 0x26069b(%rip), %r14    # 0x30e2e0
movb $0x2, 0x2250(%r14,%r15)
movl %ebx, %edi
callq 0x1ea0b
movl %ebx, %edi
movl $0x7f, %esi
callq 0xb49e
cmpl $0x0, 0x2230(%r14,%r15)
jle 0xadc7a
addq %r15, %r14
movl $0x4, 0x2234(%r14)
movl $0x202, %edi            # imm = 0x202
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9d78
callq 0x5852c
movl %eax, %r14d
leaq 0x260643(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x1e132(%rax)
je 0xadcaf
addq $0x1e132, %rax          # imm = 0x1E132
movb $0x0, (%rax)
leaq 0x28b5b6(%rip), %r15    # 0x33926c
movl (%r15), %eax
cmpl $0x1, %eax
je 0xadcf6
testl %eax, %eax
jne 0xadd1a
cmpb $0xd, %r14b
je 0xadcd1
movzbl %r14b, %eax
cmpl $0xa, %eax
jne 0xadcdd
movl $0x1, (%r15)
callq 0x58672
leaq 0x28b580(%rip), %rax    # 0x339264
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28b579(%rip), %rax    # 0x339268
movl %ecx, (%rax)
jmp 0xadbdf
cmpb $0xd, %r14b
je 0xadd09
movzbl %r14b, %eax
cmpl $0xa, %eax
jne 0xadda8
leaq 0x28b554(%rip), %rax    # 0x339264
cmpl $0x0, (%rax)
jne 0xadd26
jmp 0xadbdf
leaq 0x28b543(%rip), %rax    # 0x339264
cmpl $0x0, (%rax)
je 0xadd6d
leaq 0x25efdf(%rip), %rax    # 0x30cd0c
cmpl $0x49, (%rax)
sete %al
leaq 0x16d37a(%rip), %rcx    # 0x21b0b4
movl (%rcx), %ecx
testl %ecx, %ecx
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0xadd5c
leaq 0x16d369(%rip), %rdx    # 0x21b0b8
movl (%rdx), %eax
incl %eax
movl %eax, (%rdx)
cltd
idivl %ecx
testl %edx, %edx
jne 0xadd63
movl %ebx, %edi
callq 0x788c6
movl $0x1, 0x2bdf27(%rip)    # 0x36bc94
leaq 0x28b4f0(%rip), %rax    # 0x339264
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28b4e9(%rip), %rax    # 0x339268
movl %ecx, (%rax)
cmpb $0xd, %r14b
je 0xadd90
movzbl %r14b, %eax
cmpl $0xa, %eax
jne 0xadd9c
movl $0x1, (%r15)
jmp 0xadbdf
movl $0x0, (%r15)
jmp 0xadbdf
leaq 0x28b4b5(%rip), %rcx    # 0x339264
movslq (%rcx), %rax
cmpq $0xfff, %rax            # imm = 0xFFF
jg 0xadd6d
leal 0x1(%rax), %edx
movl %edx, (%rcx)
leaq 0x28a49a(%rip), %rcx    # 0x338260
movb %r14b, (%rcx,%rax)
jmp 0xadbdf