]> git.sur5r.net Git - cc65/commitdiff
Started to add koala output format.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 5 Mar 2012 20:30:25 +0000 (20:30 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 5 Mar 2012 20:30:25 +0000 (20:30 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5578 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/sp65/bitmap.c
src/sp65/bitmap.h
src/sp65/koala.c [new file with mode: 0644]
src/sp65/koala.h [new file with mode: 0644]
src/sp65/make/gcc.mak
src/sp65/make/watcom.mak

index 7b1cce64deadd6a1ffb0381f2398d270df4b2fa0..b9862c879445126366b56661d88ee568c0dccc76 100644 (file)
@@ -178,3 +178,19 @@ Pixel GetPixel (const Bitmap* B, unsigned X, unsigned Y)
 
 
 
+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);
+    }
+}
+
+
+
index 3f28ca9fc87f79c958291ba3da34f221d16f3813..4fe56f752e9b065589c84f30124b50217d9fef60 100644 (file)
@@ -126,6 +126,41 @@ Pixel GetPixel (const Bitmap* B, unsigned X, unsigned Y);
  * 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 */
diff --git a/src/sp65/koala.c b/src/sp65/koala.c
new file mode 100644 (file)
index 0000000..317ddbf
--- /dev/null
@@ -0,0 +1,71 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                  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");
+     }
+
+     
+
+
+
+
+}
+
+
+
diff --git a/src/sp65/koala.h b/src/sp65/koala.h
new file mode 100644 (file)
index 0000000..57ea86a
--- /dev/null
@@ -0,0 +1,69 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                  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
+
+
+
index d2bac974bd4244aba56debe5c505b2f14a646d8e..96607004f96c5eea69bc6a51805d500c9915ff4b 100644 (file)
@@ -30,6 +30,7 @@ OBJS =        asm.o           \
         error.o                \
         fileio.o        \
         input.o         \
+        koala.o         \
        main.o          \
         output.o        \
         palette.o       \
index 9642644d2076318757f6ebacddf1347657d63a8c..3b1307a847c5e2e5dade3a8d33d906da7f2c6bf0 100644 (file)
@@ -68,6 +68,7 @@ OBJS =  asm.obj         \
         error.obj      \
         fileio.obj      \
         input.obj       \
+        koala.obj       \
        main.obj        \
         output.obj      \
         palette.obj     \