1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 06:30:16 +00:00

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
This commit is contained in:
uz 2012-03-15 17:02:12 +00:00
parent fbbf7e50d2
commit 7260b3687a
9 changed files with 53 additions and 18 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -37,6 +37,9 @@
#include <stdio.h>
#include <string.h>
/* 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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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);

View File

@ -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);
}

View File

@ -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.
*/