tms34061_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-03-24 18:02:28 +00:00
parent 6f86608136
commit 926294f15c
9 changed files with 60 additions and 100 deletions

View File

@ -30,7 +30,9 @@ const device_type TMS34061 = &device_creator<tms34061_device>;
tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TMS34061, "tms34061", tag, owner, clock, "tms34061", __FILE__), : device_t(mconfig, TMS34061, "tms34061", tag, owner, clock, "tms34061", __FILE__),
device_video_interface(mconfig, *this), device_video_interface(mconfig, *this),
//m_regs[TMS34061_REGCOUNT], m_rowshift(0),
m_vramsize(0),
m_interrupt_cb(*this),
m_xmask(0), m_xmask(0),
m_yshift(0), m_yshift(0),
m_vrammask(0), m_vrammask(0),
@ -39,35 +41,9 @@ tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag,
m_latchdata(0), m_latchdata(0),
m_shiftreg(NULL), m_shiftreg(NULL),
m_timer(NULL) m_timer(NULL)
//m_display.blanked(0),
//m_display.vram(NULL),
//m_display.latchram(NULL),
//m_display.regs(NULL),
//m_display.dispstart(0),
//m_display.screen(NULL)
{ {
} memset(m_regs, 0, sizeof(m_regs));
memset(&m_display, 0, sizeof(m_display));
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void tms34061_device::device_config_complete()
{
// inherit a copy of the static data
const tms34061_interface *intf = reinterpret_cast<const tms34061_interface *>(static_config());
if (intf != NULL)
*static_cast<tms34061_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
m_rowshift = 0;
m_vramsize = 0;
//(*m_interrupt)(int state)
}
} }
//------------------------------------------------- //-------------------------------------------------
@ -76,6 +52,9 @@ void tms34061_device::device_config_complete()
void tms34061_device::device_start() void tms34061_device::device_start()
{ {
/* resolve callbak */
m_interrupt_cb.resolve();
/* reset the data */ /* reset the data */
m_vrammask = m_vramsize - 1; m_vrammask = m_vramsize - 1;
@ -151,13 +130,13 @@ static const char *const regnames[] =
void tms34061_device::update_interrupts() void tms34061_device::update_interrupts()
{ {
/* if we have a callback, process it */ /* if we have a callback, process it */
if (m_interrupt) if (!m_interrupt_cb.isnull())
{ {
/* if the status bit is set, and ints are enabled, turn it on */ /* if the status bit is set, and ints are enabled, turn it on */
if ((m_regs[TMS34061_STATUS] & 0x0001) && (m_regs[TMS34061_CONTROL1] & 0x0400)) if ((m_regs[TMS34061_STATUS] & 0x0001) && (m_regs[TMS34061_CONTROL1] & 0x0400))
(*m_interrupt)(m_screen->machine(), ASSERT_LINE); m_interrupt_cb(ASSERT_LINE);
else else
(*m_interrupt)(m_screen->machine(), CLEAR_LINE); m_interrupt_cb(CLEAR_LINE);
} }
} }

View File

@ -11,6 +11,17 @@
#ifndef __TMS34061_H__ #ifndef __TMS34061_H__
#define __TMS34061_H__ #define __TMS34061_H__
#define MCFG_TMS34061_ROWSHIFT(_shift) \
tms34061_device::set_rowshift(*device, _shift);
#define MCFG_TMS34061_VRAM_SIZE(_size) \
tms34061_device::set_vram_size(*device, _size);
#define MCFG_TMS34061_INTERRUPT_CB(_devcb) \
devcb = &tms34061_device::set_interrupt_callback(*device, DEVCB2_##_devcb);
/* register constants */ /* register constants */
enum enum
{ {
@ -35,14 +46,6 @@ enum
TMS34061_REGCOUNT TMS34061_REGCOUNT
}; };
/* interface structure */
struct tms34061_interface
{
UINT8 m_rowshift; /* VRAM address is (row << rowshift) | col */
UINT32 m_vramsize; /* size of video RAM */
void (*m_interrupt)(running_machine &machine, int state); /* interrupt gen callback */
};
/* display state structure */ /* display state structure */
struct tms34061_display struct tms34061_display
{ {
@ -59,12 +62,15 @@ struct tms34061_display
// ======================> tms34061_device // ======================> tms34061_device
class tms34061_device : public device_t, class tms34061_device : public device_t,
public device_video_interface, public device_video_interface
public tms34061_interface
{ {
public: public:
// construction/destruction // construction/destruction
tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
static void set_rowshift(device_t &device, UINT8 rowshift) { downcast<tms34061_device &>(device).m_rowshift = rowshift; }
static void set_vram_size(device_t &device, UINT32 vramsize) { downcast<tms34061_device &>(device).m_vramsize = vramsize; }
template<class _Object> static devcb2_base &set_interrupt_callback(device_t &device, _Object object) { return downcast<tms34061_device &>(device).m_interrupt_cb.set_callback(object); }
/* reads/writes to the 34061 */ /* reads/writes to the 34061 */
UINT8 read(address_space &space, int col, int row, int func); UINT8 read(address_space &space, int col, int row, int func);
@ -81,11 +87,14 @@ public:
protected: protected:
// device-level overrides // device-level overrides
virtual void device_config_complete();
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();
private: private:
UINT8 m_rowshift; /* VRAM address is (row << rowshift) | col */
UINT32 m_vramsize; /* size of video RAM */
devcb2_write_line m_interrupt_cb; /* interrupt gen callback */
UINT16 m_regs[TMS34061_REGCOUNT]; UINT16 m_regs[TMS34061_REGCOUNT];
UINT16 m_xmask; UINT16 m_xmask;
UINT8 m_yshift; UINT8 m_yshift;
@ -108,8 +117,4 @@ private:
// device type definition // device type definition
extern const device_type TMS34061; extern const device_type TMS34061;
#define MCFG_TMS34061_ADD(_tag, _interface) \
MCFG_DEVICE_ADD(_tag, TMS34061, 0) \
MCFG_DEVICE_CONFIG(_interface)
#endif #endif

View File

@ -322,21 +322,11 @@ static const ay8910_interface ay8910_config =
* *
*************************************/ *************************************/
static void generate_interrupt( running_machine &machine, int state ) WRITE_LINE_MEMBER(capbowl_state::generate_tms34061_interrupt)
{ {
capbowl_state *driver = machine.driver_data<capbowl_state>(); m_maincpu->set_input_line(M6809_FIRQ_LINE, state);
driver->m_maincpu->set_input_line(M6809_FIRQ_LINE, state);
} }
static const struct tms34061_interface tms34061intf =
{
8, /* VRAM address is (row << rowshift) | col */
0x10000, /* size of video RAM */
generate_interrupt /* interrupt gen callback */
};
/************************************* /*************************************
* *
* Machine driver * Machine driver
@ -383,7 +373,10 @@ static MACHINE_CONFIG_START( capbowl, capbowl_state )
MCFG_SCREEN_REFRESH_RATE(57) MCFG_SCREEN_REFRESH_RATE(57)
MCFG_SCREEN_UPDATE_DRIVER(capbowl_state, screen_update_capbowl) MCFG_SCREEN_UPDATE_DRIVER(capbowl_state, screen_update_capbowl)
MCFG_TMS34061_ADD("tms34061", tms34061intf) MCFG_DEVICE_ADD("tms34061", TMS34061, 0)
MCFG_TMS34061_ROWSHIFT(8) /* VRAM address is (row << rowshift) | col */
MCFG_TMS34061_VRAM_SIZE(0x10000) /* size of video RAM */
MCFG_TMS34061_INTERRUPT_CB(WRITELINE(capbowl_state, generate_tms34061_interrupt)) /* interrupt gen callback */
/* sound hardware */ /* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SPEAKER_STANDARD_MONO("mono")

View File

@ -91,6 +91,7 @@ public:
struct ef9369 m_pal; struct ef9369 m_pal;
emu_timer *m_fdc_timer; emu_timer *m_fdc_timer;
struct wd1770 m_fdc; struct wd1770 m_fdc;
DECLARE_WRITE_LINE_MEMBER(generate_tms34061_interrupt);
DECLARE_WRITE16_MEMBER(guab_tms34061_w); DECLARE_WRITE16_MEMBER(guab_tms34061_w);
DECLARE_READ16_MEMBER(guab_tms34061_r); DECLARE_READ16_MEMBER(guab_tms34061_r);
DECLARE_WRITE16_MEMBER(ef9369_w); DECLARE_WRITE16_MEMBER(ef9369_w);
@ -138,20 +139,11 @@ static const ptm6840_interface ptm_intf =
* TMS34061 CRTC * TMS34061 CRTC
*****************/ *****************/
static void tms_interrupt(running_machine &machine, int state) WRITE_LINE_MEMBER(guab_state::generate_tms34061_interrupt)
{ {
guab_state *drvstate = machine.driver_data<guab_state>(); m_maincpu->set_input_line(INT_TMS34061, state);
drvstate->m_maincpu->set_input_line(INT_TMS34061, state);
} }
static const struct tms34061_interface tms34061intf =
{
8, /* VRAM address is (row << rowshift) | col */
0x40000, /* Size of video RAM */
tms_interrupt /* Interrupt gen callback */
};
WRITE16_MEMBER(guab_state::guab_tms34061_w) WRITE16_MEMBER(guab_state::guab_tms34061_w)
{ {
int func = (offset >> 19) & 3; int func = (offset >> 19) & 3;
@ -810,7 +802,10 @@ static MACHINE_CONFIG_START( guab, guab_state )
MCFG_PALETTE_ADD("palette", 16) MCFG_PALETTE_ADD("palette", 16)
MCFG_TMS34061_ADD("tms34061", tms34061intf) MCFG_DEVICE_ADD("tms34061", TMS34061, 0)
MCFG_TMS34061_ROWSHIFT(8) /* VRAM address is (row << rowshift) | col */
MCFG_TMS34061_VRAM_SIZE(0x40000) /* size of video RAM */
MCFG_TMS34061_INTERRUPT_CB(WRITELINE(guab_state, generate_tms34061_interrupt)) /* interrupt gen callback */
MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SPEAKER_STANDARD_MONO("mono")

View File

@ -1608,24 +1608,13 @@ static const ay8910_interface ay8910_config =
* *
*************************************/ *************************************/
void itech8_state::static_generate_interrupt(running_machine &machine, int state_num) { machine.driver_data<itech8_state>()->generate_interrupt(state_num); } WRITE_LINE_MEMBER(itech8_state::generate_tms34061_interrupt)
void itech8_state::generate_interrupt(int state_num)
{ {
itech8_update_interrupts(-1, state_num, -1); itech8_update_interrupts(-1, state, -1);
if (FULL_LOGGING && state_num) logerror("------------ DISPLAY INT (%d) --------------\n", m_screen->vpos()); if (FULL_LOGGING && state) logerror("------------ DISPLAY INT (%d) --------------\n", m_screen->vpos());
} }
static const struct tms34061_interface tms34061intf =
{
8, /* VRAM address is (row << rowshift) | col */
0x40000, /* size of video RAM */
&itech8_state::static_generate_interrupt /* interrupt gen callback */
};
/************************************* /*************************************
* *
* Machine driver * Machine driver
@ -1653,7 +1642,10 @@ static MACHINE_CONFIG_START( itech8_core_lo, itech8_state )
MCFG_SCREEN_REFRESH_RATE(60) MCFG_SCREEN_REFRESH_RATE(60)
MCFG_SCREEN_SIZE(512, 263) MCFG_SCREEN_SIZE(512, 263)
MCFG_TMS34061_ADD("tms34061", tms34061intf) MCFG_DEVICE_ADD("tms34061", TMS34061, 0)
MCFG_TMS34061_ROWSHIFT(8) /* VRAM address is (row << rowshift) | col */
MCFG_TMS34061_VRAM_SIZE(0x40000) /* size of video RAM */
MCFG_TMS34061_INTERRUPT_CB(WRITELINE(itech8_state, generate_tms34061_interrupt)) /* interrupt gen callback */
/* sound hardware */ /* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SPEAKER_STANDARD_MONO("mono")

View File

@ -61,19 +61,11 @@ enum int_levels
* *
*************************************/ *************************************/
static void tms_interrupt(running_machine &machine, int state) WRITE_LINE_MEMBER(jpmsys5_state::generate_tms34061_interrupt)
{ {
jpmsys5_state *drvstate = machine.driver_data<jpmsys5_state>(); m_maincpu->set_input_line(INT_TMS34061, state);
drvstate->m_maincpu->set_input_line(INT_TMS34061, state);
} }
static const struct tms34061_interface tms34061intf =
{
8, /* VRAM address is (row << rowshift) | col */
0x40000, /* Size of video RAM - FIXME: Should be 128kB + 32kB */
tms_interrupt /* Interrupt gen callback */
};
WRITE16_MEMBER(jpmsys5_state::sys5_tms34061_w) WRITE16_MEMBER(jpmsys5_state::sys5_tms34061_w)
{ {
int func = (offset >> 19) & 3; int func = (offset >> 19) & 3;
@ -663,7 +655,10 @@ static MACHINE_CONFIG_START( jpmsys5v, jpmsys5_state )
MCFG_SCREEN_RAW_PARAMS(XTAL_40MHz / 4, 676, 20*4, 147*4, 256, 0, 254) MCFG_SCREEN_RAW_PARAMS(XTAL_40MHz / 4, 676, 20*4, 147*4, 256, 0, 254)
MCFG_SCREEN_UPDATE_DRIVER(jpmsys5_state, screen_update_jpmsys5v) MCFG_SCREEN_UPDATE_DRIVER(jpmsys5_state, screen_update_jpmsys5v)
MCFG_TMS34061_ADD("tms34061", tms34061intf) MCFG_DEVICE_ADD("tms34061", TMS34061, 0)
MCFG_TMS34061_ROWSHIFT(8) /* VRAM address is (row << rowshift) | col */
MCFG_TMS34061_VRAM_SIZE(0x40000) /* size of video RAM */
MCFG_TMS34061_INTERRUPT_CB(WRITELINE(jpmsys5_state, generate_tms34061_interrupt)) /* interrupt gen callback */
MCFG_PALETTE_ADD("palette", 16) MCFG_PALETTE_ADD("palette", 16)

View File

@ -55,6 +55,7 @@ public:
TIMER_CALLBACK_MEMBER(capbowl_update); TIMER_CALLBACK_MEMBER(capbowl_update);
inline rgb_t pen_for_pixel( UINT8 *src, UINT8 pix ); inline rgb_t pen_for_pixel( UINT8 *src, UINT8 pix );
DECLARE_WRITE_LINE_MEMBER(firqhandler); DECLARE_WRITE_LINE_MEMBER(firqhandler);
DECLARE_WRITE_LINE_MEMBER(generate_tms34061_interrupt);
protected: protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

View File

@ -69,8 +69,7 @@ public:
UINT8 m_grmatch_palcontrol; UINT8 m_grmatch_palcontrol;
UINT8 m_grmatch_xscroll; UINT8 m_grmatch_xscroll;
rgb_t m_grmatch_palette[2][16]; rgb_t m_grmatch_palette[2][16];
static void static_generate_interrupt(running_machine &machine, int state_num); DECLARE_WRITE_LINE_MEMBER(generate_tms34061_interrupt);
void generate_interrupt(int state_num);
DECLARE_WRITE8_MEMBER(itech8_nmi_ack_w); DECLARE_WRITE8_MEMBER(itech8_nmi_ack_w);
DECLARE_WRITE8_MEMBER(blitter_w); DECLARE_WRITE8_MEMBER(blitter_w);
DECLARE_WRITE8_MEMBER(rimrockn_bank_w); DECLARE_WRITE8_MEMBER(rimrockn_bank_w);

View File

@ -53,6 +53,7 @@ public:
UINT8 m_a0_data_out; UINT8 m_a0_data_out;
UINT8 m_a1_data_out; UINT8 m_a1_data_out;
UINT8 m_a2_data_out; UINT8 m_a2_data_out;
DECLARE_WRITE_LINE_MEMBER(generate_tms34061_interrupt);
DECLARE_WRITE16_MEMBER(sys5_tms34061_w); DECLARE_WRITE16_MEMBER(sys5_tms34061_w);
DECLARE_READ16_MEMBER(sys5_tms34061_r); DECLARE_READ16_MEMBER(sys5_tms34061_r);
DECLARE_WRITE16_MEMBER(ramdac_w); DECLARE_WRITE16_MEMBER(ramdac_w);