This commit is contained in:
mooglyguy 2018-06-03 19:54:49 +02:00
parent 579d0e2646
commit df821c674d
4 changed files with 16 additions and 26 deletions

View File

@ -46,7 +46,7 @@ device_execute_interface::device_execute_interface(const machine_config &mconfig
: device_interface(device, "execute")
, m_scheduler(nullptr)
, m_disabled(false)
, m_vblank_interrupt_screen(nullptr)
, m_vblank_interrupt_screen(*this, finder_base::DUMMY_TAG)
, m_timed_interrupt_period(attotime::zero)
, m_nextexec(nullptr)
, m_timedint_timer(nullptr)
@ -345,13 +345,12 @@ void device_execute_interface::execute_set_input(int linenum, int state)
void device_execute_interface::interface_validity_check(validity_checker &valid) const
{
// validate the interrupts
if (!m_vblank_interrupt.isnull())
if (!m_vblank_interrupt_screen)
{
screen_device_iterator iter(device().mconfig().root_device());
if (iter.first() == nullptr)
osd_printf_error("VBLANK interrupt specified, but the driver is screenless\n");
else if (m_vblank_interrupt_screen != nullptr && device().siblingdevice(m_vblank_interrupt_screen) == nullptr)
osd_printf_error("VBLANK interrupt references a non-existant screen tag '%s'\n", m_vblank_interrupt_screen);
if (m_vblank_interrupt_screen.finder_tag() != finder_base::DUMMY_TAG)
osd_printf_error("VBLANK interrupt references non-existent screen tag %s\n", m_vblank_interrupt_screen.finder_tag());
else if (!m_vblank_interrupt.isnull())
osd_printf_error("VBLANK interrupt specified, but no screen configured\n");
}
if (!m_timed_interrupt.isnull() && m_timed_interrupt_period == attotime::zero)
@ -443,14 +442,8 @@ void device_execute_interface::interface_post_reset()
elem.reset();
// reconfingure VBLANK interrupts
if (m_vblank_interrupt_screen != nullptr)
{
// get the screen that will trigger the VBLANK
screen_device *screen = device().siblingdevice<screen_device>(m_vblank_interrupt_screen);
assert(screen != nullptr);
screen->register_vblank_callback(vblank_state_delegate(&device_execute_interface::on_vblank, this));
}
if (m_vblank_interrupt_screen)
m_vblank_interrupt_screen->register_vblank_callback(vblank_state_delegate(&device_execute_interface::on_vblank, this));
// reconfigure periodic interrupts
if (m_timed_interrupt_period != attotime::zero)

View File

@ -86,7 +86,7 @@ enum
#define MCFG_DEVICE_VBLANK_INT_DEVICE(_tag, _devtag, _class, _func) \
dynamic_cast<device_execute_interface &>(*device).set_vblank_int(device_interrupt_delegate(&_class::_func, #_class "::" #_func, _devtag, (_class *)nullptr), _tag);
#define MCFG_DEVICE_VBLANK_INT_REMOVE() \
dynamic_cast<device_execute_interface &>(*device).set_vblank_int(device_interrupt_delegate(), nullptr);
dynamic_cast<device_execute_interface &>(*device).set_vblank_int(device_interrupt_delegate(), finder_base::DUMMY_TAG);
#define MCFG_DEVICE_PERIODIC_INT_DRIVER(_class, _func, _rate) \
dynamic_cast<device_execute_interface &>(*device).set_periodic_int(device_interrupt_delegate(&_class::_func, #_class "::" #_func, DEVICE_SELF, (_class *)nullptr), attotime::from_hz(_rate));
#define MCFG_DEVICE_PERIODIC_INT_DEVICE(_devtag, _class, _func, _rate) \
@ -140,10 +140,10 @@ public:
// inline configuration helpers
void set_disable() { m_disabled = true; }
template <typename Object> void set_vblank_int(Object &&cb, const char *tag, int rate = 0)
template <typename Object, typename T> void set_vblank_int(Object &&cb, T &&tag, int rate = 0)
{
m_vblank_interrupt = std::forward<Object>(cb);
m_vblank_interrupt_screen = tag;
m_vblank_interrupt_screen.set_tag(std::forward<T>(tag));
}
template <typename Object> void set_periodic_int(Object &&cb, const attotime &rate)
{
@ -290,7 +290,7 @@ private:
// configuration
bool m_disabled; // disabled from executing?
device_interrupt_delegate m_vblank_interrupt; // for interrupts tied to VBLANK
const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
optional_device<screen_device> m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt
device_interrupt_delegate m_timed_interrupt; // for interrupts not tied to VBLANK
attotime m_timed_interrupt_period; // period for periodic interrupts

View File

@ -422,13 +422,10 @@ uint32_t svision_state::screen_update_tvlink(screen_device &screen, bitmap_rgb32
return 0;
}
WRITE_LINE_MEMBER(svision_state::frame_int_w)
INTERRUPT_GEN_MEMBER(svision_state::svision_frame_int)
{
if (!state)
return;
if (BIT(m_reg[BANK], 0))
m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
device.execute().pulse_input_line(INPUT_LINE_NMI, attotime::zero);
m_sound->sound_decrement();
}
@ -522,6 +519,7 @@ MACHINE_CONFIG_START(svision_state::svision)
MCFG_DEVICE_ADD(m_maincpu, M65C02, 4000000)
MCFG_DEVICE_PROGRAM_MAP(svision_mem)
MCFG_DEVICE_VBLANK_INT_DRIVER(m_screen, svision_state, svision_frame_int)
MCFG_SCREEN_ADD(m_screen, LCD)
MCFG_SCREEN_REFRESH_RATE(61)
@ -529,7 +527,6 @@ MACHINE_CONFIG_START(svision_state::svision)
MCFG_SCREEN_VISIBLE_AREA(3+0, 3+160-1, 0, 160-1)
MCFG_SCREEN_UPDATE_DRIVER(svision_state, screen_update_svision)
MCFG_SCREEN_PALETTE(m_palette)
MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, svision_state, frame_int_w))
MCFG_PALETTE_ADD(m_palette, ARRAY_LENGTH(svision_palette) * 3)
MCFG_PALETTE_INIT_OWNER(svision_state, svision )

View File

@ -62,7 +62,7 @@ public:
void init_svision();
uint32_t screen_update_svision(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_tvlink(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(frame_int_w);
INTERRUPT_GEN_MEMBER(svision_frame_int);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(svision_cart);
void svisionp(machine_config &config);