mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
image_handler.cpp: Floppy fixes
- Refilter list of specific floppy formats using the known form factor and variant before trying to mount a filesystem on an image - Sort identify results by decreasing score (code already expects the best format to be first) * formats/ap_dsk35.cpp: Remove temporary hack
This commit is contained in:
parent
01a2d4ed00
commit
25976be0ac
@ -384,10 +384,6 @@ bool apple_gcr_format::load(util::random_read &io, uint32_t form_factor, const s
|
||||
|
||||
bool apple_gcr_format::save(util::random_read_write &io, const std::vector<uint32_t> &variants, const floppy_image &image) const
|
||||
{
|
||||
// HACK: don't let floptool force a square peg into a round hole
|
||||
if(image.get_form_factor() != floppy_image::FF_35)
|
||||
return false;
|
||||
|
||||
int g_tracks, g_heads;
|
||||
image.get_actual_geometry(g_tracks, g_heads);
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "multibyte.h"
|
||||
#include "strformat.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
// Format enumeration
|
||||
|
||||
@ -43,7 +45,7 @@ namespace {
|
||||
|
||||
struct fs_enum : public fs::manager_t::floppy_enumerator {
|
||||
filesystem_format *m_format;
|
||||
fs_enum(filesystem_format *format, const std::vector<u32> &variants) : fs::manager_t::floppy_enumerator(floppy_image::FF_UNKNOWN, variants), m_format(format) {}
|
||||
fs_enum(filesystem_format *format, u32 form_factor, const std::vector<u32> &variants) : fs::manager_t::floppy_enumerator(form_factor, variants), m_format(format) {}
|
||||
|
||||
virtual void add_format(const floppy_image_format_t &type, u32 image_size, const char *name, const char *description) override {
|
||||
m_format->m_floppy = true;
|
||||
@ -65,7 +67,7 @@ void formats_table::init()
|
||||
mame_formats_full_list(en);
|
||||
|
||||
for(auto &f : filesystem_formats) {
|
||||
fs_enum fen(f.get(), variants);
|
||||
fs_enum fen(f.get(), floppy_image::FF_UNKNOWN, variants);
|
||||
f->m_manager->enumerate_f(fen);
|
||||
}
|
||||
|
||||
@ -244,6 +246,9 @@ std::vector<std::pair<u8, const floppy_format_info *>> image_handler::identify(c
|
||||
res.emplace_back(std::make_pair(score, e.second));
|
||||
}
|
||||
|
||||
// Sort results by decreasing score
|
||||
std::stable_sort(res.begin(), res.end(), [](const auto &a, const auto &b) { return a.first > b.first; });
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -295,8 +300,14 @@ void image_handler::floppy_create(const floppy_create_info &format, fs::meta_dat
|
||||
|
||||
bool image_handler::floppy_mount_fs(const filesystem_format &format)
|
||||
{
|
||||
// Create a restricted copy of the format list based on the known form factor and variant
|
||||
filesystem_format fmtcopy(format.m_manager, format.m_category);
|
||||
std::vector<u32> const var(1, m_floppy_image.get_variant());
|
||||
fs_enum fen(&fmtcopy, m_floppy_image.get_form_factor(), var);
|
||||
format.m_manager->enumerate_f(fen);
|
||||
|
||||
m_floppy_fs_converter = nullptr;
|
||||
for(const auto &ci : format.m_floppy_create) {
|
||||
for(const auto &ci : fmtcopy.m_floppy_create) {
|
||||
if(ci->m_type != m_floppy_fs_converter) {
|
||||
std::vector<uint32_t> variants;
|
||||
m_floppy_fs_converter = ci->m_type;
|
||||
|
Loading…
Reference in New Issue
Block a user