From: uz Date: Thu, 15 Mar 2012 17:02:12 +0000 (+0000) Subject: Pass the source image of the conversion down to the output function, so they X-Git-Tag: V2.14~447 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7260b3687abee0bcd6b643a8f88951316b75c8d0;p=cc65 Pass the source image of the conversion down to the output function, so they are able to output the image properties as comments. git-svn-id: svn://svn.cc65.org/cc65/trunk@5616 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/sp65/asm.c b/src/sp65/asm.c index 61c4fea61..882897a40 100644 --- a/src/sp65/asm.c +++ b/src/sp65/asm.c @@ -139,7 +139,7 @@ static const char* GetSegment (const Collection* A) -void WriteAsmFile (const StrBuf* Data, const Collection* A) +void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Write the contents of Data to the given file in assembler (ca65) format */ { FILE* F; @@ -147,6 +147,9 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A) unsigned Size; + /* Get the name of the image */ + const StrBuf* S = GetBitmapName (B); + /* Get the file name */ const char* Name = NeedAttrVal (A, "name", "write"); @@ -171,12 +174,16 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A) /* Write a readable header */ fprintf (F, ";\n" - "; This file was generated by %s %s\n" + "; This file was generated by %s %s from\n" + "; %.*s (%ux%u, %u colors%s)\n" ";\n" "\n", ProgName, - GetVersionAsString ()); - + GetVersionAsString (), + SB_GetLen (S), SB_GetConstBuf (S), + GetBitmapWidth (B), GetBitmapHeight (B), + GetBitmapColors (B), + BitmapIsIndexed (B)? ", indexed" : ""); /* If we have a segment defined, output a segment directive */ if (Segment) { diff --git a/src/sp65/asm.h b/src/sp65/asm.h index 03b9b2f8f..06d16802e 100644 --- a/src/sp65/asm.h +++ b/src/sp65/asm.h @@ -42,6 +42,9 @@ #include "coll.h" #include "strbuf.h" +/* sp65 */ +#include "bitmap.h" + /*****************************************************************************/ @@ -50,7 +53,7 @@ -void WriteAsmFile (const StrBuf* Data, const Collection* A); +void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B); /* Write the contents of Data to a file in assembler (ca65) format */ diff --git a/src/sp65/bin.c b/src/sp65/bin.c index d698ae4ba..fddb8320f 100644 --- a/src/sp65/bin.c +++ b/src/sp65/bin.c @@ -37,6 +37,9 @@ #include #include +/* common */ +#include "attrib.h" + /* sp65 */ #include "attr.h" #include "bin.h" @@ -50,7 +53,8 @@ -void WriteBinFile (const StrBuf* Data, const Collection* A) +void WriteBinFile (const StrBuf* Data, const Collection* A, + const Bitmap* B attribute ((unused))) /* Write the contents of Data to the given file in binary format */ { unsigned Size; diff --git a/src/sp65/bin.h b/src/sp65/bin.h index 363111889..476ae9a16 100644 --- a/src/sp65/bin.h +++ b/src/sp65/bin.h @@ -42,6 +42,9 @@ #include "coll.h" #include "strbuf.h" +/* sp65 */ +#include "bitmap.h" + /*****************************************************************************/ @@ -50,7 +53,7 @@ -void WriteBinFile (const StrBuf* Data, const Collection* A); +void WriteBinFile (const StrBuf* Data, const Collection* A, const Bitmap* B); /* Write the contents of Data to a file in binary format */ diff --git a/src/sp65/c.c b/src/sp65/c.c index 50f9bc431..fea720f7b 100644 --- a/src/sp65/c.c +++ b/src/sp65/c.c @@ -125,7 +125,7 @@ static const char* GetIdentifier (const Collection* A) -void WriteCFile (const StrBuf* Data, const Collection* A) +void WriteCFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Write the contents of Data to a file in C format */ { FILE* F; @@ -133,6 +133,9 @@ void WriteCFile (const StrBuf* Data, const Collection* A) unsigned Size; + /* Get the name of the image */ + const StrBuf* S = GetBitmapName (B); + /* Get the file name */ const char* Name = NeedAttrVal (A, "name", "write"); @@ -154,11 +157,16 @@ void WriteCFile (const StrBuf* Data, const Collection* A) /* Write a readable header */ fprintf (F, "/*\n" - " * This file was generated by %s %s\n" + " * This file was generated by %s %s from\n" + " * %.*s (%ux%u, %u colors%s)\n" " */\n" "\n", ProgName, - GetVersionAsString ()); + GetVersionAsString (), + SB_GetLen (S), SB_GetConstBuf (S), + GetBitmapWidth (B), GetBitmapHeight (B), + GetBitmapColors (B), + BitmapIsIndexed (B)? ", indexed" : ""); /* Output the declaration and identifier */ diff --git a/src/sp65/c.h b/src/sp65/c.h index 8b32247a0..8cf763144 100644 --- a/src/sp65/c.h +++ b/src/sp65/c.h @@ -42,6 +42,9 @@ #include "coll.h" #include "strbuf.h" +/* sp65 */ +#include "bitmap.h" + /*****************************************************************************/ @@ -50,7 +53,7 @@ -void WriteCFile (const StrBuf* Data, const Collection* A); +void WriteCFile (const StrBuf* Data, const Collection* A, const Bitmap* B); /* Write the contents of Data to a file in C format */ diff --git a/src/sp65/main.c b/src/sp65/main.c index 313694ad7..a776bf9fb 100644 --- a/src/sp65/main.c +++ b/src/sp65/main.c @@ -303,7 +303,7 @@ static void OptWrite (const char* Opt attribute ((unused)), const char* Arg) Collection* A = ParseAttrList (Arg, NameList, 2); /* Write the file */ - WriteOutputFile (D, A); + WriteOutputFile (D, A, C); /* Delete the attribute list */ FreeAttrList (A); diff --git a/src/sp65/output.c b/src/sp65/output.c index 40a709103..ac6f3db92 100644 --- a/src/sp65/output.c +++ b/src/sp65/output.c @@ -67,7 +67,7 @@ typedef struct OutputFormatDesc OutputFormatDesc; struct OutputFormatDesc { /* Write routine */ - void (*Write) (const StrBuf*, const Collection*); + void (*Write) (const StrBuf*, const Collection*, const Bitmap*); }; @@ -104,10 +104,12 @@ static const FileId FormatTable[] = { -void WriteOutputFile (const StrBuf* Data, const Collection* A) +void WriteOutputFile (const StrBuf* Data, const Collection* A, const Bitmap* B) /* Write the contents of Data to a file. Format, file name etc. must be given * as attributes in A. If no format is given, the function tries to autodetect - * it by using the extension of the file name. + * it by using the extension of the file name. The bitmap passed to the + * function is the bitmap used as source of the conversion. It may be used to + * determine the bitmap properties for documentation purposes. */ { const FileId* F; @@ -136,7 +138,7 @@ void WriteOutputFile (const StrBuf* Data, const Collection* A) } /* Call the format specific write */ - OutputFormatTable[F->Id].Write (Data, A); + OutputFormatTable[F->Id].Write (Data, A, B); } diff --git a/src/sp65/output.h b/src/sp65/output.h index 2c2bbb056..6d3b4c16b 100644 --- a/src/sp65/output.h +++ b/src/sp65/output.h @@ -41,6 +41,9 @@ /* common */ #include "strbuf.h" +/* sp65 */ +#include "bitmap.h" + /*****************************************************************************/ @@ -49,10 +52,12 @@ -void WriteOutputFile (const StrBuf* Data, const Collection* A); +void WriteOutputFile (const StrBuf* Data, const Collection* A, const Bitmap* B); /* Write the contents of Data to a file. Format, file name etc. must be given * as attributes in A. If no format is given, the function tries to autodetect - * it by using the extension of the file name. + * it by using the extension of the file name. The bitmap passed to the + * function is the bitmap used as source of the conversion. It may be used to + * determine the bitmap properties for documentation purposes. */