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

   // This routine buffers up an incoming ADC message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_dac_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) {  // ADC is main input decice
      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 {  // ADC is auxiliary input device (/et=)
      c = get_dac_char();  // aaattt
      if(com[DAC_PORT].rcv_error) {      // parity/framing/overrun errors
         com[DAC_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }

   last_c = c;

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

      if(dac_wptr < MAX_TSIP) {   // add char to the message buffer
         dac_buf[dac_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
//         dac_error |= 0x8000;  // aaattt
         goto rst_msg;
      }
   }
   else {  // end of message
      dac_end:
      if(dac_wptr) {           // we have a message
         decode_dac_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      dac_wptr = 0;     // prepare for next message
      dac_rptr = 0;
      if((c == 0x0D) || (c == 0x0A)) dac_sync = 1;
      else dac_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 0xea705
movl -0x4(%rbp), %edi
callq 0x2b610
jmp 0xea896
movl -0x4(%rbp), %edi
callq 0x2bd30
cmpl $0xa, -0x4(%rbp)
jne 0xea73b
callq 0x79fc0
movb %al, -0x5(%rbp)
leaq 0x282d9e(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x17a12(%rax)
je 0xea739
leaq 0x282d8e(%rip), %rax    # 0x36d4c0
movb $0x0, 0x17a12(%rax)
jmp 0xea763
callq 0x7a130
movb %al, -0x5(%rbp)
leaq 0x282d76(%rip), %rax    # 0x36d4c0
cmpb $0x0, 0x24852(%rax)
je 0xea761
leaq 0x282d66(%rip), %rax    # 0x36d4c0
movb $0x0, 0x24852(%rax)
jmp 0xea763
movb -0x5(%rbp), %al
movb %al, 0x2e6d04(%rip)     # 0x3d1470
leaq 0x2afcf9(%rip), %rax    # 0x39a46c
cmpl $0x0, (%rax)
jne 0xea7bb
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xea78a
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xea79c
leaq 0x2afcdb(%rip), %rax    # 0x39a46c
movl $0x1, (%rax)
callq 0x7a1d0
leaq 0x2afcc1(%rip), %rax    # 0x39a464
movl $0x0, (%rax)
leaq 0x2afcb8(%rip), %rax    # 0x39a468
movl $0x0, (%rax)
jmp 0xea896
leaq 0x2afcaa(%rip), %rax    # 0x39a46c
cmpl $0x1, (%rax)
jne 0xea828
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xea7d9
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xea7ec
leaq 0x2afc84(%rip), %rax    # 0x39a464
cmpl $0x0, (%rax)
jne 0xea7ea
jmp 0xea896
jmp 0xea82a
leaq 0x2afc71(%rip), %rax    # 0x39a464
cmpl $0x1000, (%rax)         # imm = 0x1000
jge 0xea824
movb -0x5(%rbp), %dl
leaq 0x2afc5f(%rip), %rax    # 0x39a464
movl (%rax), %eax
movl %eax, %esi
addl $0x1, %esi
leaq 0x2afc51(%rip), %rcx    # 0x39a464
movl %esi, (%rcx)
movslq %eax, %rcx
leaq 0x2aec41(%rip), %rax    # 0x399460
movb %dl, (%rax,%rcx)
jmp 0xea826
jmp 0xea84a
jmp 0xea894
jmp 0xea82a
leaq 0x2afc33(%rip), %rax    # 0x39a464
cmpl $0x0, (%rax)
je 0xea848
movl -0x4(%rbp), %edi
callq 0xea590
movl $0x1, 0x2e062c(%rip)    # 0x3cae74
jmp 0xea84a
leaq 0x2afc13(%rip), %rax    # 0x39a464
movl $0x0, (%rax)
leaq 0x2afc0a(%rip), %rax    # 0x39a468
movl $0x0, (%rax)
movzbl -0x5(%rbp), %eax
cmpl $0xd, %eax
je 0xea876
movzbl -0x5(%rbp), %eax
cmpl $0xa, %eax
jne 0xea885
leaq 0x2afbef(%rip), %rax    # 0x39a46c
movl $0x1, (%rax)
jmp 0xea892
leaq 0x2afbe0(%rip), %rax    # 0x39a46c
movl $0x0, (%rax)
jmp 0xea894
jmp 0xea896
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)