Added FM encoding support to flopimg and wd17xx_dsk. [Curt Coder]

This commit is contained in:
Curt Coder 2013-01-07 18:23:45 +00:00
parent 32b4073ad9
commit 15604c6fc1
10 changed files with 198 additions and 122 deletions

View File

@ -64,23 +64,23 @@ const char *adam_format::extensions() const
// Unverified gap sizes
const adam_format::format adam_format::formats[] = {
{ /* 160K 5 1/4 inch double density single sided */
floppy_image::FF_525, floppy_image::SSDD,
floppy_image::FF_525, floppy_image::SSDD, floppy_image::MFM,
2000, 8, 40, 1, 512, {}, 1, {}, 100, 22, 84
},
{ /* 320K 5 1/4 inch double density */
floppy_image::FF_525, floppy_image::DSDD,
floppy_image::FF_525, floppy_image::DSDD, floppy_image::MFM,
2000, 8, 40, 2, 512, {}, 1, {}, 100, 22, 84
},
{ /* 640K 5 1/4 inch quad density */
floppy_image::FF_525, floppy_image::DSQD,
floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM,
2000, 8, 80, 2, 512, {}, 1, {}, 100, 22, 84
},
{ /* 720K 3 1/2 inch double density */
floppy_image::FF_35, floppy_image::DSDD,
floppy_image::FF_35, floppy_image::DSDD, floppy_image::MFM,
2000, 9, 80, 2, 512, {}, 1, {}, 100, 22, 84
},
{ /* 1440K 3 1/2 inch high density */
floppy_image::FF_35, floppy_image::DSHD,
floppy_image::FF_35, floppy_image::DSHD, floppy_image::MFM,
1000, 18, 80, 2, 512, {}, 1, {}, 100, 22, 84
},
{}

View File

@ -43,7 +43,27 @@
TODO:
- implement 70 track image detection
- implement 70 track image detection (first byte of file = 0x01 -> single sided)
- format double sided, single track density
:exp:fd:wd1770: track description
40xff 6x00
fe 4x00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 07 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0e 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 05 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0c 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 03 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0a 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 01 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 08 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0f 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 06 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0d 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 04 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 0b 00 f7 17x00 fb 128x00 f7 16x00
fe 2x00 02 00 f7 17x00 fb 128x00 f7 17x00
fe 2x00 09 00 f7 17x00 fb 128x00 f7 3476x00
*/
@ -71,103 +91,19 @@ const char *comx35_format::extensions() const
// Unverified gap sizes
const comx35_format::format comx35_format::formats[] = {
{ // 70K 5 1/4 inch single density single sided 35 tracks
floppy_image::FF_525, floppy_image::SSSD,
2000, 16, 35, 1, 128, {}, 0, {}, 100, 22, 84
{ // 70K 5 1/4 inch single density, single sided, 35 tracks
floppy_image::FF_525, floppy_image::SSSD, floppy_image::FM,
4000, 16, 35, 1, 128, {}, -1, { 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 }, 40, 11, 10
},
{ // 140K 5 1/4 inch single density double sided 35 tracks
floppy_image::FF_525, floppy_image::DSSD,
2000, 16, 35, 2, 128, {}, 0, {}, 100, 22, 84
{ // 140K 5 1/4 inch single density, double sided, 35 tracks
floppy_image::FF_525, floppy_image::DSSD, floppy_image::FM,
4000, 16, 35, 2, 128, {}, -1, { 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 }, 40, 11, 10
},
/*{ // 140K 5 1/4 inch quad density single sided 70 tracks
floppy_image::FF_525, floppy_image::SSQD,
2000, 16, 70, 1, 128, {}, 0, {}, 100, 22, 84
/*{ // 140K 5 1/4 inch single density, double track density, single sided, 70 tracks
floppy_image::FF_525, floppy_image::SSQD, floppy_image::FM,
4000, 16, 70, 1, 128, {}, -1, { 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 }, 40, 11, 10
},*/
{}
};
const floppy_format_type FLOPPY_COMX35_FORMAT = &floppy_image_format_creator<comx35_format>;
#ifdef UNUSED_CODE
/*********************************************************************
formats/comx35_dsk.c
COMX35 disk images
*********************************************************************/
#include "formats/comx35_dsk.h"
#include "formats/basicdsk.h"
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
FLOPPY_IDENTIFY( comx35_dsk_identify )
-------------------------------------------------*/
static FLOPPY_IDENTIFY( comx35_dsk_identify )
{
*vote = ((floppy_image_size(floppy) == (35*1*16*128)) || (floppy_image_size(floppy) == (35*2*16*128))) ? 100 : 0;
return FLOPPY_ERROR_SUCCESS;
}
/*-------------------------------------------------
FLOPPY_CONSTRUCT( comx35_dsk_construct )
-------------------------------------------------*/
static FLOPPY_CONSTRUCT( comx35_dsk_construct )
{
UINT8 header[1];
int heads = 1;
int cylinders = 35;
switch (floppy_image_size(floppy))
{
case 35*1*16*128:
heads = 1;
cylinders = 35;
break;
case 35*2*16*128:
floppy_image_read(floppy, header, 0x12, 1);
if (header[0] == 0x01)
{
heads = 1;
cylinders = 70;
}
else
{
heads = 2;
cylinders = 35;
}
break;
}
struct basicdsk_geometry geometry;
memset(&geometry, 0, sizeof(geometry));
geometry.heads = heads;
geometry.first_sector_id = 0;
geometry.sector_length = 128;
geometry.tracks = cylinders;
geometry.sectors = 16;
return basicdsk_construct(floppy, &geometry);
}
/*-------------------------------------------------
FLOPPY_OPTIONS( comx35 )
-------------------------------------------------*/
LEGACY_FLOPPY_OPTIONS_START( comx35 )
LEGACY_FLOPPY_OPTION( comx35, "img", "COMX35 floppy disk image", comx35_dsk_identify, comx35_dsk_construct, NULL, NULL )
LEGACY_FLOPPY_OPTIONS_END
#endif

View File

@ -129,7 +129,7 @@ const char *d81_format::extensions() const
// Unverified gap sizes
const d81_format::format d81_format::formats[] = {
{
floppy_image::FF_35, floppy_image::DSDD,
floppy_image::FF_35, floppy_image::DSDD, floppy_image::MFM,
2000, 10, 80, 2, 512, {}, 1, {}, 32, 22, 35
},
{}

View File

@ -1102,6 +1102,7 @@ bool floppy_image_format_t::extension_matches(const char *file_name) const
bool floppy_image_format_t::type_no_data(int type) const
{
return type == CRC_CCITT_START ||
type == CRC_CCITT_FM_START ||
type == CRC_AMIGA_START ||
type == CRC_MACHEAD_START ||
type == CRC_END ||
@ -1115,7 +1116,7 @@ bool floppy_image_format_t::type_data_mfm(int type, int p1, const gen_crc_info *
return !type_no_data(type) &&
type != RAW &&
type != RAWBITS &&
(type != CRC || (crcs[p1].type != CRC_CCITT && crcs[p1].type != CRC_AMIGA));
(type != CRC || (crcs[p1].type != CRC_CCITT && crcs[p1].type != CRC_CCITT_FM && crcs[p1].type != CRC_AMIGA));
}
void floppy_image_format_t::collect_crcs(const desc_e *desc, gen_crc_info *crcs)
@ -1129,6 +1130,9 @@ void floppy_image_format_t::collect_crcs(const desc_e *desc, gen_crc_info *crcs)
case CRC_CCITT_START:
crcs[desc[i].p1].type = CRC_CCITT;
break;
case CRC_CCITT_FM_START:
crcs[desc[i].p1].type = CRC_CCITT_FM;
break;
case CRC_AMIGA_START:
crcs[desc[i].p1].type = CRC_AMIGA;
break;
@ -1149,6 +1153,7 @@ int floppy_image_format_t::crc_cells_size(int type) const
{
switch(type) {
case CRC_CCITT: return 32;
case CRC_CCITT_FM: return 32;
case CRC_AMIGA: return 64;
case CRC_MACHEAD: return 8;
default: return 0;
@ -1242,6 +1247,12 @@ void floppy_image_format_t::fixup_crc_ccitt(UINT32 *buffer, const gen_crc_info *
mfm_w(buffer, offset, 16, calc_crc_ccitt(buffer, crc->start, crc->end));
}
void floppy_image_format_t::fixup_crc_ccitt_fm(UINT32 *buffer, const gen_crc_info *crc)
{
int offset = crc->write;
fm_w(buffer, offset, 16, calc_crc_ccitt(buffer, crc->start, crc->end));
}
void floppy_image_format_t::fixup_crc_machead(UINT32 *buffer, const gen_crc_info *crc)
{
UINT8 v = 0;
@ -1258,6 +1269,7 @@ void floppy_image_format_t::fixup_crcs(UINT32 *buffer, gen_crc_info *crcs)
switch(crcs[i].type) {
case CRC_AMIGA: fixup_crc_amiga(buffer, crcs+i); break;
case CRC_CCITT: fixup_crc_ccitt(buffer, crcs+i); break;
case CRC_CCITT_FM: fixup_crc_ccitt_fm(buffer, crcs+i); break;
case CRC_MACHEAD: fixup_crc_machead(buffer, crcs+i); break;
}
if(crcs[i].fixup_mfm_clock) {
@ -1339,6 +1351,11 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
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) {
case FM:
for(int i=0; i<desc[index].p2; i++)
fm_w(buffer, offset, 8, desc[index].p1);
break;
case MFM:
for(int i=0; i<desc[index].p2; i++)
mfm_w(buffer, offset, 8, desc[index].p1);
@ -1361,6 +1378,10 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
mfm_w(buffer, offset, 8, track);
break;
case TRACK_ID_FM:
fm_w(buffer, offset, 8, track);
break;
case TRACK_ID_GCR6:
raw_w(buffer, offset, 8, gcr6fw_tb[track & 0x3f]);
break;
@ -1369,6 +1390,10 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
mfm_w(buffer, offset, 8, head);
break;
case HEAD_ID_FM:
fm_w(buffer, offset, 8, head);
break;
case HEAD_ID_SWAP:
mfm_w(buffer, offset, 8, !head);
break;
@ -1381,6 +1406,10 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
mfm_w(buffer, offset, 8, sect[sector_idx].sector_id);
break;
case SECTOR_ID_FM:
fm_w(buffer, offset, 8, sect[sector_idx].sector_id);
break;
case SECTOR_ID_GCR6:
raw_w(buffer, offset, 8, gcr6fw_tb[sect[sector_idx].sector_id]);
break;
@ -1393,6 +1422,14 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
break;
}
case SIZE_ID_FM: {
int size = sect[sector_idx].size;
int id;
for(id = 0; size > 128; size >>=1, id++);
fm_w(buffer, offset, 8, id);
break;
}
case SECTOR_INFO_GCR6:
raw_w(buffer, offset, 8, gcr6fw_tb[sect[sector_idx].sector_info]);
break;
@ -1446,6 +1483,7 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
case CRC_AMIGA_START:
case CRC_CCITT_START:
case CRC_CCITT_FM_START:
case CRC_MACHEAD_START:
crcs[desc[index].p1].start = offset;
break;
@ -1466,6 +1504,13 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he
break;
}
case SECTOR_DATA_FM: {
const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx);
for(int i=0; i != csect->size; i++)
fm_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_idx);
for(int i=0; i != csect->size; i++)

View File

@ -301,18 +301,23 @@ protected:
//! Opcodes of the format description language used by generate_track()
enum {
END, //!< End of description
FM, //!< One byte in p1 to be fm-encoded, msb first, repeated p2 times
MFM, //!< One byte in p1 to be mfm-encoded, msb first, repeated p2 times
MFMBITS, //!< A value of p2 bits in p1 to be mfm-encoded, msb first
RAW, //!< One 16 bits word in p1 to be written raw, msb first, repeated p2 times
RAWBITS, //!< A value of p2 bits in p1 to be copied as-is, msb first
TRACK_ID, //!< Track id byte, mfm-encoded
TRACK_ID_FM, //!< Track id byte, fm-encoded
TRACK_ID_GCR6, //!< Track id low 6 bits, gcr6-encoded
HEAD_ID, //!< Head id byte, mfm-encoded
HEAD_ID_FM, //!< Head id byte, fm-encoded
HEAD_ID_SWAP, //!< Head id byte swapped (0->1, 1->0), mfm-encoded
TRACK_HEAD_ID_GCR6, //!< Track id 7th bit + head, gc6-encoded
SECTOR_ID, //!< Sector id byte, mfm-encoded
SECTOR_ID_FM, //!< Sector id byte, fm-encoded
SECTOR_ID_GCR6, //!< Sector id byte, gcr6-encoded
SIZE_ID, //!< Sector size code on one byte [log2(size/128)], mfm-encoded
SIZE_ID_FM, //!< Sector size code on one byte [log2(size/128)], fm-encoded
SECTOR_INFO_GCR6, //!< Sector info byte, gcr6-encoded
OFFSET_ID_O, //!< Offset (track*2+head) byte, odd bits, mfm-encoded
OFFSET_ID_E, //!< Offset (track*2+head) byte, even bits, mfm-encoded
@ -322,11 +327,13 @@ protected:
REMAIN_E, //!< Remaining sector count, even bits, mfm-encoded, total sector count in p1
SECTOR_DATA, //!< Sector data to mfm-encode, which in p1, -1 for the current one per the sector id
SECTOR_DATA_FM, //!< Sector data to fm-encode, which in p1, -1 for the current one per the sector id
SECTOR_DATA_O, //!< Sector data to mfm-encode, odd bits only, which in p1, -1 for the current one per the sector id
SECTOR_DATA_E, //!< Sector data to mfm-encode, even bits only, which in p1, -1 for the current one per the sector id
SECTOR_DATA_MAC, //!< Transformed sector data + checksum, mac style, id in p1, -1 for the current one per the sector id
CRC_CCITT_START, //!< Start a CCITT CRC calculation, with the usual x^16 + x^12 + x^5 + 1 (11021) polynomial, p1 = crc id
CRC_CCITT_FM_START, //!< Start a CCITT CRC calculation, with the usual x^16 + x^12 + x^5 + 1 (11021) polynomial, p1 = crc id
CRC_AMIGA_START, //!< Start an amiga checksum calculation, p1 = crc id
CRC_MACHEAD_START, //!< Start of the mac gcr6 sector header checksum calculation (xor of pre-encode 6-bits values, gcr6-encoded)
CRC_END, //!< End the checksum, p1 = crc id
@ -542,7 +549,7 @@ protected:
void gcr6_decode(UINT8 e0, UINT8 e1, UINT8 e2, UINT8 e3, UINT8 &va, UINT8 &vb, UINT8 &vc);
private:
enum { CRC_NONE, CRC_AMIGA, CRC_CCITT, CRC_MACHEAD };
enum { CRC_NONE, CRC_AMIGA, CRC_CCITT, CRC_CCITT_FM, CRC_MACHEAD };
enum { MAX_CRC_COUNT = 64 };
//! Holds data used internally for generating CRCs.
@ -560,6 +567,7 @@ private:
int crc_cells_size(int type) const;
void fixup_crc_amiga(UINT32 *buffer, const gen_crc_info *crc);
void fixup_crc_ccitt(UINT32 *buffer, const gen_crc_info *crc);
void fixup_crc_ccitt_fm(UINT32 *buffer, const gen_crc_info *crc);
void fixup_crc_machead(UINT32 *buffer, const gen_crc_info *crc);
void fixup_crcs(UINT32 *buffer, gen_crc_info *crcs);
void collect_crcs(const desc_e *desc, gen_crc_info *crcs);
@ -651,6 +659,13 @@ public:
DSED = 0x44455344, //!< "DSED", Double-sided extra-density (2880K)
};
//! Encodings
enum {
FM = 0x2020464D, //!< " FM", frequency modulation
MFM = 0x204D464D, //!< " MFM", modified frequency modulation
M2FM = 0x4D32464D, //!< "M2FM", modified modified frequency modulation
};
// construction/destruction

View File

@ -65,11 +65,11 @@ const char *smx_format::extensions() const
const smx_format::format smx_format::formats[] =
{
{ // Specialist MX/Orion/B2M disk image
floppy_image::FF_525, floppy_image::DSQD,
floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM,
2000, 5, 80, 2, 1024, {}, 1, {}, 100, 22, 20
},
{ // Lucksian Key Orion disk image
floppy_image::FF_525, floppy_image::DSQD,
floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM,
2000, 9, 80, 2, 512, {}, 1, {}, 100, 22, 20
},
{}

View File

@ -65,19 +65,19 @@ const char *tiki100_format::extensions() const
// double sided disks have t0s0,t0s1,t1s0,t1s1... format
const tiki100_format::format tiki100_format::formats[] = {
{ // 90K 5 1/4 inch single density single sided
floppy_image::FF_525, floppy_image::SSSD,
2000, 18, 40, 1, 128, {}, 1, {}, 80, 22, 20
floppy_image::FF_525, floppy_image::SSSD, floppy_image::FM,
4000, 18, 40, 1, 128, {}, 1, {}, 80, 22, 20
},
{ // 200K 5 1/4 inch double density single sided
floppy_image::FF_525, floppy_image::SSDD,
floppy_image::FF_525, floppy_image::SSDD, floppy_image::MFM,
2000, 10, 40, 1, 512, {}, -1, { 1,6,2,7,3,8,4,9,5,10 }, 80, 22, 20
},
{ // 400K 5 1/4 inch double density
floppy_image::FF_525, floppy_image::DSDD,
floppy_image::FF_525, floppy_image::DSDD, floppy_image::MFM,
2000, 10, 40, 2, 512, {}, -1, { 1,6,2,7,3,8,4,9,5,10 }, 80, 22, 20
},
{ // 800K 5 1/4 inch quad density
floppy_image::FF_525, floppy_image::DSQD,
floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM,
2000, 10, 80, 2, 512, {}, -1, { 1,6,2,7,3,8,4,9,5,10 }, 80, 22, 20
},
{}

View File

@ -65,11 +65,11 @@ const char *tvc_format::extensions() const
const tvc_format::format tvc_format::formats[] =
{
{ // 720K 5.25 inch
floppy_image::FF_525, floppy_image::DSQD,
floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM,
2000, 9, 80, 2, 512, {}, 1, {}, 100, 22, 20
},
{ // 360K 5.25 inch
floppy_image::FF_525, floppy_image::SSQD,
floppy_image::FF_525, floppy_image::SSQD, floppy_image::MFM,
2000, 9, 80, 1, 512, {}, 1, {}, 100, 22, 20
},
{}

View File

@ -106,15 +106,51 @@ void wd177x_format::build_sector_description(const format &f, UINT8 *sectdata, d
}
}
bool wd177x_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
floppy_image_format_t::desc_e* wd177x_format::get_desc_fm(const format &f, int &current_size)
{
int type = find_size(io, form_factor);
if(type == -1)
return false;
static floppy_image_format_t::desc_e desc[25] = {
/* 00 */ { FM, 0xff, f.gap_1 },
/* 01 */ { SECTOR_LOOP_START, 0, f.sector_count-1 },
/* 02 */ { FM, 0x00, 6 },
/* 03 */ { CRC_CCITT_FM_START, 1 },
/* 04 */ { RAW, 0x4489, 0 }, // TODO remove
/* 05 */ { FM, 0xfe, 1 },
/* 06 */ { TRACK_ID_FM },
/* 07 */ { HEAD_ID_FM },
/* 08 */ { SECTOR_ID_FM },
/* 09 */ { SIZE_ID_FM },
/* 10 */ { CRC_END, 1 },
/* 11 */ { CRC, 1 },
/* 12 */ { FM, 0xff, f.gap_2 },
/* 13 */ { FM, 0x00, 6 },
/* 14 */ { CRC_CCITT_FM_START, 2 },
/* 15 */ { RAW, 0x4489, 0 }, // TODO remove
/* 16 */ { FM, 0xfb, 1 },
/* 17 */ { SECTOR_DATA_FM, -1 },
/* 18 */ { CRC_END, 2 },
/* 19 */ { CRC, 2 },
/* 20 */ { FM, 0xff, f.gap_3 },
/* 21 */ { SECTOR_LOOP_END },
/* 22 */ { FM, 0x00, 0 },
/* 23 */ { RAWBITS, 0x9254, 0 },
/* 24 */ { END }
};
const format &f = formats[type];
current_size = f.gap_1*16;
if(f.sector_base_size)
current_size += f.sector_base_size * f.sector_count * 16;
else {
for(int j=0; j != f.sector_count; j++)
current_size += f.per_sector_size[j] * 16;
}
current_size += (6+1+4+2+f.gap_2+6+1+2+f.gap_3) * f.sector_count * 16;
floppy_image_format_t::desc_e desc[] = {
return desc;
}
floppy_image_format_t::desc_e* wd177x_format::get_desc_mfm(const format &f, int &current_size)
{
static floppy_image_format_t::desc_e desc[25] = {
/* 00 */ { MFM, 0x4e, f.gap_1 },
/* 01 */ { SECTOR_LOOP_START, 0, f.sector_count-1 },
/* 02 */ { MFM, 0x00, 12 },
@ -142,7 +178,7 @@ bool wd177x_format::load(io_generic *io, UINT32 form_factor, floppy_image *image
/* 24 */ { END }
};
int current_size = f.gap_1*16;
current_size = f.gap_1*16;
if(f.sector_base_size)
current_size += f.sector_base_size * f.sector_count * 16;
else {
@ -151,6 +187,30 @@ bool wd177x_format::load(io_generic *io, UINT32 form_factor, floppy_image *image
}
current_size += (12+3+1+4+2+f.gap_2+12+3+1+2+f.gap_3) * f.sector_count * 16;
return desc;
}
bool wd177x_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
{
int type = find_size(io, form_factor);
if(type == -1)
return false;
const format &f = formats[type];
floppy_image_format_t::desc_e *desc;
int current_size;
switch (f.encoding)
{
case floppy_image::FM:
desc = get_desc_fm(f, current_size);
break;
case floppy_image::MFM:
default:
desc = get_desc_mfm(f, current_size);
break;
}
int total_size = 200000000/f.cell_size;
int remaining_size = total_size - current_size;
if(remaining_size < 0)
@ -308,7 +368,16 @@ void wd177x_format::check_compatibility(floppy_image *image, int *candidates, in
// Extract the sectors
generate_bitstream_from_track(0, 0, formats[candidates[0]].cell_size, bitstream, track_size, image);
extract_sectors_from_bitstream_mfm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
switch (formats[candidates[0]].encoding)
{
case floppy_image::FM:
extract_sectors_from_bitstream_fm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
break;
case floppy_image::MFM:
extract_sectors_from_bitstream_mfm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
break;
}
// Check compatibility with every candidate, copy in-place
int *ok_cands = candidates;
@ -343,7 +412,6 @@ void wd177x_format::check_compatibility(floppy_image *image, int *candidates, in
candidates_count = ok_cands - candidates;
}
void wd177x_format::extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head)
{
UINT8 bitstream[500000/8];
@ -353,7 +421,16 @@ void wd177x_format::extract_sectors(floppy_image *image, const format &f, desc_s
// Extract the sectors
generate_bitstream_from_track(track, head, f.cell_size, bitstream, track_size, image);
extract_sectors_from_bitstream_mfm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
switch (f.encoding)
{
case floppy_image::FM:
extract_sectors_from_bitstream_fm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
break;
case floppy_image::MFM:
extract_sectors_from_bitstream_mfm_pc(bitstream, track_size, sectors, sectdata, sizeof(sectdata));
break;
}
for(int i=0; i<f.sector_count; i++) {
desc_s &ds = sdesc[i];

View File

@ -17,6 +17,7 @@ public:
struct format {
UINT32 form_factor; // See floppy_image for possible values
UINT32 variant; // See floppy_image for possible values
UINT32 encoding; // See floppy_image for possible values
int cell_size; // See floppy_image_format_t for details
int sector_count;
@ -28,7 +29,7 @@ public:
int per_sector_id[40]; // if sector_base_id is -1. If both per are used, then sector per_sector_id[i] has size per_sector_size[i]
int gap_1; // Usually around 80 - number of 4e between index and first IDAM sync
int gap_2; // 22 for <=1.44Mb, 41 for 2.88Mb - number of 4e between sector header and data sync
int gap_3; // Usually 84 - number of 4e between sector crc and next IDAM
int gap_3; // Usually 24 - number of 4e between sector crc and next IDAM
};
// End the array with {}
@ -41,6 +42,8 @@ public:
protected:
const format *formats;
floppy_image_format_t::desc_e* get_desc_fm(const format &f, int &current_size);
floppy_image_format_t::desc_e* get_desc_mfm(const format &f, int &current_size);
int find_size(io_generic *io, UINT32 form_factor);
int compute_track_size(const format &f) const;
void build_sector_description(const format &d, UINT8 *sectdata, desc_s *sectors) const;