   byte lastByte = -checksum;   // Checksum must come out as 0
   sendBits(lastByte, 8);
   checksum = lastByte;         // Concatenate checksums
-  PORTB |= 1<<PORTB5;          // Send 1 when idle
+  PORTB |= 1<<SER_DATA;          // Send 1 when idle
 }
 
 void sendFirst(byte value, byte n)
 {
   // Wait vertical sync NEGATIVE edge to sync with loader
-  while (~PINB & (1<<PORTB4)) // Ensure vSync is HIGH first
+  while (~PINB & (1<<SER_LATCH)) // Ensure vSync is HIGH first
     ;
-  while (PINB & (1<<PORTB4)) // Then wait for vSync to drop
+  while (PINB & (1<<SER_LATCH)) // Then wait for vSync to drop
     ;
   sendBits(value, n);
 }

#define buttonSelect 32
#define buttonB      64
#define buttonA      128

/*
 *  Loader protocol
 */

#define N 60 // Payload bytes per transmission frame
byte checksum; // Global is simplest

/*
 *  PS/2 keyboard hookup to Arduino
 */

#include <PS2Keyboard.h> // Install from the Arduino IDE's Library Manager

PS2Keyboard keyboard;

// Pins for PS/2 keyboard (Arduino Uno)
const int keyboardClockPin = 3;  // Pin 2 or 3 for IRQ
const int keyboardDataPin  = 4;  // Any available free pin

// Keyboard
// Pin  4  PS/2 Data
// Pin  3  PS/2 Clock

/*
 *  Setup runs once when the Arduino wakes up


  // Wait for vBlank to start so we're 100% sure to skip one frame and
  // the checksum resets on the other side. (This is a bit pedantic)
  while (PINB & (1<<SER_LATCH)) // ~160 us
    ;
}

