shithub: zelda3

Download patch

ref: 49cc686ed4e90acd09936f1a5eaf3870d110172c
parent: 6bd8b1185e7a9a1d80b4d9a10fbf6e04b767de4c
author: Patrick Mollohan <[email protected]>
date: Sun Sep 11 14:49:00 EDT 2022

Option to show performance in title bar

--- a/config.c
+++ b/config.c
@@ -238,6 +238,9 @@
     if (StringEqualsNoCase(key, "Autosave")) {
       g_config.autosave = (bool)strtol(value, (char**)NULL, 10);
       return true;
+    } else if (StringEqualsNoCase(key, "DisplayPerfInTitle")) {
+      g_config.display_perf_title = (bool)strtol(value, (char**)NULL, 10);
+      return true;
     }
 
   }
--- a/config.h
+++ b/config.h
@@ -42,6 +42,7 @@
   uint8 audio_channels;
   uint16 audio_samples;
   bool autosave;
+  bool display_perf_title;
 } Config;
 
 extern Config g_config;
--- a/main.c
+++ b/main.c
@@ -130,7 +130,7 @@
 
 static bool RenderScreenWithPerf(uint8 *pixel_buffer, size_t pitch, uint32 render_flags) {
   bool rv;
-  if (g_display_perf) {
+  if (g_display_perf || g_config.display_perf_title) {
     static float history[64], average;
     static int history_pos;
     uint64 before = SDL_GetPerformanceCounter();
@@ -473,9 +473,14 @@
   }
   uint64 t1 = SDL_GetPerformanceCounter();
   bool hq = RenderScreenWithPerf(pixels, pitch, g_ppu_render_flags);
-  if (g_display_perf)
-    RenderNumber(pixels + (pitch*2<<hq), pitch, g_curr_fps, hq);
-
+  if (g_display_perf) {
+    RenderNumber(pixels + (pitch * 2 << hq), pitch, g_curr_fps, hq);
+  }
+  if (g_config.display_perf_title) {
+    char title[60];
+    snprintf(title, sizeof(title), "%s | FPS: %d", kWindowTitle, g_curr_fps);
+    SDL_SetWindowTitle(window, title);
+  }
   uint64 t2 = SDL_GetPerformanceCounter();
   SDL_UnlockTexture(texture);
   uint64 t3 = SDL_GetPerformanceCounter();
--- a/zelda3.ini
+++ b/zelda3.ini
@@ -1,6 +1,7 @@
 [General]
 # Automatically save state on quit and reload on start
 Autosave = 0
+DisplayPerfInTitle = 0
 
 
 [Graphics]