Post by VDC 8x2 on May 29, 2016 4:54:41 GMT
1571-6.TXT rev 1a 96-11-06
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
THIS DOCUMENT IS COPYRIGHT (C) 1988, 1996 BY HERNE DATA
SYSTEMS LTD. THE MATERIAL CONTAINED HEREIN MAY BE FREELY
USED FOR PERSONAL INFORMATION ONLY. IF YOU REPRODUCE IT,
THIS COPYRIGHT NOTICE MUST NOT BE REMOVED. THIS MATERIAL
MAY NOT BE EXPLOITED FOR COMMERCIAL PURPOSES.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Herne Data Systems Ltd.,
PO Box 250, Tiverton, ON N0G 2T0 CANADA.
Voice/fax 519-366-2732,
e-mail herne@herne.com,
internet: www.herne.com
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Burst Mode Commands
The 1571 disk operating system (DOS) supports an extended set of
commands, collectively called "burst mode" or the "burst command
instruction set" (BCIS), which enables the drive to, among other
things, create, read and write disks in a wide variety of formats
with relative ease. Many, but not all, of the burst mode
commands have analogous commands in standard Commodore DOS. Why
then is there a need to duplicate them in burst mode? The answer
is twofold: speed and versatility. The data transfer rate of a
1541 drive (or a 1571 in 1541 mode) is about 350 bytes per
second. The 1571 in fast mode can read about 1600 bytes per
second. With burst mode, data can be read at the blistering rate
of 4000 or more bytes per second! In fact, the ultimate read
speed is not limited by the hardware. It is controlled by the
efficiency of the driving software. (That is, burst mode can, in
theory, transfer data as fast as you can send it in machine
language.) In addition, burst mode allows you to read and write
disks formatted in the industry standard MFM (maximum (or
modified) frequency modulation) format as well as Commodore GCR
(group coded recording) format. The MFM format is used by most
CP/M computers such as Kaypro, Epson, Osborne, etc., as well as
MS-DOS (IBM-PC and compatible) and TRS-80 machines. Apple ][
type computers use a modified form of GCR which is not compatible
with either MFM or Commodore GCR.
Command Syntax
Burst mode commands are accessed by sending a specific set of
characters through the disk command channel, just like the usual
Commodore DOS commands such as "n0:", "s0:", "b-p:", etc.
Because the first two characters of the command string for all
burst mode commands are "u0", burst commands are often referred
to as the extended user 0 commands.
Burst mode can be accessed by a BASIC statement such as:
OPEN 15,8,15,"U0"+CHR$({command})+additional characters
or the machine language equivalent. Alternatively, if the
command channel has been opened previously, the "OPEN 15,8,15"
can be replaced by "PRINT#15". The "additional characters" depend
on the desired command and its options. These characters
generally select secondary options. Not all of the secondary
option characters need to be sent in some cases because default
values can often be assumed.
The burst mode command byte can be divided into two parts:
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
The command parameter values for the low nibble are summarized in
Table 9-1. The high four bits contain the primary command
options. These are a series of up to four on/off switches which
control some of the main features of the command. The switch
values are outlined in Table 9-2 and detailed in the appropriate
sections of this chapter for each of the commands. It should be
noted that not all commands use all switches, but a given switch
that is used in several of the commands always occupies the same
bit position. For example, the MFM side select switch is always
controlled using bit 4 of the command byte.
Table 9-1: Burst mode command byte low nibble values
.......................................................
Command Nibble Value Command
--------------------
Binary Hex
.......................................................
0 0 0 0 0 Sector read
0 0 1 0 2 Sector write
0 1 0 0 4 Inquire disk
0 1 1 0 6 Format disk
1 0 0 0 8 Sector interleave
1 0 1 0 A Query disk format
1 1 0 0 C Inquire status
1 1 1 0 E Set utilites *
1 1 1 1 F Fast load *
.......................................................
* Note: these commands also require bit 4 to be set to 1.
Table 9-2: Summary of burst mode command switches
................................................................
Designation Bit Applicable Action
Commands
................................................................
B 5 Read; Write 1 = transfer from disk to
buffer for read (buffer
to disk for write) with
no burst transfer between
computer and drive.
0 = include burst transfer
between computer and
drive.
C 6 Inquire status 1 = disk has been changed
since last log-in.
0 = disk has not been changed
since last log-in.
D 5 Format (MFM) 1 = format double sided disk.
0 = format single sided disk.
E 6 Read; write 1 = ignore disk errors.
0 = stop on error.
F 7 Query disk 1 = step head to offset value
before analysing.
0 = analyse track 0 only.
I 6 Format (MFM) 1 = write track index mark.
0 = don't write index mark.
M 7 Format 1 = format MFM disk.
(second command byte) 0 = format GCR disk.
P 7 Format 1 = partial disk format only.
0 = format entire disk.
S 4 (most) 1 = use side 1 of MFM disk.
0 = use side 0 of MFM disk.
T 7 Read; write 1 = don't transfer data via
burst mode.
0 = transfer data via burst
mode.
W 7 Inquire status 1 = read old value.
and Sector 0 = set new value.
interleave
X - dummy filler bit. Value not important and is
ignored. Usually set to 0.
Y* 7 Fast load 1 = file does not have to be
PRG type to LOAD.
0 = file must be PRG type.
Z* 6 Format (MFM) 1 = include sector skew
table.
0 = use default sector table.
.................................................................
* Note: This switch label has been changed from that used in the
1571 User's Guide to avoid confusion with a different switch
given the same label for another command.
Many of the burst mode commands will return a "status" byte as
part of the action of the command. The status byte gives the
calling program information on the success or failure of the
requested operation. In some cases of failure, it may also be a
signal that no burst mode data will be sent. The format of the
status byte is as follows:
Bit
7 6 5 4 3 2 1 0
Mode Drive Sector Size <- controller status ->
Where:
Mode = 0 for GCR disk
= 1 for MFM disk
Drive = 0 (always)
Sector size:
0 0 128 bytes/sector
0 1 256
1 0 512
1 1 1024
The controller status values are summarized in Table 9-3. It
should be noted that in some cases the bit patterns have
different meanings depending on the type of disk (MFM or GCR) in
the drive. These differences are included in the table. In
addition, not all status codes are used by all burst mode
commands. For example, the "Write protect on" error is used only
by the "Sector write" and "Format" commands.
Table 9-3: Burst mode controller status values
............................................................
Bit Pattern Error Condition
............................................................
0 0 0 x All OK
0 0 1 0 Sector not found
0 0 1 1 GCR: No sync mark detected
MFM: No address mark detected
0 1 0 0 GCR: Data block not found
MFM: (not used)
0 1 0 1 GCR: Data checksum error
MFM: Data CRC error
0 1 1 0 Formatting error
0 1 1 1 Verify error
1 0 0 0 Write protect on during write
1 0 0 1 Header checksum error
1 0 1 0 GCR: data extends into next block
MFM: (not used)
1 0 1 1 Disk has been changed since log-in
1 1 0 0 (not used)
1 1 0 1 (not used)
1 1 1 0 Syntax error in burst command
1 1 1 1 Drive not present
............................................................
It should be noted that error checking is not performed on any of
the parameters before they are passed to the 1571. For the most
part, error checking on parameter values (such as track and
sector numbers) is not performed by the 1571 either. This must
be done by the calling program before the bytes are sent.
An example of sending a complete burst mode command from BASIC is
given below (in this example it is assumed that the disk command
channel has already been opened as logical file 15):
PRINT#15,"U0"+CHR$(16)+CHR$(5)+CHR$(2)+CHR$(1)+CHR$(4)
This command will tell the drive to read 1 sector of data,
beginning at track 5, sector 2 on side 1 of an MFM disk, stop if
an error is encountered, else transfer the data to the computer
via burst mode and then step the head to track 4 to await the
next command.
Sector-Read
Burst mode "SECTOR-READ" allows you to read one or more sectors
from a disk and transfer the data to the computer. In addition to
increased speed it has the added advantage over the DOS "u1" and
"Block-Read" commands in being able to read more than one sector
of data with a single stroke and being able to read MFM disks as
well as standard Commodore DOS GCR disks.
The command string for "SECTOR READ" is:
"U0"+CHR$({read})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
where {read} has one of the values listed in Table 9-5; {track}
and {sector} are the track number and sector number to begin
reading at; {#sectors} is the number of sectors to read in the
sequence; and {next track} tells the drive where to park the head
to await the next command. The {#sectors} parameter should be
limited to one track's worth. If it is larger, the command will
keep re-reading sectors from the same track until the specified
number has been read. Although {next track} is optional, its
inclusion is desirable, even if its value is set to {track},
because it minimizes the head movement between subsequent reads
and writes. If {next track} is omitted, the head will go back to
track 0 after each operation, causing a lot of head bouncing and
wasting time.
For a GCR disk, {track} values of 1 to 35 are used to access side
0, while 36 to 70 are used for side 1. For MFM disks, the side
is selected by the value of the "S" switch (bit 4 of the command
byte), as outlined in Table 9-5.
When the "E" switch (bit 6) is set, errors are ignored. This
means that even if the requested sector is not found or an error
occurs during the reading process, the command will transfer
whatever is already in the buffer to the computer. In this case,
the calling program in the computer should analyse the status
byte to determine if the data are valid.
Bit 0 is actually a switch to determine the drive number. Since
the 1571 is only a single drive unit, this bit is always clear.
If the 1572 dual drive is ever produced, the corresponding burst
mode commands for drive 1 will have values of 1 greater than
those listed in Table 9-5.
When both the "T" and "B" switches (bits 7 and 5) are set
(command values of $A0, $B0, $C0, and $D0), no burst mode data
transfer occurs. Instead, the specified sector is read into the
1571 data buffers beginning at address $300. (For best results,
the "T" and "B" switches should be used in tandem and always have
the same value (i.e. either both on or both off)). The data can
then be read from the drive over the normal serial bus (either
fast or slow) with a series of "MEMORY READ"s. This allows other
computers, such as the C-64, to access MFM disks. With this
option, only one sector can be read at a time, due to limitations
with buffer space in the 1571.
It should be stressed that before reading a disk for the first
time (or after removing and re-inserting the same disk), you must
"log-in" the disk using one of "QUERY DISK FORMAT", "INQUIRE
DISK" or "INQUIRE STATUS". This process is required to set-up
the 1571 electronics to handle the particular type of disk
involved. These commands are described later in the chapter.
For each sector read, a status byte will be returned first. If
the error checking is enabled, and an error occurs, then no data
will follow. Otherwise, data bytes from the sector will then be
transferred, if burst transfer has been specified. The total
number of bytes transferred is thus 1 + number of bytes per
sector (including status byte):
Sector size Total bytes sent
128 129
256 (MFM or GCR) 257
512 513
1024 1025
For multi sector reads, the sectors are read in the order
specified with the burst mode "SET SECTOR INTERLEAVE" command,
described later in this chapter. If no interleave has been
specified, the sectors are read in the order which they appear on
the disk. This may result in incorrect reading of the disk if it
has an unusual physical sector skew (that is the sector 2 might
not be physically adjacent to sector 1). To be safe, you should
always specify a sector interleave prior to multi sector
transfers, even if it is only a value of 1 which will force a
read in numerical order regardless of how the sectors are
physically located on the disk.
Table 9-5: Values for burst mode SECTOR READ command byte
...............................................................
Value Action
------------
hex decimal
...............................................................
0 0 read specified sector on MFM disk side 0
or GCR disk, transfer data to computer
via burst mode, stop if error.
10 16 same as above, but for MFM disk, side 1.
40 64 same as value 0, but ignore errors.
50 80 same as value $10, but ignore errors.
A0 160 read specified sector on MFM disk side 0
or GCR disk into data buffer only. Stop
on error. Data can be transferred using
DOS MEMORY READ command over normal
serial bus.
B0 176 same as above, but for MFM disk, side 1.
C0 192 same as value $A0, but ignore errors.
D0 208 same as value $B0, but ignore errors.
...............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
T E B S 0 0 0 0
Sector-Write
Burst mode "SECTOR-WRITE" allows you to write one or more sectors
to a disk after transferring the data from the computer.
Although the speed increase over normal DOS commands is marginal
(due to the limitations of the "verify after write" procedure
that is used for each sector written), it has the advantage over
the DOS "u2" and "Block-Write" commands in being able to write
more than one sector of data with a single stroke and being able
to write to MFM disks as well as standard Commodore DOS GCR
disks.
Similar to the "SECTOR-READ" command described above, it works on
a block-by-block basis. That is, it cannot be used to
automatically SAVE an entire file. Each block (or group of
sectors) of the file must be written individually under user
control.
The command string for "SECTOR WRITE" is:
"U0"+CHR$({write})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
where {write} has one of the values listed in Table 9-6; {track}
and {sector} are the track number and sector number to begin
writing at; {#sectors} is the number of sectors to write in the
sequence; and {next track} tells the drive where to park the head
to await the next command. The {#sectors} parameter should be
limited to one track's worth or less. If more sectors are
specified, the 1571 will keep over-writing sectors on the same
track until the specified number has been reached. This may
result in a corrupted disk. Although {next track} is optional,
its inclusion is desirable, even if its value is set to {track},
because it minimizes the head movement between subsequent reads
and writes. If {next track} is omitted, the head will go back to
track 0 after each operation, causing a lot of head bouncing and
wasting time.
For a GCR disk, {track} values of 1 to 35 are used to access side
0, while 36 to 70 are used for side 1. For MFM disks, the side
is selected by the value of bit 4 of the command byte, as
outlined in Table 9-6.
When the "E" switch (bit 6) is set, errors are ignored. This
means that even if the requested sector is not found or an error
occurs during the writing or verifying process, the command will
continue. In this case, the calling program in the computer
should analyse the status byte to determine if the write was
successful and the data are valid.
Bit 0 is actually a switch to determine the drive number. Since
the 1571 is only a single drive unit, this bit is always clear.
If the 1572 dual drive is ever produced, the corresponding burst
mode commands for drive 1 will have values of one greater than
those listed in Table 9-6.
Table 9-6: Values for burst mode SECTOR WRITE command byte
...............................................................
Value Action
------------
hex decimal
...............................................................
2 2 transfer data to drive via burst mode
and write specified sector on MFM disk
side 0, or GCR disk. Stop if error.
12 18 same as above, but for MFM disk, side 1.
42 66 same as value 2, but ignore errors.
52 82 same as value $12, but ignore errors.
A2 162 write buffer to specified sector on MFM
disk, side 0 or GCR disk. Stop on
error. Data can be written to buffer
first using DOS MEMORY WRITE command
over normal serial bus.
B2 178 same as above, but for MFM disk, side 1.
C2 194 same as value $A2, but ignore errors.
D2 210 same as value $B2, but ignore errors.
...............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
T E B S 0 0 1 0
When both the "T" and "B" switches (bits 7 and 5) are set
(command values of $A2, $B2, $C2, and $D2), no burst mode data
transfer occurs. Instead, the specified sector is written
directly from the 1571 data buffers beginning at address $300.
(For best results, the "T" and "B" switches should be used in
tandem and always have the same value (i.e. either both on or
both off)). Prior to this, the data can be written to the
buffers over the normal serial bus (either fast or slow) with a
series of "MEMORY WRITES"s. This allows other computers, such as
the C-64, to access MFM disks. With this option, only one sector
can be written at a time, due to limitations with buffer space in
the 1571.
It should be stressed that before writing a disk for the first
time (or after removing and re-inserting the same disk), you must
"log-in" the disk using one of "QUERY DISK FORMAT", "INQUIRE
DISK" or "INQUIRE STATUS". This process is required to set-up
the 1571 electronics to handle the particular type of disk
involved. These commands are described later in the chapter.
For multi sector writes, the sectors are written in the order
specified with the burst mode "SET SECTOR INTERLEAVE" command,
described later in this chapter. If no interleave has been
specified, the sectors are written in the order which they appear
on the disk. This may result in incorrect writing of the disk if
it has an unusual physical sector skew (that is the sector 2
might not be physically adjacent to sector 1). To be safe, you
should always specify a sector interleave prior to multi sector
transfers, even if it is only a value of 1 which will force a
write in numerical order regardless of how the sectors are
physically located on the disk.
A burst mode status byte will be returned after each sector
written. This byte will give the result of the requested
operation.
Inquire Disk
Before reading or writing disk sectors via burst mode, it is
necessary to set the 1571 electronics to the proper mode (GCR or
MFM) and initialize various track and sector addressing
parameters which depend on the disk characteristics. This is
generally done using one of the burst mode "log-in" commands.
The INQUIRE DISK command is perhaps the simplest way to log-in a
new disk prior to burst mode reads and writes. The command
string is:
"U0"+CHR$({inquire})
where {inquire} has a value of:
Hex Dec
4 4 to check a GCR disk (either side) or an MFM
disk (side 0)
14 20 to check an MFM disk (side 1).
After logging in the disk, the INQUIRE DISK command will return a
single status byte of the type outlined previously. The value of
the status byte can be used as an indication of the success of
the log-in as well as give some basic information about the
organization of the disk. The status byte will give the mode
(GCR or MFM) as well as the sector size. It will not return
information on the number of sectors on the track, physical
sector interleave, or the sector numbering system. For that
level of detail, the QUERY DISK FORMAT command (discussed later)
must be used. In addition, INQUIRE DISK will only look at the
first track on the disk.
Bit 4 of the command byte is the side select switch for MFM
disks. It is normally only used to test whether side 1 of an MFM
disk is used or not. In rare cases (such as in custom disk
formats), side 1 may not have the same sector size (or even mode)
as side 0. Setting the switch will allow the drive to log in
side 1 without looking at side 0.
The following procedure can be used to distinguish among GCR
disks; single and double sided MFM disks:
1) INQUIRE DISK on side 0. The result of this will tell
you whether the disk is GCR or MFM.
2) INQUIRE DISK on side 1. The result of this will tell
you if side 1 is used.
Note that this procedure can be fooled by a re-used disk that was
once formatted as a double sided MFM disk.
If the object is merely to log-in the disk and the value of the
returned status byte is not important to the calling program,
then the program can immediately procede to the read/write
operation without first reading the status byte. The process of
sending the next command over the serial bus will cancel the need
to read the status byte.
Format
The 1571 is capable of formatting disks in both GCR mode and MFM
mode. The burst mode FORMAT command can be used in both cases.
It should be noted that burst mode format commands do not require
any actual burst mode data transfer. They can be used entirely
with the conventional fast or slow serial bus, even from BASIC.
Format GCR
The command string bytes for a GCR format are:
"U0"+CHR$(6)+CHR$(0)+"{id}"
where {id} is the normal two character ID code used in the
standard DOS format (N0:diskname,ID) command. It should be noted
that no directory or BAM is created on the disk with this
command. Because of this, its usefulness is limited to creating
GCR CP/M disks, custom GCR disks or perhaps for a whole disk
backup program. The speed of formatting with this command is not
significantly faster than with the normal DOS command.
Format MFM
The command string for formatting an MFM disk is:
"U0"+CHR$({format})+CHR$({type})+CHR$({interleave})+
CHR$({sector_size})+CHR$({last_track})+
CHR$({#sectors})+CHR$({start_track#})+
CHR$({start_track_offset})+CHR$({fill_byte})+
CHR$({sector_table})+...
The values and switches for {format} and {type} are given in
Table 9-7. The actions of the various switches will be detailed
later.
{interleave} specifies a physical sector interleave or skew
factor. Normally a default of 0 is assumed (that is, no physical
skew). If any of the remaining parameters are included, then it
must be specified.
{sector_size} has one of the following values, depending on the
desired disk characteristics:
0 for 128 bytes/sector
1 for 256
2 for 512
3 for 1024
The default value is 1 for 256 byte sectors, however, if any of
the remaining parameters are specified, it must be included also.
{last_track} is the highest track number to be formatted on the
disk. Normally this is 39 (the default). This corresponds to
the 40 tracks per side available on a standard MFM disk (numbered
0 to 39). However, some MFM disk types (such as some older CP/M
types and TRS-DOS types) only use 35 tracks per side. In that
case, {last_track} would have a value of 34. Similarly, if you
wanted to squeeze every last byte out of a custom disk format,
you may be able to go a few tracks beyond the normal range and
increase the value up to 41 or 42. {last_track} can also be used
in conjunction with the P flag (for partial format) of the
command byte to create disks that have different sector sizes or
numbering schemes in different areas of the disk. This is used
by some CP/M disk types (typically smaller sector sizes in the
first few tracks of the disk than on the bulk of the disk) or can
be used as the basis of a customized copy protection scheme.
{#sectors} gives the number of sectors on each track. Combined
with the sector size, it is a direct measure of the total storage
capacity of the disk type. The values depend on the desired disk
type and can be in the following range:
Sector Size {#sectors} Default
128 1 to 27 26
256 1 to 18 16
512 1 to 10 9
1024 1 to 5 5
{start_track} is the number to be used in the sector header for
the first track on the disk. This is normally 0, but can take on
other values, especially when used in conjunction with the P
switch of the command byte and {last_track}.
{start_offset} specifies the physical track position to begin
formatting at. Again, this would normally be a value of 0, but
may take on other values for custom disk types. This is the
mechanical position that the head is stepped to prior to
commencing the formatting procedure.
(fill_byte} is the byte value written to the empty sectors on the
disk. The default value is $E5 (decimal 229) which is the
standard for positive polarity CP/M disks. Other disk operating
systems may use different values.
The {sector_table} parameters are used to create custom disk
types with non-standard sector numbering schemes. The optional
table consists of the sequence of sector numbers to be used on
the disk. The numbers do not have to be contiguous, although
non-contiguous numbers may cause problems later when you try to
log-in this disk any read or write to it. It is best used with
the partial format switch bit to create a few tracks somewhere on
the disk with strange sector numbering for copy protection
purposes.
Table 9-7: Values for burst mode Format MFM command bytes
............................................................
Value for {format} Action
--------------
Hex Dec
............................................................
6 6 Format full disk, single sided,
side 0, do not write index marks.
16 22 same as above, but for side 1.
26 38 Format full disk, double sided, do
not write index marks.
46 70 Format full disk, single sided,
side 0, write index marks.
56 86 same as above, but for side 1.
66 102 Format full disk, double sided,
write index marks.
86 134 Format partial disk, single sided,
side 0, do not write index marks.
96 150 same as above, but for side 1.
A6 166 Format partial disk, double sided,
do not write index marks.
C6 198 Format partial disk, single sided,
side 0, write index marks.
D6 214 same as above, but for side 1.
E6 230 Format partial disk, double sided,
write index marks.
............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
P I D S 0 1 1 0
{type} values:
............................................................
{type} value
-------------
hex dec Action
............................................................
80 128 Format MFM, use standard sector
numbering beginning with sector #0.
81 129 Format MFM, use standard sector
numbering beginning with sector #1.
8+x 128+x Format MFM, use standard sector
numbering begining with sector x.
C0 192 Format MFM, use included sector
numbering table.
............................................................
{type} byte values are based on:
Bit
7 6 5 4 3 2 1 0
switches <-- starting sector # -->
M Z x x x x x x
Note that the starting sector # (x) is a 5 bit value and can
range from 0 to 63. For MFM disks, M is always 1.
C-128 CP/M has automatic read and write support for a number of
standard MFM type CP/M disk formats when used with a 1571 drive.
Unfortunately, the early versions of the C-128 CP/M FORMAT.COM
disk formatting program did not include the capability to create
new disks in these formats. Table 9-8 is a list of the burst
mode commands required to format new disks in each of the MFM
types supported by C-128 CP/M. Note that the easiest way to
perform this task is with the C-128 in native mode (i.e. not in
CP/M mode) with a statement such as:
OPEN 15,8,15,{command_string} : CLOSE 15
Table 9-8: Formatting CP/M Disks
..................................................................
Disk Type Formatting Command String
..................................................................
IBM CP/M-86 SS "U0"+CHR$(70)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(8)+CHR$(0)+CHR$(0)+CHR$(229)
IBM CP/M-86 DS "U0"+CHR$(102)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(8)+CHR$(0)+CHR$(0)+CHR$(229)
Kaypro II "U0"+CHR$(70)+CHR$(128)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
Kaypro IV "U0"+CHR$(70)+CHR$(128)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
then "U0"+CHR$(86)+CHR$(138)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
Osborne SS "U0"+CHR$(70)+CHR$(129)+CHR$(0)+CHR$(3)+CHR$(39)
+CHR$(5)+CHR$(0)+CHR$(0)+CHR$(229)
Epson QX-10 (512) "U0"+CHR$(230)+CHR$(129)+CHR$(0)+CHR$(1)+CHR$(1)
+CHR$(16)+CHR$(0)+CHR$(0)+CHR$(229)
then "U0"+CHR$(230)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(2)+CHR$(2)+CHR$(229)
Epson QX-10 (256) "U0"+CHR$(102)+CHR$(129)+CHR$(0)+CHR$(1)+CHR$(39)
+CHR$(16)+CHR$(0)+CHR$(0)+CHR$(229)
or Epson QX-10 (Euro)
...............................................................
Note that "double formatting" is required on the Kaypro IV because
side 0 and side 1 of the disk are numbered differently (sectors 0 to
9 on side 0 and 10 to 19 on side 1), while on the EpsonQX10 (512)
"double formatting" is required because tracks 0 and 1 are in a
different format (256 bytes/sector; 16 sectors /track) compared to
the remainder of the disk (512 bytes/sector; 10 sectors per track).
Partial MFM Formatting
The 1571 has the ability to format or re-format selective areas of a
disk in MFM mode. This was demonstrated above for formatting an
Epson QX-10 (512) CP/M disk. The same procedure can be used to
created "custom" disk formats for copy protection purposes. Most
disk copiers, even sophisticated disk nibblers, cannot handle
multiple densities on the same disk, especially if GCR and MFM are
mixed.
Sector Interleave
The "SECTOR INTERLEAVE" command is used to specify the order in
which multiple sectors are read or written with the burst mode
commands.
Query Disk Format
The "QUERY DISK FORMAT" command is used to obtain detailed
information about the disk in the drive.
Inquire Status
The "INQUIRE STATUS" command is used to check or change the status
of the last burst mode operation. It can also be used for logging
in new disks of a known type.
Set Utilities
The "SET UTILITIES" command is used to change a variety of the 1571
operating parameters such as device number, bus mode, side select,
etc. These commands all begin with the byte sequence "U0>".
Fastload
The "FASTLOAD" command is used to read an entire file from a GCR
Commodore DOS disk via burst mode.
TABLE 9-4: Burst mode command summary
.........................................................................
FUNCTION BYTE SEQUENCE BURST MODE
"U0"+ Input Output
.........................................................................
SECTOR-READ CHR$({read})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
INQUIRE DISK: reset drive and log in MFM or GCR disk
before a read or write
MFM disk side 0 4 one status byte
or GCR disk
MFM disk side 1 20 (same as above)
QUERY DISK FORMAT: analyze disk format (GCR or
MFM-sector size,sectors/track)
Side 0, track 0 10 one status byte then:
nothing else if
GCR disk or
un-readable
format; or else:
another status
byte; number of
sectors on
track; logical
track#; min
sector#; max sec.#
hard sector
interleave
Side 1, track 0 26 (same as above)
Side 0, track n 138,n (same as above)
Side 1, track n 154,n (same as above)
READ SECTOR: (data transfer via memory-read)
MFM disk side 0 192,track#,sector#,1 sector data in 1571
or GCR disk buffer starting at
(either side) $300
MFM disk side 1 208,track#,sector#,1 (same as above)
WRITE SECTOR: (data transfer via memory-writes)
MFM disk side 0 194,track#,sector#,1 write sector data to
or GCR disk 1571 buffer starting
(either side) at address $300
MFM disk side 1 210,track#,sector#,1 (same as above)
FORMAT DISK:
MFM single sided 70,129,0,sector size (none)
(0=128 bytes/sector, 1=256,
2=512 or 3=1024),
last track# (default 39),
# of sectors per track,
starting track# (default 0),
track offset (default 0),
fill byte (default hex e5)
MFM double sided first byte=102 then rest same as above
GCR disk 6,0,ID byte#1, (none) (none)
double sided ID byte#2
no directory or
BAM
INQUIRE STATUS: check drive status or load status register
Log in disk with 76,new status (none)
new status
Check last status 140 status from last I/O
Check if disk 204 old status if logged
was logged or status error code 13
..........................................................................
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
THIS DOCUMENT IS COPYRIGHT (C) 1988, 1996 BY HERNE DATA
SYSTEMS LTD. THE MATERIAL CONTAINED HEREIN MAY BE FREELY
USED FOR PERSONAL INFORMATION ONLY. IF YOU REPRODUCE IT,
THIS COPYRIGHT NOTICE MUST NOT BE REMOVED. THIS MATERIAL
MAY NOT BE EXPLOITED FOR COMMERCIAL PURPOSES.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Herne Data Systems Ltd.,
PO Box 250, Tiverton, ON N0G 2T0 CANADA.
Voice/fax 519-366-2732,
e-mail herne@herne.com,
internet: www.herne.com
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Burst Mode Commands
The 1571 disk operating system (DOS) supports an extended set of
commands, collectively called "burst mode" or the "burst command
instruction set" (BCIS), which enables the drive to, among other
things, create, read and write disks in a wide variety of formats
with relative ease. Many, but not all, of the burst mode
commands have analogous commands in standard Commodore DOS. Why
then is there a need to duplicate them in burst mode? The answer
is twofold: speed and versatility. The data transfer rate of a
1541 drive (or a 1571 in 1541 mode) is about 350 bytes per
second. The 1571 in fast mode can read about 1600 bytes per
second. With burst mode, data can be read at the blistering rate
of 4000 or more bytes per second! In fact, the ultimate read
speed is not limited by the hardware. It is controlled by the
efficiency of the driving software. (That is, burst mode can, in
theory, transfer data as fast as you can send it in machine
language.) In addition, burst mode allows you to read and write
disks formatted in the industry standard MFM (maximum (or
modified) frequency modulation) format as well as Commodore GCR
(group coded recording) format. The MFM format is used by most
CP/M computers such as Kaypro, Epson, Osborne, etc., as well as
MS-DOS (IBM-PC and compatible) and TRS-80 machines. Apple ][
type computers use a modified form of GCR which is not compatible
with either MFM or Commodore GCR.
Command Syntax
Burst mode commands are accessed by sending a specific set of
characters through the disk command channel, just like the usual
Commodore DOS commands such as "n0:", "s0:", "b-p:", etc.
Because the first two characters of the command string for all
burst mode commands are "u0", burst commands are often referred
to as the extended user 0 commands.
Burst mode can be accessed by a BASIC statement such as:
OPEN 15,8,15,"U0"+CHR$({command})+additional characters
or the machine language equivalent. Alternatively, if the
command channel has been opened previously, the "OPEN 15,8,15"
can be replaced by "PRINT#15". The "additional characters" depend
on the desired command and its options. These characters
generally select secondary options. Not all of the secondary
option characters need to be sent in some cases because default
values can often be assumed.
The burst mode command byte can be divided into two parts:
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
The command parameter values for the low nibble are summarized in
Table 9-1. The high four bits contain the primary command
options. These are a series of up to four on/off switches which
control some of the main features of the command. The switch
values are outlined in Table 9-2 and detailed in the appropriate
sections of this chapter for each of the commands. It should be
noted that not all commands use all switches, but a given switch
that is used in several of the commands always occupies the same
bit position. For example, the MFM side select switch is always
controlled using bit 4 of the command byte.
Table 9-1: Burst mode command byte low nibble values
.......................................................
Command Nibble Value Command
--------------------
Binary Hex
.......................................................
0 0 0 0 0 Sector read
0 0 1 0 2 Sector write
0 1 0 0 4 Inquire disk
0 1 1 0 6 Format disk
1 0 0 0 8 Sector interleave
1 0 1 0 A Query disk format
1 1 0 0 C Inquire status
1 1 1 0 E Set utilites *
1 1 1 1 F Fast load *
.......................................................
* Note: these commands also require bit 4 to be set to 1.
Table 9-2: Summary of burst mode command switches
................................................................
Designation Bit Applicable Action
Commands
................................................................
B 5 Read; Write 1 = transfer from disk to
buffer for read (buffer
to disk for write) with
no burst transfer between
computer and drive.
0 = include burst transfer
between computer and
drive.
C 6 Inquire status 1 = disk has been changed
since last log-in.
0 = disk has not been changed
since last log-in.
D 5 Format (MFM) 1 = format double sided disk.
0 = format single sided disk.
E 6 Read; write 1 = ignore disk errors.
0 = stop on error.
F 7 Query disk 1 = step head to offset value
before analysing.
0 = analyse track 0 only.
I 6 Format (MFM) 1 = write track index mark.
0 = don't write index mark.
M 7 Format 1 = format MFM disk.
(second command byte) 0 = format GCR disk.
P 7 Format 1 = partial disk format only.
0 = format entire disk.
S 4 (most) 1 = use side 1 of MFM disk.
0 = use side 0 of MFM disk.
T 7 Read; write 1 = don't transfer data via
burst mode.
0 = transfer data via burst
mode.
W 7 Inquire status 1 = read old value.
and Sector 0 = set new value.
interleave
X - dummy filler bit. Value not important and is
ignored. Usually set to 0.
Y* 7 Fast load 1 = file does not have to be
PRG type to LOAD.
0 = file must be PRG type.
Z* 6 Format (MFM) 1 = include sector skew
table.
0 = use default sector table.
.................................................................
* Note: This switch label has been changed from that used in the
1571 User's Guide to avoid confusion with a different switch
given the same label for another command.
Many of the burst mode commands will return a "status" byte as
part of the action of the command. The status byte gives the
calling program information on the success or failure of the
requested operation. In some cases of failure, it may also be a
signal that no burst mode data will be sent. The format of the
status byte is as follows:
Bit
7 6 5 4 3 2 1 0
Mode Drive Sector Size <- controller status ->
Where:
Mode = 0 for GCR disk
= 1 for MFM disk
Drive = 0 (always)
Sector size:
0 0 128 bytes/sector
0 1 256
1 0 512
1 1 1024
The controller status values are summarized in Table 9-3. It
should be noted that in some cases the bit patterns have
different meanings depending on the type of disk (MFM or GCR) in
the drive. These differences are included in the table. In
addition, not all status codes are used by all burst mode
commands. For example, the "Write protect on" error is used only
by the "Sector write" and "Format" commands.
Table 9-3: Burst mode controller status values
............................................................
Bit Pattern Error Condition
............................................................
0 0 0 x All OK
0 0 1 0 Sector not found
0 0 1 1 GCR: No sync mark detected
MFM: No address mark detected
0 1 0 0 GCR: Data block not found
MFM: (not used)
0 1 0 1 GCR: Data checksum error
MFM: Data CRC error
0 1 1 0 Formatting error
0 1 1 1 Verify error
1 0 0 0 Write protect on during write
1 0 0 1 Header checksum error
1 0 1 0 GCR: data extends into next block
MFM: (not used)
1 0 1 1 Disk has been changed since log-in
1 1 0 0 (not used)
1 1 0 1 (not used)
1 1 1 0 Syntax error in burst command
1 1 1 1 Drive not present
............................................................
It should be noted that error checking is not performed on any of
the parameters before they are passed to the 1571. For the most
part, error checking on parameter values (such as track and
sector numbers) is not performed by the 1571 either. This must
be done by the calling program before the bytes are sent.
An example of sending a complete burst mode command from BASIC is
given below (in this example it is assumed that the disk command
channel has already been opened as logical file 15):
PRINT#15,"U0"+CHR$(16)+CHR$(5)+CHR$(2)+CHR$(1)+CHR$(4)
This command will tell the drive to read 1 sector of data,
beginning at track 5, sector 2 on side 1 of an MFM disk, stop if
an error is encountered, else transfer the data to the computer
via burst mode and then step the head to track 4 to await the
next command.
Sector-Read
Burst mode "SECTOR-READ" allows you to read one or more sectors
from a disk and transfer the data to the computer. In addition to
increased speed it has the added advantage over the DOS "u1" and
"Block-Read" commands in being able to read more than one sector
of data with a single stroke and being able to read MFM disks as
well as standard Commodore DOS GCR disks.
The command string for "SECTOR READ" is:
"U0"+CHR$({read})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
where {read} has one of the values listed in Table 9-5; {track}
and {sector} are the track number and sector number to begin
reading at; {#sectors} is the number of sectors to read in the
sequence; and {next track} tells the drive where to park the head
to await the next command. The {#sectors} parameter should be
limited to one track's worth. If it is larger, the command will
keep re-reading sectors from the same track until the specified
number has been read. Although {next track} is optional, its
inclusion is desirable, even if its value is set to {track},
because it minimizes the head movement between subsequent reads
and writes. If {next track} is omitted, the head will go back to
track 0 after each operation, causing a lot of head bouncing and
wasting time.
For a GCR disk, {track} values of 1 to 35 are used to access side
0, while 36 to 70 are used for side 1. For MFM disks, the side
is selected by the value of the "S" switch (bit 4 of the command
byte), as outlined in Table 9-5.
When the "E" switch (bit 6) is set, errors are ignored. This
means that even if the requested sector is not found or an error
occurs during the reading process, the command will transfer
whatever is already in the buffer to the computer. In this case,
the calling program in the computer should analyse the status
byte to determine if the data are valid.
Bit 0 is actually a switch to determine the drive number. Since
the 1571 is only a single drive unit, this bit is always clear.
If the 1572 dual drive is ever produced, the corresponding burst
mode commands for drive 1 will have values of 1 greater than
those listed in Table 9-5.
When both the "T" and "B" switches (bits 7 and 5) are set
(command values of $A0, $B0, $C0, and $D0), no burst mode data
transfer occurs. Instead, the specified sector is read into the
1571 data buffers beginning at address $300. (For best results,
the "T" and "B" switches should be used in tandem and always have
the same value (i.e. either both on or both off)). The data can
then be read from the drive over the normal serial bus (either
fast or slow) with a series of "MEMORY READ"s. This allows other
computers, such as the C-64, to access MFM disks. With this
option, only one sector can be read at a time, due to limitations
with buffer space in the 1571.
It should be stressed that before reading a disk for the first
time (or after removing and re-inserting the same disk), you must
"log-in" the disk using one of "QUERY DISK FORMAT", "INQUIRE
DISK" or "INQUIRE STATUS". This process is required to set-up
the 1571 electronics to handle the particular type of disk
involved. These commands are described later in the chapter.
For each sector read, a status byte will be returned first. If
the error checking is enabled, and an error occurs, then no data
will follow. Otherwise, data bytes from the sector will then be
transferred, if burst transfer has been specified. The total
number of bytes transferred is thus 1 + number of bytes per
sector (including status byte):
Sector size Total bytes sent
128 129
256 (MFM or GCR) 257
512 513
1024 1025
For multi sector reads, the sectors are read in the order
specified with the burst mode "SET SECTOR INTERLEAVE" command,
described later in this chapter. If no interleave has been
specified, the sectors are read in the order which they appear on
the disk. This may result in incorrect reading of the disk if it
has an unusual physical sector skew (that is the sector 2 might
not be physically adjacent to sector 1). To be safe, you should
always specify a sector interleave prior to multi sector
transfers, even if it is only a value of 1 which will force a
read in numerical order regardless of how the sectors are
physically located on the disk.
Table 9-5: Values for burst mode SECTOR READ command byte
...............................................................
Value Action
------------
hex decimal
...............................................................
0 0 read specified sector on MFM disk side 0
or GCR disk, transfer data to computer
via burst mode, stop if error.
10 16 same as above, but for MFM disk, side 1.
40 64 same as value 0, but ignore errors.
50 80 same as value $10, but ignore errors.
A0 160 read specified sector on MFM disk side 0
or GCR disk into data buffer only. Stop
on error. Data can be transferred using
DOS MEMORY READ command over normal
serial bus.
B0 176 same as above, but for MFM disk, side 1.
C0 192 same as value $A0, but ignore errors.
D0 208 same as value $B0, but ignore errors.
...............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
T E B S 0 0 0 0
Sector-Write
Burst mode "SECTOR-WRITE" allows you to write one or more sectors
to a disk after transferring the data from the computer.
Although the speed increase over normal DOS commands is marginal
(due to the limitations of the "verify after write" procedure
that is used for each sector written), it has the advantage over
the DOS "u2" and "Block-Write" commands in being able to write
more than one sector of data with a single stroke and being able
to write to MFM disks as well as standard Commodore DOS GCR
disks.
Similar to the "SECTOR-READ" command described above, it works on
a block-by-block basis. That is, it cannot be used to
automatically SAVE an entire file. Each block (or group of
sectors) of the file must be written individually under user
control.
The command string for "SECTOR WRITE" is:
"U0"+CHR$({write})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
where {write} has one of the values listed in Table 9-6; {track}
and {sector} are the track number and sector number to begin
writing at; {#sectors} is the number of sectors to write in the
sequence; and {next track} tells the drive where to park the head
to await the next command. The {#sectors} parameter should be
limited to one track's worth or less. If more sectors are
specified, the 1571 will keep over-writing sectors on the same
track until the specified number has been reached. This may
result in a corrupted disk. Although {next track} is optional,
its inclusion is desirable, even if its value is set to {track},
because it minimizes the head movement between subsequent reads
and writes. If {next track} is omitted, the head will go back to
track 0 after each operation, causing a lot of head bouncing and
wasting time.
For a GCR disk, {track} values of 1 to 35 are used to access side
0, while 36 to 70 are used for side 1. For MFM disks, the side
is selected by the value of bit 4 of the command byte, as
outlined in Table 9-6.
When the "E" switch (bit 6) is set, errors are ignored. This
means that even if the requested sector is not found or an error
occurs during the writing or verifying process, the command will
continue. In this case, the calling program in the computer
should analyse the status byte to determine if the write was
successful and the data are valid.
Bit 0 is actually a switch to determine the drive number. Since
the 1571 is only a single drive unit, this bit is always clear.
If the 1572 dual drive is ever produced, the corresponding burst
mode commands for drive 1 will have values of one greater than
those listed in Table 9-6.
Table 9-6: Values for burst mode SECTOR WRITE command byte
...............................................................
Value Action
------------
hex decimal
...............................................................
2 2 transfer data to drive via burst mode
and write specified sector on MFM disk
side 0, or GCR disk. Stop if error.
12 18 same as above, but for MFM disk, side 1.
42 66 same as value 2, but ignore errors.
52 82 same as value $12, but ignore errors.
A2 162 write buffer to specified sector on MFM
disk, side 0 or GCR disk. Stop on
error. Data can be written to buffer
first using DOS MEMORY WRITE command
over normal serial bus.
B2 178 same as above, but for MFM disk, side 1.
C2 194 same as value $A2, but ignore errors.
D2 210 same as value $B2, but ignore errors.
...............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
T E B S 0 0 1 0
When both the "T" and "B" switches (bits 7 and 5) are set
(command values of $A2, $B2, $C2, and $D2), no burst mode data
transfer occurs. Instead, the specified sector is written
directly from the 1571 data buffers beginning at address $300.
(For best results, the "T" and "B" switches should be used in
tandem and always have the same value (i.e. either both on or
both off)). Prior to this, the data can be written to the
buffers over the normal serial bus (either fast or slow) with a
series of "MEMORY WRITES"s. This allows other computers, such as
the C-64, to access MFM disks. With this option, only one sector
can be written at a time, due to limitations with buffer space in
the 1571.
It should be stressed that before writing a disk for the first
time (or after removing and re-inserting the same disk), you must
"log-in" the disk using one of "QUERY DISK FORMAT", "INQUIRE
DISK" or "INQUIRE STATUS". This process is required to set-up
the 1571 electronics to handle the particular type of disk
involved. These commands are described later in the chapter.
For multi sector writes, the sectors are written in the order
specified with the burst mode "SET SECTOR INTERLEAVE" command,
described later in this chapter. If no interleave has been
specified, the sectors are written in the order which they appear
on the disk. This may result in incorrect writing of the disk if
it has an unusual physical sector skew (that is the sector 2
might not be physically adjacent to sector 1). To be safe, you
should always specify a sector interleave prior to multi sector
transfers, even if it is only a value of 1 which will force a
write in numerical order regardless of how the sectors are
physically located on the disk.
A burst mode status byte will be returned after each sector
written. This byte will give the result of the requested
operation.
Inquire Disk
Before reading or writing disk sectors via burst mode, it is
necessary to set the 1571 electronics to the proper mode (GCR or
MFM) and initialize various track and sector addressing
parameters which depend on the disk characteristics. This is
generally done using one of the burst mode "log-in" commands.
The INQUIRE DISK command is perhaps the simplest way to log-in a
new disk prior to burst mode reads and writes. The command
string is:
"U0"+CHR$({inquire})
where {inquire} has a value of:
Hex Dec
4 4 to check a GCR disk (either side) or an MFM
disk (side 0)
14 20 to check an MFM disk (side 1).
After logging in the disk, the INQUIRE DISK command will return a
single status byte of the type outlined previously. The value of
the status byte can be used as an indication of the success of
the log-in as well as give some basic information about the
organization of the disk. The status byte will give the mode
(GCR or MFM) as well as the sector size. It will not return
information on the number of sectors on the track, physical
sector interleave, or the sector numbering system. For that
level of detail, the QUERY DISK FORMAT command (discussed later)
must be used. In addition, INQUIRE DISK will only look at the
first track on the disk.
Bit 4 of the command byte is the side select switch for MFM
disks. It is normally only used to test whether side 1 of an MFM
disk is used or not. In rare cases (such as in custom disk
formats), side 1 may not have the same sector size (or even mode)
as side 0. Setting the switch will allow the drive to log in
side 1 without looking at side 0.
The following procedure can be used to distinguish among GCR
disks; single and double sided MFM disks:
1) INQUIRE DISK on side 0. The result of this will tell
you whether the disk is GCR or MFM.
2) INQUIRE DISK on side 1. The result of this will tell
you if side 1 is used.
Note that this procedure can be fooled by a re-used disk that was
once formatted as a double sided MFM disk.
If the object is merely to log-in the disk and the value of the
returned status byte is not important to the calling program,
then the program can immediately procede to the read/write
operation without first reading the status byte. The process of
sending the next command over the serial bus will cancel the need
to read the status byte.
Format
The 1571 is capable of formatting disks in both GCR mode and MFM
mode. The burst mode FORMAT command can be used in both cases.
It should be noted that burst mode format commands do not require
any actual burst mode data transfer. They can be used entirely
with the conventional fast or slow serial bus, even from BASIC.
Format GCR
The command string bytes for a GCR format are:
"U0"+CHR$(6)+CHR$(0)+"{id}"
where {id} is the normal two character ID code used in the
standard DOS format (N0:diskname,ID) command. It should be noted
that no directory or BAM is created on the disk with this
command. Because of this, its usefulness is limited to creating
GCR CP/M disks, custom GCR disks or perhaps for a whole disk
backup program. The speed of formatting with this command is not
significantly faster than with the normal DOS command.
Format MFM
The command string for formatting an MFM disk is:
"U0"+CHR$({format})+CHR$({type})+CHR$({interleave})+
CHR$({sector_size})+CHR$({last_track})+
CHR$({#sectors})+CHR$({start_track#})+
CHR$({start_track_offset})+CHR$({fill_byte})+
CHR$({sector_table})+...
The values and switches for {format} and {type} are given in
Table 9-7. The actions of the various switches will be detailed
later.
{interleave} specifies a physical sector interleave or skew
factor. Normally a default of 0 is assumed (that is, no physical
skew). If any of the remaining parameters are included, then it
must be specified.
{sector_size} has one of the following values, depending on the
desired disk characteristics:
0 for 128 bytes/sector
1 for 256
2 for 512
3 for 1024
The default value is 1 for 256 byte sectors, however, if any of
the remaining parameters are specified, it must be included also.
{last_track} is the highest track number to be formatted on the
disk. Normally this is 39 (the default). This corresponds to
the 40 tracks per side available on a standard MFM disk (numbered
0 to 39). However, some MFM disk types (such as some older CP/M
types and TRS-DOS types) only use 35 tracks per side. In that
case, {last_track} would have a value of 34. Similarly, if you
wanted to squeeze every last byte out of a custom disk format,
you may be able to go a few tracks beyond the normal range and
increase the value up to 41 or 42. {last_track} can also be used
in conjunction with the P flag (for partial format) of the
command byte to create disks that have different sector sizes or
numbering schemes in different areas of the disk. This is used
by some CP/M disk types (typically smaller sector sizes in the
first few tracks of the disk than on the bulk of the disk) or can
be used as the basis of a customized copy protection scheme.
{#sectors} gives the number of sectors on each track. Combined
with the sector size, it is a direct measure of the total storage
capacity of the disk type. The values depend on the desired disk
type and can be in the following range:
Sector Size {#sectors} Default
128 1 to 27 26
256 1 to 18 16
512 1 to 10 9
1024 1 to 5 5
{start_track} is the number to be used in the sector header for
the first track on the disk. This is normally 0, but can take on
other values, especially when used in conjunction with the P
switch of the command byte and {last_track}.
{start_offset} specifies the physical track position to begin
formatting at. Again, this would normally be a value of 0, but
may take on other values for custom disk types. This is the
mechanical position that the head is stepped to prior to
commencing the formatting procedure.
(fill_byte} is the byte value written to the empty sectors on the
disk. The default value is $E5 (decimal 229) which is the
standard for positive polarity CP/M disks. Other disk operating
systems may use different values.
The {sector_table} parameters are used to create custom disk
types with non-standard sector numbering schemes. The optional
table consists of the sequence of sector numbers to be used on
the disk. The numbers do not have to be contiguous, although
non-contiguous numbers may cause problems later when you try to
log-in this disk any read or write to it. It is best used with
the partial format switch bit to create a few tracks somewhere on
the disk with strange sector numbering for copy protection
purposes.
Table 9-7: Values for burst mode Format MFM command bytes
............................................................
Value for {format} Action
--------------
Hex Dec
............................................................
6 6 Format full disk, single sided,
side 0, do not write index marks.
16 22 same as above, but for side 1.
26 38 Format full disk, double sided, do
not write index marks.
46 70 Format full disk, single sided,
side 0, write index marks.
56 86 same as above, but for side 1.
66 102 Format full disk, double sided,
write index marks.
86 134 Format partial disk, single sided,
side 0, do not write index marks.
96 150 same as above, but for side 1.
A6 166 Format partial disk, double sided,
do not write index marks.
C6 198 Format partial disk, single sided,
side 0, write index marks.
D6 214 same as above, but for side 1.
E6 230 Format partial disk, double sided,
write index marks.
............................................................
Note: the command byte values are based on the following
model. Switch designations are described in Table 9-2.
Bit
7 6 5 4 3 2 1 0
<-- switches --> <-- command -->
P I D S 0 1 1 0
{type} values:
............................................................
{type} value
-------------
hex dec Action
............................................................
80 128 Format MFM, use standard sector
numbering beginning with sector #0.
81 129 Format MFM, use standard sector
numbering beginning with sector #1.
8+x 128+x Format MFM, use standard sector
numbering begining with sector x.
C0 192 Format MFM, use included sector
numbering table.
............................................................
{type} byte values are based on:
Bit
7 6 5 4 3 2 1 0
switches <-- starting sector # -->
M Z x x x x x x
Note that the starting sector # (x) is a 5 bit value and can
range from 0 to 63. For MFM disks, M is always 1.
C-128 CP/M has automatic read and write support for a number of
standard MFM type CP/M disk formats when used with a 1571 drive.
Unfortunately, the early versions of the C-128 CP/M FORMAT.COM
disk formatting program did not include the capability to create
new disks in these formats. Table 9-8 is a list of the burst
mode commands required to format new disks in each of the MFM
types supported by C-128 CP/M. Note that the easiest way to
perform this task is with the C-128 in native mode (i.e. not in
CP/M mode) with a statement such as:
OPEN 15,8,15,{command_string} : CLOSE 15
Table 9-8: Formatting CP/M Disks
..................................................................
Disk Type Formatting Command String
..................................................................
IBM CP/M-86 SS "U0"+CHR$(70)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(8)+CHR$(0)+CHR$(0)+CHR$(229)
IBM CP/M-86 DS "U0"+CHR$(102)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(8)+CHR$(0)+CHR$(0)+CHR$(229)
Kaypro II "U0"+CHR$(70)+CHR$(128)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
Kaypro IV "U0"+CHR$(70)+CHR$(128)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
then "U0"+CHR$(86)+CHR$(138)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(0)+CHR$(0)+CHR$(229)
Osborne SS "U0"+CHR$(70)+CHR$(129)+CHR$(0)+CHR$(3)+CHR$(39)
+CHR$(5)+CHR$(0)+CHR$(0)+CHR$(229)
Epson QX-10 (512) "U0"+CHR$(230)+CHR$(129)+CHR$(0)+CHR$(1)+CHR$(1)
+CHR$(16)+CHR$(0)+CHR$(0)+CHR$(229)
then "U0"+CHR$(230)+CHR$(129)+CHR$(0)+CHR$(2)+CHR$(39)
+CHR$(10)+CHR$(2)+CHR$(2)+CHR$(229)
Epson QX-10 (256) "U0"+CHR$(102)+CHR$(129)+CHR$(0)+CHR$(1)+CHR$(39)
+CHR$(16)+CHR$(0)+CHR$(0)+CHR$(229)
or Epson QX-10 (Euro)
...............................................................
Note that "double formatting" is required on the Kaypro IV because
side 0 and side 1 of the disk are numbered differently (sectors 0 to
9 on side 0 and 10 to 19 on side 1), while on the EpsonQX10 (512)
"double formatting" is required because tracks 0 and 1 are in a
different format (256 bytes/sector; 16 sectors /track) compared to
the remainder of the disk (512 bytes/sector; 10 sectors per track).
Partial MFM Formatting
The 1571 has the ability to format or re-format selective areas of a
disk in MFM mode. This was demonstrated above for formatting an
Epson QX-10 (512) CP/M disk. The same procedure can be used to
created "custom" disk formats for copy protection purposes. Most
disk copiers, even sophisticated disk nibblers, cannot handle
multiple densities on the same disk, especially if GCR and MFM are
mixed.
Sector Interleave
The "SECTOR INTERLEAVE" command is used to specify the order in
which multiple sectors are read or written with the burst mode
commands.
Query Disk Format
The "QUERY DISK FORMAT" command is used to obtain detailed
information about the disk in the drive.
Inquire Status
The "INQUIRE STATUS" command is used to check or change the status
of the last burst mode operation. It can also be used for logging
in new disks of a known type.
Set Utilities
The "SET UTILITIES" command is used to change a variety of the 1571
operating parameters such as device number, bus mode, side select,
etc. These commands all begin with the byte sequence "U0>".
Fastload
The "FASTLOAD" command is used to read an entire file from a GCR
Commodore DOS disk via burst mode.
TABLE 9-4: Burst mode command summary
.........................................................................
FUNCTION BYTE SEQUENCE BURST MODE
"U0"+ Input Output
.........................................................................
SECTOR-READ CHR$({read})+CHR$({track})+CHR$({sector})
+CHR$({#sectors})+CHR$({next track})
INQUIRE DISK: reset drive and log in MFM or GCR disk
before a read or write
MFM disk side 0 4 one status byte
or GCR disk
MFM disk side 1 20 (same as above)
QUERY DISK FORMAT: analyze disk format (GCR or
MFM-sector size,sectors/track)
Side 0, track 0 10 one status byte then:
nothing else if
GCR disk or
un-readable
format; or else:
another status
byte; number of
sectors on
track; logical
track#; min
sector#; max sec.#
hard sector
interleave
Side 1, track 0 26 (same as above)
Side 0, track n 138,n (same as above)
Side 1, track n 154,n (same as above)
READ SECTOR: (data transfer via memory-read)
MFM disk side 0 192,track#,sector#,1 sector data in 1571
or GCR disk buffer starting at
(either side) $300
MFM disk side 1 208,track#,sector#,1 (same as above)
WRITE SECTOR: (data transfer via memory-writes)
MFM disk side 0 194,track#,sector#,1 write sector data to
or GCR disk 1571 buffer starting
(either side) at address $300
MFM disk side 1 210,track#,sector#,1 (same as above)
FORMAT DISK:
MFM single sided 70,129,0,sector size (none)
(0=128 bytes/sector, 1=256,
2=512 or 3=1024),
last track# (default 39),
# of sectors per track,
starting track# (default 0),
track offset (default 0),
fill byte (default hex e5)
MFM double sided first byte=102 then rest same as above
GCR disk 6,0,ID byte#1, (none) (none)
double sided ID byte#2
no directory or
BAM
INQUIRE STATUS: check drive status or load status register
Log in disk with 76,new status (none)
new status
Check last status 140 status from last I/O
Check if disk 204 old status if logged
was logged or status error code 13
..........................................................................