From f554bd91201aa8e12ec0ef3031571040a1db6f0a Mon Sep 17 00:00:00 2001 From: Michael Zapf Date: Mon, 20 Aug 2018 20:21:53 +0200 Subject: [PATCH] ti99: Adapting to common devcb3 slot device handling. (nw) --- src/devices/bus/hexbus/hexbus.cpp | 13 +- src/devices/bus/hexbus/hexbus.h | 13 +- src/devices/bus/hexbus/hx5102.cpp | 9 +- src/devices/bus/hexbus/tp0370.h | 21 +-- src/devices/bus/ti99/colorbus/colorbus.cpp | 14 +- src/devices/bus/ti99/colorbus/colorbus.h | 13 +- src/devices/bus/ti99/gromport/gromport.cpp | 30 ++- src/devices/bus/ti99/gromport/gromport.h | 33 +++- src/devices/bus/ti99/internal/ioport.cpp | 25 +-- src/devices/bus/ti99/internal/ioport.h | 21 ++- src/devices/bus/ti99/joyport/joyport.cpp | 29 +-- src/devices/bus/ti99/joyport/joyport.h | 15 +- src/devices/bus/ti99/peb/evpc.cpp | 4 +- src/devices/bus/ti99/peb/peribox.cpp | 206 ++++++++++----------- src/devices/bus/ti99/peb/peribox.h | 28 ++- src/mame/drivers/geneve.cpp | 4 +- src/mame/drivers/ti99_2.cpp | 3 +- src/mame/drivers/ti99_4p.cpp | 2 +- src/mame/drivers/ti99_4x.cpp | 27 ++- src/mame/drivers/ti99_8.cpp | 10 +- 20 files changed, 285 insertions(+), 235 deletions(-) diff --git a/src/devices/bus/hexbus/hexbus.cpp b/src/devices/bus/hexbus/hexbus.cpp index f1719780011..6b6f19b7d98 100644 --- a/src/devices/bus/hexbus/hexbus.cpp +++ b/src/devices/bus/hexbus/hexbus.cpp @@ -211,14 +211,6 @@ uint8_t hexbus_device::read(int dir) return value; } -void hexbus_device::configure_slot() -{ - option_reset(); - option_add("hx5102", HX5102); - set_default_option(nullptr); - set_fixed(false); -} - // ------------------------------------------------------------------------ hexbus_chained_device::hexbus_chained_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock): @@ -350,3 +342,8 @@ uint8_t hexbus_chained_device::to_line_state(uint8_t data, bool bav, bool hsk) // ------------------------------------------------------------------------ } } // end namespace bus::hexbus + +void hexbus_options(device_slot_interface &device) +{ + device.option_add("hx5102", HX5102); +} diff --git a/src/devices/bus/hexbus/hexbus.h b/src/devices/bus/hexbus/hexbus.h index fb558d42517..ca961a39d17 100644 --- a/src/devices/bus/hexbus/hexbus.h +++ b/src/devices/bus/hexbus/hexbus.h @@ -108,6 +108,16 @@ protected: class hexbus_device : public device_t, public device_slot_interface { public: + template + hexbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : hexbus_device(mconfig, tag, owner, clock) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + hexbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // Used to establish the reverse link (inbound) @@ -116,7 +126,6 @@ public: // Read and write operations on the bus uint8_t read(int dir); void write(int dir, uint8_t data); - void configure_slot(); protected: void device_start() override; @@ -133,4 +142,6 @@ private: DECLARE_DEVICE_TYPE_NS(HEXBUS, bus::hexbus, hexbus_device) +void hexbus_options(device_slot_interface &device); + #endif // MAME_BUS_HEXBUS_HEXBUS_H diff --git a/src/devices/bus/hexbus/hx5102.cpp b/src/devices/bus/hexbus/hx5102.cpp index 4bdb088471a..c8a74e5ba49 100644 --- a/src/devices/bus/hexbus/hx5102.cpp +++ b/src/devices/bus/hexbus/hx5102.cpp @@ -633,7 +633,6 @@ WRITE_LINE_MEMBER( hx5102_device::fdc_drq_w ) /* Define the floppy formats. - TODO: Define another DSDD format with 16 sectors. */ FLOPPY_FORMATS_MEMBER(hx5102_device::floppy_formats) FLOPPY_TI99_SDF_FORMAT, @@ -670,12 +669,12 @@ INPUT_PORTS_END */ MACHINE_CONFIG_START(hx5102_device::device_add_mconfig) // Hexbus controller - MCFG_DEVICE_ADD(IBC_TAG, IBC, 0) - MCFG_IBC_HEXBUS_OUT_CALLBACK(WRITE8(*this, hx5102_device, hexbus_out)) - MCFG_IBC_HSKLATCH_CALLBACK(WRITELINE(*this, hx5102_device, hsklatch_out)) + IBC(config, m_hexbus_ctrl, 0); + m_hexbus_ctrl->hexbus_cb().set(FUNC(hx5102_device::hexbus_out)); + m_hexbus_ctrl->hsklatch_cb().set(FUNC(hx5102_device::hsklatch_out)); // Outgoing socket for downstream devices - HEXBUS(config, "hexbus", 0).configure_slot(); + HEXBUS(config, "hexbus", 0, hexbus_options, nullptr); // TMS9995 CPU @ 12.0 MHz TMS9995(config, m_flopcpu, XTAL(12'000'000)); diff --git a/src/devices/bus/hexbus/tp0370.h b/src/devices/bus/hexbus/tp0370.h index 5f5c02489c0..385059c7fa3 100644 --- a/src/devices/bus/hexbus/tp0370.h +++ b/src/devices/bus/hexbus/tp0370.h @@ -28,9 +28,10 @@ public: DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); - template static devcb_base &set_ibc_int_callback(device_t &device, Object &&cb) { return downcast(device).m_int.set_callback(std::forward(cb)); } - template static devcb_base &set_hexbus_wr_callback(device_t &device, Object &&cb) { return downcast(device).m_hexout.set_callback(std::forward(cb)); } - template static devcb_base &set_hsklatch_wr_callback(device_t &device, Object &&cb) { return downcast(device).m_latch.set_callback(std::forward(cb)); } + // Callbacks + auto int_cb() { return m_int.bind(); } + auto hexbus_cb() { return m_hexout.bind(); } + auto hsklatch_cb() { return m_latch.bind(); } // INT line devcb_write_line m_int; @@ -68,19 +69,5 @@ private: } } - -/* - Links to outside -*/ - -#define MCFG_IBC_HEXBUS_OUT_CALLBACK(_write) \ - ibc_device::set_hexbus_wr_callback(*device, DEVCB_##_write); - -#define MCFG_IBC_HSKLATCH_CALLBACK(_write) \ - ibc_device::set_hsklatch_wr_callback(*device, DEVCB_##_write); - -#define MCFG_IBC_INT_CALLBACK(_write) \ - ibc_device::set_ibc_int_callback(*device, DEVCB_##_write); - DECLARE_DEVICE_TYPE_NS(IBC, bus::hexbus, ibc_device) #endif diff --git a/src/devices/bus/ti99/colorbus/colorbus.cpp b/src/devices/bus/ti99/colorbus/colorbus.cpp index 7b0e8bd2f10..40eb2691804 100644 --- a/src/devices/bus/ti99/colorbus/colorbus.cpp +++ b/src/devices/bus/ti99/colorbus/colorbus.cpp @@ -55,15 +55,6 @@ void ti99_colorbus_device::device_config_complete() m_connected = dynamic_cast(subdevices().first()); } -void ti99_colorbus_device::configure_slot() -{ - option_reset(); - option_add("busmouse", TI99_BUSMOUSE); - set_default_option("busmouse"); - set_fixed(false); -} - - /*****************************************************************************/ void device_ti99_colorbus_interface::interface_config_complete() @@ -72,3 +63,8 @@ void device_ti99_colorbus_interface::interface_config_complete() } } } } // end namespace bus::ti99::colorbus + +void ti99_colorbus_options(device_slot_interface &device) +{ + device.option_add("busmouse", TI99_BUSMOUSE); +} diff --git a/src/devices/bus/ti99/colorbus/colorbus.h b/src/devices/bus/ti99/colorbus/colorbus.h index 30bbfed81ef..c32e242dab8 100644 --- a/src/devices/bus/ti99/colorbus/colorbus.h +++ b/src/devices/bus/ti99/colorbus/colorbus.h @@ -43,10 +43,19 @@ protected: class ti99_colorbus_device : public device_t, public device_slot_interface { public: + template + ti99_colorbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : ti99_colorbus_device(mconfig, tag, owner, clock) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + ti99_colorbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); line_state left_button(); // left button is not connected to the V9938 but to a TMS9901 pin void poll(); - void configure_slot(); protected: void device_start() override { } @@ -62,4 +71,6 @@ private: DECLARE_DEVICE_TYPE_NS(TI99_COLORBUS, bus::ti99::colorbus, ti99_colorbus_device) +void ti99_colorbus_options(device_slot_interface &device); + #endif // MAME_BUS_TI99_COLORBUS_COLORBUS_H diff --git a/src/devices/bus/ti99/gromport/gromport.cpp b/src/devices/bus/ti99/gromport/gromport.cpp index 53570f22d79..7b2cc23d72a 100644 --- a/src/devices/bus/ti99/gromport/gromport.cpp +++ b/src/devices/bus/ti99/gromport/gromport.cpp @@ -125,9 +125,6 @@ DEFINE_DEVICE_TYPE_NS(TI99_GROMPORT, bus::ti99::gromport, gromport_device, "grom namespace bus { namespace ti99 { namespace gromport { -#define TRACE_READ 0 -#define TRACE_WRITE 0 - gromport_device::gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TI99_GROMPORT, tag, owner, clock), device_slot_interface(mconfig, *this), @@ -145,7 +142,7 @@ READ8Z_MEMBER(gromport_device::readz) { if (m_connector != nullptr) { - m_connector->readz(space, offset & m_mask, value); + m_connector->readz(space, offset & get_mask(), value); if (m_romgq) LOGMASKED(LOG_READ, "Read %04x -> %02x\n", offset | 0x6000, *value); } } @@ -159,7 +156,7 @@ WRITE8_MEMBER(gromport_device::write) if (m_connector != nullptr) { if (m_romgq) LOGMASKED(LOG_WRITE, "Write %04x <- %02x\n", offset | 0x6000, data); - m_connector->write(space, offset & m_mask, data); + m_connector->write(space, offset & get_mask(), data); } } @@ -263,17 +260,6 @@ ioport_constructor gromport_device::device_input_ports() const return INPUT_PORTS_NAME(gromport); } -void gromport_device::configure_slot(bool for998) -{ - option_reset(); - option_add("single", TI99_GROMPORT_SINGLE); - option_add("multi", TI99_GROMPORT_MULTI); - if (!for998) option_add("gkracker", TI99_GROMPORT_GK); - set_default_option("single"); - set_fixed(false); - set_mask(for998? 0x3fff : 0x1fff); -} - /*************************************************************************** Different versions of cartridge connections @@ -303,3 +289,15 @@ void cartridge_connector_device::device_config_complete() } } } // end namespace bus::ti99::gromport +void ti99_gromport_options(device_slot_interface &device) +{ + device.option_add("single", TI99_GROMPORT_SINGLE); + device.option_add("multi", TI99_GROMPORT_MULTI); + device.option_add("gkracker", TI99_GROMPORT_GK); +} + +void ti99_gromport_options_998(device_slot_interface &device) +{ + device.option_add("single", TI99_GROMPORT_SINGLE); + device.option_add("multi", TI99_GROMPORT_MULTI); +} diff --git a/src/devices/bus/ti99/gromport/gromport.h b/src/devices/bus/ti99/gromport/gromport.h index 37460ed3f7a..60875befc0d 100644 --- a/src/devices/bus/ti99/gromport/gromport.h +++ b/src/devices/bus/ti99/gromport/gromport.h @@ -28,6 +28,16 @@ class cartridge_connector_device; class gromport_device : public device_t, public device_slot_interface { public: + template + gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : gromport_device(mconfig, tag, owner, clock) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + gromport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); DECLARE_READ8Z_MEMBER(readz); DECLARE_WRITE8_MEMBER(write); @@ -38,33 +48,38 @@ public: void set_gromlines(line_state mline, line_state moline, line_state gsq); DECLARE_WRITE_LINE_MEMBER(gclock_in); - void set_mask(int mask) { m_mask = mask; } - - template devcb_base &set_ready_callback(Object &&cb) { return m_console_ready.set_callback(std::forward(cb)); } - template devcb_base &set_reset_callback(Object &&cb) { return m_console_reset.set_callback(std::forward(cb)); } - void cartridge_inserted(); bool is_grom_idle(); auto ready_cb() { return m_console_ready.bind(); } auto reset_cb() { return m_console_reset.bind(); } - void configure_slot(bool for998); protected: virtual void device_start() override; virtual void device_reset() override; virtual void device_config_complete() override; virtual ioport_constructor device_input_ports() const override; + virtual const int get_mask() { return 0x1fff; } private: cartridge_connector_device* m_connector; bool m_reset_on_insert; devcb_write_line m_console_ready; devcb_write_line m_console_reset; - int m_mask; int m_romgq; }; +// Special subclass for 99/8 +class gromport8_device : public gromport_device +{ +public: + template + gromport8_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : gromport_device(mconfig, tag, owner, clock, opts, dflt) { }; +protected: + const int get_mask() override { return 0x3fff; } +}; + class cartridge_connector_device : public device_t { public: @@ -97,5 +112,9 @@ protected: } } } // end namespace bus::ti99::gromport DECLARE_DEVICE_TYPE_NS(TI99_GROMPORT, bus::ti99::gromport, gromport_device) +DECLARE_DEVICE_TYPE_NS(TI99_GROMPORT8, bus::ti99::gromport, gromport8_device) + +void ti99_gromport_options(device_slot_interface &device); +void ti99_gromport_options_998(device_slot_interface &device); #endif // MAME_BUS_TI99_GROMPORT_GROMPORT_H diff --git a/src/devices/bus/ti99/internal/ioport.cpp b/src/devices/bus/ti99/internal/ioport.cpp index f3984425a66..3e769086141 100644 --- a/src/devices/bus/ti99/internal/ioport.cpp +++ b/src/devices/bus/ti99/internal/ioport.cpp @@ -165,21 +165,14 @@ WRITE_LINE_MEMBER(ioport_attached_device::set_ready) m_ioport->m_console_ready(state); } -void ioport_device::configure_slot(int flags) -{ - option_reset(); - if ((flags & WITH_PEB_AND_EVPC)!=0) - { - option_add("peb", TI99_PERIBOX_EV); - set_default_option("peb"); - } - else - { - option_add("peb", TI99_PERIBOX); - set_default_option(nullptr); - } - set_fixed(false); -} - } } } // end namespace bus::ti99::internal +void ti99_ioport_options_plain(device_slot_interface &device) +{ + device.option_add("peb", TI99_PERIBOX); +} + +void ti99_ioport_options_evpc(device_slot_interface &device) +{ + device.option_add("peb", TI99_PERIBOX_EV); +} diff --git a/src/devices/bus/ti99/internal/ioport.h b/src/devices/bus/ti99/internal/ioport.h index 1bca7d53a29..aa30c51da77 100644 --- a/src/devices/bus/ti99/internal/ioport.h +++ b/src/devices/bus/ti99/internal/ioport.h @@ -52,17 +52,21 @@ private: I/O port ********************************************************************/ -enum -{ - PLAIN=0, - WITH_PEB_AND_EVPC -}; - class ioport_device : public device_t, public device_slot_interface { friend class ioport_attached_device; public: + template + ioport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : ioport_device(mconfig, tag, owner, clock) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + ioport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // Methods called from the console @@ -79,8 +83,6 @@ public: auto extint_cb() { return m_console_extint.bind(); } auto ready_cb() { return m_console_ready.bind(); } - void configure_slot(int flags); - protected: void device_start() override; void device_config_complete() override; @@ -96,4 +98,7 @@ private: DECLARE_DEVICE_TYPE_NS(TI99_IOPORT, bus::ti99::internal, ioport_device) +void ti99_ioport_options_plain(device_slot_interface &device); +void ti99_ioport_options_evpc(device_slot_interface &device); + #endif /* __TI99IOPORT__ */ diff --git a/src/devices/bus/ti99/joyport/joyport.cpp b/src/devices/bus/ti99/joyport/joyport.cpp index 536b618eb6b..1a39c0d6dfa 100644 --- a/src/devices/bus/ti99/joyport/joyport.cpp +++ b/src/devices/bus/ti99/joyport/joyport.cpp @@ -95,17 +95,6 @@ void joyport_device::device_config_complete() m_connected = dynamic_cast(subdevices().first()); } -void joyport_device::configure_slot(int flags) -{ - option_reset(); - option_add("twinjoy", TI99_JOYSTICK); - if ((flags & MOUSE)!=0) option_add("mecmouse", TI99_MECMOUSE); - if ((flags & HANDSET)!=0) option_add("handset", TI99_HANDSET); - set_default_option("twinjoy"); - set_fixed(false); -} - - /*****************************************************************************/ void device_ti99_joyport_interface::interface_config_complete() @@ -115,3 +104,21 @@ void device_ti99_joyport_interface::interface_config_complete() } } } // end namespace bus::ti99::joyport +void ti99_joyport_options_plain(device_slot_interface &device) +{ + device.option_add("twinjoy", TI99_JOYSTICK); +} + +void ti99_joyport_options_mouse(device_slot_interface &device) +{ + device.option_add("twinjoy", TI99_JOYSTICK); + device.option_add("mecmouse", TI99_MECMOUSE); +} + +void ti99_joyport_options_994(device_slot_interface &device) +{ + device.option_add("twinjoy", TI99_JOYSTICK); + device.option_add("handset", TI99_HANDSET); + device.option_add("mecmouse", TI99_MECMOUSE); +} + diff --git a/src/devices/bus/ti99/joyport/joyport.h b/src/devices/bus/ti99/joyport/joyport.h index c67ebd74d74..4011efaaf70 100644 --- a/src/devices/bus/ti99/joyport/joyport.h +++ b/src/devices/bus/ti99/joyport/joyport.h @@ -56,13 +56,22 @@ protected: class joyport_device : public device_t, public device_slot_interface { public: + template + joyport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) + : joyport_device(mconfig, tag, owner, clock) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + joyport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); uint8_t read_port(); void write_port(int data); void set_interrupt(int state); void pulse_clock(); auto int_cb() { return m_interrupt.bind(); } - void configure_slot(int flags); protected: void device_start() override; @@ -77,4 +86,8 @@ private: DECLARE_DEVICE_TYPE_NS(TI99_JOYPORT, bus::ti99::joyport, joyport_device) +void ti99_joyport_options_plain(device_slot_interface &device); +void ti99_joyport_options_mouse(device_slot_interface &device); +void ti99_joyport_options_994(device_slot_interface &device); + #endif // MAME_BUS_TI99_JOYPORT_JOYPORT_H diff --git a/src/devices/bus/ti99/peb/evpc.cpp b/src/devices/bus/ti99/peb/evpc.cpp index 98b425ba6ef..254b1d08a27 100644 --- a/src/devices/bus/ti99/peb/evpc.cpp +++ b/src/devices/bus/ti99/peb/evpc.cpp @@ -506,7 +506,9 @@ void snug_enhanced_video_device::device_add_mconfig(machine_config& config) soundgen.add_route(ALL_OUTPUTS, "sound_out", 0.75); // Mouse connected to the color bus of the v9938 - TI99_COLORBUS(config, m_colorbus, 0).configure_slot(); + TI99_COLORBUS(config, m_colorbus, 0, ti99_colorbus_options, "busmouse"); } } } } // end namespace bus::ti99::peb + + diff --git a/src/devices/bus/ti99/peb/peribox.cpp b/src/devices/bus/ti99/peb/peribox.cpp index 0802d1dc1aa..80da29f6dd4 100644 --- a/src/devices/bus/ti99/peb/peribox.cpp +++ b/src/devices/bus/ti99/peb/peribox.cpp @@ -464,43 +464,33 @@ void peribox_device::device_config_complete() m_ready_flag = 0; } -void peribox_device::configure_slot(peribox_slot_device &slot, int number) +void ti99_peribox_slot_standard(device_slot_interface &device) { - slot.set_number(number); - slot.option_reset(); - slot.option_add("32kmem", TI99_32KMEM); - slot.option_add("myarcmem", TI99_MYARCMEM); - slot.option_add("samsmem", TI99_SAMSMEM); - slot.option_add("pcode", TI99_P_CODE); - slot.option_add("hsgpl", TI99_HSGPL); - slot.option_add("tirs232", TI99_RS232); - slot.option_add("speech", TI99_SPEECH); - slot.option_add("horizon", TI99_HORIZON); - slot.option_add("ide", TI99_IDE); - slot.option_add("usbsm", TI99_USBSM); - slot.option_add("bwg", TI99_BWG); - slot.option_add("hfdc", TI99_HFDC); - slot.option_add("tifdc", TI99_FDC); - slot.set_default_option(nullptr); - slot.set_fixed(false); + device.option_add("32kmem", TI99_32KMEM); + device.option_add("myarcmem", TI99_MYARCMEM); + device.option_add("samsmem", TI99_SAMSMEM); + device.option_add("pcode", TI99_P_CODE); + device.option_add("hsgpl", TI99_HSGPL); + device.option_add("tirs232", TI99_RS232); + device.option_add("speech", TI99_SPEECH); + device.option_add("horizon", TI99_HORIZON); + device.option_add("ide", TI99_IDE); + device.option_add("usbsm", TI99_USBSM); + device.option_add("bwg", TI99_BWG); + device.option_add("hfdc", TI99_HFDC); + device.option_add("tifdc", TI99_FDC); } -MACHINE_CONFIG_START(peribox_device::device_add_mconfig) - TI99_PERIBOX_SLOT(config, m_slot2, 0 ); - m_slot2->configure_slot(2); - TI99_PERIBOX_SLOT(config, m_slot3, 0 ); - m_slot3->configure_slot(3); - TI99_PERIBOX_SLOT(config, m_slot4, 0 ); - m_slot4->configure_slot(4); - TI99_PERIBOX_SLOT(config, m_slot5, 0 ); - m_slot5->configure_slot(5); - TI99_PERIBOX_SLOT(config, m_slot6, 0 ); - m_slot6->configure_slot(6); - TI99_PERIBOX_SLOT(config, m_slot7, 0 ); - m_slot7->configure_slot(7); - TI99_PERIBOX_SLOT(config, m_slot8, 0 ); - m_slot8->configure_slot(8); -MACHINE_CONFIG_END +void peribox_device::device_add_mconfig(machine_config &config) +{ + TI99_PERIBOX_SLOT(config, m_slot2, 2, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot3, 3, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot4, 4, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot5, 5, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot6, 6, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot7, 7, ti99_peribox_slot_standard, nullptr); + TI99_PERIBOX_SLOT(config, m_slot8, 8, ti99_peribox_slot_standard, nullptr); +} /**************************************************************************** A variant of the box used for the TI-99/4A with EVPC. @@ -513,26 +503,33 @@ peribox_ev_device::peribox_ev_device(const machine_config &mconfig, const char * m_genmod = false; } -void peribox_ev_device::configure_slot(peribox_slot_device &slot, int number) +void ti99_peribox_slot_evpc(device_slot_interface &device) { - slot.set_number(number); - slot.option_reset(); - slot.option_add("evpc", TI99_EVPC); - slot.option_add("32kmem", TI99_32KMEM); - slot.option_add("myarcmem", TI99_MYARCMEM); - slot.option_add("samsmem", TI99_SAMSMEM); - slot.option_add("pcode", TI99_P_CODE); - slot.option_add("hsgpl", TI99_HSGPL); - slot.option_add("tirs232", TI99_RS232); - slot.option_add("speech", TI99_SPEECH); - slot.option_add("horizon", TI99_HORIZON); - slot.option_add("ide", TI99_IDE); - slot.option_add("usbsm", TI99_USBSM); - slot.option_add("bwg", TI99_BWG); - slot.option_add("hfdc", TI99_HFDC); - slot.option_add("tifdc", TI99_FDC); - if (number==2) slot.set_default_option("evpc"); - slot.set_fixed(false); + device.option_add("evpc", TI99_EVPC); + device.option_add("32kmem", TI99_32KMEM); + device.option_add("myarcmem", TI99_MYARCMEM); + device.option_add("samsmem", TI99_SAMSMEM); + device.option_add("pcode", TI99_P_CODE); + device.option_add("hsgpl", TI99_HSGPL); + device.option_add("tirs232", TI99_RS232); + device.option_add("speech", TI99_SPEECH); + device.option_add("horizon", TI99_HORIZON); + device.option_add("ide", TI99_IDE); + device.option_add("usbsm", TI99_USBSM); + device.option_add("bwg", TI99_BWG); + device.option_add("hfdc", TI99_HFDC); + device.option_add("tifdc", TI99_FDC); +} + +void peribox_ev_device::device_add_mconfig(machine_config &config) +{ + TI99_PERIBOX_SLOT(config, m_slot2, 2, ti99_peribox_slot_evpc, "evpc"); + TI99_PERIBOX_SLOT(config, m_slot3, 3, ti99_peribox_slot_evpc, nullptr); + TI99_PERIBOX_SLOT(config, m_slot4, 4, ti99_peribox_slot_evpc, nullptr); + TI99_PERIBOX_SLOT(config, m_slot5, 5, ti99_peribox_slot_evpc, nullptr); + TI99_PERIBOX_SLOT(config, m_slot6, 6, ti99_peribox_slot_evpc, nullptr); + TI99_PERIBOX_SLOT(config, m_slot7, 7, ti99_peribox_slot_evpc, nullptr); + TI99_PERIBOX_SLOT(config, m_slot8, 8, ti99_peribox_slot_evpc, nullptr); } /**************************************************************************** @@ -563,35 +560,38 @@ peribox_genmod_device::peribox_genmod_device(const machine_config &mconfig, cons // The BwG controller will not run with the Geneve due to its wait state // logic (see bwg.c) -void peribox_gen_device::configure_slot(peribox_slot_device &slot, int number) +void ti99_peribox_slot_geneve(device_slot_interface &device) { - slot.set_number(number); - slot.option_reset(); - slot.option_add("memex", TI99_MEMEX); - slot.option_add("tirs232", TI99_RS232); - slot.option_add("speech", TI99_SPEECH); - slot.option_add("horizon", TI99_HORIZON); - slot.option_add("ide", TI99_IDE); - slot.option_add("usbsm", TI99_USBSM); - slot.option_add("hfdc", TI99_HFDC); - slot.option_add("tifdc", TI99_FDC); - slot.set_fixed(false); + device.option_add("memex", TI99_MEMEX); + device.option_add("tirs232", TI99_RS232); + device.option_add("speech", TI99_SPEECH); + device.option_add("horizon", TI99_HORIZON); + device.option_add("ide", TI99_IDE); + device.option_add("usbsm", TI99_USBSM); + device.option_add("hfdc", TI99_HFDC); + device.option_add("tifdc", TI99_FDC); } -void peribox_genmod_device::configure_slot(peribox_slot_device &slot, int number) +void peribox_gen_device::device_add_mconfig(machine_config &config) { - slot.set_number(number); - slot.option_reset(); - slot.option_add("memex", TI99_MEMEX); - slot.option_add("tirs232", TI99_RS232); - slot.option_add("speech", TI99_SPEECH); - slot.option_add("horizon", TI99_HORIZON); - slot.option_add("ide", TI99_IDE); - slot.option_add("usbsm", TI99_USBSM); - slot.option_add("hfdc", TI99_HFDC); - slot.option_add("tifdc", TI99_FDC); - if (number==2) slot.set_default_option("memex"); - slot.set_fixed(false); + TI99_PERIBOX_SLOT(config, m_slot2, 2, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot3, 3, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot4, 4, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot5, 5, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot6, 6, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot7, 7, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot8, 8, ti99_peribox_slot_geneve, nullptr); +} + +void peribox_genmod_device::device_add_mconfig(machine_config &config) +{ + TI99_PERIBOX_SLOT(config, m_slot2, 2, ti99_peribox_slot_geneve, "memex"); + TI99_PERIBOX_SLOT(config, m_slot3, 3, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot4, 4, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot5, 5, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot6, 6, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot7, 7, ti99_peribox_slot_geneve, nullptr); + TI99_PERIBOX_SLOT(config, m_slot8, 8, ti99_peribox_slot_geneve, nullptr); } /**************************************************************************** @@ -605,26 +605,32 @@ peribox_sg_device::peribox_sg_device(const machine_config &mconfig, const char * m_genmod = false; } -void peribox_sg_device::configure_slot(peribox_slot_device &slot, int number) +void ti99_peribox_slot_sgcpu(device_slot_interface &device) { - slot.set_number(number); - slot.option_reset(); - slot.option_add("evpc", TI99_EVPC); - slot.option_add("myarcmem", TI99_MYARCMEM); - slot.option_add("samsmem", TI99_SAMSMEM); - slot.option_add("pcode", TI99_P_CODE); - slot.option_add("hsgpl", TI99_HSGPL); - slot.option_add("tirs232", TI99_RS232); - slot.option_add("speech", TI99_SPEECH); - slot.option_add("horizon", TI99_HORIZON); - slot.option_add("ide", TI99_IDE); - slot.option_add("usbsm", TI99_USBSM); - slot.option_add("bwg", TI99_BWG); - slot.option_add("hfdc", TI99_HFDC); - slot.option_add("tifdc", TI99_FDC); - if (number==2) slot.set_default_option("evpc"); - else if (number==3) slot.set_default_option("hsgpl"); - slot.set_fixed(false); + device.option_add("evpc", TI99_EVPC); + device.option_add("myarcmem", TI99_MYARCMEM); + device.option_add("samsmem", TI99_SAMSMEM); + device.option_add("pcode", TI99_P_CODE); + device.option_add("hsgpl", TI99_HSGPL); + device.option_add("tirs232", TI99_RS232); + device.option_add("speech", TI99_SPEECH); + device.option_add("horizon", TI99_HORIZON); + device.option_add("ide", TI99_IDE); + device.option_add("usbsm", TI99_USBSM); + device.option_add("bwg", TI99_BWG); + device.option_add("hfdc", TI99_HFDC); + device.option_add("tifdc", TI99_FDC); +} + +void peribox_sg_device::device_add_mconfig(machine_config &config) +{ + TI99_PERIBOX_SLOT(config, m_slot2, 2, ti99_peribox_slot_sgcpu, "evpc"); + TI99_PERIBOX_SLOT(config, m_slot3, 3, ti99_peribox_slot_sgcpu, "hsgpl"); + TI99_PERIBOX_SLOT(config, m_slot4, 4, ti99_peribox_slot_sgcpu, nullptr); + TI99_PERIBOX_SLOT(config, m_slot5, 5, ti99_peribox_slot_sgcpu, nullptr); + TI99_PERIBOX_SLOT(config, m_slot6, 6, ti99_peribox_slot_sgcpu, nullptr); + TI99_PERIBOX_SLOT(config, m_slot7, 7, ti99_peribox_slot_sgcpu, nullptr); + TI99_PERIBOX_SLOT(config, m_slot8, 8, ti99_peribox_slot_sgcpu, nullptr); } /*************************************************************************** @@ -699,12 +705,6 @@ void peribox_slot_device::device_config_complete() peb->set_slot_loaded(m_slotnumber, m_card ? this : nullptr); } -void peribox_slot_device::configure_slot(int number) -{ - peribox_device *peb = dynamic_cast(owner()); - if (peb) peb->configure_slot(*this, number); -} - /* These methods are called from the expansion cards. They add the slot number to identify the slot to the box. diff --git a/src/devices/bus/ti99/peb/peribox.h b/src/devices/bus/ti99/peb/peribox.h index 7ba65b5cbd0..a936a5346ef 100644 --- a/src/devices/bus/ti99/peb/peribox.h +++ b/src/devices/bus/ti99/peb/peribox.h @@ -65,8 +65,7 @@ protected: virtual void device_start() override; virtual void device_config_complete() override; - void device_add_mconfig(machine_config &config) override; - virtual void configure_slot(peribox_slot_device &slot, int number); + virtual void device_add_mconfig(machine_config &config) override; // Next three methods call back the console via slot 1 devcb_write_line m_slot1_inta; // INTA line (Box to console) @@ -126,7 +125,7 @@ public: peribox_sg_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - void configure_slot(peribox_slot_device &slot, int number) override; + void device_add_mconfig(machine_config &config) override; }; /* @@ -138,7 +137,7 @@ public: peribox_ev_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - void configure_slot(peribox_slot_device &slot, int number) override; + void device_add_mconfig(machine_config &config) override; }; @@ -152,7 +151,7 @@ public: protected: peribox_gen_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - virtual void configure_slot(peribox_slot_device &slot, int number) override; + virtual void device_add_mconfig(machine_config &config) override; }; /* @@ -164,7 +163,7 @@ public: peribox_genmod_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - void configure_slot(peribox_slot_device &slot, int number) override; + void device_add_mconfig(machine_config &config) override; }; /***************************************************************************** @@ -217,6 +216,17 @@ class peribox_slot_device : public device_t, public device_slot_interface { friend class peribox_device; public: + template + peribox_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, int slot, U &&opts, const char *dflt) + : peribox_slot_device(mconfig, tag, owner, 0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + m_slotnumber = slot; + } + peribox_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // Called from the box (direction to card) @@ -239,7 +249,6 @@ public: // called from the box itself void set_genmod(bool set); - void configure_slot(int number); void set_number(int number) { m_slotnumber = number; } protected: @@ -262,4 +271,9 @@ DECLARE_DEVICE_TYPE_NS(TI99_PERIBOX_SG, bus::ti99::peb, peribox_sg_device) DECLARE_DEVICE_TYPE_NS(TI99_PERIBOX_GEN, bus::ti99::peb, peribox_gen_device) DECLARE_DEVICE_TYPE_NS(TI99_PERIBOX_GENMOD, bus::ti99::peb, peribox_genmod_device) +void ti99_peribox_slot_standard(device_slot_interface &device); +void ti99_peribox_slot_evpc(device_slot_interface &device); +void ti99_peribox_slot_geneve(device_slot_interface &device); +void ti99_peribox_slot_sgcpu(device_slot_interface &device); + #endif // MAME_BUS_TI99_PEB_PERIBOX_H diff --git a/src/mame/drivers/geneve.cpp b/src/mame/drivers/geneve.cpp index 27e0eb8a61d..287a1d14059 100644 --- a/src/mame/drivers/geneve.cpp +++ b/src/mame/drivers/geneve.cpp @@ -773,8 +773,8 @@ MACHINE_CONFIG_START(geneve_state::geneve_common) // User interface devices GENEVE_KEYBOARD(config, m_keyboard, 0).int_cb().set(FUNC(geneve_state::keyboard_interrupt)); - TI99_JOYPORT(config, m_joyport, 0).configure_slot(bus::ti99::joyport::PLAIN); - TI99_COLORBUS(config, m_colorbus, 0).configure_slot(); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_plain, "twinjoy"); + TI99_COLORBUS(config, m_colorbus, 0, ti99_colorbus_options, "busmouse"); // PFM expansion AT29C040(config, GENEVE_PFM512_TAG); diff --git a/src/mame/drivers/ti99_2.cpp b/src/mame/drivers/ti99_2.cpp index c2eeee8afe3..85604d10689 100644 --- a/src/mame/drivers/ti99_2.cpp +++ b/src/mame/drivers/ti99_2.cpp @@ -169,6 +169,7 @@ #include "bus/ti99/internal/992board.h" #include "machine/ram.h" #include "imagedev/cassette.h" +#include "bus/hexbus/hexbus.h" #define TI992_SCREEN_TAG "screen" #define TI992_ROM "rom_region" @@ -475,7 +476,7 @@ void ti99_2_state::ti99_2(machine_config& config) CASSETTE(config, "cassette", 0); // Hexbus - HEXBUS(config, TI_HEXBUS_TAG, 0).configure_slot(); + HEXBUS(config, TI_HEXBUS_TAG, 0, hexbus_options, nullptr); } /* diff --git a/src/mame/drivers/ti99_4p.cpp b/src/mame/drivers/ti99_4p.cpp index 7c1c73a25ee..77334665dd8 100644 --- a/src/mame/drivers/ti99_4p.cpp +++ b/src/mame/drivers/ti99_4p.cpp @@ -1052,7 +1052,7 @@ void ti99_4p_state::ti99_4p_60hz(machine_config& config) CASSETTE(config, "cassette", 0).add_route(ALL_OUTPUTS, "cass_out", 0.25); // Joystick port - TI99_JOYPORT(config, m_joyport, 0).configure_slot(bus::ti99::joyport::PLAIN); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_plain, "twinjoy"); } diff --git a/src/mame/drivers/ti99_4x.cpp b/src/mame/drivers/ti99_4x.cpp index 0947d0818bc..b1aa21d0af1 100644 --- a/src/mame/drivers/ti99_4x.cpp +++ b/src/mame/drivers/ti99_4x.cpp @@ -883,10 +883,9 @@ void ti99_4x_state::ti99_4_common(machine_config& config) TI99_DATAMUX(config, m_datamux, 0).ready_cb().set(FUNC(ti99_4x_state::console_ready_dmux)); // Cartridge port (aka GROMport) - TI99_GROMPORT(config, m_gromport, 0); + TI99_GROMPORT(config, m_gromport, 0, ti99_gromport_options, "single"); m_gromport->ready_cb().set(FUNC(ti99_4x_state::console_ready_cart)); m_gromport->reset_cb().set(FUNC(ti99_4x_state::console_reset)); - m_gromport->configure_slot(false); // Scratch pad RAM 256 bytes RAM(config, TI99_PADRAM_TAG).set_default_size("256").set_default_value(0); @@ -897,11 +896,6 @@ void ti99_4x_state::ti99_4_common(machine_config& config) // Software list SOFTWARE_LIST(config, "cart_list_ti99").set_type("ti99_cart", SOFTWARE_LIST_ORIGINAL_SYSTEM); - // I/O port - TI99_IOPORT(config, m_ioport, 0); - m_ioport->extint_cb().set(FUNC(ti99_4x_state::extint)); - m_ioport->ready_cb().set(TI99_DATAMUX_TAG, FUNC(bus::ti99::internal::datamux_device::ready_line)); - // Cassette drives. Second drive is record-only. SPEAKER(config, "cass_out").front_center(); CASSETTE(config, "cassette1", 0).add_route(ALL_OUTPUTS, "cass_out", 0.25); @@ -936,7 +930,9 @@ void ti99_4x_state::ti99_4(machine_config& config) m_tms9901->p_out_cb(0).set(FUNC(ti99_4x_state::handset_ack)); // Input/output port: normal config - m_ioport->configure_slot(bus::ti99::internal::PLAIN); + TI99_IOPORT(config, m_ioport, 0, ti99_ioport_options_plain, nullptr); + m_ioport->extint_cb().set(FUNC(ti99_4x_state::extint)); + m_ioport->ready_cb().set(TI99_DATAMUX_TAG, FUNC(bus::ti99::internal::datamux_device::ready_line)); // Sound hardware (not in EVPC variant) SPEAKER(config, "sound_out").front_center(); @@ -945,8 +941,7 @@ void ti99_4x_state::ti99_4(machine_config& config) soundgen.add_route(ALL_OUTPUTS, "sound_out", 0.75); // Joystick port. We can connect a joyport mouse or a handset (99/4-specific). - TI99_JOYPORT(config, m_joyport, 0); - m_joyport->configure_slot(bus::ti99::joyport::MOUSE | bus::ti99::joyport::HANDSET); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_994, "twinjoy"); m_joyport->int_cb().set(FUNC(ti99_4x_state::handset_interrupt_in)); } @@ -1011,7 +1006,9 @@ void ti99_4x_state::ti99_4a(machine_config& config) m_tms9901->p_out_cb(5).set(FUNC(ti99_4x_state::alphaW)); // Input/output port: Normal config - m_ioport->configure_slot(bus::ti99::internal::PLAIN); + TI99_IOPORT(config, m_ioport, 0, ti99_ioport_options_plain, nullptr); + m_ioport->extint_cb().set(FUNC(ti99_4x_state::extint)); + m_ioport->ready_cb().set(TI99_DATAMUX_TAG, FUNC(bus::ti99::internal::datamux_device::ready_line)); // Sound hardware (not in EVPC variant) SPEAKER(config, "sound_out").front_center(); @@ -1020,7 +1017,7 @@ void ti99_4x_state::ti99_4a(machine_config& config) soundgen.add_route(ALL_OUTPUTS, "sound_out", 0.75); // Joystick port - TI99_JOYPORT(config, m_joyport, 0).configure_slot(bus::ti99::joyport::MOUSE); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_mouse, "twinjoy"); } /* @@ -1128,11 +1125,13 @@ void ti99_4x_state::ti99_4ev_60hz(machine_config& config) TI99_EVPCCONN(config, TI99_EVPC_CONN_TAG, 0).vdpint_cb().set(FUNC(ti99_4x_state::video_interrupt_evpc_in)); // Input/output port: Configure for EVPC - m_ioport->configure_slot(bus::ti99::internal::WITH_PEB_AND_EVPC); + TI99_IOPORT(config, m_ioport, 0, ti99_ioport_options_evpc, "peb"); + m_ioport->extint_cb().set(FUNC(ti99_4x_state::extint)); + m_ioport->ready_cb().set(TI99_DATAMUX_TAG, FUNC(bus::ti99::internal::datamux_device::ready_line)); // Joystick port // No joyport mouse, since we have a bus mouse with the EVPC - TI99_JOYPORT(config, m_joyport, 0).configure_slot(bus::ti99::joyport::PLAIN); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_plain, "twinjoy"); } /***************************************************************************** diff --git a/src/mame/drivers/ti99_8.cpp b/src/mame/drivers/ti99_8.cpp index 119fc5c4e72..dd5813ae53e 100644 --- a/src/mame/drivers/ti99_8.cpp +++ b/src/mame/drivers/ti99_8.cpp @@ -768,10 +768,9 @@ void ti99_8_state::ti99_8(machine_config& config) m_mainboard->hold_cb().set(FUNC(ti99_8_state::cpu_hold)); // Cartridge port - TI99_GROMPORT(config, m_gromport, 0); + TI99_GROMPORT8(config, m_gromport, 0, ti99_gromport_options_998, "single"); m_gromport->ready_cb().set(TI998_MAINBOARD_TAG, FUNC(mainboard8_device::system_grom_ready)); m_gromport->reset_cb().set(FUNC(ti99_8_state::console_reset)); - m_gromport->configure_slot(true); // RAM RAM(config, TI998_SRAM_TAG).set_default_size("2K").set_default_value(0); @@ -781,13 +780,12 @@ void ti99_8_state::ti99_8(machine_config& config) SOFTWARE_LIST(config, "cart_list_ti99").set_type("ti99_cart", SOFTWARE_LIST_ORIGINAL_SYSTEM); // I/O port - TI99_IOPORT(config, m_ioport, 0); - m_ioport->configure_slot(bus::ti99::internal::PLAIN); + TI99_IOPORT(config, m_ioport, 0, ti99_ioport_options_plain, nullptr); m_ioport->extint_cb().set(FUNC(ti99_8_state::extint)); m_ioport->ready_cb().set(TI998_MAINBOARD_TAG, FUNC(mainboard8_device::pbox_ready)); // Hexbus - HEXBUS(config, TI_HEXBUS_TAG, 0).configure_slot(); + HEXBUS(config, TI_HEXBUS_TAG, 0, hexbus_options, nullptr); // Sound hardware SPEAKER(config, "sound_out").front_center(); @@ -902,7 +900,7 @@ void ti99_8_state::ti99_8(machine_config& config) p3grom2.set_region_and_ident(TI998_GROMLIB3_REG, 0x4000, 2); // Joystick port - TI99_JOYPORT(config, m_joyport, 0).configure_slot(bus::ti99::joyport::MOUSE); + TI99_JOYPORT(config, m_joyport, 0, ti99_joyport_options_mouse, "twinjoy"); } /*