From cddf3d90aca8fee0835646ac694e1eecb85c9399 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 12 Oct 2023 19:02:55 -0400 Subject: ss50_dc5: Clean up code using device finder array --- src/devices/bus/ss50/dc5.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/devices/bus/ss50/dc5.cpp b/src/devices/bus/ss50/dc5.cpp index 62982d98c38..3b077403255 100644 --- a/src/devices/bus/ss50/dc5.cpp +++ b/src/devices/bus/ss50/dc5.cpp @@ -44,10 +44,7 @@ public: : device_t(mconfig, SS50_DC5, tag, owner, clock) , ss50_card_interface(mconfig, *this) , m_fdc(*this, "fdc") - , m_floppy0(*this, "fdc:0") - , m_floppy1(*this, "fdc:1") - , m_floppy2(*this, "fdc:2") - , m_floppy3(*this, "fdc:3") + , m_floppy(*this, "fdc:%u", 0U) , m_interrupt_select(*this, "INTERRUPT_SELECT") , m_address_mode(*this, "ADDRESS_MODE") , m_two_control_regs(*this, "TWO_CONTROL_REGS") @@ -98,10 +95,7 @@ private: uint8_t validate_fdc_sector_size(uint8_t cmd); required_device m_fdc; - required_device m_floppy0; - required_device m_floppy1; - required_device m_floppy2; - required_device m_floppy3; + required_device_array m_floppy; required_ioport m_interrupt_select; required_ioport m_address_mode; required_ioport m_two_control_regs; @@ -268,10 +262,8 @@ static void flex_floppies(device_slot_interface &device) void ss50_dc5_device::device_add_mconfig(machine_config &config) { WD2797(config, m_fdc, 12_MHz_XTAL / 12); // divider is selectable - FLOPPY_CONNECTOR(config, "fdc:0", flex_floppies, "sssd35", ss50_dc5_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "fdc:1", flex_floppies, "sssd35", ss50_dc5_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "fdc:2", flex_floppies, "sssd35", ss50_dc5_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "fdc:3", flex_floppies, "sssd35", ss50_dc5_device::floppy_formats).enable_sound(true); + for (auto &floppy : m_floppy) + FLOPPY_CONNECTOR(config, floppy, flex_floppies, "sssd35", ss50_dc5_device::floppy_formats).enable_sound(true); m_fdc->intrq_wr_callback().set(FUNC(ss50_dc5_device::fdc_intrq_w)); m_fdc->drq_wr_callback().set(FUNC(ss50_dc5_device::fdc_drq_w)); @@ -605,10 +597,12 @@ void ss50_dc5_device::control_register_update() // The floppy drives do not gate the motor based on the select input, // so the motors run, or not, irrespective of the drive selection. uint8_t motor = m_motor_timer_out ? CLEAR_LINE : ASSERT_LINE; - m_floppy0->get_device()->mon_w(motor); - m_floppy1->get_device()->mon_w(motor); - m_floppy2->get_device()->mon_w(motor); - m_floppy3->get_device()->mon_w(motor); + for (auto &floppy : m_floppy) + { + floppy_image_device *fd = floppy->get_device(); + if (fd) + fd->mon_w(motor); + } // The DC2, DC3, DC4, DC5 have a drive inhibit feature controlled by // bit 7, and the drives are de-selected if the motor timer has timed @@ -622,13 +616,7 @@ void ss50_dc5_device::control_register_update() floppy_image_device *floppy = nullptr; if ((bit7_side_select || !inhibit) && m_motor_timer_out) - { - uint8_t drive = m_control_register & 3; - if (drive == 0) floppy = m_floppy0->get_device(); - if (drive == 1) floppy = m_floppy1->get_device(); - if (drive == 2) floppy = m_floppy2->get_device(); - if (drive == 3) floppy = m_floppy3->get_device(); - } + floppy = m_floppy[m_control_register & 3]->get_device(); if (floppy != m_fdc_selected_floppy) { -- cgit v1.2.3