From e7967e81b9ceb5a730814dafa33f5a02607faaf7 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Tue, 21 Apr 2015 22:25:44 +0300 Subject: [PATCH] (MESS) c4040: Added own sector dump disk format since it's different from what the 1541 uses. [Curt Coder] --- scripts/src/lib.lua | 2 + src/emu/bus/ieee488/c2040.c | 131 ++++++++++++++++++++++++--------- src/emu/bus/ieee488/c2040.h | 3 + src/emu/bus/ieee488/c2040fdc.h | 1 + src/lib/formats/c4040_dsk.c | 91 +++++++++++++++++++++++ src/lib/formats/c4040_dsk.h | 38 ++++++++++ src/lib/formats/d64_dsk.c | 3 +- src/lib/formats/d64_dsk.h | 1 + 8 files changed, 233 insertions(+), 37 deletions(-) create mode 100644 src/lib/formats/c4040_dsk.c create mode 100644 src/lib/formats/c4040_dsk.h diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index 96ab4c3cad2..e3dc7c6064a 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -157,6 +157,8 @@ project "formats" MAME_DIR .. "src/lib/formats/bw2_dsk.h", MAME_DIR .. "src/lib/formats/bw12_dsk.c", MAME_DIR .. "src/lib/formats/bw12_dsk.h", + MAME_DIR .. "src/lib/formats/c4040_dsk.c", + MAME_DIR .. "src/lib/formats/c4040_dsk.h", MAME_DIR .. "src/lib/formats/c8280_dsk.c", MAME_DIR .. "src/lib/formats/c8280_dsk.h", MAME_DIR .. "src/lib/formats/cbm_crt.c", diff --git a/src/emu/bus/ieee488/c2040.c b/src/emu/bus/ieee488/c2040.c index d12be0795a3..bb012afa92a 100644 --- a/src/emu/bus/ieee488/c2040.c +++ b/src/emu/bus/ieee488/c2040.c @@ -9,6 +9,34 @@ **********************************************************************/ +/* + + 2040/3040 disk initialization + ----------------------------- + You need to initialize each diskette before trying to access it + or you will get a DISK ID MISMATCH error upon disk commands. + On the 4040 this is done automatically by the DOS. + + open 15,8,15:print 15,"i":close 15 + + List directory + -------------- + directory / diR + + Format disk + ----------- + header "label,id",d0,i01 + + Load file + --------- + dload "name" / dL"name + + Save file + --------- + dsave "name" / dS"name + +*/ + /* TODO: @@ -53,19 +81,14 @@ const device_type C4040 = &device_creator; // ROM( c2040 ) //------------------------------------------------- -ROM_START( c2040 ) // schematic 320806 +ROM_START( c2040 ) // schematic 320806, DOS 1.0 ROM_REGION( 0x3000, M6502_TAG, 0 ) ROM_DEFAULT_BIOS("dos12") - ROM_SYSTEM_BIOS( 0, "dos10", "DOS 1.0" ) - ROMX_LOAD( "901468-xx.ul1", 0x1000, 0x1000, NO_DUMP, ROM_BIOS(1) ) - ROMX_LOAD( "901468-xx.uh1", 0x2000, 0x1000, NO_DUMP, ROM_BIOS(1) ) - ROM_SYSTEM_BIOS( 1, "dos12", "DOS 1.2" ) - ROMX_LOAD( "901468-06.ul1", 0x1000, 0x1000, CRC(25b5eed5) SHA1(4d9658f2e6ff3276e5c6e224611a66ce44b16fc7), ROM_BIOS(2) ) - ROMX_LOAD( "901468-07.uh1", 0x2000, 0x1000, CRC(9b09ae83) SHA1(6a51c7954938439ca8342fc295bda050c06e1791), ROM_BIOS(2) ) + ROM_LOAD( "901468-xx.ul1", 0x1000, 0x1000, NO_DUMP ) + ROM_LOAD( "901468-xx.uh1", 0x2000, 0x1000, NO_DUMP ) ROM_REGION( 0x400, M6504_TAG, 0 ) - ROMX_LOAD( "901466-01.uk3", 0x000, 0x400, CRC(9d1e25ce) SHA1(d539858f839f96393f218307df7394362a84a26a), ROM_BIOS(1) ) - ROMX_LOAD( "901466-02.uk3", 0x000, 0x400, CRC(9d1e25ce) SHA1(d539858f839f96393f218307df7394362a84a26a), ROM_BIOS(2) ) + ROM_LOAD( "901466-01.uk3", 0x000, 0x400, CRC(9d1e25ce) SHA1(d539858f839f96393f218307df7394362a84a26a) ) ROM_REGION( 0x800, "gcr", 0) ROM_LOAD( "901467.uk6", 0x000, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) ) @@ -82,6 +105,33 @@ const rom_entry *c2040_device::device_rom_region() const } +//------------------------------------------------- +// ROM( c3040 ) +//------------------------------------------------- + +ROM_START( c3040 ) // schematic 320806, DOS 1.2 + ROM_REGION( 0x3000, M6502_TAG, 0 ) + ROM_LOAD( "901468-06.ul1", 0x1000, 0x1000, CRC(25b5eed5) SHA1(4d9658f2e6ff3276e5c6e224611a66ce44b16fc7) ) + ROM_LOAD( "901468-07.uh1", 0x2000, 0x1000, CRC(9b09ae83) SHA1(6a51c7954938439ca8342fc295bda050c06e1791) ) + + ROM_REGION( 0x400, M6504_TAG, 0 ) + ROM_LOAD( "901466-02.uk3", 0x000, 0x400, CRC(9d1e25ce) SHA1(d539858f839f96393f218307df7394362a84a26a) ) + + ROM_REGION( 0x800, "gcr", 0) + ROM_LOAD( "901467.uk6", 0x000, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *c3040_device::device_rom_region() const +{ + return ROM_NAME( c3040 ); +} + + //------------------------------------------------- // ROM( c4040 ) //------------------------------------------------- @@ -434,9 +484,18 @@ SLOT_INTERFACE_END //------------------------------------------------- FLOPPY_FORMATS_MEMBER( c2040_device::floppy_formats ) - FLOPPY_D64_FORMAT, - FLOPPY_G64_FORMAT, - FLOPPY_D67_FORMAT + FLOPPY_D67_FORMAT, + FLOPPY_G64_FORMAT +FLOPPY_FORMATS_END + + +//------------------------------------------------- +// FLOPPY_FORMATS( floppy_formats ) +//------------------------------------------------- + +FLOPPY_FORMATS_MEMBER( c4040_device::floppy_formats ) + FLOPPY_C4040_FORMAT, + FLOPPY_G64_FORMAT FLOPPY_FORMATS_END @@ -532,8 +591,8 @@ static MACHINE_CONFIG_FRAGMENT( c4040 ) MCFG_DEVICE_ADD(FDC_TAG, C2040_FDC, XTAL_16MHz) MCFG_C2040_READY_CALLBACK(DEVWRITELINE(M6522_TAG, via6522_device, write_ca1)) MCFG_C2040_ERROR_CALLBACK(DEVWRITELINE(M6522_TAG, via6522_device, write_cb1)) - MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":0", c2040_floppies, "525ssqd", c2040_device::floppy_formats) - MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":1", c2040_floppies, "525ssqd", c2040_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":0", c2040_floppies, "525ssqd", c4040_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":1", c2040_floppies, "525ssqd", c4040_device::floppy_formats) MACHINE_CONFIG_END @@ -605,24 +664,24 @@ inline void c2040_device::update_ieee_signals() // c2040_device - constructor //------------------------------------------------- -c2040_device::c2040_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source), - device_ieee488_interface(mconfig, *this), - m_maincpu(*this, M6502_TAG), - m_fdccpu(*this, M6504_TAG), - m_riot0(*this, M6532_0_TAG), - m_riot1(*this, M6532_1_TAG), - m_miot(*this, M6530_TAG), - m_via(*this, M6522_TAG), - m_floppy0(*this, FDC_TAG":0:525ssqd"), - m_floppy1(*this, FDC_TAG":1:525ssqd"), - m_fdc(*this, FDC_TAG), - m_gcr(*this, "gcr"), - m_address(*this, "ADDRESS"), - m_rfdo(1), - m_daco(1), - m_atna(1), - m_miot_irq(CLEAR_LINE) +c2040_device::c2040_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : + device_t(mconfig, type, name, tag, owner, clock, shortname, source), + device_ieee488_interface(mconfig, *this), + m_maincpu(*this, M6502_TAG), + m_fdccpu(*this, M6504_TAG), + m_riot0(*this, M6532_0_TAG), + m_riot1(*this, M6532_1_TAG), + m_miot(*this, M6530_TAG), + m_via(*this, M6522_TAG), + m_floppy0(*this, FDC_TAG":0:525ssqd"), + m_floppy1(*this, FDC_TAG":1:525ssqd"), + m_fdc(*this, FDC_TAG), + m_gcr(*this, "gcr"), + m_address(*this, "ADDRESS"), + m_rfdo(1), + m_daco(1), + m_atna(1), + m_miot_irq(CLEAR_LINE) { } @@ -652,16 +711,16 @@ c2040_device::c2040_device(const machine_config &mconfig, const char *tag, devic // c3040_device - constructor //------------------------------------------------- -c3040_device::c3040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : c2040_device(mconfig, C3040, "C3040", tag, owner, clock, "c3040", __FILE__) { } +c3040_device::c3040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + c2040_device(mconfig, C3040, "C3040", tag, owner, clock, "c3040", __FILE__) { } //------------------------------------------------- // c4040_device - constructor //------------------------------------------------- -c4040_device::c4040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : c2040_device(mconfig, C4040, "C4040", tag, owner, clock, "c4040", __FILE__) { } +c4040_device::c4040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + c2040_device(mconfig, C4040, "C4040", tag, owner, clock, "c4040", __FILE__) { } //------------------------------------------------- diff --git a/src/emu/bus/ieee488/c2040.h b/src/emu/bus/ieee488/c2040.h index c99731d27d9..020a436a9ac 100644 --- a/src/emu/bus/ieee488/c2040.h +++ b/src/emu/bus/ieee488/c2040.h @@ -107,6 +107,9 @@ class c3040_device : public c2040_device public: // construction/destruction c3040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; }; diff --git a/src/emu/bus/ieee488/c2040fdc.h b/src/emu/bus/ieee488/c2040fdc.h index d64d2de7c01..31b3c38affa 100644 --- a/src/emu/bus/ieee488/c2040fdc.h +++ b/src/emu/bus/ieee488/c2040fdc.h @@ -15,6 +15,7 @@ #define __C2040_FLOPPY__ #include "emu.h" +#include "formats/c4040_dsk.h" #include "formats/d64_dsk.h" #include "formats/d67_dsk.h" #include "formats/g64_dsk.h" diff --git a/src/lib/formats/c4040_dsk.c b/src/lib/formats/c4040_dsk.c new file mode 100644 index 00000000000..da3ac905693 --- /dev/null +++ b/src/lib/formats/c4040_dsk.c @@ -0,0 +1,91 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************* + + formats/c4040_dsk.c + + Commodore 4040 sector disk image format + +*********************************************************************/ + +#include + +#include "formats/c4040_dsk.h" + +c4040_format::c4040_format() : d64_format(file_formats) +{ +} + +const char *c4040_format::name() const +{ + return "c4040"; +} + +const char *c4040_format::description() const +{ + return "Commodore 4040 disk image"; +} + +const char *c4040_format::extensions() const +{ + return "d64"; +} + +const c4040_format::format c4040_format::file_formats[] = { + { // c4040, dos 2, 35 tracks, head 48 tpi, stepper 96 tpi + floppy_image::FF_525, floppy_image::SSSD, 683, 35, 1, 256, 9, 8 + }, + {} +}; + +const int c4040_format::c4040_gap2[] = +{ + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, // 1-17 + 19, 19, 19, 19, 19, 19, 19, // 18-24 + 15, 15, 15, 15, 15, 15, // 25-30 + 12, 12, 12, 12, 12 // 31-35 +}; + +floppy_image_format_t::desc_e* c4040_format::get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2) +{ + static floppy_image_format_t::desc_e desc[] = { + /* 00 */ { SECTOR_LOOP_START, 0, -1 }, + /* 01 */ { RAWBYTE, 0xff, 5 }, + /* 02 */ { GCR5, 0x08, 1 }, + /* 03 */ { CRC, 1 }, + /* 04 */ { CRC_CBM_START, 1 }, + /* 05 */ { SECTOR_ID_GCR5 }, + /* 06 */ { TRACK_ID_DOS2_GCR5 }, + /* 07 */ { GCR5, id2, 1 }, + /* 08 */ { GCR5, id1, 1 }, + /* 09 */ { CRC_END, 1 }, + /* 10 */ { GCR5, 0x00, f.gap_1 }, + /* 11 */ { RAWBYTE, 0xff, 5 }, + /* 12 */ { GCR5, 0x07, 1 }, + /* 13 */ { CRC_CBM_START, 2 }, + /* 14 */ { SECTOR_DATA_GCR5, -1 }, + /* 15 */ { CRC_END, 2 }, + /* 16 */ { CRC, 2 }, + /* 17 */ { GCR5, 0x00, gap_2 }, + /* 18 */ { SECTOR_LOOP_END }, + /* 19 */ { GCR5, 0x00, 0 }, + /* 20 */ { RAWBITS, 0x14a, 0 }, + /* 21 */ { END } + }; + + desc[17].p2 = gap_2; // TODO why?!? + + current_size = 40 + (1+1+4)*10 + f.gap_1*10 + 40 + (1+f.sector_base_size+1)*10 + gap_2*10; + + current_size *= sector_count; + return desc; +} + +void c4040_format::fix_end_gap(floppy_image_format_t::desc_e* desc, int remaining_size) +{ + desc[19].p2 = remaining_size / 10; + desc[20].p2 = remaining_size % 10; + desc[20].p1 >>= remaining_size & 0x01; +} + +const floppy_format_type FLOPPY_C4040_FORMAT = &floppy_image_format_creator; diff --git a/src/lib/formats/c4040_dsk.h b/src/lib/formats/c4040_dsk.h new file mode 100644 index 00000000000..231b961c765 --- /dev/null +++ b/src/lib/formats/c4040_dsk.h @@ -0,0 +1,38 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************* + + formats/c4040_dsk.h + + Commodore 4040 sector disk image format + +*********************************************************************/ + +#ifndef C4040_DSK_H_ +#define C4040_DSK_H_ + +#include "d64_dsk.h" + +class c4040_format : public d64_format { +public: + c4040_format(); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + +protected: + virtual floppy_image_format_t::desc_e* get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2); + virtual int get_gap2(const format &f, int head, int track) { return c4040_gap2[track]; } + virtual void fix_end_gap(floppy_image_format_t::desc_e* desc, int remaining_size); + + static const format file_formats[]; + + static const int c4040_gap2[]; +}; + +extern const floppy_format_type FLOPPY_C4040_FORMAT; + + + +#endif diff --git a/src/lib/formats/d64_dsk.c b/src/lib/formats/d64_dsk.c index e5ffc9d15d9..4de63b34bc8 100644 --- a/src/lib/formats/d64_dsk.c +++ b/src/lib/formats/d64_dsk.c @@ -239,8 +239,9 @@ bool d64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) int physical_track = this->get_physical_track(f, head, track); int sector_count = this->get_sectors_per_track(f, track); int track_size = sector_count*f.sector_base_size; + int gap2 = this->get_gap2(f, head, track); - floppy_image_format_t::desc_e *desc = this->get_sector_desc(f, current_size, sector_count, id1, id2, f.gap_2); + floppy_image_format_t::desc_e *desc = this->get_sector_desc(f, current_size, sector_count, id1, id2, gap2); int remaining_size = total_size - current_size; if(remaining_size < 0) diff --git a/src/lib/formats/d64_dsk.h b/src/lib/formats/d64_dsk.h index 9d6add2817e..558d4ebf1c2 100644 --- a/src/lib/formats/d64_dsk.h +++ b/src/lib/formats/d64_dsk.h @@ -66,6 +66,7 @@ protected: void get_disk_id(const format &f, io_generic *io, UINT8 &id1, UINT8 &id2); virtual int get_image_offset(const format &f, int head, int track); int compute_track_size(const format &f, int track); + virtual int get_gap2(const format &f, int head, int track) { return f.gap_2; } virtual floppy_image_format_t::desc_e* get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2); void build_sector_description(const format &f, UINT8 *sectdata, UINT32 sect_offs, UINT32 error_offs, desc_s *sectors, int sector_count) const; virtual void fix_end_gap(floppy_image_format_t::desc_e* desc, int remaining_size);