Allow up to 256 frames per sprite

This commit is contained in:
LJ Sonic 2024-03-16 00:51:23 +01:00
parent 99a9e5fcc9
commit 178d29cf0c
5 changed files with 17 additions and 15 deletions

View file

@ -359,8 +359,8 @@ static int PopPivotTable(spriteinfo_t *info, lua_State *L, int stk)
default:
TYPEERROR("pivot frame", LUA_TNUMBER, lua_type(L, stk+1));
}
if ((idx < 0) || (idx >= 64))
return luaL_error(L, "pivot frame %d out of range (0 - %d)", idx, 63);
if ((idx < 0) || (idx >= MAXFRAMENUM))
return luaL_error(L, "pivot frame %d out of range (0 - %d)", idx, MAXFRAMENUM - 1);
// the values in pivot[] are also tables
if (PopPivotSubTable(info->pivot, L, stk+2, idx))
info->available = true;
@ -555,7 +555,7 @@ static int pivotlist_set(lua_State *L)
static int pivotlist_num(lua_State *L)
{
lua_pushinteger(L, 64);
lua_pushinteger(L, MAXFRAMENUM);
return 1;
}

View file

@ -35,7 +35,7 @@
#pragma interface
#endif
/// \brief Frame flags: only the frame number - 0 to 256 (Frames from 0 to 63, Sprite2 number uses 0 to 127 plus FF_SPR2SUPER)
/// \brief Frame flags: only the frame number - 0 to 256 (Frames from 0 to 255, Sprite2 number uses 0 to 127 plus FF_SPR2SUPER)
#define FF_FRAMEMASK 0xff
/// \brief Frame flags - SPR2: Super sprite2

View file

@ -976,6 +976,8 @@ typedef struct
#endif
} spriteframe_t;
#define MAXFRAMENUM 256
//
// A sprite definition: a number of animation frames.
//

View file

@ -100,7 +100,7 @@ typedef struct
typedef struct
{
spriteframepivot_t pivot[64];
spriteframepivot_t pivot[MAXFRAMENUM];
boolean available;
} spriteinfo_t;

View file

@ -77,7 +77,7 @@ spriteinfo_t spriteinfo[NUMSPRITES];
spritedef_t *sprites;
size_t numsprites;
static spriteframe_t sprtemp[64];
static spriteframe_t sprtemp[MAXFRAMENUM];
static size_t maxframe;
static const char *spritename;
@ -248,9 +248,9 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
static boolean GetFramesAndRotationsFromShortLumpName(
const char *name,
UINT8 *ret_frame,
INT32 *ret_frame,
UINT8 *ret_rotation,
UINT8 *ret_frame2,
INT32 *ret_frame2,
UINT8 *ret_rotation2
)
{
@ -273,7 +273,7 @@ static boolean GetFramesAndRotationsFromShortLumpName(
}
else
{
*ret_frame2 = 255;
*ret_frame2 = -1;
*ret_rotation2 = 255;
}
@ -282,9 +282,9 @@ static boolean GetFramesAndRotationsFromShortLumpName(
static boolean GetFramesAndRotationsFromLongLumpName(
const char *name,
UINT8 *ret_frame,
INT32 *ret_frame,
UINT8 *ret_rotation,
UINT8 *ret_frame2,
INT32 *ret_frame2,
UINT8 *ret_rotation2
)
{
@ -305,10 +305,10 @@ static boolean GetFramesAndRotationsFromLongLumpName(
*ret_frame = atoi(framepart);
*ret_rotation = R_Char2Rotation(*(underscore + 1));
if (*ret_frame >= 64 || *ret_rotation == 255)
if (*ret_frame >= MAXFRAMENUM || *ret_rotation == 255)
return false;
*ret_frame2 = 255;
*ret_frame2 = -1;
*ret_rotation2 = 255;
return true;
@ -404,7 +404,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
{
INT16 width, height;
INT16 topoffset, leftoffset;
UINT8 frame, frame2;
INT32 frame, frame2;
UINT8 rotation, rotation2;
boolean good = longname ?
@ -443,7 +443,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
//----------------------------------------------------
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0);
if (frame2 != 255)
if (frame2 != -1)
R_InstallSpriteLump(wadnum, l, numspritelumps, frame2, rotation2, 1);
if (++numspritelumps >= max_spritelumps)