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:
@@ -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 */
|
/* Write the contents of Data to the given file in assembler (ca65) format */
|
||||||
{
|
{
|
||||||
FILE* F;
|
FILE* F;
|
||||||
@@ -147,6 +147,9 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A)
|
|||||||
unsigned Size;
|
unsigned Size;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get the name of the image */
|
||||||
|
const StrBuf* S = GetBitmapName (B);
|
||||||
|
|
||||||
/* Get the file name */
|
/* Get the file name */
|
||||||
const char* Name = NeedAttrVal (A, "name", "write");
|
const char* Name = NeedAttrVal (A, "name", "write");
|
||||||
|
|
||||||
@@ -171,12 +174,16 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A)
|
|||||||
/* Write a readable header */
|
/* Write a readable header */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
";\n"
|
";\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"
|
||||||
"\n",
|
"\n",
|
||||||
ProgName,
|
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 we have a segment defined, output a segment directive */
|
||||||
if (Segment) {
|
if (Segment) {
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
#include "strbuf.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 */
|
/* Write the contents of Data to a file in assembler (ca65) format */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "attrib.h"
|
||||||
|
|
||||||
/* sp65 */
|
/* sp65 */
|
||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
#include "bin.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 */
|
/* Write the contents of Data to the given file in binary format */
|
||||||
{
|
{
|
||||||
unsigned Size;
|
unsigned Size;
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
#include "strbuf.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 */
|
/* Write the contents of Data to a file in binary format */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
14
src/sp65/c.c
14
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 */
|
/* Write the contents of Data to a file in C format */
|
||||||
{
|
{
|
||||||
FILE* F;
|
FILE* F;
|
||||||
@@ -133,6 +133,9 @@ void WriteCFile (const StrBuf* Data, const Collection* A)
|
|||||||
unsigned Size;
|
unsigned Size;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get the name of the image */
|
||||||
|
const StrBuf* S = GetBitmapName (B);
|
||||||
|
|
||||||
/* Get the file name */
|
/* Get the file name */
|
||||||
const char* Name = NeedAttrVal (A, "name", "write");
|
const char* Name = NeedAttrVal (A, "name", "write");
|
||||||
|
|
||||||
@@ -154,11 +157,16 @@ void WriteCFile (const StrBuf* Data, const Collection* A)
|
|||||||
/* Write a readable header */
|
/* Write a readable header */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"/*\n"
|
"/*\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"
|
||||||
"\n",
|
"\n",
|
||||||
ProgName,
|
ProgName,
|
||||||
GetVersionAsString ());
|
GetVersionAsString (),
|
||||||
|
SB_GetLen (S), SB_GetConstBuf (S),
|
||||||
|
GetBitmapWidth (B), GetBitmapHeight (B),
|
||||||
|
GetBitmapColors (B),
|
||||||
|
BitmapIsIndexed (B)? ", indexed" : "");
|
||||||
|
|
||||||
|
|
||||||
/* Output the declaration and identifier */
|
/* Output the declaration and identifier */
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
#include "strbuf.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 */
|
/* Write the contents of Data to a file in C format */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ static void OptWrite (const char* Opt attribute ((unused)), const char* Arg)
|
|||||||
Collection* A = ParseAttrList (Arg, NameList, 2);
|
Collection* A = ParseAttrList (Arg, NameList, 2);
|
||||||
|
|
||||||
/* Write the file */
|
/* Write the file */
|
||||||
WriteOutputFile (D, A);
|
WriteOutputFile (D, A, C);
|
||||||
|
|
||||||
/* Delete the attribute list */
|
/* Delete the attribute list */
|
||||||
FreeAttrList (A);
|
FreeAttrList (A);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ typedef struct OutputFormatDesc OutputFormatDesc;
|
|||||||
struct OutputFormatDesc {
|
struct OutputFormatDesc {
|
||||||
|
|
||||||
/* Write routine */
|
/* 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
|
/* 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
|
* 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;
|
const FileId* F;
|
||||||
@@ -136,7 +138,7 @@ void WriteOutputFile (const StrBuf* Data, const Collection* A)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Call the format specific write */
|
/* Call the format specific write */
|
||||||
OutputFormatTable[F->Id].Write (Data, A);
|
OutputFormatTable[F->Id].Write (Data, A, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#include "strbuf.h"
|
#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
|
/* 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
|
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user