diff options
author | 2019-10-26 12:47:04 +1100 | |
---|---|---|
committer | 2019-10-26 12:47:04 +1100 | |
commit | f81fbdb8d4356b7a526a902726463e2f1af00615 (patch) | |
tree | f73f8746dc3cd1feb81afdb3cb4e6b0b99141ea0 /src/devices/video | |
parent | bc7c6ea17e1b38f6fb488177e01c63577fbbcf71 (diff) |
Make devdelegate more like devcb for configuration. This is a
fundamental change to show device delegates are configured.
Device delegates are now aware of the current device during
configuration and will resolve string tags relative to it. This means
that device delegates need a device to be supplied on construction so
they can find the machine configuration object. There's a
one-dimensional array helper to make it easier to construct arrays of
device delegates with the same owner. (I didn't make an n-dimensional
one because I didn't hit a use case, but it would be a simple addition.)
There's no more bind_relative_to member - just call resolve() like you
would for a devcb. There's also no need to cast nullptr when creating a
late bind device delegate. The flip side is that for an overloaded or
non-capturing lambda you'll need to cast to the desired type.
There is one less conditional branch in the hot path for calls for
delegates bound to a function pointer of member function pointer. This
comes at the cost of one additional unconditional branch in the hot
path for calls to delegates bound to functoids (lambdas, functions that
don't take an object reference, other callable objects). This applies
to all delegates, not just device delegates.
Address spaces will now print an error message if a late bind error is
encountered while installing a handler. This will give the range and
address range, hopefully making it easier to guess which memory map is
faulty.
For the simple case of allowing a device_delegate member to be
configured, use a member like this:
template <typename... T> void set_foo(T &&...args) { m_foo_cb.set(std::forward<T>(args)...); }
For a case where different delegates need to be used depending on the
function signature, see src/emu/screen.h (the screen update function
setters).
Device delegates now take a target specification and function pointer.
The target may be:
* Target omitted, implying the current device being configured. This
can only be used during configuration. It will work as long as the
current device is not removed/replaced.
* A tag string relative to the current device being configured. This
can only be used during configuration. It will not be callable until
.resolve() is called. It will work as long as the current device is
not removed/replaced.
* A device finder (required_device/optional_device). The delegate will
late bind to the current target of the device finder. It will not
be callable until .resolve() is called. It will work properly if the
target device is replaced, as long as the device finder's base object
isn't removed/replaced.
* A reference to an object. It will be callable immediately. It will
work as long as the target object is not removed/replaced.
The target types and restrictions are pretty similar to what you already
have on object finders and devcb, so it shouldn't cause any surprises.
Note that dereferencing a device finder will changes the effect. To
illustrate this:
...
required_device<some_device> m_dev;
...
m_dev(*this, "dev")
...
// will late bind to "dev" relative to *this
// will work if "dev" hasn't been created yet or is replaced later
// won't work if *this is removed/replaced
// won't be callable until resolve() is called
cb1.set(m_dev, FUNC(some_device::w));
...
// will bind to current target of m_dev
// will not work if m_dev is not resolved
// will not work if "dev" is replaced later
// will be callable immediately
cb2.set(*m_dev, FUNC(some_device::w));
...
The order of the target and name has been reversed for functoids
(lambdas and other callable objects). This allows the NAME macro to
be used on lambdas and functoids. For example:
foo.set_something(NAME([this] (u8 data) { m_something = data; }));
I realise the diagnostic messages get ugly if you use NAME on a large
lambda. You can still give a literal name, you just have to place it
after the lambda rather than before. This is uglier, but it's
intentional. I'm trying to drive developers away from a certain style.
While it's nice that you can put half the driver code in the memory map,
it detracts from readability. It's hard to visualise the memory range
mappings if the memory map functions are punctuated by large lambdas.
There's also slightly higher overhead for calling a delegate bound to a
functoid.
If the code is prettier for trivial lambdas but uglier for non-trivial
lambdas in address maps, it will hopefully steer people away from
putting non-trivial lambdas in memory maps.
There were some devices that were converted from using plain delegates
without adding bind_relative_to calls. I fixed some of them (e.g.
LaserDisc) but I probably missed some. These will likely crash on
unresolved delegate calls.
There are some devices that reset delegates at configuration complete or
start time, preventing them from being set up during configuration (e.g.
src/devices/video/ppu2c0x.cpp and src/devices/machine/68307.cpp). This
goes against the design principles of how device delegates should be
used, but I didn't change them because I don't trust myself to find all
the places they're used.
I've definitely broken some stuff with this (I know about asterix), so
report issues and bear with me until I get it all fixed.
Diffstat (limited to 'src/devices/video')
47 files changed, 128 insertions, 219 deletions
diff --git a/src/devices/video/315_5313.cpp b/src/devices/video/315_5313.cpp index d664909bfae..891e9ad0328 100644 --- a/src/devices/video/315_5313.cpp +++ b/src/devices/video/315_5313.cpp @@ -169,6 +169,9 @@ sega315_5313_device::sega315_5313_device(const machine_config &mconfig, const ch , m_sndirqline_callback(*this) , m_lv6irqline_callback(*this) , m_lv4irqline_callback(*this) + , m_32x_scanline_func(*this) + , m_32x_interrupt_func(*this) + , m_32x_scanline_helper_func(*this) , m_command_pending(0) , m_command_part1(0) , m_command_part2(0) @@ -283,9 +286,9 @@ void sega315_5313_device::device_start() m_lv6irqline_callback.resolve_safe(); m_lv4irqline_callback.resolve_safe(); - m_32x_scanline_func.bind_relative_to(*owner()); - m_32x_interrupt_func.bind_relative_to(*owner()); - m_32x_scanline_helper_func.bind_relative_to(*owner()); + m_32x_scanline_func.resolve(); + m_32x_interrupt_func.resolve(); + m_32x_scanline_helper_func.resolve(); m_vram = std::make_unique<u16[]>(0x10000 / 2); m_cram = std::make_unique<u16[]>(0x80 / 2); diff --git a/src/devices/video/315_5313.h b/src/devices/video/315_5313.h index fe68bb9d9a9..72fcd51a6ed 100644 --- a/src/devices/video/315_5313.h +++ b/src/devices/video/315_5313.h @@ -37,9 +37,9 @@ public: template <typename T> void set_ext_palette(T &&tag) { m_ext_palette.set_tag(std::forward<T>(tag)); } // Temporary solution while 32x VDP mixing and scanline interrupting is moved outside MD VDP - template <typename... T> void set_md_32x_scanline(T &&... args) { m_32x_scanline_func = md_32x_scanline_delegate(std::forward<T>(args)...); } - template <typename... T> void set_md_32x_interrupt(T &&... args) { m_32x_interrupt_func = md_32x_interrupt_delegate(std::forward<T>(args)...); } - template <typename... T> void set_md_32x_scanline_helper(T &&... args) { m_32x_scanline_helper_func = md_32x_scanline_helper_delegate(std::forward<T>(args)...); } + template <typename... T> void set_md_32x_scanline(T &&... args) { m_32x_scanline_func.set(std::forward<T>(args)...); } + template <typename... T> void set_md_32x_interrupt(T &&... args) { m_32x_interrupt_func.set(std::forward<T>(args)...); } + template <typename... T> void set_md_32x_scanline_helper(T &&... args) { m_32x_scanline_helper_func.set(std::forward<T>(args)...); } int m_use_alt_timing; // use MAME scanline timer instead, render only one scanline to a single line buffer, to be rendered by a partial update call.. experimental diff --git a/src/devices/video/cdp1861.cpp b/src/devices/video/cdp1861.cpp index 27f8d0e3729..dfe71100411 100644 --- a/src/devices/video/cdp1861.cpp +++ b/src/devices/video/cdp1861.cpp @@ -99,7 +99,7 @@ void cdp1861_device::device_config_complete() screen().set_raw(clock(), SCREEN_WIDTH, HBLANK_END, HBLANK_START, TOTAL_SCANLINES, SCANLINE_VBLANK_END, SCANLINE_VBLANK_START); if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(cdp1861_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(cdp1861_device::screen_update)); } diff --git a/src/devices/video/clgd542x.cpp b/src/devices/video/clgd542x.cpp index 47b91c8743a..f9bdf1a288a 100644 --- a/src/devices/video/clgd542x.cpp +++ b/src/devices/video/clgd542x.cpp @@ -78,7 +78,7 @@ void cirrus_gd5428_device::device_start() vga.crtc.maximum_scan_line = 1; // copy over interfaces - vga.read_dipswitch = read8_delegate(); //read_dipswitch; + vga.read_dipswitch.set(nullptr); //read_dipswitch; vga.svga_intf.seq_regcount = 0x1f; vga.svga_intf.crtc_regcount = 0x2d; vga.svga_intf.vram_size = 0x200000; diff --git a/src/devices/video/crt9021.cpp b/src/devices/video/crt9021.cpp index a0dabe4d1c3..2ed5680559f 100644 --- a/src/devices/video/crt9021.cpp +++ b/src/devices/video/crt9021.cpp @@ -62,6 +62,7 @@ DEFINE_DEVICE_TYPE(CRT9021, crt9021_device, "crt9021", "SMC CRT9021 VAC") crt9021_device::crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CRT9021, tag, owner, clock), device_video_interface(mconfig, *this), + m_display_cb(*this), m_data(0), m_ms0(0), m_ms1(0), @@ -94,6 +95,8 @@ crt9021_device::crt9021_device(const machine_config &mconfig, const char *tag, d void crt9021_device::device_start() { + m_display_cb.resolve(); + // register bitmap screen().register_screen_bitmap(m_bitmap); diff --git a/src/devices/video/crt9021.h b/src/devices/video/crt9021.h index 65de1032a64..a98c76251b0 100644 --- a/src/devices/video/crt9021.h +++ b/src/devices/video/crt9021.h @@ -53,7 +53,7 @@ public: // construction/destruction crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = draw_character_delegate(std::forward<T>(args)...); } + template <typename... T> void set_display_callback(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } void write(uint8_t data) { m_data = data; } DECLARE_WRITE8_MEMBER( write ) { write(data); } diff --git a/src/devices/video/crt9028.cpp b/src/devices/video/crt9028.cpp index 07f877e3095..94cc2429e13 100644 --- a/src/devices/video/crt9028.cpp +++ b/src/devices/video/crt9028.cpp @@ -132,7 +132,7 @@ void crt9028_device::device_config_complete() } if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(crt9028_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(crt9028_device::screen_update)); } diff --git a/src/devices/video/crtc_ega.cpp b/src/devices/video/crtc_ega.cpp index 7d03b09f131..7b3641423e5 100644 --- a/src/devices/video/crtc_ega.cpp +++ b/src/devices/video/crtc_ega.cpp @@ -23,6 +23,7 @@ DEFINE_DEVICE_TYPE(CRTC_EGA, crtc_ega_device, "crtc_ega", "IBM EGA CRT Controlle crtc_ega_device::crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CRTC_EGA, tag, owner, clock), device_video_interface(mconfig, *this, false) , m_res_out_de_cb(*this), m_res_out_hsync_cb(*this), m_res_out_vsync_cb(*this), m_res_out_vblank_cb(*this) + , m_begin_update_cb(*this), m_row_update_cb(*this), m_end_update_cb(*this) , m_horiz_char_total(0), m_horiz_disp(0), m_horiz_blank_start(0), m_horiz_blank_end(0) , m_ena_vert_access(0), m_de_skew(0) , m_horiz_retr_start(0), m_horiz_retr_end(0), m_horiz_retr_skew(0) @@ -599,9 +600,9 @@ void crtc_ega_device::device_start() m_res_out_vblank_cb.resolve(); /* bind delegates */ - m_begin_update_cb.bind_relative_to(*owner()); - m_row_update_cb.bind_relative_to(*owner()); - m_end_update_cb.bind_relative_to(*owner()); + m_begin_update_cb.resolve(); + m_row_update_cb.resolve(); + m_end_update_cb.resolve(); /* create the timers */ m_line_timer = timer_alloc(TIMER_LINE); diff --git a/src/devices/video/crtc_ega.h b/src/devices/video/crtc_ega.h index 9d03177b494..e5a267bed90 100644 --- a/src/devices/video/crtc_ega.h +++ b/src/devices/video/crtc_ega.h @@ -34,9 +34,9 @@ public: auto res_out_vsync_callback() { return m_res_out_vsync_cb.bind(); } auto res_out_vblank_callback() { return m_res_out_vblank_cb.bind(); } - template <typename... T> void set_begin_update_callback(T &&... args) { m_begin_update_cb = begin_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_row_update_callback(T &&... args) { m_row_update_cb = row_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_end_update_callback(T &&... args) { m_end_update_cb = end_update_delegate(std::forward<T>(args)...); } + template <typename... T> void set_begin_update_callback(T &&... args) { m_begin_update_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_row_update_callback(T &&... args) { m_row_update_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_end_update_callback(T &&... args) { m_end_update_cb.set(std::forward<T>(args)...); } void config_set_hpixels_per_column(int hpixels_per_column) { m_hpixels_per_column = hpixels_per_column; } /* select one of the registers for reading or writing */ diff --git a/src/devices/video/ef9369.cpp b/src/devices/video/ef9369.cpp index fa2e1eb3456..49da6402bf7 100644 --- a/src/devices/video/ef9369.cpp +++ b/src/devices/video/ef9369.cpp @@ -30,6 +30,7 @@ DEFINE_DEVICE_TYPE(EF9369, ef9369_device, "ef9369", "Thomson EF9369 Single Chip ef9369_device::ef9369_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, EF9369, tag, owner, clock) + , m_color_update_cb(*this) , m_address(0) { std::fill(m_ca, m_ca + NUMCOLORS, 0); @@ -45,7 +46,7 @@ ef9369_device::ef9369_device(const machine_config &mconfig, const char *tag, dev void ef9369_device::device_start() { // bind delegate - m_color_update_cb.bind_relative_to(*owner()); + m_color_update_cb.resolve(); // register for save states save_pointer(NAME(m_ca), NUMCOLORS); diff --git a/src/devices/video/ef9369.h b/src/devices/video/ef9369.h index ecea48d6122..1e2a1af6f0d 100644 --- a/src/devices/video/ef9369.h +++ b/src/devices/video/ef9369.h @@ -46,17 +46,7 @@ public: ef9369_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // configuration - template <typename Object> void set_color_update_callback(Object &&cb) { m_color_update_cb = std::forward<Object>(cb); } - void set_color_update_callback(color_update_delegate callback) { m_color_update_cb = callback; } - template <class FunctionClass> void set_color_update_callback(const char *devname, - void (FunctionClass::*callback)(int, bool, uint8_t, uint8_t, uint8_t), const char *name) - { - set_color_update_callback(color_update_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_color_update_callback(void (FunctionClass::*callback)(int, bool, uint8_t, uint8_t, uint8_t), const char *name) - { - set_color_update_callback(color_update_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_color_update_callback(T &&... args) { m_color_update_cb.set(std::forward<T>(args)...); } DECLARE_READ8_MEMBER(data_r); DECLARE_WRITE8_MEMBER(data_w); diff --git a/src/devices/video/epic12.cpp b/src/devices/video/epic12.cpp index f4e9a70d352..49c407cb5d0 100644 --- a/src/devices/video/epic12.cpp +++ b/src/devices/video/epic12.cpp @@ -933,22 +933,22 @@ void epic12_device::install_handlers(int addr1, int addr2) { address_space &space = m_maincpu->space(AS_PROGRAM); - read32_delegate read; - write32_delegate write; + read32_delegate read(*this); + write32_delegate write(*this); if (m_is_unsafe) { printf("using unsafe blit code!\n"); - read = read32_delegate(FUNC(epic12_device::blitter_r_unsafe), this); - write = write32_delegate(FUNC(epic12_device::blitter_w_unsafe), this); + read = read32_delegate(*this, FUNC(epic12_device::blitter_r_unsafe)); + write = write32_delegate(*this, FUNC(epic12_device::blitter_w_unsafe)); } else { - read = read32_delegate(FUNC(epic12_device::blitter_r), this); - write = write32_delegate(FUNC(epic12_device::blitter_w), this); + read = read32_delegate(*this, FUNC(epic12_device::blitter_r)); + write = write32_delegate(*this, FUNC(epic12_device::blitter_w)); } - space.install_readwrite_handler(addr1, addr2, read , write, 0xffffffffffffffffU); + space.install_readwrite_handler(addr1, addr2, std::move(read), std::move(write), 0xffffffffffffffffU); } u64 epic12_device::fpga_r() diff --git a/src/devices/video/fixfreq.cpp b/src/devices/video/fixfreq.cpp index 58eec1722e3..615fe4ce0cf 100644 --- a/src/devices/video/fixfreq.cpp +++ b/src/devices/video/fixfreq.cpp @@ -180,7 +180,7 @@ void fixedfreq_device::device_config_complete() m_monitor.m_vbackporch); if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(fixedfreq_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(fixedfreq_device::screen_update)); } void fixedfreq_device::device_start() diff --git a/src/devices/video/hd44780.cpp b/src/devices/video/hd44780.cpp index 0c64922aa3f..ac19c97ffcc 100644 --- a/src/devices/video/hd44780.cpp +++ b/src/devices/video/hd44780.cpp @@ -55,6 +55,7 @@ hd44780_device::hd44780_device(const machine_config &mconfig, const char *tag, d hd44780_device::hd44780_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) + , m_pixel_update_cb(*this) , m_cgrom(nullptr) , m_cgrom_region(*this, DEVICE_SELF) , m_rs_input(0) @@ -94,7 +95,7 @@ void hd44780_device::device_start() { m_cgrom = m_cgrom_region.found() ? m_cgrom_region : memregion("cgrom")->base(); - m_pixel_update_cb.bind_relative_to(*owner()); + m_pixel_update_cb.resolve(); m_busy_timer = timer_alloc(TIMER_BUSY); m_blink_timer = timer_alloc(TIMER_BLINKING); diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h index c31cd67b426..ec45d0005d1 100644 --- a/src/devices/video/hd44780.h +++ b/src/devices/video/hd44780.h @@ -31,18 +31,7 @@ public: // static configuration helpers void set_lcd_size(int lines, int chars) { m_lines = lines; m_chars = chars; } - template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb = pixel_update_delegate(std::forward<T>(args)...); } - void set_pixel_update_cb(pixel_update_delegate callback) { m_pixel_update_cb = callback; } - template <class FunctionClass> void set_pixel_update_cb(const char *devname, - void (FunctionClass::*callback)(bitmap_ind16 &, u8, u8, u8, u8, int), const char *name) - { - set_pixel_update_cb(pixel_update_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_pixel_update_cb( - void (FunctionClass::*callback)(bitmap_ind16 &, u8, u8, u8, u8, int), const char *name) - { - set_pixel_update_cb(pixel_update_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb.set(std::forward<T>(args)...); } // device interface void write(offs_t offset, u8 data); diff --git a/src/devices/video/hd63484.cpp b/src/devices/video/hd63484.cpp index 873904d3793..1ae83881fbc 100644 --- a/src/devices/video/hd63484.cpp +++ b/src/devices/video/hd63484.cpp @@ -24,10 +24,11 @@ // hd63484_device - constructor //------------------------------------------------- -hd63484_device::hd63484_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, HD63484, tag, owner, clock), +hd63484_device::hd63484_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, HD63484, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), + m_display_cb(*this), m_auto_configure_screen(true), m_external_skew(0), m_ar(0), @@ -2003,7 +2004,7 @@ WRITE8_MEMBER( hd63484_device::data8_w ) void hd63484_device::device_start() { - m_display_cb.bind_relative_to(*owner()); + m_display_cb.resolve(); register_save_state(); } diff --git a/src/devices/video/hd63484.h b/src/devices/video/hd63484.h index 73a321fc117..508579aed73 100644 --- a/src/devices/video/hd63484.h +++ b/src/devices/video/hd63484.h @@ -27,7 +27,7 @@ public: // construction/destruction hd63484_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = display_delegate(std::forward<T>(args)...); } + template <typename... T> void set_display_callback(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } void set_auto_configure_screen(bool auto_configure_screen) { m_auto_configure_screen = auto_configure_screen; } void set_external_skew(int skew) { m_external_skew = skew; } diff --git a/src/devices/video/i82730.cpp b/src/devices/video/i82730.cpp index 5db1bf4e6a9..eeeedd3b4d1 100644 --- a/src/devices/video/i82730.cpp +++ b/src/devices/video/i82730.cpp @@ -58,6 +58,7 @@ i82730_device::i82730_device(const machine_config &mconfig, const char *tag, dev device_t(mconfig, I82730, tag, owner, clock), device_video_interface(mconfig, *this), m_sint_handler(*this), + m_update_row_cb(*this), m_cpu(*this, finder_base::DUMMY_TAG), m_program(nullptr), m_row_timer(nullptr), @@ -101,7 +102,7 @@ void i82730_device::device_start() m_sint_handler.resolve_safe(); // bind delegates - m_update_row_cb.bind_relative_to(*owner()); + m_update_row_cb.resolve(); // allocate row timer m_row_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(i82730_device::row_update), this)); diff --git a/src/devices/video/i82730.h b/src/devices/video/i82730.h index 03165358a22..2efc8c0a523 100644 --- a/src/devices/video/i82730.h +++ b/src/devices/video/i82730.h @@ -40,12 +40,7 @@ public: auto sint() { return m_sint_handler.bind(); } // inline configuration - void set_update_row_callback(update_row_delegate callback) { m_update_row_cb = callback; } - template <class FunctionClass> void set_update_row_callback(void (FunctionClass::*callback)(bitmap_rgb32 &, uint16_t *, uint8_t, uint16_t, int) - , const char *name) - { - set_update_row_callback(update_row_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_update_row_callback(T &&... args) { m_update_row_cb.set(std::forward<T>(args)...); } uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); diff --git a/src/devices/video/i8275.cpp b/src/devices/video/i8275.cpp index 4419d01fad2..ea9a22f498d 100644 --- a/src/devices/video/i8275.cpp +++ b/src/devices/video/i8275.cpp @@ -106,6 +106,7 @@ i8275_device::i8275_device(const machine_config &mconfig, device_type type, cons m_write_hrtc(*this), m_write_vrtc(*this), m_write_lc(*this), + m_display_cb(*this), m_refresh_hack(false), m_status(0), m_param_idx(0), @@ -149,12 +150,12 @@ void i8275_device::device_start() screen().register_screen_bitmap(m_bitmap); // resolve callbacks - m_display_cb.bind_relative_to(*owner()); m_write_drq.resolve_safe(); m_write_irq.resolve_safe(); m_write_hrtc.resolve_safe(); m_write_vrtc.resolve_safe(); m_write_lc.resolve_safe(); + m_display_cb.resolve(); // allocate timers m_hrtc_on_timer = timer_alloc(TIMER_HRTC_ON); diff --git a/src/devices/video/i8275.h b/src/devices/video/i8275.h index 5a9744886c0..b43fcbdefa8 100644 --- a/src/devices/video/i8275.h +++ b/src/devices/video/i8275.h @@ -62,20 +62,7 @@ public: void set_character_width(int value) { m_hpixels_per_column = value; } void set_refresh_hack(bool hack) { m_refresh_hack = hack; } - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = draw_character_delegate(std::forward<T>(args)...); } - void set_display_callback(draw_character_delegate callback) { m_display_cb = callback; } - template <class FunctionClass> void set_display_callback(const char *devname, - void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t), - const char *name) - { - set_display_callback(draw_character_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_display_callback( - void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t), - const char *name) - { - set_display_callback(draw_character_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_display_callback(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } auto drq_wr_callback() { return m_write_drq.bind(); } auto irq_wr_callback() { return m_write_irq.bind(); } diff --git a/src/devices/video/mc6845.cpp b/src/devices/video/mc6845.cpp index 119297553ef..be0adeefc84 100644 --- a/src/devices/video/mc6845.cpp +++ b/src/devices/video/mc6845.cpp @@ -112,6 +112,11 @@ mc6845_device::mc6845_device(const machine_config &mconfig, device_type type, co m_visarea_adjust_min_y(0), m_visarea_adjust_max_y(0), m_hpixels_per_column(0), + m_reconfigure_cb(*this), + m_begin_update_cb(*this), + m_update_row_cb(*this), + m_end_update_cb(*this), + m_on_update_addr_changed_cb(*this), m_out_de_cb(*this), m_out_cur_cb(*this), m_out_hsync_cb(*this), @@ -1135,19 +1140,19 @@ void mc6845_device::device_start() assert(clock() > 0); assert(m_hpixels_per_column > 0); + /* bind delegates */ + m_reconfigure_cb.resolve(); + m_begin_update_cb.resolve(); + m_update_row_cb.resolve(); + m_end_update_cb.resolve(); + m_on_update_addr_changed_cb.resolve(); + /* resolve callbacks */ m_out_de_cb.resolve_safe(); m_out_cur_cb.resolve_safe(); m_out_hsync_cb.resolve_safe(); m_out_vsync_cb.resolve_safe(); - /* bind delegates */ - m_reconfigure_cb.bind_relative_to(*owner()); - m_begin_update_cb.bind_relative_to(*owner()); - m_update_row_cb.bind_relative_to(*owner()); - m_end_update_cb.bind_relative_to(*owner()); - m_on_update_addr_changed_cb.bind_relative_to(*owner()); - /* create the timers */ m_line_timer = timer_alloc(TIMER_LINE); m_de_off_timer = timer_alloc(TIMER_DE_OFF); @@ -1390,7 +1395,7 @@ void mos8563_device::device_start() m_update_ready_bit = 1; // default update_row delegate - m_update_row_cb = update_row_delegate(FUNC(mos8563_device::vdc_update_row), this); + m_update_row_cb.set(*this, FUNC(mos8563_device::vdc_update_row)); m_char_blink_state = false; m_char_blink_count = 0; diff --git a/src/devices/video/mc6845.h b/src/devices/video/mc6845.h index f20b83e5eff..46dfd9b19fb 100644 --- a/src/devices/video/mc6845.h +++ b/src/devices/video/mc6845.h @@ -72,11 +72,11 @@ public: } void set_char_width(int pixels) { m_hpixels_per_column = pixels; } - template <typename... T> void set_reconfigure_callback(T &&... args) { m_reconfigure_cb = reconfigure_delegate(std::forward<T>(args)...); } - template <typename... T> void set_begin_update_callback(T &&... args) { m_begin_update_cb = begin_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_update_row_callback(T &&... args) { m_update_row_cb = update_row_delegate(std::forward<T>(args)...); } - template <typename... T> void set_end_update_callback(T &&... args) { m_end_update_cb = end_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_on_update_addr_change_callback(T &&... args) { m_on_update_addr_changed_cb = on_update_addr_changed_delegate(std::forward<T>(args)...); } + template <typename... T> void set_reconfigure_callback(T &&... args) { m_reconfigure_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_begin_update_callback(T &&... args) { m_begin_update_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_update_row_callback(T &&... args) { m_update_row_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_end_update_callback(T &&... args) { m_end_update_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_on_update_addr_change_callback(T &&... args) { m_on_update_addr_changed_cb.set(std::forward<T>(args)...); } auto out_de_callback() { return m_out_de_cb.bind(); } auto out_cur_callback() { return m_out_cur_cb.bind(); } diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index bc4c8d393ea..e60da56ab2b 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -135,6 +135,7 @@ mc6847_friend_device::mc6847_friend_device(const machine_config &mconfig, device , device_video_interface(mconfig, *this) , m_write_hsync(*this) , m_write_fsync(*this) + , m_charrom_cb(*this) , m_character_map(fontdata, is_mc6847t1) , m_tpfs(tpfs) , m_divider(divider) @@ -599,7 +600,7 @@ void mc6847_base_device::device_config_complete() } if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(mc6847_base_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(mc6847_base_device::screen_update)); } @@ -617,7 +618,7 @@ void mc6847_base_device::device_start() /* resolve callbacks */ m_input_cb.resolve_safe(0); - m_charrom_cb.bind_relative_to(*owner()); + m_charrom_cb.resolve(); /* set up fixed mode */ setup_fixed_mode(); diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index 8402db86c2e..78a8ad57345 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -54,16 +54,7 @@ public: auto hsync_wr_callback() { return m_write_hsync.bind(); } auto fsync_wr_callback() { return m_write_fsync.bind(); } - template <typename Object> void set_get_char_rom(Object &&cb) { m_charrom_cb = std::forward<Object>(cb); } - void set_get_char_rom(get_char_rom_delegate cb) { m_charrom_cb = cb; } - template <class FunctionClass> void set_get_char_rom(const char *devname, uint8_t (FunctionClass::*cb)(uint8_t, int), const char *name) - { - set_get_char_rom(get_char_rom_delegate(cb, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_get_char_rom(uint8_t (FunctionClass::*cb)(uint8_t, int), const char *name) - { - set_get_char_rom(get_char_rom_delegate(cb, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_get_char_rom(T &&... args) { m_charrom_cb.set(std::forward<T>(args)...); } protected: mc6847_friend_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, diff --git a/src/devices/video/nt7534.cpp b/src/devices/video/nt7534.cpp index cacda7a11d9..a4cb9fb33f7 100644 --- a/src/devices/video/nt7534.cpp +++ b/src/devices/video/nt7534.cpp @@ -34,6 +34,7 @@ nt7534_device::nt7534_device(const machine_config &mconfig, const char *tag, dev nt7534_device::nt7534_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) + , m_pixel_update_cb(*this) { } @@ -45,6 +46,8 @@ void nt7534_device::device_start() { m_busy_timer = timer_alloc(TIMER_BUSY); + m_pixel_update_cb.resolve(); + // state saving save_item(NAME(m_busy_flag)); save_item(NAME(m_page)); diff --git a/src/devices/video/nt7534.h b/src/devices/video/nt7534.h index 75390f8acaa..caece0de4d1 100644 --- a/src/devices/video/nt7534.h +++ b/src/devices/video/nt7534.h @@ -29,7 +29,7 @@ public: // construction/destruction nt7534_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb = pixel_update_delegate(std::forward<T>(args)...); } + template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb.set(std::forward<T>(args)...); } // device interface virtual DECLARE_WRITE8_MEMBER(write); diff --git a/src/devices/video/pc_vga.cpp b/src/devices/video/pc_vga.cpp index 7e15f1efe5e..cc30d50bae7 100644 --- a/src/devices/video/pc_vga.cpp +++ b/src/devices/video/pc_vga.cpp @@ -134,6 +134,7 @@ vga_device::vga_device(const machine_config &mconfig, device_type type, const ch : device_t(mconfig, type, tag, owner, clock) , device_video_interface(mconfig, *this) , device_palette_interface(mconfig, *this) + , vga(*this) { } @@ -252,7 +253,7 @@ void vga_device::device_start() // copy over interfaces - vga.read_dipswitch = read8_delegate(); //read_dipswitch; + vga.read_dipswitch.set(nullptr); //read_dipswitch; vga.svga_intf.seq_regcount = 0x05; vga.svga_intf.crtc_regcount = 0x19; vga.svga_intf.vram_size = 0x100000; diff --git a/src/devices/video/pc_vga.h b/src/devices/video/pc_vga.h index 07823707606..22d8ba33a65 100644 --- a/src/devices/video/pc_vga.h +++ b/src/devices/video/pc_vga.h @@ -110,8 +110,10 @@ protected: } - struct + struct vga_t { + vga_t(device_t &owner) : read_dipswitch(owner) { } + read8_delegate read_dipswitch; struct { diff --git a/src/devices/video/pcd8544.cpp b/src/devices/video/pcd8544.cpp index 0cca6742b05..b0592592509 100644 --- a/src/devices/video/pcd8544.cpp +++ b/src/devices/video/pcd8544.cpp @@ -31,7 +31,8 @@ DEFINE_DEVICE_TYPE(PCD8544, pcd8544_device, "pcd8544_device", "Philips PCD8544 L //------------------------------------------------- pcd8544_device::pcd8544_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, PCD8544, tag, owner, clock) + device_t(mconfig, PCD8544, tag, owner, clock), + m_screen_update_cb(*this) { } @@ -41,7 +42,7 @@ pcd8544_device::pcd8544_device(const machine_config &mconfig, const char *tag, d void pcd8544_device::device_start() { - m_screen_update_cb.bind_relative_to(*owner()); + m_screen_update_cb.resolve(); // state saving save_item(NAME(m_sdin)); diff --git a/src/devices/video/pcd8544.h b/src/devices/video/pcd8544.h index 069984e9483..6706097a4db 100644 --- a/src/devices/video/pcd8544.h +++ b/src/devices/video/pcd8544.h @@ -28,7 +28,7 @@ public: // construction/destruction pcd8544_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_screen_update_cb(T &&... args) { m_screen_update_cb = screen_update_delegate(std::forward<T>(args)...); } + template <typename... T> void set_screen_update_cb(T &&... args) { m_screen_update_cb.set(std::forward<T>(args)...); } // device interface DECLARE_WRITE_LINE_MEMBER(sdin_w); diff --git a/src/devices/video/ppu2c0x.cpp b/src/devices/video/ppu2c0x.cpp index f0b20856c57..4f2c6c587e7 100644 --- a/src/devices/video/ppu2c0x.cpp +++ b/src/devices/video/ppu2c0x.cpp @@ -117,10 +117,10 @@ device_memory_interface::space_config_vector ppu2c0x_device::memory_space_config void ppu2c0x_device::device_config_complete() { /* reset the callbacks */ - m_latch = latch_delegate(); - m_scanline_callback_proc = scanline_delegate(); - m_hblank_callback_proc = hblank_delegate(); - m_vidaccess_callback_proc = vidaccess_delegate(); + m_scanline_callback_proc.set(nullptr); + m_hblank_callback_proc.set(nullptr); + m_vidaccess_callback_proc.set(nullptr); + m_latch.set(nullptr); } ppu2c0x_device::ppu2c0x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) @@ -131,6 +131,9 @@ ppu2c0x_device::ppu2c0x_device(const machine_config &mconfig, device_type type, , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(FUNC(ppu2c0x_device::ppu2c0x), this)) , m_cpu(*this, finder_base::DUMMY_TAG) , m_scanline(0) // reset the scanline count + , m_scanline_callback_proc(*this) + , m_hblank_callback_proc(*this) + , m_vidaccess_callback_proc(*this) , m_int_callback(*this) , m_refresh_data(0) , m_refresh_latch(0) @@ -146,6 +149,7 @@ ppu2c0x_device::ppu2c0x_device(const machine_config &mconfig, device_type type, , m_scan_scale(1) // set the scan scale (this is for dual monitor vertical setups) , m_tilecount(0) , m_draw_phase(0) + , m_latch(*this) , m_use_sprite_write_limitation(true) { for (auto & elem : m_regs) diff --git a/src/devices/video/ppu2c0x.h b/src/devices/video/ppu2c0x.h index 78ebef0b2ce..5660876674a 100644 --- a/src/devices/video/ppu2c0x.h +++ b/src/devices/video/ppu2c0x.h @@ -96,10 +96,10 @@ public: uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); int get_current_scanline() { return m_scanline; } - void set_scanline_callback( scanline_delegate &&cb ) { m_scanline_callback_proc = std::move(cb); m_scanline_callback_proc.bind_relative_to(*owner()); } - void set_hblank_callback( hblank_delegate &&cb ) { m_hblank_callback_proc = std::move(cb); m_hblank_callback_proc.bind_relative_to(*owner()); } - void set_vidaccess_callback( vidaccess_delegate &&cb ) { m_vidaccess_callback_proc = std::move(cb); m_vidaccess_callback_proc.bind_relative_to(*owner()); } - void set_scanlines_per_frame( int scanlines ) { m_scanlines_per_frame = scanlines; } + template <typename... T> void set_scanline_callback(T &&... args) { m_scanline_callback_proc.set(std::forward<T>(args)...); m_scanline_callback_proc.resolve(); /* FIXME: if this is supposed to be set at config time, it should be resolved on start */ } + template <typename... T> void set_hblank_callback(T &&... args) { m_hblank_callback_proc.set(std::forward<T>(args)...); m_hblank_callback_proc.resolve(); /* FIXME: if this is supposed to be set at config time, it should be resolved on start */ } + template <typename... T> void set_vidaccess_callback(T &&... args) { m_vidaccess_callback_proc.set(std::forward<T>(args)...); m_vidaccess_callback_proc.resolve(); /* FIXME: if this is supposed to be set at config time, it should be resolved on start */ } + void set_scanlines_per_frame(int scanlines) { m_scanlines_per_frame = scanlines; } // MMC5 has to be able to check this int is_sprite_8x16() { return m_regs[PPU_CONTROL0] & PPU_CONTROL0_SPRITE_SIZE; } @@ -107,7 +107,7 @@ public: int get_tilenum() { return m_tilecount; } //27/12/2002 (HACK!) - void set_latch( latch_delegate &&cb ) { m_latch = std::move(cb); m_latch.bind_relative_to(*owner()); } + template <typename... T> void set_latch(T &&... args) { m_latch.set(std::forward<T>(args)...); m_latch.resolve(); /* FIXME: if this is supposed to be set at config time, it should be resolved on start */ } // void update_screen(bitmap_t &bitmap, const rectangle &cliprect); diff --git a/src/devices/video/psx.cpp b/src/devices/video/psx.cpp index 471bfc5b50b..6a689edf14f 100644 --- a/src/devices/video/psx.cpp +++ b/src/devices/video/psx.cpp @@ -3542,5 +3542,5 @@ void psxgpu_device::device_config_complete() } if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(psxgpu_device::update_screen), this)); + screen().set_screen_update(*this, FUNC(psxgpu_device::update_screen)); } diff --git a/src/devices/video/scn2674.cpp b/src/devices/video/scn2674.cpp index 1e6cf3d68b5..cc8121a923f 100644 --- a/src/devices/video/scn2674.cpp +++ b/src/devices/video/scn2674.cpp @@ -86,6 +86,7 @@ scn2674_device::scn2674_device(const machine_config &mconfig, device_type type, , m_dbl1(0) , m_char_buffer(0), m_attr_buffer(0) , m_linecounter(0), m_address(0), m_start1change(0) + , m_display_cb(*this) , m_scanline_timer(nullptr) , m_breq_timer(nullptr) , m_vblank_timer(nullptr) @@ -97,18 +98,15 @@ scn2674_device::scn2674_device(const machine_config &mconfig, device_type type, device_memory_interface::space_config_vector scn2674_device::memory_space_config() const { - return has_configured_map(1) ? space_config_vector { - std::make_pair(0, &m_char_space_config), - std::make_pair(1, &m_attr_space_config) - } : space_config_vector { - std::make_pair(0, &m_char_space_config) - }; + return has_configured_map(1) + ? space_config_vector{ std::make_pair(0, &m_char_space_config), std::make_pair(1, &m_attr_space_config) } + : space_config_vector{ std::make_pair(0, &m_char_space_config) }; } void scn2674_device::device_start() { // resolve callbacks - m_display_cb.bind_relative_to(*owner()); + m_display_cb.resolve(); m_intr_cb.resolve_safe(); m_breq_cb.resolve_safe(); m_mbc_cb.resolve_safe(); diff --git a/src/devices/video/scn2674.h b/src/devices/video/scn2674.h index 2b7367eeed0..f3bd19b406a 100644 --- a/src/devices/video/scn2674.h +++ b/src/devices/video/scn2674.h @@ -16,8 +16,6 @@ class scn2674_device : public device_t, public device_memory_interface { public: - scn2674_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - typedef device_delegate<void (bitmap_rgb32 &bitmap, int x, int y, uint8_t linecount, uint8_t charcode, uint8_t attrcode, uint16_t address, bool cursor, bool dw, bool lg, bool ul, bool blink)> draw_character_delegate; // static configuration @@ -28,20 +26,9 @@ public: auto mbc_attr_callback() { return m_mbc_attr_cb.bind(); } void set_character_width(int value) { m_hpixels_per_column = value; } - template <class FunctionClass> - void set_display_callback(void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, uint8_t, uint16_t, bool, bool, bool, bool, bool), const char *name) - { - set_display_callback(draw_character_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> - void set_display_callback(const char *devname, void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, uint8_t, uint16_t, bool, bool, bool, bool, bool), const char *name) - { - set_display_callback(draw_character_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - void set_display_callback(draw_character_delegate callback) - { - m_display_cb = callback; - } + template <typename... T> void set_display_callback(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } + + scn2674_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); uint8_t read(offs_t offset); void write(offs_t offset, uint8_t data); diff --git a/src/devices/video/sed1520.cpp b/src/devices/video/sed1520.cpp index feca2ed10fd..8573725835f 100644 --- a/src/devices/video/sed1520.cpp +++ b/src/devices/video/sed1520.cpp @@ -33,7 +33,7 @@ DEFINE_DEVICE_TYPE(SED1520, sed1520_device, "sed1520", "Epson SED1520") sed1520_device::sed1520_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, SED1520, tag, owner, clock), m_lcd_on(0), m_busy(0), m_page(0), m_column(0), m_old_column(0), m_start_line(0), m_adc(0), m_static_drive(0), m_modify_write(false), - m_screen_update_cb() + m_screen_update_cb(*this) { } @@ -44,7 +44,7 @@ sed1520_device::sed1520_device(const machine_config &mconfig, const char *tag, d void sed1520_device::device_start() { - m_screen_update_cb.bind_relative_to(*owner()); + m_screen_update_cb.resolve(); // state saving save_item(NAME(m_lcd_on)); diff --git a/src/devices/video/sed1520.h b/src/devices/video/sed1520.h index 9ca1358713e..2857b978d10 100644 --- a/src/devices/video/sed1520.h +++ b/src/devices/video/sed1520.h @@ -33,17 +33,7 @@ public: sed1520_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // sconfiguration helpers - void set_screen_update_cb(screen_update_delegate callback) { m_screen_update_cb = callback; } - template <class FunctionClass> void set_screen_update_cb(const char *devname, - uint32_t (FunctionClass::*callback)(bitmap_ind16 &, const rectangle &, uint8_t *, int, int), const char *name) - { - set_screen_update_cb(screen_update_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_screen_update_cb( - uint32_t (FunctionClass::*callback)(bitmap_ind16 &, const rectangle &, uint8_t *, int, int), const char *name) - { - set_screen_update_cb(screen_update_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_screen_update_cb(T &&... args) { m_screen_update_cb.set(std::forward<T>(args)...); } // device interface virtual DECLARE_WRITE8_MEMBER(write); diff --git a/src/devices/video/tms9928a.cpp b/src/devices/video/tms9928a.cpp index c068d8b4ce8..129b364e860 100644 --- a/src/devices/video/tms9928a.cpp +++ b/src/devices/video/tms9928a.cpp @@ -78,7 +78,7 @@ void tms9928a_device::device_config_complete() return; if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(tms9928a_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(tms9928a_device::screen_update)); if (!screen().refresh_attoseconds()) { diff --git a/src/devices/video/tms9928a.h b/src/devices/video/tms9928a.h index 72c466d464b..cc5a5192f14 100644 --- a/src/devices/video/tms9928a.h +++ b/src/devices/video/tms9928a.h @@ -82,7 +82,7 @@ public: void register_write(u8 data); /* update the screen */ - uint32_t screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect ); + uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); bitmap_rgb32 &get_bitmap() { return m_tmpbmp; } /* RESET pin */ diff --git a/src/devices/video/upd3301.cpp b/src/devices/video/upd3301.cpp index 07b8a32c99b..166f623dc30 100644 --- a/src/devices/video/upd3301.cpp +++ b/src/devices/video/upd3301.cpp @@ -84,6 +84,7 @@ upd3301_device::upd3301_device(const machine_config &mconfig, const char *tag, d m_write_drq(*this), m_write_hrtc(*this), m_write_vrtc(*this), + m_display_cb(*this), m_width(0), m_status(0), m_param_count(0), @@ -115,11 +116,11 @@ void upd3301_device::device_start() { screen().register_screen_bitmap(m_bitmap); // resolve callbacks - m_display_cb.bind_relative_to(*owner()); m_write_drq.resolve_safe(); m_write_int.resolve_safe(); m_write_hrtc.resolve_safe(); m_write_vrtc.resolve_safe(); + m_display_cb.resolve(); // allocate timers m_hrtc_timer = timer_alloc(TIMER_HRTC); diff --git a/src/devices/video/upd3301.h b/src/devices/video/upd3301.h index 147c12c5b7d..293aaa91613 100644 --- a/src/devices/video/upd3301.h +++ b/src/devices/video/upd3301.h @@ -60,18 +60,7 @@ public: upd3301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); void set_character_width(int value) { m_width = value; } - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = draw_character_delegate(std::forward<T>(args)...); } - void set_display_callback(draw_character_delegate callback) { m_display_cb = callback; } - template <class FunctionClass> void set_display_callback(const char *devname, - void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, int, int, int, int, int, int, int), const char *name) - { - set_display_callback(draw_character_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_display_callback( - void (FunctionClass::*callback)(bitmap_rgb32 &, int, int, uint8_t, uint8_t, int, int, int, int, int, int, int), const char *name) - { - set_display_callback(draw_character_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } + template <typename... T> void set_display_callback(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } auto drq_wr_callback() { return m_write_drq.bind(); } auto int_wr_callback() { return m_write_int.bind(); } diff --git a/src/devices/video/upd7220.cpp b/src/devices/video/upd7220.cpp index 50e1cc9bd1c..235a1a99cf6 100644 --- a/src/devices/video/upd7220.cpp +++ b/src/devices/video/upd7220.cpp @@ -615,6 +615,8 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d device_t(mconfig, UPD7220, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), + m_display_cb(*this), + m_draw_text_cb(*this), m_write_drq(*this), m_write_hsync(*this), m_write_vsync(*this), @@ -676,8 +678,8 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d void upd7220_device::device_start() { // resolve callbacks - m_display_cb.bind_relative_to(*owner()); - m_draw_text_cb.bind_relative_to(*owner()); + m_display_cb.resolve(); + m_draw_text_cb.resolve(); m_write_drq.resolve_safe(); m_write_hsync.resolve_safe(); diff --git a/src/devices/video/upd7220.h b/src/devices/video/upd7220.h index 7c7370c0cd9..d1f8806c6ac 100644 --- a/src/devices/video/upd7220.h +++ b/src/devices/video/upd7220.h @@ -56,53 +56,14 @@ class upd7220_device : public device_t, public device_video_interface { public: - typedef device_delegate<void (bitmap_rgb32 &bitmap, int y, int x, uint32_t address)> display_pixels_delegate; - typedef device_delegate<void (bitmap_rgb32 &bitmap, uint32_t addr, int y, int wd, int pitch, int lr, int cursor_on, int cursor_addr)> draw_text_delegate; + using display_pixels_delegate = device_delegate<void (bitmap_rgb32 &bitmap, int y, int x, uint32_t address)>; + using draw_text_delegate = device_delegate<void (bitmap_rgb32 &bitmap, uint32_t addr, int y, int wd, int pitch, int lr, int cursor_on, int cursor_addr)>; // construction/destruction upd7220_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // FIXME: these should be aware of current device for resolving the tag - template <class FunctionClass> - void set_display_pixels(void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t), const char *name) - { - m_display_cb = display_pixels_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t) const, const char *name) - { - m_display_cb = display_pixels_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t), const char *name) - { - m_display_cb = display_pixels_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t) const, const char *name) - { - m_display_cb = display_pixels_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int), const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int) const, const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int), const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int) const, const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } + template <typename... T> void set_display_pixels(T &&... args) { m_display_cb.set(std::forward<T>(args)...); } + template <typename... T> void set_draw_text(T &&... args) { m_draw_text_cb.set(std::forward<T>(args)...); } auto drq_wr_callback() { return m_write_drq.bind(); } auto hsync_wr_callback() { return m_write_hsync.bind(); } diff --git a/src/devices/video/v9938.cpp b/src/devices/video/v9938.cpp index 97c584fddc6..4549dae9e6e 100644 --- a/src/devices/video/v9938.cpp +++ b/src/devices/video/v9938.cpp @@ -169,7 +169,7 @@ void v99x8_device::device_config_complete() (m_pal_config ? VVISIBLE_PAL : VVISIBLE_NTSC) * 2 - 1 - VERTICAL_ADJUST * 2); if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(v99x8_device::screen_update), this)); + screen().set_screen_update(*this, FUNC(v99x8_device::screen_update)); } diff --git a/src/devices/video/virge_pci.cpp b/src/devices/video/virge_pci.cpp index bc5755d3550..c3d55f4cc62 100644 --- a/src/devices/video/virge_pci.cpp +++ b/src/devices/video/virge_pci.cpp @@ -251,11 +251,11 @@ void virgedx_pci_device::device_start() void virge_pci_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space, uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) { - memory_space->install_readwrite_handler(0xa0000, 0xbffff, read8_delegate(FUNC(virge_pci_device::vram_r),this), write8_delegate(FUNC(virge_pci_device::vram_w),this)); + memory_space->install_readwrite_handler(0xa0000, 0xbffff, read8_delegate(*this, FUNC(virge_pci_device::vram_r)), write8_delegate(*this, FUNC(virge_pci_device::vram_w))); - io_space->install_readwrite_handler(0x3b0, 0x3bf, read32_delegate(FUNC(virge_pci_device::vga_3b0_r), this), write32_delegate(FUNC(virge_pci_device::vga_3b0_w), this)); - io_space->install_readwrite_handler(0x3c0, 0x3cf, read32_delegate(FUNC(virge_pci_device::vga_3c0_r), this), write32_delegate(FUNC(virge_pci_device::vga_3c0_w), this)); - io_space->install_readwrite_handler(0x3d0, 0x3df, read32_delegate(FUNC(virge_pci_device::vga_3d0_r), this), write32_delegate(FUNC(virge_pci_device::vga_3d0_w), this)); + io_space->install_readwrite_handler(0x3b0, 0x3bf, read32_delegate(*this, FUNC(virge_pci_device::vga_3b0_r)), write32_delegate(*this, FUNC(virge_pci_device::vga_3b0_w))); + io_space->install_readwrite_handler(0x3c0, 0x3cf, read32_delegate(*this, FUNC(virge_pci_device::vga_3c0_r)), write32_delegate(*this, FUNC(virge_pci_device::vga_3c0_w))); + io_space->install_readwrite_handler(0x3d0, 0x3df, read32_delegate(*this, FUNC(virge_pci_device::vga_3d0_r)), write32_delegate(*this, FUNC(virge_pci_device::vga_3d0_w))); } void virge_pci_device::device_add_mconfig(machine_config &config) diff --git a/src/devices/video/voodoo_pci.cpp b/src/devices/video/voodoo_pci.cpp index 191eaec4bf3..494bd32a5dd 100644 --- a/src/devices/video/voodoo_pci.cpp +++ b/src/devices/video/voodoo_pci.cpp @@ -178,7 +178,7 @@ void voodoo_banshee_pci_device::map_extra(uint64_t memory_window_start, uint64_t // Should really be dependent on voodoo VGAINIT0 bit 8 and IO base + 0xc3 bit 0 uint64_t start = io_offset + 0x3b0; uint64_t end = io_offset + 0x3df; - io_space->install_readwrite_handler(start, end, read32_delegate(FUNC(voodoo_pci_device::vga_r), this), write32_delegate(FUNC(voodoo_pci_device::vga_w), this)); + io_space->install_readwrite_handler(start, end, read32_delegate(*this, FUNC(voodoo_pci_device::vga_r)), write32_delegate(*this, FUNC(voodoo_pci_device::vga_w))); logerror("%s: map %s at %0*x-%0*x\n", this->tag(), "vga_r/w", 4, uint32_t(start), 4, uint32_t(end)); } @@ -191,7 +191,7 @@ void voodoo_3_pci_device::map_extra(uint64_t memory_window_start, uint64_t memor // Should really be dependent on voodoo VGAINIT0 bit 8 and IO base + 0xc3 bit 0 uint64_t start = io_offset + 0x3b0; uint64_t end = io_offset + 0x3df; - io_space->install_readwrite_handler(start, end, read32_delegate(FUNC(voodoo_pci_device::vga_r), this), write32_delegate(FUNC(voodoo_pci_device::vga_w), this)); + io_space->install_readwrite_handler(start, end, read32_delegate(*this, FUNC(voodoo_pci_device::vga_r)), write32_delegate(*this, FUNC(voodoo_pci_device::vga_w))); logerror("%s: map %s at %0*x-%0*x\n", this->tag(), "vga_r/w", 4, uint32_t(start), 4, uint32_t(end)); } |