// File: 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
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x1b1826(%rip), %rax    # 0x29d578
cmpq $0x0, (%rax)
je 0xebd5d
jmp 0xebfdb
movl -0x4(%rbp), %edi
callq 0xcad0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0xebe09
movl -0x4(%rbp), %edi
callq 0x2b610
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0xebd89
cmpl $0x1, -0xc(%rbp)
jne 0xebe04
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x28172b(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movb $0x2, 0x2250(%rax)
movl -0x4(%rbp), %edi
callq 0x2bd30
movl -0x4(%rbp), %edi
movl $0x7f, %esi
callq 0xc0e0
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x2816f9(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2230(%rax)
jle 0xebdfa
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x2816da(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x4, 0x2234(%rax)
movl $0x202, %edi            # imm = 0x202
callq 0x9ec0
jmp 0xebfdb
movl -0x4(%rbp), %edi
callq 0x2bd30
cmpl $0xa, -0x4(%rbp)
jne 0xebe3f
callq 0x79fc0
movb %al, -0x5(%rbp)
leaq 0x28169a(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xebe3d
leaq 0x28168a(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
jmp 0xebe67
callq 0x7a030
movb %al, -0x5(%rbp)
leaq 0x281672(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x1e132(%rax)
je 0xebe65
leaq 0x281662(%rip), %rax    # 0x36d4c0
movb $0x0, 0x1e132(%rax)
jmp 0xebe67
movb -0x5(%rbp), %al
movb %al, 0x2e5a1c(%rip)     # 0x3d188c
leaq 0x2ac5d5(%rip), %rax    # 0x39844c
cmpl $0x0, (%rax)
jne 0xebebf
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xebe8e
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xebea0
leaq 0x2ac5b7(%rip), %rax    # 0x39844c
movl $0x1, (%rax)
callq 0x7a1d0
leaq 0x2ac59d(%rip), %rax    # 0x398444
movl $0x0, (%rax)
leaq 0x2ac594(%rip), %rax    # 0x398448
movl $0x0, (%rax)
jmp 0xebfdb
leaq 0x2ac586(%rip), %rax    # 0x39844c
cmpl $0x1, (%rax)
jne 0xebf2f
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xebedd
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xebef0
leaq 0x2ac560(%rip), %rax    # 0x398444
cmpl $0x0, (%rax)
jne 0xebeee
jmp 0xebfdb
jmp 0xebf31
leaq 0x2ac54d(%rip), %rax    # 0x398444
cmpl $0x1000, (%rax)         # imm = 0x1000
jge 0xebf28
movb -0x5(%rbp), %dl
leaq 0x2ac53b(%rip), %rax    # 0x398444
movl (%rax), %eax
movl %eax, %esi
addl $0x1, %esi
leaq 0x2ac52d(%rip), %rcx    # 0x398444
movl %esi, (%rcx)
movslq %eax, %rcx
leaq 0x2ab51d(%rip), %rax    # 0x397440
movb %dl, (%rax,%rcx)
jmp 0xebf2a
jmp 0xebf8f
jmp 0xebfd9
jmp 0xebf31
leaq 0x2ac50c(%rip), %rax    # 0x398444
cmpl $0x0, (%rax)
je 0xebf8d
leaq 0x27ffa8(%rip), %rax    # 0x36beec
cmpl $0x49, (%rax)
jne 0xebf7b
leaq 0x18e344(%rip), %rax    # 0x27a294
cmpl $0x0, (%rax)
je 0xebf7b
leaq 0x18e33c(%rip), %rax    # 0x27a298
movl (%rax), %eax
addl $0x1, %eax
leaq 0x18e330(%rip), %rcx    # 0x27a298
movl %eax, (%rcx)
leaq 0x18e323(%rip), %rcx    # 0x27a294
cltd
idivl (%rcx)
cmpl $0x0, %edx
je 0xebf7b
jmp 0xebf83
movl -0x4(%rbp), %edi
callq 0xa5990
movl $0x1, 0x2deee7(%rip)    # 0x3cae74
jmp 0xebf8f
leaq 0x2ac4ae(%rip), %rax    # 0x398444
movl $0x0, (%rax)
leaq 0x2ac4a5(%rip), %rax    # 0x398448
movl $0x0, (%rax)
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xebfbb
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xebfca
leaq 0x2ac48a(%rip), %rax    # 0x39844c
movl $0x1, (%rax)
jmp 0xebfd7
leaq 0x2ac47b(%rip), %rax    # 0x39844c
movl $0x0, (%rax)
jmp 0xebfd9
jmp 0xebfdb
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)