This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 0f62ea793098a63d280727b9574c62a1c77f5866
Author: Matteo Golin <[email protected]>
AuthorDate: Sat Oct 17 07:09:28 2026 -0400

    games/NXDoom: allow disabling disk icon
    
    Allow user to disable the disk icon on data loading, which saves on
    memory allocations.
    
    Signed-off-by: Matteo Golin <[email protected]>
---
 games/NXDoom/Kconfig.optimizations |   7 +
 games/NXDoom/Makefile              |   5 +-
 games/NXDoom/src/doom/d_main.c     |  27 ++--
 games/NXDoom/src/i_video.c         |   4 +
 games/NXDoom/src/m_config.c        | 259 +++++++++++++++++++------------------
 games/NXDoom/src/w_wad.c           |  11 +-
 6 files changed, 168 insertions(+), 145 deletions(-)

diff --git a/games/NXDoom/Kconfig.optimizations 
b/games/NXDoom/Kconfig.optimizations
index ee1c89f1d..15ef4755b 100644
--- a/games/NXDoom/Kconfig.optimizations
+++ b/games/NXDoom/Kconfig.optimizations
@@ -137,4 +137,11 @@ config GAMES_NXDOOM_NOWIPE
                DOOM has a wipe animation between screens which requires costly
                `z_malloc` allocations. Enabling this option disables that 
animation.
 
+config GAMES_NXDOOM_SHOWDISKICON
+       bool "Show disk icon"
+       default n
+       ---help---
+               DOOM can show a disk activity indicator when reading data. 
Disabling
+               this option removes the animation, which saves memory 
allocations.
+
 endmenu # Optimizations
diff --git a/games/NXDoom/Makefile b/games/NXDoom/Makefile
index e1745d80a..2aa00d96a 100644
--- a/games/NXDoom/Makefile
+++ b/games/NXDoom/Makefile
@@ -56,7 +56,6 @@ BASESRCS =        \
   p_rejectpad.c   \
   memio.c         \
   tables.c        \
-  v_diskicon.c    \
   v_video.c       \
   w_checksum.c    \
   w_main.c        \
@@ -71,6 +70,10 @@ ifeq ($(CONFIG_GAMES_NXDOOM_ENDOOM),y)
 BASESRCS += i_endoom.c
 endif
 
+ifeq ($(CONFIG_GAMES_NXDOOM_SHOWDISKICON),y)
+BASESRCS += v_diskicon.c # Show disk icon on data load
+endif
+
 NETSRCS =         \
   net_client.c    \
   net_common.c    \
diff --git a/games/NXDoom/src/doom/d_main.c b/games/NXDoom/src/doom/d_main.c
index 153ad957d..5213eea6e 100644
--- a/games/NXDoom/src/doom/d_main.c
+++ b/games/NXDoom/src/doom/d_main.c
@@ -158,7 +158,6 @@ boolean storedemo;
 boolean main_loop_started = false;
 
 int show_endoom = 1;
-int show_diskicon = 1;
 
 /* wipegamestate can be set to -1 to force a wipe on the next draw */
 
@@ -323,25 +322,24 @@ static const struct pack g_packs[] =
  * Private Functions
  ****************************************************************************/
 
+#ifdef CONFIG_GAMES_NXDOOM_SHOWDISKICON
 static void enable_loading_disk(void)
 {
   const char *disk_lump_name;
 
-  if (show_diskicon)
+  if (m_check_parm("-cdrom") > 0)
     {
-      if (m_check_parm("-cdrom") > 0)
-        {
-          disk_lump_name = ("STCDROM");
-        }
-      else
-        {
-          disk_lump_name = ("STDISK");
-        }
-
-      v_enable_loading_disk(disk_lump_name, SCREENWIDTH - LOADING_DISK_W,
-                            SCREENHEIGHT - LOADING_DISK_H);
+      disk_lump_name = ("STCDROM");
     }
+  else
+    {
+      disk_lump_name = ("STDISK");
+    }
+
+  v_enable_loading_disk(disk_lump_name, SCREENWIDTH - LOADING_DISK_W,
+                        SCREENHEIGHT - LOADING_DISK_H);
 }
