From ffa5eaaae451b8733bc08839a53af3fcc899a093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyarion=20Sany=C3=ABn=C3=B3na?= Date: Wed, 13 Jun 2018 09:46:10 -0500 Subject: [PATCH] Progress bars will not draw to screen faster than 30 Hz --- arm9/source/common/ui.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index 195f21b..d08487e 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -18,6 +18,7 @@ #define STRBUF_SIZE 512 // maximum size of the string buffer #define FONT_MAX_WIDTH 8 #define FONT_MAX_HEIGHT 10 +#define PROGRESS_REFRESH_RATE 30 // the progress bar is only allowed to draw to screen every X milliseconds static u32 font_width = 0; static u32 font_height = 0; @@ -934,11 +935,13 @@ bool ShowProgress(u64 current, u64 total, const char* opstr) char tempstr[64]; char progstr[64]; + static u64 last_msec_elapsed = 0; static u64 last_sec_remain = 0; if (!current) { timer = timer_start(); last_sec_remain = 0; - } + } else if (timer_msec(timer) < last_msec_elapsed + PROGRESS_REFRESH_RATE) return !CheckButton(BUTTON_B); + last_msec_elapsed = timer_msec(timer); u64 sec_elapsed = (total > 0) ? timer_sec( timer ) : 0; u64 sec_total = (current > 0) ? (sec_elapsed * total) / current : 0; u64 sec_remain = (!last_sec_remain) ? (sec_total - sec_elapsed) : ((last_sec_remain + (sec_total - sec_elapsed) + 1) / 2);