diff options
author | 2016-04-05 23:16:43 +0200 | |
---|---|---|
committer | 2016-04-05 23:30:06 +0200 | |
commit | cf830e71daf6074a0ff52df3c6f61c68a158adab (patch) | |
tree | cf5fe5e82c2b296473be10e06b0e7f9d245be0db /src | |
parent | 106c5b3aac76ae47c1e63f891dede53515e25e04 (diff) |
Make overscan on integer scaled targets optional (add option -intoverscan).
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/emuopts.cpp | 1 | ||||
-rw-r--r-- | src/emu/emuopts.h | 2 | ||||
-rw-r--r-- | src/emu/render.cpp | 31 | ||||
-rw-r--r-- | src/emu/render.h | 1 |
4 files changed, 21 insertions, 14 deletions
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index d480f94a284..33f277cdf85 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -93,6 +93,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, { OPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, { OPTION_UNEVENSTRETCHX ";uesx", "0", OPTION_BOOLEAN, "allow non-integer stretch factors only on horizontal axis"}, + { OPTION_INTOVERSCAN ";ios", "0", OPTION_BOOLEAN, "allow overscan on integer scaled targets"}, { OPTION_INTSCALEX ";sx", "0", OPTION_INTEGER, "set horizontal integer scale factor."}, { OPTION_INTSCALEY ";sy", "0", OPTION_INTEGER, "set vertical integer scale."}, diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index e87eb1012a7..522f128961e 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -102,6 +102,7 @@ enum #define OPTION_KEEPASPECT "keepaspect" #define OPTION_UNEVENSTRETCH "unevenstretch" #define OPTION_UNEVENSTRETCHX "unevenstretchx" +#define OPTION_INTOVERSCAN "intoverscan" #define OPTION_INTSCALEX "intscalex" #define OPTION_INTSCALEY "intscaley" @@ -296,6 +297,7 @@ public: bool keep_aspect() const { return bool_value(OPTION_KEEPASPECT); } bool uneven_stretch() const { return bool_value(OPTION_UNEVENSTRETCH); } bool uneven_stretch_x() const { return bool_value(OPTION_UNEVENSTRETCHX); } + bool int_overscan() const { return bool_value(OPTION_INTOVERSCAN); } int int_scale_x() const { return int_value(OPTION_INTSCALEX); } int int_scale_y() const { return int_value(OPTION_INTSCALEY); } diff --git a/src/emu/render.cpp b/src/emu/render.cpp index a340e226c50..0af06e665b2 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -934,6 +934,7 @@ render_target::render_target(render_manager &manager, const internal_layout *lay // aspect and scale options m_keepaspect = (manager.machine().options().keep_aspect() && !(flags & RENDER_CREATE_HIDDEN)); + m_int_overscan = manager.machine().options().int_overscan(); m_int_scale_x = manager.machine().options().int_scale_x(); m_int_scale_y = manager.machine().options().int_scale_y(); if (manager.machine().options().uneven_stretch() && !manager.machine().options().uneven_stretch_x()) @@ -1204,22 +1205,24 @@ void render_target::compute_visible_area(INT32 target_width, INT32 target_height if (target_orientation & ORIENTATION_SWAP_XY) src_aspect = 1.0 / src_aspect; - // get destination size and aspect - float dest_width = (float)target_width; - float dest_height = (float)target_height; - float dest_aspect = dest_width / dest_height * target_pixel_aspect; + // get target aspect + float target_aspect = (float)target_width / (float)target_height * target_pixel_aspect; - // apply aspect correction to destination rectangle - if (dest_aspect > src_aspect) - dest_width *= m_keepaspect? src_aspect / dest_aspect : 1.0f; - else - dest_height *= m_keepaspect? dest_aspect / src_aspect : 1.0f; + // determine the scale mode for each axis + bool x_is_integer = !(target_aspect >= 1.0f && m_scale_mode == SCALE_FRACTIONAL_X); + bool y_is_integer = !(target_aspect < 1.0f && m_scale_mode == SCALE_FRACTIONAL_X); + + // first compute scale factors to fit the screen + float xscale = (float)target_width / src_width; + float yscale = (float)target_height / src_height; + float maxxscale = MAX(1, m_int_overscan? render_round_nearest(xscale) : floor(xscale)); + float maxyscale = MAX(1, m_int_overscan? render_round_nearest(yscale) : floor(yscale)); - // compute scale factors - float xscale = dest_width / src_width; - float yscale = dest_height / src_height; - xscale = dest_aspect >= 1.0f && m_scale_mode == SCALE_FRACTIONAL_X? xscale : MAX(1, render_round_nearest(xscale)); - yscale = dest_aspect < 1.0f && m_scale_mode == SCALE_FRACTIONAL_X? yscale : MAX(1, render_round_nearest(yscale)); + // now apply desired scale mode and aspect correction + if (m_keepaspect && target_aspect > src_aspect) xscale *= src_aspect / target_aspect * (maxyscale / yscale); + if (m_keepaspect && target_aspect < src_aspect) yscale *= target_aspect / src_aspect * (maxxscale / xscale); + if (x_is_integer) xscale = MIN(maxxscale, MAX(1, render_round_nearest(xscale))); + if (y_is_integer) yscale = MIN(maxyscale, MAX(1, render_round_nearest(yscale))); // check if we have user defined scale factors, if so use them instead xscale = m_int_scale_x? m_int_scale_x : xscale; diff --git a/src/emu/render.h b/src/emu/render.h index 623e65a56f6..c0c8faed689 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -1008,6 +1008,7 @@ private: INT32 m_height; // height in pixels render_bounds m_bounds; // bounds of the target bool m_keepaspect; // constrain aspect ratio + bool m_int_overscan; // allow overscan on integer scaled targets float m_pixel_aspect; // aspect ratio of individual pixels int m_scale_mode; // type of scale to apply int m_int_scale_x; // horizontal integer scale factor |