screen: report refresh rate <1hz as error in validity check

This commit is contained in:
hap 2021-12-08 17:49:04 +01:00
parent acfd3ea4f6
commit a435da6f9b
3 changed files with 23 additions and 17 deletions

View File

@ -683,9 +683,9 @@ void screen_device::device_validity_check(validity_checker &valid) const
osd_printf_error("Non-raster display cannot have a variable width\n");
}
// check for zero frame rate
if (m_refresh == 0)
osd_printf_error("Invalid (zero) refresh rate\n");
// check for invalid frame rate
if (m_refresh == 0 || m_refresh > ATTOSECONDS_PER_SECOND)
osd_printf_error("Invalid (under 1Hz) refresh rate\n");
texture_format texformat = !m_screen_update_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32;
if (m_palette.finder_tag() != finder_base::DUMMY_TAG)

View File

@ -120,13 +120,16 @@ void menu_device_config::populate_text(std::optional<text_layout> &layout, float
}
else
{
std::string hz(std::to_string(u32(screen.frame_period().as_hz() * 1'000'000 + 0.5)));
size_t dpos = hz.length() - 6;
if (dpos == 0)
hz.insert(dpos++, "0");
hz.insert(dpos, ".");
size_t last = hz.find_last_not_of('0');
hz = hz.substr(0, last + (last != dpos ? 1 : 0));
const u32 rate = u32(screen.frame_period().as_hz() * 1'000'000 + 0.5);
const bool valid = rate >= 1'000'000;
std::string hz(valid ? std::to_string(rate) : "?");
if (valid)
{
size_t dpos = hz.length() - 6;
hz.insert(dpos, ".");
size_t last = hz.find_last_not_of('0');
hz = hz.substr(0, last + (last != dpos ? 1 : 0));
}
const rectangle &visarea = screen.visible_area();
layout->add_text(

View File

@ -464,13 +464,16 @@ std::string machine_info::game_info_string() const
detail = _("Vector");
else
{
std::string hz(std::to_string(u32(screen.frame_period().as_hz() * 1'000'000 + 0.5)));
size_t dpos = hz.length() - 6;
if (dpos == 0)
hz.insert(dpos++, "0");
hz.insert(dpos, ".");
size_t last = hz.find_last_not_of('0');
hz = hz.substr(0, last + (last != dpos ? 1 : 0));
const u32 rate = u32(screen.frame_period().as_hz() * 1'000'000 + 0.5);
const bool valid = rate >= 1'000'000;
std::string hz(valid ? std::to_string(rate) : "?");
if (valid)
{
size_t dpos = hz.length() - 6;
hz.insert(dpos, ".");
size_t last = hz.find_last_not_of('0');
hz = hz.substr(0, last + (last != dpos ? 1 : 0));
}
const rectangle &visarea = screen.visible_area();
detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %s" UTF8_NBSP "Hz",