diff options
author | Aaron Giles <aaron@aarongiles.com> | 2012-04-20 05:54:39 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2012-04-20 05:54:39 +0000 |
commit | 18f33f4eff805592f984a31f55513bce4a219ee5 (patch) | |
tree | 9e8dfdf1452e3d97a95936db2e9c740efa258306 /src/emu/memory.h | |
parent | 776d29c90f2a6c3c234597eb950410b95c5addec (diff) |
Changed device->subregion to device->memregion. Moved
memory_region management into the memory manager instead
of directly in the machine. Hid the global region method;
now all regions must be looked up relative to a device.
If you're a member function, you can just use memregion("tag")
directly. If you're a global function or a device referencing
global regions, use machine().root_device().memregion("tag")
to look up regions relative to the root.
S&R to convert all references:
machine([()]*)\.region
machine\1\.root_device\(\).subregion
Then remove redundant machine().root_device() within src/mame:
([ \t])machine\(\)\.root_device\(\)\.
\1
And use state->memregion() if we have a state variable present:
(state *= *[^;]+driver_data[^}]+)([^ \t]*)machine[()]*\.root_device\(\)\.
\1state->
Finally some cleanup:
screen.state->
state->
device->state->
state->
space->state->
state->
And a few hand-tweaks.
Diffstat (limited to 'src/emu/memory.h')
-rw-r--r-- | src/emu/memory.h | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/src/emu/memory.h b/src/emu/memory.h index cb2c4eb47d7..b40f378bffc 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -740,6 +740,62 @@ private: }; +// ======================> memory_region + +// memory region object +class memory_region +{ + DISABLE_COPYING(memory_region); + + friend class memory_manager; + friend class simple_list<memory_region>; + friend resource_pool_object<memory_region>::~resource_pool_object(); + + // construction/destruction + memory_region(running_machine &machine, const char *name, UINT32 length, UINT8 width, endianness_t endian); + +public: + // getters + running_machine &machine() const { return m_machine; } + memory_region *next() const { return m_next; } + UINT8 *base() { return (this != NULL) ? &m_buffer[0] : NULL; } + UINT8 *end() { return (this != NULL) ? base() + m_buffer.count() : NULL; } + UINT32 bytes() const { return (this != NULL) ? m_buffer.count() : 0; } + const char *name() const { return m_name; } + + // flag expansion + endianness_t endianness() const { return m_endianness; } + UINT8 width() const { return m_width; } + + // data access + UINT8 &u8(offs_t offset = 0) { return m_buffer[offset]; } + UINT16 &u16(offs_t offset = 0) { return reinterpret_cast<UINT16 *>(base())[offset]; } + UINT32 &u32(offs_t offset = 0) { return reinterpret_cast<UINT32 *>(base())[offset]; } + UINT64 &u64(offs_t offset = 0) { return reinterpret_cast<UINT64 *>(base())[offset]; } + + // allow passing a region for any common pointer + operator void *() { return (this != NULL) ? reinterpret_cast<void *>(base()) : NULL; } + operator INT8 *() { return (this != NULL) ? reinterpret_cast<INT8 *>(base()) : NULL; } + operator UINT8 *() { return (this != NULL) ? reinterpret_cast<UINT8 *>(base()) : NULL; } + operator INT16 *() { return (this != NULL) ? reinterpret_cast<INT16 *>(base()) : NULL; } + operator UINT16 *() { return (this != NULL) ? reinterpret_cast<UINT16 *>(base()) : NULL; } + operator INT32 *() { return (this != NULL) ? reinterpret_cast<INT32 *>(base()) : NULL; } + operator UINT32 *() { return (this != NULL) ? reinterpret_cast<UINT32 *>(base()) : NULL; } + operator INT64 *() { return (this != NULL) ? reinterpret_cast<INT64 *>(base()) : NULL; } + operator UINT64 *() { return (this != NULL) ? reinterpret_cast<UINT64 *>(base()) : NULL; } + +private: + // internal data + running_machine & m_machine; + memory_region * m_next; + astring m_name; + dynamic_buffer m_buffer; + UINT8 m_width; + endianness_t m_endianness; +}; + + + // ======================> memory_manager // holds internal state for the memory system @@ -748,14 +804,17 @@ class memory_manager friend class address_space; friend class address_table; friend class device_t; + friend class memory_block; public: // construction/destruction memory_manager(running_machine &machine); + void initialize(); // getters running_machine &machine() const { return m_machine; } address_space *first_space() const { return m_spacelist.first(); } + memory_region *first_region() const { return m_regionlist.first(); } // get a pointer to a shared memory region by tag memory_share *shared(const char *tag); @@ -767,10 +826,15 @@ public: // pointers to a bank pointer (internal usage only) UINT8 **bank_pointer_addr(UINT8 index, bool decrypted = false) { return decrypted ? &m_bankd_ptr[index] : &m_bank_ptr[index]; } + // regions + memory_region *region_alloc(const char *name, UINT32 length, UINT8 width, endianness_t endian); + void region_free(const char *name); + private: // internal helpers memory_bank *first_bank() const { return m_banklist.first(); } - memory_bank *bank(const char *tag) const { return m_bankmap.find_hash_only(tag); } + memory_bank *bank(const char *tag) const { return m_bankmap.find(tag); } + memory_region *region(const char *tag) { return m_regionlist.find(tag); } void bank_reattach(); // internal state @@ -788,6 +852,8 @@ private: UINT8 m_banknext; // next bank to allocate tagged_list<memory_share> m_sharelist; // map for share lookups + + tagged_list<memory_region> m_regionlist; // list of memory regions }; |