timers are member of vdp class (nw)

This commit is contained in:
Miodrag Milanovic 2014-03-25 13:23:39 +00:00
parent d8dda01631
commit b9d741b778
8 changed files with 37 additions and 38 deletions

View File

@ -46,12 +46,21 @@
#define MCFG_TIMER_DRIVER_ADD(_tag, _class, _callback) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_generic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL, (_class *)0));
#define MCFG_TIMER_DEVICE_ADD(_tag, _devtag, _class, _callback) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_generic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)0));
#define MCFG_TIMER_DRIVER_ADD_PERIODIC(_tag, _class, _callback, _period) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_periodic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL, (_class *)0), _period);
#define MCFG_TIMER_DEVICE_ADD_PERIODIC(_tag, _devtag, _class, _callback, _period) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_periodic(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)0), _period);
#define MCFG_TIMER_DRIVER_ADD_SCANLINE(_tag, _class, _callback, _screen, _first_vpos, _increment) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_scanline(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, NULL, (_class *)0), _screen, _first_vpos, _increment);
#define MCFG_TIMER_DEVICE_ADD_SCANLINE(_tag, _devtag, _class, _callback, _screen, _first_vpos, _increment) \
MCFG_DEVICE_ADD(_tag, TIMER, 0) \
timer_device::static_configure_scanline(*device, timer_device_expired_delegate(&_class::_callback, #_class "::" #_callback, _devtag, (_class *)0), _screen, _first_vpos, _increment);
#define MCFG_TIMER_MODIFY(_tag) \
MCFG_DEVICE_MODIFY(_tag)

View File

@ -1366,7 +1366,7 @@ static MACHINE_CONFIG_START( segac, segac2_state )
sega_genesis_vdp_device::set_genesis_vdp_lv4irqline_callback(*device, DEVCB2_WRITELINE(segac2_state, genesis_vdp_lv4irqline_callback_segac2));
sega_genesis_vdp_device::set_genesis_vdp_alt_timing(*device, 1);
MCFG_TIMER_ADD_SCANLINE("scantimer", megadriv_scanline_timer_callback_alt_timing, "megadriv", 0, 1)
MCFG_TIMER_DEVICE_ADD_SCANLINE("scantimer", "gen_vdp", sega_genesis_vdp_device, megadriv_scanline_timer_callback_alt_timing, "megadriv", 0, 1)
MCFG_SCREEN_ADD("megadriv", RASTER)

View File

@ -1241,7 +1241,7 @@ static MACHINE_CONFIG_START( system18, segas18_state )
sega_genesis_vdp_device::set_genesis_vdp_palwrite_base(*device, 0x2000);
sega_genesis_vdp_device::static_set_palette_tag(*device,":palette");
MCFG_TIMER_ADD_SCANLINE("scantimer", megadriv_scanline_timer_callback_alt_timing, "screen", 0, 1)
MCFG_TIMER_DEVICE_ADD_SCANLINE("scantimer", "gen_vdp", sega_genesis_vdp_device, megadriv_scanline_timer_callback_alt_timing, "screen", 0, 1)
// video hardware

View File

@ -521,7 +521,6 @@ public:
DECLARE_WRITE8_MEMBER( megatech_bios_port_ctrl_w );
DECLARE_READ8_MEMBER( megatech_bios_joypad_r );
DECLARE_WRITE8_MEMBER (megatech_bios_port_7f_w);
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
};
@ -549,5 +548,3 @@ extern UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32
extern int megadrive_total_scanlines;
extern int megadrive_vblank_flag;
extern UINT16* megadrive_vdp_palette_lookup;
extern TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback );
extern timer_device* megadriv_scanline_timer;

View File