+#endif
 
 static void d_bind_variables(void)
 {
@@ -383,7 +381,6 @@ static void d_bind_variables(void)
   m_bind_int_variable("vanilla_savegame_limit", &vanilla_savegame_limit);
   m_bind_int_variable("vanilla_demo_limit", &vanilla_demo_limit);
   m_bind_int_variable("show_endoom", &show_endoom);
-  m_bind_int_variable("show_diskicon", &show_diskicon);
 
   /* Multiplayer chat macros */
 
@@ -1325,7 +1322,9 @@ void d_doomloop(void)
   i_graphics_check_commandline();
   i_set_grab_mouse_callback(d_grab_mouse_callback);
   i_init_graphics();
+#ifdef CONFIG_GAMES_NXDOOM_SHOWDISKICON
   enable_loading_disk();
+#endif
 
   try_run_tics();
 
diff --git a/games/NXDoom/src/i_video.c b/games/NXDoom/src/i_video.c
index a8cd836c4..1280723e9 100644
--- a/games/NXDoom/src/i_video.c
+++ b/games/NXDoom/src/i_video.c
@@ -645,7 +645,9 @@ void i_finish_update(void)
 
   /* Draw disk icon before blit, if necessary. */
 
+#ifdef CONFIG_GAMES_NXDOOM_SHOWDISKICON
   v_draw_disk_icon();
+#endif
 
   if (palette_to_set)
     {
@@ -659,7 +661,9 @@ void i_finish_update(void)
 
   /* Restore background and undo the disk indicator, if it was drawn. */
 
+#ifdef CONFIG_GAMES_NXDOOM_SHOWDISKICON
   v_restore_disk_background();
+#endif
 }
 
 void i_read_screen(pixel_t *scr)
diff --git a/games/NXDoom/src/m_config.c b/games/NXDoom/src/m_config.c
index d4441f5ea..831e16948 100644
--- a/games/NXDoom/src/m_config.c
+++ b/games/NXDoom/src/m_config.c
@@ -719,14 +719,6 @@ static default_t extra_defaults_list[] =
 
   CONFIG_VARIABLE_INT(show_endoom),
 
-  /* @game doom strife
-   *
-   * If non-zero, a disk activity indicator is displayed when data is read
-   * from disk. If zero, the disk activity indicator is not displayed.
-   */
-
-  CONFIG_VARIABLE_INT(show_diskicon),
-
   /* If non-zero, save screenshots in PNG format. If zero, screenshots are
    * saved in PCX format, as Vanilla Doom does.
    */
@@ -1875,7 +1867,10 @@ static void save_default_collection(default_collection_t 
*collection)
   FILE *f;
 
   f = fopen(collection->filename, "w");
-  if (!f) return; /* can't write the file, but don't complain */
+  if (!f)
+    {
+      return; /* can't write the file, but don't complain */
+    }
 
   defaults = collection->defaults;
 
@@ -1895,77 +1890,79 @@ static void 
save_default_collection(default_collection_t *collection)
       chars_written = fprintf(f, "%s ", defaults[i].name);
 
       for (; chars_written < 30; ++chars_written)
-        fprintf(f, " ");
+        {
+          fprintf(f, " ");
+        }
 
       /* Print the value */
 
       switch (defaults[i].type)
         {
-        case DEFAULT_KEY:
-
-          /* use the untranslated version if we can, to reduce
-           * the possibility of screwing up the user's config
-           * file
-           */
-
-          v = *defaults[i].location.i;
+          case DEFAULT_KEY:
 
-          if (v == KEY_RSHIFT)
-            {
-              /* Special case: for shift, force scan code for
-               * right shift, as this is what Vanilla uses.
-               * This overrides the change check below, to fix
-               * configuration files made by old versions that
-               * mistakenly used the scan code for left shift.
-               */
-
-              v = 54;
-            }
-          else if (defaults[i].untranslated &&
-                   v == defaults[i].original_translated)
-            {
-              /* Has not been changed since the last time we read the config
-               * file.
-               */
+            /* use the untranslated version if we can, to reduce
+             * the possibility of screwing up the user's config
+             * file
+             */
 
-              v = defaults[i].untranslated;
-            }
-          else
-            {
-              /* search for a reverse mapping back to a scancode
-               * in the scantokey table
-               */
+            v = *defaults[i].location.i;
 
-              int s;
+            if (v == KEY_RSHIFT)
+              {
+                /* Special case: for shift, force scan code for
+                 * right shift, as this is what Vanilla uses.
+                 * This overrides the change check below, to fix
+                 * configuration files made by old versions that
+                 * mistakenly used the scan code for left shift.
+                 */
+
+                v = 54;
+              }
+            else if (defaults[i].untranslated &&
+                     v == defaults[i].original_translated)
+              {
+                /* Has not been changed since the last time we read the
+                 * config file.
+                 */
 
-              for (s = 0; s < 128; ++s)
-                {
-                  if (scantokey[s] == v)
-                    {
-                      v = s;
-                      break;
-                    }
-                }
-            }
+                v = defaults[i].untranslated;
+              }
+            else
+              {
+                /* search for a reverse mapping back to a scancode
+                 * in the scantokey table
+                 */
+
+                int s;
+
+                for (s = 0; s < 128; ++s)
+                  {
+                    if (scantokey[s] == v)
+                      {
+                        v = s;
+                        break;
+                      }
+                  }
+              }
 
-          fprintf(f, "%i", v);
-          break;
+            fprintf(f, "%i", v);
+            break;
 
-        case DEFAULT_INT:
-          fprintf(f, "%i", *defaults[i].location.i);
-          break;
+          case DEFAULT_INT:
+            fprintf(f, "%i", *defaults[i].location.i);
+            break;
 
-        case DEFAULT_INT_HEX:
-          fprintf(f, "0x%x", *defaults[i].location.i);
-          break;
+          case DEFAULT_INT_HEX:
+            fprintf(f, "0x%x", *defaults[i].location.i);
+            break;
 
-        case DEFAULT_FLOAT:
-          fprintf(f, "%f", *defaults[i].location.f);
-          break;
+          case DEFAULT_FLOAT:
+            fprintf(f, "%f", *defaults[i].location.f);
+            break;
 
-        case DEFAULT_STRING:
-          fprintf(f, "\"%s\"", *defaults[i].location.s);
-          break;
+          case DEFAULT_STRING:
+            fprintf(f, "\"%s\"", *defaults[i].location.s);
+            break;
         }
 
       fprintf(f, "\n");
@@ -1987,9 +1984,13 @@ static int parse_int_parameter(const char *strparm)
   int param;
 
   if (strparm[0] == '0' && strparm[1] == 'x')
-    sscanf(strparm + 2, "%x", (unsigned int *)&param);
+    {
+      sscanf(strparm + 2, "%x", (unsigned int *)&param);
+    }
   else
-    sscanf(strparm, "%i", &param);
+    {
+      sscanf(strparm, "%i", &param);
+    }
 
   return param;
 }
