From ba3fb1648f6a09f2b06379f36460065386639780 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 18 Jul 2023 10:55:38 -0400 Subject: [PATCH] v25: Add address translation for IDB window --- src/devices/cpu/nec/v25.cpp | 2 +- src/devices/cpu/nec/v25.h | 3 ++- src/devices/cpu/nec/v25sfr.cpp | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/devices/cpu/nec/v25.cpp b/src/devices/cpu/nec/v25.cpp index 5c0b04000e6..6d96206f0ed 100644 --- a/src/devices/cpu/nec/v25.cpp +++ b/src/devices/cpu/nec/v25.cpp @@ -630,7 +630,7 @@ void v25_common_device::device_start() m_program->cache(m_cache16); m_dr8 = [this](offs_t address) -> u8 { return m_cache16.read_byte(address); }; } - m_data = &space(AS_DATA); + space(AS_DATA).specific(m_data); m_io = &space(AS_IO); state_add( V25_PC, "PC", m_ip).formatstr("%04X"); diff --git a/src/devices/cpu/nec/v25.h b/src/devices/cpu/nec/v25.h index 1afeb9a7eb5..726f4557e59 100644 --- a/src/devices/cpu/nec/v25.h +++ b/src/devices/cpu/nec/v25.h @@ -63,6 +63,7 @@ protected: // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; + virtual bool memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; @@ -126,7 +127,7 @@ private: address_space *m_program; std::function m_dr8; - address_space *m_data; + memory_access<9, 1, 0, ENDIANNESS_LITTLE>::specific m_data; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/nec/v25sfr.cpp b/src/devices/cpu/nec/v25sfr.cpp index 81d9d5569b0..44ad9300a4d 100644 --- a/src/devices/cpu/nec/v25sfr.cpp +++ b/src/devices/cpu/nec/v25sfr.cpp @@ -605,7 +605,7 @@ void v25_common_device::idb_w(uint8_t d) uint8_t v25_common_device::v25_read_byte(unsigned a) { if (((a & 0xffe00) == m_IDB && (m_RAMEN || BIT(a, 8))) || a == 0xfffff) - return m_data->read_byte(a & 0x1ff); + return m_data.read_byte(a & 0x1ff); else return m_program->read_byte(a); } @@ -617,9 +617,9 @@ uint16_t v25_common_device::v25_read_word(unsigned a) // not sure about this - manual says FFFFC-FFFFE are "reserved" if (a == 0xffffe) - return (m_program->read_byte(a) | (m_data->read_byte(0x1ff) << 8)); + return (m_program->read_byte(a) | (m_data.read_byte(0x1ff) << 8)); else if ((a & 0xffe00) == m_IDB && (m_RAMEN || BIT(a, 8))) - return m_data->read_word(a & 0x1ff); + return m_data.read_word(a & 0x1ff); else return m_program->read_word(a); } @@ -627,7 +627,7 @@ uint16_t v25_common_device::v25_read_word(unsigned a) void v25_common_device::v25_write_byte(unsigned a, uint8_t d) { if (((a & 0xffe00) == m_IDB && (m_RAMEN || BIT(a, 8))) || a == 0xfffff) - m_data->write_byte(a & 0x1ff, d); + m_data.write_byte(a & 0x1ff, d); else m_program->write_byte(a, d); } @@ -645,10 +645,22 @@ void v25_common_device::v25_write_word(unsigned a, uint16_t d) if (a == 0xffffe) { m_program->write_byte(a, d); - m_data->write_byte(0x1ff, d >> 8); + m_data.write_byte(0x1ff, d >> 8); } else if ((a & 0xffe00) == m_IDB && (m_RAMEN || BIT(a, 8))) - m_data->write_word(a & 0x1ff, d); + m_data.write_word(a & 0x1ff, d); else m_program->write_word(a, d); } + +bool v25_common_device::memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space) +{ + if (spacenum == AS_PROGRAM && intention != TR_FETCH && (((address & 0xffe00) == m_IDB && (m_RAMEN || BIT(address, 8))) || address == 0xfffff)) + { + address &= 0x1ff; + target_space = &m_data.space(); + } + else + target_space = &space(spacenum); + return true; +}