From 90b4007b6b4f698e771e9f9161b3569b98dd86fb Mon Sep 17 00:00:00 2001 From: Michael Zapf Date: Mon, 1 Apr 2024 00:08:08 +0200 Subject: ti99: Using device arrays instead of multiple similar devices. --- src/devices/bus/ti99/gromport/multiconn.cpp | 48 ++++++++++--------------- src/devices/bus/ti99/gromport/multiconn.h | 10 ++---- src/devices/bus/ti99/peb/bwg.cpp | 47 +++++++++++------------- src/devices/bus/ti99/peb/bwg.h | 6 +--- src/devices/bus/ti99/peb/cc_fdc.cpp | 40 +++++++++------------ src/devices/bus/ti99/peb/cc_fdc.h | 6 +--- src/devices/bus/ti99/peb/hfdc.cpp | 56 +++++++++++------------------ src/devices/bus/ti99/peb/hfdc.h | 11 ++---- src/devices/bus/ti99/peb/myarcfdc.cpp | 38 ++++++++------------ src/devices/bus/ti99/peb/myarcfdc.h | 6 +--- src/devices/bus/ti99/peb/ti_fdc.cpp | 33 ++++++++--------- src/devices/bus/ti99/peb/ti_fdc.h | 5 +-- 12 files changed, 114 insertions(+), 192 deletions(-) diff --git a/src/devices/bus/ti99/gromport/multiconn.cpp b/src/devices/bus/ti99/gromport/multiconn.cpp index 81351792089..415fc7c3873 100644 --- a/src/devices/bus/ti99/gromport/multiconn.cpp +++ b/src/devices/bus/ti99/gromport/multiconn.cpp @@ -60,10 +60,7 @@ ti99_multi_cart_conn_device::ti99_multi_cart_conn_device(const machine_config &m m_active_slot(0), m_fixed_slot(0), m_next_free_slot(0), - m_cart1(*this, "1"), - m_cart2(*this, "2"), - m_cart3(*this, "3"), - m_cart4(*this, "4") + m_cart(*this, "%u", 1) { } @@ -133,8 +130,8 @@ void ti99_multi_cart_conn_device::romgq_line(int state) m_readrom = state; // Propagate to all slots - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) - m_cartridge[i]->romgq_line(state); + for (auto &cart : m_cart) + cart->romgq_line(state); } /* @@ -145,14 +142,14 @@ void ti99_multi_cart_conn_device::set_gromlines(line_state mline, line_state mol // GROM selected? m_grom_selected = (gsq == ASSERT_LINE); - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) - m_cartridge[i]->set_gromlines(mline, moline, gsq); + for (auto &cart : m_cart) + cart->set_gromlines(mline, moline, gsq); } void ti99_multi_cart_conn_device::gclock_in(int state) { - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) - m_cartridge[i]->gclock_in(state); + for (auto &cart : m_cart) + cart->gclock_in(state); } void ti99_multi_cart_conn_device::readz(offs_t offset, uint8_t *value) @@ -167,7 +164,7 @@ void ti99_multi_cart_conn_device::readz(offs_t offset, uint8_t *value) for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) { uint8_t newval = *value; - m_cartridge[i]->readz(offset, &newval); + m_cart[i]->readz(offset, &newval); if (i==slot) *value = newval; } @@ -175,7 +172,7 @@ void ti99_multi_cart_conn_device::readz(offs_t offset, uint8_t *value) else { if (slot < NUMBER_OF_CARTRIDGE_SLOTS) - m_cartridge[slot]->readz(offset, value); + m_cart[slot]->readz(offset, value); } } @@ -185,15 +182,15 @@ void ti99_multi_cart_conn_device::write(offs_t offset, uint8_t data) // We don't have GRAM cartridges, anyway, so it's just used for setting the address. if (m_grom_selected) { - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) - m_cartridge[i]->write(offset, data); + for (auto &cart : m_cart) + cart->write(offset, data); } else { int slot = get_active_slot(true, offset); if (slot < NUMBER_OF_CARTRIDGE_SLOTS) // logerror("writing %04x (slot %d) <- %02x\n", offset, slot, data); - m_cartridge[slot]->write(offset, data); + m_cart[slot]->write(offset, data); } } @@ -202,7 +199,7 @@ void ti99_multi_cart_conn_device::crureadz(offs_t offset, uint8_t *value) int slot = get_active_slot(false, offset); // Sanity check. Higher slots are always empty. if (slot < NUMBER_OF_CARTRIDGE_SLOTS) - m_cartridge[slot]->crureadz(offset, value); + m_cart[slot]->crureadz(offset, value); } void ti99_multi_cart_conn_device::cruwrite(offs_t offset, uint8_t data) @@ -210,7 +207,7 @@ void ti99_multi_cart_conn_device::cruwrite(offs_t offset, uint8_t data) int slot = get_active_slot(false, offset); if (slot < NUMBER_OF_CARTRIDGE_SLOTS) - m_cartridge[slot]->cruwrite(offset, data); + m_cart[slot]->cruwrite(offset, data); } /* @@ -221,7 +218,7 @@ bool ti99_multi_cart_conn_device::is_grom_idle() { // Sanity check. Higher slots are always empty. if (m_active_slot < NUMBER_OF_CARTRIDGE_SLOTS) - return m_cartridge[m_active_slot]->is_grom_idle(); + return m_cart[m_active_slot]->is_grom_idle(); return false; } @@ -236,13 +233,8 @@ void ti99_multi_cart_conn_device::device_start() save_item(NAME(m_fixed_slot)); save_item(NAME(m_next_free_slot)); - m_cartridge[0] = m_cart1; - m_cartridge[1] = m_cart2; - m_cartridge[2] = m_cart3; - m_cartridge[3] = m_cart4; - - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) - m_cartridge[i]->set_connector(this); + for (auto &cart : m_cart) + cart->set_connector(this); } void ti99_multi_cart_conn_device::device_reset(void) @@ -254,10 +246,8 @@ void ti99_multi_cart_conn_device::device_reset(void) void ti99_multi_cart_conn_device::device_add_mconfig(machine_config &config) { - TI99_CART(config, m_cart1, 0); - TI99_CART(config, m_cart2, 0); - TI99_CART(config, m_cart3, 0); - TI99_CART(config, m_cart4, 0); + for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) + TI99_CART(config, m_cart[i], 0); } INPUT_CHANGED_MEMBER( ti99_multi_cart_conn_device::switch_changed ) diff --git a/src/devices/bus/ti99/gromport/multiconn.h b/src/devices/bus/ti99/gromport/multiconn.h index 6ed0a716768..1767461b82f 100644 --- a/src/devices/bus/ti99/gromport/multiconn.h +++ b/src/devices/bus/ti99/gromport/multiconn.h @@ -35,25 +35,19 @@ public: bool is_grom_idle() override; protected: - static constexpr unsigned NUMBER_OF_CARTRIDGE_SLOTS = 4; - virtual void device_start() override; virtual void device_reset() override; virtual void device_add_mconfig(machine_config &config) override; virtual ioport_constructor device_input_ports() const override; private: + static constexpr unsigned NUMBER_OF_CARTRIDGE_SLOTS = 4; bool m_readrom; int m_active_slot; int m_fixed_slot; int m_next_free_slot; - required_device m_cart1; - required_device m_cart2; - required_device m_cart3; - required_device m_cart4; - - ti99_cartridge_device* m_cartridge[NUMBER_OF_CARTRIDGE_SLOTS]; + required_device_array m_cart; void set_slot(int slotnumber); int get_active_slot(bool changebase, offs_t offset); diff --git a/src/devices/bus/ti99/peb/bwg.cpp b/src/devices/bus/ti99/peb/bwg.cpp index c6a671e2633..3f6d21a293b 100644 --- a/src/devices/bus/ti99/peb/bwg.cpp +++ b/src/devices/bus/ti99/peb/bwg.cpp @@ -60,7 +60,7 @@ #define LOG_MOTOR (1U << 8) // Show motor operations #define LOG_CONFIG (1U << 9) // Configuration -#define VERBOSE (LOG_CONFIG | LOG_WARN) +#define VERBOSE (LOG_GENERAL | LOG_CONFIG | LOG_WARN) #include "logmacro.h" DEFINE_DEVICE_TYPE(TI99_BWG, bus::ti99::peb::snug_bwg_device, "ti99_bwg", "SNUG BwG Floppy Controller") @@ -94,10 +94,7 @@ snug_bwg_device::snug_bwg_device(const machine_config &mconfig, const char *tag, m_address(0), m_dsrrom(nullptr), m_buffer_ram(*this, BUFFER), - m_flopcon0(*this, "0"), - m_flopcon1(*this, "1"), - m_flopcon2(*this, "2"), - m_flopcon3(*this, "3"), + m_floppy(*this, "%u", 0), m_sel_floppy(0), m_wd1773(*this, FDC_TAG), m_clock(*this, CLOCK_TAG), @@ -359,10 +356,10 @@ void snug_bwg_device::crureadz(offs_t offset, uint8_t *value) if ((offset & 0x00f0)==0) { // Check what drives are not connected - reply = ((m_floppy[0] != nullptr)? 0 : 0x02) // DSK1 - | ((m_floppy[1] != nullptr)? 0 : 0x04) // DSK2 - | ((m_floppy[2] != nullptr)? 0 : 0x08) // DSK3 - | ((m_floppy[3] != nullptr)? 0 : 0x01); // DSK4 + reply = ((m_floppy[0]->get_device() != nullptr)? 0 : 0x02) // DSK1 + | ((m_floppy[1]->get_device() != nullptr)? 0 : 0x04) // DSK2 + | ((m_floppy[2]->get_device() != nullptr)? 0 : 0x08) // DSK3 + | ((m_floppy[3]->get_device() != nullptr)? 0 : 0x01); // DSK4 // DIP switches for step and date/time display if (m_dip1 != 0) reply |= 0x10; @@ -467,11 +464,11 @@ void snug_bwg_device::select_drive(int n, int state) LOGMASKED(LOG_WARN, "Warning: DSK%d selected while DSK%d not yet unselected\n", n, m_sel_floppy); } - if (m_floppy[n-1] != nullptr) + if (m_floppy[n-1]->get_device() != nullptr) { m_sel_floppy = n; - m_wd1773->set_floppy(m_floppy[n-1]); - m_floppy[n-1]->ss_w(m_crulatch0_7->q7_r()); + m_wd1773->set_floppy(m_floppy[n-1]->get_device()); + m_floppy[n-1]->get_device()->ss_w(m_crulatch0_7->q7_r()); } } } @@ -482,7 +479,7 @@ void snug_bwg_device::sidsel_w(int state) if (m_sel_floppy != 0) { LOGMASKED(LOG_CRU, "Set side (bit 7) = %d on DSK%d\n", state, m_sel_floppy); - m_floppy[m_sel_floppy-1]->ss_w(m_crulatch0_7->q7_r()); + m_floppy[m_sel_floppy-1]->get_device()->ss_w(m_crulatch0_7->q7_r()); } } @@ -506,7 +503,8 @@ void snug_bwg_device::motorona_w(int state) // Set all motors for (auto & elem : m_floppy) - if (elem != nullptr) elem->mon_w((state==ASSERT_LINE)? 0 : 1); + if (elem->get_device() != nullptr) + elem->get_device()->mon_w((state==ASSERT_LINE)? 0 : 1); // The motor-on line also connects to the wait state logic operate_ready_line(); @@ -546,17 +544,12 @@ void snug_bwg_device::device_reset() m_WDsel = false; m_WDsel0 = false; - m_floppy[0] = m_flopcon0->get_device(); - m_floppy[1] = m_flopcon1->get_device(); - m_floppy[2] = m_flopcon2->get_device(); - m_floppy[3] = m_flopcon3->get_device(); - - for (int i=0; i < 4; i++) + for (auto &flop : m_floppy) { - if (m_floppy[i] != nullptr) - LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", i, m_floppy[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", i); + LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", flop->basetag()); } m_wd1773->set_floppy(nullptr); @@ -612,10 +605,10 @@ void snug_bwg_device::device_add_mconfig(machine_config& config) MM58274C(config, CLOCK_TAG, 32.768_kHz_XTAL).set_mode_and_day(1, 0); // 24h, sunday - FLOPPY_CONNECTOR(config, m_flopcon0, bwg_floppies, "525dd", snug_bwg_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon1, bwg_floppies, "525dd", snug_bwg_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon2, bwg_floppies, nullptr, snug_bwg_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon3, bwg_floppies, nullptr, snug_bwg_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], bwg_floppies, "525dd", snug_bwg_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], bwg_floppies, "525dd", snug_bwg_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], bwg_floppies, nullptr, snug_bwg_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[3], bwg_floppies, nullptr, snug_bwg_device::floppy_formats).enable_sound(true); RAM(config, BUFFER).set_default_size("2K").set_default_value(0); diff --git a/src/devices/bus/ti99/peb/bwg.h b/src/devices/bus/ti99/peb/bwg.h index f1fbb9957ad..ced48131918 100644 --- a/src/devices/bus/ti99/peb/bwg.h +++ b/src/devices/bus/ti99/peb/bwg.h @@ -112,11 +112,7 @@ private: required_device m_buffer_ram; // Link to the attached floppy drives - required_device m_flopcon0; - required_device m_flopcon1; - required_device m_flopcon2; - required_device m_flopcon3; - floppy_image_device* m_floppy[4]; + required_device_array m_floppy; // Currently selected floppy drive (1-4, 0=none) int m_sel_floppy; diff --git a/src/devices/bus/ti99/peb/cc_fdc.cpp b/src/devices/bus/ti99/peb/cc_fdc.cpp index ec3717530ea..88fa46d2aa3 100644 --- a/src/devices/bus/ti99/peb/cc_fdc.cpp +++ b/src/devices/bus/ti99/peb/cc_fdc.cpp @@ -78,10 +78,7 @@ corcomp_fdc_device::corcomp_fdc_device(const machine_config &mconfig, device_typ m_wdc(*this, WDC_TAG), m_decpal(*this, dpname), m_ctrlpal(*this, cpname), - m_flopcon0(*this, "0"), - m_flopcon1(*this, "1"), - m_flopcon2(*this, "2"), - m_flopcon3(*this, "3"), + m_floppy(*this, "%u", 0), m_motormf(*this, MOTORMF_TAG), m_tms9901(*this, TMS9901_TAG), m_buffer_ram(*this, BUFFER), @@ -367,10 +364,10 @@ void corcomp_fdc_device::select_dsk(int state) } LOGMASKED(LOG_DRIVE, "Select drive DSK%d\n", m_selected_drive); - if (m_floppy[m_selected_drive-1] != nullptr) + if (m_floppy[m_selected_drive-1]->get_device() != nullptr) { - m_wdc->set_floppy(m_floppy[m_selected_drive-1]); - m_floppy[m_selected_drive-1]->ss_w(m_tms9901->read_bit(tms9901_device::INT15_P7)); + m_wdc->set_floppy(m_floppy[m_selected_drive-1]->get_device()); + m_floppy[m_selected_drive-1]->get_device()->ss_w(m_tms9901->read_bit(tms9901_device::INT15_P7)); } } } @@ -381,7 +378,7 @@ void corcomp_fdc_device::side_select(int state) if (m_selected_drive != 0) { LOGMASKED(LOG_DRIVE, "Set side (bit 7) = %d on DSK%d\n", state, m_selected_drive); - m_floppy[m_selected_drive-1]->ss_w(state); + m_floppy[m_selected_drive-1]->get_device()->ss_w(state); } } @@ -394,8 +391,10 @@ void corcomp_fdc_device::motor_w(int state) m_wdc->set_force_ready(state==ASSERT_LINE); // Set all motors - for (auto & elem : m_floppy) - if (elem != nullptr) elem->mon_w((state==ASSERT_LINE)? 0 : 1); + for (auto &elem : m_floppy) + if (elem->get_device() != nullptr) + elem->get_device()->mon_w((state==ASSERT_LINE)? 0 : 1); + operate_ready_line(); } @@ -430,17 +429,12 @@ void corcomp_fdc_device::device_start() void corcomp_fdc_device::device_reset() { - m_floppy[0] = m_flopcon0->get_device(); - m_floppy[1] = m_flopcon1->get_device(); - m_floppy[2] = m_flopcon2->get_device(); - m_floppy[3] = m_flopcon3->get_device(); - - for (int i=0; i < 4; i++) + for (auto &flop : m_floppy) { - if (m_floppy[i] != nullptr) - LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", i, m_floppy[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", i); + LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", flop->basetag()); } m_decpal->set_board(this); @@ -530,10 +524,10 @@ void corcomp_fdc_device::common_config(machine_config& config) m_motormf->set_clear_pin_value(1); m_motormf->out_cb().set(FUNC(corcomp_fdc_device::motor_w)); - FLOPPY_CONNECTOR(config, "0", ccfdc_floppies, "525dd", corcomp_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "1", ccfdc_floppies, "525dd", corcomp_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "2", ccfdc_floppies, nullptr, corcomp_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "3", ccfdc_floppies, nullptr, corcomp_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], ccfdc_floppies, "525dd", corcomp_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], ccfdc_floppies, "525dd", corcomp_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], ccfdc_floppies, nullptr, corcomp_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[3], ccfdc_floppies, nullptr, corcomp_fdc_device::floppy_formats).enable_sound(true); // SRAM 2114 1Kx4 RAM(config, BUFFER).set_default_size("1k").set_default_value(0); diff --git a/src/devices/bus/ti99/peb/cc_fdc.h b/src/devices/bus/ti99/peb/cc_fdc.h index 49530f8e428..62dc5b9adb7 100644 --- a/src/devices/bus/ti99/peb/cc_fdc.h +++ b/src/devices/bus/ti99/peb/cc_fdc.h @@ -89,11 +89,7 @@ protected: void operate_ready_line(); // Link to the attached floppy drives - required_device m_flopcon0; - required_device m_flopcon1; - required_device m_flopcon2; - required_device m_flopcon3; - floppy_image_device* m_floppy[4]; + required_device_array m_floppy; // Motor monoflop required_device m_motormf; diff --git a/src/devices/bus/ti99/peb/hfdc.cpp b/src/devices/bus/ti99/peb/hfdc.cpp index a18adb9aed9..ad116788507 100644 --- a/src/devices/bus/ti99/peb/hfdc.cpp +++ b/src/devices/bus/ti99/peb/hfdc.cpp @@ -102,13 +102,8 @@ myarc_hfdc_device::myarc_hfdc_device(const machine_config &mconfig, const char * m_motor_on_timer(nullptr), m_hdc9234(*this, FDC_TAG), m_clock(*this, CLOCK_TAG), - m_flopcon0(*this, "f1"), - m_flopcon1(*this, "f2"), - m_flopcon2(*this, "f3"), - m_flopcon3(*this, "f4"), - m_hardcon0(*this, "h1"), - m_hardcon1(*this, "h2"), - m_hardcon2(*this, "h3"), + m_floppy(*this, "f%u", 1), + m_harddisk(*this, "h%u", 1), m_current_floppy(nullptr), m_current_harddisk(nullptr), m_current_floppy_index(NONE), @@ -734,7 +729,7 @@ void myarc_hfdc_device::connect_floppy_unit(int index) LOGMASKED(LOG_LINES, "Select floppy drive DSK%d\n", index+1); // Connect new drive - m_current_floppy = m_floppy_unit[index]; + m_current_floppy = m_floppy[index]->get_device(); m_current_floppy_index = index; // We don't use the READY line of floppy drives. @@ -764,7 +759,7 @@ void myarc_hfdc_device::connect_harddisk_unit(int index) LOGMASKED(LOG_LINES, "Select hard disk WDS%d\n", index+1); // Connect new drive - m_current_harddisk = m_harddisk_unit[index]; + m_current_harddisk = m_harddisk[index]->get_device(); m_current_hd_index = index; LOGMASKED(LOG_LINES, "Connect index callback WDS%d\n", index+1); @@ -826,8 +821,8 @@ void myarc_hfdc_device::set_floppy_motors_running(bool run) } // Set all motors - for (auto & elem : m_floppy_unit) - if (elem != nullptr) elem->mon_w((run)? 0 : 1); + for (auto & elem : m_floppy) + if (elem->get_device() != nullptr) elem->get_device()->mon_w((run)? 0 : 1); } /* @@ -949,30 +944,21 @@ void myarc_hfdc_device::device_reset() m_selected = false; m_lastval = 0; m_readyflags = 0; - - m_floppy_unit[0] = m_flopcon0->get_device(); - m_floppy_unit[1] = m_flopcon1->get_device(); - m_floppy_unit[2] = m_flopcon2->get_device(); - m_floppy_unit[3] = m_flopcon3->get_device(); - m_harddisk_unit[0] = m_hardcon0->get_device(); - m_harddisk_unit[1] = m_hardcon1->get_device(); - m_harddisk_unit[2] = m_hardcon2->get_device(); - - for (int i=0; i < 4; i++) + for (auto &flop : m_floppy) { - if (m_floppy_unit[i] != nullptr) - LOGMASKED(LOG_CONFIG, "FD connector %d with %s\n", i+1, m_floppy_unit[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "FD connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "FD connector %d has no floppy attached\n", i+1); + LOGMASKED(LOG_CONFIG, "FD connector %d has no floppy attached\n", flop->basetag()); } - for (int i=0; i < 3; i++) + for (auto &hard : m_harddisk) { - if (m_harddisk_unit[i] != nullptr) - LOGMASKED(LOG_CONFIG, "HD connector %d with %s\n", i+1, m_harddisk_unit[i]->name()); + if (hard->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "HD connector %d with %s\n", hard->basetag(), hard->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "HD connector %d has no drive attached\n", i+1); + LOGMASKED(LOG_CONFIG, "HD connector %d has no floppy attached\n", hard->basetag()); } // Disconnect all units @@ -1073,15 +1059,15 @@ void myarc_hfdc_device::device_add_mconfig(machine_config& config) m_hdc9234->dmaout_cb().set(FUNC(myarc_hfdc_device::write_buffer)); // First two floppy drives shall be connected by default - FLOPPY_CONNECTOR(config, m_flopcon0, hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon1, hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon2, hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon3, hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[3], hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); // Hard disks don't go without image (other than floppy drives) - MFM_HD_CONNECTOR(config, m_hardcon0, hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); - MFM_HD_CONNECTOR(config, m_hardcon1, hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); - MFM_HD_CONNECTOR(config, m_hardcon2, hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[0], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[1], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[2], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); MM58274C(config, CLOCK_TAG, 0).set_mode_and_day(1, 0); // 24h, sunday diff --git a/src/devices/bus/ti99/peb/hfdc.h b/src/devices/bus/ti99/peb/hfdc.h index 53215eb2e4f..a600412849a 100644 --- a/src/devices/bus/ti99/peb/hfdc.h +++ b/src/devices/bus/ti99/peb/hfdc.h @@ -99,17 +99,10 @@ private: required_device m_clock; // Link to the attached floppy drives - required_device m_flopcon0; - required_device m_flopcon1; - required_device m_flopcon2; - required_device m_flopcon3; - floppy_image_device* m_floppy_unit[4]; + required_device_array m_floppy; // Link to the attached hard disks - required_device m_hardcon0; - required_device m_hardcon1; - required_device m_hardcon2; - mfm_harddisk_device* m_harddisk_unit[3]; + required_device_array m_harddisk; // Currently selected floppy drive floppy_image_device* m_current_floppy; diff --git a/src/devices/bus/ti99/peb/myarcfdc.cpp b/src/devices/bus/ti99/peb/myarcfdc.cpp index 96677bcd751..6d96c9587c1 100644 --- a/src/devices/bus/ti99/peb/myarcfdc.cpp +++ b/src/devices/bus/ti99/peb/myarcfdc.cpp @@ -64,10 +64,7 @@ myarc_fdc_device::myarc_fdc_device(const machine_config &mconfig, const char *ta m_buffer_ram(*this, BUFFER_TAG), m_pal(*this, PAL_TAG), m_dsrrom(nullptr), - m_flopcon0(*this, "0"), - m_flopcon1(*this, "1"), - m_flopcon2(*this, "2"), - m_flopcon3(*this, "3"), + m_floppy(*this, "%u", 0), m_banksel(false), m_cardsel(false), m_selected_drive(0), @@ -278,8 +275,8 @@ void myarc_fdc_device::fdc_mon_w(int state) // Do not start the motors when no drive is selected. However, motors // can always be stopped. if (m_selected_drive != 0 || state==1) - for (int i = 0; i < 4; i++) - if (m_floppy[i] != nullptr) m_floppy[i]->mon_w(state); + for (auto &flop : m_floppy) + if (flop->get_device() != nullptr) flop->get_device()->mon_w(state); } /* @@ -303,7 +300,7 @@ void myarc_fdc_device::sidsel_w(int state) if (m_selected_drive != 0) { LOGMASKED(LOG_DRIVE, "Set side = %d on DSK%d\n", state, m_selected_drive); - m_floppy[m_selected_drive-1]->ss_w(state); + m_floppy[m_selected_drive-1]->get_device()->ss_w(state); } } @@ -339,12 +336,12 @@ void myarc_fdc_device::drivesel_w(int state) } else { - if (m_floppy[driveno-1] != nullptr) + if (m_floppy[driveno-1]->get_device() != nullptr) { m_selected_drive = driveno; LOGMASKED(LOG_DRIVE, "Select drive DSK%d\n", driveno); - m_wdc->set_floppy(m_floppy[driveno-1]); - m_floppy[driveno-1]->ss_w(m_drivelatch->q2_r()); + m_wdc->set_floppy(m_floppy[driveno-1]->get_device()); + m_floppy[driveno-1]->get_device()->ss_w(m_drivelatch->q2_r()); } } } @@ -360,17 +357,12 @@ void myarc_fdc_device::device_start() void myarc_fdc_device::device_reset() { - m_floppy[0] = m_flopcon0->get_device(); - m_floppy[1] = m_flopcon1->get_device(); - m_floppy[2] = m_flopcon2->get_device(); - m_floppy[3] = m_flopcon3->get_device(); - - for (int i=0; i < 4; i++) + for (auto &flop : m_floppy) { - if (m_floppy[i] != nullptr) - LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", i, m_floppy[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", i); + LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", flop->basetag()); } if (ioport("CONTROLLER")->read()==0) @@ -467,10 +459,10 @@ void myarc_fdc_device::device_add_mconfig(machine_config& config) DDCC1_PAL(config, PAL_TAG, 0); // Floppy drives - FLOPPY_CONNECTOR(config, "0", myarc_ddcc_floppies, "525dd", myarc_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "1", myarc_ddcc_floppies, "525dd", myarc_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "2", myarc_ddcc_floppies, nullptr, myarc_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "3", myarc_ddcc_floppies, nullptr, myarc_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], myarc_ddcc_floppies, "525dd", myarc_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], myarc_ddcc_floppies, "525dd", myarc_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], myarc_ddcc_floppies, nullptr, myarc_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[3], myarc_ddcc_floppies, nullptr, myarc_fdc_device::floppy_formats).enable_sound(true); } ioport_constructor myarc_fdc_device::device_input_ports() const diff --git a/src/devices/bus/ti99/peb/myarcfdc.h b/src/devices/bus/ti99/peb/myarcfdc.h index e6785aab737..6bd5a416a97 100644 --- a/src/devices/bus/ti99/peb/myarcfdc.h +++ b/src/devices/bus/ti99/peb/myarcfdc.h @@ -85,11 +85,7 @@ private: uint8_t* m_dsrrom; // Link to the attached floppy drives - required_device m_flopcon0; - required_device m_flopcon1; - required_device m_flopcon2; - required_device m_flopcon3; - floppy_image_device* m_floppy[4]; + required_device_array m_floppy; // Debugger accessors void debug_read(offs_t offset, uint8_t* value); diff --git a/src/devices/bus/ti99/peb/ti_fdc.cpp b/src/devices/bus/ti99/peb/ti_fdc.cpp index 41a29a0bfec..2bb69dfbca6 100644 --- a/src/devices/bus/ti99/peb/ti_fdc.cpp +++ b/src/devices/bus/ti99/peb/ti_fdc.cpp @@ -56,9 +56,7 @@ ti_fdc_device::ti_fdc_device(const machine_config &mconfig, const char *tag, dev m_crulatch(*this, "crulatch"), m_motormf(*this, "motormf"), m_dsrrom(nullptr), - m_flopcon0(*this, "0"), - m_flopcon1(*this, "1"), - m_flopcon2(*this, "2"), + m_floppy(*this, "%u", 0), m_sel_floppy(0) { } @@ -258,7 +256,8 @@ void ti_fdc_device::dvena_w(int state) // Set all motors for (auto & elem : m_floppy) - if (elem != nullptr) elem->mon_w((state==ASSERT_LINE)? 0 : 1); + if (elem->get_device() != nullptr) + elem->get_device()->mon_w((state==ASSERT_LINE)? 0 : 1); // The motor-on line also connects to the wait state logic operate_ready_line(); @@ -285,7 +284,7 @@ void ti_fdc_device::sidsel_w(int state) // Select side of disk (bit 7) LOGMASKED(LOG_CRU, "Set side (bit 7) = %d\n", state); if (m_sel_floppy > 0) - m_floppy[m_sel_floppy-1]->ss_w(state); + m_floppy[m_sel_floppy-1]->get_device()->ss_w(state); } /* @@ -328,11 +327,11 @@ void ti_fdc_device::select_drive(int n, int state) LOGMASKED(LOG_WARN, "Warning: DSK%d selected while DSK%d not yet unselected\n", n, m_sel_floppy); } - if (m_floppy[n-1] != nullptr) + if (m_floppy[n-1]->get_device() != nullptr) { m_sel_floppy = n; - m_fd1771->set_floppy(m_floppy[n-1]); - m_floppy[n-1]->ss_w(m_crulatch->q7_r()); + m_fd1771->set_floppy(m_floppy[n-1]->get_device()); + m_floppy[n-1]->get_device()->ss_w(m_crulatch->q7_r()); } } } @@ -362,16 +361,12 @@ void ti_fdc_device::device_reset() m_inDsrArea = false; m_WDsel = false; - m_floppy[0] = m_flopcon0->get_device(); - m_floppy[1] = m_flopcon1->get_device(); - m_floppy[2] = m_flopcon2->get_device(); - - for (int i=0; i < 3; i++) + for (auto &flop : m_floppy) { - if (m_floppy[i] != nullptr) - LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", i, m_floppy[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "Connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "No floppy attached to connector %d\n", i); + LOGMASKED(LOG_CONFIG, "Connector %d has no floppy attached\n", flop->basetag()); } m_sel_floppy = 0; @@ -402,9 +397,9 @@ void ti_fdc_device::device_add_mconfig(machine_config& config) m_fd1771->drq_wr_callback().set(FUNC(ti_fdc_device::fdc_drq_w)); m_fd1771->hld_wr_callback().set(FUNC(ti_fdc_device::fdc_hld_w)); - FLOPPY_CONNECTOR(config, m_flopcon0, tifdc_floppies, "525dd", ti_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon1, tifdc_floppies, "525dd", ti_fdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, m_flopcon2, tifdc_floppies, nullptr, ti_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], tifdc_floppies, "525dd", ti_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], tifdc_floppies, "525dd", ti_fdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], tifdc_floppies, nullptr, ti_fdc_device::floppy_formats).enable_sound(true); LS259(config, m_crulatch); // U23 m_crulatch->q_out_cb<0>().set(FUNC(ti_fdc_device::dskpgena_w)); diff --git a/src/devices/bus/ti99/peb/ti_fdc.h b/src/devices/bus/ti99/peb/ti_fdc.h index eb5eb1b8054..cfe822c0dae 100644 --- a/src/devices/bus/ti99/peb/ti_fdc.h +++ b/src/devices/bus/ti99/peb/ti_fdc.h @@ -104,10 +104,7 @@ private: uint8_t* m_dsrrom; // Link to the attached floppy drives - required_device m_flopcon0; - required_device m_flopcon1; - required_device m_flopcon2; - floppy_image_device* m_floppy[3]; + required_device_array m_floppy; // Currently selected floppy drive int m_sel_floppy; -- cgit v1.2.3