// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
callq 0xb9c3
testl %eax, %eax
je 0xaca2e
movl %r14d, %edi
callq 0x1ea2c
cmpl $0xa, %r14d
jne 0xaca40
callq 0x584d5
movl %eax, %ebx
leaq 0x2618c3(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xaca66
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0xaca63
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1e6a0
movl $0x10, %edi
callq 0xbb11
movzbl %al, %ebx
leaq 0x26188c(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x24852(%rax)
je 0xaca66
addq $0x24852, %rax          # imm = 0x24852
movb $0x0, (%rax)
leaq 0x28e81f(%rip), %r15    # 0x33b28c
movl (%r15), %eax
cmpl $0x1, %eax
je 0xacaa8
testl %eax, %eax
jne 0xacabe
cmpl $0xd, %ebx
je 0xaca83
cmpl $0xa, %ebx
jne 0xaca8f
movl $0x1, (%r15)
callq 0x58682
leaq 0x28e7ee(%rip), %rax    # 0x33b284
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28e7e7(%rip), %rax    # 0x33b288
movl %ecx, (%rax)
jmp 0xacb2d
cmpl $0xd, %ebx
je 0xacab2
cmpl $0xa, %ebx
jne 0xacb0c
leaq 0x28e7cb(%rip), %rax    # 0x33b284
cmpl $0x0, (%rax)
je 0xacb2d
leaq 0x28e7bf(%rip), %rax    # 0x33b284
cmpl $0x0, (%rax)
je 0xacadc
movl %r14d, %edi
callq 0xac921
movl $0x1, 0x2bf1b8(%rip)    # 0x36bc94
leaq 0x28e7a1(%rip), %rax    # 0x33b284
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28e79a(%rip), %rax    # 0x33b288
movl %ecx, (%rax)
cmpl $0xd, %ebx
je 0xacafa
cmpl $0xa, %ebx
jne 0xacb03
movl $0x1, (%r15)
jmp 0xacb2d
movl $0x0, (%r15)
jmp 0xacb2d
leaq 0x28e771(%rip), %rcx    # 0x33b284
movslq (%rcx), %rax
cmpq $0xfff, %rax            # imm = 0xFFF
jg 0xacadc
leal 0x1(%rax), %edx
movl %edx, (%rcx)
leaq 0x28d756(%rip), %rcx    # 0x33a280
movb %bl, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq