From 40910ec4a6b3a725f65699765e9f0a0c9a85c125 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 18 Oct 2010 08:07:02 +0000 Subject: [PATCH] Fix MT04059: Add new method reset_origin() to screen devices to allow manual synchronization of VBLANK start against an external timing source. Updated the MC6845 device to call reset_origin() on its screen at the start of each frame if a screen is present. The practical upshot is that now the screen timing and MC6845 timing is once against synchronized, but by tying the screen timing to the MC6845 and not the other way around. --- src/emu/video.c | 17 +++++++++++++++++ src/emu/video.h | 1 + src/emu/video/mc6845.c | 3 +++ 3 files changed, 21 insertions(+) diff --git a/src/emu/video.c b/src/emu/video.c index ed1fc210059..69ec5ca4cf9 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -2087,6 +2087,23 @@ void screen_device::configure(int width, int height, const rectangle &visarea, a } +//------------------------------------------------- +// reset_origin - reset the timing such that the +// given (x,y) occurs at the current time +//------------------------------------------------- + +void screen_device::reset_origin(int beamy, int beamx) +{ + // compute the effective VBLANK start/end times + m_vblank_end_time = attotime_sub_attoseconds(timer_get_time(machine), beamy * m_scantime + beamx * m_pixeltime); + m_vblank_start_time = attotime_sub_attoseconds(m_vblank_end_time, m_vblank_period); + + // re-adjust the scanline 0 and VBLANK timers + timer_adjust_oneshot(m_scanline0_timer, time_until_pos(0), 0); + timer_adjust_oneshot(m_vblank_begin_timer, time_until_vblank_start(), 0); +} + + //------------------------------------------------- // realloc_screen_bitmaps - reallocate bitmaps // and textures as necessary diff --git a/src/emu/video.h b/src/emu/video.h index 8ffcc82537a..c49a6dd5ead 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -160,6 +160,7 @@ public: // dynamic configuration void configure(int width, int height, const rectangle &visarea, attoseconds_t frame_period); + void reset_origin(int beamy = 0, int beamx = 0); void set_visible_area(int min_x, int max_x, int min_y, int max_y); // beam positioning and state diff --git a/src/emu/video/mc6845.c b/src/emu/video/mc6845.c index 3b38f5ddb43..92b521c580e 100644 --- a/src/emu/video/mc6845.c +++ b/src/emu/video/mc6845.c @@ -651,6 +651,9 @@ static TIMER_CALLBACK( line_timer_cb ) mc6845->line_enable_ff = 1; /* also update the cursor state now */ update_cursor_state(mc6845); + + if (mc6845->screen != NULL) + mc6845->screen->reset_origin(); } else {