(mess) d88: Reduce the gap3 size from the standard value when the data otherwise won't fit [O. Galibert]

This commit is contained in:
Olivier Galibert 2012-10-11 07:37:04 +00:00
parent 7e9a0ca0f7
commit 076063767d

View File

@ -524,16 +524,16 @@ bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
mfm_w(track_data, tpos, 8, 0xfc);
for(int i=0; i<50; i++) mfm_w(track_data, tpos, 8, 0x4e);
// Updated after reading the first header
// Read all sector headers to compute the available and expected size for gap3
int sector_count = 1;
int gap3 = 84;
int etpos = tpos;
int rpos = pos;
for(int i=0; i<sector_count; i++) {
UINT8 hs[16];
io_generic_read(io, hs, pos, 16);
io_generic_read(io, hs, rpos, 16);
UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14));
io_generic_read(io, sect_data, pos+16, size);
pos += 16+size;
rpos += 16+size;
if(i == 0) {
sector_count = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+4));
if(size < 512)
@ -541,6 +541,23 @@ bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
else
gap3 = form_factor == floppy_image::FF_35 ? 84 : 80;
}
etpos += (12+3+5+2+22+12+3+1+size+2)*16;
}
if(etpos > cell_count)
throw emu_fatalerror("d88_format: Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, etpos);
if(etpos + gap3*16*(sector_count-1) > cell_count)
gap3 = (cell_count - etpos) / 16 / (sector_count-1);
// Build the track
for(int i=0; i<sector_count; i++) {
UINT8 hs[16];
io_generic_read(io, hs, pos, 16);
UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14));
io_generic_read(io, sect_data, pos+16, size);
pos += 16+size;
int cpos;
UINT16 crc;
// sync and IDAM and gap 2
@ -569,8 +586,6 @@ bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
// Gap 4b
if(tpos > cell_count)
throw emu_fatalerror("d88_format: Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, tpos);
while(tpos < cell_count-15) mfm_w(track_data, tpos, 8, 0x4e);
raw_w(track_data, tpos, cell_count-tpos, 0x9254 >> (16+tpos-cell_count));