diff options
Diffstat (limited to 'src/emu/screen.h')
-rw-r--r-- | src/emu/screen.h | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/emu/screen.h b/src/emu/screen.h index c43c5fe7278..3842a65b2e6 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -12,6 +12,7 @@ #pragma once +#include <type_traits> #include <utility> @@ -338,36 +339,29 @@ public: m_yoffset = yoffs; } - // FIXME: these should be aware of current device for resolving the tag - template <class FunctionClass> - void set_screen_update(u32 (FunctionClass::*callback)(screen_device &, bitmap_ind16 &, const rectangle &), const char *name) + template <typename F> + std::enable_if_t<screen_update_ind16_delegate::supports_callback<F>::value> set_screen_update(F &&callback, const char *name) { - set_screen_update(screen_update_ind16_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); + m_screen_update_ind16.set(std::forward<F>(callback), name); + m_screen_update_rgb32 = screen_update_rgb32_delegate(*this); } - template <class FunctionClass> - void set_screen_update(u32 (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name) + template <typename F> + std::enable_if_t<screen_update_rgb32_delegate::supports_callback<F>::value> set_screen_update(F &&callback, const char *name) { - set_screen_update(screen_update_rgb32_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); + m_screen_update_ind16 = screen_update_ind16_delegate(*this); + m_screen_update_rgb32.set(std::forward<F>(callback), name); } - template <class FunctionClass> - void set_screen_update(const char *devname, u32 (FunctionClass::*callback)(screen_device &, bitmap_ind16 &, const rectangle &), const char *name) + template <typename T, typename F> + std::enable_if_t<screen_update_ind16_delegate::supports_callback<F>::value> set_screen_update(T &&target, F &&callback, const char *name) { - set_screen_update(screen_update_ind16_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); + m_screen_update_ind16.set(std::forward<T>(target), std::forward<F>(callback), name); + m_screen_update_rgb32 = screen_update_rgb32_delegate(*this); } - template <class FunctionClass> - void set_screen_update(const char *devname, u32 (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name) + template <typename T, typename F> + std::enable_if_t<screen_update_rgb32_delegate::supports_callback<F>::value> set_screen_update(T &&target, F &&callback, const char *name) { - set_screen_update(screen_update_rgb32_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - void set_screen_update(screen_update_ind16_delegate callback) - { - m_screen_update_ind16 = callback; - m_screen_update_rgb32 = screen_update_rgb32_delegate(); - } - void set_screen_update(screen_update_rgb32_delegate callback) - { - m_screen_update_ind16 = screen_update_ind16_delegate(); - m_screen_update_rgb32 = callback; + m_screen_update_ind16 = screen_update_ind16_delegate(*this); + m_screen_update_rgb32.set(std::forward<T>(target), std::forward<F>(callback), name); } auto screen_vblank() { return m_screen_vblank.bind(); } |