// File: /workspace/github_cpp_makefile_star2_O1/ke6jjj[P]r-dat/DATTrackFramer.cc
// Function: DATTrackFramer::TrackDetected(bool)
void
DATTrackFramer::TrackDetected(bool up)
{
  mTracking = up;
  
  //
  // Wait until tracking is complete (goes down).
  //
  if (up)
    return;

  //
  // Our current track is complete. Give it a chance to perform
  // all error correction.
  //
  mCurrentTrack->Complete();
  
  //
  // If there were any ATF tones detected, use the majority count to
  // determine whether this was a negative azimuth track or a positive
  // azimuth track.
  //
  // Currently only ATF3 (negative azimuth signal) is likely to be detected,
  // so if its count is high enough, assume that the track is an A track.
  //
  printf("Track ATF3 Count: %d\n", mATF3Count);
  if (mATF3Count > mATF3Threshold) {
    mCurrentTrack->SetHead(Track::HEAD_A);
  }

  //
  // See if this track completes a frame (a pair of tracks).
  //
  if (mLastTrack == NULL) {
    //
    // There is no previous track. Just stash this one away.
    //
    mLastTrack = mCurrentTrack;
  } else {
    //
    // We have a previous track. Are these two a pair or are they
    // separate?
    //
    if (mReceiver.IsFrame(*mLastTrack, *mCurrentTrack)) {
      //
      // According to the downstream frame receiver, these two
      // tracks pair into a full frame. Give them to the
      // receiver as such.
      //
      mReceiver.ReceiveFrame(*mLastTrack, *mCurrentTrack);
      
      //
      // The pair have been shipped off. Prepare for a new set.
      //
      delete mLastTrack;
      delete mCurrentTrack;
      mLastTrack = NULL;
    } else {
      //
      // These two don't pair. Dump the last track and continue
      // searching.
      //
      delete mLastTrack;
      mLastTrack = mCurrentTrack;
    }
  }

  //
  // Reset the automatic track finding tone counts.
  //
  mATF2Count = 0;
  mATF3Count = 0;

  //
  // Prepare a new track.
  //
  mCurrentTrack = new Track(Track::HEAD_UNKNOWN);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movb %sil, 0x8(%rdi)
testl %esi, %esi
jne 0x3181
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x362e
movl 0x14(%rbx), %esi
leaq 0x6aa1(%rip), %rdi      # 0x9b4b
xorl %eax, %eax
callq 0x2040
movl 0x14(%rbx), %eax
cmpl 0xc(%rbx), %eax
jle 0x30c4
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0x3498
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x3153
movq 0x18(%rbx), %rdx
movq 0x28(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
je 0x3135
movq 0x28(%rbx), %rdi
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x3113
movq %r14, %rdi
callq 0x3492
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x3131
movq %r14, %rdi
callq 0x3492
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
xorl %eax, %eax
jmp 0x3157
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x3153
movq %r14, %rdi
callq 0x3492
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
movq 0x18(%rbx), %rax
movq %rax, 0x20(%rbx)
movq $0x0, 0x10(%rbx)
movl $0x25d0, %edi           # imm = 0x25D0
callq 0x20e0
movq %rax, %r14
movq %rax, %rdi
movl $0x2, %esi
callq 0x3420
movq %r14, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x21d0
nop