| 1 |
|
| 2 |
This text file describes the DMK format as it is being used in openMSX. |
| 3 |
|
| 4 |
Originally openMSX only support simple sector based formats like the |
| 5 |
generic dsk format and the xsa format (which in essence is a compressed |
| 6 |
dsk format). These formats contained a simple dump of all the data in |
| 7 |
the sectors on a 360/720KB Double Density disk. |
| 8 |
|
| 9 |
These formats however could not be used to store track info that was |
| 10 |
commonly used for copyprotecting disks. Copy protecting resorted to |
| 11 |
tricks like out of order sectors, partially formated tracks and other |
| 12 |
trickery that was made possible by customizing the actual track |
| 13 |
headers, sector headers and CRC checks that are used by the FDC (floppy |
| 14 |
disk controller) chip when reading data from a disk. |
| 15 |
|
| 16 |
When Wouter,one of the openMSX developers, started to look for a |
| 17 |
format for openMSX to store more complete (read: copy-protected) |
| 18 |
diskimages his eyes fell upon the DMK format. |
| 19 |
|
| 20 |
The DMK format was originaly created to store TRS-80 disk. Not all of |
| 21 |
the TRS-80 specifics in the DMK format apply to the MSX standard so |
| 22 |
not everything in the DMK format is implemented for the moment, nor |
| 23 |
will it probably ever be . For instance Single Density was never |
| 24 |
used on MSX, so no support for it is implemented in openMSX. |
| 25 |
|
| 26 |
|
| 27 |
The original page containing this info can be found at |
| 28 |
http://www.trs-80.com/wordpress/dsk-and-dmk-image-utilities/ |
| 29 |
|
| 30 |
DMK Format Details |
| 31 |
================== |
| 32 |
|
| 33 |
Files with a .DSK extension could be JV1, JV3, or DMK format. The DMK |
| 34 |
format is a format developed by David Keil which allows for the storing |
| 35 |
of TRS-80 disks in pure form, which would allow for the representation |
| 36 |
of copy protected disks into emulator images. The DMK format gives the |
| 37 |
ability to support any FM or MFM encoded format that is reasonably close |
| 38 |
to the IBM 3740 or IBM System 34 standards. |
| 39 |
|
| 40 |
DMK format disks are easy to discern because of its 16 byte header. |
| 41 |
Emulators made after 2005 should handle the DMK format. |
| 42 |
|
| 43 |
The DMK virtual disk format is as close to the way data on a real disk |
| 44 |
is stored as possible. There is very little added overhead and the data |
| 45 |
is easily examined and edited using PC based hex editors. The actual |
| 46 |
design is really quite simple and enables support of ALL the WD-17xx |
| 47 |
controller functions and formats. While the design is simple however the |
| 48 |
programming requirements for this format are much more extensive then |
| 49 |
for the JV1/JV3 formats. |
| 50 |
Disk header: |
| 51 |
|
| 52 |
Virtual disks have a 16 byte disk header which is initialized when the |
| 53 |
user creates a new virtual disk. This header may be modified before or |
| 54 |
after a virtual disk has been formatted to change some of its |
| 55 |
characteristics. |
| 56 |
|
| 57 |
+----------------------------------------------------------------------+ |
| 58 |
| Byte 0 | If this byte is set to FFH the disk is 'write | |
| 59 |
| | protected', 00H allows writing. | |
| 60 |
|--------------+-------------------------------------------------------| |
| 61 |
| Byte 1 | Number of tracks on virtual disk. Since tracks start | |
| 62 |
| | at 0 this value will be one greater than the highest | |
| 63 |
| | track written to the disk. So a disk with 40 tracks | |
| 64 |
| | will have a value of 40 (28H) in this field after | |
| 65 |
| | formatting while the highest track written would be | |
| 66 |
| | 39. This field is updated after a track is formatted | |
| 67 |
| | if the track formatted is greater than or equal to | |
| 68 |
| | the current number of tracks. Re-formatting a disk | |
| 69 |
| | with fewer tracks will NOT reduce the number of | |
| 70 |
| | tracks on the virtual disk. Once a virtual disk has | |
| 71 |
| | allocated space for a track it will NEVER release it. | |
| 72 |
| | Formatting a virtual disk with 80 tracks then | |
| 73 |
| | re-formatting it with 40 tracks would waste space | |
| 74 |
| | just like formatting only 40 tracks on an 80 track | |
| 75 |
| | drive. The emulator and TRS-80 operating system don't | |
| 76 |
| | care. To re-format a virtual disk with fewer tracks | |
| 77 |
| | use the /I option at start-up to delete and re-create | |
| 78 |
| | the virtual disk first, then re-format to save space. | |
| 79 |
| | | |
| 80 |
| | Note: This field should NEVER be modified. Changing | |
| 81 |
| | this number will cause TRS-80 operating system disk | |
| 82 |
| | errors. (Like reading an 80 track disk in a 40 track | |
| 83 |
| | drive) | |
| 84 |
| | | |
| 85 |
|--------------+-------------------------------------------------------| |
| 86 |
| Byte 2 & 3 | This is the track length for the virtual disk. By | |
| 87 |
| | default the value is 1900H, 80H bytes more than the | |
| 88 |
| | actual track length, this gives a track length of | |
| 89 |
| | 6272 bytes. A real double density track length is | |
| 90 |
| | aprox. 6250 bytes. This is the default value when a | |
| 91 |
| | virtual disk is created. Values for other disk and | |
| 92 |
| | format types are 0CC0H for single density 5.25" | |
| 93 |
| | floppies, 14E0H for single density 8" floppies and | |
| 94 |
| | 2940H for double density 8" floppies. The max value | |
| 95 |
| | is 2940H. For normal formatting of disks the values | |
| 96 |
| | of 1900H and 2940H for 5.25" and 8" are used. The | |
| 97 |
| | emulator will write two bytes and read every second | |
| 98 |
| | byte when in single density to maintain proper | |
| 99 |
| | sector spacing, allowing mixed density disks. Setting | |
| 100 |
| | the track length must be done before a virtual disk | |
| 101 |
| | is formatted or the disk will have to be re-formatted | |
| 102 |
| | and since the space for the disk has already been | |
| 103 |
| | allocated no space will be saved. | |
| 104 |
| | | |
| 105 |
| | WARNING: Bytes are entered in reverse order (ex. | |
| 106 |
| | 2940H would be entered, byte 2=40, byte 3=29). | |
| 107 |
| | | |
| 108 |
| | Note: No modification of the track length is | |
| 109 |
| | necessary, doing so only saves space and is not | |
| 110 |
| | necessary to normal operation. The values for all | |
| 111 |
| | normal 5.25" and 8" disks are set when the virtual | |
| 112 |
| | disk is created. DON'T modify the track length unless | |
| 113 |
| | you understand these instructions completely. Nothing | |
| 114 |
| | in the PC world can be messed up by improper | |
| 115 |
| | modification but any other virtual disk mounted in | |
| 116 |
| | the emulator with an improperly modified disk could | |
| 117 |
| | have their data scrambled. | |
| 118 |
|--------------+-------------------------------------------------------| |
| 119 |
| Byte 4 | Virtual disk option flags. | |
| 120 |
| | | |
| 121 |
| | Bit 4 of this byte, if set, means this is a single | |
| 122 |
| | sided ONLY disk. This bit is set if the user selects | |
| 123 |
| | single sided during disk creation and should not | |
| 124 |
| | require modification. This flag is used only to save | |
| 125 |
| | PC hard disk space and is never required. | |
| 126 |
| | | |
| 127 |
| | Bit 6 of this byte, if set, means this disk is to be | |
| 128 |
| | single density size and the emulator will access one | |
| 129 |
| | byte instead of two when doing I/O in single density. | |
| 130 |
| | Double density can still be written to a single | |
| 131 |
| | density disk but with half the track length only 10 | |
| 132 |
| | 256 byte sectors can be written in either density. | |
| 133 |
| | Mixed density is also possible but sector timing may | |
| 134 |
| | be off so protected disks may not work, a maximum of | |
| 135 |
| | 10 256 byte sectors of mixed density can be written | |
| 136 |
| | to a single density disk. A program like "Spook | |
| 137 |
| | House" which has a mixed density track 0 with 1 SD | |
| 138 |
| | sector and 1 DD sector and the rest of the disk | |
| 139 |
| | consisting of 10 SD sectors/track will work with this | |
| 140 |
| | flag set and save half the PC hard disk space. The | |
| 141 |
| | protected disk "Super Utility + 3.0" however has 6 SD | |
| 142 |
| | and 6 DD sectors/track for a total of 12 256 byte | |
| 143 |
| | sectors/track. This disk cannot be single density. | |
| 144 |
| | | |
| 145 |
| | This bit is set if the user selects single density | |
| 146 |
| | during disk creation and should not require | |
| 147 |
| | modification. This flag is used only to save PC hard | |
| 148 |
| | disk space and is never required. | |
| 149 |
| | | |
| 150 |
| | Bit 7 of this byte, if set, means density is to be | |
| 151 |
| | ignored when accessing this disk. The disk MUST be | |
| 152 |
| | formatted in double density but the emulator will | |
| 153 |
| | then read and write the sectors in either density. | |
| 154 |
| | The emulator will access one byte instead of two when | |
| 155 |
| | doing I/O in single density. | |
| 156 |
| | | |
| 157 |
| | This flag was an early way to support mixed density | |
| 158 |
| | disks it is no longer needed for this purpose. It is | |
| 159 |
| | now used for compatibility with old virtual disks | |
| 160 |
| | created without the double byte now used when in | |
| 161 |
| | single density. This bit can be set manually in a hex | |
| 162 |
| | editor to access old virtual disks written in single | |
| 163 |
| | density. | |
| 164 |
|--------------+-------------------------------------------------------| |
| 165 |
| Byte 5-B | reserved for future options | |
| 166 |
|--------------+-------------------------------------------------------| |
| 167 |
| Byte C-F | Must be zero if virtual disk is in emulator's native | |
| 168 |
| | format. | |
| 169 |
| | | |
| 170 |
| | Must be 12345678h if virtual disk is a REAL disk | |
| 171 |
| | specification file used to access REAL TRS-80 | |
| 172 |
| | floppies in compatible PC drives. | |
| 173 |
|--------------+-------------------------------------------------------| |
| 174 |
| Track Header | Each track has a 128 (80H) byte header which contains | |
| 175 |
| | an offset to each IDAM in the track. This is created | |
| 176 |
| | during format and should NEVER require modification. | |
| 177 |
| | The actual track data follows this header and can be | |
| 178 |
| | viewed with a hex editor showing the raw data on the | |
| 179 |
| | track. Modification should not be done as each IDAM | |
| 180 |
| | and sector has a CRC, this is just like a real disk, | |
| 181 |
| | and modifying the sector data without updating the | |
| 182 |
| | CRC value will cause CRC errors when accessing the | |
| 183 |
| | virtual disk within the emulator. | |
| 184 |
| | | |
| 185 |
| | Note: Modification within MSDOS could however be done | |
| 186 |
| | to emulate a protected disk in the TRS-80 emulator. | |
| 187 |
+----------------------------------------------------------------------+ |
| 188 |
|
| 189 |
Track header: |
| 190 |
|
| 191 |
Each side of each track has a 128 (80H) byte header which contains an |
| 192 |
offset pointer to each IDAM in the track. This allows a maximum of 64 |
| 193 |
sector IDAMs/track. This is more than twice what an 8 inch disk would |
| 194 |
require and 3.5 times that of a normal TRS-80 5 inch DD disk. This |
| 195 |
should more than enough for any protected disk also. |
| 196 |
|
| 197 |
These IDAM pointers MUST adhere to the following rules. |
| 198 |
|
| 199 |
* Each pointer is a 2 byte offset to the FEh byte of the IDAM. In |
| 200 |
double byte single density the pointer is to the first FEh. |
| 201 |
* The offset includes the 128 byte header. For example, an IDAM 10h |
| 202 |
bytes into the track would have a pointer of 90h, 10h+80h=90h. |
| 203 |
* The IDAM offsets MUST be in ascending order with no unused or bad |
| 204 |
pointers. |
| 205 |
* If all the entries are not used the header is terminated with a |
| 206 |
0000h entry. Unused entries must also be zero filled. |
| 207 |
* Any IDAMs overwritten during a sector write command should have |
| 208 |
their entry removed from the header and all other pointer entries |
| 209 |
shifted to fill in. |
| 210 |
* The IDAM pointers are created during the track write command |
| 211 |
(format). A completed track write MUST remove all previous IDAM |
| 212 |
pointers. A partial track write (aborted with the forced interrupt |
| 213 |
command) MUST have it's previous pointers that were not |
| 214 |
overwritten added to the new IDAM pointers. |
| 215 |
* The pointer bytes are stored in reverse order (LSB/MSB). |
| 216 |
|
| 217 |
Each IDAM pointer has two flags. Bit 15 is set if the sector is double |
| 218 |
density. Bit 14 is currently undefined. These bits must be masked to get |
| 219 |
the actual sector offset. For example, an offset to an IDAM at byte 90h |
| 220 |
would be 0090h if single density and 8090h if double density. |
| 221 |
|
| 222 |
Track data: |
| 223 |
|
| 224 |
The actual track data follows the header and can be viewed with a hex |
| 225 |
editor showing the raw data on the track. If the virtual disk doesn't |
| 226 |
have bits 6 or 7 set of byte 4 of the disk header then each single |
| 227 |
density data byte is written twice, this includes IDAMs and CRCs (the |
| 228 |
CRCs are calculated as if only 1 byte was written however). The IDAM and |
| 229 |
sector data each have CRCs, this is just like on a real disk. |
| 230 |
|
| 231 |
Modification should not be done since doing so without updating the |
| 232 |
CRCs would cause data errors. Modification could be done however to |
| 233 |
create protected tracks for importing protected disks to virtual disk |
| 234 |
format. Examples of disks created using this technique are "Super |
| 235 |
Utility+ 3.0" and "Forbidden City". |
| 236 |
|