@@ -2002,77 +2003,77 @@ static void set_variable(default_t *def, const char 
*value)
 
   switch (def->type)
     {
-    case DEFAULT_STRING:
-      *def->location.s = m_string_duplicate(value);
-      break;
+      case DEFAULT_STRING:
+        *def->location.s = m_string_duplicate(value);
+        break;
 
-    case DEFAULT_INT:
-    case DEFAULT_INT_HEX:
-      *def->location.i = parse_int_parameter(value);
-      break;
+      case DEFAULT_INT:
+      case DEFAULT_INT_HEX:
+        *def->location.i = parse_int_parameter(value);
+        break;
 
-    case DEFAULT_KEY:
+      case DEFAULT_KEY:
 
-      /* translate scancodes read from config
-       * file (save the old value in untranslated)
-       */
+        /* translate scancodes read from config
+         * file (save the old value in untranslated)
+         */
 
-      intparm = parse_int_parameter(value);
-      def->untranslated = intparm;
-      if (intparm >= 0 && intparm < 128)
-        {
-          intparm = scantokey[intparm];
-        }
-      else
-        {
-          intparm = 0;
-        }
+        intparm = parse_int_parameter(value);
+        def->untranslated = intparm;
+        if (intparm >= 0 && intparm < 128)
+          {
+            intparm = scantokey[intparm];
+          }
+        else
+          {
+            intparm = 0;
+          }
 
-      def->original_translated = intparm;
-      *def->location.i = intparm;
-      break;
-
-    case DEFAULT_FLOAT:
-      {
-        /* Different locales use different decimal separators.
-         * However, the choice of the current locale isn't always
-         * under our own control. If the atof() function fails to
-         * parse the string representing the floating point number
-         * using the current locale's decimal separator, it will
-         * return 0, resulting in silent sound effects. To
-         * mitigate this, we replace the first non-digit,
-         * non-minus character in the string with the current
-         * locale's decimal separator before passing it to atof().
-         */
+        def->original_translated = intparm;
+        *def->location.i = intparm;
+        break;
 
-        struct lconv *lc = localeconv();
-        char dec;
-        char *str;
-        int i = 0;
+      case DEFAULT_FLOAT:
+        {
+          /* Different locales use different decimal separators.
+           * However, the choice of the current locale isn't always
+           * under our own control. If the atof() function fails to
+           * parse the string representing the floating point number
+           * using the current locale's decimal separator, it will
+           * return 0, resulting in silent sound effects. To
+           * mitigate this, we replace the first non-digit,
+           * non-minus character in the string with the current
+           * locale's decimal separator before passing it to atof().
+           */
 
-        dec = lc->decimal_point[0];
-        str = m_string_duplicate(value);
+          struct lconv *lc = localeconv();
+          char dec;
+          char *str;
+          int i = 0;
 
-        /* Skip sign indicators. */
+          dec = lc->decimal_point[0];
+          str = m_string_duplicate(value);
 
-        if (str[i] == '-' || str[i] == '+')
-          {
-            i++;
-          }
+          /* Skip sign indicators. */
 
-        for (; str[i] != '\0'; i++)
-          {
-            if (!isdigit(str[i]))
-              {
-                str[i] = dec;
-                break;
-              }
-          }
+          if (str[i] == '-' || str[i] == '+')
+            {
+              i++;
+            }
+
+          for (; str[i] != '\0'; i++)
+            {
+              if (!isdigit(str[i]))
+                {
+                  str[i] = dec;
+                  break;
+                }
+            }
 
-        *def->location.f = (float)atof(str);
-        free(str);
-      }
-      break;
+          *def->location.f = (float)atof(str);
+          free(str);
+        }
+        break;
     }
 }
 
