// File: /workspace/github_cpp_makefile_star2_O2/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 0x3008
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x3498
movl 0x14(%rbx), %esi
leaq 0x5c25(%rip), %rdi      # 0x8b5b
xorl %eax, %eax
callq 0x2040
movl 0x14(%rbx), %eax
cmpl 0xc(%rbx), %eax
jle 0x2f50
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0x3318
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x2fdf
movq 0x18(%rbx), %rdx
movq 0x28(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
je 0x2fc1
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 0x2f92
movq %r14, %rdi
callq 0x3312
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x2fb0
movq %r14, %rdi
callq 0x3312
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
xorl %eax, %eax
jmp 0x2fe3
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x2fd2
movq %r14, %rdi
callq 0x3312
movl $0x25d0, %esi           # imm = 0x25D0
movq %r14, %rdi
callq 0x20f0
movq 0x18(%rbx), %rax
movq %rax, 0x20(%rbx)
andq $0x0, 0x10(%rbx)
movl $0x25d0, %edi           # imm = 0x25D0
callq 0x20e0
movq %rax, %r14
pushq $0x2
popq %rsi
movq %rax, %rdi
callq 0x3288
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 0x21e0