diff options
author | 2018-05-11 01:12:28 +0900 | |
---|---|---|
committer | 2018-05-11 18:23:04 +0900 | |
commit | 4c24f25845f129f77829fc6d8e701a0e3762be80 (patch) | |
tree | 9bd0b9d5cf348f95ffa86911b71956fdd7f8b410 /src/devices/cpu/nec | |
parent | de781d1d84e064956df88bfec929b573d4800789 (diff) |
emumem: Rename direct_read_handler to memory_access_cache. Parametrize the template on more information (data width, endianness) to make it possible to turn it into an handler cache eventually, and not just a memory block cache. Make it capable of large and unaligned accesses. [O. Galibert]
Diffstat (limited to 'src/devices/cpu/nec')
-rw-r--r-- | src/devices/cpu/nec/nec.cpp | 13 | ||||
-rw-r--r-- | src/devices/cpu/nec/nec.h | 2 | ||||
-rw-r--r-- | src/devices/cpu/nec/v25.cpp | 12 | ||||
-rw-r--r-- | src/devices/cpu/nec/v25.h | 2 |
4 files changed, 21 insertions, 8 deletions
diff --git a/src/devices/cpu/nec/nec.cpp b/src/devices/cpu/nec/nec.cpp index 5b95f818d78..9b7661adc82 100644 --- a/src/devices/cpu/nec/nec.cpp +++ b/src/devices/cpu/nec/nec.cpp @@ -218,7 +218,7 @@ void nec_common_device::do_prefetch(int previous_ICount) uint8_t nec_common_device::fetch() { prefetch(); - return m_direct->read_byte((Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } uint16_t nec_common_device::fetchword() @@ -238,7 +238,7 @@ static uint8_t parity_table[256]; uint8_t nec_common_device::fetchop() { prefetch(); - return m_direct->read_byte(( Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } @@ -419,7 +419,14 @@ void nec_common_device::device_start() save_item(NAME(m_prefetch_reset)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->data_width() == 8) { + auto cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } + m_io = &space(AS_IO); state_add( NEC_PC, "PC", m_debugger_temp).callimport().callexport().formatstr("%05X"); diff --git a/src/devices/cpu/nec/nec.h b/src/devices/cpu/nec/nec.h index 244c448f794..becf599aa94 100644 --- a/src/devices/cpu/nec/nec.h +++ b/src/devices/cpu/nec/nec.h @@ -88,7 +88,7 @@ private: uint8_t m_halted; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t address)> m_dr8; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/nec/v25.cpp b/src/devices/cpu/nec/v25.cpp index 48f3e1d9e27..7a076f2c6c3 100644 --- a/src/devices/cpu/nec/v25.cpp +++ b/src/devices/cpu/nec/v25.cpp @@ -137,7 +137,7 @@ void v25_common_device::do_prefetch(int previous_ICount) uint8_t v25_common_device::fetch() { prefetch(); - return m_direct->read_byte((Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } uint16_t v25_common_device::fetchword() @@ -161,7 +161,7 @@ uint8_t v25_common_device::fetchop() uint8_t ret; prefetch(); - ret = m_direct->read_byte(( Sreg(PS)<<4)+m_ip++, m_fetch_xor); + ret = m_dr8((Sreg(PS)<<4)+m_ip++); if (m_MF == 0) if (m_v25v35_decryptiontable) @@ -511,7 +511,13 @@ void v25_common_device::device_start() save_item(NAME(m_prefetch_reset)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->data_width() == 8) { + auto cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } m_io = &space(AS_IO); m_pt_in.resolve_safe(0xff); diff --git a/src/devices/cpu/nec/v25.h b/src/devices/cpu/nec/v25.h index e9ab912111b..27a63b739b0 100644 --- a/src/devices/cpu/nec/v25.h +++ b/src/devices/cpu/nec/v25.h @@ -141,7 +141,7 @@ private: uint32_t m_IDB; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t address)> m_dr8; address_space *m_io; int m_icount; |