From ffe3325258a13be07dc530fa82f69324df6d28d1 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Thu, 17 Jan 2013 15:32:52 +0000 Subject: [PATCH] (MESS) d64/g64 floppy modernization WIP. (nw) --- .gitattributes | 4 + src/lib/formats/d64_dsk.c | 165 ++++++++++++-------------------------- src/lib/formats/d64_dsk.h | 42 ++++------ src/lib/formats/d67_dsk.c | 86 ++++++++++++++++++++ src/lib/formats/d67_dsk.h | 34 ++++++++ src/lib/formats/d80_dsk.c | 122 ++++++++++++++++++++++++++++ src/lib/formats/d80_dsk.h | 39 +++++++++ src/lib/formats/g64_dsk.c | 51 +++++++----- src/lib/formats/g64_dsk.h | 2 +- src/lib/lib.mak | 2 + 10 files changed, 384 insertions(+), 163 deletions(-) create mode 100644 src/lib/formats/d67_dsk.c create mode 100644 src/lib/formats/d67_dsk.h create mode 100644 src/lib/formats/d80_dsk.c create mode 100644 src/lib/formats/d80_dsk.h diff --git a/.gitattributes b/.gitattributes index 416bc611c1e..b29605947b8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1866,6 +1866,10 @@ src/lib/formats/csw_cas.c svneol=native#text/plain src/lib/formats/csw_cas.h svneol=native#text/plain src/lib/formats/d64_dsk.c svneol=native#text/plain src/lib/formats/d64_dsk.h svneol=native#text/plain +src/lib/formats/d67_dsk.c svneol=native#text/plain +src/lib/formats/d67_dsk.h svneol=native#text/plain +src/lib/formats/d80_dsk.c svneol=native#text/plain +src/lib/formats/d80_dsk.h svneol=native#text/plain src/lib/formats/d81_dsk.c svneol=native#text/plain src/lib/formats/d81_dsk.h svneol=native#text/plain src/lib/formats/d88_dsk.c svneol=native#text/plain diff --git a/src/lib/formats/d64_dsk.c b/src/lib/formats/d64_dsk.c index 3c3fb8f21fe..9d2ac61d289 100644 --- a/src/lib/formats/d64_dsk.c +++ b/src/lib/formats/d64_dsk.c @@ -35,7 +35,7 @@ formats/d64_dsk.c - Commodore 2040/8050/1541 sector disk image format + Commodore 2040/1541/1571 sector disk image format *********************************************************************/ @@ -44,6 +44,12 @@ d64_format::d64_format() { + formats = file_formats; +} + +d64_format::d64_format(const format *_formats) +{ + formats = _formats; } const char *d64_format::name() const @@ -53,40 +59,31 @@ const char *d64_format::name() const const char *d64_format::description() const { - return "Commodore 2040/8050/1541 disk image"; + return "Commodore 4040/1541/1571 disk image"; } const char *d64_format::extensions() const { - return "d64,d67,d71,d80,d82"; + return "d64,d71"; } -const d64_format::format d64_format::formats[] = { - { // d67, dos 1, 35 tracks - floppy_image::FF_525, floppy_image::SSSD, DOS_1, 690, 35, 1, 9, 8 +const d64_format::format d64_format::file_formats[] = { + { // d64, dos 2, 35 tracks, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::SSSD, 683, 35, 1, 256, 9, 8 }, - { // d64, dos 2, 35 tracks - floppy_image::FF_525, floppy_image::SSSD, DOS_2, 683, 35, 1, 9, 8 + { // d64, dos 2, 40 tracks, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::SSSD, 768, 35, 1, 256, 9, 8 }, - { // d64, dos 2, 40 tracks - floppy_image::FF_525, floppy_image::SSSD, DOS_2, 768, 35, 1, 9, 8 + { // d64, dos 2, 42 tracks, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::SSSD, 802, 35, 1, 256, 9, 8 }, - { // d64, dos 2, 42 tracks - floppy_image::FF_525, floppy_image::SSSD, DOS_2, 802, 35, 1, 9, 8 - }, - { // d71, dos 2, 35 tracks, 2 heads - floppy_image::FF_525, floppy_image::DSSD, DOS_2, 683, 35, 2, 9, 8 - }, - { // d80, dos 2.5, 77 tracks - floppy_image::FF_525, floppy_image::SSQD, DOS_25, 2083, 77, 1, 9, 8 - }, - { // d82, dos 2.5, 77 tracks, 2 heads - floppy_image::FF_525, floppy_image::DSQD, DOS_25, 2083, 77, 2, 9, 8 + { // d71, dos 2, 35 tracks, 2 heads, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::DSSD, 683, 35, 2, 256, 9, 8 }, {} }; -const UINT32 d64_format::dos1_cell_size[] = +const UINT32 d64_format::cell_size[] = { 4000, // 16MHz/16/4 3750, // 16MHz/15/4 @@ -94,25 +91,7 @@ const UINT32 d64_format::dos1_cell_size[] = 3250 // 16MHz/13/4 }; -const UINT32 d64_format::dos25_cell_size[] = -{ - 2667, // 12MHz/16/2 - 2500, // 12MHz/15/2 - 2333, // 12MHz/14/2 - 2167 // 12MHz/13/2 -}; - -const int d64_format::dos1_sectors_per_track[] = -{ - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, // 1-17 - 20, 20, 20, 20, 20, 20, 20, // 18-24 - 18, 18, 18, 18, 18, 18, // 25-30 - 17, 17, 17, 17, 17, // 31-35 - 17, 17, 17, 17, 17, // 36-40 - 17, 17 // 41-42 -}; - -const int d64_format::dos2_sectors_per_track[] = +const int d64_format::sectors_per_track[] = { 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, // 1-17 19, 19, 19, 19, 19, 19, 19, // 18-24 @@ -122,17 +101,7 @@ const int d64_format::dos2_sectors_per_track[] = 17, 17 // 41-42 }; -const int d64_format::dos25_sectors_per_track[] = -{ - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, // 1-39 - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, // 40-53 - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, // 54-64 - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, // 65-77 - 23, 23, 23, 23, 23, 23, 23 // 78-84 -}; - -const int d64_format::dos1_speed_zone[] = +const int d64_format::speed_zone[] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 1-17 2, 2, 2, 2, 2, 2, 2, // 18-24 @@ -142,24 +111,14 @@ const int d64_format::dos1_speed_zone[] = 0, 0 // 41-42 }; -const int d64_format::dos25_speed_zone[] = -{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 1-39 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 40-53 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 54-64 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 65-77 - 0, 0, 0, 0, 0, 0, 0 // 78-84 -}; - int d64_format::find_size(io_generic *io, UINT32 form_factor) { int size = io_generic_size(io); for(int i=0; formats[i].sector_count; i++) { const format &f = formats[i]; - if(size == f.sector_count*SECTOR_SIZE) + if(size == f.sector_count*f.sector_base_size) return i; - if(size == (f.sector_count*SECTOR_SIZE) + f.sector_count) + if(size == (f.sector_count*f.sector_base_size) + f.sector_count) return i; } return -1; @@ -176,63 +135,37 @@ int d64_format::identify(io_generic *io, UINT32 form_factor) int d64_format::get_physical_track(const format &f, int track) { - int physical_track = 0; + // skip halftracks + return track * 2; +} - switch (f.dos) { - case DOS_1: physical_track = track*2; break; // skip halftracks - case DOS_2: physical_track = track*2; break; // skip halftracks - case DOS_25: physical_track = track; break; - } - - return physical_track; +int d64_format::get_disk_id_offset(const format &f) +{ + return 101144; } void d64_format::get_disk_id(const format &f, io_generic *io, UINT8 &id1, UINT8 &id2) { - int offset = 0; - - switch (f.dos) { - case DOS_1: offset = DOS1_DISK_ID_OFFSET; break; - case DOS_2: offset = DOS1_DISK_ID_OFFSET; break; - case DOS_25: offset = DOS25_DISK_ID_OFFSET; break; - } - UINT8 id[2]; - io_generic_read(io, id, offset, 2); + io_generic_read(io, id, get_disk_id_offset(f), 2); id1 = id[0]; id2 = id[1]; } UINT32 d64_format::get_cell_size(const format &f, int track) { - int cell_size = 0; - - switch (f.dos) { - case DOS_1: cell_size = dos1_cell_size[dos1_speed_zone[track]]; break; - case DOS_2: cell_size = dos1_cell_size[dos1_speed_zone[track]]; break; - case DOS_25: cell_size = dos25_cell_size[dos25_speed_zone[track]]; break; - } - - return cell_size; + return cell_size[speed_zone[track]]; } int d64_format::get_sectors_per_track(const format &f, int track) { - int sector_count = 0; - - switch (f.dos) { - case DOS_1: sector_count = dos1_sectors_per_track[track]; break; - case DOS_2: sector_count = dos2_sectors_per_track[track]; break; - case DOS_25: sector_count = dos25_sectors_per_track[track]; break; - } - - return sector_count; + return sectors_per_track[track]; } floppy_image_format_t::desc_e* d64_format::get_sector_desc(const format &f, int ¤t_size, int track, int sector_count, UINT8 id1, UINT8 id2, int gap_2) { static floppy_image_format_t::desc_e desc[] = { - /* 00 */ { SECTOR_LOOP_START, 0, sector_count-1 }, + /* 00 */ { SECTOR_LOOP_START, 0, -1 }, /* 01 */ { RAWBYTE, 0xff, 5 }, /* 02 */ { GCR5, 0x08, 1 }, /* 03 */ { CRC, 1 }, @@ -254,13 +187,13 @@ floppy_image_format_t::desc_e* d64_format::get_sector_desc(const format &f, int /* 19 */ { RAWBYTE, 0x55, gap_2 }, /* 20 */ { SECTOR_LOOP_END }, /* 21 */ { RAWBYTE, 0x55, 0 }, - /* 22 */ { RAWBITS, 0xffff, 0 }, + /* 22 */ { RAWBITS, 0x5555, 0 }, /* 23 */ { END } }; - current_size = 40 + (1+1+4+2)*10 + (f.gap_1)*8 + 40 + (1+SECTOR_SIZE+1+2)*10 + gap_2*8; - current_size *= sector_count; + current_size = 40 + (1+1+4+2)*10 + (f.gap_1)*8 + 40 + (1+f.sector_base_size+1+2)*10 + gap_2*8; + current_size *= sector_count; return desc; } @@ -268,9 +201,9 @@ void d64_format::build_sector_description(const format &f, UINT8 *sectdata, desc { int cur_offset = 0; - for(int i=0; iget_cell_size(f, track); + int physical_track = this->get_physical_track(f, track); + int sector_count = this->get_sectors_per_track(f, track); + int track_size = sector_count*f.sector_base_size; desc = get_sector_desc(f, current_size, track+1, sector_count, id1, id2, f.gap_2); @@ -325,9 +257,7 @@ bool d64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) desc[22].p2 = remaining_size & 7; desc[22].p1 >>= 8-(remaining_size & 7); - printf("track %u cursize %u totsize %u phystrack %u secnt %u trksize %u trkofs %u\n", track,current_size,total_size,physical_track,sector_count,track_size,track_offset); - - build_sector_description(f, &img[track_offset], sectors, sector_count, &img[f.sector_count*SECTOR_SIZE + error_offset]); + build_sector_description(f, &img[track_offset], sectors, sector_count, &img[f.sector_count*f.sector_base_size + error_offset]); generate_track(desc, physical_track, head, sectors, sector_count, total_size, image); track_offset += track_size; @@ -340,6 +270,11 @@ bool d64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) return true; } +void d64_format::extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head) +{ + +} + bool d64_format::save(io_generic *io, floppy_image *image) { return false; diff --git a/src/lib/formats/d64_dsk.h b/src/lib/formats/d64_dsk.h index 1a95954de42..7f73f45ae89 100644 --- a/src/lib/formats/d64_dsk.h +++ b/src/lib/formats/d64_dsk.h @@ -2,7 +2,7 @@ formats/d64_dsk.h - Commodore 2040/8050/1541 sector disk image format + Commodore 2040/1541/1571 sector disk image format *********************************************************************/ @@ -17,15 +17,16 @@ public: UINT32 form_factor; // See floppy_image for possible values UINT32 variant; // See floppy_image for possible values - int dos; int sector_count; int track_count; int head_count; + int sector_base_size; int gap_1; int gap_2; }; d64_format(); + d64_format(const format *formats); virtual const char *name() const; virtual const char *description() const; @@ -37,13 +38,6 @@ public: virtual bool supports_save() const; protected: - enum - { - DOS_1, - DOS_2, - DOS_25 - }; - enum { ERROR_00 = 1, @@ -60,31 +54,23 @@ protected: ERROR_74, /* disk not ready (no device 1) UNIMPLEMENTED */ }; - static const int SECTOR_SIZE = 256; - - static const int DOS1_DISK_ID_OFFSET = 101144; - static const int DOS25_DISK_ID_OFFSET = 282136; - - floppy_image_format_t::desc_e* get_sector_desc(const format &f, int ¤t_size, int track, int sector_count, UINT8 id1, UINT8 id2, int gap_2); + const format *formats; int find_size(io_generic *io, UINT32 form_factor); - int get_physical_track(const format &f, int track); - UINT32 get_cell_size(const format &f, int track); - int get_sectors_per_track(const format &f, int track); + virtual int get_physical_track(const format &f, int track); + virtual UINT32 get_cell_size(const format &f, int track); + virtual int get_sectors_per_track(const format &f, int track); + virtual int get_disk_id_offset(const format &f); void get_disk_id(const format &f, io_generic *io, UINT8 &id1, UINT8 &id2); + floppy_image_format_t::desc_e* get_sector_desc(const format &f, int ¤t_size, int track, int sector_count, UINT8 id1, UINT8 id2, int gap_2); void build_sector_description(const format &f, UINT8 *sectdata, desc_s *sectors, int sector_count, UINT8 *errordata) const; + void extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head); - static const format formats[]; + static const format file_formats[]; - static const UINT32 dos1_cell_size[]; - static const UINT32 dos25_cell_size[]; - - static const int dos1_speed_zone[]; - static const int dos25_speed_zone[]; - - static const int dos1_sectors_per_track[]; - static const int dos2_sectors_per_track[]; - static const int dos25_sectors_per_track[]; + static const UINT32 cell_size[]; + static const int sectors_per_track[]; + static const int speed_zone[]; }; extern const floppy_format_type FLOPPY_D64_FORMAT; diff --git a/src/lib/formats/d67_dsk.c b/src/lib/formats/d67_dsk.c new file mode 100644 index 00000000000..90ef089dc54 --- /dev/null +++ b/src/lib/formats/d67_dsk.c @@ -0,0 +1,86 @@ +/*************************************************************************** + + Copyright Olivier Galibert + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +****************************************************************************/ + +/********************************************************************* + + formats/d67_dsk.c + + Commodore 2040 sector disk image format + +*********************************************************************/ + +#include "emu.h" +#include "formats/d67_dsk.h" + +d67_format::d67_format() : d64_format(formats) +{ +} + +const char *d67_format::name() const +{ + return "d67"; +} + +const char *d67_format::description() const +{ + return "Commodore 2040 disk image"; +} + +const char *d67_format::extensions() const +{ + return "d67"; +} + +const d67_format::format d67_format::formats[] = { + { // d67, dos 1, 35 tracks, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::SSSD, 690, 35, 1, 256, 9, 8 + }, + {} +}; + +const int d67_format::sectors_per_track[] = +{ + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, // 1-17 + 20, 20, 20, 20, 20, 20, 20, // 18-24 + 18, 18, 18, 18, 18, 18, // 25-30 + 17, 17, 17, 17, 17, // 31-35 + 17, 17, 17, 17, 17, // 36-40 + 17, 17 // 41-42 +}; + +int d67_format::get_sectors_per_track(const format &f, int track) +{ + return sectors_per_track[track]; +} + +const floppy_format_type FLOPPY_D67_FORMAT = &floppy_image_format_creator; diff --git a/src/lib/formats/d67_dsk.h b/src/lib/formats/d67_dsk.h new file mode 100644 index 00000000000..8167ae50b9c --- /dev/null +++ b/src/lib/formats/d67_dsk.h @@ -0,0 +1,34 @@ +/********************************************************************* + + formats/d67_dsk.h + + Commodore 2040 sector disk image format + +*********************************************************************/ + +#ifndef D67_DSK_H_ +#define D67_DSK_H_ + +#include "d64_dsk.h" + +class d67_format : public d64_format { +public: + d67_format(); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + +protected: + virtual int get_sectors_per_track(const format &f, int track); + + static const format formats[]; + + static const int sectors_per_track[]; +}; + +extern const floppy_format_type FLOPPY_D67_FORMAT; + + + +#endif diff --git a/src/lib/formats/d80_dsk.c b/src/lib/formats/d80_dsk.c new file mode 100644 index 00000000000..6139cfa8468 --- /dev/null +++ b/src/lib/formats/d80_dsk.c @@ -0,0 +1,122 @@ +/*************************************************************************** + + Copyright Olivier Galibert + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +****************************************************************************/ + +/********************************************************************* + + formats/d80_dsk.c + + Commodore 8050/8250/SFD-1001 sector disk image format + +*********************************************************************/ + +#include "emu.h" +#include "formats/d80_dsk.h" + +d80_format::d80_format() : d64_format(formats) +{ +} + +const char *d80_format::name() const +{ + return "d80"; +} + +const char *d80_format::description() const +{ + return "Commodore 8050/8250/SFD-1001 disk image"; +} + +const char *d80_format::extensions() const +{ + return "d80,d82"; +} + +const d80_format::format d80_format::formats[] = { + { // d80, dos 2.5, 77 tracks, head/stepper 100 tpi + floppy_image::FF_525, floppy_image::SSQD, 2083, 77, 1, 256, 9, 8 + }, + { // d82, dos 2.5, 77 tracks, 2 heads, head/stepper 100 tpi + floppy_image::FF_525, floppy_image::DSQD, 2083, 77, 2, 256, 9, 8 + }, + {} +}; + +const UINT32 d80_format::cell_size[] = +{ + 2667, // 12MHz/16/2 + 2500, // 12MHz/15/2 + 2333, // 12MHz/14/2 + 2167 // 12MHz/13/2 +}; + +const int d80_format::sectors_per_track[] = +{ + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, // 1-39 + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, // 40-53 + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, // 54-64 + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, // 65-77 + 23, 23, 23, 23, 23, 23, 23 // 78-84 +}; + +const int d80_format::speed_zone[] = +{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 1-39 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 40-53 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 54-64 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 65-77 + 0, 0, 0, 0, 0, 0, 0 // 78-84 +}; + +int d80_format::get_physical_track(const format &f, int track) +{ + return track; +} + +UINT32 d80_format::get_cell_size(const format &f, int track) +{ + return cell_size[speed_zone[track]]; +} + +int d80_format::get_sectors_per_track(const format &f, int track) +{ + return sectors_per_track[track]; +} + +int d80_format::get_disk_id_offset(const format &f) +{ + return 282136; +} + +const floppy_format_type FLOPPY_D80_FORMAT = &floppy_image_format_creator; diff --git a/src/lib/formats/d80_dsk.h b/src/lib/formats/d80_dsk.h new file mode 100644 index 00000000000..b569355caf3 --- /dev/null +++ b/src/lib/formats/d80_dsk.h @@ -0,0 +1,39 @@ +/********************************************************************* + + formats/d80_dsk.h + + Commodore 8050/8250/SFD-1001 sector disk image format + +*********************************************************************/ + +#ifndef D80_DSK_H_ +#define D80_DSK_H_ + +#include "d64_dsk.h" + +class d80_format : public d64_format { +public: + d80_format(); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + +protected: + virtual int get_physical_track(const format &f, int track); + virtual UINT32 get_cell_size(const format &f, int track); + virtual int get_sectors_per_track(const format &f, int track); + virtual int get_disk_id_offset(const format &f); + + static const format formats[]; + + static const UINT32 cell_size[]; + static const int speed_zone[]; + static const int sectors_per_track[]; +}; + +extern const floppy_format_type FLOPPY_D80_FORMAT; + + + +#endif diff --git a/src/lib/formats/g64_dsk.c b/src/lib/formats/g64_dsk.c index f6a6ae8cc0d..2207503421e 100644 --- a/src/lib/formats/g64_dsk.c +++ b/src/lib/formats/g64_dsk.c @@ -35,7 +35,7 @@ formats/g64_dsk.c - Commodore 1541 GCR disk image format + Commodore 1541/1571 GCR disk image format *********************************************************************/ @@ -60,7 +60,7 @@ const char *g64_format::description() const const char *g64_format::extensions() const { - return "g64"; + return "g64,g41,g71"; } const UINT32 g64_format::c1541_cell_size[] = @@ -76,7 +76,7 @@ int g64_format::identify(io_generic *io, UINT32 form_factor) UINT8 header[8]; io_generic_read(io, &header, 0, sizeof(header)); - if ( memcmp( header, G64_FORMAT_HEADER, 8 ) ==0) { + if ( memcmp( header, G64_FORMAT_HEADER, 8 ) == 0) { return 100; } return 0; @@ -88,7 +88,11 @@ bool g64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) UINT8 *img = global_alloc_array(UINT8, size); io_generic_read(io, img, 0, size); - int track_count = pick_integer_le(img, 9, 2); + int version = img[0x08]; + if (version) + throw emu_fatalerror("g64_format: Unsupported version %u", version); + + int track_count = img[0x09]; int pos = 0x0c; int track_offset[track_count]; @@ -109,27 +113,36 @@ bool g64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) if (pos > 0) { track_size = pick_integer_le(img, pos, 2); pos +=2; - } - if (speed_zone_offset[track] > 3) - throw emu_fatalerror("g64_format: Unsupported variable speed zones on track %d", track); + if (speed_zone_offset[track] > 3) + throw emu_fatalerror("g64_format: Unsupported variable speed zones on track %d", track); - UINT32 cell_size = c1541_cell_size[speed_zone_offset[track]]; - int total_size = 200000000/cell_size; - UINT32 *buffer = global_alloc_array_clear(UINT32, total_size); - int offset = 0; + UINT32 cell_size = c1541_cell_size[speed_zone_offset[track]]; + int total_size = 200000000/cell_size; + UINT32 *buffer = global_alloc_array_clear(UINT32, total_size); + int offset = 0; - if (pos > 0) { - for (int i=0; i=0; bit--) { + bit_w(buffer, offset++, BIT(img[pos], bit), cell_size); + if (offset == total_size) break; + } } - if (offset >= total_size) - throw emu_fatalerror("g64_format: Too many cells for track %d", track); - } + if (offset < total_size) { + // pad the remainder of the track with sync + int count = (total_size-offset); + for (int i=0; i= 84 ? track - 84 : track; + int head = track >= 84; + + generate_track_from_levels(physical_track, head, buffer, total_size, 0, image); + global_free(buffer); + } } image->set_variant(floppy_image::SSSD); diff --git a/src/lib/formats/g64_dsk.h b/src/lib/formats/g64_dsk.h index 1a8365bd6d4..8b39a7e6e89 100644 --- a/src/lib/formats/g64_dsk.h +++ b/src/lib/formats/g64_dsk.h @@ -2,7 +2,7 @@ formats/g64_dsk.h - Commodore 1541 GCR disk image format + Commodore 1541/1571 GCR disk image format *********************************************************************/ diff --git a/src/lib/lib.mak b/src/lib/lib.mak index 050bd5e8c94..edc30d25cd5 100644 --- a/src/lib/lib.mak +++ b/src/lib/lib.mak @@ -118,6 +118,8 @@ FORMATSOBJS = \ $(LIBOBJ)/formats/cqm_dsk.o \ $(LIBOBJ)/formats/csw_cas.o \ $(LIBOBJ)/formats/d64_dsk.o \ + $(LIBOBJ)/formats/d67_dsk.o \ + $(LIBOBJ)/formats/d80_dsk.o \ $(LIBOBJ)/formats/d81_dsk.o \ $(LIBOBJ)/formats/d88_dsk.o \ $(LIBOBJ)/formats/dfi_dsk.o \