mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
tms9927: Added VSYNC callback. [Curt Coder]
This commit is contained in:
parent
189678f296
commit
6c8616c1c7
@ -37,13 +37,15 @@ const device_type CRT5057 = &device_creator<crt5057_device>;
|
|||||||
|
|
||||||
tms9927_device::tms9927_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
tms9927_device::tms9927_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||||
: device_t(mconfig, TMS9927, "TMS9927", tag, owner, clock, "tms9927", __FILE__),
|
: device_t(mconfig, TMS9927, "TMS9927", tag, owner, clock, "tms9927", __FILE__),
|
||||||
device_video_interface(mconfig, *this)
|
device_video_interface(mconfig, *this),
|
||||||
|
m_write_vsyn(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
tms9927_device::tms9927_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
|
tms9927_device::tms9927_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
|
||||||
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
|
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
|
||||||
device_video_interface(mconfig, *this)
|
device_video_interface(mconfig, *this),
|
||||||
|
m_write_vsyn(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +100,12 @@ void tms9927_device::device_start()
|
|||||||
assert(m_selfload != NULL);
|
assert(m_selfload != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolve callbacks
|
||||||
|
m_write_vsyn.resolve_safe();
|
||||||
|
|
||||||
|
// allocate timers
|
||||||
|
m_vsync_timer = timer_alloc(TIMER_VSYNC);
|
||||||
|
|
||||||
/* register for state saving */
|
/* register for state saving */
|
||||||
machine().save().register_postload(save_prepost_delegate(FUNC(tms9927_device::state_postload), this));
|
machine().save().register_postload(save_prepost_delegate(FUNC(tms9927_device::state_postload), this));
|
||||||
|
|
||||||
@ -130,6 +138,30 @@ void tms9927_device::device_stop()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_timer - handle timer events
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void tms9927_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case TIMER_VSYNC:
|
||||||
|
m_vsyn = !m_vsyn;
|
||||||
|
|
||||||
|
m_write_vsyn(m_vsyn);
|
||||||
|
|
||||||
|
if (m_vsyn)
|
||||||
|
{
|
||||||
|
m_vsync_timer->adjust(m_screen->time_until_pos(3));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_vsync_timer->adjust(m_screen->time_until_pos(0));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tms9927_device::state_postload()
|
void tms9927_device::state_postload()
|
||||||
{
|
{
|
||||||
@ -297,4 +329,7 @@ void tms9927_device::recompute_parameters(int postload)
|
|||||||
refresh = HZ_TO_ATTOSECONDS(m_clock) * m_total_hpix * m_total_vpix;
|
refresh = HZ_TO_ATTOSECONDS(m_clock) * m_total_hpix * m_total_vpix;
|
||||||
|
|
||||||
m_screen->configure(m_total_hpix, m_total_vpix, visarea, refresh);
|
m_screen->configure(m_total_hpix, m_total_vpix, visarea, refresh);
|
||||||
|
|
||||||
|
m_vsyn = 0;
|
||||||
|
m_vsync_timer->adjust(m_screen->time_until_pos(0, 0));
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#ifndef __TMS9927__
|
#ifndef __TMS9927__
|
||||||
#define __TMS9927__
|
#define __TMS9927__
|
||||||
|
|
||||||
|
|
||||||
|
#define MCFG_TMS9927_VSYN_CALLBACK(_write) \
|
||||||
|
devcb = &tms9927_device::set_vsyn_wr_callback(*device, DEVCB2_##_write);
|
||||||
|
|
||||||
/* interface */
|
/* interface */
|
||||||
struct tms9927_interface
|
struct tms9927_interface
|
||||||
{
|
{
|
||||||
@ -27,6 +31,8 @@ public:
|
|||||||
tms9927_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
|
tms9927_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
|
||||||
~tms9927_device() {}
|
~tms9927_device() {}
|
||||||
|
|
||||||
|
template<class _Object> static devcb2_base &set_vsyn_wr_callback(device_t &device, _Object object) { return downcast<tms9927_device &>(device).m_write_vsyn.set_callback(object); }
|
||||||
|
|
||||||
DECLARE_WRITE8_MEMBER(write);
|
DECLARE_WRITE8_MEMBER(write);
|
||||||
DECLARE_READ8_MEMBER(read);
|
DECLARE_READ8_MEMBER(read);
|
||||||
|
|
||||||
@ -40,13 +46,20 @@ protected:
|
|||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
virtual void device_stop();
|
virtual void device_stop();
|
||||||
virtual void device_reset();
|
virtual void device_reset();
|
||||||
|
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TIMER_VSYNC
|
||||||
|
};
|
||||||
|
|
||||||
void state_postload();
|
void state_postload();
|
||||||
void recompute_parameters(int postload);
|
void recompute_parameters(int postload);
|
||||||
void generic_access(address_space &space, offs_t offset);
|
void generic_access(address_space &space, offs_t offset);
|
||||||
|
|
||||||
|
devcb2_write_line m_write_vsyn;
|
||||||
|
|
||||||
// internal state
|
// internal state
|
||||||
const UINT8 *m_selfload;
|
const UINT8 *m_selfload;
|
||||||
|
|
||||||
@ -60,6 +73,10 @@ private:
|
|||||||
UINT8 m_valid_config;
|
UINT8 m_valid_config;
|
||||||
UINT16 m_total_hpix, m_total_vpix;
|
UINT16 m_total_hpix, m_total_vpix;
|
||||||
UINT16 m_visible_hpix, m_visible_vpix;
|
UINT16 m_visible_hpix, m_visible_vpix;
|
||||||
|
|
||||||
|
int m_vsyn;
|
||||||
|
|
||||||
|
emu_timer *m_vsync_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const device_type TMS9927;
|
extern const device_type TMS9927;
|
||||||
|
Loading…
Reference in New Issue
Block a user