Started to add koala output format.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5578 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,41 @@ Pixel GetPixel (const Bitmap* B, unsigned X, unsigned Y);
|
|||||||
* or a palette index, depending on the type of the bitmap.
|
* 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 */
|
/* End of bitmap.h */
|
||||||
|
|||||||
71
src/sp65/koala.c
Normal file
71
src/sp65/koala.c
Normal file
@@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
69
src/sp65/koala.h
Normal file
69
src/sp65/koala.h
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ OBJS = asm.o \
|
|||||||
error.o \
|
error.o \
|
||||||
fileio.o \
|
fileio.o \
|
||||||
input.o \
|
input.o \
|
||||||
|
koala.o \
|
||||||
main.o \
|
main.o \
|
||||||
output.o \
|
output.o \
|
||||||
palette.o \
|
palette.o \
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ OBJS = asm.obj \
|
|||||||
error.obj \
|
error.obj \
|
||||||
fileio.obj \
|
fileio.obj \
|
||||||
input.obj \
|
input.obj \
|
||||||
|
koala.obj \
|
||||||
main.obj \
|
main.obj \
|
||||||
output.obj \
|
output.obj \
|
||||||
palette.obj \
|
palette.obj \
|
||||||
|
|||||||
Reference in New Issue
Block a user