1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-11 05:29:33 +00:00

Add anchor point support

git-svn-id: svn://svn.cc65.org/cc65/trunk@5917 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
karri 2012-11-06 06:24:50 +00:00
parent 5b479a4f51
commit c250482137

View File

@ -33,6 +33,8 @@
#include <stdlib.h>
/* common */
#include "attrib.h"
#include "print.h"
@ -86,6 +88,32 @@ static enum Mode GetMode (const Collection* A)
}
static unsigned GetActionPointX (const Collection* A)
/* Return the sprite mode from the attribute collection A */
{
/* Check for a action point x attribute */
const char* ActionPointX = GetAttrVal (A, "ax");
if (ActionPointX) {
return atoi(ActionPointX);
} else {
return 0;
}
}
static unsigned GetActionPointY (const Collection* A)
/* Return the sprite mode from the attribute collection A */
{
/* Check for a action point y attribute */
const char* ActionPointY = GetAttrVal (A, "ay");
if (ActionPointY) {
return atoi(ActionPointY);
} else {
return 0;
}
}
static void encodeSprite(StrBuf *D, enum Mode M, char ColorBits, char ColorMask, char LineBuffer[512],
int i, int LastOpaquePixel) {
/*
@ -218,9 +246,15 @@ StrBuf* GenLynxSprite (const Bitmap* B, const Collection* A)
char ColorBits;
char ColorMask;
/* Anchor point of the sprite */
OX = 0;
OY = 0;
/* Action point of the sprite */
OX = GetActionPointX (A);
OY = GetActionPointY (A);
if (OX >= GetBitmapWidth (B)) {
Error ("Action point X cannot be larger than bitmap width");
}
if (OY >= GetBitmapHeight (B)) {
Error ("Action point Y cannot be larger than bitmap height");
}
/* Output the image properties */
Print (stdout, 1, "Image is %ux%u with %u colors%s\n",