Commit Graph

17 Commits

Author SHA1 Message Date
Olivier Galibert
2393deea86 naomi: Split the rom boards into a collection of devices. [O. Galibert] 2011-08-23 18:47:49 +00:00
Olivier Galibert
c9fc846c46 memory: Fix an endianness issue when doing a device mapping on a big endian bus [O. Galibert] 2011-08-05 18:52:29 +00:00
Olivier Galibert
abc59bb3f8 addrmap: Allow adding device-sourced memory maps in the main map. [O. Galibert]
Device-side, it only works for modern device.  Declare the map with
DECLARE_ADDRESS_MAP(name, width).  It's a method which can be virtual
but not static.

In the implementation, define ADDRESS_MAP_MODERN, and define the map
starting with DEVICE_ADDRESS_MAP_START(name, width, device_class).
Rest is like a normal modern map.

To include it in the memory map use:
  AM_DEVICE( "device tag", devicea_class, name )

Or for device with differing widths:
  AM_DEVICE8(  "device tag", devicea_class, name, unitmask )
  AM_DEVICE16( "device tag", devicea_class, name, unitmask )
  AM_DEVICE32( "device tag", devicea_class, name, unitmask )
2011-07-05 04:41:06 +00:00
Miodrag Milanovic
b734d88389 - Removed difference between handling driver and device address maps
- Updated modern macros to propagate device so it is possible to make modern maps for devices too
- Updated bsmt2000.c and mie.c as examples of modern address map devices
2011-05-08 18:07:36 +00:00
smf-
dbf11f83ae reapplied change until someone can actually explain where it causes a problem. 2011-05-08 13:41:43 +00:00
Miodrag Milanovic
33b33272ac Reverting back addrmap changes and adding AM_SUBDEVICE macro to help addressing cpu sub devices in address maps (no whatsnew) 2011-05-08 10:55:12 +00:00
Aaron Giles
919913f118 Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this
environment. This in general greatly simplifies writing a modern
device. [Aaron Giles]

General notes:
 * some more cleanup probably needs to happen behind this change,
   but I needed to get it in before the next device modernization 
   or import from MESS  :)

 * new template function device_creator which automatically defines
   the static function that creates the device; use this instead of
   creating a static_alloc_device_config function

 * added device_stop() method which is called at around the time
   the previous device_t's destructor was called; if you auto_free
   anything, do it here because the machine is gone when the 
   destructor is called

 * changed the static_set_* calls to pass a device_t & instead of
   a device_config *

 * for many devices, the static config structure member names over-
   lapped the device's names for devcb_* functions; in these cases
   the members in the interface were renamed to have a _cb suffix

 * changed the driver_enumerator to only cache 100 machine_configs
   because caching them all took a ton of memory; fortunately this
   implementation detail is completely hidden behind the 
   driver_enumerator interface

 * got rid of the macros for creating derived classes; doing it
   manually is now clean enough that it isn't worth hiding the
   details in a macro
2011-04-27 05:11:18 +00:00
Aaron Giles
55866daab8 Delegates 2.0 implementation. Resdesigned how delegates work to make
them more flexible and simpler to use. Got rid of the proto_delegates
altogether in favor of supporting delegates that are bound to NULL
objects. Added a front-end template that supports "natural" syntax
favored by libraries like boost. Added support for static functions
that take reference parameters instead of pointer parameters for the
object type. Updated all delegate users in the system to the new
syntax. [Aaron Giles]

Changed the DIRECT_UPDATE_HANDLER to take a machine reference like 
everything else in the system. Updated all users. [Aaron Giles]

Changed the FUNC() macro to automatically put an & in front of the
item passed. In general this works transparently, however it does have
the nice side-effect of catching situations where a variable is passed
instead of a function name. Fixed those cases to push the naming
upstream so that the name is now provided properly. Also added a
FUNC_NULL macro since FUNC(NULL) no longer works. [Aaron Giles]
2011-04-16 23:02:16 +00:00
Aaron Giles
202d7680a4 Created new enum type address_spacenum for specifying an address
space by index. Update functions and methods that accepted an
address space index to take an address_spacenum instead. Note that
this means you can't use a raw integer in ADDRESS_SPACE macros, so
instead of 0 use the enumerated AS_0.

Standardized the project on the shortened constants AS_* over the
older ADDRESS_SPACE_*. Removed the latter to prevent confusion.
Also centralized the location of these definitions to memory.h.
2011-03-27 07:37:24 +00:00
Aaron Giles
7c2a83e1ef Add DEVICE_SELF_OWNER which allows an address map to refer to the
owner of its owning device. Useful for CPU address map handlers for
CPU's that are part of a device.
2010-12-20 14:08:32 +00:00
Aaron Giles
442e1a2ccf Modernized liberator driver, added save state support.
Moved generalized EAROM handling to atarigen.

Added new (modern) address map macros for referencing member
functions in base classes: AM_READ_BASE(_class, _member),
AM_WRITE_BASE, AM_READWRITE_BASE, etc.

Added BSD licenses to atarigen and er2055.
2010-09-22 08:12:01 +00:00
Aaron Giles
c971dd5b03 Added AM_DEVREAD_MODERN/AM_DEVWRITE_MODERN/etc. macros for the non-modern
address map case so that updated devices can shed their old-style read/write
handlers in favor of member functions.

Bulk converted all okim6295_r/okim6295_w references in the address maps to
call to the modern member functions.
2010-09-05 06:30:20 +00:00
Aaron Giles
0e672ba6eb Cleanups and version bump. 2010-08-30 15:20:58 +00:00
Aaron Giles
aafb63c072 Added an alternate set of address map macros. Now, if you
#define ADDRESS_MAP_MODERN prior to #including "emu.h", you will
get the new macros, which have the following properties:

* ADDRESS_MAP_START takes a 4th parameter, which is the name of the
   driver_data class the other macros will reference

* AM_READ/AM_WRITE/etc. all assume you are providing method names off
   of the driver_data class you originally specified

* AM_READ_LEGACY/AM_WRITE_LEGACY macros are provided for calling
   global static functions of yore

* AM_BASE/AM_SIZE all assume you are providing member names off of the
   driver_Data class

* AM_BASE_LEGACY/AM_SIZE_LEGACY are provided to reference globals if
   necessary

Also removed AM_READ_MEMBER/AM_WRITE_MEMBER/etc from the non-modern
macros. If you want to use member functions in the address map, you
are now required to use the new macros.
2010-08-21 23:47:07 +00:00
Aaron Giles
dd19e512c0 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.
2010-08-19 06:57:51 +00:00
Aaron Giles
ab18e234b0 Cleanups and version bump. 2010-08-12 04:24:53 +00:00
Aaron Giles
fe47da274e Return to type safety. Changed address maps back into functions that build
up the definition, rather than the whole tokenizing system, which lost type
checking. Added a new module addrmap.c which implements the address map
classes, and changed the macros to call methods on the address_map and
address_map_entry classes which are strongly typed.

Fixed a few incorrectly specified memory map entries along the way. Please
double-check to make sure the behavior is expected in: twincobr.c, lordgun.c,
galaxold.c.

This change also means that since the address_maps are now constructor
functions, they are detected when not used, so a number of #ifdef UNUSED_CODE
were added around dangling address map definitions.

Also included with this change:
- removed cputag_clocks_to_attotime() and cputag_attotime_to_clocks() in
   favor of just expanding the class
- same for cputag_suspend() and cputag_resume()
2010-08-01 21:04:03 +00:00