diff options
Diffstat (limited to 'src/lib/formats/fdd_dsk.cpp')
-rw-r--r-- | src/lib/formats/fdd_dsk.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/lib/formats/fdd_dsk.cpp b/src/lib/formats/fdd_dsk.cpp index 5e34c4ad7df..7519eb593dd 100644 --- a/src/lib/formats/fdd_dsk.cpp +++ b/src/lib/formats/fdd_dsk.cpp @@ -2,7 +2,7 @@ // copyright-holders:Fabio Priuli /********************************************************************* - formats/fdd_dsk.h + formats/fdd_dsk.cpp PC98 FDD disk images @@ -31,41 +31,48 @@ *********************************************************************/ -#include <assert.h> - #include "fdd_dsk.h" +#include "ioprocs.h" + +#include "osdcomm.h" // little_endianize_int32 + +#include <cstring> + + fdd_format::fdd_format() { } -const char *fdd_format::name() const +const char *fdd_format::name() const noexcept { return "fdd"; } -const char *fdd_format::description() const +const char *fdd_format::description() const noexcept { return "FDD disk image"; } -const char *fdd_format::extensions() const +const char *fdd_format::extensions() const noexcept { return "fdd"; } -int fdd_format::identify(io_generic *io, uint32_t form_factor) +int fdd_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const { uint8_t h[7]; - io_generic_read(io, h, 0, 7); + auto const [err, actual] = read_at(io, 0, h, 7); // FIXME: should it really be reading six bytes? also check for premature EOF. + if (err) + return false; - if (strncmp((const char *)h, "VFD1.0", 6) == 0) - return 100; + if (memcmp(h, "VFD1.0", 6) == 0) + return FIFID_SIGN; return 0; } -bool fdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image) +bool fdd_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image &image) const { uint8_t hsec[0x0c]; @@ -82,11 +89,11 @@ bool fdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image) for (int track = 0; track < 160; track++) { - int curr_num_sec = 0, curr_track_size = 0; + int curr_num_sec = 0; [[maybe_unused]] int curr_track_size = 0; for (int sect = 0; sect < 26; sect++) { // read sector map for this sector - io_generic_read(io, hsec, pos, 0x0c); + /*auto const [err, actual] =*/ read_at(io, pos, hsec, 0x0c); // FIXME: check for errors and premature EOF pos += 0x0c; if (hsec[0] == 0xff) // unformatted/unused sector @@ -121,7 +128,7 @@ bool fdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image) if (sec_offs[cur_sec_map] == 0xffffffff) memset(sect_data + cur_pos, fill_vals[cur_sec_map], sector_size); else - io_generic_read(io, sect_data + cur_pos, sec_offs[cur_sec_map], sector_size); + /*auto const [err, actual] =*/ read_at(io, sec_offs[cur_sec_map], sect_data + cur_pos, sector_size); // FIXME: check for errors and premature EOF sects[i].track = tracks[cur_sec_map]; sects[i].head = heads[cur_sec_map]; @@ -140,9 +147,9 @@ bool fdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image) return true; } -bool fdd_format::supports_save() const +bool fdd_format::supports_save() const noexcept { return false; } -const floppy_format_type FLOPPY_FDD_FORMAT = &floppy_image_format_creator<fdd_format>; +const fdd_format FLOPPY_FDD_FORMAT; |