From 197d41a3e23cab35848f623c6133baccc62aacbe Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 26 Aug 2026 17:56:52 -0400 Subject: OSD stuff and Android fixes Signed-off-by: Andrew Opalach --- src/util/print_time.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/util') diff --git a/src/util/print_time.h b/src/util/print_time.h index 89644b2..b6ab625 100644 --- a/src/util/print_time.h +++ b/src/util/print_time.h @@ -2,19 +2,29 @@ #include +static inline bool camu_split_time(u64 nanoseconds, u32 *hours, u32 *minutes, u32 *seconds, u32 *hundredths) +{ + *hours = nanoseconds / 3600000000u; + *minutes = nanoseconds / 60000000u; + *seconds = nanoseconds / 1000000u; + *hundredths = nanoseconds / 10000u; + bool over_an_hour = *minutes >= 60u; + *hundredths -= *seconds * 100u; + *seconds -= *minutes * 60u; + *minutes -= *hours * 60u; + return over_an_hour; +} + static inline s32 camu_print_time(char *buf, size_t size, u64 nanoseconds, bool always_show_hour, u32 hour_padding) { - u32 hours = nanoseconds / 3600000000u; - u32 minutes = nanoseconds / 60000000u; - bool show_hour = always_show_hour || minutes >= 60u; - u32 seconds = nanoseconds / 1000000u; - seconds -= minutes * 60u; - minutes -= hours * 60u; + u32 hours, minutes, seconds, hundredths; + bool show_hour = camu_split_time(nanoseconds, &hours, &minutes, &seconds, &hundredths); + show_hour |= always_show_hour; s32 offset = 0; if (show_hour && hour_padding >= 2 && hour_padding <= 4) { static const char *padding_table[] = { "%.2u:", "%.3u:", "%.4u:" }; offset += al_snprintf(buf, size, padding_table[hour_padding - 2u], hours); } - offset += al_snprintf(buf + offset, size - offset, "%.2u:%.2u", minutes, seconds); + offset += al_snprintf(buf + offset, size - offset, "%.2u:%.2u.%.2u", minutes, seconds, hundredths); return offset; } -- cgit v1.2.3-101-g0448