C1591 "Highly 1581 compatible 16MB hard disk implementation" proposal. For Commodore 8 bit emulators, Ultimate 64, 1541 ultimate, and Turbo Chameleon. This is a proposal document to make a modified 1581 ROM that supports a disk file with 256 tracks and 256 sectors (track 0 and 40 reserved). The proposed file extension would be .d16 and the file should be exactly 16777216 bytes in size, however if you are loading a custom ROM, this could be, bigger than you believe. This format is being built to be futureproof. There is some allocations for future ROMs that can implement hard disks, but as long as the format is respected, all versions should be readable up to their size limits, and in fact, tracks 1-80, sectors 1-40 can be copied right back to a 1581 and it will work. The file will be made up 65536 sectors which will closely follow the 1581 disk format. The root directory will still be on track 40 for full compatibility, and a few (only a few) patches to the 1581 rom will need to be made. Instead of being a disk with 80 tracks and 40 sectors (a format that was already abstracted from the controller) it will be 256x256. However some sectors will be reserved. Requirements of patched ROM (Will go over a disassembly of 1581 ROM to make it): 1) Change all track and sector limits to 255 ($FF) 2) Alternate BAM handling routines, should write to track 0 instead, there should only be a few of them. a) Keep the 1581 BAMs in sync for the first 80 tracks and 40 sectors. 3) Prefer to create new partitions (directories) above track 80 to keep a totally 1581 compatible area free for root directory sectors 4) Prefer to create files in the 80/40 area first to keep the root directory compatible with 1581 up to the first 800k 5) @U0>P[0-3]: Change disk pronoun, see below. Possible additional changes (unrequired): 1) @U0>D1: Protect track 18 (mark all of its sectors as $FE in BAM, to allow 1541 presentation. Possible emulator/fpga changes (unrequired, but recommended): 1) Implement Alternate ROM protocol to read a ROM for the drive handler from the image. 2) If a .d16 file, assume that track, sector, and head can be 24 bit. Determine geometry from the rigid disk block. 1591 unaware applications that simply communicate with the drive using DOS and the kernel will be able to use all of the disk without any problems. 1591 unaware applications that are 1581 aware will also be able to use the first 800K without any problems. Their 1581 aware low level operations will not affect the integrity of the disk. 1591 aware applications Disk format ----------- Track Sector(s) Description 0 0 **** 1591 rigid disk block. All unspecified areas $00 filled **** $00-$1F *** Disk Identification *** $00-$03 "1591" (DO NOT CHANGE) $04-$07 "DOSx" Where x = version byte, starting with 1. Alternate ROMs can completely change this. $08 (b0-b5) $00 = No Alternate DOS ROM at track 40 sector 192 $01-3F = Number of valid sectors in alternate DOS ROM (b6-b7) Disk pronoun: 00 = (default) Present as a d16 (16mb) disk or let alternate ROM decide 01 = Present as 1581 (extremely safe, allows accesses outside 1581 space) 10 = Present as 1581 (completely safe, limits to 1581 space unless switched) 11 = Present as 1541 (potentially dangerous, protect track 18 in REAL BAM) $09-$0A Alternate ROM DOS type (Something other than "4F" please. "3D" if you want to masquerade as a 1581) $0B-$0D Just "FOX" here. Look for 1591???????FOX to positively identify this as a 1591 image. $0E-$0F Disk ID $10-$1F Disk label, $00 padded $20-$2F *** Disk Geometry - 1581 patched rom will not use this but it should always be correct *** $20-$22 Number of sectors (a pure d16 has 00 01 00 here) $23-$25 Number of tracks (a pure d16 has 00 01 00 here) $26-$27 Number of heads (a pure d16 has 01 00 here, which means use logical block addressing) $28-$2A Size of a sector (a pure d16 has 00 01 00 here, 256 bytes) $2B Bit 7: 0 = Thin provisioned, 1 = Thick provisioned Bit 3-0: Provisioned 2^n sectors at a time Note: ($20..$22)*($23..$25)*($26-$27)*($28-$2A) = expected size of file. (unless thin provisioned) Yes, that is up to 96 bits in size or up to 256 YiB (yobibytes) $2C-$2F Reserved, $00 padded $30-$FF *** Reserved, $00 filled *** 0 $01-$FF Real BAM sectors (sector = track number of BAM) $00 BAM info $01-FF $00 = Unused sector (or wiped sector) $01-FD = Used (number of valid bytes in sector after next sector pointer) $FE = Reserved/Special (not associated with a file) $FF = Previously used but free sector (could undelete) 40 0 *** Disk header *** $00–01 T/S reference to first directory sector (40,3) $02 DOS version ('F') $04-$13 Disk Label, $A0 padded $16-$17 Disk ID $19-$1A DOS type ('4F') $20-$FF Reserved, GEOS may use ... 40 1 1581 compatible BAM mirror $00-01 T/S to next BAM sector (40,2) $02 DOS version ('F') $04-$05 Disk ID $06 I/O byte bit 7 set - Verify on bit 7 clear - Verify off bit 6 set - Check header CRC bit 6 clear - Don't check header CRC $07 Autoboot flag $08-0B Track of real BAM sector (00 00 00 00) $0C-0F Sector of real BAM sector (01 00 00 00) $10-$FF BAM entries for Tracks 1-40, sectors 1-40 (Side 1) 40 2 1581 compatible BAM mirror $00-$01 00/FF $02 DOS version ('F') $04-$05 Disk ID $06 I/O byte $07 Autoboot flag $08-0B Track of real BAM sector (00 00 00 00) $0C-0F Sector of real BAM sector (02 00 00 00) $10-$FF BAM entries for Tracks 41-80, Sectors 1-40 (Side 2) 40 $03-$82 Directory sectors $00-1F: First directory entry $00-$01: Track/Sector location of next directory sector $02: File type. Bit 0-3: The actual filetype 000 (0) - DEL ($00) 001 (1) - SEQ ($81) 010 (2) - PRG ($82) 011 (3) - USR ($83) 100 (4) - REL ($84) 101 (5) - CBM ($85, partition or sub-directory) (6-15) - Reserved Bit 4: Not used Bit 5: Used only during SAVE-@ replacement Bit 6: Locked flag (Set produces ">" locked files) Bit 7: Closed flag (Not set produces "*", or "splat" files) $03-$04: Track/sector location of first sector of file or partition $05-$14: 16 character filename (in PETASCII, padded with $A0) $15-$16: Track/Sector location of first SUPER SIDE SECTOR block (REL file only) $17: REL file record length (REL file only) $18-$1B: Unused (GEOS may use) $1C-$1D: (Used during an @SAVE or @OPEN, holds the new t/s link) $1E-$1F: File or partition size in sectors, little endian, file size ~ ($1e-$1f * 254) $20-3F: Next directory entry ... $E0-FF: 8th directory entry (Next sector has 8 more entries, up to 1024 directory entries) 40 $83-$9F (7168) Usable by applications and alternative OSes, DOS ROMs $A0-$BF (8192) Reserved for alternate DOS ROM use 40 $C0-$FF Up to 16K of alternative DOS ROM for handling of this image (allow for larger formats, future drive types) 1-39 $00-$FF Usable sectors for data 41-255 $00-$FF Usable sectors for data Result ------ @$ 0 "LABEL " ID 4F 65024 BLOCKS FREE.