Previous 199869 Revisions Next

r18154 Wednesday 26th September, 2012 at 10:07:49 UTC by Aaron Giles
Moved device_delegates into their own files. Employed a
non-templatized helper class so that the code can live
co-located, rather than invading device.h.

Changed the read/write delegates to derive from
device_delegate. Updated the address map macros to create
these properly.

Removed remnants of the old AM_BASE/SIZE macros from the
memory system.
[src/emu]addrmap.c addrmap.h delegate.h devcb.h devdelegate.c* devdelegate.h* device.h dimemory.c emu.h emu.mak emucore.c emucore.h memory.c memory.h

trunk/src/emu/device.h
r18153r18154
992992   return (tag[0] == ':') ? subdevice(tag) : NULL;
993993}
994994
995
996//-------------------------------------------------
997//  bind_relative_to - perform a late binding of
998//  a device_delegate
999//-------------------------------------------------
1000
1001template<typename _Signature>
1002void device_delegate<_Signature>::bind_relative_to(device_t &search_root)
1003{
1004   if (!basetype::isnull())
1005   {
1006      device_t *device = search_root.subdevice(m_device_name);
1007      if (device == NULL)
1008         throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag());
1009      basetype::late_bind(*device);
1010   }
1011}
1012
1013995#endif   /* __DEVINTRF_H__ */
trunk/src/emu/memory.c
r18153r18154
18281828      }
18291829
18301830      // validate adjusted addresses against implicit regions
1831      if (entry->m_region != NULL && entry->m_share == NULL && entry->m_baseptr == NULL)
1831      if (entry->m_region != NULL && entry->m_share == NULL)
18321832      {
18331833         // determine full tag
18341834         astring fulltag;
r18153r18154
19031903void address_space::populate_map_entry(const address_map_entry &entry, read_or_write readorwrite)
19041904{
19051905   const map_handler_data &data = (readorwrite == ROW_READ) ? entry.m_read : entry.m_write;
1906   device_t *target_device;
19071906   astring fulltag;
19081907
19091908   // based on the handler type, alter the bits, name, funcptr, and object
r18153r18154
19311930         break;
19321931
19331932      case AMH_DEVICE_DELEGATE:
1934         target_device = device().siblingdevice(data.m_tag);
1935         if (target_device == NULL)
1936            throw emu_fatalerror("Attempted to map a non-existent device '%s' in space %s of device '%s'\n", data.m_tag.cstr(), m_name, m_device.tag());
1937
19381933         if (readorwrite == ROW_READ)
19391934            switch (data.m_bits)
19401935            {
1941               case 8:      install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read8_delegate(entry.m_rproto8, *target_device), data.m_mask);      break;
1942               case 16:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read16_delegate(entry.m_rproto16, *target_device), data.m_mask);      break;
1943               case 32:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read32_delegate(entry.m_rproto32, *target_device), data.m_mask);      break;
1944               case 64:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read64_delegate(entry.m_rproto64, *target_device), data.m_mask);      break;
1936               case 8:      install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read8_delegate(entry.m_rproto8, *entry.m_read.m_devbase), data.m_mask); break;
1937               case 16:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read16_delegate(entry.m_rproto16, *entry.m_read.m_devbase), data.m_mask); break;
1938               case 32:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read32_delegate(entry.m_rproto32, *entry.m_read.m_devbase), data.m_mask); break;
1939               case 64:   install_read_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, read64_delegate(entry.m_rproto64, *entry.m_read.m_devbase), data.m_mask); break;
19451940            }
19461941         else
19471942            switch (data.m_bits)
19481943            {
1949               case 8:      install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write8_delegate(entry.m_wproto8, *target_device), data.m_mask);      break;
1950               case 16:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write16_delegate(entry.m_wproto16, *target_device), data.m_mask);   break;
1951               case 32:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write32_delegate(entry.m_wproto32, *target_device), data.m_mask);   break;
1952               case 64:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write64_delegate(entry.m_wproto64, *target_device), data.m_mask);   break;
1944               case 8:      install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write8_delegate(entry.m_wproto8, *entry.m_write.m_devbase), data.m_mask); break;
1945               case 16:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write16_delegate(entry.m_wproto16, *entry.m_write.m_devbase), data.m_mask); break;
1946               case 32:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write32_delegate(entry.m_wproto32, *entry.m_write.m_devbase), data.m_mask); break;
1947               case 64:   install_write_handler(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, write64_delegate(entry.m_wproto64, *entry.m_write.m_devbase), data.m_mask); break;
19531948            }
19541949         break;
19551950
r18153r18154
19741969
19751970      case AMH_PORT:
19761971         install_readwrite_port(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror,
1977                     (readorwrite == ROW_READ) ? data.m_tag.cstr() : NULL,
1978                     (readorwrite == ROW_WRITE) ? data.m_tag.cstr() : NULL);
1972                     (readorwrite == ROW_READ) ? data.m_tag : NULL,
1973                     (readorwrite == ROW_WRITE) ? data.m_tag : NULL);
19791974         break;
19801975
19811976      case AMH_BANK:
19821977         install_bank_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror,
1983                     (readorwrite == ROW_READ) ? data.m_tag.cstr() : NULL,
1984                     (readorwrite == ROW_WRITE) ? data.m_tag.cstr() : NULL);
1978                     (readorwrite == ROW_READ) ? data.m_tag : NULL,
1979                     (readorwrite == ROW_WRITE) ? data.m_tag : NULL);
19851980         break;
19861981
19871982      case AMH_DEVICE_SUBMAP:
1988         throw emu_fatalerror("Internal mapping error: leftover mapping of '%s'.\n", data.m_tag.cstr());
1983         throw emu_fatalerror("Internal mapping error: leftover mapping of '%s'.\n", data.m_tag);
19891984   }
19901985}
19911986
r18153r18154
20672062
20682063void address_space::locate_memory()
20692064{
2070   // fill in base/size entries
2071   for (const address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next())
2072   {
2073      if (entry->m_baseptr != NULL)
2074         *entry->m_baseptr = entry->m_memory;
2075      if (entry->m_baseptroffs_plus1 != 0)
2076         *(void **)(reinterpret_cast<UINT8 *>(machine().driver_data()) + entry->m_baseptroffs_plus1 - 1) = entry->m_memory;
2077      if (entry->m_sizeptr != NULL)
2078         *entry->m_sizeptr = entry->m_byteend - entry->m_bytestart + 1;
2079      if (entry->m_sizeptroffs_plus1 != 0)
2080         *(size_t *)(reinterpret_cast<UINT8 *>(machine().driver_data()) + entry->m_sizeptroffs_plus1 - 1) = entry->m_byteend - entry->m_bytestart + 1;
2081   }
2082
20832065   // once this is done, find the starting bases for the banks
20842066   for (memory_bank *bank = manager().m_banklist.first(); bank != NULL; bank = bank->next())
20852067      if (bank->base() == NULL && bank->references_space(*this, ROW_READWRITE))
r18153r18154
27132695
27142696bool address_space::needs_backing_store(const address_map_entry *entry)
27152697{
2716   // if we are asked to provide a base pointer, then yes, we do need backing
2717   if (entry->m_baseptr != NULL || entry->m_baseptroffs_plus1 != 0)
2718      return true;
2719
27202698   // if we are sharing, and we don't have a pointer yet, create one
27212699   if (entry->m_share != NULL)
27222700   {
trunk/src/emu/memory.h
r18153r18154
105105typedef UINT32   offs_t;
106106
107107// address map constructors are functions that build up an address_map
108typedef void (*address_map_constructor)(address_map &map, const device_t &devconfig);
108typedef void (*address_map_constructor)(address_map &map, device_t &devconfig);
109109
110110// submap retriever delegate
111typedef delegate<void (address_map &, const device_t &)> address_map_delegate;
111typedef delegate<void (address_map &, device_t &)> address_map_delegate;
112112
113113
114114// legacy space read/write handlers
r18153r18154
162162// ======================> read_delegate
163163
164164// declare delegates for each width
165typedef delegate<UINT8 (address_space &, offs_t, UINT8)> read8_delegate;
166typedef delegate<UINT16 (address_space &, offs_t, UINT16)> read16_delegate;
167typedef delegate<UINT32 (address_space &, offs_t, UINT32)> read32_delegate;
168typedef delegate<UINT64 (address_space &, offs_t, UINT64)> read64_delegate;
165typedef device_delegate<UINT8 (address_space &, offs_t, UINT8)> read8_delegate;
166typedef device_delegate<UINT16 (address_space &, offs_t, UINT16)> read16_delegate;
167typedef device_delegate<UINT32 (address_space &, offs_t, UINT32)> read32_delegate;
168typedef device_delegate<UINT64 (address_space &, offs_t, UINT64)> read64_delegate;
169169
170170
171171// ======================> write_delegate
172172
173173// declare delegates for each width
174typedef delegate<void (address_space &, offs_t, UINT8, UINT8)> write8_delegate;
175typedef delegate<void (address_space &, offs_t, UINT16, UINT16)> write16_delegate;
176typedef delegate<void (address_space &, offs_t, UINT32, UINT32)> write32_delegate;
177typedef delegate<void (address_space &, offs_t, UINT64, UINT64)> write64_delegate;
174typedef device_delegate<void (address_space &, offs_t, UINT8, UINT8)> write8_delegate;
175typedef device_delegate<void (address_space &, offs_t, UINT16, UINT16)> write16_delegate;
176typedef device_delegate<void (address_space &, offs_t, UINT32, UINT32)> write32_delegate;
177typedef device_delegate<void (address_space &, offs_t, UINT64, UINT64)> write64_delegate;
178178
179179
180180// ======================> direct_read_data
trunk/src/emu/emu.h
r18153r18154
6767#include "hash.h"
6868#include "fileio.h" // remove me once NVRAM is implemented as device
6969#include "delegate.h"
70#include "devdelegate.h"
7071
7172// memory and address spaces
7273#include "memory.h"
r18153r18154
8182class machine_config;
8283typedef device_t * (*machine_config_constructor)(machine_config &config, device_t *owner);
8384
84// device_delegate is a delegate that wraps with a device tag and can be easily
85// late bound without replicating logic everywhere
86template<typename _Signature>
87class device_delegate : public delegate<_Signature>
88{
89   typedef delegate<_Signature> basetype;
90
91public:
92   // provide same set of constructors as the base class, with additional device name
93   // parameter
94   device_delegate() : basetype(), m_device_name(NULL) { }
95   device_delegate(const basetype &src) : basetype(src), m_device_name(src.m_device_name) { }
96   device_delegate(const basetype &src, delegate_late_bind &object) : basetype(src, object), m_device_name(src.m_device_name) { }
97   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname) : basetype(funcptr, name, (_FunctionClass *)0), m_device_name(devname) { }
98   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), m_device_name(devname) { }
99   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), m_device_name(devname) { }
100   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_ref_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), m_device_name(devname) { }
101   device_delegate(typename basetype::template traits<device_t>::static_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), m_device_name(NULL) { }
102   device_delegate(typename basetype::template traits<device_t>::static_ref_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), m_device_name(NULL) { }
103   device_delegate &operator=(const basetype &src) { *static_cast<basetype *>(this) = src; m_device_name = src.m_device_name; return *this; }
104
105   // perform the binding
106   void bind_relative_to(device_t &search_root);
107
108private:
109   // internal state
110   const char *m_device_name;
111};
112
11385// I/O
11486#include "input.h"
11587#include "ioport.h"
trunk/src/emu/delegate.h
r18153r18154
448448   template<class _FunctionClass>
449449   static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
450450   {
451      return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
451      _FunctionClass *result = dynamic_cast<_FunctionClass *>(&object);
452      return reinterpret_cast<delegate_generic_class *>(result);
452453   }
453454
454455   // internal state
r18153r18154
636637   template<class _FunctionClass>
637638   static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
638639   {
639      return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
640      _FunctionClass *result = dynamic_cast<_FunctionClass *>(&object);
641      return reinterpret_cast<delegate_generic_class *>(result);
640642   }
641643
642644   // internal state
r18153r18154
761763   delegate &operator=(const basetype &src) { *static_cast<basetype *>(this) = src; return *this; }
762764};
763765
764// Some useful delegates
765
766typedef delegate<void (bool state)> line_cb_t;
767
768766#endif   /* __DELEGATE_H__ */
trunk/src/emu/dimemory.c
r18153r18154
241241         int alignunit = datawidth / 8;
242242
243243         // construct the maps
244         ::address_map *map = global_alloc(::address_map(device(), spacenum));
244         ::address_map *map = global_alloc(::address_map(const_cast<device_t &>(device()), spacenum));
245245
246246         // if this is an empty map, just skip it
247247         if (map->m_entrylist.first() == NULL)
r18153r18154
323323            }
324324
325325            // make sure all devices exist
326            if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag && device().siblingdevice(entry->m_read.m_tag) == NULL)
327               mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_read.m_tag.cstr());
328            if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag && device().siblingdevice(entry->m_write.m_tag) == NULL)
329               mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_write.m_tag.cstr());
326            if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag != NULL)
327            {
328               astring temp(entry->m_read.m_tag);
329               if (device().siblingdevice(temp) == NULL)
330                  mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_read.m_tag);
331            }
332            if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag != NULL)
333            {
334               astring temp(entry->m_write.m_tag);
335               if (device().siblingdevice(temp) == NULL)
336                  mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_write.m_tag);
337            }
330338
331339            // make sure ports exist
332340//              if ((entry->m_read.m_type == AMH_PORT && entry->m_read.m_tag != NULL && portlist.find(entry->m_read.m_tag) == NULL) ||
333341//                  (entry->m_write.m_type == AMH_PORT && entry->m_write.m_tag != NULL && portlist.find(entry->m_write.m_tag) == NULL))
334//                  mame_printf_error("%s space memory map entry references nonexistant port tag '%s'\n", spaceconfig->m_name, entry->m_read.m_tag.cstr());
342//                  mame_printf_error("%s space memory map entry references nonexistant port tag '%s'\n", spaceconfig->m_name, entry->m_read.m_tag);
335343
336344            // validate bank and share tags
337345            if (entry->m_read.m_type == AMH_BANK)
trunk/src/emu/devdelegate.c
r0r18154
1/***************************************************************************
2
3    devdelegate.c
4
5    Delegates that are late-bound to MAME devices.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#include "emu.h"
41
42
43//-------------------------------------------------
44//  bound_object - use the device name to locate
45//   a device relative to the given search root;
46//   fatal error if not found
47//-------------------------------------------------
48
49delegate_late_bind &device_delegate_helper::bound_object(device_t &search_root)
50{
51   device_t *device = search_root.subdevice(m_device_name);
52   if (device == NULL)
53      throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag());
54   return *device;
55}
56
57
58//-------------------------------------------------
59//  safe_tag - return a tag string or (unknown) if
60//   the object is not valid
61//-------------------------------------------------
62
63const char *device_delegate_helper::safe_tag(device_t *object)
64{
65   return (object != NULL) ? object->tag() : "(unknown)";
66}
trunk/src/emu/devdelegate.h
r0r18154
1/***************************************************************************
2
3    devdelegate.h
4
5    Delegates that are late-bound to MAME devices.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#pragma once
41
42#ifndef __DEVDELEGATE_H__
43#define __DEVDELEGATE_H__
44
45#include "delegate.h"
46
47
48//**************************************************************************
49//  TYPE DEFINITIONS
50//**************************************************************************
51
52// ======================> device_delegate_helper
53
54// device_delegate_helper does non-template work
55class device_delegate_helper
56{
57protected:
58   // constructor
59   device_delegate_helper(const char *devname) : m_device_name(devname) { }
60   
61   // internal helpers
62   delegate_late_bind &bound_object(device_t &search_root);
63   static const char *safe_tag(device_t *object);
64
65   // internal state
66   const char *m_device_name;
67};
68
69
70// ======================> device_delegate
71
72// device_delegate is a delegate that wraps with a device tag and can be easily
73// late bound without replicating logic everywhere
74template<typename _Signature>
75class device_delegate : public delegate<_Signature>, device_delegate_helper
76{
77   typedef device_delegate<_Signature> thistype;
78   typedef delegate<_Signature> basetype;
79
80public:
81   // provide the same constructors as the base class
82   device_delegate() : basetype(), device_delegate_helper(NULL) { }
83   device_delegate(const basetype &src) : basetype(src), device_delegate_helper(src.m_device_name) { }
84   device_delegate(const basetype &src, delegate_late_bind &object) : basetype(src, object), device_delegate_helper(src.m_device_name) { }
85   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, _FunctionClass *object) : basetype(funcptr, name, object), device_delegate_helper(safe_tag(dynamic_cast<device_t *>(object))) { }
86   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_func_type funcptr, const char *name, _FunctionClass *object) : basetype(funcptr, name, object), device_delegate_helper(safe_tag(dynamic_cast<device_t *>(object))) { }
87   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_ref_func_type funcptr, const char *name, _FunctionClass *object) : basetype(funcptr, name, object), device_delegate_helper(safe_tag(dynamic_cast<device_t *>(object))) { }
88   device_delegate &operator=(const thistype &src) { *static_cast<basetype *>(this) = src; m_device_name = src.m_device_name; return *this; }
89
90   // provide additional constructors that take a device name string
91   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { }
92   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { }
93   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { }
94   template<class _FunctionClass> device_delegate(typename basetype::template traits<_FunctionClass>::static_ref_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { }
95   device_delegate(typename basetype::template traits<device_t>::static_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), device_delegate_helper(NULL) { }
96   device_delegate(typename basetype::template traits<device_t>::static_ref_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), device_delegate_helper(NULL) { }
97
98   // and constructors that provide a search root
99   device_delegate(const thistype &src, device_t &search_root) : basetype(src), device_delegate_helper(src.m_device_name) { bind_relative_to(search_root); }
100
101   // perform the binding
102   void bind_relative_to(device_t &search_root) { if (!basetype::isnull()) basetype::late_bind(bound_object(search_root)); }
103};
104
105
106#endif   /* __DEVDELEGATE_H__ */
trunk/src/emu/emu.mak
r18153r18154
5454   $(EMUOBJ)/crsshair.o \
5555   $(EMUOBJ)/debugger.o \
5656   $(EMUOBJ)/delegate.o \
57   $(EMUOBJ)/devdelegate.o \
5758   $(EMUOBJ)/devcb.o \
5859   $(EMUOBJ)/devcpu.o \
5960   $(EMUOBJ)/device.o \
trunk/src/emu/emucore.c
r18153r18154
1818         src_type.name(), dst_type.name());
1919}
2020
21void report_bad_device_cast(const device_t *dev, const std::type_info &dst_type)
21void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type)
2222{
2323   throw emu_fatalerror("Error: bad downcast<> or device<>.  Tried to convert the device %s of type %s to a %s, which are incompatible.\n",
24         dev->tag(), dev->name(), dst_type.name());
24         dev->tag(), src_type.name(), dst_type.name());
2525}
trunk/src/emu/emucore.h
r18153r18154
335335class device_t;
336336
337337void report_bad_cast(const std::type_info &src_type, const std::type_info &dst_type);
338void report_bad_device_cast(const device_t *dev, const std::type_info &dst_type);
338void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type);
339339
340340// template function for casting from a base class to a derived class that is checked
341341// in debug builds and fast in release builds
r18153r18154
346346   if (dynamic_cast<_Dest>(src) != src)
347347   {
348348      if (dynamic_cast<const device_t *>(src) != NULL)
349         report_bad_device_cast(dynamic_cast<const device_t *>(src), typeid(_Dest));
349         report_bad_device_cast(dynamic_cast<const device_t *>(src), typeid(src), typeid(_Dest));
350350      else
351351         report_bad_cast(typeid(src), typeid(_Dest));
352352   }
r18153r18154
361361   if (&dynamic_cast<_Dest>(src) != &src)
362362   {
363363      if (dynamic_cast<const device_t *>(&src) != NULL)
364         report_bad_device_cast(dynamic_cast<const device_t *>(&src), typeid(_Dest));
364         report_bad_device_cast(dynamic_cast<const device_t *>(&src), typeid(src), typeid(_Dest));
365365      else
366366         report_bad_cast(typeid(src), typeid(_Dest));
367367   }
trunk/src/emu/addrmap.c
r18153r18154
5656     m_addrmirror(0),
5757     m_addrmask(0),
5858     m_share(NULL),
59     m_baseptr(NULL),
60     m_sizeptr(NULL),
61     m_baseptroffs_plus1(0),
62     m_sizeptroffs_plus1(0),
6359     m_region(NULL),
6460     m_rgnoffs(0),
6561     m_rspace8(NULL),
r18153r18154
9692//  an I/O port
9793//-------------------------------------------------
9894
99void address_map_entry::set_read_port(const device_t &device, const char *tag)
95void address_map_entry::set_read_port(device_t &device, const char *tag)
10096{
10197   m_read.m_type = AMH_PORT;
102   device.subtag(m_read.m_tag, tag);
98   m_read.m_tag = tag;
99   m_read.m_devbase = &device;
103100}
104101
105102
r18153r18154
108105//  an I/O port
109106//-------------------------------------------------
110107
111void address_map_entry::set_write_port(const device_t &device, const char *tag)
108void address_map_entry::set_write_port(device_t &device, const char *tag)
112109{
113110   m_write.m_type = AMH_PORT;
114   device.subtag(m_write.m_tag, tag);
111   m_write.m_tag = tag;
112   m_write.m_devbase = &device;
115113}
116114
117115
r18153r18154
120118//  reading and writing an I/O port
121119//-------------------------------------------------
122120
123void address_map_entry::set_readwrite_port(const device_t &device, const char *tag)
121void address_map_entry::set_readwrite_port(device_t &device, const char *tag)
124122{
125123   m_read.m_type = AMH_PORT;
126   device.subtag(m_read.m_tag, tag);
124   m_read.m_tag = tag;
125   m_read.m_devbase = &device;
127126   m_write.m_type = AMH_PORT;
128   device.subtag(m_write.m_tag, tag);
127   m_write.m_tag = tag;
128   m_write.m_devbase = &device;
129129}
130130
131131
r18153r18154
134134//  from a memory bank
135135//-------------------------------------------------
136136
137void address_map_entry::set_read_bank(const device_t &device, const char *tag)
137void address_map_entry::set_read_bank(device_t &device, const char *tag)
138138{
139139   m_read.m_type = AMH_BANK;
140   device.subtag(m_read.m_tag, tag);
140   m_read.m_tag = tag;
141   m_read.m_devbase = &device;
141142}
142143
143144
r18153r18154
146147//  to a memory bank
147148//-------------------------------------------------
148149
149void address_map_entry::set_write_bank(const device_t &device, const char *tag)
150void address_map_entry::set_write_bank(device_t &device, const char *tag)
150151{
151152   m_write.m_type = AMH_BANK;
152   device.subtag(m_write.m_tag, tag);
153   m_write.m_tag = tag;
154   m_write.m_devbase = &device;
153155}
154156
155157
r18153r18154
158160//  reading and writing to a memory bank
159161//-------------------------------------------------
160162
161void address_map_entry::set_readwrite_bank(const device_t &device, const char *tag)
163void address_map_entry::set_readwrite_bank(device_t &device, const char *tag)
162164{
163165   m_read.m_type = AMH_BANK;
164   device.subtag(m_read.m_tag, tag);
166   m_read.m_tag = tag;
167   m_read.m_devbase = &device;
165168   m_write.m_type = AMH_BANK;
166   device.subtag(m_write.m_tag, tag);
169   m_write.m_tag = tag;
170   m_write.m_devbase = &device;
167171}
168172
169173
r18153r18154
172176//  retrieve a submap from a device
173177//-------------------------------------------------
174178
175void address_map_entry::set_submap(const device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask)
179void address_map_entry::set_submap(device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask)
176180{
177181   if(!bits)
178182      bits = m_map.m_databits;
r18153r18154
180184   assert(unitmask_is_appropriate(bits, mask, func.name()));
181185
182186   m_read.m_type = AMH_DEVICE_SUBMAP;
183   device.subtag(m_read.m_tag, tag);
187   m_read.m_tag = tag;
188   m_read.m_devbase = &device;
184189   m_read.m_mask = mask;
185190   m_write.m_type = AMH_DEVICE_SUBMAP;
186   device.subtag(m_write.m_tag, tag);
191   m_write.m_tag = tag;
192   m_write.m_devbase = &device;
187193   m_write.m_mask = mask;
188194   m_submap_delegate = func;
189195   m_submap_bits = bits;
r18153r18154
226232}
227233
228234
229void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 unitmask)
235void address_map_entry::internal_set_handler(device_t &device, read8_delegate func, UINT64 unitmask)
230236{
231237   assert(!func.isnull());
232238   assert(unitmask_is_appropriate(8, unitmask, func.name()));
r18153r18154
234240   m_read.m_bits = 8;
235241   m_read.m_mask = unitmask;
236242   m_read.m_name = func.name();
237   device.subtag(m_read.m_tag, tag);
243   m_read.m_devbase = &device;
238244   m_rproto8 = func;
239245}
240246
241247
242void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 unitmask)
248void address_map_entry::internal_set_handler(device_t &device, write8_delegate func, UINT64 unitmask)
243249{
244250   assert(!func.isnull());
245251   assert(unitmask_is_appropriate(8, unitmask, func.name()));
r18153r18154
247253   m_write.m_bits = 8;
248254   m_write.m_mask = unitmask;
249255   m_write.m_name = func.name();
250   device.subtag(m_write.m_tag, tag);
256   m_write.m_devbase = &device;
251257   m_wproto8 = func;
252258}
253259
254260
255void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT64 unitmask)
261void address_map_entry::internal_set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 unitmask)
256262{
257   internal_set_handler(device, tag, rfunc, unitmask);
258   internal_set_handler(device, tag, wfunc, unitmask);
263   internal_set_handler(device, rfunc, unitmask);
264   internal_set_handler(device, wfunc, unitmask);
259265}
260266
261267
r18153r18154
295301}
296302
297303
298void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 unitmask)
304void address_map_entry::internal_set_handler(device_t &device, read16_delegate func, UINT64 unitmask)
299305{
300306   assert(!func.isnull());
301307   assert(unitmask_is_appropriate(16, unitmask, func.name()));
r18153r18154
303309   m_read.m_bits = 16;
304310   m_read.m_mask = unitmask;
305311   m_read.m_name = func.name();
306   device.subtag(m_read.m_tag, tag);
312   m_read.m_devbase = &device;
307313   m_rproto16 = func;
308314}
309315
310316
311void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 unitmask)
317void address_map_entry::internal_set_handler(device_t &device, write16_delegate func, UINT64 unitmask)
312318{
313319   assert(!func.isnull());
314320   assert(unitmask_is_appropriate(16, unitmask, func.name()));
r18153r18154
316322   m_write.m_bits = 16;
317323   m_write.m_mask = unitmask;
318324   m_write.m_name = func.name();
319   device.subtag(m_write.m_tag, tag);
325   m_write.m_devbase = &device;
320326   m_wproto16 = func;
321327}
322328
323329
324void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT64 unitmask)
330void address_map_entry::internal_set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 unitmask)
325331{
326   internal_set_handler(device, tag, rfunc, unitmask);
327   internal_set_handler(device, tag, wfunc, unitmask);
332   internal_set_handler(device, rfunc, unitmask);
333   internal_set_handler(device, wfunc, unitmask);
328334}
329335
330336
r18153r18154
364370}
365371
366372
367void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 unitmask)
373void address_map_entry::internal_set_handler(device_t &device, read32_delegate func, UINT64 unitmask)
368374{
369375   assert(!func.isnull());
370376   assert(unitmask_is_appropriate(32, unitmask, func.name()));
r18153r18154
372378   m_read.m_bits = 32;
373379   m_read.m_mask = unitmask;
374380   m_read.m_name = func.name();
375   device.subtag(m_read.m_tag, tag);
381   m_read.m_devbase = &device;
376382   m_rproto32 = func;
377383}
378384
379385
380void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 unitmask)
386void address_map_entry::internal_set_handler(device_t &device, write32_delegate func, UINT64 unitmask)
381387{
382388   assert(!func.isnull());
383389   assert(unitmask_is_appropriate(32, unitmask, func.name()));
r18153r18154
385391   m_write.m_bits = 32;
386392   m_write.m_mask = unitmask;
387393   m_write.m_name = func.name();
388   device.subtag(m_write.m_tag, tag);
394   m_write.m_devbase = &device;
389395   m_wproto32 = func;
390396}
391397
392398
393void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc, UINT64 unitmask)
399void address_map_entry::internal_set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 unitmask)
394400{
395   internal_set_handler(device, tag, rfunc, unitmask);
396   internal_set_handler(device, tag, wfunc, unitmask);
401   internal_set_handler(device, rfunc, unitmask);
402   internal_set_handler(device, wfunc, unitmask);
397403}
398404
399405
r18153r18154
433439}
434440
435441
436void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read64_delegate func, UINT64 unitmask)
442void address_map_entry::internal_set_handler(device_t &device, read64_delegate func, UINT64 unitmask)
437443{
438444   assert(!func.isnull());
439445   assert(unitmask_is_appropriate(64, unitmask, func.name()));
r18153r18154
441447   m_read.m_bits = 64;
442448   m_read.m_mask = 0;
443449   m_read.m_name = func.name();
444   device.subtag(m_read.m_tag, tag);
450   m_read.m_devbase = &device;
445451   m_rproto64 = func;
446452}
447453
448454
449void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write64_delegate func, UINT64 unitmask)
455void address_map_entry::internal_set_handler(device_t &device, write64_delegate func, UINT64 unitmask)
450456{
451457   assert(!func.isnull());
452458   assert(unitmask_is_appropriate(64, unitmask, func.name()));
r18153r18154
454460   m_write.m_bits = 64;
455461   m_write.m_mask = 0;
456462   m_write.m_name = func.name();
457   device.subtag(m_write.m_tag, tag);
463   m_write.m_devbase = &device;
458464   m_wproto64 = func;
459465}
460466
461467
462void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc, UINT64 unitmask)
468void address_map_entry::internal_set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc, UINT64 unitmask)
463469{
464   internal_set_handler(device, tag, rfunc, unitmask);
465   internal_set_handler(device, tag, wfunc, unitmask);
470   internal_set_handler(device, rfunc, unitmask);
471   internal_set_handler(device, wfunc, unitmask);
466472}
467473
468474
r18153r18154
552558//  address_map - constructor
553559//-------------------------------------------------
554560
555address_map::address_map(const device_t &device, address_spacenum spacenum)
561address_map::address_map(device_t &device, address_spacenum spacenum)
556562   : m_spacenum(spacenum),
557563     m_databits(0xff),
558564     m_unmapval(0),
r18153r18154
587593//  address_map - constructor in the submap case
588594//-------------------------------------------------
589595
590address_map::address_map(const device_t &device, address_map_entry *entry)
596address_map::address_map(device_t &device, address_map_entry *entry)
591597   : m_spacenum(AS_PROGRAM),
592598     m_databits(0xff),
593599     m_unmapval(0),
594600     m_globalmask(0)
595601{
596602   // Retrieve the submap
597   entry->m_submap_delegate.late_bind(const_cast<device_t &>(device));
603   entry->m_submap_delegate.late_bind(device);
598604   entry->m_submap_delegate(*this, device);
599605}
600606
r18153r18154
604610//  address_map - constructor dynamic device mapping case
605611//----------------------------------------------------------
606612
607address_map::address_map(const address_space &space, offs_t start, offs_t end, int bits, UINT64 unitmask, const device_t &device, address_map_delegate submap_delegate)
613address_map::address_map(const address_space &space, offs_t start, offs_t end, int bits, UINT64 unitmask, device_t &device, address_map_delegate submap_delegate)
608614   : m_spacenum(space.spacenum()),
609615     m_databits(space.data_width()),
610616     m_unmapval(space.unmap()),
trunk/src/emu/addrmap.h
r18153r18154
8181      : m_type(AMH_NONE),
8282        m_bits(0),
8383        m_mask(0),
84        m_name(NULL) { }
84        m_name(NULL),
85        m_devbase(NULL),
86        m_tag(NULL) { }
8587
8688   map_handler_type      m_type;            // type of the handler
8789   UINT8               m_bits;            // width of the handler in bits, or 0 for default
8890   UINT64               m_mask;            // mask for which lanes apply
8991   const char *         m_name;            // name of the handler
90   astring               m_tag;            // path to the target tag
92   device_t *            m_devbase;         // pointer to "base" device
93   const char *         m_tag;            // tag for I/O ports and banks
9194};
9295
9396
r18153r18154
110113   void set_write_type(map_handler_type _type) { m_write.m_type = _type; }
111114   void set_region(const char *tag, offs_t offset) { m_region = tag; m_rgnoffs = offset; }
112115   void set_share(const char *tag) { assert(m_share == NULL); m_share = tag; }
113   void set_sizeptr(size_t *_sizeptr) { m_sizeptr = _sizeptr; }
114   void set_member_baseptr(FPTR offs) { m_baseptroffs_plus1 = offs + 1; }
115   void set_member_sizeptr(FPTR offs) { m_sizeptroffs_plus1 = offs + 1; }
116116
117117   // mask setting
118118   void set_mask(offs_t _mask);
119119
120120   // I/O port configuration
121   void set_read_port(const device_t &device, const char *tag);
122   void set_write_port(const device_t &device, const char *tag);
123   void set_readwrite_port(const device_t &device, const char *tag);
121   void set_read_port(device_t &device, const char *tag);
122   void set_write_port(device_t &device, const char *tag);
123   void set_readwrite_port(device_t &device, const char *tag);
124124
125125   // memory bank configuration
126   void set_read_bank(const device_t &device, const char *tag);
127   void set_write_bank(const device_t &device, const char *tag);
128   void set_readwrite_bank(const device_t &device, const char *tag);
126   void set_read_bank(device_t &device, const char *tag);
127   void set_write_bank(device_t &device, const char *tag);
128   void set_readwrite_bank(device_t &device, const char *tag);
129129
130130   // submap referencing
131   void set_submap(const device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask);
131   void set_submap(device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask);
132132
133133   // public state
134134   address_map_entry *      m_next;               // pointer to the next entry
r18153r18154
143143   map_handler_data      m_read;               // data for read handler
144144   map_handler_data      m_write;            // data for write handler
145145   const char *         m_share;            // tag of a shared memory block
146   void **               m_baseptr;            // receives pointer to memory (optional)
147   size_t *            m_sizeptr;            // receives size of area in bytes (optional)
148   UINT32               m_baseptroffs_plus1;   // offset of base pointer within driver_data, plus 1
149   UINT32               m_sizeptroffs_plus1;   // offset of size pointer within driver_data, plus 1
150146   const char *         m_region;            // tag of region containing the memory backing this entry
151147   offs_t               m_rgnoffs;            // offset within the region
152148
r18153r18154
179175   offs_t               m_bytemask;            // byte-adjusted mask bits
180176
181177protected:
182   // internal base pointer setting (derived classes provide typed versions)
183   void internal_set_baseptr(void **_baseptr) { m_baseptr = _baseptr; }
184
185178   // internal handler setters for 8-bit functions
186179   void internal_set_handler(read8_space_func func, const char *string, UINT64 mask);
187180   void internal_set_handler(write8_space_func func, const char *string, UINT64 mask);
188181   void internal_set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc,  const char *wstring, UINT64 mask);
189   void internal_set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 mask);
190   void internal_set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 mask);
191   void internal_set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask);
182   void internal_set_handler(device_t &device, read8_delegate func, UINT64 mask);
183   void internal_set_handler(device_t &device, write8_delegate func, UINT64 mask);
184   void internal_set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask);
192185
193186   // internal handler setters for 16-bit functions
194187   void internal_set_handler(read16_space_func func, const char *string, UINT64 mask);
195188   void internal_set_handler(write16_space_func func, const char *string, UINT64 mask);
196189   void internal_set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 mask);
197   void internal_set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 mask);
198   void internal_set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 mask);
199   void internal_set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask);
190   void internal_set_handler(device_t &device, read16_delegate func, UINT64 mask);
191   void internal_set_handler(device_t &device, write16_delegate func, UINT64 mask);
192   void internal_set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask);
200193
201194   // internal handler setters for 32-bit functions
202195   void internal_set_handler(read32_space_func func, const char *string, UINT64 mask);
203196   void internal_set_handler(write32_space_func func, const char *string, UINT64 mask);
204197   void internal_set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 mask);
205   void internal_set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 mask);
206   void internal_set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 mask);
207   void internal_set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask);
198   void internal_set_handler(device_t &device, read32_delegate func, UINT64 mask);
199   void internal_set_handler(device_t &device, write32_delegate func, UINT64 mask);
200   void internal_set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask);
208201
209202   // internal handler setters for 64-bit functions
210203   void internal_set_handler(read64_space_func func, const char *string, UINT64 mask);
211204   void internal_set_handler(write64_space_func func, const char *string, UINT64 mask);
212205   void internal_set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring, UINT64 mask);
213   void internal_set_handler(const device_t &device, const char *tag, read64_delegate func, UINT64 mask);
214   void internal_set_handler(const device_t &device, const char *tag, write64_delegate func, UINT64 mask);
215   void internal_set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc, UINT64 mask);
206   void internal_set_handler(device_t &device, read64_delegate func, UINT64 mask);
207   void internal_set_handler(device_t &device, write64_delegate func, UINT64 mask);
208   void internal_set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc, UINT64 mask);
216209
217210private:
218211   // helper functions
r18153r18154
228221public:
229222   address_map_entry8(address_map &map, offs_t start, offs_t end);
230223
231   void set_baseptr(UINT8 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
232
233224   // native-size handlers
234225   void set_handler(read8_space_func func, const char *string) { internal_set_handler(func, string, 0); }
235226   void set_handler(write8_space_func func, const char *string) { internal_set_handler(func, string, 0); }
236227   void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); }
237   void set_handler(const device_t &device, const char *tag, read8_delegate func) { internal_set_handler(device, tag, func, 0); }
238   void set_handler(const device_t &device, const char *tag, write8_delegate func) { internal_set_handler(device, tag, func, 0); }
239   void set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
228   void set_handler(device_t &device, read8_delegate func) { internal_set_handler(device, func, 0); }
229   void set_handler(device_t &device, write8_delegate func) { internal_set_handler(device, func, 0); }
230   void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
240231};
241232
242233
r18153r18154
248239public:
249240   address_map_entry16(address_map &map, offs_t start, offs_t end);
250241
251   void set_baseptr(UINT16 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
252
253242   // native-size handlers
254243   void set_handler(read16_space_func func, const char *string) { internal_set_handler(func, string, 0); }
255244   void set_handler(write16_space_func func, const char *string) { internal_set_handler(func, string, 0); }
256245   void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); }
257   void set_handler(const device_t &device, const char *tag, read16_delegate func) { internal_set_handler(device, tag, func, 0); }
258   void set_handler(const device_t &device, const char *tag, write16_delegate func) { internal_set_handler(device, tag, func, 0); }
259   void set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
246   void set_handler(device_t &device, read16_delegate func) { internal_set_handler(device, func, 0); }
247   void set_handler(device_t &device, write16_delegate func) { internal_set_handler(device, func, 0); }
248   void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
260249
261250   // 8-bit handlers
262251   void set_handler(read8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); }
263252   void set_handler(write8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); }
264253   void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT16 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
265   void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT16 mask) { internal_set_handler(device, tag, func, mask); }
266   void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT16 mask) { internal_set_handler(device, tag, func, mask); }
267   void set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT16 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
254   void set_handler(device_t &device, read8_delegate func, UINT16 mask) { internal_set_handler(device, func, mask); }
255   void set_handler(device_t &device, write8_delegate func, UINT16 mask) { internal_set_handler(device, func, mask); }
256   void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT16 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
268257};
269258
270259
r18153r18154
276265public:
277266   address_map_entry32(address_map &map, offs_t start, offs_t end);
278267
279   void set_baseptr(UINT32 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
280
281268   // native-size handlers
282269   void set_handler(read32_space_func func, const char *string) { internal_set_handler(func, string, 0); }
283270   void set_handler(write32_space_func func, const char *string) { internal_set_handler(func, string, 0); }
284271   void set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); }
285   void set_handler(const device_t &device, const char *tag, read32_delegate func) { internal_set_handler(device, tag, func, 0); }
286   void set_handler(const device_t &device, const char *tag, write32_delegate func) { internal_set_handler(device, tag, func, 0); }
287   void set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
272   void set_handler(device_t &device, read32_delegate func) { internal_set_handler(device, func, 0); }
273   void set_handler(device_t &device, write32_delegate func) { internal_set_handler(device, func, 0); }
274   void set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
288275
289276   // 16-bit handlers
290277   void set_handler(read16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
291278   void set_handler(write16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
292279   void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
293   void set_handler(const device_t &device, const char *tag, read16_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
294   void set_handler(const device_t &device, const char *tag, write16_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
295   void set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT32 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
280   void set_handler(device_t &device, read16_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
281   void set_handler(device_t &device, write16_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
282   void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT32 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
296283
297284   // 8-bit handlers
298285   void set_handler(read8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
299286   void set_handler(write8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
300287   void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
301   void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
302   void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
303   void set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT32 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
288   void set_handler(device_t &device, read8_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
289   void set_handler(device_t &device, write8_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
290   void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT32 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
304291};
305292
306293
r18153r18154
312299public:
313300   address_map_entry64(address_map &map, offs_t start, offs_t end);
314301
315   void set_baseptr(UINT64 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
316
317302   // native-size handlers
318303   void set_handler(read64_space_func func, const char *string) { internal_set_handler(func, string, 0); }
319304   void set_handler(write64_space_func func, const char *string) { internal_set_handler(func, string, 0); }
320305   void set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); }
321   void set_handler(const device_t &device, const char *tag, read64_delegate func) { internal_set_handler(device, tag, func, 0); }
322   void set_handler(const device_t &device, const char *tag, write64_delegate func) { internal_set_handler(device, tag, func, 0); }
323   void set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
306   void set_handler(device_t &device, read64_delegate func) { internal_set_handler(device, func, 0); }
307   void set_handler(device_t &device, write64_delegate func) { internal_set_handler(device, func, 0); }
308   void set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
324309
325310   // 32-bit handlers
326311   void set_handler(read32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
327312   void set_handler(write32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
328313   void set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
329   void set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
330   void set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
331   void set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
314   void set_handler(device_t &device, read32_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
315   void set_handler(device_t &device, write32_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
316   void set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
332317
333318   // 16-bit handlers
334319   void set_handler(read16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
335320   void set_handler(write16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
336321   void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
337   void set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
338   void set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
339   void set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
322   void set_handler(device_t &device, read16_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
323   void set_handler(device_t &device, write16_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
324   void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
340325
341326   // 8-bit handlers
342327   void set_handler(read8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
343328   void set_handler(write8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
344329   void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); }
345   void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
346   void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
347   void set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask) { internal_set_handler(device, tag, rfunc, wfunc, mask); }
330   void set_handler(device_t &device, read8_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
331   void set_handler(device_t &device, write8_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
332   void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
348333};
349334
350335
r18153r18154
355340{
356341public:
357342   // construction/destruction
358   address_map(const device_t &device, address_spacenum spacenum);
359   address_map(const device_t &device, address_map_entry *entry);
360   address_map(const address_space &space, offs_t start, offs_t end, int bits, UINT64 unitmask, const device_t &device, address_map_delegate submap_delegate);
343   address_map(device_t &device, address_spacenum spacenum);
344   address_map(device_t &device, address_map_entry *entry);
345   address_map(const address_space &space, offs_t start, offs_t end, int bits, UINT64 unitmask, device_t &device, address_map_delegate submap_delegate);
361346   ~address_map();
362347
363348   // configuration
r18153r18154
395380#define ADDRESS_MAP_NAME(_name) construct_address_map_##_name
396381
397382#define ADDRESS_MAP_START(_name, _space, _bits, _class) \
398void ADDRESS_MAP_NAME(_name)(address_map &map, const device_t &device) \
383void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) \
399384{ \
400385   typedef read##_bits##_delegate read_delegate; \
401386   typedef write##_bits##_delegate write_delegate; \
r18153r18154
405390   typedef _class drivdata_class; \
406391
407392#define DEVICE_ADDRESS_MAP_START(_name, _bits, _class) \
408void _class :: _name(address_map &map, const device_t &device) \
393void _class :: _name(address_map &map, device_t &device) \
409394{ \
410395   typedef read##_bits##_delegate read_delegate; \
411396   typedef write##_bits##_delegate write_delegate; \
r18153r18154
419404
420405// use this to declare external references to an address map
421406#define ADDRESS_MAP_EXTERN(_name, _bits) \
422   extern void ADDRESS_MAP_NAME(_name)(address_map &map, const device_t &device)
407   extern void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device)
423408
424409// use this to declare an address map as a member of a modern device class
425410#define DECLARE_ADDRESS_MAP(_name, _bits) \
426   void _name(address_map &map, const device_t &device)
411   void _name(address_map &map, device_t &device)
427412
428413
429414// global controls
r18153r18154
495480
496481// legacy device reads
497482#define AM_DEVREAD_LEGACY(_tag, _handler) \
498   curentry->set_handler(device, _tag, read_delegate(&_handler, #_handler, (device_t *)0)); \
483   curentry->set_handler(device, read_delegate(&_handler, #_handler, _tag, (device_t *)0)); \
499484
500485#define AM_DEVREAD8_LEGACY(_tag, _handler, _unitmask) \
501   curentry->set_handler(device, _tag, read8_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
486   curentry->set_handler(device, read8_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
502487
503488
504489
505490
506491// legacy device writes
507492#define AM_DEVWRITE_LEGACY(_tag, _handler) \
508   curentry->set_handler(device, _tag, write_delegate(&_handler, #_handler, (device_t *)0)); \
493   curentry->set_handler(device, write_delegate(&_handler, #_handler, _tag, (device_t *)0)); \
509494
510495#define AM_DEVWRITE8_LEGACY(_tag, _handler, _unitmask) \
511   curentry->set_handler(device, _tag, write8_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
496   curentry->set_handler(device, write8_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
512497
513498#define AM_DEVWRITE16_LEGACY(_tag, _handler, _unitmask) \
514   curentry->set_handler(device, _tag, write16_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
499   curentry->set_handler(device, write16_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
515500
516501
517502
518503// legacy device reads/writes
519504#define AM_DEVREADWRITE_LEGACY(_tag, _rhandler, _whandler) \
520   curentry->set_handler(device, _tag, read_delegate(&_rhandler, #_rhandler, (device_t *)0), write_delegate(&_whandler, #_whandler, (device_t *)0)); \
505   curentry->set_handler(device, read_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write_delegate(&_whandler, #_whandler, _tag, (device_t *)0)); \
521506
522507#define AM_DEVREADWRITE8_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
523   curentry->set_handler(device, _tag, read8_delegate(&_rhandler, #_rhandler, (device_t *)0), write8_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
508   curentry->set_handler(device, read8_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write8_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
524509
525510#define AM_DEVREADWRITE16_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
526   curentry->set_handler(device, _tag, read16_delegate(&_rhandler, #_rhandler, (device_t *)0), write16_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
511   curentry->set_handler(device, read16_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write16_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
527512
528513#define AM_DEVREADWRITE32_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
529   curentry->set_handler(device, _tag, read32_delegate(&_rhandler, #_rhandler, (device_t *)0), write32_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
514   curentry->set_handler(device, read32_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write32_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
530515
531516
532517// driver data reads
533518#define AM_READ(_handler) \
534   curentry->set_handler(device, DEVICE_SELF, read_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0)); \
519   curentry->set_handler(device, read_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0)); \
535520
536521#define AM_READ8(_handler, _unitmask) \
537   curentry->set_handler(device, DEVICE_SELF, read8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
522   curentry->set_handler(device, read8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
538523
539524#define AM_READ16(_handler, _unitmask) \
540   curentry->set_handler(device, DEVICE_SELF, read16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
525   curentry->set_handler(device, read16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
541526
542527#define AM_READ32(_handler, _unitmask) \
543   curentry->set_handler(device, DEVICE_SELF, read32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
528   curentry->set_handler(device, read32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
544529
545530
546531// driver data writes
547532#define AM_WRITE(_handler) \
548   curentry->set_handler(device, DEVICE_SELF, write_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0)); \
533   curentry->set_handler(device, write_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0)); \
549534
550535#define AM_WRITE8(_handler, _unitmask) \
551   curentry->set_handler(device, DEVICE_SELF, write8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
536   curentry->set_handler(device, write8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
552537
553538#define AM_WRITE16(_handler, _unitmask) \
554   curentry->set_handler(device, DEVICE_SELF, write16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
539   curentry->set_handler(device, write16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
555540
556541#define AM_WRITE32(_handler, _unitmask) \
557   curentry->set_handler(device, DEVICE_SELF, write32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
542   curentry->set_handler(device, write32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
558543
559544
560545// driver data reads/writes
561546#define AM_READWRITE(_rhandler, _whandler) \
562   curentry->set_handler(device, DEVICE_SELF, read_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, (drivdata_class *)0), write_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, (drivdata_class *)0)); \
547   curentry->set_handler(device, read_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, DEVICE_SELF, (drivdata_class *)0), write_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, DEVICE_SELF, (drivdata_class *)0)); \
563548
564549#define AM_READWRITE8(_rhandler, _whandler, _unitmask) \
565   curentry->set_handler(device, DEVICE_SELF, read8_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, (drivdata_class *)0), write8_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, (drivdata_class *)0), _unitmask); \
550   curentry->set_handler(device, read8_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, DEVICE_SELF, (drivdata_class *)0), write8_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
566551
567552#define AM_READWRITE16(_rhandler, _whandler, _unitmask) \
568   curentry->set_handler(device, DEVICE_SELF, read16_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, (drivdata_class *)0), write16_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, (drivdata_class *)0), _unitmask); \
553   curentry->set_handler(device, read16_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, DEVICE_SELF, (drivdata_class *)0), write16_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
569554
570555#define AM_READWRITE32(_rhandler, _whandler, _unitmask) \
571   curentry->set_handler(device, DEVICE_SELF, read32_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, (drivdata_class *)0), write32_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, (drivdata_class *)0), _unitmask); \
556   curentry->set_handler(device, read32_delegate(&drivdata_class::_rhandler, "driver_data::" #_rhandler, DEVICE_SELF, (drivdata_class *)0), write32_delegate(&drivdata_class::_whandler, "driver_data::" #_whandler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
572557
573558
574559// device reads
575560#define AM_DEVREAD(_tag, _class, _handler) \
576   curentry->set_handler(device, _tag, read_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0)); \
561   curentry->set_handler(device, read_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0)); \
577562
578563#define AM_DEVREAD8(_tag, _class, _handler, _unitmask) \
579   curentry->set_handler(device, _tag, read8_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
564   curentry->set_handler(device, read8_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
580565
581566#define AM_DEVREAD16(_tag, _class, _handler, _unitmask) \
582   curentry->set_handler(device, _tag, read16_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
567   curentry->set_handler(device, read16_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
583568
584569#define AM_DEVREAD32(_tag, _class, _handler, _unitmask) \
585   curentry->set_handler(device, _tag, read32_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
570   curentry->set_handler(device, read32_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
586571
587572
588573// device writes
589574#define AM_DEVWRITE(_tag, _class, _handler) \
590   curentry->set_handler(device, _tag, write_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0)); \
575   curentry->set_handler(device, write_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0)); \
591576
592577#define AM_DEVWRITE8(_tag, _class, _handler, _unitmask) \
593   curentry->set_handler(device, _tag, write8_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
578   curentry->set_handler(device, write8_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
594579
595580#define AM_DEVWRITE16(_tag, _class, _handler, _unitmask) \
596   curentry->set_handler(device, _tag, write16_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
581   curentry->set_handler(device, write16_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
597582
598583#define AM_DEVWRITE32(_tag, _class, _handler, _unitmask) \
599   curentry->set_handler(device, _tag, write32_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
584   curentry->set_handler(device, write32_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
600585
601586
602587// device reads/writes
603588#define AM_DEVREADWRITE(_tag, _class, _rhandler, _whandler) \
604   curentry->set_handler(device, _tag, read_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0)); \
589   curentry->set_handler(device, read_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0)); \
605590
606591#define AM_DEVREADWRITE8(_tag, _class, _rhandler, _whandler, _unitmask) \
607   curentry->set_handler(device, _tag, read8_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write8_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
592   curentry->set_handler(device, read8_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write8_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
608593
609594#define AM_DEVREADWRITE16(_tag, _class, _rhandler, _whandler, _unitmask) \
610   curentry->set_handler(device, _tag, read16_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write16_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
595   curentry->set_handler(device, read16_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write16_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
611596
612597#define AM_DEVREADWRITE32(_tag, _class, _rhandler, _whandler, _unitmask) \
613   curentry->set_handler(device, _tag, read32_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write32_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
598   curentry->set_handler(device, read32_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write32_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
614599
615600
616601// device mapping
trunk/src/emu/devcb.h
r18153r18154
9999//  MACROS
100100//**************************************************************************
101101
102// Some useful delegates
103typedef delegate<void (bool state)> line_cb_t;
104
102105// static template for a read_line stub function that calls through a given READ_LINE_MEMBER
103106template<class _Class, int (_Class::*_Function)()>
104107int devcb_line_stub(device_t *device)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team