Skip to content

Commit

Permalink
- SW: eliminated all SPRITE_TAG# macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 12, 2021
1 parent b1ac1ad commit a358cf8
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 75 deletions.
52 changes: 27 additions & 25 deletions source/games/sw/src/_polymost.cpp
Expand Up @@ -106,24 +106,25 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG3(i) == 0)
auto sp = &sprite[i];
if (SP_TAG3(sp) == 0)
{
// back up ceilingpicnum and ceilingstat
SPRITE_TAG5(i) = sector[sprite[i].sectnum].ceilingpicnum;
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG2(i);
SPRITE_TAG4(i) = sector[sprite[i].sectnum].ceilingstat;
//SET(sector[sprite[i].sectnum].ceilingstat, ((int)SPRITE_TAG7(i))<<7);
SET(sector[sprite[i].sectnum].ceilingstat, SPRITE_TAG6(i));
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
SP_TAG5(sp) = sector[sp->sectnum].ceilingpicnum;
sector[sp->sectnum].ceilingpicnum = SP_TAG2(sp);
SP_TAG4(sp) = sector[sprite[i].sectnum].ceilingstat;
//SET(sp->sectnum].ceilingstat, ((int)SP_TAG7(sp))<<7);
SET(sector[sp->sectnum].ceilingstat, SP_TAG6(sp));
RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX);
}
else if (SPRITE_TAG3(i) == 1)
else if (SP_TAG3(sp) == 1)
{
SPRITE_TAG5(i) = sector[sprite[i].sectnum].floorpicnum;
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG2(i);
SPRITE_TAG4(i) = sector[sprite[i].sectnum].floorstat;
//SET(sector[sprite[i].sectnum].floorstat, ((int)SPRITE_TAG7(i))<<7);
SET(sector[sprite[i].sectnum].floorstat, SPRITE_TAG6(i));
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
SP_TAG5(sp) = sector[sp->sectnum].floorpicnum;
sector[sp->sectnum].floorpicnum = SP_TAG2(sp);
SP_TAG4(sp) = sector[sp->sectnum].floorstat;
//SET(sector[sp->sectnum].floorstat, ((int)SP_TAG7(sp))<<7);
SET(sector[sp->sectnum].floorstat, SP_TAG6(sp));
RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX);
}
}

Expand All @@ -132,26 +133,27 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short
it.Reset(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
auto sp = &sprite[i];
// manually set gotpic
if (gotsector[sprite[i].sectnum])
if (gotsector[sp->sectnum])
{
setgotpic(FAF_MIRROR_PIC);
}

if (SPRITE_TAG3(i) == 0)
if (SP_TAG3(sp) == 0)
{
// restore ceilingpicnum and ceilingstat
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG5(i);
sector[sprite[i].sectnum].ceilingstat = SPRITE_TAG4(i);
//RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_TYPE_MASK);
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
sector[sp->sectnum].ceilingpicnum = SP_TAG5(sp);
sector[sp->sectnum].ceilingstat = SP_TAG4(sp);
//RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_TYPE_MASK);
RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX);
}
else if (SPRITE_TAG3(i) == 1)
else if (SP_TAG3(sp) == 1)
{
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG5(i);
sector[sprite[i].sectnum].floorstat = SPRITE_TAG4(i);
//RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_TYPE_MASK);
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
sector[sp->sectnum].floorpicnum = SP_TAG5(sp);
sector[sp->sectnum].floorstat = SP_TAG4(sp);
//RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_TYPE_MASK);
RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion source/games/sw/src/break.cpp
Expand Up @@ -540,7 +540,8 @@ short FindBreakSpriteMatch(short match)
StatIterator it(STAT_BREAKABLE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG2(i) == match && sprite[i].picnum == ST1)
auto sp = &sprite[i];
if (SP_TAG2(sp) == match && sp->picnum == ST1)
{
return i;
}
Expand Down
3 changes: 2 additions & 1 deletion source/games/sw/src/cache.cpp
Expand Up @@ -63,7 +63,8 @@ void PreCacheOverride(void)
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
int j = SPRITE_TAG2(i);
auto sp = &sprite[i];
int j = SP_TAG2(sp);
if(j >= 0 && j <= MAXTILES)
markTileForPrecache(j, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/sw/src/copysect.cpp
Expand Up @@ -128,8 +128,8 @@ void CopySectorMatch(short match)
{
src_sp = &sprite[ss];

if (SP_TAG2(src_sp) == SPRITE_TAG2(ed) &&
SP_TAG3(src_sp) == SPRITE_TAG3(ed))
if (SP_TAG2(src_sp) == SP_TAG2(dest_sp) &&
SP_TAG3(src_sp) == SP_TAG3(dest_sp))
{
int src_move;
ssectp = &sector[src_sp->sectnum];
Expand Down
50 changes: 26 additions & 24 deletions source/games/sw/src/draw.cpp
Expand Up @@ -1404,24 +1404,25 @@ void UpdateWallPortalState()
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG3(i) == 0)
auto sp = &sprite[i];
if (SP_TAG3(sp) == 0)
{
// back up ceilingpicnum and ceilingstat
SPRITE_TAG5(i) = sector[sprite[i].sectnum].ceilingpicnum;
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG2(i);
SPRITE_TAG4(i) = sector[sprite[i].sectnum].ceilingstat;
//SET(sector[sprite[i].sectnum].ceilingstat, ((int)SPRITE_TAG7(i))<<7);
SET(sector[sprite[i].sectnum].ceilingstat, SPRITE_TAG6(i));
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
SP_TAG5(sp) = sector[sp->sectnum].ceilingpicnum;
sector[sp->sectnum].ceilingpicnum = SP_TAG2(sp);
SP_TAG4(sp) = sector[sp->sectnum].ceilingstat;
//SET(sector[sp->sectnum].ceilingstat, ((int)SP_TAG7(sp))<<7);
SET(sector[sp->sectnum].ceilingstat, SP_TAG6(sp));
RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX);
}
else if (SPRITE_TAG3(i) == 1)
else if (SP_TAG3(sp) == 1)
{
SPRITE_TAG5(i) = sector[sprite[i].sectnum].floorpicnum;
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG2(i);
SPRITE_TAG4(i) = sector[sprite[i].sectnum].floorstat;
//SET(sector[sprite[i].sectnum].floorstat, ((int)SPRITE_TAG7(i))<<7);
SET(sector[sprite[i].sectnum].floorstat, SPRITE_TAG6(i));
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
SP_TAG5(sp) = sector[sp->sectnum].floorpicnum;
sector[sp->sectnum].floorpicnum = SP_TAG2(sp);
SP_TAG4(sp) = sector[sp->sectnum].floorstat;
//SET(sector[sp->sectnum].floorstat, ((int)SP_TAG7(sp))<<7);
SET(sector[sp->sectnum].floorstat, SP_TAG6(sp));
RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX);
}
}

