floppy: revisit the identify returns

This commit is contained in:
Olivier Galibert 2022-03-30 21:26:25 +02:00
parent afc735c502
commit 3728913a4e
63 changed files with 181 additions and 89 deletions

View File

@ -601,6 +601,8 @@ image_init_result floppy_image_device::call_load()
const floppy_image_format_t *best_format = nullptr;
for (const floppy_image_format_t *format : fif_list) {
int score = format->identify(*io, form_factor, variants);
if(score && format->extension_matches(filename()))
score |= floppy_image_format_t::FIFID_EXT;
if(score > best) {
best = score;
best_format = format;

View File

@ -113,7 +113,7 @@ int acorn_ssd_format::identify(util::random_read &io, uint32_t form_factor, cons
int type = find_size(io, form_factor, variants);
if (type != -1)
return 90;
return FIFID_SIZE;
return 0;
}
@ -246,7 +246,7 @@ int acorn_dsd_format::identify(util::random_read &io, uint32_t form_factor, cons
int type = find_size(io, form_factor, variants);
if (type != -1)
return 90;
return FIFID_SIZE;
return 0;
}
@ -351,7 +351,7 @@ int opus_ddos_format::identify(util::random_read &io, uint32_t form_factor, cons
int type = find_size(io, form_factor, variants);
if (type != -1)
return 90;
return FIFID_SIZE;
return 0;
}
@ -448,7 +448,7 @@ int acorn_adfs_old_format::identify(util::random_read &io, uint32_t form_factor,
int type = find_size(io, form_factor, variants);
if(type != -1)
return 100;
return FIFID_SIZE;
return 0;
}
@ -552,7 +552,7 @@ int acorn_adfs_new_format::identify(util::random_read &io, uint32_t form_factor,
int type = find_size(io, form_factor, variants);
if (type != -1)
return 100;
return FIFID_SIZE;
return 0;
}
@ -633,7 +633,7 @@ int acorn_dos_format::identify(util::random_read &io, uint32_t form_factor, cons
int type = find_size(io, form_factor, variants);
if (type != -1)
return 90;
return FIFID_SIZE;
return 0;
}
@ -695,7 +695,7 @@ int opus_ddcpm_format::identify(util::random_read &io, uint32_t form_factor, con
}
if (size == 819200 && memcmp(h, "Slogger ", 8) == 0)
return 100;
return FIFID_SIGN | FIFID_SIZE;
LOG_FORMATS("ddcpm: no match\n");
return 0;

View File

@ -35,7 +35,7 @@ int afs_format::identify(util::random_read &io, uint32_t form_factor, const std:
int type = find_size(io, form_factor, variants);
if (type != -1)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -47,7 +47,7 @@ int aim_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if (size == 2068480)
return 100;
return FIFID_SIZE;
return 0;
}

View File

@ -44,7 +44,7 @@ int adf_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if ((size == 901120) || (size == 912384) || (size == 1802240))
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -594,12 +594,81 @@ int a2_16sect_format::identify(util::random_read &io, uint32_t form_factor, cons
uint32_t expected_size = APPLE2_TRACK_COUNT * 16 * 256;
// check standard size plus some oddball sizes in our softlist
if ((size == expected_size) || (size == 35 * 16 * 256) || (size == 143403) || (size == 143363) || (size == 143358))
if ((size != expected_size) && (size != 35 * 16 * 256) && (size != 143403) && (size != 143363) && (size != 143358))
{
return 50;
return 0;
}
return 0;
uint8_t sector_data[256*2];
static const unsigned char pascal_block1[4] = { 0x08, 0xa5, 0x0f, 0x29 };
static const unsigned char pascal2_block1[4] = { 0xff, 0xa2, 0x00, 0x8e };
static const unsigned char dos33_block1[4] = { 0xa2, 0x02, 0x8e, 0x52 };
static const unsigned char sos_block1[4] = { 0xc9, 0x20, 0xf0, 0x3e };
static const unsigned char a3a2emul_block1[6] = { 0x8d, 0xd0, 0x03, 0x4c, 0xc7, 0xa4 };
static const unsigned char cpm22_block1[8] = { 0xa2, 0x55, 0xa9, 0x00, 0x9d, 0x00, 0x0d, 0xca };
static const unsigned char subnod_block1[8] = { 0x63, 0xaa, 0xf0, 0x76, 0x8d, 0x63, 0xaa, 0x8e };
size_t actual;
io.read_at(0, sector_data, 256*2, actual);
bool prodos_order = false;
// check ProDOS boot block
if (!memcmp("PRODOS", &sector_data[0x103], 6))
{
prodos_order = true;
} // check for alternate version ProDOS boot block
if (!memcmp("PRODOS", &sector_data[0x121], 6))
{
prodos_order = true;
} // check for ProDOS order SOS disk
else if (!memcmp(sos_block1, &sector_data[0x100], 4))
{
prodos_order = true;
} // check for Apple III A2 emulator disk in ProDOS order
else if (!memcmp(a3a2emul_block1, &sector_data[0x100], 6))
{
prodos_order = true;
} // check for PCPI Applicard software in ProDOS order
else if (!memcmp("COPYRIGHT (C) 1979, DIGITAL RESEARCH", &sector_data[0x118], 36))
{
prodos_order = true;
} // check Apple II Pascal
else if (!memcmp("SYSTEM.APPLE", &sector_data[0xd7], 12))
{
// Pascal discs can still be DOS order.
// Check for the second half of the boot code at 0x100
// (which means ProDOS order)
if (!memcmp(pascal_block1, &sector_data[0x100], 4))
{
prodos_order = true;
}
} // check for DOS 3.3 disks in ProDOS order
else if (!memcmp(dos33_block1, &sector_data[0x100], 4))
{
prodos_order = true;
} // check for a later version of the Pascal boot block
else if (!memcmp(pascal2_block1, &sector_data[0x100], 4))
{
prodos_order = true;
} // check for CP/M disks in ProDOS order
else if (!memcmp(cpm22_block1, &sector_data[0x100], 8))
{
prodos_order = true;
} // check for subnodule disk
else if (!memcmp(subnod_block1, &sector_data[0x100], 8))
{
prodos_order = true;
} // check for ProDOS 2.5's new boot block
else if (!memcmp("PRODOS", &sector_data[0x3a], 6))
{
prodos_order = true;
}
else if (!memcmp("PRODOS", &sector_data[0x40], 6))
{
prodos_order = true;
}
return FIFID_SIZE | (m_prodos_order == prodos_order ? FIFID_HINT : 0);
}
bool a2_16sect_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const
@ -984,7 +1053,7 @@ int a2_rwts18_format::identify(util::random_read &io, uint32_t form_factor, cons
if(io.length(size))
return 0;
uint32_t const expected_size = APPLE2_TRACK_COUNT * 16 * 256;
return size == expected_size;
return size == expected_size ? FIFID_SIZE : 0;
}
bool a2_rwts18_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const
@ -1465,7 +1534,7 @@ int a2_edd_format::identify(util::random_read &io, uint32_t form_factor, const s
uint64_t size;
if (io.length(size))
return 0;
return ((size == 2244608) || (size == 2310144)) ? 50 : 0;
return ((size == 2244608) || (size == 2310144)) ? FIFID_SIZE : 0;
}
uint8_t a2_edd_format::pick(const uint8_t *data, int pos)
@ -1592,8 +1661,8 @@ int a2_woz_format::identify(util::random_read &io, uint32_t form_factor, const s
uint8_t header[8];
size_t actual;
io.read_at(0, header, 8, actual);
if (!memcmp(header, signature, 8)) return 100;
if (!memcmp(header, signature2, 8)) return 100;
if (!memcmp(header, signature, 8)) return FIFID_SIGN;
if (!memcmp(header, signature2, 8)) return FIFID_SIGN;
return 0;
}
@ -1898,7 +1967,7 @@ int a2_nib_format::identify(util::random_read &io, uint32_t form_factor, const s
return 0;
if (size == expected_size_35t || size == expected_size_40t)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -1258,7 +1258,7 @@ int dc42_format::identify(util::random_read &io, uint32_t form_factor, const std
return 0;
}
return (size == 0x54+tsize+dsize && h[0] < 64 && h[0x52] == 1 && h[0x53] == 0) ? 100 : 0;
return (size == 0x54+tsize+dsize && h[0] < 64 && h[0x52] == 1 && h[0x53] == 0) ? FIFID_STRUCT|FIFID_STRUCT : 0;
}
bool dc42_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const
@ -1448,7 +1448,7 @@ int apple_gcr_format::identify(util::random_read &io, uint32_t form_factor, cons
return 0;
if(size == 409600 || (size == 819200 && (variants.empty() || has_variant(variants, floppy_image::DSDD))))
return 50;
return FIFID_SIZE;
return 0;
}
@ -1557,13 +1557,13 @@ int apple_2mg_format::identify(util::random_read &io, uint32_t form_factor, cons
io.read_at(0, signature, 4, actual);
if (!strncmp(reinterpret_cast<char *>(signature), "2IMG", 4))
{
return 100;
return FIFID_SIGN;
}
// Bernie ][ The Rescue wrote 2MGs with the signature byte-flipped, other fields are valid
if (!strncmp(reinterpret_cast<char *>(signature), "GMI2", 4))
{
return 100;
return FIFID_SIGN;
}
return 0;

View File

@ -96,7 +96,7 @@ const char *apd_format::extensions() const
int apd_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const
{
uint64_t size;
if (io.length(size))
if (io.length(size) || !size)
return 0;
std::vector<uint8_t> img(size);
@ -129,7 +129,7 @@ int apd_format::identify(util::random_read &io, uint32_t form_factor, const std:
}
if (!memcmp(&img[0], APD_HEADER, sizeof(APD_HEADER))) {
return 100;
return FIFID_SIGN;
}
return 0;

View File

@ -53,7 +53,7 @@ int ccvf_format::identify(util::random_read &io, uint32_t form_factor, const std
size_t actual;
io.read_at(0, h, 36, actual);
if (!memcmp(h, "Compucolor Virtual Floppy Disk Image", 36))
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -93,7 +93,7 @@ int cc525dsdd_format::identify(util::random_read &io, uint32_t form_factor, cons
find_size(io, track_count, head_count, sector_count);
if (track_count)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -71,7 +71,7 @@ int mgt_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if(/*size == 737280 || */ size == 819200)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -261,7 +261,7 @@ int cqm_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 3, actual);
if (h[0] == 'C' && h[1] == 'Q' && h[2] == 0x14)
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -107,7 +107,7 @@ int d64_format::identify(util::random_read &io, uint32_t form_factor, const std:
const int type = find_size(io, form_factor);
if (type != -1)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -426,7 +426,7 @@ int d88_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 32, actual);
if((little_endianize_int32(*(uint32_t *)(h+0x1c)) == size) &&
(h[0x1b] == 0x00 || h[0x1b] == 0x10 || h[0x1b] == 0x20 || h[0x1b] == 0x30 || h[0x1b] == 0x40))
return 100;
return FIFID_SIZE|FIFID_STRUCT;
return 0;
}

View File

@ -108,11 +108,11 @@ int dcp_format::identify(util::random_read &io, uint32_t form_factor, const std:
// in theory track map should be enough (former check), but some images have it wrong!
// hence, if this check fails, we also allow for images with all tracks and wrong track map
if (size - 0xa2 == (heads * count_tracks * spt * bps) || size - 0xa2 == (heads * tracks * spt * bps))
return 100;
return FIFID_STRUCT|FIFID_SIZE;
// for disk type 0x11 the head 0 track 0 has 26 sectors of half width, so we need to compensate calculation
if (is_hdb && (size - 0xa2 + (0x80 * 26) == (heads * count_tracks * spt * bps) || size - 0xa2 + (0x80 * 26) == (heads * tracks * spt * bps)))
return 100;
return FIFID_STRUCT|FIFID_SIZE;
return 0;
}

View File

@ -64,7 +64,7 @@ int dfi_format::identify(util::random_read &io, uint32_t form_factor, const std:
char sign[4];
size_t actual;
io.read_at(0, sign, 4, actual);
return memcmp(sign, "DFE2", 4) ? 0 : 100;
return memcmp(sign, "DFE2", 4) ? 0 : FIFID_SIGN;
}
bool dfi_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const

View File

@ -41,7 +41,7 @@ int dim_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0xab, h, 16, actual);
if(strncmp((const char *)h, "DIFC HEADER", 11) == 0)
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -45,7 +45,7 @@ int dip_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if (size == 0x134000 + 0x100)
return 100;
return FIFID_SIZE;
return 0;
}

View File

@ -76,7 +76,7 @@ int dmk_format::identify(util::random_read &io, uint32_t form_factor, const std:
if (size == header_size + heads * tracks * track_size)
{
return 70;
return FIFID_STRUCT|FIFID_SIZE;
}
return 0;

View File

@ -84,7 +84,7 @@ int ds9_format::identify(util::random_read &io, uint32_t form_factor, const std:
find_size(io, track_count, head_count, sector_count);
if (track_count)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -309,10 +309,10 @@ int dsk_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, &header, sizeof(header), actual);
if ( memcmp( header, DSK_FORMAT_HEADER, 8 ) ==0) {
return 100;
return FIFID_SIGN;
}
if ( memcmp( header, EXT_FORMAT_HEADER, 16 ) ==0) {
return 100;
return FIFID_SIGN;
}
return 0;
}

View File

@ -126,9 +126,9 @@ int dvk_mx_format::identify(util::random_read &io, uint32_t form_factor, const s
io.read_at(512, sectdata, 512, actual);
// check value in RT-11 home block. see src/tools/imgtool/modules/rt11.cpp
if (pick_integer_le(sectdata, 0724, 2) == 6)
return 100;
return FIFID_SIGN|FIFID_SIZE;
else
return 75;
return FIFID_SIZE;
}

View File

@ -93,7 +93,7 @@ int esqimg_format::identify(util::random_read &io, uint32_t form_factor, const s
find_size(io, track_count, head_count, sector_count);
if(track_count)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -98,7 +98,7 @@ int esq8img_format::identify(util::random_read &io, uint32_t form_factor, const
find_size(io, track_count, head_count, sector_count);
if(track_count)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -66,7 +66,7 @@ int fdd_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 7, actual);
if (strncmp((const char *)h, "VFD1.0", 6) == 0)
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -80,7 +80,7 @@ int flex_format::identify(util::random_read &io, uint32_t form_factor, const std
int type = find_size(io, form_factor, variants);
if (type != -1)
return 75;
return FIFID_SIZE;
return 0;
}

View File

@ -35,6 +35,18 @@ class floppy_image_format_t
public:
virtual ~floppy_image_format_t() = default;
// The result of identify is a binary or of these flags, comparison afterwards is numerical.
// If a match is incorrect (bad signature for instance), result must be 0. The non-zero
// result helps to decide how reliable the identification is, for choice classification.
enum {
FIFID_HINT = 0x01, // All other things being equal, favorise this format
FIFID_EXT = 0x02, // Extension matches one of the list (set outside of identify)
FIFID_SIZE = 0x04, // File size matches what is expected
FIFID_SIGN = 0x08, // The file signature matches
FIFID_STRUCT = 0x10, // Some file internal structure aspects have been verified
};
/*! @brief Identify an image.
The identify function tests if the image is valid
for this particular format.
@ -42,7 +54,7 @@ public:
@param form_factor Physical form factor of disk, from the enum
in floppy_image
@param variants the variants from floppy_image the drive can handle
@return 1 if image valid, 0 otherwise.
@return Binary or of FIFID flags, 0 if invalid for that format
*/
virtual int identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const = 0;

View File

@ -95,7 +95,7 @@ int fsd_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, h, 3, actual);
if (memcmp(h, "FSD", 3) == 0) {
return 100;
return FIFID_SIGN;
}
LOG_FORMATS("fsd: no match\n");
return 0;

View File

@ -38,7 +38,7 @@ int g64_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, h, 8, actual);
if (!memcmp(h, G64_FORMAT_HEADER, 8))
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -95,7 +95,7 @@ int hpi_format::identify(util::random_read &io, uint32_t form_factor, const std:
unsigned dummy_tracks;
if (((form_factor == floppy_image::FF_8) || (form_factor == floppy_image::FF_UNKNOWN)) &&
geometry_from_size(size , dummy_heads , dummy_tracks)) {
return 50;
return FIFID_SIZE;
} else {
return 0;
}

View File

@ -142,7 +142,7 @@ int hfe_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, &header, sizeof(header), actual);
if ( memcmp( header, HFE_FORMAT_HEADER, 8 ) ==0) {
return 100;
return FIFID_SIGN;
}
return 0;
}

