src/mess/formats/ti99_dsk.c
| r9560 | r9561 | |
| 5 | 5 | * TI99 and Geneve disk images |
| 6 | 6 | * Sector Dump and Track Dump format |
| 7 | 7 | * |
| 8 | | * used by TI-99/4, TI-99/4A, TI-99/8, TI-99/4P, and Geneve |
| 8 | * used by TI-99/4, TI-99/4A, TI-99/8, SGCPU ("TI-99/4P"), and Geneve |
| 9 | 9 | * |
| 10 | 10 | * The Sector Dump Format is also known as v9t9 (named after the first TI |
| 11 | 11 | * emulator to use this format). It is a contiguous sequence of sector contents |
| r9560 | r9561 | |
| 63 | 63 | * |
| 64 | 64 | * TODO: Link to imgtool. imgtool still uses its own format creation |
| 65 | 65 | * |
| 66 | | * TODO: Test with diverse disks, inserted at the start and in the meantime |
| 67 | | * Check delay |
| 68 | | * |
| 69 | | * |
| 70 | 66 | * FIXME: If image is broken with good first track and defect higher tracks, |
| 71 | 67 | * tdf_guess_geometry fails to define a geometry. The guessing should |
| 72 | 68 | * always be done. |
| r9560 | r9561 | |
| 104 | 100 | int heads; |
| 105 | 101 | int tracks; |
| 106 | 102 | int sectors; |
| 107 | | int track_size; /* Complete track; to be calculated */ |
| 103 | int track_size; // Complete track; to be calculated |
| 108 | 104 | int format; |
| 109 | 105 | int first_idam; |
| 110 | 106 | int dam_offset; |
| r9560 | r9561 | |
| 124 | 120 | } |
| 125 | 121 | |
| 126 | 122 | #define TI99_DSK_TAG "ti99dsktag" |
| 127 | | |
| 128 | | #if 0 |
| 129 | | static void dump_contents(UINT8 *buffer, int length) |
| 130 | | { |
| 131 | | for (int i=0; i < length; i+=16) |
| 132 | | { |
| 133 | | for (int j=0; j < 16; j+=2) |
| 134 | | { |
| 135 | | printf("%02x%02x ", buffer[i+j], buffer[i+j+1]); |
| 136 | | } |
| 137 | | printf("\n"); |
| 138 | | } |
| 139 | | } |
| 140 | | #endif |
| 141 | | |
| 142 | 123 | #define TI99DSK_BLOCKNOTFOUND -1 |
| 143 | 124 | |
| 144 | 125 | /* |
| r9560 | r9561 | |
| 174 | 155 | */ |
| 175 | 156 | static int ti99_get_heads_per_disk(floppy_image *floppy) |
| 176 | 157 | { |
| 177 | | /* struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 178 | | return tag->heads; */ |
| 158 | // struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 159 | // return tag->heads; |
| 179 | 160 | return 2; |
| 180 | 161 | } |
| 181 | 162 | |
| r9560 | r9561 | |
| 187 | 168 | { |
| 188 | 169 | int drivetracks = 42; |
| 189 | 170 | |
| 190 | | /* This may fail on startup; therefore we use a special function in |
| 191 | | 99_dsk to explicitly set the geometry. */ |
| 171 | // This may fail on startup; therefore we use a special function in |
| 172 | // in the floppy controller implementations to explicitly set the geometry. |
| 192 | 173 | if (use_80_track_drives) |
| 193 | 174 | { |
| 194 | 175 | drivetracks = 83; |
| r9560 | r9561 | |
| 296 | 277 | int totsecs; |
| 297 | 278 | typedef struct ti99_vib |
| 298 | 279 | { |
| 299 | | char name[10]; /* volume name (10 characters, pad with spaces) */ |
| 300 | | UINT8 totsecsMSB; /* disk length in sectors (big-endian) (usually 360, 720 or 1440) */ |
| 280 | char name[10]; // volume name (10 characters, pad with spaces) |
| 281 | UINT8 totsecsMSB; // disk length in sectors (big-endian) (usually 360, 720 or 1440) |
| 301 | 282 | UINT8 totsecsLSB; |
| 302 | | UINT8 secspertrack; /* sectors per track (usually 9 (FM) or 18 (MFM)) */ |
| 303 | | UINT8 id[3]; /* String "DSK" */ |
| 304 | | UINT8 protection; /* 'P' if disk is protected, ' ' otherwise. */ |
| 305 | | UINT8 tracksperside; /* tracks per side (usually 40) */ |
| 306 | | UINT8 sides; /* sides (1 or 2) */ |
| 307 | | UINT8 density; /* 0,1 (FM) or 2,3,4 (MFM) */ |
| 308 | | UINT8 res[36]; /* Empty for traditional disks, or up to 3 directory pointers */ |
| 309 | | UINT8 abm[200]; /* allocation bitmap: a 1 for each sector in use (sector 0 is LSBit of byte 0, sector 7 is MSBit of byte 0, sector 8 is LSBit of byte 1, etc.) */ |
| 283 | UINT8 secspertrack; // sectors per track (usually 9 (FM) or 18 (MFM)) |
| 284 | UINT8 id[3]; // String "DSK" |
| 285 | UINT8 protection; // 'P' if disk is protected, ' ' otherwise. |
| 286 | UINT8 tracksperside; // tracks per side (usually 40) |
| 287 | UINT8 sides; // sides (1 or 2) |
| 288 | UINT8 density; // 0,1 (FM) or 2,3,4 (MFM) |
| 289 | UINT8 res[36]; // Empty for traditional disks, or up to 3 directory pointers |
| 290 | UINT8 abm[200]; // allocation bitmap: a 1 for each sector in use (sector 0 is LSBit of byte 0, |
| 291 | // sector 7 is MSBit of byte 0, sector 8 is LSBit of byte 1, etc.) |
| 310 | 292 | } ti99_vib; |
| 311 | 293 | |
| 312 | 294 | ti99_vib vib; |
| r9560 | r9561 | |
| 323 | 305 | |
| 324 | 306 | file_size = (UINT32) size; |
| 325 | 307 | |
| 326 | | /* Read the Volume Information Block */ |
| 308 | // Read the Volume Information Block |
| 327 | 309 | floppy_image_read(floppy, &vib, 0, sizeof(vib)); |
| 328 | 310 | |
| 329 | | /* If we have read the sector successfully, let us parse it */ |
| 311 | // If we have read the sector successfully, let us parse it |
| 330 | 312 | totsecs = (vib.totsecsMSB << 8) | vib.totsecsLSB; |
| 331 | 313 | geometry->secspertrack = vib.secspertrack; |
| 332 | 314 | if (geometry->secspertrack == 0) |
| 333 | | /* Some images might be like this, because the original SSSD TI controller always assumes 9. */ |
| 315 | // Some images might be like this, because the original SSSD |
| 316 | // TI controller always assumes 9. |
| 334 | 317 | geometry->secspertrack = 9; |
| 335 | 318 | geometry->tracksperside = vib.tracksperside; |
| 336 | 319 | if (geometry->tracksperside == 0) |
| 337 | | /* Some images are like this, because the original SSSD TI controller always assumes 40. */ |
| 320 | // Some images are like this, because the original SSSD TI controller |
| 321 | // always assumes 40. |
| 338 | 322 | geometry->tracksperside = 40; |
| 339 | 323 | geometry->sides = vib.sides; |
| 340 | 324 | if (geometry->sides == 0) |
| 341 | | /* Some images are like this, because the original SSSD TI controller always assumes that tracks beyond 40 are on side 2. */ |
| 325 | // Some images are like this, because the original SSSD TI controller |
| 326 | // always assumes that tracks beyond 40 are on side 2. */ |
| 342 | 327 | geometry->sides = totsecs / (geometry->secspertrack * geometry->tracksperside); |
| 343 | 328 | geometry->density = vib.density; |
| 344 | | /* check that the format makes sense */ |
| 329 | // check that the format makes sense |
| 345 | 330 | if (((geometry->secspertrack * geometry->tracksperside * geometry->sides) == totsecs) |
| 346 | 331 | && (geometry->density <= 4) && (totsecs >= 2) && (! memcmp(vib.id, "DSK", 3)) |
| 347 | 332 | && (file_size == totsecs*256)) |
| r9560 | r9561 | |
| 351 | 336 | } |
| 352 | 337 | logerror("SDF/VIB not consistent; guessing format\n"); |
| 353 | 338 | |
| 354 | | /* So that was not consistent. We guess the size from the file size |
| 355 | | and assume that the VIB did not contain reliable data. For the |
| 356 | | ambiguous case we choose the most common format. |
| 357 | | */ |
| 339 | // So that was not consistent. We guess the size from the file size |
| 340 | // and assume that the VIB did not contain reliable data. For the |
| 341 | // ambiguous case we choose the most common format. |
| 342 | |
| 358 | 343 | switch (file_size) |
| 359 | 344 | { |
| 360 | 345 | case 1*40*9*256: |
| 361 | | /* 90kbytes: SSSD */ |
| 346 | // 90kbytes: SSSD |
| 362 | 347 | case 0: |
| 363 | 348 | /*default:*/ |
| 364 | 349 | geometry->sides = 1; |
| r9560 | r9561 | |
| 368 | 353 | break; |
| 369 | 354 | |
| 370 | 355 | case 2*40*9*256: |
| 371 | | /* 180kbytes: either DSSD or 18-sector-per-track SSDD. |
| 372 | | We assume DSSD since DSSD is more common and is supported by |
| 373 | | the original TI SD disk controller. */ |
| 356 | // 180kbytes: either DSSD or 18-sector-per-track SSDD. |
| 357 | // We assume DSSD since DSSD is more common and is supported by |
| 358 | // the original TI SD disk controller. |
| 374 | 359 | geometry->sides = 2; |
| 375 | 360 | geometry->tracksperside = 40; |
| 376 | 361 | geometry->secspertrack = 9; |
| r9560 | r9561 | |
| 378 | 363 | break; |
| 379 | 364 | |
| 380 | 365 | case 1*40*16*256: |
| 381 | | /* 160kbytes: 16-sector-per-track SSDD (standard format for TI |
| 382 | | DD disk controller prototype, and the TI hexbus disk |
| 383 | | controller?) */ |
| 366 | // 160kbytes: 16-sector-per-track SSDD (standard format for TI |
| 367 | // DD disk controller prototype, and the TI hexbus disk |
| 368 | // controller?) */ |
| 384 | 369 | geometry->sides = 1; |
| 385 | 370 | geometry->tracksperside = 40; |
| 386 | 371 | geometry->secspertrack = 16; |
| r9560 | r9561 | |
| 388 | 373 | break; |
| 389 | 374 | |
| 390 | 375 | case 2*40*16*256: |
| 391 | | /* 320kbytes: 16-sector-per-track DSDD (standard format for TI |
| 392 | | DD disk controller prototype, and TI hexbus disk |
| 393 | | controller?) */ |
| 376 | // 320kbytes: 16-sector-per-track DSDD (standard format for TI |
| 377 | // DD disk controller prototype, and TI hexbus disk |
| 378 | // controller?) |
| 394 | 379 | geometry->sides = 2; |
| 395 | 380 | geometry->tracksperside = 40; |
| 396 | 381 | geometry->secspertrack = 16; |
| r9560 | r9561 | |
| 398 | 383 | break; |
| 399 | 384 | |
| 400 | 385 | case 2*40*18*256: |
| 401 | | /* 360kbytes: 18-sector-per-track DSDD (standard format for most |
| 402 | | third-party DD disk controllers, but reportedly not supported by |
| 403 | | the original TI DD disk controller prototype) */ |
| 386 | // 360kbytes: 18-sector-per-track DSDD (standard format for most |
| 387 | // third-party DD disk controllers, but reportedly not supported by |
| 388 | // the original TI DD disk controller prototype) |
| 404 | 389 | geometry->sides = 2; |
| 405 | 390 | geometry->tracksperside = 40; |
| 406 | 391 | geometry->secspertrack = 18; |
| r9560 | r9561 | |
| 408 | 393 | break; |
| 409 | 394 | |
| 410 | 395 | case 2*80*18*256: |
| 411 | | /* 720kbytes: 18-sector-per-track 80-track DSDD (Myarc only) */ |
| 396 | // 720kbytes: 18-sector-per-track 80-track DSDD (Myarc only) |
| 412 | 397 | geometry->sides = 2; |
| 413 | 398 | geometry->tracksperside = 80; |
| 414 | 399 | geometry->secspertrack = 18; |
| r9560 | r9561 | |
| 416 | 401 | break; |
| 417 | 402 | |
| 418 | 403 | case 2*80*36*256: |
| 419 | | /* 1.44Mbytes: DSHD (Myarc only) */ |
| 404 | // 1.44Mbytes: DSHD (Myarc only) |
| 420 | 405 | geometry->sides = 2; |
| 421 | 406 | geometry->tracksperside = 80; |
| 422 | 407 | geometry->secspertrack = 36; |
| r9560 | r9561 | |
| 510 | 495 | /* Determine from the image geometry whether we have FM or MFM */ |
| 511 | 496 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 512 | 497 | |
| 513 | | /* Do we have a 40 track disk in an 80 track drive? In that case we |
| 514 | | double the "width" of the tracks. */ |
| 498 | // Do we have a 40 track disk in an 80 track drive? In that case we |
| 499 | // double the "width" of the tracks. */ |
| 515 | 500 | if (use_80_track_drives && tag->tracks<=40) |
| 516 | 501 | { |
| 517 | 502 | imgtrack = track / 2; |
| r9560 | r9561 | |
| 646 | 631 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 647 | 632 | int imgtrack = track; |
| 648 | 633 | |
| 649 | | /* Find out if we are going to write an FM or MFM track. Caution: The |
| 650 | | original TI controller is known to have a bug in the formatting |
| 651 | | routine (using a MOVB instead of a MOV instruction when setting the |
| 652 | | pointer to the track data), outputting false bytes at the |
| 653 | | beginning of the track. So we don't rely on absolute positions |
| 654 | | (neither does the controller). |
| 655 | | */ |
| 634 | // Find out if we are going to write an FM or MFM track. Note that the |
| 635 | // original TI controller is known to have a bug in the formatting |
| 636 | // routine (using a MOVB instead of a MOV instruction when setting the |
| 637 | // pointer to the track data), outputting false bytes at the |
| 638 | // beginning of the track. So we do not rely on absolute positions |
| 639 | // (and neither does the controller). |
| 656 | 640 | track_image = (UINT8*)buffer; |
| 657 | 641 | |
| 658 | 642 | if (use_80_track_drives && tag->tracks<=40) |
| r9560 | r9561 | |
| 668 | 652 | |
| 669 | 653 | current_pos = find_block(track_image, 0, 100, 0x4e, leadin); |
| 670 | 654 | |
| 671 | | /* In case of defect formats, we continue as far as possible. This |
| 672 | | may lead to sectors not being written. */ |
| 655 | // In case of defect formats, we continue as far as possible. This |
| 656 | // may lead to sectors not being written. */ |
| 673 | 657 | if (current_pos==TI99DSK_BLOCKNOTFOUND) |
| 674 | 658 | { |
| 675 | 659 | /* Not MFM, possibly FM image */ |
| r9560 | r9561 | |
| 741 | 725 | } |
| 742 | 726 | else |
| 743 | 727 | { |
| 744 | | /* else the sector head data do not match the |
| 745 | | current track and head. Ignore the sector. */ |
| 728 | // else the sector head data do not match the |
| 729 | // current track and head. Ignore the sector. |
| 746 | 730 | logerror("Wrong track: wtrack=%d, imgtrack=%d, whead=%d, imghead=%d\n",wtrack,imgtrack, whead,head); |
| 747 | 731 | } |
| 748 | 732 | } |
| r9560 | r9561 | |
| 1125 | 1109 | if (format==TI99_FM) |
| 1126 | 1110 | { |
| 1127 | 1111 | // printf("Trying FM\n"); |
| 1128 | | /* We are seeking the lead-in and pre-id gap from |
| 1129 | | position 0 to position 50. This is just to make sure that |
| 1130 | | if there are bad bytes at the beginning (original TI controller) |
| 1131 | | we will skip them.*/ |
| 1112 | // We are seeking the lead-in and pre-id gap from |
| 1113 | // position 0 to position 50. This is just to make sure that |
| 1114 | // if there are bad bytes at the beginning (original TI controller) |
| 1115 | // we will skip them. |
| 1132 | 1116 | current_pos = find_block(track, 0, 50, 0x00, 22); |
| 1133 | 1117 | if (current_pos==TI99DSK_BLOCKNOTFOUND) |
| 1134 | 1118 | { |
| r9560 | r9561 | |
| 1139 | 1123 | { |
| 1140 | 1124 | current_pos += 22; |
| 1141 | 1125 | if (track[current_pos]==0xfe /* IDAM */ && |
| 1142 | | track[current_pos+4]==0x01 /* sector length, always 256 for TI */ && |
| 1143 | | track[current_pos+24]==0xfb) /* DAM */ |
| 1126 | track[current_pos+4]==0x01 /* sector length, always 256 for TI */ && |
| 1127 | track[current_pos+24]==0xfb) /* DAM */ |
| 1144 | 1128 | { |
| 1145 | 1129 | /* We're pretty sure this is the beginning. */ |
| 1146 | 1130 | *offset = current_pos; |
| r9560 | r9561 | |
| 1176 | 1160 | { |
| 1177 | 1161 | current_pos += 10; |
| 1178 | 1162 | if (track[current_pos] == 0xa1 /* First sync */ && |
| 1179 | | track[current_pos+3] == 0xfe /* IDAM */ && |
| 1180 | | track[current_pos+44] == 0xa1 /* First sync */ && |
| 1181 | | track[current_pos+47] == 0xfb) /* DAM */ |
| 1163 | track[current_pos+3] == 0xfe /* IDAM */ && |
| 1164 | track[current_pos+44] == 0xa1 /* First sync */ && |
| 1165 | track[current_pos+47] == 0xfb) /* DAM */ |
| 1182 | 1166 | { |
| 1183 | 1167 | /* We're pretty sure this is the beginning. */ |
| 1184 | 1168 | *offset = current_pos + 3; |
| r9560 | r9561 | |
| 1246 | 1230 | if ((head < 0) || (head >= tag->heads) || (imgtrack < 0) || (imgtrack >= tag->tracks)) |
| 1247 | 1231 | return FLOPPY_ERROR_SEEKERROR; |
| 1248 | 1232 | |
| 1249 | | /* For head 0, tracks increase from 0 to tracks-1; then for head 1, |
| 1250 | | tracks also increase from 0 to tracks-1. */ |
| 1233 | // For head 0, tracks increase from 0 to tracks-1; then for head 1, |
| 1234 | // tracks also increase from 0 to tracks-1. */ |
| 1251 | 1235 | *offset = head * (tag->tracks * tag->track_size) + imgtrack * tag->track_size; |
| 1252 | 1236 | |
| 1253 | 1237 | return FLOPPY_ERROR_SUCCESS; |
| r9560 | r9561 | |
| 1274 | 1258 | |
| 1275 | 1259 | floppy_image_read(floppy, buffer, track_offset, buflen); |
| 1276 | 1260 | |
| 1277 | | /* Rebuild the CRCs. PC99 did not store the CRC but put |
| 1278 | | F7F7 in its place. |
| 1279 | | The first CRC is at position IDAM + 5 |
| 1280 | | The second CRC is at position IDAM + 0x119 (FM) or +0x12d (MFM) |
| 1281 | | All this is repeated for each sector in the track |
| 1282 | | */ |
| 1261 | // Rebuild the CRCs. PC99 did not store the CRC but put |
| 1262 | // F7F7 in its place. |
| 1263 | // The first CRC is at position IDAM + 5 |
| 1264 | // The second CRC is at position IDAM + 0x119 (FM) or +0x12d (MFM) |
| 1265 | // All this is repeated for each sector in the track |
| 1266 | |
| 1283 | 1267 | if (determine_offset(tag->format, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR) |
| 1284 | 1268 | return FLOPPY_ERROR_SEEKERROR; |
| 1285 | 1269 | |
| r9560 | r9561 | |
| 1289 | 1273 | byte = read_byte(tag->format, first_idam, track_data, i); |
| 1290 | 1274 | if (byte == TI99_IDAM) |
| 1291 | 1275 | { |
| 1292 | | /* Do we have a valid CRCs already? Then this image |
| 1293 | | already contains proper CRCs handling. Do not |
| 1294 | | recreate them. */ |
| 1276 | // Do we have a valid CRCs already? Then this image |
| 1277 | // already contains proper CRCs handling. Do not recreate them. |
| 1295 | 1278 | if (track_data[i+5] != 0xf7 || track_data[i+6] != 0xf7) |
| 1296 | 1279 | return FLOPPY_ERROR_SUCCESS; |
| 1297 | 1280 | |
| r9560 | r9561 | |
| 1349 | 1332 | if (err) |
| 1350 | 1333 | return err; |
| 1351 | 1334 | |
| 1352 | | /* According to the TDF format, we don't need the CRC but replace it |
| 1353 | | with F7F7. For now we keep it and see whether PC99 can cope with |
| 1354 | | that. (Otherwise we would have to copy the const buffer). */ |
| 1335 | // According to the TDF format, we don't need the CRC but replace it |
| 1336 | // with F7F7. For now we keep it and see whether PC99 can cope with |
| 1337 | // that. (Otherwise we would have to copy the const buffer). */ |
| 1355 | 1338 | floppy_image_write(floppy, buffer, offset + track_offset, buflen); |
| 1356 | 1339 | return FLOPPY_ERROR_SUCCESS; |
| 1357 | 1340 | } |
| r9560 | r9561 | |
| 1497 | 1480 | |
| 1498 | 1481 | floppy_image_write(floppy, buffer, offset, SECTOR_SIZE); |
| 1499 | 1482 | |
| 1500 | | /* Recalculate CRC */ |
| 1501 | | crc = ccitt_crc16(0xffff, (UINT8*)buffer, SECTOR_SIZE); |
| 1483 | // Recalculate CRC. We init the CRC with bf84 (DAM fb is |
| 1484 | // already included; would be ffff without) |
| 1485 | crc = ccitt_crc16(0xbf84, (UINT8*)buffer, SECTOR_SIZE); |
| 1502 | 1486 | crc_field[0] = (crc>>8) & 0xff; |
| 1503 | 1487 | crc_field[1] = (crc & 0xff); |
| 1504 | 1488 | floppy_image_write(floppy, crc_field, offset+SECTOR_SIZE, 2); |
| r9560 | r9561 | |
| 1597 | 1581 | /* Write the sector data at that position. */ |
| 1598 | 1582 | floppy_image_write(floppy, buffer, offset, SECTOR_SIZE); |
| 1599 | 1583 | |
| 1600 | | /* Recalculate CRC */ |
| 1601 | | crc = ccitt_crc16(0xffff, (UINT8*)buffer, SECTOR_SIZE); |
| 1584 | // Recalculate CRC. We init the CRC with bf84 (DAM fb is |
| 1585 | // already included; would be ffff without) |
| 1586 | crc = ccitt_crc16(0xbf84, (UINT8*)buffer, SECTOR_SIZE); |
| 1602 | 1587 | crc_field[0] = (crc>>8) & 0xff; |
| 1603 | 1588 | crc_field[1] = (crc & 0xff); |
| 1604 | 1589 | floppy_image_write(floppy, crc_field, offset+SECTOR_SIZE, 2); |
| r9560 | r9561 | |
| 1780 | 1765 | if (determine_offset(TI99_FM, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR) |
| 1781 | 1766 | { |
| 1782 | 1767 | logerror("IDAM not found. Unformatted disk.\n"); |
| 1783 | | /* FM failed as well. Disk is not formatted. We assume |
| 1784 | | a format that fits into the space provided by the |
| 1785 | | file. |
| 1786 | | We only give a moderate vote in this case, so SDF |
| 1787 | | make take it. |
| 1788 | | */ |
| 1768 | |
| 1769 | // FM failed as well. Disk is not formatted. We assume |
| 1770 | // a format that fits into the space provided by the file. |
| 1771 | // We only give a moderate vote in this case, so SDF |
| 1772 | // make take it. |
| 1773 | |
| 1789 | 1774 | free(track_data); |
| 1790 | 1775 | if (size < 130120 || size > 2078720) |
| 1791 | 1776 | { |
| r9560 | r9561 | |
| 1905 | 1890 | } |
| 1906 | 1891 | logerror("Determined %d sectors\n", idamcnt); |
| 1907 | 1892 | |
| 1908 | | /* Now calculate the geometry |
| 1909 | | The track size, in theory, may change due to reformatting, |
| 1910 | | and it may also vary between tracks, but the TDF does not support |
| 1911 | | varying track lengths. So every track has the same length as track 0. |
| 1912 | | Also, we don't yet know whether the drive and the disk have the |
| 1913 | | same track count. For 80 track drives and 40 track disks, we need |
| 1914 | | double-stepping; this will be known as soon as the controller is |
| 1915 | | initialized; we need to check that in the access methods. |
| 1916 | | */ |
| 1893 | // Now calculate the geometry |
| 1894 | // The track size, in theory, may change due to reformatting, |
| 1895 | // and it may also vary between tracks, but the TDF does not support |
| 1896 | // varying track lengths. So every track has the same length as track 0. |
| 1897 | // Also, we don't yet know whether the drive and the disk have the |
| 1898 | // same track count. For 80 track drives and 40 track disks, we need |
| 1899 | // double-stepping; this will be known as soon as the controller is |
| 1900 | // initialized; we need to check that in the access methods. |
| 1917 | 1901 | |
| 1918 | 1902 | tracklength = idamcnt * totalseclen + trackadd; |
| 1919 | 1903 | /*offset = 0;*/ |
| 1920 | 1904 | |
| 1921 | | /* Read the last track. We assume that all tracks are properly |
| 1922 | | formatted; otherwise, the above calculations would already fail. |
| 1923 | | That is, the last track in the image tells us whether it is for |
| 1924 | | head 0 or for head 1. |
| 1925 | | */ |
| 1905 | // Read the last track. We assume that all tracks are properly |
| 1906 | // formatted; otherwise, the above calculations would already fail. |
| 1907 | // That is, the last track in the image tells us whether it is for |
| 1908 | // head 0 or for head 1. |
| 1926 | 1909 | |
| 1927 | 1910 | geometry->sides = 1; |
| 1928 | 1911 | floppy_image_read(floppy, track_data, size-tracklength, tracklength); |