--- /dev/null
+/*****************************************************************************/
+/* */
+/* convert.c */
+/* */
+/* Main target conversion module for the sp65 file and bitmap utility */
+/* */
+/* */
+/* */
+/* (C) 2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* sp65 */
+#include "convert.h"
+#include "koala.h"
+#include "vic2sprite.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+StrBuf* ConvertTo (const Bitmap* B, const Collection* A)
+/* Convert the bitmap B into some sort of other binary format. The output is
+ * stored in a string buffer (which is actually a dynamic char array) and
+ * returned. The actual output format is taken from the "format" attribute
+ * in the attribute collection A.
+ */
+{
+}
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* convert.h */
+/* */
+/* Main target conversion module for the sp65 file and bitmap utility */
+/* */
+/* */
+/* */
+/* (C) 2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef CONVERT_H
+#define CONVERT_H
+
+
+
+/* common */
+#include "coll.h"
+#include "strbuf.h"
+
+/* sp65 */
+#include "bitmap.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+StrBuf* ConvertTo (const Bitmap* B, const Collection* A);
+/* Convert the bitmap B into some sort of other binary format. The output is
+ * stored in a string buffer (which is actually a dynamic char array) and
+ * returned. The actual output format is taken from the "format" attribute
+ * in the attribute collection A.
+ */
+
+
+
+/* End of convert.h */
+
+#endif
+
+
+
/* sp65 */
#include "attr.h"
+#include "convert.h"
#include "error.h"
#include "input.h"
#include "output.h"
/* Bitmap first read */
static Bitmap* B;
-/* Bitmap last processed */
+/* Bitmap working copy */
static Bitmap* C;
+/* Output data from convertion */
+static StrBuf* D;
+
/*****************************************************************************/
"Usage: %s [options] file [options] [file]\n"
"Short options:\n"
" -V\t\t\t\tPrint the version number and exit\n"
+ " -c fmt[,attrlist]\t\tConvert into target format\n"
" -h\t\t\t\tHelp (this text)\n"
+ " -r file[,attrlist]\t\tRead an input file\n"
" -v\t\t\t\tIncrease verbosity\n"
+ " -w file[,attrlist]\t\tWrite the output to a file\n"
"\n"
"Long options:\n"
+ " --convert-to fmt[,attrlist]\tConvert into target format\n"
" --help\t\t\tHelp (this text)\n"
" --pop\t\t\t\tRestore the original loaded image\n"
" --read file[,attrlist]\tRead an input file\n"
" --slice x,y,w,h\t\tGenerate a slice from the loaded bitmap\n"
" --verbose\t\t\tIncrease verbosity\n"
" --version\t\t\tPrint the version number and exit\n"
- " --write file[,attrlist]\tWrite an output file\n",
+ " --write file[,attrlist]\tWrite the output to a file\n",
ProgName);
}
+static void SetOutputData (StrBuf* N)
+/* Delete the old output data and replace it by the given one. The new one
+ * may be NULL to clear it.
+ */
+{
+ /* Delete the old output data */
+ if (D != 0) {
+ FreeStrBuf (D);
+ }
+
+ /* Set the new one */
+ D = N;
+}
+
+
+
+static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg)
+/* Convert the bitmap into a target format */
+{
+ static const char* NameList[] = {
+ "format"
+ };
+
+ /* Parse the argument */
+ Collection* A = ParseAttrList (Arg, NameList, 2);
+
+ /* We must have a bitmap */
+ if (C == 0) {
+ Error ("No bitmap to convert");
+ }
+
+ /* Convert the bitmap */
+ SetOutputData (ConvertTo (C, A));
+
+ /* Delete the attribute list */
+ FreeCollection (A);
+}
+
+
+
static void OptHelp (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print usage information and exit */
/* Write the file */
WriteOutputFile (FileName, 0, OF);
+
+ /* Delete the attribute list */
+ FreeCollection (A);
}
{
/* Program long options */
static const LongOpt OptTab[] = {
+ { "--convert-to", 1, OptConvertTo },
{ "--help", 0, OptHelp },
{ "--pop", 0, OptPop },
{ "--read", 1, OptRead },
OptVersion (Arg, 0);
break;
+ case 'c':
+ OptConvertTo (Arg, GetArg (&I, 2));
+ break;
+
case 'h':
OptHelp (Arg, 0);
break;
OptVerbose (Arg, 0);
break;
+ case 'w':
+ OptWrite (Arg, GetArg (&I, 2));
+ break;
+
default:
UnknownOption (Arg);
break;
bin.o \
bitmap.o \
color.o \
- error.o \
+ convert.o \
+ error.o \
fileio.o \
input.o \
koala.o \
bin.obj \
bitmap.obj \
color.obj \
- error.obj \
+ convert.obj \
+ error.obj \
fileio.obj \
input.obj \
koala.obj \