Clean up picanm[] by making its elements values of struct type picanm_t.

The size of that struct is currently 4, and its layout almost the same as
what is read in with loadpics().  The number of tiles in an animation is
bumped to 256, so that the max. tile difference in DEF's animtilerange is
255. (There's no way to have such animations from ART.)

git-svn-id: https://svn.eduke32.com/eduke32@3202 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-11-17 19:46:28 +00:00
parent 29a8f245b8
commit 44904b12be
11 changed files with 155 additions and 106 deletions

View file

@ -147,9 +147,6 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
# define YAX_SKIPWALL(i) (i)=(i) # define YAX_SKIPWALL(i) (i)=(i)
#endif #endif
#define PICANM_TEXHITSCAN_BIT (1<<28)
#define PICANM_NOFULLBRIGHT_BIT (1<<30)
#define CLIPMASK0 (((1L)<<16)+1L) #define CLIPMASK0 (((1L)<<16)+1L)
#define CLIPMASK1 (((256L)<<16)+64L) #define CLIPMASK1 (((256L)<<16)+64L)
@ -485,7 +482,32 @@ EXTERN int32_t pow2long[32];
#ifdef __cplusplus #ifdef __cplusplus
}; };
#endif #endif
EXTERN int32_t picanm[MAXTILES];
// picanm[].sf:
// |bit(1<<7)
// |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed|
enum {
PICANM_ANIMTYPE_NONE = 0,
PICANM_ANIMTYPE_OSC = (1<<6),
PICANM_ANIMTYPE_FWD = (2<<6),
PICANM_ANIMTYPE_BACK = (3<<6),
PICANM_ANIMTYPE_SHIFT = 6,
PICANM_ANIMTYPE_MASK = (3<<6), // must be 192
PICANM_MISC_MASK = (3<<4),
PICANM_TEXHITSCAN_BIT = (2<<4),
PICANM_NOFULLBRIGHT_BIT = (1<<4),
PICANM_ANIMSPEED_MASK = 15, // must be 15
};
// NOTE: If the layout of this struct is changed, loadpics() must be modified
// accordingly.
typedef struct {
uint8_t num; // animate number
int8_t xofs, yofs;
uint8_t sf; // anim. speed and flags
} picanm_t;
EXTERN picanm_t picanm[MAXTILES];
EXTERN intptr_t waloff[MAXTILES]; // stores pointers to cache -- SA EXTERN intptr_t waloff[MAXTILES]; // stores pointers to cache -- SA
EXTERN int32_t windowpos, windowx, windowy; EXTERN int32_t windowpos, windowx, windowy;
@ -694,7 +716,7 @@ void delete_maphack_lights();
int32_t clipmapinfo_load(void); int32_t clipmapinfo_load(void);
#endif #endif
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum); int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum);
void set_picsizanm(int32_t picnum, int16_t dasizx, int16_t dasizy, int32_t daanm); void set_tilesiz(int32_t picnum, int16_t dasizx, int16_t dasizy);
int32_t loadpics(const char *filename, int32_t askedsize); int32_t loadpics(const char *filename, int32_t askedsize);
void loadtile(int16_t tilenume); void loadtile(int16_t tilenume);
int32_t qloadkvx(int32_t voxindex, const char *filename); int32_t qloadkvx(int32_t voxindex, const char *filename);

View file

