trunk/src/lib/formats/d88_dsk.c
| r18434 | r18435 | |
| 524 | 524 | mfm_w(track_data, tpos, 8, 0xfc); |
| 525 | 525 | for(int i=0; i<50; i++) mfm_w(track_data, tpos, 8, 0x4e); |
| 526 | 526 | |
| 527 | | // Updated after reading the first header |
| 527 | // Read all sector headers to compute the available and expected size for gap3 |
| 528 | 528 | int sector_count = 1; |
| 529 | 529 | int gap3 = 84; |
| 530 | int etpos = tpos; |
| 531 | int rpos = pos; |
| 530 | 532 | for(int i=0; i<sector_count; i++) { |
| 531 | 533 | UINT8 hs[16]; |
| 532 | | io_generic_read(io, hs, pos, 16); |
| 534 | io_generic_read(io, hs, rpos, 16); |
| 533 | 535 | UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14)); |
| 534 | | io_generic_read(io, sect_data, pos+16, size); |
| 535 | | pos += 16+size; |
| 536 | | |
| 536 | rpos += 16+size; |
| 537 | 537 | if(i == 0) { |
| 538 | 538 | sector_count = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+4)); |
| 539 | 539 | if(size < 512) |
| r18434 | r18435 | |
| 541 | 541 | else |
| 542 | 542 | gap3 = form_factor == floppy_image::FF_35 ? 84 : 80; |
| 543 | 543 | } |
| 544 | etpos += (12+3+5+2+22+12+3+1+size+2)*16; |
| 545 | } |
| 546 | |
| 547 | if(etpos > cell_count) |
| 548 | throw emu_fatalerror("d88_format: Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, etpos); |
| 549 | |
| 550 | if(etpos + gap3*16*(sector_count-1) > cell_count) |
| 551 | gap3 = (cell_count - etpos) / 16 / (sector_count-1); |
| 552 | |
| 553 | // Build the track |
| 554 | for(int i=0; i<sector_count; i++) { |
| 555 | UINT8 hs[16]; |
| 556 | io_generic_read(io, hs, pos, 16); |
| 557 | UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14)); |
| 558 | io_generic_read(io, sect_data, pos+16, size); |
| 559 | pos += 16+size; |
| 560 | |
| 544 | 561 | int cpos; |
| 545 | 562 | UINT16 crc; |
| 546 | 563 | // sync and IDAM and gap 2 |
| r18434 | r18435 | |
| 569 | 586 | |
| 570 | 587 | // Gap 4b |
| 571 | 588 | |
| 572 | | if(tpos > cell_count) |
| 573 | | throw emu_fatalerror("d88_format: Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, tpos); |
| 574 | 589 | while(tpos < cell_count-15) mfm_w(track_data, tpos, 8, 0x4e); |
| 575 | 590 | raw_w(track_data, tpos, cell_count-tpos, 0x9254 >> (16+tpos-cell_count)); |
| 576 | 591 | |