diff --git a/src/mame/drivers/battlnts.c b/src/mame/drivers/battlnts.c index 8d7f7573b87..2471e476371 100644 --- a/src/mame/drivers/battlnts.c +++ b/src/mame/drivers/battlnts.c @@ -208,12 +208,6 @@ GFXDECODE_END * *************************************/ -static const k007420_interface bladestl_k007420_intf = -{ - 0x3ff, battlnts_sprite_callback /* banklimit, callback */ -}; - - void battlnts_state::machine_start() { UINT8 *ROM = memregion("maincpu")->base(); @@ -260,7 +254,9 @@ static MACHINE_CONFIG_START( battlnts, battlnts_state ) MCFG_K007342_CALLBACK_OWNER(battlnts_state, battlnts_tile_callback) MCFG_K007342_GFXDECODE("gfxdecode") - MCFG_K007420_ADD("k007420", bladestl_k007420_intf) + MCFG_K007420_ADD("k007420") + MCFG_K007420_BANK_LIMIT(0x3ff) + MCFG_K007420_CALLBACK_OWNER(battlnts_state, battlnts_sprite_callback) MCFG_K007420_PALETTE("palette") /* sound hardware */ diff --git a/src/mame/drivers/bladestl.c b/src/mame/drivers/bladestl.c index d5315438fbc..a9f5ad84c77 100644 --- a/src/mame/drivers/bladestl.c +++ b/src/mame/drivers/bladestl.c @@ -280,12 +280,6 @@ static const ay8910_interface ay8910_config = }; -static const k007420_interface bladestl_k007420_intf = -{ - 0x3ff, bladestl_sprite_callback /* banklimit, callback */ -}; - - void bladestl_state::machine_start() { UINT8 *ROM = memregion("maincpu")->base(); @@ -341,8 +335,11 @@ static MACHINE_CONFIG_START( bladestl, bladestl_state ) MCFG_K007342_CALLBACK_OWNER(bladestl_state, bladestl_tile_callback) MCFG_K007342_GFXDECODE("gfxdecode") - MCFG_K007420_ADD("k007420", bladestl_k007420_intf) + MCFG_K007420_ADD("k007420") + MCFG_K007420_BANK_LIMIT(0x3ff) + MCFG_K007420_CALLBACK_OWNER(bladestl_state, bladestl_sprite_callback) MCFG_K007420_PALETTE("palette") + MCFG_K051733_ADD("k051733") /* sound hardware */ diff --git a/src/mame/drivers/rockrage.c b/src/mame/drivers/rockrage.c index 0af02657c7a..65da640ac6f 100644 --- a/src/mame/drivers/rockrage.c +++ b/src/mame/drivers/rockrage.c @@ -220,12 +220,6 @@ GFXDECODE_END ***************************************************************************/ -static const k007420_interface rockrage_k007420_intf = -{ - 0x3ff, rockrage_sprite_callback -}; - - void rockrage_state::machine_start() { UINT8 *ROM = memregion("maincpu")->base(); @@ -268,7 +262,9 @@ static MACHINE_CONFIG_START( rockrage, rockrage_state ) MCFG_K007342_CALLBACK_OWNER(rockrage_state, rockrage_tile_callback) MCFG_K007342_GFXDECODE("gfxdecode") - MCFG_K007420_ADD("k007420", rockrage_k007420_intf) + MCFG_K007420_ADD("k007420") + MCFG_K007420_BANK_LIMIT(0x3ff) + MCFG_K007420_CALLBACK_OWNER(rockrage_state, rockrage_sprite_callback) MCFG_K007420_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", rockrage) diff --git a/src/mame/includes/battlnts.h b/src/mame/includes/battlnts.h index ff5fc207b52..8808c2c0ff4 100644 --- a/src/mame/includes/battlnts.h +++ b/src/mame/includes/battlnts.h @@ -41,7 +41,5 @@ public: required_device m_maincpu; required_device m_gfxdecode; K007342_CALLBACK_MEMBER(battlnts_tile_callback); + K007420_CALLBACK_MEMBER(battlnts_sprite_callback); }; - -/*----------- defined in video/battlnts.c -----------*/ -void battlnts_sprite_callback(running_machine &machine, int *code, int *color); diff --git a/src/mame/includes/bladestl.h b/src/mame/includes/bladestl.h index 3c4abf9e91f..33e05dc6053 100644 --- a/src/mame/includes/bladestl.h +++ b/src/mame/includes/bladestl.h @@ -53,7 +53,6 @@ public: required_device m_palette; void set_pens(); K007342_CALLBACK_MEMBER(bladestl_tile_callback); + K007420_CALLBACK_MEMBER(bladestl_sprite_callback); }; -/*----------- defined in video/bladestl.c -----------*/ -void bladestl_sprite_callback(running_machine &machine, int *code, int *color); diff --git a/src/mame/includes/rockrage.h b/src/mame/includes/rockrage.h index 8dd4c70ae83..35a52946d8e 100644 --- a/src/mame/includes/rockrage.h +++ b/src/mame/includes/rockrage.h @@ -50,6 +50,7 @@ public: INTERRUPT_GEN_MEMBER(rockrage_interrupt); void set_pens(); K007342_CALLBACK_MEMBER(rockrage_tile_callback); + K007420_CALLBACK_MEMBER(rockrage_sprite_callback); + }; -void rockrage_sprite_callback(running_machine &machine, int *code, int *color); diff --git a/src/mame/video/battlnts.c b/src/mame/video/battlnts.c index 1428668b852..605cfa8d263 100644 --- a/src/mame/video/battlnts.c +++ b/src/mame/video/battlnts.c @@ -19,11 +19,9 @@ K007342_CALLBACK_MEMBER(battlnts_state::battlnts_tile_callback) ***************************************************************************/ -void battlnts_sprite_callback(running_machine &machine, int *code,int *color) +K007420_CALLBACK_MEMBER(battlnts_state::battlnts_sprite_callback) { - battlnts_state *state = machine.driver_data(); - - *code |= ((*color & 0xc0) << 2) | state->m_spritebank; + *code |= ((*color & 0xc0) << 2) | m_spritebank; *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0; } diff --git a/src/mame/video/bladestl.c b/src/mame/video/bladestl.c index 6ee93a704ca..dcae9f20f41 100644 --- a/src/mame/video/bladestl.c +++ b/src/mame/video/bladestl.c @@ -54,11 +54,9 @@ K007342_CALLBACK_MEMBER(bladestl_state::bladestl_tile_callback) ***************************************************************************/ -void bladestl_sprite_callback( running_machine &machine, int *code,int *color ) +K007420_CALLBACK_MEMBER(bladestl_state::bladestl_sprite_callback) { - bladestl_state *state = machine.driver_data(); - - *code |= ((*color & 0xc0) << 2) + state->m_spritebank; + *code |= ((*color & 0xc0) << 2) + m_spritebank; *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0 + (*color & 0x0f); } diff --git a/src/mame/video/k007342.c b/src/mame/video/k007342.c index 1b6b816a00f..101f81c8f0e 100644 --- a/src/mame/video/k007342.c +++ b/src/mame/video/k007342.c @@ -49,8 +49,7 @@ k007342_device::k007342_device(const machine_config &mconfig, const char *tag, d //m_regs[8], //m_scrollx[2], //m_scrolly[2], - m_gfxdecode(*this), - m_callback(k007342_delegate()), + m_gfxdecode(*this), m_gfxnum(0) { } diff --git a/src/mame/video/k007420.c b/src/mame/video/k007420.c index 362df77b1e6..170def9759c 100644 --- a/src/mame/video/k007420.c +++ b/src/mame/video/k007420.c @@ -20,38 +20,21 @@ k007420_device::k007420_device(const machine_config &mconfig, const char *tag, d : device_t(mconfig, K007420, "Konami 007420", tag, owner, clock, "k007420", __FILE__), m_ram(NULL), m_flipscreen(0), - m_palette(*this) + m_palette(*this), + m_banklimit(0) //m_regs[8], { } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void k007420_device::device_config_complete() -{ - // inherit a copy of the static data - const k007420_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_banklimit = 0; - m_callback = NULL; - } -} - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void k007420_device::device_start() { + // bind the init function + m_callback.bind_relative_to(*owner()); + m_ram = auto_alloc_array_clear(machine(), UINT8, 0x200); save_pointer(NAME(m_ram), 0x200); @@ -125,7 +108,7 @@ void k007420_device::sprites_draw( bitmap_ind16 &bitmap, const rectangle &clipre flipx = m_ram[offs + 4] & 0x04; flipy = m_ram[offs + 4] & 0x08; - m_callback(machine(), &code, &color); + m_callback(&code, &color); bank = code & bankmask; code &= codemask; diff --git a/src/mame/video/k007420.h b/src/mame/video/k007420.h index 797652e0476..a1da00bd0d0 100644 --- a/src/mame/video/k007420.h +++ b/src/mame/video/k007420.h @@ -2,30 +2,24 @@ #ifndef __K007420_H__ #define __K007420_H__ -typedef void (*k007420_callback)(running_machine &machine, int *code, int *color); +typedef device_delegate k007420_delegate; -struct k007420_interface -{ - int m_banklimit; - k007420_callback m_callback; -}; - -class k007420_device : public device_t, - public k007420_interface +class k007420_device : public device_t { public: k007420_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~k007420_device() {} static void static_set_palette_tag(device_t &device, const char *tag); - + static void static_set_bank_limit(device_t &device, int limit) { downcast(device).m_banklimit = limit; } + static void static_set_callback(device_t &device, k007420_delegate callback) { downcast(device).m_callback = callback; } + DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); void sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx); protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); private: @@ -35,15 +29,26 @@ private: int m_flipscreen; // current code uses the 7342 flipscreen!! UINT8 m_regs[8]; // current code uses the 7342 regs!! (only [2]) required_device m_palette; + int m_banklimit; + k007420_delegate m_callback; }; extern const device_type K007420; -#define MCFG_K007420_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, K007420, 0) \ - MCFG_DEVICE_CONFIG(_interface) +#define MCFG_K007420_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, K007420, 0) #define MCFG_K007420_PALETTE(_palette_tag) \ k007420_device::static_set_palette_tag(*device, "^" _palette_tag); +#define MCFG_K007420_BANK_LIMIT(_limit) \ + k007420_device::static_set_bank_limit(*device, _limit); + +#define MCFG_K007420_CALLBACK_OWNER(_class, _method) \ + k007420_device::static_set_callback(*device, k007420_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + +// function definition for a callback +#define K007420_CALLBACK_MEMBER(_name) void _name(int *code, int *color) + + #endif diff --git a/src/mame/video/rockrage.c b/src/mame/video/rockrage.c index 563da669b68..e218506983c 100644 --- a/src/mame/video/rockrage.c +++ b/src/mame/video/rockrage.c @@ -60,11 +60,9 @@ K007342_CALLBACK_MEMBER(rockrage_state::rockrage_tile_callback) ***************************************************************************/ -void rockrage_sprite_callback( running_machine &machine, int *code, int *color ) +K007420_CALLBACK_MEMBER(rockrage_state::rockrage_sprite_callback) { - rockrage_state *state = machine.driver_data(); - - *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1) * ((state->m_vreg & 0x03) << 1); + *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1) * ((m_vreg & 0x03) << 1); *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0; }