mirror of
https://github.com/holub/mame
synced 2025-04-27 10:43:07 +03:00
k007420 callbacks to delegates (nw)
This commit is contained in:
parent
09cf6f06ff
commit
9a05909abe
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
@ -41,7 +41,5 @@ public:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<gfxdecode_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);
|
||||
|
@ -53,7 +53,6 @@ public:
|
||||
required_device<palette_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);
|
||||
|
@ -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);
|
||||
|
@ -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<battlnts_state>();
|
||||
|
||||
*code |= ((*color & 0xc0) << 2) | state->m_spritebank;
|
||||
*code |= ((*color & 0xc0) << 2) | m_spritebank;
|
||||
*code = (*code << 2) | ((*color & 0x30) >> 4);
|
||||
*color = 0;
|
||||
}
|
||||
|
@ -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<bladestl_state>();
|
||||
|
||||
*code |= ((*color & 0xc0) << 2) + state->m_spritebank;
|
||||
*code |= ((*color & 0xc0) << 2) + m_spritebank;
|
||||
*code = (*code << 2) | ((*color & 0x30) >> 4);
|
||||
*color = 0 + (*color & 0x0f);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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<const k007420_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<k007420_interface *>(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;
|
||||
|
@ -2,30 +2,24 @@
|
||||
#ifndef __K007420_H__
|
||||
#define __K007420_H__
|
||||
|
||||
typedef void (*k007420_callback)(running_machine &machine, int *code, int *color);
|
||||
typedef device_delegate<void (int *code, int *color)> 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<k007420_device &>(device).m_banklimit = limit; }
|
||||
static void static_set_callback(device_t &device, k007420_delegate callback) { downcast<k007420_device &>(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<palette_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
|
||||
|
@ -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<rockrage_state>();
|
||||
|
||||
*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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user