   } \
 }\
 
+    edgesRead = 0;
+
     for (int i = 1; i <= bitcount; i++) {
         while (!N64_QUERY)
           FAIL_TIMEOUT;
         long lowTime = readTimer();
         startTimer();
+        edgesRead++;
         while (N64_QUERY)
           FAIL_TIMEOUT;
         long highTime = readTimer();
         startTimer();
+        edgesRead++;
         char bit = (lowTime < highTime);
         newByte <<= 1;
         newByte |= bit;

  // Initialize SD card
  if (!sd.begin()) {
    m64OpenSuccess = false; 
    Serial.println(F("SD initialization failed!"));
    return;
  }
  Serial.println(F("SD initialization done."));

  // Setup buffer
  bufferALoaded = false;
  bufferBLoaded = false;
  bufferAInUse = false;
  bufferBInUse = false;
  bufferEndPos = -1;
  bufferOneMore = true;
  bufferPos = -1;

  Serial.println(F("Initialization done."));
}

void logFrame()


static void n64Interrupt()
{
    noInterrupts();

    unsigned char data, addr;
    int ticksSinceLast = readTimer();
    startTimer();
    volatile uint32_t *config = portConfigRegister(N64_PIN);
    uint32_t oldConfig = *config;