Expand All @@ -1433,20 +1434,21 @@ void RestorePortalState()
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG3(i) == 0)
auto sp = &sprite[i];
if (SP_TAG3(sp) == 0)
{
// restore ceilingpicnum and ceilingstat
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG5(i);
sector[sprite[i].sectnum].ceilingstat = SPRITE_TAG4(i);
//RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_TYPE_MASK);
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
sector[sp->sectnum].ceilingpicnum = SP_TAG5(sp);
sector[sp->sectnum].ceilingstat = SP_TAG4(sp);
//RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_TYPE_MASK);
RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX);
}
else if (SPRITE_TAG3(i) == 1)
else if (SP_TAG3(sp) == 1)
{
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG5(i);
sector[sprite[i].sectnum].floorstat = SPRITE_TAG4(i);
//RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_TYPE_MASK);
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
sector[sp->sectnum].floorpicnum = SP_TAG5(sp);
sector[sp->sectnum].floorstat = SP_TAG4(sp);
//RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_TYPE_MASK);
RESET(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX);
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions source/games/sw/src/game.h
Expand Up @@ -198,23 +198,6 @@ inline int32_t FIXED(int32_t msw, int32_t lsw)
#define SET_SP_TAG13(sp,val) (*((short*)&(sp)->xoffset)) = LittleShort((short)val)
#define SET_SP_TAG14(sp,val) (*((short*)&(sp)->xrepeat)) = LittleShort((short)val)

#define SPRITE_TAG2(sp) (sprite[sp].lotag)
#define SPRITE_TAG3(sp) (sprite[sp].clipdist)
#define SPRITE_TAG4(sp) (sprite[sp].ang)
#define SPRITE_TAG5(sp) (sprite[sp].xvel)
#define SPRITE_TAG6(sp) (sprite[sp].yvel)
#define SPRITE_TAG7(sp) (MSB_VAR(sprite[sp].zvel))
#define SPRITE_TAG8(sp) (LSB_VAR(sprite[sp].zvel))
#define SPRITE_TAG9(sp) (MSB_VAR(sprite[sp].owner))
#define SPRITE_TAG10(sp) (LSB_VAR(sprite[sp].owner))
#define SPRITE_TAG11(sp) (sprite[sp].shade)
#define SPRITE_TAG12(sp) (sprite[sp].pal)
#define SPRITE_TAG13(sp) LittleShort(*((short*)&sprite[sp].xoffset))
#define SPRITE_TAG14(sp) LittleShort(*((short*)&sprite[sp].xrepeat))
#define SPRITE_TAG15(sp) (sprite[sp].z)
#define SET_SPRITE_TAG13(sp,val) (*((short*)&sprite[sp].xoffset)) = LittleShort((short)val)
#define SET_SPRITE_TAG14(sp,val) (*((short*)&sprite[sp].xrepeat)) = LittleShort((short)val)

// OVER and UNDER water macros
#define SpriteInDiveArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_DIVE_AREA) ? true : false)
#define SpriteInUnderwaterArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? true : false)
Expand Down
11 changes: 6 additions & 5 deletions source/games/sw/src/sector.cpp
Expand Up @@ -1506,19 +1506,20 @@ void DoDeleteSpriteMatch(short match)
StatIterator it(StatList[stat]);
while ((i = it.NextIndex()) >= 0)
{
if (del_x == sprite[i].x && del_y == sprite[i].y)
auto sp = &sprite[i];
if (del_x == sp->x && del_y == sp->y)
{
// special case lighting delete of Fade On/off after fades
if (StatList[stat] == STAT_LIGHTING)
{
// set shade to darkest and then kill it
sprite[i].shade = int8_t(SPRITE_TAG6(i));
sprite[i].pal = 0;
SectorLightShade(&sprite[i], sprite[i].shade);
sp->shade = int8_t(SP_TAG6(sp));
sp->pal = 0;
SectorLightShade(&sprite[i], sp->shade);
DiffuseLighting(&sprite[i]);
}

////DSPRINTF(ds,"Delete Sprite stat %d, x %d, y %d",sprite[i].statnum, sprite[i].x, sprite[i].y);
////DSPRINTF(ds,"Delete Sprite stat %d, x %d, y %d",sp->statnum, sp->x, sp->y);
//MONO_PRINT(ds);
SpriteQueueDelete(i);
KillSprite(i);
Expand Down

0 comments on commit a358cf8

Please sign in to comment.