]> git.sur5r.net Git - cc65/blobdiff - src/sp65/main.c
No copyright message here.
[cc65] / src / sp65 / main.c
index a6b63ce2017cf3579b72a6b500ae1bc3af1d63ba..ec3223c08bea4ba818beed3a77b77c948e589f68 100644 (file)
@@ -161,6 +161,26 @@ static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg)
 
 
 
+static void OptDumpPalette (const char* Opt attribute ((unused)),
+                            const char* Arg attribute ((unused)))
+/* Dump the palette of the current work bitmap */
+{
+    /* We must have a bitmap ... */
+    if (C == 0) {
+        Error ("No bitmap");
+    }
+
+    /* ... which must be indexed */
+    if (!BitmapIsIndexed (C)) {
+        Error ("Current bitmap is not indexed");
+    }
+
+    /* Dump the palette */
+    DumpPalette (stdout, GetBitmapPalette (C));
+}
+
+
+
 static void OptHelp (const char* Opt attribute ((unused)),
                     const char* Arg attribute ((unused)))
 /* Print usage information and exit */
@@ -264,9 +284,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
                        const char* Arg attribute ((unused)))
 /* Print the assembler version */
 {
-    fprintf (stderr,
-                    "%s V%s - (C) Copyright 2012, Ullrich von Bassewitz\n",
-                    ProgName, GetVersionAsString ());
+    fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
 }
 
 
@@ -282,8 +300,13 @@ static void OptWrite (const char* Opt attribute ((unused)), const char* Arg)
     /* Parse the argument */
     Collection* A = ParseAttrList (Arg, NameList, 2);
 
+    /* We must have output data */
+    if (D == 0) {
+        Error ("No conversion, so there's nothing to write");
+    }
+
     /* Write the file */
-    WriteOutputFile (D, A);
+    WriteOutputFile (D, A, C);
 
     /* Delete the attribute list */
     FreeAttrList (A);
@@ -297,6 +320,7 @@ int main (int argc, char* argv [])
     /* Program long options */
     static const LongOpt OptTab[] = {
         { "--convert-to",       1,      OptConvertTo            },
+        { "--dump-palette",     0,      OptDumpPalette          },
        { "--help",             0,      OptHelp                 },
         { "--list-conversions", 0,      OptListConversions      },
         { "--pop",              0,      OptPop                  },
@@ -373,6 +397,11 @@ int main (int argc, char* argv [])
        ++I;
     }
 
+    /* Cleanup data */
+    SetWorkBitmap (C);
+    FreeBitmap (B);
+    FreeStrBuf (D);
+
     /* Success */
     return EXIT_SUCCESS;
 }