From c25048213788c5fa8fd2065fbd97d026110c281e Mon Sep 17 00:00:00 2001 From: karri Date: Tue, 6 Nov 2012 06:24:50 +0000 Subject: [PATCH] Add anchor point support git-svn-id: svn://svn.cc65.org/cc65/trunk@5917 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/sp65/lynxsprite.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/sp65/lynxsprite.c b/src/sp65/lynxsprite.c index 3250c0e0b..d1dff1284 100644 --- a/src/sp65/lynxsprite.c +++ b/src/sp65/lynxsprite.c @@ -33,6 +33,8 @@ +#include + /* 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", -- 2.39.5