Game: fix displayed viewscreen when its x/yrepeat isn't evenly divisible by 4.

git-svn-id: https://svn.eduke32.com/eduke32@5312 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2015-07-25 17:23:22 +00:00
parent 3375bce927
commit ff56964e1b
5 changed files with 40 additions and 13 deletions

View file

@ -2235,7 +2235,9 @@ DETONATE:
g_curViewscreen = -1; g_curViewscreen = -1;
sprite[i].yvel = 0; // VIEWSCREEN_YVEL sprite[i].yvel = 0; // VIEWSCREEN_YVEL
T1 = 0; T1 = 0;
walock[TILE_VIEWSCR] = 199;
for (int ii=0; ii < VIEWSCREENFACTOR; ii++)
walock[TILE_VIEWSCR-ii] = 199;
} }
} }

View file

@ -105,7 +105,9 @@ enum {
#define TILE_TILT (MAXTILES-2) #define TILE_TILT (MAXTILES-2)
#define TILE_ANIM (MAXTILES-4) #define TILE_ANIM (MAXTILES-4)
#define TILE_VIEWSCR (MAXTILES-5) #define TILE_VIEWSCR (MAXTILES-5)
EDUKE32_STATIC_ASSERT(5 <= MAXTILES-MAXUSERTILES); // Reserved: TILE_VIEWSCR_1 (MAXTILES-6)
// Reserved: TILE_VIEWSCR_2 (MAXTILES-7)
EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES);
// sprites with these statnums should be considered for fixing // sprites with these statnums should be considered for fixing
#define ROTFIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \ #define ROTFIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \

View file

@ -7518,6 +7518,10 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
continue; continue;
case VIEWSCREEN__STATIC: case VIEWSCREEN__STATIC:
case VIEWSCREEN2__STATIC: case VIEWSCREEN2__STATIC:
{
const int viewscrShift = G_GetViewscreenSizeShift(t);
const int viewscrTile = TILE_VIEWSCR-viewscrShift;
if (g_curViewscreen >= 0 && actor[OW].t_data[0] == 1) if (g_curViewscreen >= 0 && actor[OW].t_data[0] == 1)
{ {
t->picnum = STATIC; t->picnum = STATIC;
@ -7525,7 +7529,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
t->xrepeat += 10; t->xrepeat += 10;
t->yrepeat += 9; t->yrepeat += 9;
} }
else if (g_curViewscreen == i && display_mirror != 3 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) else if (g_curViewscreen == i && display_mirror != 3 && waloff[viewscrTile] && walock[viewscrTile] > 200)
{ {
// this exposes a sprite sorting issue which needs to be debugged further... // this exposes a sprite sorting issue which needs to be debugged further...
#if 0 #if 0
@ -7541,16 +7545,15 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
updatesector(newt->x, newt->y, &newt->sectnum); updatesector(newt->x, newt->y, &newt->sectnum);
} }
#endif #endif
t->picnum = viewscrTile;
t->picnum = TILE_VIEWSCR;
#if VIEWSCREENFACTOR > 0 #if VIEWSCREENFACTOR > 0
t->xrepeat = (t->xrepeat>>VIEWSCREENFACTOR) + (t->xrepeat & 1); t->xrepeat >>= viewscrShift;
t->yrepeat = (t->yrepeat>>VIEWSCREENFACTOR) + (t->yrepeat & 1); t->yrepeat >>= viewscrShift;
#endif #endif
} }
break; break;
}
case SHRINKSPARK__STATIC: case SHRINKSPARK__STATIC:
t->picnum = SHRINKSPARK+((totalclock>>4)&3); t->picnum = SHRINKSPARK+((totalclock>>4)&3);

View file

@ -613,6 +613,23 @@ static inline int32_t G_GetMusicIdx(const char *str)
return (ep * MAXLEVELS) + lev; return (ep * MAXLEVELS) + lev;
} }
static inline int G_GetViewscreenSizeShift(const tspritetype *tspr)
{
#if VIEWSCREENFACTOR == 0
UNREFERENCED_PARAMETER(tspr);
return VIEWSCREENFACTOR;
#else
static const int mask = (1<<VIEWSCREENFACTOR)-1;
const int rem = (tspr->xrepeat & mask) | (tspr->yrepeat & mask);
for (int i=0; i < VIEWSCREENFACTOR; i++)
if (rem & (1<<i))
return i;
return VIEWSCREENFACTOR;
#endif
}
extern void G_StartMusic(void); extern void G_StartMusic(void);
#ifdef LUNATIC #ifdef LUNATIC

View file

@ -404,12 +404,15 @@ void G_AnimateCamSprite(int32_t smoothratio)
if (OW >= 0 && dist(&sprite[ps->i], &sprite[i]) < VIEWSCREEN_ACTIVE_DISTANCE) if (OW >= 0 && dist(&sprite[ps->i], &sprite[i]) < VIEWSCREEN_ACTIVE_DISTANCE)
{ {
if (waloff[TILE_VIEWSCR] == 0) const int viewscrShift = G_GetViewscreenSizeShift((const tspritetype *)&sprite[i]);
allocatepermanenttile(TILE_VIEWSCR, tilesiz[PN].x<<VIEWSCREENFACTOR, tilesiz[PN].y<<VIEWSCREENFACTOR); const int viewscrTile = TILE_VIEWSCR-viewscrShift;
else
walock[TILE_VIEWSCR] = 255;
G_SetupCamTile(OW, TILE_VIEWSCR, smoothratio); if (waloff[viewscrTile] == 0)
allocatepermanenttile(viewscrTile, tilesiz[PN].x<<viewscrShift, tilesiz[PN].y<<viewscrShift);
else
walock[viewscrTile] = 255;
G_SetupCamTile(OW, viewscrTile, smoothratio);
#ifdef POLYMER #ifdef POLYMER
// Force texture update on viewscreen sprite in Polymer! // Force texture update on viewscreen sprite in Polymer!
if (getrendermode() == REND_POLYMER) if (getrendermode() == REND_POLYMER)