diff options
Diffstat (limited to 'src/emu/screen.cpp')
-rw-r--r-- | src/emu/screen.cpp | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 26ef04c43ce..2ec5b660876 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -615,7 +615,7 @@ void screen_device::device_validity_check(validity_checker &valid) const // sanity check display area if (m_type != SCREEN_TYPE_VECTOR && m_type != SCREEN_TYPE_SVG) { - if (m_visarea.empty() || m_visarea.max_x >= m_width || m_visarea.max_y >= m_height) + if (m_visarea.empty() || m_visarea.right() >= m_width || m_visarea.bottom() >= m_height) osd_printf_error("Invalid display area\n"); // sanity check screen formats @@ -722,10 +722,15 @@ void screen_device::device_start() m_svg = std::make_unique<svg_renderer>(reg); machine().output().set_notifier(nullptr, svg_renderer::output_notifier, m_svg.get()); - // The OSD picks up the size before start is called, so this only affect the info display if it's called up in-game - m_width = m_svg->width(); - m_height = m_svg->height(); - m_visarea.set(0, m_width-1, 0, m_height-1); + // don't do this - SVG units are arbitrary and interpreting them as pixels causes bad things to happen + // just render at the size/aspect ratio supplied by the driver + if (false) + { + // The OSD picks up the size before start is called, so this only affect the info display if it's called up in-game + m_width = m_svg->width(); + m_height = m_svg->height(); + m_visarea.set(0, m_width - 1, 0, m_height - 1); + } } // if we have a palette and it's not started, wait for it @@ -886,8 +891,8 @@ void screen_device::device_timer(emu_timer &timer, device_timer_id id, int param // compute the next visible scanline param++; - if (param > m_visarea.max_y) - param = m_visarea.min_y; + if (param > m_visarea.bottom()) + param = m_visarea.top(); m_scanline_timer->adjust(time_until_pos(param), param); break; } @@ -903,12 +908,12 @@ void screen_device::configure(int width, int height, const rectangle &visarea, a // validate arguments assert(width > 0); assert(height > 0); - assert(visarea.min_x >= 0); - assert(visarea.min_y >= 0); -// assert(visarea.max_x < width); -// assert(visarea.max_y < height); - assert(m_type == SCREEN_TYPE_VECTOR || m_type == SCREEN_TYPE_SVG || visarea.min_x < width); - assert(m_type == SCREEN_TYPE_VECTOR || m_type == SCREEN_TYPE_SVG || visarea.min_y < height); + assert(visarea.left() >= 0); + assert(visarea.top() >= 0); +// assert(visarea.right() < width); +// assert(visarea.bottom() < height); + assert(m_type == SCREEN_TYPE_VECTOR || m_type == SCREEN_TYPE_SVG || visarea.left() < width); + assert(m_type == SCREEN_TYPE_VECTOR || m_type == SCREEN_TYPE_SVG || visarea.top() < height); assert(frame_period > 0); // fill in the new parameters @@ -973,9 +978,9 @@ void screen_device::reset_origin(int beamy, int beamx) else m_scanline0_timer->adjust(time_until_pos(0)); - // if we are resetting relative to (visarea.max_y + 1, 0) == VBLANK start, + // if we are resetting relative to (visarea.bottom() + 1, 0) == VBLANK start, // call the VBLANK start timer now; otherwise, adjust it for the future - if (beamy == ((m_visarea.max_y + 1) % m_height) && beamx == 0) + if (beamy == ((m_visarea.bottom() + 1) % m_height) && beamx == 0) vblank_begin(); else m_vblank_begin_timer->adjust(time_until_vblank_start()); @@ -994,8 +999,8 @@ void screen_device::realloc_screen_bitmaps() return; // determine effective size to allocate - s32 effwidth = std::max(m_width, m_visarea.max_x + 1); - s32 effheight = std::max(m_height, m_visarea.max_y + 1); + s32 effwidth = std::max(m_width, m_visarea.right() + 1); + s32 effheight = std::max(m_height, m_visarea.bottom() + 1); // reize all registered screen bitmaps for (auto &item : m_auto_bitmap_list) @@ -1063,21 +1068,20 @@ bool screen_device::update_partial(int scanline) } // set the range of scanlines to render - rectangle clip = m_visarea; - if (m_last_partial_scan > clip.min_y) - clip.min_y = m_last_partial_scan; - if (scanline < clip.max_y) - clip.max_y = scanline; + rectangle clip(m_visarea); + clip.sety( + (std::max)(clip.top(), m_last_partial_scan), + (std::min)(clip.bottom(), scanline)); // skip if entirely outside of visible area - if (clip.min_y > clip.max_y) + if (clip.top() > clip.bottom()) { LOG_PARTIAL_UPDATES(("skipped because outside of visible area\n")); return false; } // otherwise, render - LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y)); + LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.top(), clip.bottom())); g_profiler.start(PROFILER_VIDEO); u32 flags; @@ -1137,7 +1141,7 @@ void screen_device::update_now() int current_hpos = hpos(); rectangle clip = m_visarea; - LOG_PARTIAL_UPDATES(("update_now(): Y=%d, X=%d, last partial %d, partial hpos %d (vis %d %d)\n", current_vpos, current_hpos, m_last_partial_scan, m_partial_scan_hpos, m_visarea.max_x, m_visarea.max_y)); + LOG_PARTIAL_UPDATES(("update_now(): Y=%d, X=%d, last partial %d, partial hpos %d (vis %d %d)\n", current_vpos, current_hpos, m_last_partial_scan, m_partial_scan_hpos, m_visarea.right(), m_visarea.bottom())); // start off by doing a partial update up to the line before us, in case that was necessary if (current_vpos > m_last_partial_scan) @@ -1154,17 +1158,14 @@ void screen_device::update_now() // now finish the previous partial scanline int scanline = current_vpos - 1; - if (m_partial_scan_hpos > clip.min_x) - clip.min_x = m_partial_scan_hpos; - if (current_hpos < clip.max_x) - clip.max_x = current_hpos; - if (m_last_partial_scan > clip.min_y) - clip.min_y = m_last_partial_scan; - if (scanline < clip.max_y) - clip.max_y = scanline; + clip.set( + (std::max)(clip.left(), m_partial_scan_hpos), + (std::min)(clip.right(), current_hpos), + (std::max)(clip.top(), m_last_partial_scan), + (std::min)(clip.bottom(), scanline)); // if there's something to draw, do it - if ((clip.min_x <= clip.max_x) && (clip.min_y <= clip.max_y)) + if (!clip.empty()) { g_profiler.start(PROFILER_VIDEO); @@ -1191,21 +1192,18 @@ void screen_device::update_now() // now draw this partial scanline clip = m_visarea; - if (m_partial_scan_hpos > clip.min_x) - clip.min_x = m_partial_scan_hpos; - if (current_hpos < clip.max_x) - clip.max_x = current_hpos; - if (current_vpos > clip.min_y) - clip.min_y = current_vpos; - if (current_vpos < clip.max_y) - clip.max_y = current_vpos; + clip.set( + (std::max)(clip.left(), m_partial_scan_hpos), + (std::min)(clip.right(), current_hpos), + (std::max)(clip.top(), current_vpos), + (std::min)(clip.bottom(), current_vpos)); // and if there's something to draw, do it - if ((clip.min_x <= clip.max_x) && (clip.min_y <= clip.max_y)) + if (!clip.empty()) { g_profiler.start(PROFILER_VIDEO); - LOG_PARTIAL_UPDATES(("doing scanline partial draw: Y %d X %d-%d\n", clip.max_y, clip.min_x, clip.max_x)); + LOG_PARTIAL_UPDATES(("doing scanline partial draw: Y %d X %d-%d\n", clip.bottom(), clip.left(), clip.right())); u32 flags; screen_bitmap &curbitmap = m_bitmap[m_curbitmap]; @@ -1227,7 +1225,7 @@ void screen_device::update_now() m_last_partial_scan = current_vpos; // if we completed the line, mark it so - if (current_hpos >= m_visarea.max_x) + if (current_hpos >= m_visarea.right()) { m_partial_scan_hpos = 0; m_last_partial_scan = current_vpos + 1; @@ -1267,7 +1265,7 @@ int screen_device::vpos() const vpos = delta / m_scantime; // adjust for the fact that VBLANK starts at the bottom of the visible area - return (m_visarea.max_y + 1 + vpos) % m_height; + return (m_visarea.bottom() + 1 + vpos) % m_height; } @@ -1307,7 +1305,7 @@ attotime screen_device::time_until_pos(int vpos, int hpos) const assert(hpos >= 0); // since we measure time relative to VBLANK, compute the scanline offset from VBLANK - vpos += m_height - (m_visarea.max_y + 1); + vpos += m_height - (m_visarea.bottom() + 1); vpos %= m_height; // compute the delta for the given X,Y position @@ -1545,11 +1543,11 @@ void screen_device::finalize_burnin() return; // compute the scaled visible region - rectangle scaledvis; - scaledvis.min_x = m_visarea.min_x * m_burnin.width() / m_width; - scaledvis.max_x = m_visarea.max_x * m_burnin.width() / m_width; - scaledvis.min_y = m_visarea.min_y * m_burnin.height() / m_height; - scaledvis.max_y = m_visarea.max_y * m_burnin.height() / m_height; + rectangle scaledvis( + m_visarea.left() * m_burnin.width() / m_width, + m_visarea.right() * m_burnin.width() / m_width, + m_visarea.top() * m_burnin.height() / m_height, + m_visarea.bottom() * m_burnin.height() / m_height); // wrap a bitmap around the memregion we care about bitmap_argb32 finalmap(scaledvis.width(), scaledvis.height()); |