diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2014-05-13 17:05:43 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2014-05-13 17:05:43 +0000 |
commit | 55bf85dc99639edb974414be564480babc1a9a4f (patch) | |
tree | 53d9748b42b4cc8b2bc2045c4d16cfcd50beed28 /src/emu | |
parent | f5d20c68501e01c83b4c42ad001d826bb1b24370 (diff) |
farewell devcb (nw)
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/devcb.c | 1310 | ||||
-rw-r--r-- | src/emu/devcb.h | 770 | ||||
-rw-r--r-- | src/emu/emu.h | 1 | ||||
-rw-r--r-- | src/emu/emu.mak | 1 |
4 files changed, 0 insertions, 2082 deletions
diff --git a/src/emu/devcb.c b/src/emu/devcb.c deleted file mode 100644 index 7060f331320..00000000000 --- a/src/emu/devcb.c +++ /dev/null @@ -1,1310 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** - - devcb.c - - Device callback interface helpers. - -***************************************************************************/ - -#include "emu.h" - - -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// special identifiers used to discover NULL functions -UINT8 devcb_resolved_read_line::s_null; -UINT8 devcb_resolved_write_line::s_null; -UINT8 devcb_resolved_read8::s_null; -UINT8 devcb_resolved_write8::s_null; -UINT8 devcb_resolved_read16::s_null; -UINT8 devcb_resolved_write16::s_null; -UINT8 devcb_resolved_read32::s_null; -UINT8 devcb_resolved_write32::s_null; -UINT8 devcb_resolved_read64::s_null; -UINT8 devcb_resolved_write64::s_null; - - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> devcb_resolver - -class devcb_resolver -{ -public: - static ioport_port *resolve_port(const char *tag, device_t ¤t); - static device_t *resolve_device(int index, const char *tag, device_t ¤t); - static device_execute_interface *resolve_execute_interface(const char *tag, device_t ¤t); -}; - - - -//************************************************************************** -// DEVCB RESOLVER -//************************************************************************** - -//------------------------------------------------- -// resolve_port - resolve to an input port object -// based on the provided tag -//------------------------------------------------- - -ioport_port *devcb_resolver::resolve_port(const char *tag, device_t ¤t) -{ - astring fullname; - ioport_port *result = current.ioport(current.siblingtag(fullname, tag)); - if (result == NULL) - throw emu_fatalerror("Unable to find input port '%s' (requested by %s '%s')", fullname.cstr(), current.name(), current.tag()); - return result; -} - - -//------------------------------------------------- -// resolve_device - resolve to a device given -// a tag and special index type -//------------------------------------------------- - -device_t *devcb_resolver::resolve_device(int index, const char *tag, device_t ¤t) -{ - device_t *result = current.siblingdevice(tag); - if (result == NULL) - throw emu_fatalerror("Unable to resolve device '%s' (requested by callback to %s '%s')", tag, current.name(), current.tag()); - return result; -} - - -//------------------------------------------------- -// resolve_execute_interface - resolve to an -// execute interface on a device given a device -// tag -//------------------------------------------------- - -device_execute_interface *devcb_resolver::resolve_execute_interface(const char *tag, device_t ¤t) -{ - // find our target device - device_t *targetdev = current.siblingdevice(tag); - if (targetdev == NULL) - throw emu_fatalerror("Unable to resolve device '%s' (requested by %s '%s')", tag, current.name(), current.tag()); - - // make sure the target device has an execute interface - device_execute_interface *exec; - if (!targetdev->interface(exec)) - throw emu_fatalerror("Device '%s' (requested by %s '%s') has no execute interface", tag, current.name(), current.tag()); - - return exec; -} - - -//************************************************************************** -// DEVCB RESOLVED READ LINE -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_read_line - empty constructor -//------------------------------------------------- - -devcb_resolved_read_line::devcb_resolved_read_line() -{ - m_object.port = NULL; - m_helper.read_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_read_line::resolve(const devcb_read_line &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_object.constant = 0; - m_helper.null_indicator = &s_null; - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(&devcb_resolved_read_line::from_constant, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(&devcb_resolved_read_line::from_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.readline != NULL) - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(desc.readline, desc.name, m_object.device); - else - { - m_helper.read8_device = desc.readdevice; - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(&devcb_resolved_read_line::from_read8, desc.name, this); - } - break; - - case DEVCB_TYPE_CONSTANT: - m_object.constant = desc.index; - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(&devcb_resolved_read_line::from_constant, "constant", this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_read_line_delegate *>(this) = devcb_read_line_delegate(&devcb_resolved_read_line::from_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// from_port - helper to convert from an I/O port -// value to a line value -//------------------------------------------------- - -int devcb_resolved_read_line::from_port() -{ - return (m_object.port->read() & 1) ? ASSERT_LINE : CLEAR_LINE; -} - - -//------------------------------------------------- -// from_read8 - helper to convert from an 8-bit -// memory read value to a line value -//------------------------------------------------- - -int devcb_resolved_read_line::from_read8() -{ - return ((*m_helper.read8_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), 0, 0xff) & 1) ? ASSERT_LINE : CLEAR_LINE; -} - - -//------------------------------------------------- -// from_constant - helper to convert from a -// constant value to a line value -//------------------------------------------------- - -int devcb_resolved_read_line::from_constant() -{ - return (m_object.constant & 1) ? ASSERT_LINE : CLEAR_LINE; -} - -//------------------------------------------------- -// from_constant - helper to convert from a -// unmap value to a line value -//------------------------------------------------- - -int devcb_resolved_read_line::from_unmap() -{ - logerror("%s: unmapped devcb read\n", - m_object.device->tag()); - return CLEAR_LINE; -} - - -//************************************************************************** -// DEVCB RESOLVED WRITE LINE -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_write_line - empty constructor -//------------------------------------------------- - -devcb_resolved_write_line::devcb_resolved_write_line() -{ - m_object.port = NULL; - m_helper.write_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_write_line::resolve(const devcb_write_line &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_helper.null_indicator = &s_null; - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(&devcb_resolved_write_line::to_null, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(&devcb_resolved_write_line::to_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.writeline != NULL) - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(desc.writeline, desc.name, m_object.device); - else - { - m_helper.write8_device = desc.writedevice; - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(&devcb_resolved_write_line::to_write8, desc.name, this); - } - break; - - case DEVCB_TYPE_INPUT_LINE: - m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); - m_helper.input_line = desc.index; - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(&devcb_resolved_write_line::to_input, desc.tag, this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_write_line_delegate *>(this) = devcb_write_line_delegate(&devcb_resolved_write_line::to_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// to_null - helper to handle a NULL write -//------------------------------------------------- - -void devcb_resolved_write_line::to_null(int state) -{ -} - -//------------------------------------------------- -// to_unmap - helper to handle a unmap write -//------------------------------------------------- - -void devcb_resolved_write_line::to_unmap(int state) -{ - logerror("%s: unmapped devcb write %s\n", - m_object.device->tag(), - core_i64_format(state, 2 * sizeof(UINT8),false)); -} - -//------------------------------------------------- -// to_port - helper to convert to an I/O port -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write_line::to_port(int state) -{ - m_object.port->write(state, 0xffffffff); -} - - -//------------------------------------------------- -// to_write8 - helper to convert to an 8-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write_line::to_write8(int state) -{ - (*m_helper.write8_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), 0, state, 0xff); -} - - -//------------------------------------------------- -// to_input - helper to convert to a device input -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write_line::to_input(int state) -{ - m_object.execute->set_input_line(m_helper.input_line, state); -} - - - -//************************************************************************** -// DEVCB RESOLVED READ8 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_read8 - empty constructor -//------------------------------------------------- - -devcb_resolved_read8::devcb_resolved_read8() -{ - m_object.port = NULL; - m_helper.read_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_read8::resolve(const devcb_read8 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_object.constant = 0; - m_helper.null_indicator = &s_null; - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_constant, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.readdevice != NULL) - { - m_helper.read8_device = desc.readdevice; - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_read8device, desc.name, this); - } - else - { - m_helper.read_line = desc.readline; - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_readline, desc.name, this); - } - break; - - case DEVCB_TYPE_CONSTANT: - m_object.constant = desc.index; - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_constant, "constant", this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_read8_delegate *>(this) = devcb_read8_delegate(&devcb_resolved_read8::from_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// from_port - helper to convert from an I/O port -// value to an 8-bit value -//------------------------------------------------- - -UINT8 devcb_resolved_read8::from_port(offs_t offset, UINT8 mem_mask) -{ - return m_object.port->read(); -} - - -//------------------------------------------------- -// from_read8device - helper to convert from a device -// line read value to an 8-bit value -//------------------------------------------------- - -UINT8 devcb_resolved_read8::from_read8device(offs_t offset, UINT8 mem_mask) -{ - return (*m_helper.read8_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, mem_mask); -} - - -//------------------------------------------------- -// from_readline - helper to convert from a device -// line read value to an 8-bit value -//------------------------------------------------- - -UINT8 devcb_resolved_read8::from_readline(offs_t offset, UINT8 mem_mask) -{ - return (*m_helper.read_line)(m_object.device); -} - - -//------------------------------------------------- -// from_constant - helper to convert from a -// constant value to an 8-bit value -//------------------------------------------------- - -UINT8 devcb_resolved_read8::from_constant(offs_t offset, UINT8 mem_mask) -{ - return m_object.constant; -} - -//------------------------------------------------- -// from_constant - helper to convert from a -// unmap value to an 8-bit value -//------------------------------------------------- - -UINT8 devcb_resolved_read8::from_unmap(offs_t offset, UINT8 mem_mask) -{ - logerror("%s: unmapped devcb read\n", - m_object.device->tag()); - return 0; -} - -//************************************************************************** -// DEVCB RESOLVED WRITE8 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_write8 - empty constructor -//------------------------------------------------- - -devcb_resolved_write8::devcb_resolved_write8() -{ - m_object.port = NULL; - m_helper.write_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_write8::resolve(const devcb_write8 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_helper.null_indicator = &s_null; - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_null, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.writedevice != NULL) - { - m_helper.write8_device = desc.writedevice; - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_write8device, desc.name, this); - } - else - { - m_helper.write_line = desc.writeline; - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_writeline, desc.name, this); - } - break; - - case DEVCB_TYPE_INPUT_LINE: - m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); - m_helper.input_line = desc.index; - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_input, desc.tag, this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_write8_delegate *>(this) = devcb_write8_delegate(&devcb_resolved_write8::to_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// to_null - helper to handle a NULL write -//------------------------------------------------- - -void devcb_resolved_write8::to_null(offs_t offset, UINT8 data, UINT8 mem_mask) -{ -} - -//------------------------------------------------- -// to_unmap - helper to handle a unmap write -//------------------------------------------------- - -void devcb_resolved_write8::to_unmap(offs_t offset, UINT8 data, UINT8 mem_mask) -{ - logerror("%s: unmapped devcb write %s & %s\n", - m_object.device->tag(), - core_i64_format(data, 2 * sizeof(UINT8),false), - core_i64_format(mem_mask, 2 * sizeof(UINT8),false)); -} - -//------------------------------------------------- -// to_port - helper to convert to an I/O port -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write8::to_port(offs_t offset, UINT8 data, UINT8 mem_mask) -{ - m_object.port->write(data, mem_mask); -} - - -//------------------------------------------------- -// to_write8device - helper to convert to an 8-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write8::to_write8device(offs_t offset, UINT8 data, UINT8 mem_mask) -{ - (*m_helper.write8_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mem_mask); -} - - -//------------------------------------------------- -// to_write8 - helper to convert to an 8-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write8::to_writeline(offs_t offset, UINT8 data, UINT8 mem_mask) -{ - (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - - -//------------------------------------------------- -// to_input - helper to convert to a device input -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write8::to_input(offs_t offset, UINT8 data, UINT8 mem_mask) -{ - m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - - - -//************************************************************************** -// DEVCB RESOLVED READ16 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_read16 - empty constructor -//------------------------------------------------- - -devcb_resolved_read16::devcb_resolved_read16() -{ - m_object.port = NULL; - m_helper.read_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_read16::resolve(const devcb_read16 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_object.constant = 0; - m_helper.null_indicator = &s_null; - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_constant, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.readdevice != NULL) - { - m_helper.read16_device = desc.readdevice; - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_read16, desc.name, this); - } - else - { - m_helper.read_line = desc.readline; - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_readline, desc.name, this); - } - break; - - case DEVCB_TYPE_CONSTANT: - m_object.constant = desc.index; - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_constant, "constant", this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_read16_delegate *>(this) = devcb_read16_delegate(&devcb_resolved_read16::from_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// from_port - helper to convert from an I/O port -// value to a 16-bit value -//------------------------------------------------- - -UINT16 devcb_resolved_read16::from_port(offs_t offset, UINT16 mask) -{ - return m_object.port->read(); -} - - -//------------------------------------------------- -// from_read16 - helper to convert from a device -// line read value to a 16-bit value -//------------------------------------------------- - -UINT16 devcb_resolved_read16::from_read16(offs_t offset, UINT16 mask) -{ - return (*m_helper.read16_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, mask); -} - - -//------------------------------------------------- -// from_read16 - helper to convert from a device -// line read value to a 16-bit value -//------------------------------------------------- - -UINT16 devcb_resolved_read16::from_readline(offs_t offset, UINT16 mask) -{ - return (*m_helper.read_line)(m_object.device); -} - - -//------------------------------------------------- -// from_constant - helper to convert from a -// constant value to a 16-bit value -//------------------------------------------------- - -UINT16 devcb_resolved_read16::from_constant(offs_t offset, UINT16 mask) -{ - return m_object.constant; -} - -//------------------------------------------------- -// from_constant - helper to convert from a -// unmap value to a 16-bit value -//------------------------------------------------- - -UINT16 devcb_resolved_read16::from_unmap(offs_t offset, UINT16 mem_mask) -{ - logerror("%s: unmapped devcb read\n", - m_object.device->tag()); - return 0; -} - -//************************************************************************** -// DEVCB RESOLVED WRITE16 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_write16 - empty constructor -//------------------------------------------------- - -devcb_resolved_write16::devcb_resolved_write16() -{ - m_object.port = NULL; - m_helper.write_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_write16::resolve(const devcb_write16 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_helper.null_indicator = &s_null; - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_null, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.writedevice != NULL) - { - m_helper.write16_device = desc.writedevice; - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_write16, desc.name, this); - } - else - { - m_helper.write_line = desc.writeline; - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_writeline, desc.name, this); - } - break; - - case DEVCB_TYPE_INPUT_LINE: - m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); - m_helper.input_line = desc.index; - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_input, desc.tag, this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_write16_delegate *>(this) = devcb_write16_delegate(&devcb_resolved_write16::to_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// to_null - helper to handle a NULL write -//------------------------------------------------- - -void devcb_resolved_write16::to_null(offs_t offset, UINT16 data, UINT16 mask) -{ -} - - -//------------------------------------------------- -// to_unmap - helper to handle a unmap write -//------------------------------------------------- - -void devcb_resolved_write16::to_unmap(offs_t offset, UINT16 data, UINT16 mask) -{ - logerror("%s: unmapped devcb write %s & %s\n", - m_object.device->tag(), - core_i64_format(data, 2 * sizeof(UINT16),false), - core_i64_format(mask, 2 * sizeof(UINT16),false)); -} - -//------------------------------------------------- -// to_port - helper to convert to an I/O port -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write16::to_port(offs_t offset, UINT16 data, UINT16 mask) -{ - m_object.port->write(data, mask); -} - - -//------------------------------------------------- -// to_write16 - helper to convert to a 16-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write16::to_write16(offs_t offset, UINT16 data, UINT16 mask) -{ - (*m_helper.write16_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mask); -} - - -//------------------------------------------------- -// to_write16 - helper to convert to a 16-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write16::to_writeline(offs_t offset, UINT16 data, UINT16 mask) -{ - (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - - -//------------------------------------------------- -// to_input - helper to convert to a device input -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write16::to_input(offs_t offset, UINT16 data, UINT16 mask) -{ - m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - -//************************************************************************** -// DEVCB RESOLVED READ32 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_read32 - empty constructor -//------------------------------------------------- - -devcb_resolved_read32::devcb_resolved_read32() -{ - m_object.port = NULL; - m_helper.read_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_read32::resolve(const devcb_read32 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_object.constant = 0; - m_helper.null_indicator = &s_null; - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_constant, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.readdevice != NULL) - { - m_helper.read32_device = desc.readdevice; - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_read32, desc.name, this); - } - else - { - m_helper.read_line = desc.readline; - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_readline, desc.name, this); - } - break; - - case DEVCB_TYPE_CONSTANT: - m_object.constant = desc.index; - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_constant, "constant", this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_read32_delegate *>(this) = devcb_read32_delegate(&devcb_resolved_read32::from_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// from_port - helper to convert from an I/O port -// value to a 32-bit value -//------------------------------------------------- - -UINT32 devcb_resolved_read32::from_port(offs_t offset, UINT32 mask) -{ - return m_object.port->read(); -} - - -//------------------------------------------------- -// from_read32 - helper to convert from a device -// line read value to a 32-bit value -//------------------------------------------------- - -UINT32 devcb_resolved_read32::from_read32(offs_t offset, UINT32 mask) -{ - return (*m_helper.read32_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, mask); -} - - -//------------------------------------------------- -// from_read32 - helper to convert from a device -// line read value to a 32-bit value -//------------------------------------------------- - -UINT32 devcb_resolved_read32::from_readline(offs_t offset, UINT32 mask) -{ - return (*m_helper.read_line)(m_object.device); -} - - -//------------------------------------------------- -// from_constant - helper to convert from a -// constant value to a 32-bit value -//------------------------------------------------- - -UINT32 devcb_resolved_read32::from_constant(offs_t offset, UINT32 mask) -{ - return m_object.constant; -} - -//------------------------------------------------- -// from_constant - helper to convert from a -// unmap value to a 32-bit value -//------------------------------------------------- - -UINT32 devcb_resolved_read32::from_unmap(offs_t offset, UINT32 mem_mask) -{ - logerror("%s: unmapped devcb read\n", - m_object.device->tag()); - return 0; -} - -//************************************************************************** -// DEVCB RESOLVED WRITE32 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_write32 - empty constructor -//------------------------------------------------- - -devcb_resolved_write32::devcb_resolved_write32() -{ - m_object.port = NULL; - m_helper.write_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_write32::resolve(const devcb_write32 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_helper.null_indicator = &s_null; - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_null, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.writedevice != NULL) - { - m_helper.write32_device = desc.writedevice; - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_write32, desc.name, this); - } - else - { - m_helper.write_line = desc.writeline; - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_writeline, desc.name, this); - } - break; - - case DEVCB_TYPE_INPUT_LINE: - m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); - m_helper.input_line = desc.index; - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_input, desc.tag, this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_write32_delegate *>(this) = devcb_write32_delegate(&devcb_resolved_write32::to_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// to_null - helper to handle a NULL write -//------------------------------------------------- - -void devcb_resolved_write32::to_null(offs_t offset, UINT32 data, UINT32 mask) -{ -} - - -//------------------------------------------------- -// to_unmap - helper to handle a unmap write -//------------------------------------------------- - -void devcb_resolved_write32::to_unmap(offs_t offset, UINT32 data, UINT32 mask) -{ - logerror("%s: unmapped devcb write %s & %s\n", - m_object.device->tag(), - core_i64_format(data, 2 * sizeof(UINT32),false), - core_i64_format(mask, 2 * sizeof(UINT32),false)); -} - -//------------------------------------------------- -// to_port - helper to convert to an I/O port -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write32::to_port(offs_t offset, UINT32 data, UINT32 mask) -{ - m_object.port->write(data, mask); -} - - -//------------------------------------------------- -// to_write32 - helper to convert to a 32-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write32::to_write32(offs_t offset, UINT32 data, UINT32 mask) -{ - (*m_helper.write32_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mask); -} - - -//------------------------------------------------- -// to_write32 - helper to convert to a 32-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write32::to_writeline(offs_t offset, UINT32 data, UINT32 mask) -{ - (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - - -//------------------------------------------------- -// to_input - helper to convert to a device input -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write32::to_input(offs_t offset, UINT32 data, UINT32 mask) -{ - m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - -//************************************************************************** -// DEVCB RESOLVED READ64 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_read64 - empty constructor -//------------------------------------------------- - -devcb_resolved_read64::devcb_resolved_read64() -{ - m_object.port = NULL; - m_helper.read_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_read64::resolve(const devcb_read64 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_object.constant = 0; - m_helper.null_indicator = &s_null; - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_constant, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.readdevice != NULL) - { - m_helper.read64_device = desc.readdevice; - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_read64, desc.name, this); - } - else - { - m_helper.read_line = desc.readline; - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_readline, desc.name, this); - } - break; - - case DEVCB_TYPE_CONSTANT: - m_object.constant = desc.index; - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_constant, "constant", this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_read64_delegate *>(this) = devcb_read64_delegate(&devcb_resolved_read64::from_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// from_port - helper to convert from an I/O port -// value to a 64-bit value -//------------------------------------------------- - -UINT64 devcb_resolved_read64::from_port(offs_t offset, UINT64 mask) -{ - return m_object.port->read(); -} - - -//------------------------------------------------- -// from_read64 - helper to convert from a device -// line read value to a 64-bit value -//------------------------------------------------- - -UINT64 devcb_resolved_read64::from_read64(offs_t offset, UINT64 mask) -{ - return (*m_helper.read64_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, mask); -} - - -//------------------------------------------------- -// from_read64 - helper to convert from a device -// line read value to a 64-bit value -//------------------------------------------------- - -UINT64 devcb_resolved_read64::from_readline(offs_t offset, UINT64 mask) -{ - return (*m_helper.read_line)(m_object.device); -} - - -//------------------------------------------------- -// from_constant - helper to convert from a -// constant value to a 64-bit value -//------------------------------------------------- - -UINT64 devcb_resolved_read64::from_constant(offs_t offset, UINT64 mask) -{ - return m_object.constant; -} - -//------------------------------------------------- -// from_constant - helper to convert from a -// unmap value to a 64-bit value -//------------------------------------------------- - -UINT64 devcb_resolved_read64::from_unmap(offs_t offset, UINT64 mem_mask) -{ - logerror("%s: unmapped devcb read\n", - m_object.device->tag()); - return 0; -} - -//************************************************************************** -// DEVCB RESOLVED WRITE64 -//************************************************************************** - -//------------------------------------------------- -// devcb_resolved_write64 - empty constructor -//------------------------------------------------- - -devcb_resolved_write64::devcb_resolved_write64() -{ - m_object.port = NULL; - m_helper.write_line = NULL; -} - - -//------------------------------------------------- -// resolve - resolve to a delegate from a static -// structure definition -//------------------------------------------------- - -void devcb_resolved_write64::resolve(const devcb_write64 &desc, device_t &device) -{ - switch (desc.type) - { - default: - case DEVCB_TYPE_NULL: - m_helper.null_indicator = &s_null; - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_null, "(null)", this); - break; - - case DEVCB_TYPE_IOPORT: - m_object.port = devcb_resolver::resolve_port(desc.tag, device); - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_port, desc.tag, this); - break; - - case DEVCB_TYPE_DEVICE: - m_object.device = devcb_resolver::resolve_device(desc.index, desc.tag, device); - if (desc.writedevice != NULL) - { - m_helper.write64_device = desc.writedevice; - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_write64, desc.name, this); - } - else - { - m_helper.write_line = desc.writeline; - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_writeline, desc.name, this); - } - break; - - case DEVCB_TYPE_INPUT_LINE: - m_object.execute = devcb_resolver::resolve_execute_interface(desc.tag, device); - m_helper.input_line = desc.index; - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_input, desc.tag, this); - break; - - case DEVCB_TYPE_UNMAP: - m_helper.null_indicator = &s_null; - m_object.device = &device; - *static_cast<devcb_write64_delegate *>(this) = devcb_write64_delegate(&devcb_resolved_write64::to_unmap, "unmap", this); - break; - } -} - - -//------------------------------------------------- -// to_null - helper to handle a NULL write -//------------------------------------------------- - -void devcb_resolved_write64::to_null(offs_t offset, UINT64 data, UINT64 mask) -{ -} - - -//------------------------------------------------- -// to_unmap - helper to handle a unmap write -//------------------------------------------------- - -void devcb_resolved_write64::to_unmap(offs_t offset, UINT64 data, UINT64 mask) -{ - logerror("%s: unmapped devcb write %s & %s\n", - m_object.device->tag(), - core_i64_format(data, 2 * sizeof(UINT64),false), - core_i64_format(mask, 2 * sizeof(UINT64),false)); -} - -//------------------------------------------------- -// to_port - helper to convert to an I/O port -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write64::to_port(offs_t offset, UINT64 data, UINT64 mask) -{ - m_object.port->write(data, mask); -} - - -//------------------------------------------------- -// to_write64 - helper to convert to a 64-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write64::to_write64(offs_t offset, UINT64 data, UINT64 mask) -{ - (*m_helper.write64_device)(m_object.device, m_object.device->machine().driver_data()->generic_space(), offset, data, mask); -} - - -//------------------------------------------------- -// to_write64 - helper to convert to a 64-bit -// memory read value from a line value -//------------------------------------------------- - -void devcb_resolved_write64::to_writeline(offs_t offset, UINT64 data, UINT64 mask) -{ - (*m_helper.write_line)(m_object.device, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} - - -//------------------------------------------------- -// to_input - helper to convert to a device input -// value from a line value -//------------------------------------------------- - -void devcb_resolved_write64::to_input(offs_t offset, UINT64 data, UINT64 mask) -{ - m_object.execute->set_input_line(m_helper.input_line, (data & 1) ? ASSERT_LINE : CLEAR_LINE); -} diff --git a/src/emu/devcb.h b/src/emu/devcb.h deleted file mode 100644 index 1d22e54b951..00000000000 --- a/src/emu/devcb.h +++ /dev/null @@ -1,770 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** - - devcb.h - - Device callback interface helpers. - -**************************************************************************** - - These functions are used to adapt multiple read/write handler types - to be used with device I/O. In general, a device is expected to - declare its desired callback type, and these functions allow other - callback types to be adapted appropriately. - - The desired callback types currently supported include: - - read_line_device_func: (device) - write_line_device_func: (device, data) - read8_device_func: (device, offset) - write8_device_func: (device, offset, data) - read16_device_func: (device, offset) - write16_device_func: (device, offset, data) - read32_device_func: (device, offset) - write32_device_func: (device, offset, data) - read64_device_func: (device, offset) - write64_device_func: (device, offset, data) - - The adapted callback types supported are: - - input port (port) - cpu input line (cpu input line) - read_line_device_func: (device) - write_line_device_func: (device, data) - read8_device_func: (device, offset) - write8_device_func: (device, offset, data) - read16_device_func: (device, offset) - write16_device_func: (device, offset, data) - read32_device_func: (device, offset) - write32_device_func: (device, offset, data) - read64_device_func: (device, offset) - write64_device_func: (device, offset, data) - -***************************************************************************/ - -#pragma once - -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - -#ifndef __DEVCB_H__ -#define __DEVCB_H__ - - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -// callback types -enum -{ - DEVCB_TYPE_NULL = 0, // NULL callback - DEVCB_TYPE_IOPORT, // I/O port read/write - DEVCB_TYPE_DEVICE, // device read/write - DEVCB_TYPE_INPUT_LINE, // device input line write - DEVCB_TYPE_CONSTANT, // constant value read - DEVCB_TYPE_UNMAP // unmapped line -}; - - - -//************************************************************************** -// MACROS -//************************************************************************** - -// static template for a read_line stub function that calls through a given READ_LINE_MEMBER -template<class _Class, int (_Class::*_Function)()> -int devcb_line_stub(device_t *device) -{ - _Class *target = downcast<_Class *>(device); - return (target->*_Function)(); -} - -// static template for a read8 stub function that calls through a given READ8_MEMBER -template<class _Class, UINT8 (_Class::*_Function)(address_space &, offs_t, UINT8)> -UINT8 devcb_stub(device_t *device, address_space &space, offs_t offset, UINT8 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - return (target->*_Function)(space, offset, mem_mask); -} - -// static template for a read16 stub function that calls through a given READ16_MEMBER -template<class _Class, UINT16 (_Class::*_Function)(address_space &, offs_t, UINT16)> -UINT16 devcb_stub16(device_t *device, address_space &space, offs_t offset, UINT16 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - return (target->*_Function)(space, offset, mem_mask); -} - -// static template for a read32 stub function that calls through a given READ32_MEMBER -template<class _Class, UINT32 (_Class::*_Function)(address_space &, offs_t, UINT32)> -UINT32 devcb_stub32(device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - return (target->*_Function)(space, offset, mem_mask); -} - -// static template for a read64 stub function that calls through a given READ64_MEMBER -template<class _Class, UINT64 (_Class::*_Function)(address_space &, offs_t, UINT64)> -UINT64 devcb_stub64(device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - return (target->*_Function)(space, offset, mem_mask); -} - -// static template for a write_line stub function that calls through a given WRITE_LINE_MEMBER -template<class _Class, void (_Class::*_Function)(int state)> -void devcb_line_stub(device_t *device, int state) -{ - _Class *target = downcast<_Class *>(device); - (target->*_Function)(state); -} - -// static template for a write8 stub function that calls through a given WRITE8_MEMBER -template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT8, UINT8)> -void devcb_stub(device_t *device, address_space &space, offs_t offset, UINT8 data, UINT8 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - (target->*_Function)(space, offset, data, mem_mask); -} - -// static template for a write16 stub function that calls through a given WRITE16_MEMBER -template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT16, UINT16)> -void devcb_stub16(device_t *device, address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - (target->*_Function)(space, offset, data, mem_mask); -} - -// static template for a write32 stub function that calls through a given WRITE32_MEMBER -template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT32, UINT32)> -void devcb_stub32(device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - (target->*_Function)(space, offset, data, mem_mask); -} - -// static template for a write64 stub function that calls through a given WRITE64_MEMBER -template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT64, UINT64)> -void devcb_stub64(device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) -{ - _Class *target = downcast<_Class *>(device); - (target->*_Function)(space, offset, data, mem_mask); -} - -#define DEVCB_NULL { DEVCB_TYPE_NULL } - -// line or read/write handlers for the driver device -#define DEVCB_DRIVER_LINE_MEMBER(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL } -#define DEVCB_DRIVER_MEMBER(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb> } -#define DEVCB_DRIVER_MEMBER16(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb> } -#define DEVCB_DRIVER_MEMBER32(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub32<cls, &cls::memb> } -//#define DEVCB_DRIVER_MEMBER64(cls,memb) { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub64<cls, &cls::memb> } - -// line or read/write handlers for another device -#define DEVCB_DEVICE_LINE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL } -#define DEVCB_DEVICE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb> } -#define DEVCB_DEVICE_MEMBER16(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb> } -#define DEVCB_DEVICE_MEMBER32(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub32<cls, &cls::memb> } -//#define DEVCB_DEVICE_MEMBER64(tag,cls,memb) { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub64<cls, &cls::memb> } - -// constant values -#define DEVCB_CONSTANT(value) { DEVCB_TYPE_CONSTANT, value, NULL, NULL, NULL } -#define DEVCB_LINE_GND DEVCB_CONSTANT(0) -#define DEVCB_LINE_VCC DEVCB_CONSTANT(1) - -#define DEVCB_UNMAPPED { DEVCB_TYPE_UNMAP, 0, NULL, NULL, NULL } - -// read handlers for an I/O port by tag -#define DEVCB_INPUT_PORT(tag) { DEVCB_TYPE_IOPORT, 0, (tag), NULL, NULL, NULL } - -// write handlers for a CPU input line -#define DEVCB_CPU_INPUT_LINE(tag,line) { DEVCB_TYPE_INPUT_LINE, (line), (tag), NULL, NULL, NULL } - - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// read/write types for I/O lines (similar to read/write handlers but no offset) -typedef int (*read_line_device_func)(device_t *device); -typedef void (*write_line_device_func)(device_t *device, int state); - -// legacy device read/write handlers -typedef UINT8 (*read8_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 mem_mask); -typedef void (*write8_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data, ATTR_UNUSED UINT8 mem_mask); -typedef UINT16 (*read16_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask); -typedef void (*write16_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask); -typedef UINT32 (*read32_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask); -typedef void (*write32_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask); -typedef UINT64 (*read64_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask); -typedef void (*write64_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask); - - - -// ======================> devcb_resolved_objects - -// resolving a devcb may produce one of the following object types -union devcb_resolved_objects -{ - ioport_port * port; - address_space * space; - device_t * device; - device_execute_interface * execute; - UINT32 constant; -}; - - -// ======================> devcb_resolved_helpers - -// resolving a devcb may produce one of the following helper functions/additional info -union devcb_resolved_read_helpers -{ - UINT8 * null_indicator; - read_line_device_func read_line; - read8_device_func read8_device; - read16_device_func read16_device; - read32_device_func read32_device; - read64_device_func read64_device; -}; - -union devcb_resolved_write_helpers -{ - UINT8 * null_indicator; - write_line_device_func write_line; - write8_device_func write8_device; - write16_device_func write16_device; - write32_device_func write32_device; - write64_device_func write64_device; - int input_line; -}; - - -// ======================> devcb_read_line - -// static structure used for device configuration when the desired callback type is a read_line_device_func -struct devcb_read_line -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - read_line_device_func readline; // read line function - read8_device_func readdevice; // read device function -}; - - -// ======================> devcb_resolved_read_line - -// base delegate type for a read_line -typedef delegate<int ()> devcb_read_line_delegate; - -// class which wraps resolving a devcb_read_line into a delegate -class devcb_resolved_read_line : public devcb_read_line_delegate -{ - DISABLE_COPYING(devcb_resolved_read_line); - -public: - // construction/destruction - devcb_resolved_read_line(); - devcb_resolved_read_line(const devcb_read_line &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_read_line &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - -private: - // internal helpers - int from_port(); - int from_read8(); - int from_constant(); - int from_unmap(); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_read_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_write_line - -// static structure used for device configuration when the desired callback type is a write_line_device_func -struct devcb_write_line -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - write_line_device_func writeline; // write line function - write8_device_func writedevice; // write device function -}; - - -// ======================> devcb_resolved_write_line - -// base delegate type for a write_line -typedef delegate<void (int)> devcb_write_line_delegate; - -// class which wraps resolving a devcb_write_line into a delegate -class devcb_resolved_write_line : public devcb_write_line_delegate -{ - DISABLE_COPYING(devcb_resolved_write_line); - -public: - // construction/destruction - devcb_resolved_write_line(); - devcb_resolved_write_line(const devcb_write_line &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_write_line &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - -private: - // internal helpers - void to_null(int state); - void to_port(int state); - void to_write8(int state); - void to_input(int state); - void to_unmap(int state); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_write_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_read8 - -// static structure used for device configuration when the desired callback type is a read8_device_func -struct devcb_read8 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - read_line_device_func readline; // read line function - read8_device_func readdevice; // read device function -}; - - -// ======================> devcb_resolved_read8 - -// base delegate type for a read8 -typedef delegate<UINT8 (offs_t, UINT8)> devcb_read8_delegate; - -// class which wraps resolving a devcb_read8 into a delegate -class devcb_resolved_read8 : public devcb_read8_delegate -{ - DISABLE_COPYING(devcb_resolved_read8); - -public: - // construction/destruction - devcb_resolved_read8(); - devcb_resolved_read8(const devcb_read8 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_read8 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - UINT8 operator()(offs_t offset, UINT8 mem_mask = 0xff) const { return devcb_read8_delegate::operator()(offset, mem_mask); } - -private: - // internal helpers - UINT8 from_port(offs_t offset, UINT8 mem_mask); - UINT8 from_read8device(offs_t offset, UINT8 mem_mask); - UINT8 from_readline(offs_t offset, UINT8 mem_mask); - UINT8 from_constant(offs_t offset, UINT8 mem_mask); - UINT8 from_unmap(offs_t offset, UINT8 mem_mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_read_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_write8 - -// static structure used for device configuration when the desired callback type is a write8_device_func -struct devcb_write8 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - write_line_device_func writeline; // write line function - write8_device_func writedevice; // write device function -}; - - -// ======================> devcb_resolved_write8 - -// base delegate type for a write8 -typedef delegate<void (offs_t, UINT8, UINT8)> devcb_write8_delegate; - -// class which wraps resolving a devcb_write8 into a delegate -class devcb_resolved_write8 : public devcb_write8_delegate -{ - DISABLE_COPYING(devcb_resolved_write8); - -public: - // construction/destruction - devcb_resolved_write8(); - devcb_resolved_write8(const devcb_write8 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_write8 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - void operator()(offs_t offset, UINT8 data, UINT8 mem_mask = 0xff) const { devcb_write8_delegate::operator()(offset, data, mem_mask); } - -private: - // internal helpers - void to_null(offs_t offset, UINT8 data, UINT8 mem_mask); - void to_port(offs_t offset, UINT8 data, UINT8 mem_mask); - void to_write8device(offs_t offset, UINT8 data, UINT8 mem_mask); - void to_writeline(offs_t offset, UINT8 data, UINT8 mem_mask); - void to_input(offs_t offset, UINT8 data, UINT8 mem_mask); - void to_unmap(offs_t offset, UINT8 data, UINT8 mem_mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_write_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_read16 - -// static structure used for device configuration when the desired callback type is a read16_device_func -struct devcb_read16 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - read_line_device_func readline; // read line function - read16_device_func readdevice; // read device function -}; - - -// ======================> devcb_resolved_read16 - -// base delegate type for a write16 -typedef delegate<UINT16 (offs_t, UINT16)> devcb_read16_delegate; - -// class which wraps resolving a devcb_read16 into a delegate -class devcb_resolved_read16 : public devcb_read16_delegate -{ - DISABLE_COPYING(devcb_resolved_read16); - -public: - // construction/destruction - devcb_resolved_read16(); - devcb_resolved_read16(const devcb_read16 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_read16 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - UINT16 operator()(offs_t offset, UINT16 mem_mask = 0xffff) const { return devcb_read16_delegate::operator()(offset, mem_mask); } - -private: - // internal helpers - UINT16 from_port(offs_t offset, UINT16 mask); - UINT16 from_read16(offs_t offset, UINT16 mask); - UINT16 from_readline(offs_t offset, UINT16 mask); - UINT16 from_constant(offs_t offset, UINT16 mask); - UINT16 from_unmap(offs_t offset, UINT16 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_read_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_write16 - -// static structure used for device configuration when the desired callback type is a write16_device_func -struct devcb_write16 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - write_line_device_func writeline; // write line function - write16_device_func writedevice; // write device function -}; - - -// ======================> devcb_resolved_write16 - -// base delegate type for a write16 -typedef delegate<void (offs_t, UINT16, UINT16)> devcb_write16_delegate; - -// class which wraps resolving a devcb_write16 into a delegate -class devcb_resolved_write16 : public devcb_write16_delegate -{ - DISABLE_COPYING(devcb_resolved_write16); - -public: - // construction/destruction - devcb_resolved_write16(); - devcb_resolved_write16(const devcb_write16 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_write16 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - void operator()(offs_t offset, UINT16 data, UINT16 mem_mask = 0xffff) const { devcb_write16_delegate::operator()(offset, data, mem_mask); } - -private: - // internal helpers - void to_null(offs_t offset, UINT16 data, UINT16 mask); - void to_port(offs_t offset, UINT16 data, UINT16 mask); - void to_write16(offs_t offset, UINT16 data, UINT16 mask); - void to_writeline(offs_t offset, UINT16 data, UINT16 mask); - void to_input(offs_t offset, UINT16 data, UINT16 mask); - void to_unmap(offs_t offset, UINT16 data, UINT16 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_write_helpers m_helper; - static UINT8 s_null; -}; - -// ======================> devcb_read32 - -// static structure used for device configuration when the desired callback type is a read32_device_func -struct devcb_read32 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - read_line_device_func readline; // read line function - read32_device_func readdevice; // read device function -}; - - -// ======================> devcb_resolved_read32 - -// base delegate type for a write32 -typedef delegate<UINT32 (offs_t, UINT32)> devcb_read32_delegate; - -// class which wraps resolving a devcb_read32 into a delegate -class devcb_resolved_read32 : public devcb_read32_delegate -{ - DISABLE_COPYING(devcb_resolved_read32); - -public: - // construction/destruction - devcb_resolved_read32(); - devcb_resolved_read32(const devcb_read32 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_read32 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - UINT32 operator()(offs_t offset, UINT32 mem_mask = 0xffff) const { return devcb_read32_delegate::operator()(offset, mem_mask); } - -private: - // internal helpers - UINT32 from_port(offs_t offset, UINT32 mask); - UINT32 from_read32(offs_t offset, UINT32 mask); - UINT32 from_readline(offs_t offset, UINT32 mask); - UINT32 from_constant(offs_t offset, UINT32 mask); - UINT32 from_unmap(offs_t offset, UINT32 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_read_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_write32 - -// static structure used for device configuration when the desired callback type is a write32_device_func -struct devcb_write32 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - write_line_device_func writeline; // write line function - write32_device_func writedevice; // write device function -}; - - -// ======================> devcb_resolved_write32 - -// base delegate type for a write32 -typedef delegate<void (offs_t, UINT32, UINT32)> devcb_write32_delegate; - -// class which wraps resolving a devcb_write32 into a delegate -class devcb_resolved_write32 : public devcb_write32_delegate -{ - DISABLE_COPYING(devcb_resolved_write32); - -public: - // construction/destruction - devcb_resolved_write32(); - devcb_resolved_write32(const devcb_write32 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_write32 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - void operator()(offs_t offset, UINT32 data, UINT32 mem_mask = 0xffff) const { devcb_write32_delegate::operator()(offset, data, mem_mask); } - -private: - // internal helpers - void to_null(offs_t offset, UINT32 data, UINT32 mask); - void to_port(offs_t offset, UINT32 data, UINT32 mask); - void to_write32(offs_t offset, UINT32 data, UINT32 mask); - void to_writeline(offs_t offset, UINT32 data, UINT32 mask); - void to_input(offs_t offset, UINT32 data, UINT32 mask); - void to_unmap(offs_t offset, UINT32 data, UINT32 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_write_helpers m_helper; - static UINT8 s_null; -}; - -// ======================> devcb_read64 - -// static structure used for device configuration when the desired callback type is a read64_device_func -struct devcb_read64 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - read_line_device_func readline; // read line function - read64_device_func readdevice; // read device function -}; - - -// ======================> devcb_resolved_read64 - -// base delegate type for a write64 -typedef delegate<UINT64 (offs_t, UINT64)> devcb_read64_delegate; - -// class which wraps resolving a devcb_read64 into a delegate -class devcb_resolved_read64 : public devcb_read64_delegate -{ - DISABLE_COPYING(devcb_resolved_read64); - -public: - // construction/destruction - devcb_resolved_read64(); - devcb_resolved_read64(const devcb_read64 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_read64 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - UINT64 operator()(offs_t offset, UINT64 mem_mask = 0xffff) const { return devcb_read64_delegate::operator()(offset, mem_mask); } - -private: - // internal helpers - UINT64 from_port(offs_t offset, UINT64 mask); - UINT64 from_read64(offs_t offset, UINT64 mask); - UINT64 from_readline(offs_t offset, UINT64 mask); - UINT64 from_constant(offs_t offset, UINT64 mask); - UINT64 from_unmap(offs_t offset, UINT64 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_read_helpers m_helper; - static UINT8 s_null; -}; - - -// ======================> devcb_write64 - -// static structure used for device configuration when the desired callback type is a write64_device_func -struct devcb_write64 -{ - UINT16 type; // one of the special DEVCB_TYPE values - UINT16 index; // index related to the above types - const char * tag; // tag of target, where appropriate - const char * name; // name of the target function - write_line_device_func writeline; // write line function - write64_device_func writedevice; // write device function -}; - - -// ======================> devcb_resolved_write64 - -// base delegate type for a write64 -typedef delegate<void (offs_t, UINT64, UINT64)> devcb_write64_delegate; - -// class which wraps resolving a devcb_write64 into a delegate -class devcb_resolved_write64 : public devcb_write64_delegate -{ - DISABLE_COPYING(devcb_resolved_write64); - -public: - // construction/destruction - devcb_resolved_write64(); - devcb_resolved_write64(const devcb_write64 &desc, device_t &device) { resolve(desc, device); } - - // resolution - void resolve(const devcb_write64 &desc, device_t &device); - - // override parent class' notion of NULL - bool isnull() const { return m_helper.null_indicator == &s_null; } - - // provide default for mem_mask - void operator()(offs_t offset, UINT64 data, UINT64 mem_mask = 0xffff) const { devcb_write64_delegate::operator()(offset, data, mem_mask); } - -private: - // internal helpers - void to_null(offs_t offset, UINT64 data, UINT64 mask); - void to_port(offs_t offset, UINT64 data, UINT64 mask); - void to_write64(offs_t offset, UINT64 data, UINT64 mask); - void to_writeline(offs_t offset, UINT64 data, UINT64 mask); - void to_input(offs_t offset, UINT64 data, UINT64 mask); - void to_unmap(offs_t offset, UINT64 data, UINT64 mask); - - // internal state - devcb_resolved_objects m_object; - devcb_resolved_write_helpers m_helper; - static UINT8 s_null; -}; - -#endif // __DEVCB_H__ diff --git a/src/emu/emu.h b/src/emu/emu.h index 64381cb032a..b4a1b7294fb 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -113,7 +113,6 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_ #include "speaker.h" // generic helpers -#include "devcb.h" #include "devcb2.h" #include "dispatch.h" #include "drivers/xtal.h" diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 3444b0d0877..99708bf660c 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -59,7 +59,6 @@ EMUOBJS = \ $(EMUOBJ)/crsshair.o \ $(EMUOBJ)/debugger.o \ $(EMUOBJ)/devdelegate.o \ - $(EMUOBJ)/devcb.o \ $(EMUOBJ)/devcb2.o \ $(EMUOBJ)/devcpu.o \ $(EMUOBJ)/devfind.o \ |