mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
ep64_exdos, compis_fdc: Clean up code using device finder arrays for floppy drives
This commit is contained in:
parent
231df06c12
commit
59521cf6cf
@ -48,6 +48,8 @@ This PCB plugs into the external expansion connector on the right side of the ma
|
||||
#include "emu.h"
|
||||
#include "exdos.h"
|
||||
|
||||
#include "formats/ep64_dsk.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -109,10 +111,9 @@ void ep64_exdos_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
WD1770(config, m_fdc, 8_MHz_XTAL);
|
||||
|
||||
FLOPPY_CONNECTOR(config, m_floppy0, ep64_exdos_floppies, "35dd", ep64_exdos_device::floppy_formats);
|
||||
FLOPPY_CONNECTOR(config, m_floppy1, ep64_exdos_floppies, nullptr, ep64_exdos_device::floppy_formats);
|
||||
FLOPPY_CONNECTOR(config, m_floppy2, ep64_exdos_floppies, nullptr, ep64_exdos_device::floppy_formats);
|
||||
FLOPPY_CONNECTOR(config, m_floppy3, ep64_exdos_floppies, nullptr, ep64_exdos_device::floppy_formats);
|
||||
for (auto &floppy : m_floppy)
|
||||
FLOPPY_CONNECTOR(config, floppy, ep64_exdos_floppies, nullptr, ep64_exdos_device::floppy_formats);
|
||||
m_floppy[0]->set_default_option("35dd");
|
||||
}
|
||||
|
||||
|
||||
@ -128,11 +129,8 @@ ep64_exdos_device::ep64_exdos_device(const machine_config &mconfig, const char *
|
||||
device_t(mconfig, EP64_EXDOS, tag, owner, clock),
|
||||
device_ep64_expansion_bus_card_interface(mconfig, *this),
|
||||
m_fdc(*this, WD1770_TAG),
|
||||
m_floppy0(*this, WD1770_TAG":0"),
|
||||
m_floppy1(*this, WD1770_TAG":1"),
|
||||
m_floppy2(*this, WD1770_TAG":2"),
|
||||
m_floppy3(*this, WD1770_TAG":3"),
|
||||
m_floppy(nullptr),
|
||||
m_floppy(*this, WD1770_TAG":%u", 0U),
|
||||
m_selected_floppy(nullptr),
|
||||
m_rom(*this, "rom")
|
||||
{
|
||||
}
|
||||
@ -159,8 +157,8 @@ void ep64_exdos_device::device_reset()
|
||||
{
|
||||
m_fdc->reset();
|
||||
|
||||
m_floppy = nullptr;
|
||||
m_fdc->set_floppy(m_floppy);
|
||||
m_selected_floppy = nullptr;
|
||||
m_fdc->set_floppy(m_selected_floppy);
|
||||
m_fdc->dden_w(0);
|
||||
}
|
||||
|
||||
@ -191,7 +189,7 @@ uint8_t ep64_exdos_device::read()
|
||||
data |= m_fdc->intrq_r() << 1;
|
||||
data |= m_fdc->drq_r() << 7;
|
||||
|
||||
data |= (m_floppy ? m_floppy->dskchg_r() : 1) << 6;
|
||||
data |= (m_selected_floppy ? m_selected_floppy->dskchg_r() : 1) << 6;
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -218,19 +216,18 @@ void ep64_exdos_device::write(uint8_t data)
|
||||
|
||||
*/
|
||||
|
||||
m_floppy = nullptr;
|
||||
m_selected_floppy = nullptr;
|
||||
|
||||
if (BIT(data, 0)) m_floppy = m_floppy0->get_device();
|
||||
if (BIT(data, 1)) m_floppy = m_floppy1->get_device();
|
||||
if (BIT(data, 2)) m_floppy = m_floppy2->get_device();
|
||||
if (BIT(data, 3)) m_floppy = m_floppy3->get_device();
|
||||
|
||||
m_fdc->set_floppy(m_floppy);
|
||||
|
||||
if (m_floppy)
|
||||
for (int n = 0; n < 4; n++)
|
||||
{
|
||||
m_floppy->ss_w(BIT(data, 4));
|
||||
if (BIT(data, n))
|
||||
m_selected_floppy = m_floppy[n]->get_device();
|
||||
}
|
||||
|
||||
m_fdc->set_floppy(m_selected_floppy);
|
||||
|
||||
if (m_selected_floppy)
|
||||
m_selected_floppy->ss_w(BIT(data, 4));
|
||||
|
||||
m_fdc->dden_w(BIT(data, 5));
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "exp.h"
|
||||
#include "formats/ep64_dsk.h"
|
||||
#include "imagedev/floppy.h"
|
||||
#include "machine/wd_fdc.h"
|
||||
|
||||
@ -47,11 +46,8 @@ private:
|
||||
static void floppy_formats(format_registration &fr);
|
||||
|
||||
required_device<wd1770_device> m_fdc;
|
||||
required_device<floppy_connector> m_floppy0;
|
||||
required_device<floppy_connector> m_floppy1;
|
||||
required_device<floppy_connector> m_floppy2;
|
||||
required_device<floppy_connector> m_floppy3;
|
||||
floppy_image_device *m_floppy;
|
||||
required_device_array<floppy_connector, 4> m_floppy;
|
||||
floppy_image_device *m_selected_floppy;
|
||||
required_memory_region m_rom;
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "emu.h"
|
||||
#include "compis_fdc.h"
|
||||
|
||||
#include "formats/cpis_dsk.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
@ -61,8 +63,9 @@ void compis_fdc_device::device_add_mconfig(machine_config &config)
|
||||
I8272A(config, m_fdc, 8'000'000, true);
|
||||
m_fdc->intrq_wr_callback().set(FUNC(compis_fdc_device::fdc_irq));
|
||||
m_fdc->drq_wr_callback().set(FUNC(compis_fdc_device::fdc_drq));
|
||||
FLOPPY_CONNECTOR(config, m_floppy0, compis_floppies, "525qd", compis_fdc_device::floppy_formats);
|
||||
FLOPPY_CONNECTOR(config, m_floppy1, compis_floppies, "525qd", compis_fdc_device::floppy_formats);
|
||||
|
||||
for (auto &floppy : m_floppy)
|
||||
FLOPPY_CONNECTOR(config, floppy, compis_floppies, "525qd", compis_fdc_device::floppy_formats);
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +82,7 @@ compis_fdc_device::compis_fdc_device(const machine_config &mconfig, const char *
|
||||
device_t(mconfig, COMPIS_FDC, tag, owner, clock),
|
||||
device_isbx_card_interface(mconfig, *this),
|
||||
m_fdc(*this, I8272_TAG),
|
||||
m_floppy0(*this, I8272_TAG":0"),
|
||||
m_floppy1(*this, I8272_TAG":1")
|
||||
m_floppy(*this, I8272_TAG":%u", 0U)
|
||||
{
|
||||
}
|
||||
|
||||
@ -171,6 +173,10 @@ void compis_fdc_device::opt0_w(int state)
|
||||
|
||||
void compis_fdc_device::opt1_w(int state)
|
||||
{
|
||||
m_floppy0->get_device()->mon_w(state);
|
||||
m_floppy1->get_device()->mon_w(state);
|
||||
for (auto &floppy : m_floppy)
|
||||
{
|
||||
floppy_image_device *fd = floppy->get_device();
|
||||
if (fd)
|
||||
fd->mon_w(state);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "isbx.h"
|
||||
#include "formats/cpis_dsk.h"
|
||||
#include "imagedev/floppy.h"
|
||||
#include "machine/upd765.h"
|
||||
|
||||
@ -53,8 +52,7 @@ private:
|
||||
static void floppy_formats(format_registration &fr);
|
||||
|
||||
required_device<i8272a_device> m_fdc;
|
||||
required_device<floppy_connector> m_floppy0;
|
||||
required_device<floppy_connector> m_floppy1;
|
||||
required_device_array<floppy_connector, 2> m_floppy;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user