From 4b70fe0b7355e590f4dd44c70084b12c57d01995 Mon Sep 17 00:00:00 2001 From: igor Date: Sat, 18 Apr 2026 00:42:29 -0700 Subject: [PATCH] FPS cap. --- Makefile | 3 +++ timetracker.c | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 622cbb6..ee1c377 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ EXE=timetracker $(EXE): $(EXE).c $(CC) $(FLAGS) $(UFLAGS) $(INCLUDE) $^ $(LIBS) $(FRAMEWORKS) -o $@ +run: + ./$(EXE) + tags: $(OBJS) ctags -R *.h *.c diff --git a/timetracker.c b/timetracker.c index 804d674..da9b0e9 100644 --- a/timetracker.c +++ b/timetracker.c @@ -154,13 +154,15 @@ typedef struct Hours { Hours break_time(U64 seconds) { Hours hours; + hours.hours = seconds / 60 / 60; hours.minutes = seconds / 60 - (60 * hours.hours); hours.seconds = seconds - ((hours.hours * 60 * 60) + (hours.minutes * 60)); + return hours; } -void switch_activity(activity *activities, U32 *current_activity, activity_type type, U64 time) +static void switch_activity(activity *activities, U32 *current_activity, activity_type type, U64 time) { if((activities[*current_activity].type != type) && (0 <= type && type < activity_type_COUNT)) { (*current_activity)++; @@ -311,7 +313,7 @@ internal void poll_input() mark_dirty(); } -S32 main(int argc, char *argv[]) +S32 main(S32 argc, char *argv[]) { // TODO: Move into global state. activity activities[256]; // TODO: This should be a dynamic array. @@ -358,7 +360,6 @@ S32 main(int argc, char *argv[]) state.font_size = 30; - double last_input_s = now(); SetTargetFPS(30); @@ -490,8 +491,6 @@ S32 main(int argc, char *argv[]) } DrawRectangle(state.mouse_pos.x, state.mouse_pos.y, 10, 10, WHITE); - - DrawFPS(20, 20); EndDrawing(); // Reset statistics as we will accumulate seconds again. @@ -505,17 +504,15 @@ S32 main(int argc, char *argv[]) last_save = now_s; } -#if 0 if(is_dirty()) { clear_dirty(); SetTargetFPS(120); // FPS cap } else { if(now_s - last_input_s > 1) { - SetTargetFPS(20); + SetTargetFPS(30); last_input_s = now_s; } } -#endif } save_activities(f, file_path, current_activity, activities);