From a877bb053b821c32320a0ef651b96bb83ab34d79 Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Wed, 20 May 2015 15:59:11 +0200 Subject: [PATCH] nascom_fdc: proper support for single/double sided disk drives --- src/emu/bus/nasbus/floppy.c | 51 +++++++++++++++++++++++++++++++++++-- src/emu/bus/nasbus/floppy.h | 7 ++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/emu/bus/nasbus/floppy.c b/src/emu/bus/nasbus/floppy.c index 5eebd9a10c6..f140ff9ab0a 100644 --- a/src/emu/bus/nasbus/floppy.c +++ b/src/emu/bus/nasbus/floppy.c @@ -10,6 +10,14 @@ #include "formats/nascom_dsk.h" +//************************************************************************** +// CONSTANTS/MACROS +//************************************************************************** + +#define VERBOSE 1 +#define VERBOSE_STATUS 0 + + //************************************************************************** // DEVICE DEFINITIONS //************************************************************************** @@ -88,6 +96,22 @@ void nascom_fdc_device::device_reset() m_nasbus->m_io->install_read_handler(0xe5, 0xe5, read8_delegate(FUNC(nascom_fdc_device::status_r), this)); } +//------------------------------------------------- +// device_reset_after_children - device-specific reset after children +//------------------------------------------------- + +void nascom_fdc_device::device_reset_after_children() +{ + // sanity check + if (m_floppy0->get_device() && m_floppy1->get_device()) + if (m_floppy0->get_device()->get_sides() != m_floppy1->get_device()->get_sides()) + fatalerror("Floppy drive 0 and 1 need to be of the same type.\n"); + + if (m_floppy2->get_device() && m_floppy3->get_device()) + if (m_floppy2->get_device()->get_sides() != m_floppy3->get_device()->get_sides()) + fatalerror("Floppy drive 2 and 3 need to be of the same type.\n"); +} + //************************************************************************** // IMPLEMENTATION @@ -95,12 +119,32 @@ void nascom_fdc_device::device_reset() READ8_MEMBER( nascom_fdc_device::select_r ) { - return m_select | 0xa0; + m_select |= (0x80 | 0x20); + + // double sided drive for drive 0/1? + if (m_floppy0->get_device() && (m_floppy0->get_device()->get_sides() == 2)) + m_select &= ~0x20; + + if (m_floppy1->get_device() && (m_floppy1->get_device()->get_sides() == 2)) + m_select &= ~0x20; + + // double sided drive for drive 2/3? + if (m_floppy2->get_device() && (m_floppy2->get_device()->get_sides() == 2)) + m_select &= ~0x80; + + if (m_floppy3->get_device() && (m_floppy3->get_device()->get_sides() == 2)) + m_select &= ~0x80; + + if (VERBOSE) + logerror("nascom_fdc_device::select_r: 0x%02x\n", m_select); + + return m_select; } WRITE8_MEMBER( nascom_fdc_device::select_w ) { - logerror("nascom_fdc_device::select_w: 0x%02x\n", data); + if (VERBOSE) + logerror("nascom_fdc_device::select_w: 0x%02x\n", data); m_floppy = NULL; @@ -129,5 +173,8 @@ READ8_MEMBER( nascom_fdc_device::status_r ) data |= m_fdc->intrq_r() << 0; data |= m_fdc->drq_r() << 7; + if (VERBOSE_STATUS) + logerror("nascom_fdc_device::status_r: 0x%02x\n", data); + return data; } diff --git a/src/emu/bus/nasbus/floppy.h b/src/emu/bus/nasbus/floppy.h index 5bedb37a7e4..6994a9e978f 100644 --- a/src/emu/bus/nasbus/floppy.h +++ b/src/emu/bus/nasbus/floppy.h @@ -28,9 +28,9 @@ public: // construction/destruction nascom_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - DECLARE_READ8_MEMBER( select_r ); - DECLARE_WRITE8_MEMBER( select_w ); - DECLARE_READ8_MEMBER( status_r ); + DECLARE_READ8_MEMBER(select_r); + DECLARE_WRITE8_MEMBER(select_w); + DECLARE_READ8_MEMBER(status_r); DECLARE_FLOPPY_FORMATS(floppy_formats); @@ -38,6 +38,7 @@ protected: virtual machine_config_constructor device_mconfig_additions() const; virtual void device_start(); virtual void device_reset(); + virtual void device_reset_after_children(); private: required_device m_fdc;