ADTPro Protocol

Functions

"C" - CD
Change working directory
"Z" - Size
Ask for file size (implies existence test; used as part of Put protocol)
"G" - Get
Initiate disk image download from host
"P" - Put
Inititate disk image upload to host(always overwrite)
"B" - Batch
Inititate batch upload (unique suffix added to specified prefix)
"3" - Send SOS Kernel
Inititate SOS kernel bootstrapping download
"4" - Send SOS Interpreter
Inititate SOS interpreter bootstrapping download
"5" - Send SOS Driver
Inititate SOS driver bootstrapping download
"D" - DIR
DOS ADT compatible listing of the current directory
"R" - Receive
DOS ADT compatible download 140k disk
"S" - Send
DOS ADT compatible upload 140k disk

Change Directory

 Apple sends:
   One byte: "C" ($C3)
   Byte stream: directory name (null terminated)

 Host sends: return code:
   $00 = ok
   $06 = Unable to change directory

Get (Receive) disk (Host -> Apple ][)

 Apple sends: 
   One byte: "G" ($C7)
   Byte stream: file name (null terminated)

 Host sends: return code:
   $00 = Ok
   $02 = File not found (Apple aborts)

 Apple sends:
   $06 = ACK

 (parts = filesize /(40 * 512), remainder = filesize % (40 * 512))
 (loop: parts * 40 blocks + remainder * blocks)

   Host sends:
     2 bytes: current block number (LSB, MSB)
     1 byte: half-block number (2 = bytes 0-255, 1 = bytes 256-511)
     Half-block, RLE encoded
     two bytes:
       CRC (lo)
       CRC (hi)

   Apple sends:
     One byte acknowledgement:
       $06 = ACK (Apple understood the packet, CRC is correct; send next one)
       $15 = NAK (Resend this same packet again: block number tells what Apple
                 is still waiting to get a good packet for)
     Two bytes: current block number (LSB, MSB)
     One byte: half-block number (2 = bytes 0-255, 1 = bytes 256-511)

   Note: if the host receives a NAK, and the Apple is expecting a packet 
         that is one greater than what's just been sent, then an ACK got 
         lost.  Recovery is for the host to go ahead and advance to the next
         block and send that.

 (loop end)

 Apple sends: One byte: number of errors encountered

Put (Send) disk (from Apple ][ to host)

Apple sends:
  One byte: "Z" ($DA)
  Byte stream: file name (null terminated)

Host sends:
  Two bytes: file size in blocks (LSB, MSB)
  One byte: return code:
    $00 = File exists (and file size is valid)
    $02 = File does not exist
    $04 = File exists, not recognized as a valid disk image

Apple sends:
  One byte: "P" ($D0)
  Byte stream: file name (null terminated)
  Two bytes:
    Number of blocks to follow (lsb)
    Number of blocks to follow (msb)

Host sends: return code:
  $00 = Ok
  $02 = Unable to write (Apple aborts)

Apple sends:
  $06 = ACK

(parts = filesize /(40 * 512), remainder = filesize % (40 * 512))
(loop: parts * 40 blocks + remainder * blocks)

  Apple sends:
    Two bytes: current block number (LSB, MSB)
    One byte: half-block number (2 = bytes 0-255, 1 = bytes 256-511)
    Half-block, RLE encoded
    two bytes:
      CRC (LSB)
      CRC (MSB)

  Host sends one byte acknowledgement:
    $06 = ACK (Host understood the packet, CRC is correct; send next one)
              (Also: this is a duplicate packet, already received; acknowledge
              so the Apple sends the next one)
    $15 = NAK (Resend the same packet again)

(end loop)

Apple sends: One byte: number of errors encountered

SOS Kernel Download

Apple sends:
  One byte: "3" ($B3)

Host sends:
  Continuous byte stream of $56 pages ($5600 bytes) of SOS kernel file image

SOS Interpreter Download

Apple sends:
  One byte: "4" ($B4)

Host sends:
  Two bytes: image size in bytes (LSB, MSB)
  Continuous byte stream of serial ADTPro SOS program file image

SOS Driver Download

Apple sends:
  One byte: "5" ($B5)

Host sends:
  Two bytes: image size in bytes (LSB, MSB)
  Continuous byte stream of SOS driver file image

ADT Compatibility

Receive 140k disk (from host to Apple ][)

Apple sends: One byte: "R" ($D2)
Apple sends: Byte stream: file name (null terminated)

Host sends one byte return code:
  $00 = ok
  $1a = file can't be opened (Old ADT message number)
  $1e = not a 140k image (Old ADT message number)

(Assuming zero return code...)
(loop: 5 parts * 7 tracks * 16 sectors)

  Apple sends one byte acknowledgement:
    $06 = ACK (always ACK for the first sector)
    $15 = NAK

  Host sends:
    Next sector, RLE encoded
    two bytes:
      CRC (lo)
      CRC (hi)

(loop end)

Apple sends:
  One byte: number of errors encountered

Send 140k disk (from Apple ][ to host)

Apple sends: One byte: "S" ($D3)

Host sends one byte return code:
  $00 = Ok
  $1c = File exists
  $1a = Can't open
  $1e = Disk full

(Assuming zero return code...)
(loop: 5 parts * 7 tracks * 16 sectors)

  Host sends:
    $00 = ready to commence

  Apple sends:
    Next sector, RLE encoded
    two bytes:
      CRC (lo)
      CRC (hi)

  Host sends one byte acknowledgement:
    $06 = ACK
    $15 = NAK

(loop end)

Apple sends:
  One byte: number of errors encountered

DIR

Apple sends: One byte: "D" ($C4)

Host sends: 
  Screen-formatted data of directory contents; null-terminated

  Final byte:
    $00 = last screen
    $01 = another screen follows

If final byte is $01:
  Apple sends one byte:
      "D" ($C4) = retrieve subsequent screen
      $00 = abort