 // XXX Keyboard: Map Enter to both newline AND buttonA
 // XXX Keyboard: Delete = buttonA (same code 0x7f). Change delete code?
 // XXX Keyboard: Is it possible to mimic key hold-down properly???
+// XXX Timeouts/reset in case of hanging (dead man switch function?)
 // XXX Embed a Gigatron Terminal program. Or better: GigaMon
 
 /*----------------------------------------------------------------------+


    // Check that segment doesn't cross the page boundary
    if ((address & 255) + len > 256) {
      Serial.println("!Data error (page overflow)");
      return;
    }

    // Send downstream
    Serial.print(":Loading ");
    Serial.print(len);
    Serial.print(" bytes at $");
    Serial.println(address, HEX);
    Serial.flush();

    sendGt1Segment(address, len, segment);

    // Signal that we're ready to receive more

  case 'Q': sendController(~buttonSelect, 2); break;
  case 'E': sendController(~buttonStart,  2); break;
  case 0: /* Empty line */                    break;
  #if hasSerial
    default:
      Serial.println("!Unknown command (type 'H' for help)");
  #endif
  }
  prompt();
}

void doVersion()
{
  #if hasSerial
    Serial.println(":Gigatron Interface Adapter [" version "]\n"
                   ":Type 'H' for help");
  #endif
}

void doHelp()
{
  #if hasSerial
    Serial.println(":Commands are");
    Serial.println(": V        Show version");
    Serial.println(": H        Show this help");
    Serial.println(": R        Reset Gigatron");
    Serial.println(": L        Start Loader");
    Serial.println(": P        Transfer object file from PROGMEM");
    Serial.println(": U        Transfer object file from USB");
    Serial.println(": W/A/S/D  Up/left/down/right arrow");
    Serial.println(": Z/X      A/B button ");
    Serial.println(": Q/E      Select/start button");
  #endif
}

void doReset()
{
  // Soft reset: hold start for >128 frames (>2.1 seconds)
  #if hasSerial
    Serial.println(":Resetting Gigatron");
    Serial.flush();
  #endif
  sendController(~buttonStart, 128+32);

  // Wait for main menu to be ready
