mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
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.
This commit is contained in:
parent
acf55c87ef
commit
ea8a131e0d
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -869,6 +869,8 @@ src/emu/devcb.c svneol=native#text/plain
|
||||
src/emu/devcb.h svneol=native#text/plain
|
||||
src/emu/devcpu.c svneol=native#text/plain
|
||||
src/emu/devcpu.h svneol=native#text/plain
|
||||
src/emu/devdelegate.c svneol=native#text/plain
|
||||
src/emu/devdelegate.h svneol=native#text/plain
|
||||
src/emu/device.c svneol=native#text/plain
|
||||
src/emu/device.h svneol=native#text/plain
|
||||
src/emu/devlegcy.h svneol=native#text/plain
|
||||
|
@ -56,10 +56,6 @@ address_map_entry::address_map_entry(address_map &map, offs_t start, offs_t end)
|
||||
m_addrmirror(0),
|
||||
m_addrmask(0),
|
||||
m_share(NULL),
|
||||
m_baseptr(NULL),
|
||||
m_sizeptr(NULL),
|
||||
m_baseptroffs_plus1(0),
|
||||
m_sizeptroffs_plus1(0),
|
||||
m_region(NULL),
|
||||
m_rgnoffs(0),
|
||||
m_rspace8(NULL),
|
||||
@ -96,10 +92,11 @@ void address_map_entry::set_mask(offs_t _mask)
|
||||
// an I/O port
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_read_port(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_read_port(device_t &device, const char *tag)
|
||||
{
|
||||
m_read.m_type = AMH_PORT;
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_tag = tag;
|
||||
m_read.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -108,10 +105,11 @@ void address_map_entry::set_read_port(const device_t &device, const char *tag)
|
||||
// an I/O port
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_write_port(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_write_port(device_t &device, const char *tag)
|
||||
{
|
||||
m_write.m_type = AMH_PORT;
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_tag = tag;
|
||||
m_write.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -120,12 +118,14 @@ void address_map_entry::set_write_port(const device_t &device, const char *tag)
|
||||
// reading and writing an I/O port
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_readwrite_port(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_readwrite_port(device_t &device, const char *tag)
|
||||
{
|
||||
m_read.m_type = AMH_PORT;
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_tag = tag;
|
||||
m_read.m_devbase = &device;
|
||||
m_write.m_type = AMH_PORT;
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_tag = tag;
|
||||
m_write.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -134,10 +134,11 @@ void address_map_entry::set_readwrite_port(const device_t &device, const char *t
|
||||
// from a memory bank
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_read_bank(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_read_bank(device_t &device, const char *tag)
|
||||
{
|
||||
m_read.m_type = AMH_BANK;
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_tag = tag;
|
||||
m_read.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -146,10 +147,11 @@ void address_map_entry::set_read_bank(const device_t &device, const char *tag)
|
||||
// to a memory bank
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_write_bank(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_write_bank(device_t &device, const char *tag)
|
||||
{
|
||||
m_write.m_type = AMH_BANK;
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_tag = tag;
|
||||
m_write.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -158,12 +160,14 @@ void address_map_entry::set_write_bank(const device_t &device, const char *tag)
|
||||
// reading and writing to a memory bank
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_readwrite_bank(const device_t &device, const char *tag)
|
||||
void address_map_entry::set_readwrite_bank(device_t &device, const char *tag)
|
||||
{
|
||||
m_read.m_type = AMH_BANK;
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_tag = tag;
|
||||
m_read.m_devbase = &device;
|
||||
m_write.m_type = AMH_BANK;
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_tag = tag;
|
||||
m_write.m_devbase = &device;
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +176,7 @@ void address_map_entry::set_readwrite_bank(const device_t &device, const char *t
|
||||
// retrieve a submap from a device
|
||||
//-------------------------------------------------
|
||||
|
||||
void address_map_entry::set_submap(const device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask)
|
||||
void address_map_entry::set_submap(device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask)
|
||||
{
|
||||
if(!bits)
|
||||
bits = m_map.m_databits;
|
||||
@ -180,10 +184,12 @@ void address_map_entry::set_submap(const device_t &device, const char *tag, addr
|
||||
assert(unitmask_is_appropriate(bits, mask, func.name()));
|
||||
|
||||
m_read.m_type = AMH_DEVICE_SUBMAP;
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_tag = tag;
|
||||
m_read.m_devbase = &device;
|
||||
m_read.m_mask = mask;
|
||||
m_write.m_type = AMH_DEVICE_SUBMAP;
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_tag = tag;
|
||||
m_write.m_devbase = &device;
|
||||
m_write.m_mask = mask;
|
||||
m_submap_delegate = func;
|
||||
m_submap_bits = bits;
|
||||
@ -226,7 +232,7 @@ void address_map_entry::internal_set_handler(read8_space_func rfunc, const char
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read8_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(8, unitmask, func.name()));
|
||||
@ -234,12 +240,12 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_read.m_bits = 8;
|
||||
m_read.m_mask = unitmask;
|
||||
m_read.m_name = func.name();
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_devbase = &device;
|
||||
m_rproto8 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, write8_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(8, unitmask, func.name()));
|
||||
@ -247,15 +253,15 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_write.m_bits = 8;
|
||||
m_write.m_mask = unitmask;
|
||||
m_write.m_name = func.name();
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_devbase = &device;
|
||||
m_wproto8 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 unitmask)
|
||||
{
|
||||
internal_set_handler(device, tag, rfunc, unitmask);
|
||||
internal_set_handler(device, tag, wfunc, unitmask);
|
||||
internal_set_handler(device, rfunc, unitmask);
|
||||
internal_set_handler(device, wfunc, unitmask);
|
||||
}
|
||||
|
||||
|
||||
@ -295,7 +301,7 @@ void address_map_entry::internal_set_handler(read16_space_func rfunc, const char
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read16_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(16, unitmask, func.name()));
|
||||
@ -303,12 +309,12 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_read.m_bits = 16;
|
||||
m_read.m_mask = unitmask;
|
||||
m_read.m_name = func.name();
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_devbase = &device;
|
||||
m_rproto16 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, write16_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(16, unitmask, func.name()));
|
||||
@ -316,15 +322,15 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_write.m_bits = 16;
|
||||
m_write.m_mask = unitmask;
|
||||
m_write.m_name = func.name();
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_devbase = &device;
|
||||
m_wproto16 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 unitmask)
|
||||
{
|
||||
internal_set_handler(device, tag, rfunc, unitmask);
|
||||
internal_set_handler(device, tag, wfunc, unitmask);
|
||||
internal_set_handler(device, rfunc, unitmask);
|
||||
internal_set_handler(device, wfunc, unitmask);
|
||||
}
|
||||
|
||||
|
||||
@ -364,7 +370,7 @@ void address_map_entry::internal_set_handler(read32_space_func rfunc, const char
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read32_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(32, unitmask, func.name()));
|
||||
@ -372,12 +378,12 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_read.m_bits = 32;
|
||||
m_read.m_mask = unitmask;
|
||||
m_read.m_name = func.name();
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_devbase = &device;
|
||||
m_rproto32 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, write32_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(32, unitmask, func.name()));
|
||||
@ -385,15 +391,15 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_write.m_bits = 32;
|
||||
m_write.m_mask = unitmask;
|
||||
m_write.m_name = func.name();
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_devbase = &device;
|
||||
m_wproto32 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 unitmask)
|
||||
{
|
||||
internal_set_handler(device, tag, rfunc, unitmask);
|
||||
internal_set_handler(device, tag, wfunc, unitmask);
|
||||
internal_set_handler(device, rfunc, unitmask);
|
||||
internal_set_handler(device, wfunc, unitmask);
|
||||
}
|
||||
|
||||
|
||||
@ -433,7 +439,7 @@ void address_map_entry::internal_set_handler(read64_space_func rfunc, const char
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read64_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read64_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(64, unitmask, func.name()));
|
||||
@ -441,12 +447,12 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_read.m_bits = 64;
|
||||
m_read.m_mask = 0;
|
||||
m_read.m_name = func.name();
|
||||
device.subtag(m_read.m_tag, tag);
|
||||
m_read.m_devbase = &device;
|
||||
m_rproto64 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, write64_delegate func, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, write64_delegate func, UINT64 unitmask)
|
||||
{
|
||||
assert(!func.isnull());
|
||||
assert(unitmask_is_appropriate(64, unitmask, func.name()));
|
||||
@ -454,15 +460,15 @@ void address_map_entry::internal_set_handler(const device_t &device, const char
|
||||
m_write.m_bits = 64;
|
||||
m_write.m_mask = 0;
|
||||
m_write.m_name = func.name();
|
||||
device.subtag(m_write.m_tag, tag);
|
||||
m_write.m_devbase = &device;
|
||||
m_wproto64 = func;
|
||||
}
|
||||
|
||||
|
||||
void address_map_entry::internal_set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc, UINT64 unitmask)
|
||||
void address_map_entry::internal_set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc, UINT64 unitmask)
|
||||
{
|
||||
internal_set_handler(device, tag, rfunc, unitmask);
|
||||
internal_set_handler(device, tag, wfunc, unitmask);
|
||||
internal_set_handler(device, rfunc, unitmask);
|
||||
internal_set_handler(device, wfunc, unitmask);
|
||||
}
|
||||
|
||||
|
||||
@ -552,7 +558,7 @@ address_map_entry64::address_map_entry64(address_map &map, offs_t start, offs_t
|
||||
// address_map - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
address_map::address_map(const device_t &device, address_spacenum spacenum)
|
||||
address_map::address_map(device_t &device, address_spacenum spacenum)
|
||||
: m_spacenum(spacenum),
|
||||
m_databits(0xff),
|
||||
m_unmapval(0),
|
||||
@ -587,14 +593,14 @@ address_map::address_map(const device_t &device, address_spacenum spacenum)
|
||||
// address_map - constructor in the submap case
|
||||
//-------------------------------------------------
|
||||
|
||||
address_map::address_map(const device_t &device, address_map_entry *entry)
|
||||
address_map::address_map(device_t &device, address_map_entry *entry)
|
||||
: m_spacenum(AS_PROGRAM),
|
||||
m_databits(0xff),
|
||||
m_unmapval(0),
|
||||
m_globalmask(0)
|
||||
{
|
||||
// Retrieve the submap
|
||||
entry->m_submap_delegate.late_bind(const_cast<device_t &>(device));
|
||||
entry->m_submap_delegate.late_bind(device);
|
||||
entry->m_submap_delegate(*this, device);
|
||||
}
|
||||
|
||||
@ -604,7 +610,7 @@ address_map::address_map(const device_t &device, address_map_entry *entry)
|
||||
// address_map - constructor dynamic device mapping case
|
||||
//----------------------------------------------------------
|
||||
|
||||
address_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)
|
||||
address_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)
|
||||
: m_spacenum(space.spacenum()),
|
||||
m_databits(space.data_width()),
|
||||
m_unmapval(space.unmap()),
|
||||
|
@ -81,13 +81,16 @@ public:
|
||||
: m_type(AMH_NONE),
|
||||
m_bits(0),
|
||||
m_mask(0),
|
||||
m_name(NULL) { }
|
||||
m_name(NULL),
|
||||
m_devbase(NULL),
|
||||
m_tag(NULL) { }
|
||||
|
||||
map_handler_type m_type; // type of the handler
|
||||
UINT8 m_bits; // width of the handler in bits, or 0 for default
|
||||
UINT64 m_mask; // mask for which lanes apply
|
||||
const char * m_name; // name of the handler
|
||||
astring m_tag; // path to the target tag
|
||||
device_t * m_devbase; // pointer to "base" device
|
||||
const char * m_tag; // tag for I/O ports and banks
|
||||
};
|
||||
|
||||
|
||||
@ -110,25 +113,22 @@ public:
|
||||
void set_write_type(map_handler_type _type) { m_write.m_type = _type; }
|
||||
void set_region(const char *tag, offs_t offset) { m_region = tag; m_rgnoffs = offset; }
|
||||
void set_share(const char *tag) { assert(m_share == NULL); m_share = tag; }
|
||||
void set_sizeptr(size_t *_sizeptr) { m_sizeptr = _sizeptr; }
|
||||
void set_member_baseptr(FPTR offs) { m_baseptroffs_plus1 = offs + 1; }
|
||||
void set_member_sizeptr(FPTR offs) { m_sizeptroffs_plus1 = offs + 1; }
|
||||
|
||||
// mask setting
|
||||
void set_mask(offs_t _mask);
|
||||
|
||||
// I/O port configuration
|
||||
void set_read_port(const device_t &device, const char *tag);
|
||||
void set_write_port(const device_t &device, const char *tag);
|
||||
void set_readwrite_port(const device_t &device, const char *tag);
|
||||
void set_read_port(device_t &device, const char *tag);
|
||||
void set_write_port(device_t &device, const char *tag);
|
||||
void set_readwrite_port(device_t &device, const char *tag);
|
||||
|
||||
// memory bank configuration
|
||||
void set_read_bank(const device_t &device, const char *tag);
|
||||
void set_write_bank(const device_t &device, const char *tag);
|
||||
void set_readwrite_bank(const device_t &device, const char *tag);
|
||||
void set_read_bank(device_t &device, const char *tag);
|
||||
void set_write_bank(device_t &device, const char *tag);
|
||||
void set_readwrite_bank(device_t &device, const char *tag);
|
||||
|
||||
// submap referencing
|
||||
void set_submap(const device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask);
|
||||
void set_submap(device_t &device, const char *tag, address_map_delegate func, int bits, UINT64 mask);
|
||||
|
||||
// public state
|
||||
address_map_entry * m_next; // pointer to the next entry
|
||||
@ -143,10 +143,6 @@ public:
|
||||
map_handler_data m_read; // data for read handler
|
||||
map_handler_data m_write; // data for write handler
|
||||
const char * m_share; // tag of a shared memory block
|
||||
void ** m_baseptr; // receives pointer to memory (optional)
|
||||
size_t * m_sizeptr; // receives size of area in bytes (optional)
|
||||
UINT32 m_baseptroffs_plus1; // offset of base pointer within driver_data, plus 1
|
||||
UINT32 m_sizeptroffs_plus1; // offset of size pointer within driver_data, plus 1
|
||||
const char * m_region; // tag of region containing the memory backing this entry
|
||||
offs_t m_rgnoffs; // offset within the region
|
||||
|
||||
@ -179,40 +175,37 @@ public:
|
||||
offs_t m_bytemask; // byte-adjusted mask bits
|
||||
|
||||
protected:
|
||||
// internal base pointer setting (derived classes provide typed versions)
|
||||
void internal_set_baseptr(void **_baseptr) { m_baseptr = _baseptr; }
|
||||
|
||||
// internal handler setters for 8-bit functions
|
||||
void internal_set_handler(read8_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(write8_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read8_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, write8_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask);
|
||||
|
||||
// internal handler setters for 16-bit functions
|
||||
void internal_set_handler(read16_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(write16_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read16_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, write16_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask);
|
||||
|
||||
// internal handler setters for 32-bit functions
|
||||
void internal_set_handler(read32_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(write32_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read32_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, write32_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask);
|
||||
|
||||
// internal handler setters for 64-bit functions
|
||||
void internal_set_handler(read64_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(write64_space_func func, const char *string, UINT64 mask);
|
||||
void internal_set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read64_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, write64_delegate func, UINT64 mask);
|
||||
void internal_set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read64_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, write64_delegate func, UINT64 mask);
|
||||
void internal_set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc, UINT64 mask);
|
||||
|
||||
private:
|
||||
// helper functions
|
||||
@ -228,15 +221,13 @@ class address_map_entry8 : public address_map_entry
|
||||
public:
|
||||
address_map_entry8(address_map &map, offs_t start, offs_t end);
|
||||
|
||||
void set_baseptr(UINT8 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
|
||||
|
||||
// native-size handlers
|
||||
void set_handler(read8_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
void set_handler(write8_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read8_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, write8_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, read8_delegate rfunc, write8_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
|
||||
void set_handler(device_t &device, read8_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, write8_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
|
||||
};
|
||||
|
||||
|
||||
@ -248,23 +239,21 @@ class address_map_entry16 : public address_map_entry
|
||||
public:
|
||||
address_map_entry16(address_map &map, offs_t start, offs_t end);
|
||||
|
||||
void set_baseptr(UINT16 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
|
||||
|
||||
// native-size handlers
|
||||
void set_handler(read16_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
void set_handler(write16_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read16_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, write16_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, read16_delegate rfunc, write16_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
|
||||
void set_handler(device_t &device, read16_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, write16_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
|
||||
|
||||
// 8-bit handlers
|
||||
void set_handler(read8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT16 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT16 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read8_delegate func, UINT16 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write8_delegate func, UINT16 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT16 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
};
|
||||
|
||||
|
||||
@ -276,31 +265,29 @@ class address_map_entry32 : public address_map_entry
|
||||
public:
|
||||
address_map_entry32(address_map &map, offs_t start, offs_t end);
|
||||
|
||||
void set_baseptr(UINT32 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
|
||||
|
||||
// native-size handlers
|
||||
void set_handler(read32_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
void set_handler(write32_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read32_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, write32_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, read32_delegate rfunc, write32_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
|
||||
void set_handler(device_t &device, read32_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, write32_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
|
||||
|
||||
// 16-bit handlers
|
||||
void set_handler(read16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read16_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write16_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read16_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write16_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT32 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
|
||||
// 8-bit handlers
|
||||
void set_handler(read8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT32 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read8_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write8_delegate func, UINT32 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT32 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
};
|
||||
|
||||
|
||||
@ -312,39 +299,37 @@ class address_map_entry64 : public address_map_entry
|
||||
public:
|
||||
address_map_entry64(address_map &map, offs_t start, offs_t end);
|
||||
|
||||
void set_baseptr(UINT64 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); }
|
||||
|
||||
// native-size handlers
|
||||
void set_handler(read64_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
void set_handler(write64_space_func func, const char *string) { internal_set_handler(func, string, 0); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read64_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, write64_delegate func) { internal_set_handler(device, tag, func, 0); }
|
||||
void set_handler(const device_t &device, const char *tag, read64_delegate rfunc, write64_delegate wfunc) { internal_set_handler(device, tag, rfunc, wfunc, 0); }
|
||||
void set_handler(device_t &device, read64_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, write64_delegate func) { internal_set_handler(device, func, 0); }
|
||||
void set_handler(device_t &device, read64_delegate rfunc, write64_delegate wfunc) { internal_set_handler(device, rfunc, wfunc, 0); }
|
||||
|
||||
// 32-bit handlers
|
||||
void set_handler(read32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read32_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write32_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read32_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write32_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read32_delegate rfunc, write32_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
|
||||
// 16-bit handlers
|
||||
void set_handler(read16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read16_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write16_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read16_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write16_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read16_delegate rfunc, write16_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
|
||||
// 8-bit handlers
|
||||
void set_handler(read8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
void set_handler(write8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); }
|
||||
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); }
|
||||
void set_handler(const device_t &device, const char *tag, read8_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
void set_handler(const device_t &device, const char *tag, write8_delegate func, UINT64 mask) { internal_set_handler(device, tag, func, mask); }
|
||||
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); }
|
||||
void set_handler(device_t &device, read8_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, write8_delegate func, UINT64 mask) { internal_set_handler(device, func, mask); }
|
||||
void set_handler(device_t &device, read8_delegate rfunc, write8_delegate wfunc, UINT64 mask) { internal_set_handler(device, rfunc, wfunc, mask); }
|
||||
};
|
||||
|
||||
|
||||
@ -355,9 +340,9 @@ class address_map
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
address_map(const device_t &device, address_spacenum spacenum);
|
||||
address_map(const device_t &device, address_map_entry *entry);
|
||||
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);
|
||||
address_map(device_t &device, address_spacenum spacenum);
|
||||
address_map(device_t &device, address_map_entry *entry);
|
||||
address_map(const address_space &space, offs_t start, offs_t end, int bits, UINT64 unitmask, device_t &device, address_map_delegate submap_delegate);
|
||||
~address_map();
|
||||
|
||||
// configuration
|
||||
@ -395,7 +380,7 @@ public:
|
||||
#define ADDRESS_MAP_NAME(_name) construct_address_map_##_name
|
||||
|
||||
#define ADDRESS_MAP_START(_name, _space, _bits, _class) \
|
||||
void ADDRESS_MAP_NAME(_name)(address_map &map, const device_t &device) \
|
||||
void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) \
|
||||
{ \
|
||||
typedef read##_bits##_delegate read_delegate; \
|
||||
typedef write##_bits##_delegate write_delegate; \
|
||||
@ -405,7 +390,7 @@ void ADDRESS_MAP_NAME(_name)(address_map &map, const device_t &device) \
|
||||
typedef _class drivdata_class; \
|
||||
|
||||
#define DEVICE_ADDRESS_MAP_START(_name, _bits, _class) \
|
||||
void _class :: _name(address_map &map, const device_t &device) \
|
||||
void _class :: _name(address_map &map, device_t &device) \
|
||||
{ \
|
||||
typedef read##_bits##_delegate read_delegate; \
|
||||
typedef write##_bits##_delegate write_delegate; \
|
||||
@ -419,11 +404,11 @@ void _class :: _name(address_map &map, const device_t &device) \
|
||||
|
||||
// use this to declare external references to an address map
|
||||
#define ADDRESS_MAP_EXTERN(_name, _bits) \
|
||||
extern void ADDRESS_MAP_NAME(_name)(address_map &map, const device_t &device)
|
||||
extern void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device)
|
||||
|
||||
// use this to declare an address map as a member of a modern device class
|
||||
#define DECLARE_ADDRESS_MAP(_name, _bits) \
|
||||
void _name(address_map &map, const device_t &device)
|
||||
void _name(address_map &map, device_t &device)
|
||||
|
||||
|
||||
// global controls
|
||||
@ -495,122 +480,122 @@ void _class :: _name(address_map &map, const device_t &device) \
|
||||
|
||||
// legacy device reads
|
||||
#define AM_DEVREAD_LEGACY(_tag, _handler) \
|
||||
curentry->set_handler(device, _tag, read_delegate(&_handler, #_handler, (device_t *)0)); \
|
||||
curentry->set_handler(device, read_delegate(&_handler, #_handler, _tag, (device_t *)0)); \
|
||||
|
||||
#define AM_DEVREAD8_LEGACY(_tag, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read8_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, read8_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
|
||||
|
||||
|
||||
// legacy device writes
|
||||
#define AM_DEVWRITE_LEGACY(_tag, _handler) \
|
||||
curentry->set_handler(device, _tag, write_delegate(&_handler, #_handler, (device_t *)0)); \
|
||||
curentry->set_handler(device, write_delegate(&_handler, #_handler, _tag, (device_t *)0)); \
|
||||
|
||||
#define AM_DEVWRITE8_LEGACY(_tag, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, write8_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, write8_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVWRITE16_LEGACY(_tag, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, write16_delegate(&_handler, #_handler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, write16_delegate(&_handler, #_handler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
|
||||
|
||||
// legacy device reads/writes
|
||||
#define AM_DEVREADWRITE_LEGACY(_tag, _rhandler, _whandler) \
|
||||
curentry->set_handler(device, _tag, read_delegate(&_rhandler, #_rhandler, (device_t *)0), write_delegate(&_whandler, #_whandler, (device_t *)0)); \
|
||||
curentry->set_handler(device, read_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write_delegate(&_whandler, #_whandler, _tag, (device_t *)0)); \
|
||||
|
||||
#define AM_DEVREADWRITE8_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read8_delegate(&_rhandler, #_rhandler, (device_t *)0), write8_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, read8_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write8_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREADWRITE16_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read16_delegate(&_rhandler, #_rhandler, (device_t *)0), write16_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, read16_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write16_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREADWRITE32_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read32_delegate(&_rhandler, #_rhandler, (device_t *)0), write32_delegate(&_whandler, #_whandler, (device_t *)0), _unitmask); \
|
||||
curentry->set_handler(device, read32_delegate(&_rhandler, #_rhandler, _tag, (device_t *)0), write32_delegate(&_whandler, #_whandler, _tag, (device_t *)0), _unitmask); \
|
||||
|
||||
|
||||
// driver data reads
|
||||
#define AM_READ(_handler) \
|
||||
curentry->set_handler(device, DEVICE_SELF, read_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0)); \
|
||||
curentry->set_handler(device, read_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0)); \
|
||||
|
||||
#define AM_READ8(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, read8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
#define AM_READ16(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, read16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
#define AM_READ32(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, read32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
|
||||
// driver data writes
|
||||
#define AM_WRITE(_handler) \
|
||||
curentry->set_handler(device, DEVICE_SELF, write_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0)); \
|
||||
curentry->set_handler(device, write_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0)); \
|
||||
|
||||
#define AM_WRITE8(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, write8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write8_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
#define AM_WRITE16(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, write16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write16_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
#define AM_WRITE32(_handler, _unitmask) \
|
||||
curentry->set_handler(device, DEVICE_SELF, write32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, (drivdata_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write32_delegate(&drivdata_class::_handler, "driver_data::" #_handler, DEVICE_SELF, (drivdata_class *)0), _unitmask); \
|
||||
|
||||
|
||||
// driver data reads/writes
|
||||
#define AM_READWRITE(_rhandler, _whandler) \
|
||||
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)); \
|
||||
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)); \
|
||||
|
||||
#define AM_READWRITE8(_rhandler, _whandler, _unitmask) \
|
||||
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); \
|
||||
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); \
|
||||
|
||||
#define AM_READWRITE16(_rhandler, _whandler, _unitmask) \
|
||||
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); \
|
||||
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); \
|
||||
|
||||
#define AM_READWRITE32(_rhandler, _whandler, _unitmask) \
|
||||
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); \
|
||||
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); \
|
||||
|
||||
|
||||
// device reads
|
||||
#define AM_DEVREAD(_tag, _class, _handler) \
|
||||
curentry->set_handler(device, _tag, read_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0)); \
|
||||
curentry->set_handler(device, read_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0)); \
|
||||
|
||||
#define AM_DEVREAD8(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read8_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read8_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREAD16(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read16_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read16_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREAD32(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read32_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read32_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
|
||||
// device writes
|
||||
#define AM_DEVWRITE(_tag, _class, _handler) \
|
||||
curentry->set_handler(device, _tag, write_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0)); \
|
||||
curentry->set_handler(device, write_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0)); \
|
||||
|
||||
#define AM_DEVWRITE8(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, write8_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write8_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVWRITE16(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, write16_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write16_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVWRITE32(_tag, _class, _handler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, write32_delegate(&_class::_handler, #_class "::" #_handler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, write32_delegate(&_class::_handler, #_class "::" #_handler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
|
||||
// device reads/writes
|
||||
#define AM_DEVREADWRITE(_tag, _class, _rhandler, _whandler) \
|
||||
curentry->set_handler(device, _tag, read_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0)); \
|
||||
curentry->set_handler(device, read_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0)); \
|
||||
|
||||
#define AM_DEVREADWRITE8(_tag, _class, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read8_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write8_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read8_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write8_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREADWRITE16(_tag, _class, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read16_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write16_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read16_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write16_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
#define AM_DEVREADWRITE32(_tag, _class, _rhandler, _whandler, _unitmask) \
|
||||
curentry->set_handler(device, _tag, read32_delegate(&_class::_rhandler, #_class "::" #_rhandler, (_class *)0), write32_delegate(&_class::_whandler, #_class "::" #_whandler, (_class *)0), _unitmask); \
|
||||
curentry->set_handler(device, read32_delegate(&_class::_rhandler, #_class "::" #_rhandler, _tag, (_class *)0), write32_delegate(&_class::_whandler, #_class "::" #_whandler, _tag, (_class *)0), _unitmask); \
|
||||
|
||||
|
||||
// device mapping
|
||||
|
@ -448,7 +448,8 @@ protected:
|
||||
template<class _FunctionClass>
|
||||
static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
|
||||
{
|
||||
return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
|
||||
_FunctionClass *result = dynamic_cast<_FunctionClass *>(&object);
|
||||
return reinterpret_cast<delegate_generic_class *>(result);
|
||||
}
|
||||
|
||||
// internal state
|
||||
@ -636,7 +637,8 @@ protected:
|
||||
template<class _FunctionClass>
|
||||
static delegate_generic_class *late_bind_helper(delegate_late_bind &object)
|
||||
{
|
||||
return reinterpret_cast<delegate_generic_class *>(dynamic_cast<_FunctionClass *>(&object));
|
||||
_FunctionClass *result = dynamic_cast<_FunctionClass *>(&object);
|
||||
return reinterpret_cast<delegate_generic_class *>(result);
|
||||
}
|
||||
|
||||
// internal state
|
||||
@ -761,8 +763,4 @@ public:
|
||||
delegate &operator=(const basetype &src) { *static_cast<basetype *>(this) = src; return *this; }
|
||||
};
|
||||
|
||||
// Some useful delegates
|
||||
|
||||
typedef delegate<void (bool state)> line_cb_t;
|
||||
|
||||
#endif /* __DELEGATE_H__ */
|
||||
|
@ -99,6 +99,9 @@ enum
|
||||
// MACROS
|
||||
//**************************************************************************
|
||||
|
||||
// Some useful delegates
|
||||
typedef delegate<void (bool state)> line_cb_t;
|
||||
|
||||
// static template for a read_line stub function that calls through a given READ_LINE_MEMBER
|
||||
template<class _Class, int (_Class::*_Function)()>
|
||||
int devcb_line_stub(device_t *device)
|
||||
|
66
src/emu/devdelegate.c
Normal file
66
src/emu/devdelegate.c
Normal file
@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
|
||||
devdelegate.c
|
||||
|
||||
Delegates that are late-bound to MAME devices.
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// bound_object - use the device name to locate
|
||||
// a device relative to the given search root;
|
||||
// fatal error if not found
|
||||
//-------------------------------------------------
|
||||
|
||||
delegate_late_bind &device_delegate_helper::bound_object(device_t &search_root)
|
||||
{
|
||||
device_t *device = search_root.subdevice(m_device_name);
|
||||
if (device == NULL)
|
||||
throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag());
|
||||
return *device;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// safe_tag - return a tag string or (unknown) if
|
||||
// the object is not valid
|
||||
//-------------------------------------------------
|
||||
|
||||
const char *device_delegate_helper::safe_tag(device_t *object)
|
||||
{
|
||||
return (object != NULL) ? object->tag() : "(unknown)";
|
||||
}
|
106
src/emu/devdelegate.h
Normal file
106
src/emu/devdelegate.h
Normal file
@ -0,0 +1,106 @@
|
||||
/***************************************************************************
|
||||
|
||||
devdelegate.h
|
||||
|
||||
Delegates that are late-bound to MAME devices.
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DEVDELEGATE_H__
|
||||
#define __DEVDELEGATE_H__
|
||||
|
||||
#include "delegate.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> device_delegate_helper
|
||||
|
||||
// device_delegate_helper does non-template work
|
||||
class device_delegate_helper
|
||||
{
|
||||
protected:
|
||||
// constructor
|
||||
device_delegate_helper(const char *devname) : m_device_name(devname) { }
|
||||
|
||||
// internal helpers
|
||||
delegate_late_bind &bound_object(device_t &search_root);
|
||||
static const char *safe_tag(device_t *object);
|
||||
|
||||
// internal state
|
||||
const char *m_device_name;
|
||||
};
|
||||
|
||||
|
||||
// ======================> device_delegate
|
||||
|
||||
// device_delegate is a delegate that wraps with a device tag and can be easily
|
||||
// late bound without replicating logic everywhere
|
||||
template<typename _Signature>
|
||||
class device_delegate : public delegate<_Signature>, device_delegate_helper
|
||||
{
|
||||
typedef device_delegate<_Signature> thistype;
|
||||
typedef delegate<_Signature> basetype;
|
||||
|
||||
public:
|
||||
// provide the same constructors as the base class
|
||||
device_delegate() : basetype(), device_delegate_helper(NULL) { }
|
||||
device_delegate(const basetype &src) : basetype(src), device_delegate_helper(src.m_device_name) { }
|
||||
device_delegate(const basetype &src, delegate_late_bind &object) : basetype(src, object), device_delegate_helper(src.m_device_name) { }
|
||||
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))) { }
|
||||
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))) { }
|
||||
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))) { }
|
||||
device_delegate &operator=(const thistype &src) { *static_cast<basetype *>(this) = src; m_device_name = src.m_device_name; return *this; }
|
||||
|
||||
// provide additional constructors that take a device name string
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
|
||||
// and constructors that provide a search root
|
||||
device_delegate(const thistype &src, device_t &search_root) : basetype(src), device_delegate_helper(src.m_device_name) { bind_relative_to(search_root); }
|
||||
|
||||
// perform the binding
|
||||
void bind_relative_to(device_t &search_root) { if (!basetype::isnull()) basetype::late_bind(bound_object(search_root)); }
|
||||
};
|
||||
|
||||
|
||||
#endif /* __DEVDELEGATE_H__ */
|
@ -992,22 +992,4 @@ inline device_t *device_t::siblingdevice(const char *tag) const
|
||||
return (tag[0] == ':') ? subdevice(tag) : NULL;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// bind_relative_to - perform a late binding of
|
||||
// a device_delegate
|
||||
//-------------------------------------------------
|
||||
|
||||
template<typename _Signature>
|
||||
void device_delegate<_Signature>::bind_relative_to(device_t &search_root)
|
||||
{
|
||||
if (!basetype::isnull())
|
||||
{
|
||||
device_t *device = search_root.subdevice(m_device_name);
|
||||
if (device == NULL)
|
||||
throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag());
|
||||
basetype::late_bind(*device);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __DEVINTRF_H__ */
|
||||
|
@ -241,7 +241,7 @@ void device_memory_interface::interface_validity_check(validity_checker &valid)
|
||||
int alignunit = datawidth / 8;
|
||||
|
||||
// construct the maps
|
||||
::address_map *map = global_alloc(::address_map(device(), spacenum));
|
||||
::address_map *map = global_alloc(::address_map(const_cast<device_t &>(device()), spacenum));
|
||||
|
||||
// if this is an empty map, just skip it
|
||||
if (map->m_entrylist.first() == NULL)
|
||||
@ -323,15 +323,23 @@ void device_memory_interface::interface_validity_check(validity_checker &valid)
|
||||
}
|
||||
|
||||
// make sure all devices exist
|
||||
if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag && device().siblingdevice(entry->m_read.m_tag) == NULL)
|
||||
mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_read.m_tag.cstr());
|
||||
if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag && device().siblingdevice(entry->m_write.m_tag) == NULL)
|
||||
mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_write.m_tag.cstr());
|
||||
if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag != NULL)
|
||||
{
|
||||
astring temp(entry->m_read.m_tag);
|
||||
if (device().siblingdevice(temp) == NULL)
|
||||
mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_read.m_tag);
|
||||
}
|
||||
if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag != NULL)
|
||||
{
|
||||
astring temp(entry->m_write.m_tag);
|
||||
if (device().siblingdevice(temp) == NULL)
|
||||
mame_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_write.m_tag);
|
||||
}
|
||||
|
||||
// make sure ports exist
|
||||
// if ((entry->m_read.m_type == AMH_PORT && entry->m_read.m_tag != NULL && portlist.find(entry->m_read.m_tag) == NULL) ||
|
||||
// (entry->m_write.m_type == AMH_PORT && entry->m_write.m_tag != NULL && portlist.find(entry->m_write.m_tag) == NULL))
|
||||
// mame_printf_error("%s space memory map entry references nonexistant port tag '%s'\n", spaceconfig->m_name, entry->m_read.m_tag.cstr());
|
||||
// mame_printf_error("%s space memory map entry references nonexistant port tag '%s'\n", spaceconfig->m_name, entry->m_read.m_tag);
|
||||
|
||||
// validate bank and share tags
|
||||
if (entry->m_read.m_type == AMH_BANK)
|
||||
|
@ -67,6 +67,7 @@
|
||||
#include "hash.h"
|
||||
#include "fileio.h" // remove me once NVRAM is implemented as device
|
||||
#include "delegate.h"
|
||||
#include "devdelegate.h"
|
||||
|
||||
// memory and address spaces
|
||||
#include "memory.h"
|
||||
@ -81,35 +82,6 @@
|
||||
class machine_config;
|
||||
typedef device_t * (*machine_config_constructor)(machine_config &config, device_t *owner);
|
||||
|
||||
// device_delegate is a delegate that wraps with a device tag and can be easily
|
||||
// late bound without replicating logic everywhere
|
||||
template<typename _Signature>
|
||||
class device_delegate : public delegate<_Signature>
|
||||
{
|
||||
typedef delegate<_Signature> basetype;
|
||||
|
||||
public:
|
||||
// provide same set of constructors as the base class, with additional device name
|
||||
// parameter
|
||||
device_delegate() : basetype(), m_device_name(NULL) { }
|
||||
device_delegate(const basetype &src) : basetype(src), m_device_name(src.m_device_name) { }
|
||||
device_delegate(const basetype &src, delegate_late_bind &object) : basetype(src, object), m_device_name(src.m_device_name) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
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) { }
|
||||
device_delegate &operator=(const basetype &src) { *static_cast<basetype *>(this) = src; m_device_name = src.m_device_name; return *this; }
|
||||
|
||||
// perform the binding
|
||||
void bind_relative_to(device_t &search_root);
|
||||
|
||||
private:
|
||||
// internal state
|
||||
const char *m_device_name;
|
||||
};
|
||||
|
||||
// I/O
|
||||
#include "input.h"
|
||||
#include "ioport.h"
|
||||
|
@ -54,6 +54,7 @@ EMUOBJS = \
|
||||
$(EMUOBJ)/crsshair.o \
|
||||
$(EMUOBJ)/debugger.o \
|
||||
$(EMUOBJ)/delegate.o \
|
||||
$(EMUOBJ)/devdelegate.o \
|
||||
$(EMUOBJ)/devcb.o \
|
||||
$(EMUOBJ)/devcpu.o \
|
||||
$(EMUOBJ)/device.o \
|
||||
|
@ -18,8 +18,8 @@ void report_bad_cast(const std::type_info &src_type, const std::type_info &dst_t
|
||||
src_type.name(), dst_type.name());
|
||||
}
|
||||
|
||||
void report_bad_device_cast(const device_t *dev, const std::type_info &dst_type)
|
||||
void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type)
|
||||
{
|
||||
throw emu_fatalerror("Error: bad downcast<> or device<>. Tried to convert the device %s of type %s to a %s, which are incompatible.\n",
|
||||
dev->tag(), dev->name(), dst_type.name());
|
||||
dev->tag(), src_type.name(), dst_type.name());
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ private:
|
||||
class device_t;
|
||||
|
||||
void report_bad_cast(const std::type_info &src_type, const std::type_info &dst_type);
|
||||
void report_bad_device_cast(const device_t *dev, const std::type_info &dst_type);
|
||||
void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type);
|
||||
|
||||
// template function for casting from a base class to a derived class that is checked
|
||||
// in debug builds and fast in release builds
|
||||
@ -346,7 +346,7 @@ inline _Dest downcast(_Source *src)
|
||||
if (dynamic_cast<_Dest>(src) != src)
|
||||
{
|
||||
if (dynamic_cast<const device_t *>(src) != NULL)
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(src), typeid(_Dest));
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(src), typeid(src), typeid(_Dest));
|
||||
else
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
@ -361,7 +361,7 @@ inline _Dest downcast(_Source &src)
|
||||
if (&dynamic_cast<_Dest>(src) != &src)
|
||||
{
|
||||
if (dynamic_cast<const device_t *>(&src) != NULL)
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(&src), typeid(_Dest));
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(&src), typeid(src), typeid(_Dest));
|
||||
else
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ void address_space::prepare_map()
|
||||
}
|
||||
|
||||
// validate adjusted addresses against implicit regions
|
||||
if (entry->m_region != NULL && entry->m_share == NULL && entry->m_baseptr == NULL)
|
||||
if (entry->m_region != NULL && entry->m_share == NULL)
|
||||
{
|
||||
// determine full tag
|
||||
astring fulltag;
|
||||
@ -1903,7 +1903,6 @@ void address_space::populate_from_map(address_map *map)
|
||||
void address_space::populate_map_entry(const address_map_entry &entry, read_or_write readorwrite)
|
||||
{
|
||||
const map_handler_data &data = (readorwrite == ROW_READ) ? entry.m_read : entry.m_write;
|
||||
device_t *target_device;
|
||||
astring fulltag;
|
||||
|
||||
// based on the handler type, alter the bits, name, funcptr, and object
|
||||
@ -1931,25 +1930,21 @@ void address_space::populate_map_entry(const address_map_entry &entry, read_or_w
|
||||
break;
|
||||
|
||||
case AMH_DEVICE_DELEGATE:
|
||||
target_device = device().siblingdevice(data.m_tag);
|
||||
if (target_device == NULL)
|
||||
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());
|
||||
|
||||
if (readorwrite == ROW_READ)
|
||||
switch (data.m_bits)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
else
|
||||
switch (data.m_bits)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1974,18 +1969,18 @@ void address_space::populate_map_entry(const address_map_entry &entry, read_or_w
|
||||
|
||||
case AMH_PORT:
|
||||
install_readwrite_port(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror,
|
||||
(readorwrite == ROW_READ) ? data.m_tag.cstr() : NULL,
|
||||
(readorwrite == ROW_WRITE) ? data.m_tag.cstr() : NULL);
|
||||
(readorwrite == ROW_READ) ? data.m_tag : NULL,
|
||||
(readorwrite == ROW_WRITE) ? data.m_tag : NULL);
|
||||
break;
|
||||
|
||||
case AMH_BANK:
|
||||
install_bank_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror,
|
||||
(readorwrite == ROW_READ) ? data.m_tag.cstr() : NULL,
|
||||
(readorwrite == ROW_WRITE) ? data.m_tag.cstr() : NULL);
|
||||
(readorwrite == ROW_READ) ? data.m_tag : NULL,
|
||||
(readorwrite == ROW_WRITE) ? data.m_tag : NULL);
|
||||
break;
|
||||
|
||||
case AMH_DEVICE_SUBMAP:
|
||||
throw emu_fatalerror("Internal mapping error: leftover mapping of '%s'.\n", data.m_tag.cstr());
|
||||
throw emu_fatalerror("Internal mapping error: leftover mapping of '%s'.\n", data.m_tag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2067,19 +2062,6 @@ void address_space::allocate_memory()
|
||||
|
||||
void address_space::locate_memory()
|
||||
{
|
||||
// fill in base/size entries
|
||||
for (const address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next())
|
||||
{
|
||||
if (entry->m_baseptr != NULL)
|
||||
*entry->m_baseptr = entry->m_memory;
|
||||
if (entry->m_baseptroffs_plus1 != 0)
|
||||
*(void **)(reinterpret_cast<UINT8 *>(machine().driver_data()) + entry->m_baseptroffs_plus1 - 1) = entry->m_memory;
|
||||
if (entry->m_sizeptr != NULL)
|
||||
*entry->m_sizeptr = entry->m_byteend - entry->m_bytestart + 1;
|
||||
if (entry->m_sizeptroffs_plus1 != 0)
|
||||
*(size_t *)(reinterpret_cast<UINT8 *>(machine().driver_data()) + entry->m_sizeptroffs_plus1 - 1) = entry->m_byteend - entry->m_bytestart + 1;
|
||||
}
|
||||
|
||||
// once this is done, find the starting bases for the banks
|
||||
for (memory_bank *bank = manager().m_banklist.first(); bank != NULL; bank = bank->next())
|
||||
if (bank->base() == NULL && bank->references_space(*this, ROW_READWRITE))
|
||||
@ -2713,10 +2695,6 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend)
|
||||
|
||||
bool address_space::needs_backing_store(const address_map_entry *entry)
|
||||
{
|
||||
// if we are asked to provide a base pointer, then yes, we do need backing
|
||||
if (entry->m_baseptr != NULL || entry->m_baseptroffs_plus1 != 0)
|
||||
return true;
|
||||
|
||||
// if we are sharing, and we don't have a pointer yet, create one
|
||||
if (entry->m_share != NULL)
|
||||
{
|
||||
|
@ -105,10 +105,10 @@ class address_table_write;
|
||||
typedef UINT32 offs_t;
|
||||
|
||||
// address map constructors are functions that build up an address_map
|
||||
typedef void (*address_map_constructor)(address_map &map, const device_t &devconfig);
|
||||
typedef void (*address_map_constructor)(address_map &map, device_t &devconfig);
|
||||
|
||||
// submap retriever delegate
|
||||
typedef delegate<void (address_map &, const device_t &)> address_map_delegate;
|
||||
typedef delegate<void (address_map &, device_t &)> address_map_delegate;
|
||||
|
||||
|
||||
// legacy space read/write handlers
|
||||
@ -162,19 +162,19 @@ typedef delegate<offs_t (direct_read_data &, offs_t)> direct_update_delegate;
|
||||
// ======================> read_delegate
|
||||
|
||||
// declare delegates for each width
|
||||
typedef delegate<UINT8 (address_space &, offs_t, UINT8)> read8_delegate;
|
||||
typedef delegate<UINT16 (address_space &, offs_t, UINT16)> read16_delegate;
|
||||
typedef delegate<UINT32 (address_space &, offs_t, UINT32)> read32_delegate;
|
||||
typedef delegate<UINT64 (address_space &, offs_t, UINT64)> read64_delegate;
|
||||
typedef device_delegate<UINT8 (address_space &, offs_t, UINT8)> read8_delegate;
|
||||
typedef device_delegate<UINT16 (address_space &, offs_t, UINT16)> read16_delegate;
|
||||
typedef device_delegate<UINT32 (address_space &, offs_t, UINT32)> read32_delegate;
|
||||
typedef device_delegate<UINT64 (address_space &, offs_t, UINT64)> read64_delegate;
|
||||
|
||||
|
||||
// ======================> write_delegate
|
||||
|
||||
// declare delegates for each width
|
||||
typedef delegate<void (address_space &, offs_t, UINT8, UINT8)> write8_delegate;
|
||||
typedef delegate<void (address_space &, offs_t, UINT16, UINT16)> write16_delegate;
|
||||
typedef delegate<void (address_space &, offs_t, UINT32, UINT32)> write32_delegate;
|
||||
typedef delegate<void (address_space &, offs_t, UINT64, UINT64)> write64_delegate;
|
||||
typedef device_delegate<void (address_space &, offs_t, UINT8, UINT8)> write8_delegate;
|
||||
typedef device_delegate<void (address_space &, offs_t, UINT16, UINT16)> write16_delegate;
|
||||
typedef device_delegate<void (address_space &, offs_t, UINT32, UINT32)> write32_delegate;
|
||||
typedef device_delegate<void (address_space &, offs_t, UINT64, UINT64)> write64_delegate;
|
||||
|
||||
|
||||
// ======================> direct_read_data
|
||||
|
Loading…
Reference in New Issue
Block a user