@ -2159,7 +2159,7 @@ static int32_t insert_sprite_common(int32_t sectnum, int32_t dax, int32_t day)
void correct_sprite_yoffset(int32_t i) void correct_sprite_yoffset(int32_t i)
{ {
int32_t tileyofs = (int8_t)((picanm[sprite[i].picnum]>>16)&255); int32_t tileyofs = picanm[sprite[i].picnum].yofs;
int32_t tileysiz = tilesizy[sprite[i].picnum]; int32_t tileysiz = tilesizy[sprite[i].picnum];
if (klabs(tileyofs) >= tileysiz) if (klabs(tileyofs) >= tileysiz)

View file

@ -475,18 +475,28 @@ static int32_t defsparser(scriptfile *script)
if (check_tile_range("animtilerange", &tile1, &tile2, script, cmdtokptr)) if (check_tile_range("animtilerange", &tile1, &tile2, script, cmdtokptr))
break; break;
if (tile2-tile1 >= 64) if (tile2-tile1 > 255)
{ {
initprintf("Error: animtilerange: tile difference can be at most 64 on line %s:%d\n", initprintf("Error: animtilerange: tile difference can be at most 255 on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr)); script->filename, scriptfile_getlinum(script,cmdtokptr));
break; break;
} }
spd = clamp(spd, 0, 15); spd = clamp(spd, 0, 15);
type = clamp(type, 0, 3); if (type&~3)
{
initprintf("Error: animtilerange: animation type must be 0, 1, 2 or 3 on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr));
}
picanm[tile1] &= 0xf0ffff00; // clear animation fields // set anim speed
picanm[tile1] |= (spd<<24)+(type<<6)+tile2-tile1; picanm[tile1].sf &= ~PICANM_ANIMSPEED_MASK;
picanm[tile1].sf |= spd;
// set anim type
picanm[tile1].sf &= ~PICANM_ANIMTYPE_MASK;
picanm[tile1].sf |= type<<PICANM_ANIMTYPE_SHIFT;
// set anim number
picanm[tile1].num = tile2-tile1;
break; break;
} }
@ -543,7 +553,7 @@ static int32_t defsparser(scriptfile *script)
{ {
// filefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data // filefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data
if (texhitscan) if (texhitscan)
picanm[tile] |= PICANM_TEXHITSCAN_BIT; picanm[tile].sf |= PICANM_TEXHITSCAN_BIT;
else else
initprintf("Error: missing 'file name' for tilefromtexture definition near line %s:%d\n", initprintf("Error: missing 'file name' for tilefromtexture definition near line %s:%d\n",
script->filename, scriptfile_getlinum(script,texturetokptr)); script->filename, scriptfile_getlinum(script,texturetokptr));
@ -568,13 +578,11 @@ static int32_t defsparser(scriptfile *script)
if (xsiz <= 0 || ysiz <= 0) if (xsiz <= 0 || ysiz <= 0)
break; break;
xoffset = clamp(xoffset, -128, 127)&255; set_tilesiz(tile, xsiz, ysiz);
yoffset = clamp(yoffset, -128, 127)&255; picanm[tile].xofs = clamp(xoffset, -128, 127);
picanm[tile].yofs = clamp(yoffset, -128, 127);
set_picsizanm(tile, xsiz, ysiz, (picanm[tile]&0xff0000ff)+
(xoffset<<8)+(yoffset<<16));
if (texhitscan) if (texhitscan)
picanm[tile] |= PICANM_TEXHITSCAN_BIT; picanm[tile].sf |= PICANM_TEXHITSCAN_BIT;
tile_from_truecolpic(tile, picptr, alphacut); tile_from_truecolpic(tile, picptr, alphacut);
@ -604,7 +612,8 @@ static int32_t defsparser(scriptfile *script)
if (check_tile("importtile", &tile, script, cmdtokptr)) if (check_tile("importtile", &tile, script, cmdtokptr))
break; break;
set_picsizanm(tile, xsiz, ysiz, 0); set_tilesiz(tile, xsiz, ysiz);
Bmemset(&picanm[tile], 0, sizeof(picanm_t));
tile_from_truecolpic(tile, picptr, 255); tile_from_truecolpic(tile, picptr, 255);
@ -621,7 +630,8 @@ static int32_t defsparser(scriptfile *script)
if (xsiz > 0 && ysiz > 0) if (xsiz > 0 && ysiz > 0)
{ {
set_picsizanm(tile, xsiz, ysiz, 0); set_tilesiz(tile, xsiz, ysiz);
Bmemset(&picanm[tile], 0, sizeof(picanm_t));
faketilesiz[tile] = -1; faketilesiz[tile] = -1;
} }
@ -644,7 +654,8 @@ static int32_t defsparser(scriptfile *script)
for (i=tile1; i<=tile2; i++) for (i=tile1; i<=tile2; i++)
{ {
set_picsizanm(i, xsiz, ysiz, 0); set_tilesiz(i, xsiz, ysiz);
Bmemset(&picanm[i], 0, sizeof(picanm_t));
faketilesiz[i] = -1; faketilesiz[i] = -1;
} }
@ -1950,7 +1961,7 @@ static int32_t defsparser(scriptfile *script)
e = min(e, MAXTILES-1); e = min(e, MAXTILES-1);
for (i=b; i<=e; i++) for (i=b; i<=e; i++)
picanm[i] |= PICANM_TEXHITSCAN_BIT; picanm[i].sf |= PICANM_TEXHITSCAN_BIT;
} }
break; break;

View file

@ -3096,30 +3096,32 @@ static void prepwall(int32_t z, const walltype *wal)
// //
int32_t animateoffs(int16_t tilenum, int16_t fakevar) int32_t animateoffs(int16_t tilenum, int16_t fakevar)
{ {
int32_t i, k, offs; int32_t i, k, offs=0, animnum=picanm[tilenum].num;
UNREFERENCED_PARAMETER(fakevar); UNREFERENCED_PARAMETER(fakevar);
offs = 0; i = totalclocklock>>(picanm[tilenum].sf&PICANM_ANIMSPEED_MASK);
i = (totalclocklock>>((picanm[tilenum]>>24)&15));
if ((picanm[tilenum]&63) > 0) if (picanm[tilenum].num > 0)
{ {
switch (picanm[tilenum]&192) switch (picanm[tilenum].sf&PICANM_ANIMTYPE_MASK)
{ {
case 64: case PICANM_ANIMTYPE_OSC:
k = (i%((picanm[tilenum]&63)<<1)); k = (i%(animnum<<1));
if (k < (picanm[tilenum]&63)) if (k < animnum)
offs = k; offs = k;
else else
offs = (((picanm[tilenum]&63)<<1)-k); offs = (animnum<<1)-k;
break; break;
case 128: case PICANM_ANIMTYPE_FWD:
offs = (i%((picanm[tilenum]&63)+1)); offs = i%(animnum+1);
break;
case PICANM_ANIMTYPE_BACK:
offs = -(i%(animnum+1));
break; break;
case 192:
offs = -(i%((picanm[tilenum]&63)+1));
} }
} }
return(offs); return(offs);
} }
@ -5529,8 +5531,8 @@ static void drawsprite(int32_t snum)
if (cstat&512) settransreverse(); else settransnormal(); if (cstat&512) settransreverse(); else settransnormal();
} }
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)tspr->xoffset); xoff = picanm[tilenum].xofs + tspr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)tspr->yoffset); yoff = picanm[tilenum].yofs + tspr->yoffset;
if ((cstat&48) == 0) if ((cstat&48) == 0)
{ {
@ -6312,7 +6314,7 @@ draw_as_face_sprite:
} }
if (!(cstat&128)) tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat); if (!(cstat&128)) tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat);
yoff = /*(int32_t) ((int8_t)((picanm[sprite[tspr->owner].picnum]>>16)&255)) +*/ (int32_t)tspr->yoffset; yoff = /*picanm[sprite[tspr->owner].picnum].yofs +*/ tspr->yoffset;
tspr->z -= mulscale14(yoff,nyrepeat); tspr->z -= mulscale14(yoff,nyrepeat);
globvis = globalvisibility; globvis = globalvisibility;
@ -7037,8 +7039,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
{ {
// Bit 1<<4 clear: origin is center of tile, and per-tile offset is applied. // Bit 1<<4 clear: origin is center of tile, and per-tile offset is applied.
// TODO: split the two? // TODO: split the two?
xoff = (int32_t)((int8_t)((picanm[picnum]>>8)&255))+(xsiz>>1); xoff = picanm[picnum].xofs + (xsiz>>1);
yoff = (int32_t)((int8_t)((picanm[picnum]>>16)&255))+(ysiz>>1); yoff = picanm[picnum].yofs + (ysiz>>1);
} }
// Bit 1<<2: invert y // Bit 1<<2: invert y
@ -8909,7 +8911,7 @@ killsprite:
spritesz[k] = tspriteptr[k]->z; spritesz[k] = tspriteptr[k]->z;
if ((tspriteptr[k]->cstat&48) != 32) if ((tspriteptr[k]->cstat&48) != 32)
{ {
yoff = (int32_t)((int8_t)((picanm[tspriteptr[k]->picnum]>>16)&255))+((int32_t)tspriteptr[k]->yoffset); yoff = picanm[tspriteptr[k]->picnum].yofs + tspriteptr[k]->yoffset;
spritesz[k] -= ((yoff*tspriteptr[k]->yrepeat)<<2); spritesz[k] -= ((yoff*tspriteptr[k]->yrepeat)<<2);
yspan = (tilesizy[tspriteptr[k]->picnum]*tspriteptr[k]->yrepeat<<2); yspan = (tilesizy[tspriteptr[k]->picnum]*tspriteptr[k]->yrepeat<<2);
if (!(tspriteptr[k]->cstat&128)) spritesz[k] -= (yspan>>1); if (!(tspriteptr[k]->cstat&128)) spritesz[k] -= (yspan>>1);
@ -9223,8 +9225,8 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
npoints = 0; npoints = 0;
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); yoff = picanm[tilenum].yofs + spr->yoffset;
if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&4) > 0) xoff = -xoff;
if ((spr->cstat&8) > 0) yoff = -yoff; if ((spr->cstat&8) > 0) yoff = -yoff;
@ -10445,24 +10447,27 @@ void nextpage(void)
numframes++; numframes++;
} }
void set_picsizanm(int32_t picnum, int16_t dasizx, int16_t dasizy, int32_t daanm) static void set_picsiz(int32_t picnum)
{ {
int32_t j; int32_t j;
tilesizx[picnum] = dasizx;
tilesizy[picnum] = dasizy;
picanm[picnum] = daanm;
j = 15; j = 15;
while ((j > 1) && (pow2long[j] > dasizx)) while ((j > 1) && (pow2long[j] > tilesizx[picnum]))
j--; j--;
picsiz[picnum] = j; picsiz[picnum] = j;
j = 15; j = 15;
while ((j > 1) && (pow2long[j] > dasizy)) while ((j > 1) && (pow2long[j] > tilesizy[picnum]))
j--; j--;
picsiz[picnum] += j<<4; picsiz[picnum] |= j<<4;
}
void set_tilesiz(int32_t picnum, int16_t dasizx, int16_t dasizy)
{
tilesizx[picnum] = dasizx;
tilesizy[picnum] = dasizy;
set_picsiz(picnum);
} }
// //
@ -10528,7 +10533,16 @@ int32_t loadpics(const char *filename, int32_t askedsize)
{ {
tilesizx[i] = B_LITTLE16(tilesizx[i]); tilesizx[i] = B_LITTLE16(tilesizx[i]);
tilesizy[i] = B_LITTLE16(tilesizy[i]); tilesizy[i] = B_LITTLE16(tilesizy[i]);
picanm[i] = B_LITTLE32(picanm[i]);
Bassert(sizeof(picanm_t)==4);
Bassert(PICANM_ANIMTYPE_MASK == 192);
// Old on-disk format: anim type is in the 2 highest bits of the lowest byte.
picanm[i].sf &= ~192;
picanm[i].sf |= picanm[i].num&192;
picanm[i].num &= ~192;
// don't allow setting texhitscan/nofullbright from ART (yet?)
picanm[i].sf &= ~PICANM_MISC_MASK;
} }
offscount = 4+4+4+4+(localnumtiles<<3); offscount = 4+4+4+4+(localnumtiles<<3);
@ -10572,7 +10586,7 @@ int32_t loadpics(const char *filename, int32_t askedsize)
initcache((intptr_t)pic, cachesize); initcache((intptr_t)pic, cachesize);
for (i=0; i<MAXTILES; i++) for (i=0; i<MAXTILES; i++)
set_picsizanm(i, tilesizx[i], tilesizy[i], picanm[i]); set_picsiz(i);
artfil = -1; artfil = -1;
artfilnum = -1; artfilnum = -1;
@ -10672,7 +10686,8 @@ intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz)
walock[tilenume] = 255; walock[tilenume] = 255;
allocache(&waloff[tilenume],dasiz,&walock[tilenume]); allocache(&waloff[tilenume],dasiz,&walock[tilenume]);
set_picsizanm(tilenume, xsiz, ysiz, 0); set_tilesiz(tilenume, xsiz, ysiz);
Bmemset(&picanm[tilenume], 0, sizeof(picanm_t));
return(waloff[tilenume]); return(waloff[tilenume]);
} }
@ -10896,8 +10911,8 @@ void spriteheightofs(int16_t i, int32_t *height, int32_t *zofs, int32_t alsotile
*zofs = hei>>1; *zofs = hei>>1;
if (alsotileyofs && (unsigned)sprite[i].picnum < MAXTILES) if (alsotileyofs && (unsigned)sprite[i].picnum < MAXTILES)
if (picanm[sprite[i].picnum]&0x00ff0000) if (picanm[sprite[i].picnum].yofs)
*zofs -= ((int8_t)((picanm[sprite[i].picnum]>>16)&255))*sprite[i].yrepeat<<2; *zofs -= picanm[sprite[i].picnum].yofs*sprite[i].yrepeat<<2;
} }
*height = hei; *height = hei;
} }
@ -11441,7 +11456,7 @@ restart_grand:
i = (tilesizy[spr->picnum]*spr->yrepeat<<2); i = (tilesizy[spr->picnum]*spr->yrepeat<<2);
if (cstat&128) z1 += (i>>1); if (cstat&128) z1 += (i>>1);
if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (picanm[spr->picnum].yofs) z1 -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
if ((intz > z1) || (intz < z1-i)) continue; if ((intz > z1) || (intz < z1-i)) continue;
topu = vx*(y1-sv->y) - vy*(x1-sv->x); topu = vx*(y1-sv->y) - vy*(x1-sv->x);
@ -11466,7 +11481,7 @@ restart_grand:
//These lines get the 2 points of the rotated sprite //These lines get the 2 points of the rotated sprite
//Given: (x1, y1) starts out as the center point //Given: (x1, y1) starts out as the center point
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
k = spr->ang; l = spr->xrepeat; k = spr->ang; l = spr->xrepeat;
dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l;
@ -11484,10 +11499,10 @@ restart_grand:
k = ((tilesizy[tilenum]*spr->yrepeat)<<2); k = ((tilesizy[tilenum]*spr->yrepeat)<<2);
if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z;
if (picanm[tilenum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[tilenum]>>16)&255))*spr->yrepeat<<2); if (picanm[tilenum].yofs) daz -= (picanm[tilenum].yofs*spr->yrepeat<<2);
if (intz > daz-k && intz < daz) if (intz > daz-k && intz < daz)
{ {
if (picanm[tilenum]&PICANM_TEXHITSCAN_BIT) if (picanm[tilenum].sf&PICANM_TEXHITSCAN_BIT)
{ {
// daz-intz > 0 && daz-intz < k // daz-intz > 0 && daz-intz < k
int32_t xtex = mulscale16(ucoefup16, tilesizx[tilenum]); int32_t xtex = mulscale16(ucoefup16, tilesizx[tilenum]);
@ -11529,8 +11544,8 @@ restart_grand:
if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) continue; if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) continue;
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); yoff = picanm[tilenum].yofs + spr->yoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
if ((cstat&8) > 0) yoff = -yoff; if ((cstat&8) > 0) yoff = -yoff;
@ -11729,7 +11744,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
intz = zs+scale(vz,topt,bot); intz = zs+scale(vz,topt,bot);
i = tilesizy[spr->picnum]*spr->yrepeat; i = tilesizy[spr->picnum]*spr->yrepeat;
if (spr->cstat&128) z1 += (i<<1); if (spr->cstat&128) z1 += (i<<1);
if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (picanm[spr->picnum].yofs) z1 -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
if ((intz <= z1) && (intz >= z1-(i<<2))) if ((intz <= z1) && (intz >= z1-(i<<2)))
{ {
topu = vx*(y1-ys) - vy*(x1-xs); topu = vx*(y1-ys) - vy*(x1-xs);
@ -12298,7 +12313,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum,
{ {
k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2);
if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z;
if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (picanm[spr->picnum].yofs) daz -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
if (((pos->z) < daz+ceildist) && ((pos->z) > daz-k-flordist)) if (((pos->z) < daz+ceildist) && ((pos->z) > daz-k-flordist))
{ {
bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz;
@ -12311,7 +12326,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum,
case 16: case 16:
k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2);
if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z;
if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (picanm[spr->picnum].yofs) daz -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
daz2 = daz-k; daz2 = daz-k;
daz += ceildist; daz2 -= flordist; daz += ceildist; daz2 -= flordist;
if (((pos->z) < daz) && ((pos->z) > daz2)) if (((pos->z) < daz) && ((pos->z) > daz2))
@ -12319,7 +12334,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum,
//These lines get the 2 points of the rotated sprite //These lines get the 2 points of the rotated sprite
//Given: (x1, y1) starts out as the center point //Given: (x1, y1) starts out as the center point
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
k = spr->ang; l = spr->xrepeat; k = spr->ang; l = spr->xrepeat;
dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l;
@ -12358,8 +12373,8 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum,
if (((pos->z) > spr->z) == ((cstat&8)==0)) continue; if (((pos->z) > spr->z) == ((cstat&8)==0)) continue;
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); yoff = picanm[tilenum].yofs + spr->yoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
if ((cstat&8) > 0) yoff = -yoff; if ((cstat&8) > 0) yoff = -yoff;
@ -12556,7 +12571,7 @@ int32_t pushmove(vec3_t *vect, int16_t *sectnum,
{ {
t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2);
if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z; if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z;
if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (picanm[spr->picnum].yofs) daz -= ((int32_t)picanm[spr->picnum].yofs*spr->yrepeat<<2);
if (((vect->z) < daz+ceildist) && ((vect->z) > daz-t-flordist)) if (((vect->z) < daz+ceildist) && ((vect->z) > daz-t-flordist))
{ {
t = (spr->clipdist<<2)+walldist; t = (spr->clipdist<<2)+walldist;
@ -13208,15 +13223,15 @@ restart_grand:
daz = spr->z; daz = spr->z;
k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1);
if (cstat&128) daz += k; if (cstat&128) daz += k;
if (picanm[spr->picnum]&0x00ff0000) if (picanm[spr->picnum].yofs)
daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
daz2 = daz - (k<<1); daz2 = daz - (k<<1);
clipyou = 1; clipyou = 1;
} }
break; break;
case 16: case 16:
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
k = spr->ang; l = spr->xrepeat; k = spr->ang; l = spr->xrepeat;
dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l;
@ -13227,8 +13242,8 @@ restart_grand:
{ {
daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1);
if (cstat&128) daz += k; if (cstat&128) daz += k;
if (picanm[spr->picnum]&0x00ff0000) if (picanm[spr->picnum].yofs)
daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz -= (picanm[spr->picnum].yofs*spr->yrepeat<<2);
daz2 = daz-(k<<1); daz2 = daz-(k<<1);
clipyou = 1; clipyou = 1;
} }
@ -13240,8 +13255,8 @@ restart_grand:
if ((pos->z > daz) == ((cstat&8)==0)) continue; if ((pos->z > daz) == ((cstat&8)==0)) continue;
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); yoff = picanm[tilenum].yofs + spr->yoffset;
if ((cstat&4) > 0) xoff = -xoff; if ((cstat&4) > 0) xoff = -xoff;
if ((cstat&8) > 0) yoff = -yoff; if ((cstat&8) > 0) yoff = -yoff;

View file

@ -81,8 +81,8 @@ extern palette_t palookupfog[MAXPALOOKUPS];
int32_t wallfront(int32_t l1, int32_t l2); int32_t wallfront(int32_t l1, int32_t l2);
int32_t animateoffs(int16_t tilenum, int16_t fakevar); int32_t animateoffs(int16_t tilenum, int16_t fakevar);
#define DO_TILE_ANIM(Picnum, Fakevar) do { \ #define DO_TILE_ANIM(Picnum, Fakevar) do { \
if (picanm[Picnum]&192) Picnum += animateoffs(Picnum, Fakevar); \ if (picanm[Picnum].sf&PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum, Fakevar); \
} while (0) } while (0)
void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat, void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat,

View file

@ -3559,8 +3559,8 @@ void polymer_updatesprite(int32_t snum)
tilexoff = (int32_t)tspr->xoffset; tilexoff = (int32_t)tspr->xoffset;
tileyoff = (int32_t)tspr->yoffset; tileyoff = (int32_t)tspr->yoffset;
tilexoff += (int8_t)((usehightile&&h_xsize[curpicnum])?(h_xoffs[curpicnum]):((picanm[curpicnum]>>8)&255)); tilexoff += (usehightile && h_xsize[curpicnum]) ? h_xoffs[curpicnum] : picanm[curpicnum].xofs;
tileyoff += (int8_t)((usehightile&&h_xsize[curpicnum])?(h_yoffs[curpicnum]):((picanm[curpicnum]>>16)&255)); tileyoff += (usehightile && h_xsize[curpicnum]) ? h_yoffs[curpicnum] : picanm[curpicnum].yofs;
xoff = (int32_t)(tilexoff * xratio); xoff = (int32_t)(tilexoff * xratio);
yoff = (int32_t)(tileyoff * yratio); yoff = (int32_t)(tileyoff * yratio);

View file

@ -1210,7 +1210,7 @@ static int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dameth, pthty
} }
else else
{ {
const int32_t dofullbright = !(picanm[dapic]&PICANM_NOFULLBRIGHT_BIT); const int32_t dofullbright = !(picanm[dapic].sf&PICANM_NOFULLBRIGHT_BIT);
int32_t y; int32_t y;
for (y=0; y<ysiz; y++) for (y=0; y<ysiz; y++)
@ -4902,8 +4902,8 @@ void polymost_drawsprite(int32_t snum)
flag = usehightile && h_xsize[globalpicnum]; flag = usehightile && h_xsize[globalpicnum];
xoff = (int32_t)tspr->xoffset; xoff = (int32_t)tspr->xoffset;
yoff = (int32_t)tspr->yoffset; yoff = (int32_t)tspr->yoffset;
xoff += (int8_t)(flag ? h_xoffs[globalpicnum] : ((picanm[globalpicnum]>>8)&255)); xoff += flag ? h_xoffs[globalpicnum] : picanm[globalpicnum].xofs;
yoff += (int8_t)(flag ? h_yoffs[globalpicnum] : ((picanm[globalpicnum]>>16)&255)); yoff += flag ? h_yoffs[globalpicnum] : picanm[globalpicnum].yofs;
} }
method = 1+4; method = 1+4;
@ -5437,8 +5437,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (dastat&16) if (dastat&16)
{ {
xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum];
xoff = (int32_t)((int8_t)((picanm[picnum]>>8)&255))+(xsiz>>1); xoff = picanm[picnum].xofs + (xsiz>>1);
yoff = (int32_t)((int8_t)((picanm[picnum]>>16)&255))+(ysiz>>1); yoff = picanm[picnum].yofs + (ysiz>>1);
d = (double)z/(65536.0*16384.0); d = (double)z/(65536.0*16384.0);
cosang2 = cosang = (double)sintable[(a+512)&2047]*d; cosang2 = cosang = (double)sintable[(a+512)&2047]*d;
@ -5653,8 +5653,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
} }
else else
{ {
xoff = (int32_t)((int8_t)((picanm[globalpicnum]>>8)&255))+(xsiz>>1); xoff = picanm[globalpicnum].xofs + (xsiz>>1);
yoff = (int32_t)((int8_t)((picanm[globalpicnum]>>16)&255))+(ysiz>>1); yoff = picanm[globalpicnum].yofs + (ysiz>>1);
} }
if (dastat&4) if (dastat&4)

