+unsigned GetBitmapColors (const Bitmap* B)
+/* Get the number of colors in an image. The function will return the number
+ * of palette entries for indexed bitmaps and 2^24 for non indexed bitmaps.
+ */
+{
+ switch (B->Type) {
+ case bmMonochrome: return 2;
+ case bmIndexed: return B->Pal->Count;
+ case bmRGB:
+ case bmRGBA: return (1U << 24);
+ default: Internal ("Unknown bitmap type %u", B->Type);
+ }
+}
+
+
+
* or a palette index, depending on the type of the bitmap.
*/
+#if defined(HAVE_INLINE)
+INLINE BitmapType GetBitmapType (const Bitmap* B)
+/* Get the type of a bitmap */
+{
+ return B->Type;
+}
+#else
+# define GetBitmapType(B) ((B)->Type)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned GetBitmapWidth (const Bitmap* B)
+/* Get the width of a bitmap */
+{
+ return B->Width;
+}
+#else
+# define GetBitmapWidth(B) ((B)->Width)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned GetBitmapHeight (const Bitmap* B)
+/* Get the height of a bitmap */
+{
+ return B->Height;
+}
+#else
+# define GetBitmapHeight(B) ((B)->Height)
+#endif
+
+unsigned GetBitmapColors (const Bitmap* B);
+/* Get the number of colors in an image. The function will return the number
+ * of palette entries for indexed bitmaps and 2^24 for non indexed bitmaps.
+ */
+
/* End of bitmap.h */
--- /dev/null
+/*****************************************************************************/
+/* */
+/* koala.c */
+/* */
+/* Koala format backend for the sp65 sprite 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 "koala.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+StrBuf* GenKoala (const Bitmap* B, const Collection* A)
+/* Generate binary output in koala format for the bitmap B. The output is
+ * stored in a string buffer (which is actually a dynamic char array) and
+ * returned.
+ */
+{
+ /* Koala pictures are always 160x200 in size with 16 colors */
+ if (GetBitmapType (B) != bmIndexed ||
+ GetBitmapColors (B) > 16 ||
+ GetBitmapHeight (B) != 200 ||
+ GetBitmapWidth (B) != 160) {
+
+ Error ("Bitmaps converted to koala format must be in indexed mode "
+ "with 16 colors max and a size of 160x200");
+ }
+
+
+
+
+
+
+}
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* koala.h */
+/* */
+/* Koala format backend for the sp65 sprite 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 KOALA_H
+#define KOALA_H
+
+
+
+/* common */
+#include "coll.h"
+#include "strbuf.h"
+
+/* sp65 */
+#include "bitmap.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+StrBuf* GenKoala (const Bitmap* B, const Collection* A);
+/* Generate binary output in koala format for the bitmap B. The output is
+ * stored in a string buffer (which is actually a dynamic char array) and
+ * returned.
+ */
+
+
+
+/* End of koala.h */
+
+#endif
+
+
+
error.o \
fileio.o \
input.o \
+ koala.o \
main.o \
output.o \
palette.o \
error.obj \
fileio.obj \
input.obj \
+ koala.obj \
main.obj \
output.obj \
palette.obj \