diff --git a/src/lib/formats/ami_dsk.c b/src/lib/formats/ami_dsk.c index 6eec7f1b28b..4a3b1fd4e67 100644 --- a/src/lib/formats/ami_dsk.c +++ b/src/lib/formats/ami_dsk.c @@ -49,6 +49,7 @@ bool adf_format::load(io_generic *io, floppy_image *image) for(int i=0; i<11; i++) { sectors[i].data = sectdata + 512*i; sectors[i].size = 512; + sectors[i].sector_id = i; } for(int track=0; track < 80; track++) { diff --git a/src/lib/formats/flopimg.c b/src/lib/formats/flopimg.c index 0e93287b98a..a025e84350e 100644 --- a/src/lib/formats/flopimg.c +++ b/src/lib/formats/flopimg.c @@ -1161,6 +1161,25 @@ void floppy_image_format_t::fixup_crcs(UINT8 *buffer, gen_crc_info *crcs) } } +int floppy_image_format_t::calc_sector_index(int num, int interleave, int skew, int total_sectors, int track_head) +{ + int i = 0; + int sec = 0; + // use interleave + while (i != num) + { + i++; + i += interleave; + i %= total_sectors; + sec++; + } + // use skew param + sec -= track_head * skew; + sec %= total_sectors; + if (sec < 0) sec += total_sectors; + return sec; +} + void floppy_image_format_t::generate_track(const desc_e *desc, UINT8 track, UINT8 head, const desc_s *sect, int sect_count, int track_size, floppy_image *image) { UINT8 *buffer = global_alloc_array_clear(UINT8, (track_size+7)/8); @@ -1171,9 +1190,12 @@ void floppy_image_format_t::generate_track(const desc_e *desc, UINT8 track, UINT int offset = 0; int index = 0; int sector_loop_start = 0; - int sector_id = 0; + int sector_idx = 0; + int sector_cnt = 0; int sector_limit = 0; - + int sector_interleave = 0; + int sector_skew = 0; + while(desc[index].type != END) { // printf("%d.%d.%d (%d) - %d %d\n", desc[index].type, desc[index].p1, desc[index].p2, index, offset, offset/8); switch(desc[index].type) { @@ -1204,11 +1226,11 @@ void floppy_image_format_t::generate_track(const desc_e *desc, UINT8 track, UINT break; case SECTOR_ID: - mfm_w(buffer, offset, 8, sector_id); + mfm_w(buffer, offset, 8, sect[sector_idx].sector_id); break; case SIZE_ID: { - int size = sect[sector_id].size; + int size = sect[sector_idx].size; int id; for(id = 0; size > 128; size >>=1, id++); mfm_w(buffer, offset, 8, id); @@ -1224,36 +1246,44 @@ void floppy_image_format_t::generate_track(const desc_e *desc, UINT8 track, UINT break; case SECTOR_ID_O: - mfm_half_w(buffer, offset, 7, sector_id); + mfm_half_w(buffer, offset, 7, sector_idx); break; case SECTOR_ID_E: - mfm_half_w(buffer, offset, 6, sector_id); + mfm_half_w(buffer, offset, 6, sector_idx); break; case REMAIN_O: - mfm_half_w(buffer, offset, 7, desc[index].p1 - sector_id); + mfm_half_w(buffer, offset, 7, desc[index].p1 - sector_idx); break; case REMAIN_E: - mfm_half_w(buffer, offset, 6, desc[index].p1 - sector_id); + mfm_half_w(buffer, offset, 6, desc[index].p1 - sector_idx); break; case SECTOR_LOOP_START: fixup_crcs(buffer, crcs); sector_loop_start = index; - sector_id = desc[index].p1; + sector_idx = desc[index].p1; + sector_cnt = sector_idx; sector_limit = desc[index].p2; + sector_idx = calc_sector_index(sector_cnt,sector_interleave,sector_skew,sector_limit+1,track*2 + head); break; case SECTOR_LOOP_END: fixup_crcs(buffer, crcs); - if(sector_id < sector_limit) { - sector_id++; + if(sector_cnt < sector_limit) { + sector_cnt++; + sector_idx = calc_sector_index(sector_cnt,sector_interleave,sector_skew,sector_limit+1,track*2 + head); index = sector_loop_start; } break; + case SECTOR_INTERLEAVE_SKEW: + sector_interleave = desc[index].p1; + sector_skew = desc[index].p2; + break; + case CRC_AMIGA_START: case CRC_CCITT_START: crcs[desc[index].p1].start = offset; @@ -1269,21 +1299,21 @@ void floppy_image_format_t::generate_track(const desc_e *desc, UINT8 track, UINT break; case SECTOR_DATA: { - const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_id); + const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); for(int i=0; i != csect->size; i++) mfm_w(buffer, offset, 8, csect->data[i]); break; } case SECTOR_DATA_O: { - const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_id); + const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); for(int i=0; i != csect->size; i++) mfm_half_w(buffer, offset, 7, csect->data[i]); break; } case SECTOR_DATA_E: { - const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_id); + const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); for(int i=0; i != csect->size; i++) mfm_half_w(buffer, offset, 6, csect->data[i]); break; @@ -1382,7 +1412,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_9[] = { { MFM, 0x4e, 22 }, { MFM, 0x00, 12 }, - { SECTOR_LOOP_START, 1, 9 }, + { SECTOR_LOOP_START, 0, 8 }, NORMAL_SECTOR(2), { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, @@ -1400,7 +1430,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_0[] = SECTOR_42_HEADER(1), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 10 }, + { SECTOR_LOOP_START, 0, 9 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1412,7 +1442,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_0[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_1[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 10, 10 }, + { SECTOR_LOOP_START, 9, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1422,7 +1452,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_1[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 9 }, + { SECTOR_LOOP_START, 0, 8 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1434,7 +1464,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_1[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_2[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 9, 10 }, + { SECTOR_LOOP_START, 8, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1444,7 +1474,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_2[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 8 }, + { SECTOR_LOOP_START, 0, 7 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1456,7 +1486,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_2[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_3[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 8, 10 }, + { SECTOR_LOOP_START, 7, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1466,7 +1496,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_3[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 7 }, + { SECTOR_LOOP_START, 0, 6 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1478,7 +1508,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_3[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_4[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 7, 10 }, + { SECTOR_LOOP_START, 6, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1488,7 +1518,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_4[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 6 }, + { SECTOR_LOOP_START, 0, 5 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1500,7 +1530,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_4[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_5[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 6, 10 }, + { SECTOR_LOOP_START, 5, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1510,7 +1540,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_5[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 5 }, + { SECTOR_LOOP_START, 0, 4 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1522,7 +1552,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_5[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_6[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 5, 10 }, + { SECTOR_LOOP_START, 4, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1532,7 +1562,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_6[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 4 }, + { SECTOR_LOOP_START, 0, 3 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1544,7 +1574,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_6[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_7[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 4, 10 }, + { SECTOR_LOOP_START, 3, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1554,7 +1584,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_7[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 3 }, + { SECTOR_LOOP_START, 0, 2 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1566,7 +1596,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_7[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_8[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 3, 10 }, + { SECTOR_LOOP_START, 2, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1576,7 +1606,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_8[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 2 }, + { SECTOR_LOOP_START, 0, 1 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1588,7 +1618,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_8[] = const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_9[] = { { MFM, 0x4e, 20 }, - { SECTOR_LOOP_START, 2, 10 }, + { SECTOR_LOOP_START, 1, 9 }, { MFM, 0x4e, 40 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(1), @@ -1598,7 +1628,7 @@ const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_10_9[] = SECTOR_42_HEADER(3), { MFM, 0x4e, 5 }, - { SECTOR_LOOP_START, 1, 1 }, + { SECTOR_LOOP_START, 0, 0 }, { MFM, 0x00, 12 }, NORMAL_SECTOR(4), { MFM, 0x4e, 40 }, @@ -1622,318 +1652,14 @@ const floppy_image_format_t::desc_e *const floppy_image_format_t::atari_st_fcp_1 }; -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_0[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, +const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11[] = { + { MFM, 0x4e, 1 }, + { SECTOR_INTERLEAVE_SKEW, 1, 1}, + { SECTOR_LOOP_START, 0, 10 }, { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, { MFM, 0x4e, 23 }, { END }, }; -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_1[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_2[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_3[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_4[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_5[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_6[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_7[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_8[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_9[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - -const floppy_image_format_t::desc_e floppy_image_format_t::atari_st_fcp_11_10[] = { - { MFM, 0x4e, 3 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 2, 2 }, NORMAL_SECTOR( 5), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 8, 8 }, NORMAL_SECTOR( 7), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 3, 3 }, NORMAL_SECTOR( 9), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 9, 9 }, NORMAL_SECTOR(11), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 4, 4 }, NORMAL_SECTOR(13), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 10, 10 }, NORMAL_SECTOR(15), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 5, 5 }, NORMAL_SECTOR(17), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 11, 11 }, NORMAL_SECTOR(19), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 6, 6 }, NORMAL_SECTOR(21), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 1, 1 }, NORMAL_SECTOR( 1), { SECTOR_LOOP_END }, - { MFM, 0x4e, 2 }, { MFM, 0x00, 2 }, - { SECTOR_LOOP_START, 7, 7 }, NORMAL_SECTOR( 3), { SECTOR_LOOP_END }, - { MFM, 0x4e, 23 }, - { END }, -}; - - -const floppy_image_format_t::desc_e *const floppy_image_format_t::atari_st_fcp_11[11] = { - atari_st_fcp_11_0, - atari_st_fcp_11_1, - atari_st_fcp_11_2, - atari_st_fcp_11_3, - atari_st_fcp_11_4, - atari_st_fcp_11_5, - atari_st_fcp_11_6, - atari_st_fcp_11_7, - atari_st_fcp_11_8, - atari_st_fcp_11_9, - atari_st_fcp_11_10, -}; - #undef SECTOR_42_HEADER #undef NORMAL_SECTOR @@ -1945,7 +1671,7 @@ const floppy_image_format_t::desc_e *floppy_image_format_t::atari_st_fcp_get_des case 10: return atari_st_fcp_10[(track*head_count + head) % 10]; case 11: - return atari_st_fcp_11[(track*head_count + head) % 11]; + return atari_st_fcp_11; } return 0; } diff --git a/src/lib/formats/flopimg.h b/src/lib/formats/flopimg.h index 6938ac96827..43b60ff0c3f 100644 --- a/src/lib/formats/flopimg.h +++ b/src/lib/formats/flopimg.h @@ -276,12 +276,14 @@ protected: SECTOR_LOOP_START, // Start of the per-sector loop, sector number goes from p1 to p2 inclusive SECTOR_LOOP_END, // End of the per-sector loop + SECTOR_INTERLEAVE_SKEW, // Defines interleave and skew for sector counting }; // Sector data description struct desc_s { int size; // Sector size, int bytes const UINT8 *data; // Sector data + UINT8 sector_id; // Sector ID }; @@ -312,16 +314,12 @@ protected: // faster verify and skew/interleave where appropriate static const desc_e atari_st_fcp_9[]; static const desc_e *const atari_st_fcp_10[10]; - static const desc_e *const atari_st_fcp_11[11]; + static const desc_e atari_st_fcp_11[]; static const desc_e atari_st_fcp_10_0[], atari_st_fcp_10_1[], atari_st_fcp_10_2[], atari_st_fcp_10_3[]; static const desc_e atari_st_fcp_10_4[], atari_st_fcp_10_5[], atari_st_fcp_10_6[], atari_st_fcp_10_7[]; static const desc_e atari_st_fcp_10_8[], atari_st_fcp_10_9[]; - static const desc_e atari_st_fcp_11_0[], atari_st_fcp_11_1[], atari_st_fcp_11_2[], atari_st_fcp_11_3[]; - static const desc_e atari_st_fcp_11_4[], atari_st_fcp_11_5[], atari_st_fcp_11_6[], atari_st_fcp_11_7[]; - static const desc_e atari_st_fcp_11_8[], atari_st_fcp_11_9[], atari_st_fcp_11_10[]; - static const desc_e *atari_st_fcp_get_desc(UINT8 track, UINT8 head, UINT8 head_count, UINT8 sect_count); // Amiga formats (100K cells) @@ -419,6 +417,8 @@ private: int sbit_r(const UINT8 *bitstream, int pos); int sbit_rp(const UINT8 *bitstream, int &pos, int track_size); UINT8 sbyte_mfm_r(const UINT8 *bitstream, int &pos, int track_size); + + int calc_sector_index(int num, int interleave, int skew, int total_sectors, int track_head); }; // a device_type is simply a pointer to its alloc function diff --git a/src/lib/formats/st_dsk.c b/src/lib/formats/st_dsk.c index f33e78903bc..57e935c7689 100644 --- a/src/lib/formats/st_dsk.c +++ b/src/lib/formats/st_dsk.c @@ -61,9 +61,10 @@ bool st_format::load(io_generic *io, floppy_image *image) UINT8 sectdata[11*512]; desc_s sectors[11]; - for(int i=1; i<=sector_count; i++) { - sectors[i].data = sectdata + 512*(i-1); + for(int i=0; i