From 91108d0b60d0b07f84f29b44d03d803c1913ffec Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Sat, 22 Feb 2014 11:01:31 +0000 Subject: Merge memarray improvements from palette branch into trunk (nw) --- src/emu/memarray.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/emu/memarray.h') diff --git a/src/emu/memarray.h b/src/emu/memarray.h index 1b963b7e3a0..e4b3e583b76 100644 --- a/src/emu/memarray.h +++ b/src/emu/memarray.h @@ -45,15 +45,17 @@ public: // construction/destruction memory_array(); memory_array(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe) { set(base, bytes, membits, endianness, bpe); } + template memory_array(dynamic_array<_Type> &array, endianness_t endianness, int bpe) { set(array, endianness, bpe); } memory_array(const address_space &space, void *base, UINT32 bytes, int bpe) { set(space, base, bytes, bpe); } memory_array(const memory_share &share, int bpe) { set(share, bpe); } - memory_array(const memory_array &helper) { set(helper); } + memory_array(const memory_array &array) { set(array); } // configuration void set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe); + template void set(dynamic_array<_Type> &array, endianness_t endianness, int bpe) { set(&array[0], array.count(), 8*sizeof(_Type), endianness, bpe); } void set(const address_space &space, void *base, UINT32 bytes, int bpe); void set(const memory_share &share, int bpe); - void set(const memory_array &helper); + void set(const memory_array &array); // getters void *base() const { return m_base; } @@ -62,9 +64,19 @@ public: endianness_t endianness() const { return m_endianness; } int bytes_per_entry() const { return m_bytes_per_entry; } - // readers and writers - UINT32 read(int index) { return (this->*m_reader)(index); } - void write(int index, UINT32 data) { (this->*m_writer)(index, data); } + // entry-level readers and writers + UINT32 read(int index) { return (this->*m_read_entry)(index); } + void write(int index, UINT32 data) { (this->*m_write_entry)(index, data); } + + // byte/word/dword-level readers and writers + UINT8 read8(offs_t offset) { return reinterpret_cast(m_base)[offset]; } + UINT16 read16(offs_t offset) { return reinterpret_cast(m_base)[offset]; } + UINT32 read32(offs_t offset) { return reinterpret_cast(m_base)[offset]; } + UINT64 read64(offs_t offset) { return reinterpret_cast(m_base)[offset]; } + void write8(offs_t offset, UINT8 data) { reinterpret_cast(m_base)[offset] = data; } + void write16(offs_t offset, UINT16 data) { reinterpret_cast(m_base)[offset] = data; } + void write32(offs_t offset, UINT32 data) { reinterpret_cast(m_base)[offset] = data; } + void write64(offs_t offset, UINT64 data) { reinterpret_cast(m_base)[offset] = data; } private: // internal read/write helpers for 1 byte entries @@ -100,8 +112,8 @@ private: int m_membits; endianness_t m_endianness; int m_bytes_per_entry; - UINT32 (memory_array::*m_reader)(int); - void (memory_array::*m_writer)(int, UINT32); + UINT32 (memory_array::*m_read_entry)(int); + void (memory_array::*m_write_entry)(int, UINT32); }; -- cgit v1.2.3-70-g09d2