@ -965,7 +965,7 @@ UINT16 sega_32x_device::get_hposition(void)
attotime time_elapsed_since_megadriv_scanline_timer;
UINT16 value4;
time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed();
time_elapsed_since_megadriv_scanline_timer = machine().device<timer_device>(":md_scan_timer")->time_elapsed();
if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))
{

View File

@ -28,9 +28,6 @@ Known Non-Issues (confirmed on Real Genesis)
MACHINE_CONFIG_EXTERN( megadriv );
extern timer_device* megadriv_scanline_timer;
void megadriv_z80_hold(running_machine &machine)
{
md_base_state *state = machine.driver_data<md_base_state>();
@ -887,8 +884,8 @@ MACHINE_RESET_MEMBER(md_base_state,megadriv)
if (!m_vdp->m_use_alt_timing)
{
megadriv_scanline_timer = machine().device<timer_device>("md_scan_timer");
megadriv_scanline_timer->adjust(attotime::zero);
m_vdp->m_megadriv_scanline_timer = machine().device<timer_device>("md_scan_timer");
m_vdp->m_megadriv_scanline_timer->adjust(attotime::zero);
}
if (m_other_hacks)
@ -908,7 +905,7 @@ MACHINE_RESET_MEMBER(md_base_state,megadriv)
void md_base_state::megadriv_stop_scanline_timer()
{
if (!m_vdp->m_use_alt_timing)
megadriv_scanline_timer->reset();
m_vdp->m_megadriv_scanline_timer->reset();
}
@ -964,7 +961,7 @@ IRQ_CALLBACK_MEMBER(md_base_state::genesis_int_callback)
}
MACHINE_CONFIG_FRAGMENT( megadriv_timers )
MCFG_TIMER_ADD("md_scan_timer", megadriv_scanline_timer_callback)
MCFG_TIMER_DEVICE_ADD("md_scan_timer", "gen_vdp", sega_genesis_vdp_device, megadriv_scanline_timer_callback)
MACHINE_CONFIG_END
@ -1015,7 +1012,7 @@ MACHINE_CONFIG_FRAGMENT( md_ntsc )
MCFG_SCREEN_UPDATE_DRIVER(md_base_state,screen_update_megadriv) /* Copies a bitmap */
MCFG_SCREEN_VBLANK_DRIVER(md_base_state,screen_eof_megadriv) /* Used to Sync the timing */
MCFG_TIMER_ADD_SCANLINE("scantimer", megadriv_scanline_timer_callback_alt_timing, "megadriv", 0, 1)
MCFG_TIMER_DEVICE_ADD_SCANLINE("scantimer", "gen_vdp", sega_genesis_vdp_device, megadriv_scanline_timer_callback_alt_timing, "megadriv", 0, 1)
MCFG_VIDEO_START_OVERRIDE(md_base_state,megadriv)
@ -1291,7 +1288,7 @@ void md_base_state::screen_eof_megadriv(screen_device &screen, bool state)
if (!m_vdp->m_use_alt_timing)
{
m_vdp->vdp_handle_eof();
megadriv_scanline_timer->adjust(attotime::zero);
m_vdp->m_megadriv_scanline_timer->adjust(attotime::zero);
}
}
}

View File

@ -9,9 +9,6 @@
#include "sound/sn76496.h"
timer_device* megadriv_scanline_timer;
#define MAX_HPOSITION 480
@ -1127,7 +1124,7 @@ UINT16 sega_genesis_vdp_device::get_hposition()
{
attotime time_elapsed_since_megadriv_scanline_timer;
time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed();
time_elapsed_since_megadriv_scanline_timer = m_megadriv_scanline_timer->time_elapsed();
if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))
{
@ -2736,41 +2733,37 @@ void sega_genesis_vdp_device::vdp_handle_eof()
// called at the start of each scanline
TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback )
TIMER_DEVICE_CALLBACK_MEMBER( sega_genesis_vdp_device::megadriv_scanline_timer_callback )
{
sega_genesis_vdp_device *vdp = timer.machine().device<sega_genesis_vdp_device>("gen_vdp"); // yuck
if (!vdp->m_use_alt_timing)
if (!m_use_alt_timing)
{
timer.machine().scheduler().synchronize();
vdp->vdp_handle_scanline_callback(param);
machine().scheduler().synchronize();
vdp_handle_scanline_callback(param);
megadriv_scanline_timer->adjust(attotime::from_hz(vdp->get_framerate()) / megadrive_total_scanlines);
m_megadriv_scanline_timer->adjust(attotime::from_hz(get_framerate()) / megadrive_total_scanlines);
}
else
{
vdp->vdp_handle_scanline_callback(param);
vdp_handle_scanline_callback(param);
}
}
TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback_alt_timing )
TIMER_DEVICE_CALLBACK_MEMBER( sega_genesis_vdp_device::megadriv_scanline_timer_callback_alt_timing )
{
sega_genesis_vdp_device *vdp = timer.machine().device<sega_genesis_vdp_device>("gen_vdp"); // yuck
if (vdp->m_use_alt_timing)
if (m_use_alt_timing)
{
if (param==0)
{
//printf("where are we? %d %d\n", m_screen->vpos(), vdp->screen().hpos());
vdp->vdp_handle_eof();
//vdp->vdp_clear_bitmap();
//printf("where are we? %d %d\n", m_screen->vpos(), screen().hpos());
vdp_handle_eof();
//vdp_clear_bitmap();
}
vdp->vdp_handle_scanline_callback(param);
vdp_handle_scanline_callback(param);
int vpos = vdp->screen().vpos();
int vpos = screen().vpos();
if (vpos > 0)
vdp->screen().update_partial(vpos-1);
screen().update_partial(vpos-1);
}
}

View File

@ -146,7 +146,6 @@
#define MEGADRIVE_REG17_UNUSED ((m_vdp_regs[0x17]&0x3f)>>0)
TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback_alt_timing );
UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32 source, address_space & space68k);
@ -201,6 +200,10 @@ public:
UINT16* m_render_line;
UINT16* m_render_line_raw;
TIMER_DEVICE_CALLBACK_MEMBER( megadriv_scanline_timer_callback_alt_timing );
TIMER_DEVICE_CALLBACK_MEMBER( megadriv_scanline_timer_callback );
timer_device* m_megadriv_scanline_timer;
protected:
virtual void device_start();
virtual void device_reset();