View File

@ -67,7 +67,7 @@ int mfm_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, &header, sizeof(header), actual);
if ( memcmp( header, MFM_FORMAT_HEADER, 6 ) ==0) {
return 100;
return FIFID_SIGN;
}
return 0;
}

View File

@ -60,7 +60,7 @@ int ibmxdf_format::identify(util::random_read &io, uint32_t form_factor, const s
int type = find_size(io, form_factor, variants);
if (type != -1)
return 75;
return FIFID_SIZE;
return 0;
}

View File

@ -420,7 +420,7 @@ int imd_format::identify(util::random_read &io, uint32_t form_factor, const std:
size_t actual;
io.read_at(0, h, 4, actual);
if(!memcmp(h, "IMD ", 4))
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -52,7 +52,7 @@ int img_format::identify(util::random_read &io, uint32_t form_factor, const std:
if (((form_factor == floppy_image::FF_8) || (form_factor == floppy_image::FF_UNKNOWN)) &&
size == IMG_IMAGE_SIZE) {
return 50;
return FIFID_SIZE;
} else {
return 0;
}

View File

@ -37,7 +37,7 @@ int ipf_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 12, actual);
if(!memcmp(h, refh, 12))
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -192,8 +192,9 @@ const char *jfd_format::extensions() const
int jfd_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const
{
uint64_t size;
if (io.length(size))
if (io.length(size) || !size)
return 0;
std::vector<uint8_t> img(size);
size_t actual;
io.read_at(0, &img[0], size, actual);
@ -224,7 +225,7 @@ int jfd_format::identify(util::random_read &io, uint32_t form_factor, const std:
}
if (!memcmp(&img[0], JFD_HEADER, sizeof(JFD_HEADER))) {
return 100;
return FIFID_SIGN;
}
return 0;

View File

@ -135,7 +135,7 @@ bool jvc_format::parse_header(util::random_read &io, int &header_size, int &trac
// The JVC format has a header whose size is the size of the image modulo 256. Currently, we only
// handle up to five header bytes
uint64_t size;
if (io.length(size))
if (io.length(size) || !size)
return false;
header_size = size % 256;
uint8_t header[5];
@ -178,7 +178,7 @@ bool jvc_format::parse_header(util::random_read &io, int &header_size, int &trac
int jvc_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const
{
int header_size, tracks, heads, sectors, sector_size, sector_base_id;
return parse_header(io, header_size, tracks, heads, sectors, sector_size, sector_base_id) ? 50 : 0;
return parse_header(io, header_size, tracks, heads, sectors, sector_size, sector_base_id) ? FIFID_STRUCT|FIFID_SIZE : 0;
}
bool jvc_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const

View File

@ -50,7 +50,7 @@ int m20_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if (size == 286720)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -79,7 +79,7 @@ int mdos_format::identify(util::random_read &io, uint32_t form_factor, const std
int type = find_size(io, form_factor, variants);
if (type != -1)
return 75;
return FIFID_SIZE;
return 0;
}

View File

@ -107,7 +107,7 @@ int mfi_format::identify(util::random_read &io, uint32_t form_factor, const std:
(h.cyl_count >> RESOLUTION_SHIFT) < 3 &&
h.head_count <= 2 &&
(!form_factor || !h.form_factor || h.form_factor == form_factor))
return 100;
return FIFID_SIGN|FIFID_STRUCT;
return 0;
}

View File

@ -112,7 +112,7 @@ int nfd_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 16, actual);
if (strncmp((const char *)h, "T98FDDIMAGE.R0", 14) == 0 || strncmp((const char *)h, "T98FDDIMAGE.R1", 14) == 0)
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -35,7 +35,7 @@ int opd_format::identify(util::random_read &io, uint32_t form_factor, const std:
int const type = find_size(io, form_factor, variants);
if (type != -1)
return 90;
return FIFID_SIZE;
return 0;
}

View File

@ -54,7 +54,7 @@ int oric_dsk_format::identify(util::random_read &io, uint32_t form_factor, const
if(sides < 0 || sides > 2 || geom != 1 || size != 256+6400*sides*tracks)
return 0;
return 100;
return FIFID_SIGN|FIFID_SIZE|FIFID_STRUCT;
}
bool oric_dsk_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const
@ -138,7 +138,7 @@ int oric_jasmin_format::identify(util::random_read &io, uint32_t form_factor, co
bool const can_ds = variants.empty() || has_variant(variants, floppy_image::DSDD);
if(size == 41*17*256 || (can_ds && size == 41*17*256*2))
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -75,7 +75,7 @@ int os9_format::identify(util::random_read &io, uint32_t form_factor, const std:
int const type = find_size(io, form_factor, variants);
if (type != -1)
return 75;
return FIFID_SIZE;
return 0;
}

View File

@ -49,7 +49,7 @@ int pasti_format::identify(util::random_read &io, uint32_t form_factor, const st
if(!memcmp(h, "RSY\0\3\0", 6) &&
(1 || (h[10] >= 80 && h[10] <= 82) || (h[10] >= 160 && h[10] <= 164)))
return 100;
return FIFID_SIGN;
return 0;
}

View File

@ -51,7 +51,7 @@ int pc98fdi_format::identify(util::random_read &io, uint32_t form_factor, const
uint32_t const sides = little_endianize_int32(*(uint32_t *) (h + 0x18));
uint32_t const ntrk = little_endianize_int32(*(uint32_t *) (h + 0x1c));
if(size == hsize + psize && psize == ssize*scnt*sides*ntrk)
return 100;
return FIFID_STRUCT;
return 0;
}

View File

@ -54,7 +54,7 @@ int poly_cpm_format::identify(util::random_read &io, uint32_t form_factor, const
io.read_at(0, boot, 16, actual);
if (memcmp(boot, "\x86\xc3\xb7\x00\x00\x8e\x10\xc0\xbf\x00\x01\xbf\xe0\x60\x00\x00", 16) == 0)
{
return 100;
return FIFID_SIZE|FIFID_SIGN;
}
}

View File

@ -135,7 +135,7 @@ int rx50img_format::identify(util::random_read &io, uint32_t form_factor, const
find_size(io, track_count, head_count, sector_count);
if(track_count)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -69,7 +69,7 @@ int sdf_format::identify(util::random_read &io, uint32_t form_factor, const std:
if (size == HEADER_SIZE + heads * tracks * TOTAL_TRACK_SIZE)
{
return 100;
return FIFID_SIGN|FIFID_SIZE|FIFID_STRUCT;
}
return 0;

View File

@ -58,7 +58,7 @@ int st_format::identify(util::random_read &io, uint32_t form_factor, const std::
find_size(io, track_count, head_count, sector_count);
if(track_count)
return 50;
return FIFID_SIZE;
return 0;
}
@ -224,7 +224,7 @@ int msa_format::identify(util::random_read &io, uint32_t form_factor, const std:
(head == 0 || head == 1) &&
strack <= etrack &&
etrack < 82)
return 100;
return FIFID_SIGN | FIFID_STRUCT;
return 0;
}

View File

@ -39,7 +39,7 @@ int svi_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
if (size == 172032 || size == 346112)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -816,7 +816,7 @@ int td0_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, h, 7, actual);
if(((h[0] == 'T') && (h[1] == 'D')) || ((h[0] == 't') && (h[1] == 'd')))
{
return 100;
return FIFID_SIGN;
}
return 0;
}

View File

@ -943,7 +943,7 @@ int ti99_sdf_format::identify(util::random_read &io, uint32_t form_factor, const
case 368640: // DSDD
case 737280: // DSDD80
case 1474560: // DSQD
vote = 50;
vote = FIFID_SIZE;
break;
default:
vote = 0;
@ -961,7 +961,7 @@ int ti99_sdf_format::identify(util::random_read &io, uint32_t form_factor, const
if ((vib.id[0]=='D')&&(vib.id[1]=='S')&&(vib.id[2]=='K'))
{
LOGMASKED(LOG_INFO, "[ti99_dsk] Found formatted SDF disk medium\n");
vote = 100;
vote |= FIFID_SIGN;
}
else
{
@ -1239,7 +1239,7 @@ int ti99_tdf_format::identify(util::random_read &io, uint32_t form_factor, const
// Do we have a plausible image size? From the size alone we only give a 50 percent vote.
if (sector_count != 0)
vote = 50;
vote = FIFID_SIZE;
if (vote > 0)
{
@ -1283,7 +1283,7 @@ int ti99_tdf_format::identify(util::random_read &io, uint32_t form_factor, const
else
{
LOGMASKED(LOG_INFO, "[ti99_dsk] Image format complies with TDF\n");
vote = 100;
vote |= FIFID_STRUCT;
}
}
else LOGMASKED(LOG_INFO, "[ti99_dsk] Disk image is not a TDF image\n");

View File

@ -226,7 +226,7 @@ int jv3_format::identify(util::random_read &io, uint32_t form_factor, const std:
return 0;
}
return 80;
return FIFID_STRUCT;
}
bool jv3_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const

View File

@ -39,7 +39,7 @@ int uniflex_format::identify(util::random_read &io, uint32_t form_factor, const
int const type = find_size(io, form_factor, variants);
if (type != -1)
return 75;
return FIFID_SIZE;
return 0;
}

View File

@ -45,7 +45,7 @@ int upd765_format::identify(util::random_read &io, uint32_t form_factor, const s
int type = find_size(io, form_factor, variants);
if(type != -1)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -41,7 +41,7 @@ int vdk_format::identify(util::random_read &io, uint32_t form_factor, const std:
io.read_at(0, id, 2, actual);
if (id[0] == 'd' && id[1] == 'k')
return 50;
return FIFID_SIGN;
else
return 0;
}

View File

@ -146,7 +146,7 @@ int victor9k_format::identify(util::random_read &io, uint32_t form_factor, const
int type = find_size(io, form_factor);
if (type != -1)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -227,7 +227,7 @@ int vtech_bin_format::identify(util::random_read &io, uint32_t form_factor, cons
return 0;
if(size == 40*16*256)
return 50;
return FIFID_SIZE;
return 0;
}
@ -256,7 +256,7 @@ int vtech_dsk_format::identify(util::random_read &io, uint32_t form_factor, cons
count_sd++;
}
return count_sh >= 30*16 && count_sd >= 30*16 ? 100 : 0;
return count_sh >= 30*16 && count_sd >= 30*16 ? FIFID_STRUCT : 0;
}
bool vtech_bin_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) const

View File

@ -67,7 +67,7 @@ int wd177x_format::identify(util::random_read &io, uint32_t form_factor, const s
int const type = find_size(io, form_factor, variants);
if(type != -1)
return 50;
return FIFID_SIZE;
return 0;
}

View File

@ -139,7 +139,13 @@ static int identify(int argc, char *argv[])
bool first = true;
for(const auto &e : scores) {
printf("%-*s %c %3d - %-*s %s\n", sz, first ? argv[i] : "", first ? ':' : ' ', e.first, sz2, e.second->m_format->name(), e.second->m_format->description());
printf("%-*s %c %c%c%c%c%c - %-*s %s\n", sz, first ? argv[i] : "", first ? ':' : ' ',
e.first & 0x10 ? '+' : '.',
e.first & 0x08 ? '+' : '.',
e.first & 0x04 ? '+' : '.',
e.first & 0x02 ? '+' : '.',
e.first & 0x01 ? '+' : '.',
sz2, e.second->m_format->name(), e.second->m_format->description());
first = false;
}
}

View File

@ -246,6 +246,8 @@ std::vector<std::pair<u8, const floppy_format_info *>> image_handler::identify(c
for(const auto &e : formats.floppy_format_info_by_key) {
u8 score = e.second->m_format->identify(*io, floppy_image::FF_UNKNOWN, variants);
if(score && e.second->m_format->extension_matches(m_on_disk_path.c_str()))
score |= floppy_image_format_t::FIFID_EXT;
if(score)
res.emplace_back(std::make_pair(score, e.second));
}