TPDD Base Protocol: Difference between revisions
No edit summary |
No edit summary |
||
Line 78: | Line 78: | ||
specify the bank number as part of the request. The above commands reference BANK 0. To | specify the bank number as part of the request. The above commands reference BANK 0. To | ||
reference BANK 1 you must add 40 HEX to these values (bit 6 = bank number). E.G. 'open | reference BANK 1 you must add 40 HEX to these values (bit 6 = bank number). E.G. 'open | ||
file' becomes 41 for BANK 1.</P><HR> | file' becomes 41 for BANK 1.</P><HR>== Request Command details == | ||
{| WIDTH="100%" BORDER="1" | {| WIDTH="100%" BORDER="1" | ||
| <P><B | | <P><B>Type 00 - Directory Reference</B></P><PRE> 2 1 1 24 1 1 1 bytes | ||
+----+--+--+--------------+----------+------------+------+ | |||
|5a5a|00|1a| filename |attribute |search form |chksum| | |||
+----+--+--+--------------+----------+------------+------+</PRE><P>Preamble - always 'ZZ'<BR> | |||
request - type 00h<BR> | request - type 00h<BR> | ||
length - length of data 1ah (26 decimal)<BR> | length - length of data 1ah (26 decimal)<BR> | ||
Line 91: | Line 95: | ||
04h - end directory reference</P></BLOCKQUOTE><P>checksum - see below for calculating | 04h - end directory reference</P></BLOCKQUOTE><P>checksum - see below for calculating | ||
|- | |- | ||
| | | | ||
== Type 01 - Open file == | |||
<PRE> 2 1 1 1 1 bytes | |||
+----+--+--+------+------+ | |||
|5a5a|01|01| mode |chksum| | |||
+----+--+--+------+------+</PRE> | |||
Preamble - always 'ZZ'<BR> | |||
request - type 01h<BR> | request - type 01h<BR> | ||
length - length of data 01h (1 decimal)<BR> | length - length of data 01h (1 decimal)<BR> | ||
mode - </P><BLOCKQUOTE> | mode - </P><BLOCKQUOTE> | ||
02h - open existing file for APPEND | |||
03h - open existing file for READ | 01h - open new file for WRITE | ||
02h - open existing file for APPEND | |||
03h - open existing file for READ | |||
</BLOCKQUOTE> | |||
checksum - see below for calculating | checksum - see below for calculating | ||
|- | |- | ||
| < | | | ||
request - type 03h | |||
length - length of data 00h (no data field) | |||
checksum - see below for calculating | == Type 02 - Close file == | ||
<PRE> 2 1 1 1 bytes | |||
+----+--+--+------+ | |||
|5a5a|02|00|chksum| | |||
+----+--+--+------+</PRE> | |||
* Preamble - always 'ZZ' | |||
* request - type 02h | |||
* length - length of data 00h (no data field) | |||
* checksum - see below for calculating | |||
== Type 03 - Read file == | |||
<PRE><FONT SIZE="-1"> | |||
<pre> 2 1 1 1 bytes | |||
+----+--+--+------+ | |||
|5a5a|03|00|chksum| | |||
+----+--+--+------+</PRE> | |||
* Preamble - always 'ZZ' | |||
* request - type 03h | |||
* length - length of data 00h (no data field) | |||
* checksum - see below for calculating | |||
|- | |- | ||
| <B><FONT SIZE="+1">Type 04 - Write file</FONT></B><PRE><FONT SIZE="-1"><BIG> 2 1 1 1-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+---+------+------+</FONT><FONT SIZE="-1"> |5a5a|04|01-|data |chksum|</FONT><FONT SIZE="-1"> | | | 80| | |</FONT><FONT SIZE="-1"> +----+--+---+------+------+</FONT></BIG></PRE><P>Preamble - always 'ZZ'<BR> | | <B><FONT SIZE="+1">Type 04 - Write file</FONT></B><PRE><FONT SIZE="-1"><BIG> 2 1 1 1-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+---+------+------+</FONT><FONT SIZE="-1"> |5a5a|04|01-|data |chksum|</FONT><FONT SIZE="-1"> | | | 80| | |</FONT><FONT SIZE="-1"> +----+--+---+------+------+</FONT></BIG></PRE><P>Preamble - always 'ZZ'<BR> | ||
Line 139: | Line 179: | ||
attribute- not used (specify 'F')<BR> | attribute- not used (specify 'F')<BR> | ||
checksum - see below for calculating | checksum - see below for calculating | ||
|}<H2>Return Command Details</H2> | |} | ||
<H2>Return Command Details</H2> | |||
{| WIDTH="100%" BORDER="1" | {| WIDTH="100%" BORDER="1" | ||
| <B><FONT SIZE="+1">Type 10 - Read file Return </FONT></B><PRE><FONT SIZE="-1"><BIG> 1 1 0-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+---+----------+-----+</FONT><FONT SIZE="-1"> |10|00-| file data|cksum|</FONT><FONT SIZE="-1"> | | 80| |cksum|</FONT><FONT SIZE="-1"> +--+---+----------+-----+</FONT></BIG></PRE><P>return - type 10<BR> | | <B><FONT SIZE="+1">Type 10 - Read file Return </FONT></B><PRE><FONT SIZE="-1"><BIG> 1 1 0-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+---+----------+-----+</FONT><FONT SIZE="-1"> |10|00-| file data|cksum|</FONT><FONT SIZE="-1"> | | 80| |cksum|</FONT><FONT SIZE="-1"> +--+---+----------+-----+</FONT></BIG></PRE><P>return - type 10<BR> |
Revision as of 00:58, 13 December 2008
General Reference
- Disks are single sided 3.5 inch standard disks
- PDD1 - 40 tracks 2 sectors 1280 bytes/sector (100K/disk)
- PDD2 - 80 tracks 2 sectors 1280 bytes/sector (200K/disk treated as two banks of 100k each)
- Maximum file size = 64k.
- Maximum number of directory entries (files) is 40 for PDD1 and 80 for PDD2.
- File names are maximum 24 characters (padded with trailing blanks) although Tandy always used 6 for filename and 2 for filetype, with period seperator (i.e. XXXXXX.TT)
- All communications with drive are at 19,200 bps. PDD1 has dip switches so this can drop to 9600bps. PDD2 is auto sensing down to 1200bps (??? - can anyone confirm this?).
Command Format
All commands are in a request/return format (half-duplex)
General request format:
preamble type length data checksum
General return format:
type length data checksum
Command Type
(all values are in HEX)
command | request | return |
---|---|---|
directory ref | 00 | 11 12 |
open file | 01 | 12 |
close file | 02 | 12 |
read file | 03 | 10 12 |
write file | 04 | 12 |
delete file | 05 | 12 |
format disk | 06 * | 12 |
drive status | 07 * | 12 |
drive condition | 0C * | 15 |
rename file | 0D | 12 |
* PDD2 treats the disk as two banks of 100k each. All commands except these two must
specify the bank number as part of the request. The above commands reference BANK 0. To reference BANK 1 you must add 40 HEX to these values (bit 6 = bank number). E.G. 'open
file' becomes 41 for BANK 1.
== Request Command details ==
Type 00 - Directory Reference 2 1 1 24 1 1 1 bytes +----+--+--+--------------+----------+------------+------+ |5a5a|00|1a| filename |attribute |search form |chksum| +----+--+--+--------------+----------+------------+------+ Preamble - always 'ZZ' request - type 00h
checksum - see below for calculating |
Type 01 - Open file2 1 1 1 1 bytes +----+--+--+------+------+ |5a5a|01|01| mode |chksum| +----+--+--+------+------+ Preamble - always 'ZZ'
checksum - see below for calculating |
Type 02 - Close file2 1 1 1 bytes +----+--+--+------+ |5a5a|02|00|chksum| +----+--+--+------+
Type 03 - Read file<FONT SIZE="-1"> <pre> 2 1 1 1 bytes +----+--+--+------+ |5a5a|03|00|chksum| +----+--+--+------+
|
Type 04 - Write file<FONT SIZE="-1"><BIG> 2 1 1 1-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+---+------+------+</FONT><FONT SIZE="-1"> |5a5a|04|01-|data |chksum|</FONT><FONT SIZE="-1"> | | | 80| | |</FONT><FONT SIZE="-1"> +----+--+---+------+------+</FONT></BIG> Preamble - always 'ZZ' reques - type 04 |
Type 05 - Delete file<FONT SIZE="-1"><BIG> 2 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+--+------+</FONT><FONT SIZE="-1"> |5a5a|05|00|chksum|</FONT><FONT SIZE="-1"> +----+--+--+------+</FONT></BIG> Preamble - always 'ZZ' request - type 05h |
Type 06 - Format Disk<FONT SIZE="-1"><BIG> 2 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+--+------+</FONT><FONT SIZE="-1"> |5a5a|06|00|chksum|</FONT><FONT SIZE="-1"> +----+--+--+------+</FONT></BIG> Preamble - always 'ZZ' request - type 06h |
Type 07 - Drive Status<FONT SIZE="-1"><BIG> 2 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+--+------+</FONT><FONT SIZE="-1"> |5a5a|07|00|chksum|</FONT><FONT SIZE="-1"> +----+--+--+------+</FONT></BIG> Preamble - always 'ZZ' request - type 07h |
Type 0C - Drive Condition<FONT SIZE="-1"><BIG> 2 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+--+------+</FONT><FONT SIZE="-1"> |5a5a|0C|00|chksum|</FONT><FONT SIZE="-1"> +----+--+--+------+</FONT></BIG> Preamble - always 'ZZ' request - type 0Ch |
Type 0D - Rename file <FONT SIZE="-1"><BIG> 2 1 1 24 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +----+--+--+-------+------+------+</FONT><FONT SIZE="-1"> |5a5a|0D|19|newname|attrib|chksum|</FONT><FONT SIZE="-1"> +----+--+--+-------+------+------+</FONT></BIG> Preamble - always 'ZZ' request - type 0D |
Return Command Details
Type 10 - Read file Return <FONT SIZE="-1"><BIG> 1 1 0-128 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+---+----------+-----+</FONT><FONT SIZE="-1"> |10|00-| file data|cksum|</FONT><FONT SIZE="-1"> | | 80| |cksum|</FONT><FONT SIZE="-1"> +--+---+----------+-----+</FONT></BIG> return - type 10
file data - data read from file checksum - see below for calculating | |||||||||||||||||||||||||||
Type 11 - Directory reference return<FONT SIZE="-1"><BIG> 1 1 24 1 2 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+--+--------+------+----+----+-----+</FONT><FONT SIZE="-1"> |11|1c|filename|attrib|size|free|cksum|</FONT><FONT SIZE="-1"> +--+--+--------+------+----+----+-----+</FONT></BIG> return - type 11h length - length of data 1Ch (28 decimal) | |||||||||||||||||||||||||||
Type 12 - Normal Return <FONT SIZE="-1"><BIG> 1 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+--+-----+-----+</FONT><FONT SIZE="-1"> |12|01|error|cksum|</FONT><FONT SIZE="-1"> +--+--+-----+-----+</FONT></BIG> return - type 12h length - length of data 01h
checksum - see below for calculating | |||||||||||||||||||||||||||
Type 15 - Drive Condition Return <FONT SIZE="-1"><BIG> 1 1 1 1 bytes</BIG></FONT><BIG><FONT SIZE="-1"> +--+--+---------+-----+</FONT><FONT SIZE="-1"> |15|01|condition|cksum|</FONT><FONT SIZE="-1"> +--+--+---------+-----+</FONT></BIG> return - type 15h length - length of data 01h <FONT SIZE="-1"> 7 6 5 4 3 2 1 0 bit</FONT><FONT SIZE="-1"> +-+-+-+-+-+-+-+-+</FONT><FONT SIZE="-1"> MSB |0|0|0|0|x|x|x|x| LSB</FONT><FONT SIZE="-1"> +-+-+-+-+-+-+-+-+</FONT><FONT SIZE="-1"> | | | |</FONT><FONT SIZE="-1"> | | | +--power (0=normal 1=low)</FONT><FONT SIZE="-1"> | | +----write protect (0=not prot 1=prot)</FONT><FONT SIZE="-1"> | +------disk out (0=disk in 1=disk out)</FONT><FONT SIZE="-1"> +--------disk change status (0=not changed 1=changed)</FONT> checksum - see below for calculating |
Sequence of Events
Get directory | req 00 search form 01 req 00 search form 02 (repeat as needed) |
Write file | req 00 search form 00 req 01 mode 01 or 02 |
Read file | req 00 search form 00 req 01 mode 03 |
Rename file | req 00 search form 00 req 0d |
Delete file | req 00 search form 00 req 05 |
Calculating Checksum
The check sum is "the one's complement of the least significant byte of the number
of bytes from the block format through the data block". Most people (me included) don't understand what that involves if you have to calculate it. Fortunately I found an
example of how to do this and so I'm passing it on to you.
Checksum=(bytes MOD 256) XOR 255
where bytes = number of bytes including the Request Type, Length and all Data fields (but not including the preamble).
Using this Information
A lot of the above commands can be set up in advance since there is no variable part to
calculate. Some commands must have the length and checksum calculate as the data is built
but the others don't. Here's how I set up some of the commands in my program:
Close$="ZZ"+Chr$(2)+Chr$(0)+Chr$(253)
Dir1$="ZZ"+Chr$(0)+Chr$(26)+Space$(24)+"F"+Chr$(1)+Chr$(158)
Dir2$="ZZ"+Chr$(0)+Chr$(26)+Space$(24)+"F"+Chr$(2)+Chr$(157)
Status$="ZZ"+Chr$(7)+Chr$(0)+Chr$(248)+Chr$(13)
Format$="ZZ"+Chr$(6)+Chr$(0)+Chr$(249)+Chr$(13)
Erase$="ZZ"+Chr$(5)+Chr$(0)+Chr$(250)
Seek$(1)="ZZ"+Chr$(1)+Chr$(1)+Chr$(1)+Chr$(252)
Seek$(2)="ZZ"+Chr$(1)+Chr$(1)+Chr$(2)+Chr$(251)
Seek$(3)="ZZ"+Chr$(1)+Chr$(1)+Chr$(3)+Chr$(250)
The above commands can be sent directly without any calculating to speed up your program.
<A HREF="index.html"><IMG SRC="../graphics/ureturn.gif" ALT="ureturn.gif (2080 bytes)" WIDTH="155" HEIGHT="60"></A>