summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/bus/coco/coco_dwsock.cpp10
-rw-r--r--src/devices/bus/megadrive/jcart.cpp16
-rw-r--r--src/devices/bus/mtx/sdx.cpp2
-rw-r--r--src/devices/bus/sbus/sbus.cpp2
-rw-r--r--src/devices/bus/sbus/sbus.h14
-rw-r--r--src/emu/devfind.h48
-rw-r--r--src/mame/drivers/maxaflex.cpp4
-rw-r--r--src/mame/drivers/meyc8088.cpp8
-rw-r--r--src/mame/drivers/sun4.cpp2
-rw-r--r--src/mame/drivers/topspeed.cpp10
-rw-r--r--src/mame/video/dooyong.h2
11 files changed, 72 insertions, 46 deletions
diff --git a/src/devices/bus/coco/coco_dwsock.cpp b/src/devices/bus/coco/coco_dwsock.cpp
index 96cfd234f8c..b970458c91c 100644
--- a/src/devices/bus/coco/coco_dwsock.cpp
+++ b/src/devices/bus/coco/coco_dwsock.cpp
@@ -80,7 +80,7 @@ beckerport_device::~beckerport_device()
device_start
-------------------------------------------------*/
-void beckerport_device::device_start(void)
+void beckerport_device::device_start()
{
char chAddress[64];
@@ -104,7 +104,7 @@ void beckerport_device::device_start(void)
device_stop
-------------------------------------------------*/
-void beckerport_device::device_stop(void)
+void beckerport_device::device_stop()
{
if (m_pSocket)
{
@@ -117,7 +117,7 @@ void beckerport_device::device_stop(void)
device_config_complete
-------------------------------------------------*/
-void beckerport_device::device_config_complete(void)
+void beckerport_device::device_config_complete()
{
m_hostname = "127.0.0.1";
m_dwtcpport = 65504;
@@ -198,9 +198,9 @@ void beckerport_device::write(offs_t offset, u8 data)
update_port
-------------------------------------------------*/
-void beckerport_device::update_port(void)
+void beckerport_device::update_port()
{
device_stop();
- m_dwtcpport = m_dwconfigport.read_safe(65504);
+ m_dwtcpport = m_dwconfigport->read();
device_start();
}
diff --git a/src/devices/bus/megadrive/jcart.cpp b/src/devices/bus/megadrive/jcart.cpp
index 26c99b2ef5f..4bda9522e9d 100644
--- a/src/devices/bus/megadrive/jcart.cpp
+++ b/src/devices/bus/megadrive/jcart.cpp
@@ -165,14 +165,14 @@ uint16_t md_jcart_device::read(offs_t offset)
if (m_jcart_io_data[0] & 0x40)
{
- joy[0] = m_jcart3.read_safe(0);
- joy[1] = m_jcart4.read_safe(0);
+ joy[0] = m_jcart3->read();
+ joy[1] = m_jcart4->read();
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
else
{
- joy[0] = ((m_jcart3.read_safe(0) & 0xc0) >> 2) | (m_jcart3.read_safe(0) & 0x03);
- joy[1] = ((m_jcart4.read_safe(0) & 0xc0) >> 2) | (m_jcart4.read_safe(0) & 0x03);
+ joy[0] = ((m_jcart3->read() & 0xc0) >> 2) | (m_jcart3->read() & 0x03);
+ joy[1] = ((m_jcart4->read() & 0xc0) >> 2) | (m_jcart4->read() & 0x03);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
}
@@ -208,14 +208,14 @@ uint16_t md_seprom_codemast_device::read(offs_t offset)
if (m_jcart_io_data[0] & 0x40)
{
- joy[0] = m_jcart3.read_safe(0);
- joy[1] = m_jcart4.read_safe(0);
+ joy[0] = m_jcart3->read();
+ joy[1] = m_jcart4->read();
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
else
{
- joy[0] = ((m_jcart3.read_safe(0) & 0xc0) >> 2) | (m_jcart3.read_safe(0) & 0x03);
- joy[1] = ((m_jcart4.read_safe(0) & 0xc0) >> 2) | (m_jcart4.read_safe(0) & 0x03);
+ joy[0] = ((m_jcart3->read() & 0xc0) >> 2) | (m_jcart3->read() & 0x03);
+ joy[1] = ((m_jcart4->read() & 0xc0) >> 2) | (m_jcart4->read() & 0x03);
return (m_jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
}
diff --git a/src/devices/bus/mtx/sdx.cpp b/src/devices/bus/mtx/sdx.cpp
index 09e7199ac53..150ff7b6d1a 100644
--- a/src/devices/bus/mtx/sdx.cpp
+++ b/src/devices/bus/mtx/sdx.cpp
@@ -281,7 +281,7 @@ uint8_t mtx_sdx_device::sdx_status_r()
uint8_t data = 0x00;
- data |= m_dsw[BIT(m_control, 0)].read_safe(0x0f) & 0x0f;
+ data |= m_dsw[BIT(m_control, 0)]->read() & 0x0f;
data |= (m_floppy0->get_device() && m_floppy1->get_device()) ? 0x10 : 0x00;
diff --git a/src/devices/bus/sbus/sbus.cpp b/src/devices/bus/sbus/sbus.cpp
index 4dff2c5db9b..01f753f12f5 100644
--- a/src/devices/bus/sbus/sbus.cpp
+++ b/src/devices/bus/sbus/sbus.cpp
@@ -85,7 +85,7 @@ sbus_device::sbus_device(const machine_config &mconfig, device_type type, const
, device_memory_interface(mconfig, *this)
, m_space_config("SBus Space", ENDIANNESS_BIG, 32, 32, 0, address_map_constructor())
, m_maincpu(*this, finder_base::DUMMY_TAG)
- , m_type1space(*this, finder_base::DUMMY_TAG)
+ , m_type1space(*this, finder_base::DUMMY_TAG, -1)
, m_irq_cb(*this)
, m_buserr(*this)
{
diff --git a/src/devices/bus/sbus/sbus.h b/src/devices/bus/sbus/sbus.h
index c6ad513f4ca..2c66318c8aa 100644
--- a/src/devices/bus/sbus/sbus.h
+++ b/src/devices/bus/sbus/sbus.h
@@ -58,20 +58,18 @@ class sbus_device : public device_t,
public:
// construction/destruction
template <typename T, typename U>
- sbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&space_tag)
+ sbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&space_tag, int space_num)
: sbus_device(mconfig, tag, owner, clock)
{
- set_cpu_tag(std::forward<T>(cpu_tag));
- set_space_tag(std::forward<U>(space_tag));
+ set_cpu(std::forward<T>(cpu_tag));
+ set_type1space(std::forward<U>(space_tag), space_num);
}
sbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// inline configuration
- template <typename T> void set_cpu_tag(T &&tag) { m_maincpu.set_tag(std::forward<T>(tag)); }
- template <typename T> void set_space_tag(T &&tag) { m_type1space.set_tag(std::forward<T>(tag)); }
-
- // devcb3
+ template <typename T> void set_cpu(T &&tag) { m_maincpu.set_tag(std::forward<T>(tag)); }
+ template <typename T> void set_type1space(T &&tag, int num) { m_type1space.set_tag(std::forward<T>(tag), num); }
template <unsigned Line> auto irq() { return m_irq_cb[Line].bind(); }
auto buserr() { return m_buserr.bind(); }
@@ -101,7 +99,7 @@ protected:
// internal state
required_device<sparc_base_device> m_maincpu;
- required_device<address_map_bank_device> m_type1space;
+ required_address_space m_type1space;
address_space *m_space;
devcb_write_line::array<7> m_irq_cb;
diff --git a/src/emu/devfind.h b/src/emu/devfind.h
index 36628b2721d..88d47f25aed 100644
--- a/src/emu/devfind.h
+++ b/src/emu/devfind.h
@@ -836,6 +836,44 @@ protected:
template <unsigned Count> using memory_bank_array_creator = object_array_finder<memory_bank_creator, Count>;
+/// \brief Base class for optional I/O port finders
+///
+/// Adds helpers for to test whether the I/O port was found, and to read
+/// the port value or return a default if the I/O port was not found.
+template <>
+class object_finder_base<ioport_port, false> : public object_finder_common_base<ioport_port, false>
+{
+public:
+ /// \brief Read I/O port if found or return default value
+ ///
+ /// If the I/O port was found, this reads a value from the I/O port
+ /// and returns it. If the I/O port was not found, the default
+ /// value (supplied as a parameter) is returned.
+ /// \param [in] defval Value to return if I/O port was not found.
+ /// \return Value read from I/O port if found, or supplied default
+ /// value otherwise.
+ ioport_value read_safe(ioport_value defval) { return this->m_target ? this->m_target->read() : defval; }
+
+ /// \brief Return whether target has been found
+ ///
+ /// Works on the assumption that the target object pointer will
+ /// be non-null if the target has been found, and null
+ /// otherwise.
+ /// \return True if object has been found, or false otherwise.
+ bool found() const { return this->m_target != nullptr; }
+
+ /// \brief Cast-to-Boolean operator
+ ///
+ /// Allows truth tests to test whether it's safe to dereference
+ /// the object, similar to pointers and various C++ standard
+ /// library objects.
+ /// \return True if safe to dereference, or false otherwise.
+ explicit operator bool() const { return this->m_target != nullptr; }
+
+ using object_finder_common_base<ioport_port, false>::object_finder_common_base;
+};
+
+
/// \brief I/O port finder template
///
/// Template argument is whether the I/O port is required. It is a
@@ -854,16 +892,6 @@ public:
/// remains valid until resolution time.
ioport_finder(device_t &base, char const *tag);
- /// \brief Read I/O port if found or return default value
- ///
- /// If the I/O port was found, this reads a value from the I/O port
- /// and returns it. If the I/O port was not found, the default
- /// value (supplied as a parameter) is returned.
- /// \param [in] defval Value to return if I/O port was not found.
- /// \return Value read from I/O port if found, or supplied default
- /// value otherwise.
- ioport_value read_safe(ioport_value defval) { return this->m_target ? this->m_target->read() : defval; }
-
private:
/// \brief Find I/O port
///
diff --git a/src/mame/drivers/maxaflex.cpp b/src/mame/drivers/maxaflex.cpp
index bb7a3d01754..fdc24aa5c5b 100644
--- a/src/mame/drivers/maxaflex.cpp
+++ b/src/mame/drivers/maxaflex.cpp
@@ -285,12 +285,12 @@ INPUT_PORTS_END
uint8_t maxaflex_state::pia_pa_r()
{
- return atari_input_disabled() ? 0xff : m_joy01.read_safe(0);
+ return atari_input_disabled() ? 0xff : m_joy01->read();
}
uint8_t maxaflex_state::pia_pb_r()
{
- return atari_input_disabled() ? 0xff : m_joy23.read_safe(0);
+ return atari_input_disabled() ? 0xff : m_joy23->read();
}
diff --git a/src/mame/drivers/meyc8088.cpp b/src/mame/drivers/meyc8088.cpp
index ebb3568b920..24c9cbb5068 100644
--- a/src/mame/drivers/meyc8088.cpp
+++ b/src/mame/drivers/meyc8088.cpp
@@ -244,10 +244,10 @@ uint8_t meyc8088_state::input_r()
uint8_t ret = 0xff;
// multiplexed switch inputs
- if (~m_common & 1) ret &= m_switches[0].read_safe(0); // bit switches
- if (~m_common & 2) ret &= m_switches[1].read_safe(0); // control switches
- if (~m_common & 4) ret &= m_switches[2].read_safe(0); // light switches
- if (~m_common & 8) ret &= m_switches[3].read_safe(0); // light switches
+ if (~m_common & 1) ret &= m_switches[0]->read(); // bit switches
+ if (~m_common & 2) ret &= m_switches[1]->read(); // control switches
+ if (~m_common & 4) ret &= m_switches[2]->read(); // light switches
+ if (~m_common & 8) ret &= m_switches[3]->read(); // light switches
return ret;
}
diff --git a/src/mame/drivers/sun4.cpp b/src/mame/drivers/sun4.cpp
index 713d4d7c6ac..1059bfe3741 100644
--- a/src/mame/drivers/sun4.cpp
+++ b/src/mame/drivers/sun4.cpp
@@ -1494,7 +1494,7 @@ void sun4c_state::sun4c(machine_config &config)
m_maincpu->set_mmu(m_mmu);
// SBus
- SBUS(config, m_sbus, 20'000'000, "maincpu", "type1");
+ SBUS(config, m_sbus, 20'000'000, m_maincpu, m_type1space, 0);
m_sbus->irq<0>().set(FUNC(sun4c_state::sbus_irq_w<SPARC_IRQ1>));
m_sbus->irq<1>().set(FUNC(sun4c_state::sbus_irq_w<SPARC_IRQ2>));
m_sbus->irq<2>().set(FUNC(sun4c_state::sbus_irq_w<SPARC_IRQ3>));
diff --git a/src/mame/drivers/topspeed.cpp b/src/mame/drivers/topspeed.cpp
index 5550b21e71c..2cd71f6691d 100644
--- a/src/mame/drivers/topspeed.cpp
+++ b/src/mame/drivers/topspeed.cpp
@@ -192,7 +192,7 @@ u8 topspeed_state::input_bypass_r()
{
// Read port number
const u8 port = m_tc0040ioc->port_r();
- const u16 steer = 0xff80 + m_steer.read_safe(0);
+ const u16 steer = 0xff80 + m_steer->read();
switch (port)
{
@@ -209,14 +209,14 @@ u8 topspeed_state::input_bypass_r()
CUSTOM_INPUT_MEMBER(topspeed_state::gas_pedal_r)
{
- static const u8 retval[8] = { 0,1,3,2,6,7,5,4 };
- return retval[m_gas.read_safe(0) & 7];
+ static constexpr u8 retval[8] = { 0,1,3,2,6,7,5,4 };
+ return retval[m_gas->read() & 7];
}
CUSTOM_INPUT_MEMBER(topspeed_state::brake_pedal_r)
{
- static const u8 retval[8] = { 0,1,3,2,6,7,5,4 };
- return retval[m_brake.read_safe(0) & 7];
+ static constexpr u8 retval[8] = { 0,1,3,2,6,7,5,4 };
+ return retval[m_brake->read() & 7];
}
// TODO: proper motorcpu hook-up
diff --git a/src/mame/video/dooyong.h b/src/mame/video/dooyong.h
index bc871d94fb3..31846057958 100644
--- a/src/mame/video/dooyong.h
+++ b/src/mame/video/dooyong.h
@@ -16,7 +16,7 @@ DECLARE_DEVICE_TYPE(DOOYONG_RAM_TILEMAP, dooyong_ram_tilemap_device)
class dooyong_tilemap_device_base : public device_t
{
public:
- template <typename T> void set_gfxdecode_tag(T &&cpu_tag) { m_gfxdecode.set_tag(std::forward<T>(cpu_tag)); }
+ template <typename T> void set_gfxdecode_tag(T &&gfxdecode_tag) { m_gfxdecode.set_tag(std::forward<T>(gfxdecode_tag)); }
void set_gfxnum(int gfxnum) { m_gfxnum = gfxnum; }
void draw(screen_device &screen, bitmap_ind16 &dest, rectangle const &cliprect, u32 flags, u8 priority, u8 priority_mask = 0xff);