diff options
Diffstat (limited to 'src/devices/bus/vtech/memexp/memory.cpp')
-rw-r--r-- | src/devices/bus/vtech/memexp/memory.cpp | 111 |
1 files changed, 60 insertions, 51 deletions
diff --git a/src/devices/bus/vtech/memexp/memory.cpp b/src/devices/bus/vtech/memexp/memory.cpp index 1b9465d9da9..bfac5f06b4c 100644 --- a/src/devices/bus/vtech/memexp/memory.cpp +++ b/src/devices/bus/vtech/memexp/memory.cpp @@ -25,31 +25,31 @@ DEFINE_DEVICE_TYPE(VTECH_LASER_64K, vtech_laser_64k_device, "vtech_laser_6 //************************************************************************** //------------------------------------------------- -// laser110_16k_device - constructor +// mem_map - memory space address map //------------------------------------------------- -vtech_laser110_16k_device::vtech_laser110_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, VTECH_LASER110_16K, tag, owner, clock), - device_vtech_memexp_interface(mconfig, *this) +void vtech_laser110_16k_device::mem_map(address_map &map) { + map.unmap_value_high(); + map(0x8000, 0xbfff).ram(); } //------------------------------------------------- -// device_start - device-specific startup +// laser110_16k_device - constructor //------------------------------------------------- -void vtech_laser110_16k_device::device_start() +vtech_laser110_16k_device::vtech_laser110_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + vtech_memexp_device(mconfig, VTECH_LASER110_16K, tag, owner, clock) { - m_ram.resize(16 * 1024); } //------------------------------------------------- -// device_reset - device-specific reset +// device_start - device-specific startup //------------------------------------------------- -void vtech_laser110_16k_device::device_reset() +void vtech_laser110_16k_device::device_start() { - program_space().install_ram(0x8000, 0xbfff, &m_ram[0]); + vtech_memexp_device::device_start(); } @@ -58,31 +58,31 @@ void vtech_laser110_16k_device::device_reset() //************************************************************************** //------------------------------------------------- -// vtech_laser210_16k_device - constructor +// mem_map - memory space address map //------------------------------------------------- -vtech_laser210_16k_device::vtech_laser210_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, VTECH_LASER210_16K, tag, owner, clock), - device_vtech_memexp_interface(mconfig, *this) +void vtech_laser210_16k_device::mem_map(address_map &map) { + map.unmap_value_high(); + map(0x9000, 0xcfff).ram(); } //------------------------------------------------- -// device_start - device-specific startup +// vtech_laser210_16k_device - constructor //------------------------------------------------- -void vtech_laser210_16k_device::device_start() +vtech_laser210_16k_device::vtech_laser210_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + vtech_memexp_device(mconfig, VTECH_LASER210_16K, tag, owner, clock) { - m_ram.resize(16 * 1024); } //------------------------------------------------- -// device_reset - device-specific reset +// device_start - device-specific startup //------------------------------------------------- -void vtech_laser210_16k_device::device_reset() +void vtech_laser210_16k_device::device_start() { - program_space().install_ram(0x9000, 0xcfff, &m_ram[0]); + vtech_memexp_device::device_start(); } @@ -91,12 +91,21 @@ void vtech_laser210_16k_device::device_reset() //************************************************************************** //------------------------------------------------- +// mem_map - memory space address map +//------------------------------------------------- + +void vtech_laser310_16k_device::mem_map(address_map &map) +{ + map.unmap_value_high(); + map(0xb800, 0xf7ff).ram(); +} + +//------------------------------------------------- // vtech_laser310_16k_device - constructor //------------------------------------------------- vtech_laser310_16k_device::vtech_laser310_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, VTECH_LASER310_16K, tag, owner, clock), - device_vtech_memexp_interface(mconfig, *this) + vtech_memexp_device(mconfig, VTECH_LASER310_16K, tag, owner, clock) { } @@ -106,30 +115,42 @@ vtech_laser310_16k_device::vtech_laser310_16k_device(const machine_config &mconf void vtech_laser310_16k_device::device_start() { - m_ram.resize(16 * 1024); + vtech_memexp_device::device_start(); } + +//************************************************************************** +// VZ300 64K DEVICE +//************************************************************************** + //------------------------------------------------- -// device_reset - device-specific reset +// mem_map - memory space address map //------------------------------------------------- -void vtech_laser310_16k_device::device_reset() +void vtech_laser_64k_device::mem_map(address_map &map) { - program_space().install_ram(0xb800, 0xf7ff, &m_ram[0]); + map.unmap_value_high(); + map(0x8000, 0xbfff).bankrw(m_fixed_bank); + map(0xc000, 0xffff).bankrw(m_bank); } +//------------------------------------------------- +// io_map - memory space address map +//------------------------------------------------- -//************************************************************************** -// VZ300 64K DEVICE -//************************************************************************** +void vtech_laser_64k_device::io_map(address_map &map) +{ + map.unmap_value_high(); + map(0x70, 0x70).mirror(0x0f).lw8(NAME([this] (uint8_t data) { m_bank->set_entry(data & 0x03); })); +} //------------------------------------------------- // vtech_laser_64k_device - constructor //------------------------------------------------- vtech_laser_64k_device::vtech_laser_64k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, VTECH_LASER_64K, tag, owner, clock), - device_vtech_memexp_interface(mconfig, *this), + vtech_memexp_device(mconfig, VTECH_LASER_64K, tag, owner, clock), + m_fixed_bank(*this, "fixed_bank"), m_bank(*this, "bank") { } @@ -140,29 +161,17 @@ vtech_laser_64k_device::vtech_laser_64k_device(const machine_config &mconfig, co void vtech_laser_64k_device::device_start() { - m_ram.resize(64 * 1024); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- + vtech_memexp_device::device_start(); -void vtech_laser_64k_device::device_reset() -{ - // fixed first bank - program_space().install_ram(0x8000, 0xbfff, &m_ram[0]); + // init ram + m_ram = std::make_unique<uint8_t[]>(0x10000); - // other banks - program_space().install_readwrite_bank(0xc000, 0xffff, m_bank); + // configure banking + m_fixed_bank->set_base(m_ram.get()); - m_bank->configure_entries(0, 4, &m_ram[0], 0x4000); + m_bank->configure_entries(0, 4, m_ram.get(), 0x4000); m_bank->set_entry(1); - // bank switch - io_space().install_write_handler(0x70, 0x7f, write8smo_delegate(*this, FUNC(vtech_laser_64k_device::bankswitch_w))); -} - -void vtech_laser_64k_device::bankswitch_w(uint8_t data) -{ - m_bank->set_entry(data & 0x03); + // register for savestates + save_pointer(NAME(m_ram), 0x10000); } |