changeset 2571:bb44c48cffac

Add helper function for getting C64 chargen ROM path from environment variable 'CHARGEN_ROM' and use it instead of the compile-time hardcoded value.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Mar 2022 23:23:05 +0200
parents 1559011d749f
children 92b93a12c014
files tools/64vw.c tools/gfxconv.c tools/lib64util.c tools/lib64util.h
diffstat 4 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tools/64vw.c	Wed Mar 02 00:31:27 2022 +0200
+++ b/tools/64vw.c	Wed Mar 02 23:23:05 2022 +0200
@@ -25,7 +25,7 @@
         optListOnly  = FALSE;
 size_t  noptFilenames1 = 0, noptFilenames2 = 0;
 char    **optFilenames = NULL;
-char    *optCharROMFilename = NULL;
+const char *optCharROMFilename = NULL;
 DMC64Palette *optC64Palette = NULL;
 char    *optC64PaletteFile = NULL;
 
@@ -78,7 +78,7 @@
     "Default character ROM file for this build is:\n"
     "  %s\n",
     SET_SKIP_AMOUNT,
-    DM_DEF_CHARGEN
+    dmGetChargenROMPath()
     );
 }
 
@@ -392,7 +392,7 @@
 
     // Check character ROM filename
     if (optCharROMFilename == NULL)
-        optCharROMFilename = DM_DEF_CHARGEN;
+        optCharROMFilename = dmGetChargenROMPath();
 
     // Attempt to read character ROM
     dmMsg(1, "Using character ROM file '%s'.\n",
--- a/tools/gfxconv.c	Wed Mar 02 00:31:27 2022 +0200
+++ b/tools/gfxconv.c	Wed Mar 02 23:23:05 2022 +0200
@@ -154,7 +154,7 @@
 int     optRemapNoMatchColor = -1;
 DMMapValue optRemapTable[DM_MAX_COLORS];
 int     optColorMap[D64_NCOLORS];
-char    *optCharROMFilename = NULL;
+const char *optCharROMFilename = NULL;
 DMC64Palette *optC64Palette = NULL;
 char    *optPaletteFile = NULL;
 DMPalette *optPaletteData = NULL;
@@ -248,7 +248,7 @@
     "Default C64 character ROM file for this build is:\n"
     "%s\n"
     "\n",
-    DM_DEF_CHARGEN
+    dmGetChargenROMPath()
     );
 }
 
@@ -3010,7 +3010,7 @@
                     {
                         // Check character ROM filename
                         if (optCharROMFilename == NULL)
-                            optCharROMFilename = DM_DEF_CHARGEN;
+                            optCharROMFilename = dmGetChargenROMPath();
 
                         // Attempt to read character ROM
                         dmMsg(1, "Using character ROM file '%s'.\n",
--- a/tools/lib64util.c	Wed Mar 02 00:31:27 2022 +0200
+++ b/tools/lib64util.c	Wed Mar 02 23:23:05 2022 +0200
@@ -8,6 +8,11 @@
 #include "lib64util.h"
 #include "dmfile.h"
 
+// Default character file ROM path, if not defined yet
+#ifndef DM_DEF_CHARGEN
+#define DM_DEF_CHARGEN   "/usr/local/lib64/vice/C64/chargen"
+#endif
+
 
 //
 // Some common C64 palettes
@@ -428,3 +433,14 @@
 
     return res;
 }
+
+
+const char *dmGetChargenROMPath()
+{
+    const char *path = getenv("CHARGEN_ROM");
+    if (path != NULL)
+        return path;
+    else
+        return DM_DEF_CHARGEN;
+}
+
--- a/tools/lib64util.h	Wed Mar 02 00:31:27 2022 +0200
+++ b/tools/lib64util.h	Wed Mar 02 23:23:05 2022 +0200
@@ -15,12 +15,6 @@
 #endif
 
 
-// Default character file ROM path, if not defined yet
-#ifndef DM_DEF_CHARGEN
-#define DM_DEF_CHARGEN   "/usr/local/lib64/vice/C64/chargen"
-#endif
-
-
 //
 // Global variables
 //
@@ -42,6 +36,8 @@
 
 int       dmHandleExternalPalette(const char *filename, DMPalette **ppal);
 
+const char *dmGetChargenROMPath();
+
 
 #ifdef __cplusplus
 }