summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/vtech/memexp/memexp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/vtech/memexp/memexp.cpp')
-rw-r--r--src/devices/bus/vtech/memexp/memexp.cpp127
1 files changed, 103 insertions, 24 deletions
diff --git a/src/devices/bus/vtech/memexp/memexp.cpp b/src/devices/bus/vtech/memexp/memexp.cpp
index d857ccf3d0b..74d2213009a 100644
--- a/src/devices/bus/vtech/memexp/memexp.cpp
+++ b/src/devices/bus/vtech/memexp/memexp.cpp
@@ -1,5 +1,5 @@
-// license:GPL-2.0+
-// copyright-holders:Dirk Best
+// license: GPL-2.0+
+// copyright-holders: Dirk Best
/***************************************************************************
VTech Laser/VZ Memory Expansion Slot
@@ -30,8 +30,8 @@ DEFINE_DEVICE_TYPE(VTECH_MEMEXP_SLOT, vtech_memexp_slot_device, "vtech_memexp_sl
vtech_memexp_slot_device::vtech_memexp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, VTECH_MEMEXP_SLOT, tag, owner, clock),
device_single_card_slot_interface<device_vtech_memexp_interface>(mconfig, *this),
- m_program(*this, finder_base::DUMMY_TAG, -1),
- m_io(*this, finder_base::DUMMY_TAG, -1),
+ m_memspace(*this, finder_base::DUMMY_TAG, -1),
+ m_iospace(*this, finder_base::DUMMY_TAG, -1),
m_int_handler(*this),
m_nmi_handler(*this),
m_reset_handler(*this)
@@ -47,33 +47,46 @@ vtech_memexp_slot_device::~vtech_memexp_slot_device()
}
//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
+// device_start - device-specific startup
//-------------------------------------------------
-void vtech_memexp_slot_device::device_config_complete()
+void vtech_memexp_slot_device::device_start()
{
- // for passthrough connectors, use the parent slot's spaces
- if (dynamic_cast<device_vtech_memexp_interface *>(owner()) != nullptr)
- {
- auto parent = dynamic_cast<vtech_memexp_slot_device *>(owner()->owner());
- if (parent != nullptr)
+ // get inserted module
+ m_module = get_card_device();
+
+ // install memory access taps
+ m_memspace->install_readwrite_tap
+ (
+ 0x0000, 0xffff, "mem_tap",
+ [this](offs_t offset, uint8_t &data, uint8_t mem_mask)
+ {
+ if (m_module)
+ data &= m_module->mreq_r(offset);
+ },
+ [this](offs_t offset, uint8_t &data, uint8_t mem_mask)
{
- if (m_program.finder_tag() == finder_base::DUMMY_TAG)
- m_program.set_tag(parent->m_program, parent->m_program.spacenum());
- if (m_io.finder_tag() == finder_base::DUMMY_TAG)
- m_io.set_tag(parent->m_io, parent->m_io.spacenum());
+ if (m_module)
+ m_module->mreq_w(offset, data);
}
- }
-}
+ );
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
+ // install io access taps
+ m_iospace->install_readwrite_tap
+ (
+ 0x00, 0xff, "io_tap",
+ [this](offs_t offset, uint8_t &data, uint8_t mem_mask)
+ {
+ if (m_module)
+ data &= m_module->iorq_r(offset);
+ },
+ [this](offs_t offset, uint8_t &data, uint8_t mem_mask)
+ {
+ if (m_module)
+ m_module->iorq_w(offset, data);
+ }
+ );
-void vtech_memexp_slot_device::device_start()
-{
// resolve callbacks
m_int_handler.resolve_safe();
m_nmi_handler.resolve_safe();
@@ -102,3 +115,69 @@ device_vtech_memexp_interface::device_vtech_memexp_interface(const machine_confi
device_vtech_memexp_interface::~device_vtech_memexp_interface()
{
}
+
+
+//**************************************************************************
+// BASE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// vtech_memexp_device - constructor
+//-------------------------------------------------
+
+vtech_memexp_device::vtech_memexp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, type, tag, owner, clock),
+ device_vtech_memexp_interface(mconfig, *this),
+ m_mem(*this, "memspace"),
+ m_io(*this, "iospace")
+{
+}
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void vtech_memexp_device::device_add_mconfig(machine_config &config)
+{
+ ADDRESS_MAP_BANK(config, m_mem);
+ m_mem->set_addrmap(AS_PROGRAM, &vtech_memexp_device::mem_map);
+ m_mem->set_data_width(8);
+ m_mem->set_addr_width(16);
+
+ ADDRESS_MAP_BANK(config, m_io);
+ m_io->set_addrmap(AS_PROGRAM, &vtech_memexp_device::io_map);
+ m_io->set_data_width(8);
+ m_io->set_addr_width(16);
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void vtech_memexp_device::device_start()
+{
+ // silence unmapped warnings, or we'll get them for everything the
+ // expansion device doesn't handle
+ m_mem->set_log_unmap(false);
+ m_io->set_log_unmap(false);
+}
+
+uint8_t vtech_memexp_device::mreq_r(offs_t offset)
+{
+ return m_mem->read8(offset);
+}
+
+void vtech_memexp_device::mreq_w(offs_t offset, uint8_t data)
+{
+ m_mem->write8(offset, data);
+}
+
+uint8_t vtech_memexp_device::iorq_r(offs_t offset)
+{
+ return m_io->read8(offset);
+}
+
+void vtech_memexp_device::iorq_w(offs_t offset, uint8_t data)
+{
+ m_io->write8(offset, data);
+}