diff options
Diffstat (limited to 'src/lib/formats/concept_dsk.cpp')
-rw-r--r-- | src/lib/formats/concept_dsk.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/src/lib/formats/concept_dsk.cpp b/src/lib/formats/concept_dsk.cpp index eea65064fc7..52950b3e57d 100644 --- a/src/lib/formats/concept_dsk.cpp +++ b/src/lib/formats/concept_dsk.cpp @@ -2,7 +2,7 @@ // copyright-holders:Olivier Galibert, R. Belmont /********************************************************************* - formats/concept_dsk.c + formats/concept_dsk.cpp Formats for Corvus Concept @@ -10,11 +10,11 @@ *********************************************************************/ -#include <assert.h> - -#include "flopimg.h" #include "formats/concept_dsk.h" +#include "ioprocs.h" + + /* 9 sectors / track, 512 bytes per sector */ const floppy_image_format_t::desc_e cc525dsdd_format::cc_9_desc[] = { { MFM, 0x4e, 80 }, @@ -52,105 +52,104 @@ cc525dsdd_format::cc525dsdd_format() { } -const char *cc525dsdd_format::name() const +const char *cc525dsdd_format::name() const noexcept { - return "img"; + return "concept"; } -const char *cc525dsdd_format::description() const +const char *cc525dsdd_format::description() const noexcept { return "Corvus Concept 5.25\" DSDD floppy disk image"; } -const char *cc525dsdd_format::extensions() const +const char *cc525dsdd_format::extensions() const noexcept { return "img"; } -bool cc525dsdd_format::supports_save() const +bool cc525dsdd_format::supports_save() const noexcept { return true; } -void cc525dsdd_format::find_size(io_generic *io, uint8_t &track_count, uint8_t &head_count, uint8_t §or_count) +void cc525dsdd_format::find_size(util::random_read &io, uint8_t &track_count, uint8_t &head_count, uint8_t §or_count) { - uint64_t size = io_generic_size(io); - track_count = 77; head_count = 2; sector_count = 9; - uint32_t expected_size = 512 * track_count*head_count*sector_count; - if (size == expected_size) - { + uint32_t const expected_size = 512 * track_count*head_count*sector_count; + + uint64_t size; + if (!io.length(size) && (size == expected_size)) return; - } track_count = head_count = sector_count = 0; } -int cc525dsdd_format::identify(io_generic *io, uint32_t form_factor) +int cc525dsdd_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); - if(track_count) - return 50; + if (track_count) + return FIFID_SIZE; + return 0; } -bool cc525dsdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image) +bool cc525dsdd_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image &image) const { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); uint8_t sectdata[10*512]; desc_s sectors[10]; - for(int i=0; i<sector_count; i++) { + for (int i=0; i<sector_count; i++) { sectors[i+1].data = sectdata + 512*i; sectors[i+1].size = 512; sectors[i+1].sector_id = i+1; } int track_size = sector_count*512; - for(int track=0; track < track_count; track++) { - for(int head=0; head < head_count; head++) { - io_generic_read(io, sectdata, (track*head_count + head)*track_size, track_size); + for (int track=0; track < track_count; track++) { + for (int head=0; head < head_count; head++) { + /*auto const [err, acutal] =*/ read_at(io, (track*head_count + head) * track_size, sectdata, track_size); // FIXME: check for errors and premature EOF generate_track(cc_9_desc, track, head, sectors, sector_count, 100000, image); } } - image->set_variant(floppy_image::DSDD); + image.set_variant(floppy_image::DSDD); return true; } -bool cc525dsdd_format::save(io_generic *io, floppy_image *image) +bool cc525dsdd_format::save(util::random_read_write &io, const std::vector<uint32_t> &variants, const floppy_image &image) const { int track_count, head_count, sector_count; get_geometry_mfm_pc(image, 2000, track_count, head_count, sector_count); - if(track_count != 77) + if (track_count != 77) track_count = 77; // Happens for a fully unformatted floppy - if(!head_count) + if (!head_count) head_count = 2; - if(sector_count != 9) + if (sector_count != 9) sector_count = 9; uint8_t sectdata[9*512]; int track_size = sector_count*512; - for(int track=0; track < track_count; track++) { - for(int head=0; head < head_count; head++) { + for (int track=0; track < track_count; track++) { + for (int head=0; head < head_count; head++) { get_track_data_mfm_pc(track, head, image, 2000, 512, sector_count, sectdata); - io_generic_write(io, sectdata, (track*head_count + head)*track_size, track_size); + /*auto const [err, actual] =*/ write_at(io, (track*head_count + head)*track_size, sectdata, track_size); // FIXME: check for errors } } return true; } -const floppy_format_type FLOPPY_CONCEPT_525DSDD_FORMAT = &floppy_image_format_creator<cc525dsdd_format>; +const cc525dsdd_format FLOPPY_CONCEPT_525DSDD_FORMAT; |