@@ -2181,6 +2182,7 @@ static char *get_default_config_dir(void)
 
   char *result = CONFIG_GAMES_NXDOOM_PREFDIR "/";
   char *copy = m_string_duplicate(result);
+
   return copy;
 }
 
@@ -2480,6 +2482,7 @@ char *m_get_autoload_dir(const char *iwadname)
   if (autoload_path == NULL || strlen(autoload_path) == 0)
     {
       char *prefdir = CONFIG_GAMES_NXDOOM_PREFDIR "/";
+
       autoload_path = m_string_join(prefdir, "autoload", NULL);
     }
 
diff --git a/games/NXDoom/src/w_wad.c b/games/NXDoom/src/w_wad.c
index 88c75ada5..44a4f5829 100644
--- a/games/NXDoom/src/w_wad.c
+++ b/games/NXDoom/src/w_wad.c
@@ -252,6 +252,7 @@ wad_file_t *w_add_file(const char *filename)
   for (i = startlump; i < numlumps; ++i)
     {
       lumpinfo_t *lump_p = &filelumps[i - startlump];
+
       lump_p->wad_file = wad_file;
       lump_p->position = LONG(filerover->filepos);
       lump_p->size = LONG(filerover->size);
@@ -379,7 +380,9 @@ void w_read_lump(lumpindex_t lump, void *dest)
 
   l = lumpinfo[lump];
 
+#ifdef CONFIG_GAMES_NXDOOM_SHOWDISKICON
   v_begin_read(l->size);
+#endif
 
   c = w_read(l->wad_file, l->position, dest, l->size);
 
@@ -515,9 +518,13 @@ void w_profile(void)
         {
           block = (memblock_t *)((byte *)ptr - sizeof(memblock_t));
           if (block->tag < PU_PURGELEVEL)
-            ch = 'S';
+            {
+              ch = 'S';
+            }
           else
-            ch = 'P';
+            {
+              ch = 'P';
+            }
         }
 
       info[i][profilecount] = ch;

Reply via email to