summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/memarray.h
diff options
context:
space:
mode:
author Alex W. Jackson <alex.w.jackson@gmail.com>2014-02-22 11:01:31 +0000
committer Alex W. Jackson <alex.w.jackson@gmail.com>2014-02-22 11:01:31 +0000
commit91108d0b60d0b07f84f29b44d03d803c1913ffec (patch)
treeb1829403d81d0fe6e270b2ddc0a4f624b480aa54 /src/emu/memarray.h
parent887d09c71d0544b66c41b01857e33b35d8b0d281 (diff)
Merge memarray improvements from palette branch into trunk (nw)
Diffstat (limited to 'src/emu/memarray.h')
-rw-r--r--src/emu/memarray.h26
1 files changed, 19 insertions, 7 deletions
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 <typename _Type> 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 <typename _Type> 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<UINT8 *>(m_base)[offset]; }
+ UINT16 read16(offs_t offset) { return reinterpret_cast<UINT16 *>(m_base)[offset]; }
+ UINT32 read32(offs_t offset) { return reinterpret_cast<UINT32 *>(m_base)[offset]; }
+ UINT64 read64(offs_t offset) { return reinterpret_cast<UINT64 *>(m_base)[offset]; }
+ void write8(offs_t offset, UINT8 data) { reinterpret_cast<UINT8 *>(m_base)[offset] = data; }
+ void write16(offs_t offset, UINT16 data) { reinterpret_cast<UINT16 *>(m_base)[offset] = data; }
+ void write32(offs_t offset, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[offset] = data; }
+ void write64(offs_t offset, UINT64 data) { reinterpret_cast<UINT64 *>(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);
};