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",