View file

@ -4083,15 +4083,16 @@ static void tilescreen_drawrest(int32_t iSelected, int32_t showmsg)
printext256(xdim>>2,ydim-10,whitecol,-1,szT,0); printext256(xdim>>2,ydim-10,whitecol,-1,szT,0);
// EditArt offset flags. // EditArt offset flags.
Bsprintf(szT,"%d, %d", (int8_t)((picanm[idTile]>>8)&0xFF), (int8_t)((picanm[idTile]>>16)&0xFF)); Bsprintf(szT,"%d, %d", picanm[idTile].xofs, picanm[idTile].yofs);
printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0); printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0);
// EditArt animation flags. // EditArt animation flags.
if (picanm[idTile]&0xc0) if (picanm[idTile].sf&PICANM_ANIMTYPE_MASK)
{ {
static const char *anmtype[] = {"", "Osc", "Fwd", "Bck"}; static const char *anmtype[] = {"", "Osc", "Fwd", "Bck"};
int32_t ii = (picanm[idTile].sf&PICANM_ANIMTYPE_MASK)>>PICANM_ANIMTYPE_SHIFT;
Bsprintf(szT,"%s %d", anmtype[(picanm[idTile]&0xc0)>>6], picanm[idTile]&0x3f); Bsprintf(szT,"%s %d", anmtype[ii], picanm[idTile].num);
printext256((xdim>>2)+100+14*8,ydim-10,whitecol,-1,szT,0); printext256((xdim>>2)+100+14*8,ydim-10,whitecol,-1,szT,0);
} }
} }
@ -4488,8 +4489,8 @@ ENDFOR1:
curspr = linebegspr = startspr; curspr = linebegspr = startspr;
t = sprite[startspr].picnum; t = sprite[startspr].picnum;
sprite[startspr].xoffset = -(((picanm[t])>>8)&255); sprite[startspr].xoffset = -picanm[t].xofs;
sprite[startspr].yoffset = -(((picanm[t])>>16)&255); sprite[startspr].yoffset = -picanm[t].yofs;
spritenums = (int16_t *)Bmalloc(stackallocsize * sizeof(int16_t)); spritenums = (int16_t *)Bmalloc(stackallocsize * sizeof(int16_t));
if (!spritenums) goto ERROR_NOMEMORY; if (!spritenums) goto ERROR_NOMEMORY;
@ -4605,8 +4606,8 @@ ENDFOR1:
sprite[i].picnum = t; sprite[i].picnum = t;
sprite[i].ang = daang; sprite[i].ang = daang;
sprite[i].xoffset = -(((picanm[sprite[i].picnum])>>8)&255); sprite[i].xoffset = -picanm[t].xofs;
sprite[i].yoffset = -(((picanm[sprite[i].picnum])>>16)&255); sprite[i].yoffset = -picanm[t].yofs;
sprite[i].xoffset += alphabets[alphidx].xofs[(int32_t)ch-33]; sprite[i].xoffset += alphabets[alphidx].xofs[(int32_t)ch-33];
sprite[i].yoffset += alphabets[alphidx].yofs[(int32_t)ch-33]; sprite[i].yoffset += alphabets[alphidx].yofs[(int32_t)ch-33];

