diff options
author | 2010-08-19 06:57:51 +0000 | |
---|---|---|
committer | 2010-08-19 06:57:51 +0000 | |
commit | dd19e512c03c58a100ae5025c9fd7624387667fd (patch) | |
tree | 28462fd2aa1b3a76b823d5c21ce65678085e6c8f /src/emu/dimemory.h | |
parent | bf9afe4c4bb2112d706452c7b73bd8ebce16e3e0 (diff) |
Massive memory system change. This is another step along the path toward
supporting cleaner implementations of drivers in the explicitly OO world.
Expect a follow-on of several more changes to clean up from this one, which
deliberately tried to avoid touching much driver code.
Converted address_space to a class, and moved most members behind accessor
methods, apart from space->machine and space->cpu. Removed external references
to 8le/8be/16le/16be/32le/32be/64le/64be. All external access is now done via
virtual functions read_byte()/read_word()/etc. Moved differentiation between
the endianness and the bus width internal to memory.c, and also added a new
axis to support small/large address spaces, which allows for faster lookups
on spaces smaller than 18 bits.
Provided methods for most global memory operations within the new address_space
class. These will be bulk converted in a future update, but for now there are
inline wrappers to hide this change from existing callers.
Created new module delegate.h which implements C++ delegates in a form that
works for MAME. Details are in the opening comment. Delegates allow member
functions of certain classes to be used as callbacks, which will hopefully
be the beginning of the end of fetching the driver_data field in most
callbacks. All classes that host delegates must derive from bindable_object.
Today, all devices and driver_data do implicitly via their base class.
Defined delegates for read/write handlers. The new delegates are always
passed an address_space reference, along with offset, data, and mask. Delegates
can refer to methods either in the driver_data class or in a device class.
To specify a callback in an address map, just use AM_READ_MEMBER(class, member).
In fact, all existing AM_ macros that take read/write handlers can now accept
delegates in their place. Delegates that are specified in an address map are
proto-delegates which have no object; they are bound to their object when
the corresponding address_space is created.
Added machine->m_nonspecific_space which can be passed as the required
address_space parameter to the new read/write methods in legacy situations
where the space is not provided. Eventually this can go away but we will
need it for a while yet.
Added methods to the new address_space class to dynamically install delegates
just like you can dynamically install handlers today. Delegates installed this
way must be pre-bound to their object.
Moved beathead's read/write handlers into members of beathead_state as an
example of using the new delegates. This provides examples of both static (via
an address_map) and dynamic (via install_handler calls) mapping using delegates.
Added read/write member functions to okim6295_device as an example of using
delegates to call devices. Updated audio/williams.c as a single example of
calling the device via its member function callbacks. These will be bulk
updated in a future update, and the old global callbacks removed.
Changed the DIRECT_UPDATE_CALLBACKs into delegates as well. Updated all users
to the new function format. Added methods on direct_read_data for configuring the
parameters in a standard way to make the implementation clearer.
Created a simple_list template container class for managing the common
singly-linked lists we use all over in the project.
Many other internal changes in memory.c, mostly involving restructuring the code
into proper classes.
Diffstat (limited to 'src/emu/dimemory.h')
-rw-r--r-- | src/emu/dimemory.h | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h index 633f4def973..fd3ab38cc44 100644 --- a/src/emu/dimemory.h +++ b/src/emu/dimemory.h @@ -100,48 +100,6 @@ const int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); // TYPE DEFINITIONS //************************************************************************** -// ======================> address_space_config - -class address_space_config -{ -public: - address_space_config(); - address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); - address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); - - inline offs_t addr2byte(offs_t address) const - { - return (m_addrbus_shift < 0) ? (address << -m_addrbus_shift) : (address >> m_addrbus_shift); - } - - inline offs_t addr2byte_end(offs_t address) const - { - return (m_addrbus_shift < 0) ? ((address << -m_addrbus_shift) | ((1 << -m_addrbus_shift) - 1)) : (address >> m_addrbus_shift); - } - - inline offs_t byte2addr(offs_t address) const - { - return (m_addrbus_shift > 0) ? (address << m_addrbus_shift) : (address >> -m_addrbus_shift); - } - - inline offs_t byte2addr_end(offs_t address) const - { - return (m_addrbus_shift > 0) ? ((address << m_addrbus_shift) | ((1 << -m_addrbus_shift) - 1)) : (address >> -m_addrbus_shift); - } - - const char * m_name; - endianness_t m_endianness; - UINT8 m_databus_width; - UINT8 m_addrbus_width; - INT8 m_addrbus_shift; - UINT8 m_logaddr_width; - UINT8 m_page_shift; - address_map_constructor m_internal_map; - address_map_constructor m_default_map; -}; - - - // ======================> device_config_memory_interface // class representing interface-specific configuration state @@ -187,11 +145,11 @@ public: // basic information getters const address_space_config *space_config(int spacenum = 0) const { return m_memory_config.space_config(spacenum); } - const address_space *space(int index = 0) const { return m_addrspace[index]; } - const address_space *space(device_space index) const { return m_addrspace[static_cast<int>(index)]; } + address_space *space(int index = 0) const { return m_addrspace[index]; } + address_space *space(device_space index) const { return m_addrspace[static_cast<int>(index)]; } // address space accessors - void set_address_space(int spacenum, const address_space *space); + void set_address_space(int spacenum, address_space &space); // address translation bool translate(int spacenum, int intention, offs_t &address) { return memory_translate(spacenum, intention, address); } @@ -212,7 +170,7 @@ protected: // configuration const device_config_memory_interface &m_memory_config; // reference to our device_config_execute_interface - const address_space * m_addrspace[ADDRESS_SPACES]; // reported address spaces + address_space * m_addrspace[ADDRESS_SPACES]; // reported address spaces }; |