From 4ea0eebb1e8340ee963488b1a0d41e7b8d43e6d5 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Thu, 23 May 2024 01:29:52 -0300 Subject: [PATCH] Add repeatcnt field to edge textures --- doc/specs/udmf_srb2.txt | 98 +++++++++++++++++++++-------------------- src/lua_maplib.c | 8 ++++ src/p_saveg.c | 33 ++++++++------ src/p_setup.c | 5 +++ src/r_defs.h | 1 + src/r_segs.c | 6 +-- 6 files changed, 88 insertions(+), 63 deletions(-) diff --git a/doc/specs/udmf_srb2.txt b/doc/specs/udmf_srb2.txt index e0862ac32..ea35d6775 100644 --- a/doc/specs/udmf_srb2.txt +++ b/doc/specs/udmf_srb2.txt @@ -1,5 +1,5 @@ =============================================================================== -Universal Doom Map Format Sonic Robo Blast 2 extensions v1.1 02.05.2024 +Universal Doom Map Format Sonic Robo Blast 2 extensions v1.1 23.05.2024 Copyright (c) 2024 Sonic Team Junior uses Universal Doom Map Format Specification v1.1 as a template, @@ -127,7 +127,7 @@ Sonic Robo Blast 2 defines the following standardized fields: texturebottom = ; // Lower texture. Default = "-". texturemiddle = ; // Middle texture. Default = "-". - repeatcnt = ; // Number of middle texture repetitions. Default = 0 + repeatcnt = ; // Number of middle texture repetitions. Default = 0. sector = ; // Sector index. No valid default. @@ -147,53 +147,57 @@ Sonic Robo Blast 2 defines the following standardized fields: clipmidtex = ; // Side's mid textures are clipped to floor and ceiling. wrapmidtex = ; // Side's mid textures are wrapped. - edge_top_upper_texture = ; // Top edge texture of the upper wall. Default = "-". - edge_top_upper_offsetx = ; // X offset for the top edge of the upper wall. Default = 0.0. - edge_top_upper_offsety = ; // Y offset for the top edge of the upper wall. Default = 0.0. - edge_top_upper_scalex = ; // X scale for the top edge of the upper wall. Default = 1.0. - edge_top_upper_scaley = ; // Y scale for the top edge of the upper wall. Default = 1.0. - edge_top_upper_noskew = ; // Disables skewing of the top edge of the upper wall. - edge_top_upper_noclip = ; // Top edge texture extends outside the upper wall (displays like a mid texture.) - edge_top_upper_wrap = ; // Top edge texture of the upper wall wraps. - edge_top_upper_alpha = ; // Translucency of this edge. Default is 1.0 - edge_top_upper_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", - // "reversesubtract", "modulate", or "fog". Default is "translucent". + edge_top_upper_texture = ; // Top edge texture of the upper wall. Default = "-". + edge_top_upper_offsetx = ; // X offset for the top edge of the upper wall. Default = 0.0. + edge_top_upper_offsety = ; // Y offset for the top edge of the upper wall. Default = 0.0. + edge_top_upper_scalex = ; // X scale for the top edge of the upper wall. Default = 1.0. + edge_top_upper_scaley = ; // Y scale for the top edge of the upper wall. Default = 1.0. + edge_top_upper_repeatcnt = ; // Number of texture repetitions. Default = 0. + edge_top_upper_noskew = ; // Disables skewing of the top edge of the upper wall. + edge_top_upper_noclip = ; // Top edge texture extends outside the 3D floor wall (displays like a mid texture.) + edge_top_upper_wrap = ; // Top edge texture of the upper wall wraps. + edge_top_upper_alpha = ; // Translucency of this edge. Default is 1.0 + edge_top_upper_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", + // "reversesubtract", "modulate", or "fog". Default is "translucent". - edge_top_lower_texture = ; // Bottom edge texture of the upper wall. Default = "-". - edge_top_lower_offsetx = ; // X offset for the bottom edge of the upper wall. Default = 0.0. - edge_top_lower_offsety = ; // Y offset for the bottom edge of the upper wall. Default = 0.0. - edge_top_lower_scalex = ; // X scale for the bottom edge of the upper wall. Default = 1.0. - edge_top_lower_scaley = ; // Y scale for the bottom edge of the upper wall. Default = 1.0. - edge_top_lower_noskew = ; // Disables skewing of the bottom edge of the upper wall. - edge_top_lower_noclip = ; // Bottom edge texture extends outside the upper wall (displays like a mid texture.) - edge_top_lower_wrap = ; // Bottom edge texture of the upper wall wraps. - edge_top_lower_alpha = ; // Translucency of this edge. Default is 1.0 - edge_top_lower_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", - // "reversesubtract", "modulate", or "fog". Default is "translucent". + edge_top_lower_texture = ; // Bottom edge texture of the upper wall. Default = "-". + edge_top_lower_offsetx = ; // X offset for the bottom edge of the upper wall. Default = 0.0. + edge_top_lower_offsety = ; // Y offset for the bottom edge of the upper wall. Default = 0.0. + edge_top_lower_scalex = ; // X scale for the bottom edge of the upper wall. Default = 1.0. + edge_top_lower_scaley = ; // Y scale for the bottom edge of the upper wall. Default = 1.0. + edge_top_lower_repeatcnt = ; // Number of texture repetitions. Default = 0. + edge_top_lower_noskew = ; // Disables skewing of the bottom edge of the upper wall. + edge_top_lower_noclip = ; // Bottom edge texture extends outside the 3D floor wall (displays like a mid texture.) + edge_top_lower_wrap = ; // Bottom edge texture of the upper wall wraps. + edge_top_lower_alpha = ; // Translucency of this edge. Default is 1.0 + edge_top_lower_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", + // "reversesubtract", "modulate", or "fog". Default is "translucent". - edge_bottom_upper_texture = ; // Top edge texture of the lower wall. Default = "-". - edge_bottom_upper_offsetx = ; // X offset for the top edge of the lower wall. Default = 0.0. - edge_bottom_upper_offsety = ; // Y offset for the top edge of the lower wall. Default = 0.0. - edge_bottom_upper_scalex = ; // X scale for the top edge of the lower wall. Default = 1.0. - edge_bottom_upper_scaley = ; // Y scale for the top edge of the lower wall. Default = 1.0. - edge_bottom_upper_noskew = ; // Disables skewing of the top edge of the lower wall. - edge_bottom_upper_noclip = ; // Top edge texture extends outside the lower wall (displays like a mid texture.) - edge_bottom_upper_wrap = ; // Top edge texture of the lower wall wraps. - edge_bottom_upper_alpha = ; // Translucency of this edge. Default is 1.0 - edge_bottom_upper_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", - // "reversesubtract", "modulate", or "fog". Default is "translucent". + edge_bottom_upper_texture = ; // Top edge texture of the lower wall. Default = "-". + edge_bottom_upper_offsetx = ; // X offset for the top edge of the lower wall. Default = 0.0. + edge_bottom_upper_offsety = ; // Y offset for the top edge of the lower wall. Default = 0.0. + edge_bottom_upper_scalex = ; // X scale for the top edge of the lower wall. Default = 1.0. + edge_bottom_upper_scaley = ; // Y scale for the top edge of the lower wall. Default = 1.0. + edge_bottom_upper_repeatcnt = ; // Number of texture repetitions. Default = 0. + edge_bottom_upper_noskew = ; // Disables skewing of the top edge of the lower wall. + edge_bottom_upper_noclip = ; // Top edge texture extends outside the 3D floor wall (displays like a mid texture.) + edge_bottom_upper_wrap = ; // Top edge texture of the lower wall wraps. + edge_bottom_upper_alpha = ; // Translucency of this edge. Default is 1.0 + edge_bottom_upper_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", + // "reversesubtract", "modulate", or "fog". Default is "translucent". - edge_bottom_lower_texture = ; // Bottom edge texture of the lower wall. Default = "-". - edge_bottom_lower_offsetx = ; // X offset for the bottom edge of the lower wall. Default = 0.0. - edge_bottom_lower_offsety = ; // Y offset for the bottom edge of the lower wall. Default = 0.0. - edge_bottom_lower_scalex = ; // X scale for the bottom edge of the lower wall. Default = 1.0. - edge_bottom_lower_scaley = ; // Y scale for the bottom edge of the lower wall. Default = 1.0. - edge_bottom_lower_noskew = ; // Disables skewing of the bottom edge of the lower wall. - edge_bottom_lower_noclip = ; // Bottom edge texture extends outside the lower wall (displays like a mid texture.) - edge_bottom_lower_wrap = ; // Bottom edge texture of the lower wall wraps. - edge_bottom_lower_alpha = ; // Translucency of this edge. Default is 1.0 - edge_bottom_lower_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", - // "reversesubtract", "modulate", or "fog". Default is "translucent". + edge_bottom_lower_texture = ; // Bottom edge texture of the lower wall. Default = "-". + edge_bottom_lower_offsetx = ; // X offset for the bottom edge of the lower wall. Default = 0.0. + edge_bottom_lower_offsety = ; // Y offset for the bottom edge of the lower wall. Default = 0.0. + edge_bottom_lower_scalex = ; // X scale for the bottom edge of the lower wall. Default = 1.0. + edge_bottom_lower_scaley = ; // Y scale for the bottom edge of the lower wall. Default = 1.0. + edge_bottom_lower_repeatcnt = ; // Number of texture repetitions. Default = 0. + edge_bottom_lower_noskew = ; // Disables skewing of the bottom edge of the lower wall. + edge_bottom_lower_noclip = ; // Bottom edge texture extends outside the 3D floor wall (displays like a mid texture.) + edge_bottom_lower_wrap = ; // Bottom edge texture of the lower wall wraps. + edge_bottom_lower_alpha = ; // Translucency of this edge. Default is 1.0 + edge_bottom_lower_renderstyle = ; // Render style of this edge. Can be "translucent", "add", "subtract", + // "reversesubtract", "modulate", or "fog". Default is "translucent". comment = ; // A comment. Implementors should attach no special // semantic meaning to this field. @@ -357,7 +361,7 @@ Sonic Robo Blast 2 defines the following standardized fields: Changelog ======================================= -1.1: 02.05.2024 +1.1: 23.05.2024 Added edge texture properties. Added clipmidtex property to lines and sides. Added wrapmidtex property to sides. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 21eb58523..378cdce81 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1485,6 +1485,7 @@ enum sideoverlay_e { sideoverlay_offsety, sideoverlay_scalex, sideoverlay_scaley, + sideoverlay_repeatcnt, sideoverlay_alpha, sideoverlay_blendmode, sideoverlay_noskew, @@ -1499,6 +1500,7 @@ static const char *const sideoverlay_opt[] = { "offsety", "scalex", "scaley", + "repeatcnt", "alpha", "blendmode", "noskew", @@ -1542,6 +1544,9 @@ static int sideoverlay_get(lua_State *L) case sideoverlay_scaley: lua_pushfixed(L, overlay->scaley); return 1; + case sideoverlay_repeatcnt: + lua_pushinteger(L, overlay->repeatcnt); + return 1; case sideoverlay_alpha: lua_pushfixed(L, overlay->alpha); return 1; @@ -1598,6 +1603,9 @@ static int sideoverlay_set(lua_State *L) case sideoverlay_scaley: overlay->scaley = luaL_checkfixed(L, 3); break; + case sideoverlay_repeatcnt: + overlay->repeatcnt = luaL_checkinteger(L, 3); + break; case sideoverlay_alpha: overlay->alpha = min(max(0, luaL_checkfixed(L, 3)), FRACUNIT); break; diff --git a/src/p_saveg.c b/src/p_saveg.c index 8980f6b5b..5d8ebea5b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -934,9 +934,10 @@ enum LD_EDGEOFFY = 1<<2, LD_EDGESCALEX = 1<<3, LD_EDGESCALEY = 1<<4, - LD_EDGEALPHA = 1<<5, - LD_EDGEBLEND = 1<<6, - LD_EDGEFLAGS = 1<<7 + LD_EDGEREPEAT = 1<<5, + LD_EDGEALPHA = 1<<6, + LD_EDGEBLEND = 1<<7, + LD_EDGEFLAGS = 1<<8 }; static boolean P_AreArgsEqual(const line_t *li, const line_t *spawnli) @@ -1370,9 +1371,9 @@ static void UnArchiveSectors(void) } } -static UINT8 GetSideEdgeDiff(const side_overlay_t *edge, const side_overlay_t *spawnedge) +static UINT16 GetSideEdgeDiff(const side_overlay_t *edge, const side_overlay_t *spawnedge) { - UINT8 diff = 0; + UINT16 diff = 0; if (edge->texture != spawnedge->texture) diff |= LD_EDGETEX; if (edge->offsetx != spawnedge->offsetx) @@ -1383,6 +1384,8 @@ static UINT8 GetSideEdgeDiff(const side_overlay_t *edge, const side_overlay_t *s diff |= LD_EDGESCALEX; if (edge->scaley != spawnedge->scaley) diff |= LD_EDGESCALEY; + if (edge->repeatcnt != spawnedge->repeatcnt) + diff |= LD_EDGEREPEAT; if (edge->alpha != spawnedge->alpha) diff |= LD_EDGEALPHA; if (edge->blendmode != spawnedge->blendmode) @@ -1392,13 +1395,13 @@ static UINT8 GetSideEdgeDiff(const side_overlay_t *edge, const side_overlay_t *s return diff; } -static void GetAllSideEdgeDiff(const side_t *si, const side_t *spawnsi, UINT8 edgediff[4]) +static void GetAllSideEdgeDiff(const side_t *si, const side_t *spawnsi, UINT16 edgediff[4]) { for (unsigned i = 0; i < NUM_WALL_OVERLAYS; i++) edgediff[i] = GetSideEdgeDiff(&si->overlays[i], &spawnsi->overlays[i]); } -static UINT32 GetSideDiff(const side_t *si, const side_t *spawnsi, UINT8 edgediff[4]) +static UINT32 GetSideDiff(const side_t *si, const side_t *spawnsi, UINT16 edgediff[4]) { UINT32 diff = 0; if (si->textureoffset != spawnsi->textureoffset) @@ -1451,9 +1454,9 @@ static UINT32 GetSideDiff(const side_t *si, const side_t *spawnsi, UINT8 edgedif return diff; } -static void ArchiveSideEdge(const side_overlay_t *edge, UINT8 diff) +static void ArchiveSideEdge(const side_overlay_t *edge, UINT16 diff) { - WRITEUINT8(save_p, diff); + WRITEUINT16(save_p, diff); if (diff & LD_EDGETEX) WRITEINT32(save_p, edge->texture); @@ -1465,6 +1468,8 @@ static void ArchiveSideEdge(const side_overlay_t *edge, UINT8 diff) WRITEFIXED(save_p, edge->scalex); if (diff & LD_EDGESCALEY) WRITEFIXED(save_p, edge->scaley); + if (diff & LD_EDGEREPEAT) + WRITEINT16(save_p, edge->repeatcnt); if (diff & LD_EDGEALPHA) WRITEFIXED(save_p, edge->alpha); if (diff & LD_EDGEBLEND) @@ -1473,7 +1478,7 @@ static void ArchiveSideEdge(const side_overlay_t *edge, UINT8 diff) WRITEUINT8(save_p, edge->flags); } -static void ArchiveSide(const side_t *si, UINT32 diff, UINT8 edgediff[4]) +static void ArchiveSide(const side_t *si, UINT32 diff, UINT16 edgediff[4]) { WRITEUINT32(save_p, diff); @@ -1536,8 +1541,8 @@ static void ArchiveLines(void) for (i = 0; i < numlines; i++, spawnli++, li++) { - UINT8 edgediff1[4] = { 0, 0, 0, 0 }; - UINT8 edgediff2[4] = { 0, 0, 0, 0 }; + UINT16 edgediff1[4] = { 0, 0, 0, 0 }; + UINT16 edgediff2[4] = { 0, 0, 0, 0 }; diff = diff2 = 0; side1diff = side2diff = 0; @@ -1634,7 +1639,7 @@ static void ArchiveLines(void) static void UnArchiveSideEdge(side_overlay_t *edge) { - UINT8 diff = READUINT8(save_p); + UINT16 diff = READUINT16(save_p); if (diff & LD_EDGETEX) edge->texture = READINT32(save_p); @@ -1646,6 +1651,8 @@ static void UnArchiveSideEdge(side_overlay_t *edge) edge->scalex = READFIXED(save_p); if (diff & LD_EDGESCALEY) edge->scaley = READFIXED(save_p); + if (diff & LD_EDGEREPEAT) + edge->repeatcnt = READINT16(save_p); if (diff & LD_EDGEALPHA) edge->alpha = READFIXED(save_p); if (diff & LD_EDGEBLEND) diff --git a/src/p_setup.c b/src/p_setup.c index f98141c69..81199beaa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1335,6 +1335,7 @@ static void P_InitSideEdges(side_t *sd) sd->overlays[j].texture = R_TextureNumForName("-"); sd->overlays[j].offsetx = sd->overlays[j].offsety = 0; sd->overlays[j].scalex = sd->overlays[j].scaley = FRACUNIT; + sd->overlays[j].repeatcnt = 0; sd->overlays[j].alpha = FRACUNIT; sd->overlays[j].blendmode = AST_COPY; sd->overlays[j].flags = 0; @@ -1938,6 +1939,8 @@ static void ParseTextmapSidedefOverlay(unsigned which, UINT32 i, const char *par overlay->scalex = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "scaley")) overlay->scaley = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "repeatcnt")) + overlay->repeatcnt = atol(val); else if (fastcmp(param, "alpha")) overlay->alpha = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "renderstyle")) @@ -2285,6 +2288,8 @@ static void WriteTextmapEdgeTexture(const char *prefix, unsigned i, side_t *side fprintf(f, "%s""scalex = %f;\n", prefix, FIXED_TO_FLOAT(side->overlays[i].scalex)); if (side->overlays[i].scaley != FRACUNIT) fprintf(f, "%s""scaley = %f;\n", prefix, FIXED_TO_FLOAT(side->overlays[i].scaley)); + if (side->overlays[i].repeatcnt != 0) + fprintf(f, "%s""repeatcnt = %d;\n", prefix, side->overlays[i].repeatcnt); if (side->overlays[i].alpha != FRACUNIT) fprintf(f, "%s""alpha = %f;\n", prefix, FIXED_TO_FLOAT(side->overlays[i].alpha)); if (side->overlays[i].blendmode != AST_COPY) diff --git a/src/r_defs.h b/src/r_defs.h index d9dd63dd3..03550612d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -649,6 +649,7 @@ typedef struct INT32 texture; fixed_t offsetx, offsety; fixed_t scalex, scaley; + INT16 repeatcnt; UINT8 blendmode; fixed_t alpha; UINT8 flags; diff --git a/src/r_segs.c b/src/r_segs.c index 43f4b35fe..a00cfc24c 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -123,10 +123,10 @@ transnum_t R_GetLinedefTransTable(fixed_t alpha) INT32 R_GetOverlayTextureRepeats(unsigned which, side_t *side, INT32 texnum, sector_t *sec_front, sector_t *sec_back, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) { - INT32 repeats = 1; + INT32 repeats = side->overlays[which].repeatcnt; - if (!(side->overlays[which].flags & SIDEOVERLAYFLAG_WRAP)) - return repeats; + if (repeats > 0 || (side->overlays[which].flags & SIDEOVERLAYFLAG_WRAP) == 0) + return max(repeats, 1); fixed_t high, low; fixed_t texheight = FixedDiv(textureheight[texnum], abs(side->overlays[which].scaley));