View file

@ -2247,7 +2247,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
x1 = sprx; x1 = sprx;
y1 = spry; y1 = spry;
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&4) > 0) xoff = -xoff;
k = spr->ang; k = spr->ang;
l = spr->xrepeat; l = spr->xrepeat;
@ -2277,10 +2277,9 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
break; break;
case 32: case 32:
tilenum = spr->picnum; tilenum = spr->picnum;
xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); xoff = picanm[tilenum].xofs + spr->xoffset;
yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); yoff = picanm[tilenum].yofs + spr->yoffset;
if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&4) > 0) xoff = -xoff;
if ((spr->cstat&8) > 0) yoff = -yoff; if ((spr->cstat&8) > 0) yoff = -yoff;
@ -3841,7 +3840,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
const int16_t tang = (ud.screen_tilting) ? p->rotscrnang : 0; const int16_t tang = (ud.screen_tilting) ? p->rotscrnang : 0;
setviewback(); setviewback();
picanm[TILE_TILT] &= 0xff0000ff; picanm[TILE_TILT].xofs = picanm[TILE_TILT].yofs = 0;
i = (tang&511); i = (tang&511);
if (i > 256) if (i > 256)
@ -9735,7 +9734,7 @@ static void G_Startup(void)
// Make the fullscreen nuke logo background non-fullbright. Has to be // Make the fullscreen nuke logo background non-fullbright. Has to be
// after dynamic tile remapping (from C_Compile) and loading tiles. // after dynamic tile remapping (from C_Compile) and loading tiles.
picanm[LOADSCREEN] |= PICANM_NOFULLBRIGHT_BIT; picanm[LOADSCREEN].sf |= PICANM_NOFULLBRIGHT_BIT;
// initprintf("Loading palette/lookups...\n"); // initprintf("Loading palette/lookups...\n");
G_LoadExtraPalettes(); G_LoadExtraPalettes();

