From 08f871c71ce5beb6e13d375bab9bc82f32559f8d Mon Sep 17 00:00:00 2001 From: Sandro Ronco Date: Tue, 1 Apr 2014 19:37:34 +0000 Subject: [PATCH] converted h63484 to use delegates. (nw) --- src/emu/video/h63484.c | 33 +++++---------------------------- src/emu/video/h63484.h | 27 +++++++++++++-------------- src/mame/drivers/adp.c | 22 ++++++++++------------ 3 files changed, 28 insertions(+), 54 deletions(-) diff --git a/src/emu/video/h63484.c b/src/emu/video/h63484.c index 87631a77a11..a98e9a5f039 100644 --- a/src/emu/video/h63484.c +++ b/src/emu/video/h63484.c @@ -382,26 +382,6 @@ inline void h63484_device::writeword(offs_t address, UINT16 data) } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void h63484_device::device_config_complete() -{ - // inherit a copy of the static data - const h63484_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - // ... - } -} - inline void h63484_device::fifo_w_clear() { int i; @@ -1974,7 +1954,7 @@ WRITE16_MEMBER( h63484_device::data_w ) void h63484_device::device_start() { - //h63484->space = device->memory().space(AS_0); + m_display_cb.bind_relative_to(*owner()); } //------------------------------------------------- @@ -2062,13 +2042,10 @@ void h63484_device::draw_graphics_line(bitmap_ind16 &bitmap, const rectangle &cl for (int b=0; b>= bpp; } diff --git a/src/emu/video/h63484.h b/src/emu/video/h63484.h index e9d07f1490f..be9acbe5a4d 100644 --- a/src/emu/video/h63484.h +++ b/src/emu/video/h63484.h @@ -14,39 +14,38 @@ #include "emu.h" +typedef device_delegate h63484_display_delegate; + + /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_H63484_ADD(_tag, _clock, _config, _map) \ +#define MCFG_H63484_ADD(_tag, _clock, _map) \ MCFG_DEVICE_ADD(_tag, H63484, _clock) \ - MCFG_DEVICE_CONFIG(_config) \ MCFG_DEVICE_ADDRESS_MAP(AS_0, _map) -#define H63484_INTERFACE(name) \ - const h63484_interface (name) = +#define MCFG_H63484_ADDRESS_MAP(_map) \ + MCFG_DEVICE_ADDRESS_MAP(AS_0, _map) -typedef void (*h63484_display_pixels_func)(device_t *device, bitmap_ind16 &bitmap, int y, int x, UINT16 data); -#define H63484_DISPLAY_PIXELS(name) void name(device_t *device, bitmap_ind16 &bitmap, int y, int x, UINT16 data) +#define MCFG_H63484_DISPLAY_CALLBACK_OWNER(_class, _method) \ + h63484_device::static_set_display_callback(*device, h63484_display_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); -// ======================> h63484_interface +#define H63484_DISPLAY_PIXELS_MEMBER(_name) void _name(bitmap_ind16 &bitmap, const rectangle &cliprect, int y, int x, UINT16 data) -struct h63484_interface -{ - h63484_display_pixels_func m_display_cb; -}; // ======================> h63484_device class h63484_device : public device_t, public device_memory_interface, - public device_video_interface, - public h63484_interface + public device_video_interface { public: // construction/destruction h63484_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + static void static_set_display_callback(device_t &device, h63484_display_delegate callback) { downcast(device).m_display_cb = callback; } + DECLARE_WRITE16_MEMBER( address_w ); DECLARE_WRITE16_MEMBER( data_w ); @@ -62,7 +61,6 @@ protected: virtual void device_start(); virtual void device_reset(); //virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual void device_config_complete(); inline UINT16 readword(offs_t address); inline void writeword(offs_t address, UINT16 data); @@ -105,6 +103,7 @@ private: int translate_command(UINT16 data); void draw_graphics_line(bitmap_ind16 &bitmap, const rectangle &cliprect, int vs, int y, int layer_n, bool active, bool ins_window); + h63484_display_delegate m_display_cb; UINT8 m_ar; UINT8 m_vreg[0x100]; diff --git a/src/mame/drivers/adp.c b/src/mame/drivers/adp.c index 4a6d2fad32c..63962608837 100644 --- a/src/mame/drivers/adp.c +++ b/src/mame/drivers/adp.c @@ -196,13 +196,15 @@ public: DECLARE_PALETTE_INIT(adp); DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); UINT32 screen_update_adp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + H63484_DISPLAY_PIXELS_MEMBER( acrtc_display_pixels ); //INTERRUPT_GEN_MEMBER(adp_int); }; -static H63484_DISPLAY_PIXELS( acrtc_display_pixels ) +H63484_DISPLAY_PIXELS_MEMBER( adp_state::acrtc_display_pixels ) { - bitmap.pix16(y, x) = data & 0xf; + if (cliprect.contains(x, y)) + bitmap.pix16(y, x) = data; } UINT32 adp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) @@ -645,11 +647,6 @@ static ADDRESS_MAP_START( fstation_h63484_map, AS_0, 16, adp_state ) AM_RANGE(0x80000, 0xfffff) AM_RAM ADDRESS_MAP_END -static H63484_INTERFACE( adp_h63484_intf ) -{ - acrtc_display_pixels -}; - static MACHINE_CONFIG_START( quickjac, adp_state ) MCFG_CPU_ADD("maincpu", M68000, 8000000) @@ -678,7 +675,8 @@ static MACHINE_CONFIG_START( quickjac, adp_state ) MCFG_PALETTE_INIT_OWNER(adp_state,adp) - MCFG_H63484_ADD("h63484", 0, adp_h63484_intf, adp_h63484_map) + MCFG_H63484_ADD("h63484", 0, adp_h63484_map) + MCFG_H63484_DISPLAY_CALLBACK_OWNER(adp_state, acrtc_display_pixels) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("aysnd", AY8910, 3686400/2) @@ -702,8 +700,8 @@ static MACHINE_CONFIG_DERIVED( backgamn, skattv ) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( fashiong, skattv ) - MCFG_DEVICE_REMOVE("h63484") - MCFG_H63484_ADD("h63484", 0, adp_h63484_intf, fashiong_h63484_map) + MCFG_DEVICE_MODIFY("h63484") + MCFG_H63484_ADDRESS_MAP(fashiong_h63484_map) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( funland, quickjac ) @@ -713,8 +711,8 @@ static MACHINE_CONFIG_DERIVED( funland, quickjac ) MCFG_DEVICE_REMOVE("palette") MCFG_PALETTE_ADD_INIT_BLACK("palette", 0x100) - MCFG_DEVICE_REMOVE("h63484") - MCFG_H63484_ADD("h63484", 0, adp_h63484_intf, fstation_h63484_map) + MCFG_DEVICE_MODIFY("h63484") + MCFG_H63484_ADDRESS_MAP(fstation_h63484_map) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( fstation, funland )