Login
Back to forumReply to this topicGo to last reply

Posted By

JamesC
on 2002-03-12
 1581 Specs for Emulator Authors

From a disk emulation standpoint, I would expect the 1581 to be one step further than the 1571, which in itself is a step from the 1541.

The 1581 is PHYSICALLY organized differently than its LOGICAL organization. This is to allow compatibility with older CBM serial device programs, but enable Commodore to use more common (and cheaper) MFM parts.

Commodore uses a 32K ROM chip to hold DOS version 3D for the 1581. 8K of RAM is provided so that the drive can read an entire track at once, speeding up diskette read operations by an average of 30%. Actual reads and writes are performed by a Western Digital 1772 or 1770 drive controller, with Commodore's 32K ROM providing the user interface.

(Quoted from 1581 manual, Chapter 10, US/Canada version):
All DOS operations of the 1581 are done in 256 byte blocks. These blocks appear as individually numbered sectors on the disk. By going through the DOS interface via the commands outlined in this manual, the logical disk format is as follows:
single sided
80 tracks (track 1 to track 80)
40 256 byte sectors per track (0 to 39)
TOTAL DISK STORAGE 3160 BLOCKS
MAXIMUM 296 DIRECTORY ENTRIES
Internally, however, the 1581 has a different view of things. The disk is actually formatted as follows:
double sided (sides 0 and 1, inverted from MFM)
80 tracks per side (0 to 79)
10 512 byte sectors per track (1 to 10)
That is the physical disk format created whenever a HEADER command is sent to the 1581 from the host computer. The physical format is different from the logical format so that more data can be squeezed onto each disk.
All commands sent from the host computer are parsed through the DOS (except the burst commands) and refer to the logical format. Software inside the 1581 automatically takes care of the logical to physical translations necessary to retrieve data properly from the disk.
One of the improvements in the 1581 design over previous Commodore disk drives which makes the device more efficient is the Track Cache Buffer. This buffer is located from $0C00 through $1FFF. All disk accesses involve an entire physical track at a time. If a single sector is needed from a particular track, the entire track is read into RAM. Consequently, any more requests for sectors from the same track require only a RAM data transfer. Sector writes are also speeded up considerably since each consecutive write to sectors on the same track require only a RAM to RAM data transfer. After data is written into the Track Cache Buffer, it is not written to the disk until one of the following occurs: 1) a request is made for access of a sector on a different track; 2) a 'dump track buffer' command is issued; or 3) after 250 milliseconds of no serial bus activity.
[ Note from James: the DOS passes logical locations to the drive controller. It is the responsibility of the drive controller to translate to physical locations.]
Appendix B adds three disk error messages to the standard 1541/1571 error list: Error 2, "Partition selected" (not an error, the numbers following indicate the beginning and ending tracks of the partition); error 76, "Controller Error" indicates that the 177x controller chip is malfunctioning; error 77, "Selected Partition Illegal" indicates that the partition creation command sent does not meet criteria required for a partition.

The directory resides on track 40. Track 40 sector 0 holds the directory header in standard 1541 format: Bytes 00-01 track and sector of first directory block (usually track 40 sector 3); 02 Disk Version Number (should be 'D'); 03 is $00; 04-21 Disk Name; 22-23 Disk ID; 24 is ; 25 is DOS Version Number (3); 26 is Disk Version Number (again a 'D'); 27-28 are and ; 29-255 are zeroes.

Track 40 sector 1 is BAM for side 0 (tracks 1-40). Bytes 00-01 link to the second BAM block for side 1 (held in track 40 sector 2). Byte 02 is the Version Number; byte 03 is Compliment Version Number. Bytes 04-05 Disk ID; 06 is Disk i/o byte (normally 0); 07 is auto-loader flag (zero for our use, detailed below); 08-15 reserved; 16-255 BAM image of tracks 1-40.

Track 40 sector 2 is BAM for side 1 (tracks 41-80). Byte 00 holds $00; byte 01 holds . Bytes 02-15 are copies of 40/01. Bytes 16-255 hold BAM image of tracks 41-80.

BAM image bytes are as follows: 6 bytes per track. Byte offset of 0 = number of free sectors on this track. Offset 1= MSB sector 7, LSB sector 0. Offset 2= MSB sector 15, LSB sector 8. Offset 3= MSB 23, LSB 16. Offset 4=MSB 31, LSB 24. Offset 5= MSB 39, LSB 32.

Directory file format of sectors 3-39, track 40:
Bytes 0,1 are link to next directory block. Bytes 2-255 are file entries 1 to 8 in standard 1541 directory format.

Partition and Subdirectories -- To protect direct access sectors from being deallocated during a VALIDATE command, place them in a defined partition area. VALIDATE on the 1581 automatically skips partition files (file type CBM in the directory, when file types 1-4 are seq, prg, usr, rel, then 5=cbm). Partition files are named when created by the user:
OPEN 15,8,15
PRINT#15, "/0:partition_name,"+CHR$(starting track#)+CHR$(starting sector#)+CHR$(low # of sectors)+CHR$(high # of sectors)+",C"
PRINT DS$
CLOSE 15
Note the commas within the quotation marks after partition_name and before the C at the end of the command.
If a partition is to be used as a subdirectory, it must meet the following criteria:
Partition must be at least 120 sectors (3 tracks)
Must start with sector 0
Must end with sector 40 of a given track
Cannot contain track 40
Partitions are allowed within partitions. Partitions will have their first track allocated as directory track identical to track 40 format.

Partitions that qualify as subdirectories can be entered with
OPEN 15,8,15
PRINT#15,"/0:partition_name"
PRINT DS$
CLOSE 15
Selected partition may not be used for storage until it is formatted with HEADER command.
Directories can only be accessed forward. To go from root directory (track 40) to subdirectory 1 to subdirectory 2 within subdirectory 1, you must:
OPEN 15,8,15
PRINT#15,"/" (if not already at root)
PRINT#15,"/0:partition_1"
PRINT#15,"/0:partition_under_partition_1"
PRINT DS$
CLOSE 15
Partitions may be deleted by SCRATCHing their corresponding entries in the directory. Any files within the subdirectory will be lost, because as we learned above any attempt to re-divide the disk will require a HEADER before the new subdirectory can be accessed.
As the Plus/4 cannot take advantage of burst access routines I will not waste [even more] bandwidth detailing them here. Information is identical to 1571 burst mode if you wish to check there.

If you require more information or a sample .d81 file for testing purposes, please email me at doctorduckie@hotmail.com .

James C in NTSC-land


Posted By

Mike
on 2002-09-21
 (no topic)

See.... I missed this one happy

I have a 1581 here as well.... I think itd be cool to use .d81 files, and it shouldnt be too hard to do either. I'll look into it when I get time..

Posted By

JamesC
on 2002-09-21
 Mike -->

I have a scanner hooked up now (I did not at the time I posted that message).... if you want to see the pages from the 1581 manual I can scan them for you.

Posted By

Mike
on 2002-09-29
 (no topic)

No thats okay.... I have one as well.... happy



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024