View file

@ -141,7 +141,8 @@ void GAME_onshowosd(int32_t shown)
// most of this is copied from my dummytile stuff in defs.c // most of this is copied from my dummytile stuff in defs.c
if (!tilesizx[BGTILE] || !tilesizy[BGTILE]) if (!tilesizx[BGTILE] || !tilesizy[BGTILE])
{ {
set_picsizanm(BGTILE, BGTILE_SIZEX, BGTILE_SIZEY, 0); set_tilesiz(BGTILE, BGTILE_SIZEX, BGTILE_SIZEY);
Bmemset(&picanm[BGTILE], 0, sizeof(picanm_t));
faketilesiz[BGTILE] = -1; faketilesiz[BGTILE] = -1;
} }

View file

@ -49,7 +49,7 @@ extern int32_t g_levelTextTime;
static void tloadtile(int32_t tilenume, int32_t type) static void tloadtile(int32_t tilenume, int32_t type)
{ {
if ((picanm[tilenume]&63) < 1) if (picanm[tilenume].num < 1)
{ {
if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) g_precacheCount++; if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) g_precacheCount++;
gotpic[tilenume>>3] |= pow2char[tilenume&7]; gotpic[tilenume>>3] |= pow2char[tilenume&7];
@ -60,15 +60,15 @@ static void tloadtile(int32_t tilenume, int32_t type)
{ {
int32_t i,j; int32_t i,j;
if ((picanm[tilenume]&192)==192) if ((picanm[tilenume].sf&PICANM_ANIMTYPE_MASK)==PICANM_ANIMTYPE_BACK)
{ {
i = tilenume - (picanm[tilenume]&63); i = tilenume - picanm[tilenume].num;
j = tilenume; j = tilenume;
} }
else else
{ {
i = tilenume; i = tilenume;
j = tilenume + (picanm[tilenume]&63); j = tilenume + picanm[tilenume].num;
} }
for (; i<=j; i++) for (; i<=j; i++)
{ {