Previous 199869 Revisions Next

r18435 Thursday 11th October, 2012 at 07:37:04 UTC by O. Galibert
(mess) d88: Reduce the gap3 size from the standard value when the data otherwise won't fit [O. Galibert]
[src/lib/formats]d88_dsk.c

trunk/src/lib/formats/d88_dsk.c
r18434r18435
524524         mfm_w(track_data, tpos, 8, 0xfc);
525525         for(int i=0; i<50; i++) mfm_w(track_data, tpos, 8, 0x4e);
526526
527         // Updated after reading the first header
527         // Read all sector headers to compute the available and expected size for gap3
528528         int sector_count = 1;
529529         int gap3 = 84;
530         int etpos = tpos;
531         int rpos = pos;
530532         for(int i=0; i<sector_count; i++) {
531533            UINT8 hs[16];
532            io_generic_read(io, hs, pos, 16);
534            io_generic_read(io, hs, rpos, 16);
533535            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;
537537            if(i == 0) {
538538               sector_count = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+4));
539539               if(size < 512)
r18434r18435
541541               else
542542                  gap3 = form_factor == floppy_image::FF_35 ? 84 : 80;
543543            }
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
544561            int cpos;
545562            UINT16 crc;
546563            // sync and IDAM and gap 2
r18434r18435
569586
570587         // Gap 4b
571588
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);
574589         while(tpos < cell_count-15) mfm_w(track_data, tpos, 8, 0x4e);
575590         raw_w(track_data, tpos, cell_count-tpos, 0x9254 >> (16+tpos-cell_count));
576591

Previous 199869 Revisions Next


© 1997-2024 The MAME Team