summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Vas Crabb <vas@vastheman.com>2018-06-06 23:39:57 +1000
committerGravatarGravatar Vas Crabb <vas@vastheman.com>2018-06-06 23:39:57 +1000
commitbefb02ba663b990146be09387755a24163c283c7 (patch) (github)
tree185e616d912a6021869bffb33c6116c71c2a7dfd
parentf5e90f3e045556f3248b173351929e64dae304c3 (diff)
downloadmame-befb02ba663b990146be09387755a24163c283c7.tar.bz2
mame-befb02ba663b990146be09387755a24163c283c7.zip
Next-gen config: make address map config not look like arse
-rw-r--r--src/emu/addrmap.h22
-rw-r--r--src/emu/device.ipp14
-rw-r--r--src/emu/diexec.h6
-rw-r--r--src/emu/dimemory.h21
-rw-r--r--src/emu/speaker.h12
-rw-r--r--src/mame/drivers/ksys573.cpp10
-rw-r--r--src/mame/drivers/tranz330.cpp4
-rw-r--r--src/mame/drivers/zorba.cpp6
8 files changed, 68 insertions, 27 deletions
diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h
index 16ae233649f..9673aa929ec 100644
--- a/src/emu/addrmap.h
+++ b/src/emu/addrmap.h
@@ -14,8 +14,8 @@
#error Dont include this file directly; include emu.h instead.
#endif
-#ifndef __ADDRMAP_H__
-#define __ADDRMAP_H__
+#ifndef MAME_EMU_ADDRMAP_H
+#define MAME_EMU_ADDRMAP_H
@@ -47,16 +47,12 @@ enum map_handler_type
class map_handler_data
{
public:
- map_handler_data()
- : m_type(AMH_NONE),
- m_bits(0),
- m_name(nullptr),
- m_tag(nullptr) { }
-
- map_handler_type m_type; // type of the handler
- u8 m_bits; // width of the handler in bits, or 0 for default
- const char * m_name; // name of the handler
- const char * m_tag; // tag for I/O ports and banks
+ map_handler_data() { }
+
+ map_handler_type m_type = AMH_NONE; // type of the handler
+ u8 m_bits = 0; // width of the handler in bits, or 0 for default
+ const char * m_name = nullptr; // name of the handler
+ const char * m_tag = nullptr; // tag for I/O ports and banks
};
@@ -485,4 +481,4 @@ public:
void map_validity_check(validity_checker &valid, int spacenum) const;
};
-#endif /* __ADDRMAP_H__ */
+#endif // MAME_EMU_ADDRMAP_H
diff --git a/src/emu/device.ipp b/src/emu/device.ipp
index e90f6bd4e6c..e2641dd3c1e 100644
--- a/src/emu/device.ipp
+++ b/src/emu/device.ipp
@@ -90,4 +90,18 @@ inline void device_t::logerror(Format &&fmt, Params &&... args) const
}
}
+template <typename T, typename Ret, typename... Params>
+std::enable_if_t<device_memory_interface::is_related_class<device_t, T>::value> device_memory_interface::set_addrmap(int spacenum, Ret (T::*func)(Params... args))
+{
+ device_t &dev(device().mconfig().current_device());
+ set_addrmap(spacenum, address_map_constructor(func, dev.tag(), &downcast<T &>(dev)));
+}
+
+template <typename T, typename Ret, typename... Params>
+std::enable_if_t<!device_memory_interface::is_related_class<device_t, T>::value> device_memory_interface::set_addrmap(int spacenum, Ret (T::*func)(Params... args))
+{
+ device_t &dev(device().mconfig().current_device());
+ set_addrmap(spacenum, address_map_constructor(func, dev.tag(), &dynamic_cast<T &>(dev)));
+}
+
#endif // MAME_EMU_DEVICE_IPP
diff --git a/src/emu/diexec.h b/src/emu/diexec.h
index dd3c5c54727..3c9d754434e 100644
--- a/src/emu/diexec.h
+++ b/src/emu/diexec.h
@@ -140,10 +140,10 @@ public:
// inline configuration helpers
void set_disable() { m_disabled = true; }
- template <typename Object> void set_vblank_int(Object &&cb, const char *tag, int rate = 0)
+ template <typename Object> void set_vblank_int(Object &&cb, const char *tag, int rate = 0)
{
m_vblank_interrupt = std::forward<Object>(cb);
- m_vblank_interrupt_screen = tag;
+ m_vblank_interrupt_screen = tag;
}
template <typename Object> void set_periodic_int(Object &&cb, const attotime &rate)
{
@@ -290,7 +290,7 @@ private:
// configuration
bool m_disabled; // disabled from executing?
device_interrupt_delegate m_vblank_interrupt; // for interrupts tied to VBLANK
- const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
+ const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
device_interrupt_delegate m_timed_interrupt; // for interrupts not tied to VBLANK
attotime m_timed_interrupt_period; // period for periodic interrupts
diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h
index ce3d857c98c..80e2bd72100 100644
--- a/src/emu/dimemory.h
+++ b/src/emu/dimemory.h
@@ -17,6 +17,8 @@
#ifndef MAME_EMU_DIMEMORY_H
#define MAME_EMU_DIMEMORY_H
+#include <type_traits>
+
//**************************************************************************
// CONSTANTS
@@ -72,6 +74,11 @@ constexpr int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MAS
class device_memory_interface : public device_interface
{
friend class device_scheduler;
+ template <typename T, typename U> struct is_related_class { static constexpr bool value = std::is_convertible<std::add_pointer_t<T>, std::add_pointer_t<U> >::value; };
+ template <typename T, typename U> struct is_related_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && is_related_class<T, U>::value; };
+ template <typename T, typename U> struct is_related_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && is_related_class<T, U>::value; };
+ template <typename T, typename U> struct is_unrelated_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && !is_related_class<T, U>::value; };
+ template <typename T, typename U> struct is_unrelated_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && !is_related_class<T, U>::value; };
public:
// construction/destruction
@@ -83,7 +90,19 @@ public:
const address_space_config *space_config(int spacenum = 0) const { return spacenum >= 0 && spacenum < int(m_address_config.size()) ? m_address_config[spacenum] : nullptr; }
int max_space_count() const { return m_address_config.size(); }
- // static inline configuration helpers
+ // configuration helpers
+ template <typename T, typename U, typename Ret, typename... Params>
+ std::enable_if_t<is_related_device<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.tag(), &downcast<U &>(obj))); }
+ template <typename T, typename U, typename Ret, typename... Params>
+ std::enable_if_t<is_related_interface<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.device().tag(), &downcast<U &>(obj))); }
+ template <typename T, typename U, typename Ret, typename... Params>
+ std::enable_if_t<is_unrelated_device<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.tag(), &dynamic_cast<U &>(obj))); }
+ template <typename T, typename U, typename Ret, typename... Params>
+ std::enable_if_t<is_unrelated_interface<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params... args)) { set_addrmap(spacenum, address_map_constructor(func, obj.device().tag(), &dynamic_cast<U &>(obj))); }
+ template <typename T, typename Ret, typename... Params>
+ std::enable_if_t<is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params... args));
+ template <typename T, typename Ret, typename... Params>
+ std::enable_if_t<!is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params... args));
void set_addrmap(int spacenum, address_map_constructor map);
// basic information getters
diff --git a/src/emu/speaker.h b/src/emu/speaker.h
index 64c6767cc40..ce4034ade0f 100644
--- a/src/emu/speaker.h
+++ b/src/emu/speaker.h
@@ -6,6 +6,18 @@
Speaker output sound device.
+ Speakers have (x, y, z) coordinates in 3D space:
+ * Observer is at position (0, 0, 0)
+ * Positive x is to the right of the observer
+ * Negative x is to the left of the observer
+ * Positive y is above the observer
+ * Negative y is below the observer
+ * Positive z is in front of the observer
+ * Negative z is behind the observer
+
+ Currently, MAME only considers the sign of the x coordinate (not its
+ magnitude), and completely ignores the y and z coordinates.
+
***************************************************************************/
#ifndef MAME_EMU_SPEAKER_H
#define MAME_EMU_SPEAKER_H
diff --git a/src/mame/drivers/ksys573.cpp b/src/mame/drivers/ksys573.cpp
index 122e163af87..da970f9b948 100644
--- a/src/mame/drivers/ksys573.cpp
+++ b/src/mame/drivers/ksys573.cpp
@@ -2144,14 +2144,14 @@ MACHINE_CONFIG_END
// Variants with additional digital sound board
MACHINE_CONFIG_START(ksys573_state::k573d)
konami573(config);
- m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573d_map, tag(), this));
+ m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573d_map);
MCFG_KONAMI_573_DIGITAL_IO_BOARD_ADD( "k573dio", XTAL(19'660'800) )
MACHINE_CONFIG_END
// Variants with additional analogue i/o board
MACHINE_CONFIG_START(ksys573_state::k573a)
konami573(config);
- m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573a_map, tag(), this));
+ m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573a_map);
MACHINE_CONFIG_END
MACHINE_CONFIG_START(ksys573_state::pccard1_16mb)
@@ -2409,7 +2409,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(ksys573_state::fbaitbc)
konami573(config);
- m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::fbaitbc_map, tag(), this));
+ m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::fbaitbc_map);
MCFG_DEVICE_ADD(m_upd4701, UPD4701A, 0)
MCFG_UPD4701_PORTY("uPD4701_y")
@@ -2449,7 +2449,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(ksys573_state::pnchmn)
konami573(config);
- m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::konami573a_map, tag(), this));
+ m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::konami573a_map);
cassxi(config);
pccard1_32mb(config);
@@ -2465,7 +2465,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(ksys573_state::gunmania)
konami573(config);
- m_maincpu->set_addrmap(AS_PROGRAM, address_map_constructor(&std::remove_pointer_t<decltype(this)>::gunmania_map, tag(), this));
+ m_maincpu->set_addrmap(AS_PROGRAM, &ksys573_state::gunmania_map);
DS2401( config, "gunmania_id" );
pccard2_32mb(config);
diff --git a/src/mame/drivers/tranz330.cpp b/src/mame/drivers/tranz330.cpp
index f3b04af06f5..147a626abf0 100644
--- a/src/mame/drivers/tranz330.cpp
+++ b/src/mame/drivers/tranz330.cpp
@@ -143,8 +143,8 @@ static const z80_daisy_config tranz330_daisy_chain[] =
void tranz330_state::tranz330(machine_config &config)
{
Z80(config, m_cpu, XTAL(7'159'090)/2); //*
- m_cpu->set_addrmap(AS_PROGRAM, address_map_constructor(&tranz330_state::tranz330_mem, tag(), this));
- m_cpu->set_addrmap(AS_IO, address_map_constructor(&tranz330_state::tranz330_io, tag(), this));
+ m_cpu->set_addrmap(AS_PROGRAM, &tranz330_state::tranz330_mem);
+ m_cpu->set_addrmap(AS_IO, &tranz330_state::tranz330_io);
m_cpu->set_daisy_config(tranz330_daisy_chain);
CLOCK(config, "ctc_clock", XTAL(7'159'090)/4) // ?
diff --git a/src/mame/drivers/zorba.cpp b/src/mame/drivers/zorba.cpp
index cc55777ef71..3b9d6d032a9 100644
--- a/src/mame/drivers/zorba.cpp
+++ b/src/mame/drivers/zorba.cpp
@@ -137,9 +137,9 @@ GFXDECODE_END
MACHINE_CONFIG_START(zorba_state::zorba)
// basic machine hardware
- MCFG_DEVICE_ADD(m_maincpu, Z80, 24_MHz_XTAL / 6)
- MCFG_DEVICE_PROGRAM_MAP(zorba_mem)
- MCFG_DEVICE_IO_MAP(zorba_io)
+ Z80(config, m_maincpu, 24_MHz_XTAL / 6);
+ m_maincpu->set_addrmap(AS_PROGRAM, &zorba_state::zorba_mem);
+ m_maincpu->set_addrmap(AS_IO, &zorba_state::zorba_io);
/* video hardware */
MCFG_SCREEN_ADD_MONOCHROME("screen", RASTER, rgb_t::green())