From 90115f4de2964170bf4c84e4ceb0404a5a636b16 Mon Sep 17 00:00:00 2001 From: holub Date: Mon, 20 Jun 2022 12:13:47 -0400 Subject: [PATCH] spectrum.cpp, spec128.cpp: Fixed partial updates at end of frame. (#9945) See MT08264 and MT08265 as well as discussion on GitHub #9670 and #9750. --- src/mame/drivers/spec128.cpp | 7 +++++-- src/mame/drivers/spectrum.cpp | 4 +++- src/mame/includes/spectrum.h | 2 ++ src/mame/video/spectrum.cpp | 21 ++++++++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/mame/drivers/spec128.cpp b/src/mame/drivers/spec128.cpp index d926c34ac13..aaa8d0ef3bb 100644 --- a/src/mame/drivers/spec128.cpp +++ b/src/mame/drivers/spec128.cpp @@ -346,7 +346,8 @@ GFXDECODE_END rectangle spectrum_128_state::get_screen_area() { - return rectangle{48, 48 + 255, 63, 63 + 191}; + return { SPEC_LEFT_BORDER, SPEC_LEFT_BORDER + SPEC_DISPLAY_XSIZE - 1, + SPEC128_UNSEEN_LINES + SPEC_TOP_BORDER, SPEC128_UNSEEN_LINES + SPEC_TOP_BORDER + SPEC_DISPLAY_YSIZE - 1 }; } void spectrum_128_state::spectrum_128(machine_config &config) @@ -363,7 +364,9 @@ void spectrum_128_state::spectrum_128(machine_config &config) config.set_maximum_quantum(attotime::from_hz(60)); /* video hardware */ - m_screen->set_raw(X1_128_SINCLAIR / 5, 456, 311, {get_screen_area().left() - 48, get_screen_area().right() + 48, get_screen_area().top() - 48, get_screen_area().bottom() + 56}); + rectangle visarea = { get_screen_area().left() - SPEC_LEFT_BORDER, get_screen_area().right() + SPEC_RIGHT_BORDER, + get_screen_area().top() - SPEC_TOP_BORDER, get_screen_area().bottom() + SPEC_BOTTOM_BORDER }; + m_screen->set_raw(X1_128_SINCLAIR / 5, SPEC128_CYCLES_PER_LINE * 2, SPEC128_UNSEEN_LINES + SPEC_SCREEN_HEIGHT, visarea); subdevice("gfxdecode")->set_info(spec128); diff --git a/src/mame/drivers/spectrum.cpp b/src/mame/drivers/spectrum.cpp index b13b8f7b287..4027e4d4bd8 100644 --- a/src/mame/drivers/spectrum.cpp +++ b/src/mame/drivers/spectrum.cpp @@ -796,7 +796,9 @@ void spectrum_state::spectrum_common(machine_config &config) /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_raw(X1 / 2, 448, 312, {get_screen_area().left() - 48, get_screen_area().right() + 48, get_screen_area().top() - 48, get_screen_area().bottom() + 56}); + rectangle visarea = { get_screen_area().left() - SPEC_LEFT_BORDER, get_screen_area().right() + SPEC_RIGHT_BORDER, + get_screen_area().top() - SPEC_TOP_BORDER, get_screen_area().bottom() + SPEC_BOTTOM_BORDER }; + m_screen->set_raw(X1 / 2, SPEC_CYCLES_PER_LINE * 2, SPEC_UNSEEN_LINES + SPEC_SCREEN_HEIGHT, visarea); m_screen->set_screen_update(FUNC(spectrum_state::screen_update_spectrum)); m_screen->set_palette("palette"); diff --git a/src/mame/includes/spectrum.h b/src/mame/includes/spectrum.h index ed1c26309b3..9bdab767b49 100644 --- a/src/mame/includes/spectrum.h +++ b/src/mame/includes/spectrum.h @@ -97,9 +97,11 @@ protected: TIMER_CALLBACK_MEMBER(irq_on); TIMER_CALLBACK_MEMBER(irq_off); + TIMER_CALLBACK_MEMBER(finish_screen_update); emu_timer *m_irq_on_timer; emu_timer *m_irq_off_timer; + emu_timer *m_finish_screen_update_timer; int m_port_fe_data; int m_port_7ffd_data; diff --git a/src/mame/video/spectrum.cpp b/src/mame/video/spectrum.cpp index 70ecf5249ed..39390e2f436 100644 --- a/src/mame/video/spectrum.cpp +++ b/src/mame/video/spectrum.cpp @@ -19,6 +19,22 @@ #include "includes/spectrum.h" #include "includes/spec128.h" +TIMER_CALLBACK_MEMBER(spectrum_state::finish_screen_update) +{ + /* TMP screen.cpp at the current state behaves incorrectly if layout is configured as: visarea.bottom() == m_screen.bottom() + This leads video_manager::finish_screen_updates() to ignore final update_now(). As a result partially rendered scanline of + the screen is redrawn entirely. + Consider this timer a tmp solution till screen.cpp provides better support for such case. + Validation: + https://mametesters.org/view.php?id=8264 + https://mametesters.org/view.php?id=8265 + https://github.com/mamedev/mame/pull/9670#issuecomment-1118576555 + https://github.com/mamedev/mame/pull/9750 + */ + m_screen->update_now(); + m_finish_screen_update_timer->adjust(m_screen->time_until_pos(m_screen->visible_area().bottom(), m_screen->visible_area().right() + 1)); +} + /*************************************************************************** Start the video hardware emulation. ***************************************************************************/ @@ -26,6 +42,8 @@ void spectrum_state::video_start() { m_irq_on_timer = timer_alloc(FUNC(spectrum_state::irq_on), this); m_irq_off_timer = timer_alloc(FUNC(spectrum_state::irq_off), this); + m_finish_screen_update_timer = timer_alloc(FUNC(spectrum_state::finish_screen_update), this); + finish_screen_update(0); m_frame_invert_count = 16; m_screen_location = m_video_ram; @@ -85,7 +103,8 @@ void spectrum_state::spectrum_palette(palette_device &palette) const rectangle spectrum_state::get_screen_area() { // 256x192 screen position without border - return rectangle{48, 48 + 255, 64, 64 + 191}; + return { SPEC_LEFT_BORDER, SPEC_LEFT_BORDER + SPEC_DISPLAY_XSIZE - 1, + SPEC_UNSEEN_LINES + SPEC_TOP_BORDER, SPEC_UNSEEN_LINES + SPEC_TOP_BORDER + SPEC_DISPLAY_YSIZE - 1 }; } u8 spectrum_state::get_border_color(u16 hpos, u16 vpos)