From 178d29cf0c6002b31349739422a48fb0f7d81e7a Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 16 Mar 2024 00:51:23 +0100 Subject: [PATCH] Allow up to 256 frames per sprite --- src/lua_infolib.c | 6 +++--- src/p_pspr.h | 2 +- src/r_defs.h | 2 ++ src/r_picformats.h | 2 +- src/r_things.c | 20 ++++++++++---------- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 0bcbcc5b9..cff72deb4 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -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; } diff --git a/src/p_pspr.h b/src/p_pspr.h index be0d9f39e..5fb676763 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -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 diff --git a/src/r_defs.h b/src/r_defs.h index cb94dd6e5..da4dd2d70 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -976,6 +976,8 @@ typedef struct #endif } spriteframe_t; +#define MAXFRAMENUM 256 + // // A sprite definition: a number of animation frames. // diff --git a/src/r_picformats.h b/src/r_picformats.h index 3ee9805d8..098f927a5 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -100,7 +100,7 @@ typedef struct typedef struct { - spriteframepivot_t pivot[64]; + spriteframepivot_t pivot[MAXFRAMENUM]; boolean available; } spriteinfo_t; diff --git a/src/r_things.c b/src/r_things.c index 317aa6c56..4e60e913f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -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)