diff options
author | hap <happppp@users.noreply.github.com> | 2021-12-08 17:49:04 +0100 |
---|---|---|
committer | hap <happppp@users.noreply.github.com> | 2021-12-08 17:49:04 +0100 |
commit | a435da6f9bd16871e5e7c562bd3ce591e0a04379 (patch) | |
tree | 2cf3698f870cc465feb8a6699a1e9e240e046b0f /src/frontend | |
parent | acfd3ea4f6d851e517cdf7f0c33d50afe3daae1f (diff) |
screen: report refresh rate <1hz as error in validity check
Diffstat (limited to 'src/frontend')
-rw-r--r-- | src/frontend/mame/ui/devopt.cpp | 17 | ||||
-rw-r--r-- | src/frontend/mame/ui/info.cpp | 17 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp index cfb277127fd..c9a2c7f4360 100644 --- a/src/frontend/mame/ui/devopt.cpp +++ b/src/frontend/mame/ui/devopt.cpp @@ -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( diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index ec7d5f0242f..d7ed21065fa 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -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", |