- took care of the automap code.

This was virtually unchanged from JFDuke except for better formatting.
This commit is contained in:
Christoph Oelckers 2020-07-02 20:58:56 +02:00
parent 17c9513c98
commit aaa8ae7306
4 changed files with 426 additions and 430 deletions

View file

@ -260,5 +260,292 @@ void drawbackground(void)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void drawoverheadmap(int cposx, int cposy, int czoom, int cang)
{
int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
int xvect, yvect, xvect2, yvect2;
int p;
PalEntry col;
walltype* wal, * wal2;
spritetype* spr;
renderSetAspect(65536, 65536);
xvect = sintable[(-cang) & 2047] * czoom;
yvect = sintable[(1536 - cang) & 2047] * czoom;
xvect2 = mulscale16(xvect, yxaspect);
yvect2 = mulscale16(yvect, yxaspect);
//Draw red lines
for (i = 0; i < numsectors; i++)
{
if (!gFullMap && !show2dsector[i]) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
z1 = sector[i].ceilingz;
z2 = sector[i].floorz;
for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++)
{
k = wal->nextwall;
if (k < 0) continue;
if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2)
if (((wal->cstat | wall[wal->nextwall].cstat) & (16 + 32)) == 0) continue;
if (!gFullMap && !show2dsector[wal->nextsector])
{
col = PalEntry(170, 170, 170);
ox = wal->x - cposx;
oy = wal->y - cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11);
y1 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11);
wal2 = &wall[wal->point2];
ox = wal2->x - cposx;
oy = wal2->y - cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11);
y2 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11);
drawlinergb(x1, y1, x2, y2, col);
}
}
}
//Draw sprites
k = ps[screenpeek].i;
for (i = 0; i < numsectors; i++)
{
if (!gFullMap || !show2dsector[i]) continue;
for (j = headspritesect[i]; j >= 0; j = nextspritesect[j])
{
spr = &sprite[j];
if (j == k || (spr->cstat & 0x8000) || spr->cstat == 257 || spr->xrepeat == 0) continue;
col = PalEntry(0, 170, 170);
if (spr->cstat & 1) col = PalEntry(170, 0, 170);
sprx = spr->x;
spry = spr->y;
if ((spr->cstat & 257) != 0) switch (spr->cstat & 48)
{
case 0:
// break;
ox = sprx - cposx;
oy = spry - cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = (sintable[(spr->ang + 512) & 2047] >> 7);
oy = (sintable[(spr->ang) & 2047] >> 7);
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect, ox, yvect);
x3 = mulscale16(x2, yxaspect);
y3 = mulscale16(y2, yxaspect);
drawlinergb(x1 - x2 + (xdim << 11), y1 - y3 + (ydim << 11),
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
drawlinergb(x1 - y2 + (xdim << 11), y1 + x3 + (ydim << 11),
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
drawlinergb(x1 + y2 + (xdim << 11), y1 - x3 + (ydim << 11),
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
break;
case 16:
if (spr->picnum == TILE_LASERLINE)
{
x1 = sprx;
y1 = spry;
tilenum = spr->picnum;
xoff = tileLeftOffset(tilenum) + spr->xoffset;
if ((spr->cstat & 4) > 0) xoff = -xoff;
k = spr->ang;
l = spr->xrepeat;
dax = sintable[k & 2047] * l;
day = sintable[(k + 1536) & 2047] * l;
l = tilesiz[tilenum].x;
k = (l >> 1) + xoff;
x1 -= mulscale16(dax, k);
x2 = x1 + mulscale16(dax, l);
y1 -= mulscale16(day, k);
y2 = y1 + mulscale16(day, l);
ox = x1 - cposx;
oy = y1 - cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x2 - cposx;
oy = y2 - cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2);
drawlinergb(x1 + (xdim << 11), y1 + (ydim << 11),
x2 + (xdim << 11), y2 + (ydim << 11), col);
}
break;
case 32:
tilenum = spr->picnum;
xoff = tileLeftOffset(tilenum) + spr->xoffset;
yoff = tileTopOffset(tilenum) + spr->yoffset;
if ((spr->cstat & 4) > 0) xoff = -xoff;
if ((spr->cstat & 8) > 0) yoff = -yoff;
k = spr->ang;
cosang = sintable[(k + 512) & 2047];
sinang = sintable[k & 2047];
xspan = tilesiz[tilenum].x;
xrepeat = spr->xrepeat;
yspan = tilesiz[tilenum].y;
yrepeat = spr->yrepeat;
dax = ((xspan >> 1) + xoff) * xrepeat;
day = ((yspan >> 1) + yoff) * yrepeat;
x1 = sprx + dmulscale16(sinang, dax, cosang, day);
y1 = spry + dmulscale16(sinang, day, -cosang, dax);
l = xspan * xrepeat;
x2 = x1 - mulscale16(sinang, l);
y2 = y1 + mulscale16(cosang, l);
l = yspan * yrepeat;
k = -mulscale16(cosang, l);
x3 = x2 + k;
x4 = x1 + k;
k = -mulscale16(sinang, l);
y3 = y2 + k;
y4 = y1 + k;
ox = x1 - cposx;
oy = y1 - cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x2 - cposx;
oy = y2 - cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x3 - cposx;
oy = y3 - cposy;
x3 = dmulscale16(ox, xvect, -oy, yvect);
y3 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x4 - cposx;
oy = y4 - cposy;
x4 = dmulscale16(ox, xvect, -oy, yvect);
y4 = dmulscale16(oy, xvect2, ox, yvect2);
drawlinergb(x1 + (xdim << 11), y1 + (ydim << 11),
x2 + (xdim << 11), y2 + (ydim << 11), col);
drawlinergb(x2 + (xdim << 11), y2 + (ydim << 11),
x3 + (xdim << 11), y3 + (ydim << 11), col);
drawlinergb(x3 + (xdim << 11), y3 + (ydim << 11),
x4 + (xdim << 11), y4 + (ydim << 11), col);
drawlinergb(x4 + (xdim << 11), y4 + (ydim << 11),
x1 + (xdim << 11), y1 + (ydim << 11), col);
break;
}
}
}
//Draw white lines
for (i = numsectors - 1; i >= 0; i--)
{
if (!gFullMap && !show2dsector[i]) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
k = -1;
for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++)
{
if (wal->nextwall >= 0) continue;
if (tilesiz[wal->picnum].x == 0) continue;
if (tilesiz[wal->picnum].y == 0) continue;
if (j == k)
{
x1 = x2;
y1 = y2;
}
else
{
ox = wal->x - cposx;
oy = wal->y - cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11);
y1 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11);
}
k = wal->point2;
wal2 = &wall[k];
ox = wal2->x - cposx;
oy = wal2->y - cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11);
y2 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11);
drawlinergb(x1, y1, x2, y2, PalEntry(170, 170, 170));
}
}
videoSetCorrectedAspect();
for (p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ud.scrollmode && p == screenpeek) continue;
ox = sprite[ps[p].i].x - cposx;
oy = sprite[ps[p].i].y - cposy;
daang = (sprite[ps[p].i].ang - cang) & 2047;
if (p == screenpeek)
{
ox = 0;
oy = 0;
daang = 0;
}
x1 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
y1 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
if (p == screenpeek || ud.coop == 1)
{
if (sprite[ps[p].i].xvel > 16 && ps[p].on_ground)
i = TILE_APLAYERTOP + (((int)totalclock >> 4) & 3);
else
i = TILE_APLAYERTOP;
j = klabs(ps[p].truefz - ps[p].posz) >> 8;
j = mulscale(czoom * (sprite[ps[p].i].yrepeat + j), yxaspect, 16);
if (j < 22000) j = 22000;
else if (j > (65536 << 1)) j = (65536 << 1);
/*
rotatesprite((x1 << 4) + (xdim << 15), (y1 << 4) + (ydim << 15), j,
daang, i, sprite[ps[p].i].shade, sprite[ps[p].i].pal,
(sprite[ps[p].i].cstat & 2) >> 1, windowx1, windowy1, windowx2, windowy2);
*/
}
}
}
END_DUKE_NS

View file

@ -24,6 +24,4 @@ protected:
PalEntry LightForShade(int shade);
};
void drawstatusbar(int snum);
END_DUKE_NS

View file

@ -1444,8 +1444,6 @@ static void postloadplayer(int32_t savegamep)
FX_SetReverb(0);
}
}
//5
G_ResetInterpolations();

View file

@ -41,6 +41,7 @@ BEGIN_DUKE_NS
void drawstatusbar_d(int snum);
void drawstatusbar_r(int snum);
void drawoverheadmap(int cposx, int cposy, int czoom, int cang);
int32_t g_crosshairSum = -1;
// yxaspect and viewingrange just before the 'main' drawrooms call
@ -222,294 +223,6 @@ static inline void G_MoveClouds(void)
}
}
static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16_t cang)
{
int32_t i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff;
int32_t dax, day, cosang, sinang, xspan, yspan, sprx, spry;
int32_t xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
int32_t xvect, yvect, xvect2, yvect2;
int16_t p;
PalEntry col;
uwalltype *wal, *wal2;
spritetype *spr;
int32_t tmpydim = (xdim*5)/8;
renderSetAspect(65536, divscale16(tmpydim*320, xdim*200));
xvect = sintable[(-cang)&2047] * czoom;
yvect = sintable[(1536-cang)&2047] * czoom;
xvect2 = mulscale16(xvect, yxaspect);
yvect2 = mulscale16(yvect, yxaspect);
//Draw red lines
for (i=numsectors-1; i>=0; i--)
{
if (!gFullMap && !show2dsector[i]) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
z1 = sector[i].ceilingz;
z2 = sector[i].floorz;
for (j=startwall, wal=(uwalltype *)&wall[startwall]; j<endwall; j++, wal++)
{
k = wal->nextwall;
if (k < 0) continue;
if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2)
if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue;
if (!gFullMap && !show2dsector[wal->nextsector])
{
col = PalEntry(170, 170, 170);
ox = wal->x-cposx;
oy = wal->y-cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
wal2 = (uwalltype *)&wall[wal->point2];
ox = wal2->x-cposx;
oy = wal2->y-cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
drawlinergb(x1, y1, x2, y2, col);
}
}
}
//Draw sprites
k = g_player[screenpeek].ps->i;
/*if (!FURY)*/ for (i=numsectors-1; i>=0; i--) // todo - make a switchable flag.
{
if (!gFullMap || !show2dsector[i]) continue;
for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
{
spr = &sprite[j];
if (j == k || (spr->cstat&0x8000) || spr->cstat == 257 || spr->xrepeat == 0) continue;
col = PalEntry(0, 170, 170);
if (spr->cstat & 1) col = PalEntry(170, 0, 170);
sprx = spr->x;
spry = spr->y;
if ((spr->cstat&257) != 0) switch (spr->cstat&48)
{
case 0:
// break;
ox = sprx-cposx;
oy = spry-cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = (sintable[(spr->ang+512)&2047]>>7);
oy = (sintable[(spr->ang)&2047]>>7);
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect, ox, yvect);
x3 = mulscale16(x2, yxaspect);
y3 = mulscale16(y2, yxaspect);
drawlinergb(x1-x2+(xdim<<11), y1-y3+(ydim<<11),
x1+x2+(xdim<<11), y1+y3+(ydim<<11), col);
drawlinergb(x1-y2+(xdim<<11), y1+x3+(ydim<<11),
x1+x2+(xdim<<11), y1+y3+(ydim<<11), col);
drawlinergb(x1+y2+(xdim<<11), y1-x3+(ydim<<11),
x1+x2+(xdim<<11), y1+y3+(ydim<<11), col);
break;
case 16:
if (spr->picnum == TILE_LASERLINE)
{
x1 = sprx;
y1 = spry;
tilenum = spr->picnum;
xoff = tileLeftOffset(tilenum) + spr->xoffset;
if ((spr->cstat&4) > 0) xoff = -xoff;
k = spr->ang;
l = spr->xrepeat;
dax = sintable[k&2047]*l;
day = sintable[(k+1536)&2047]*l;
l = tilesiz[tilenum].x;
k = (l>>1)+xoff;
x1 -= mulscale16(dax, k);
x2 = x1+mulscale16(dax, l);
y1 -= mulscale16(day, k);
y2 = y1+mulscale16(day, l);
ox = x1-cposx;
oy = y1-cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x2-cposx;
oy = y2-cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2);
drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col);
}
break;
case 32:
tilenum = spr->picnum;
xoff = tileLeftOffset(tilenum) + spr->xoffset;
yoff = tileTopOffset(tilenum) + spr->yoffset;
if ((spr->cstat&4) > 0) xoff = -xoff;
if ((spr->cstat&8) > 0) yoff = -yoff;
k = spr->ang;
cosang = sintable[(k+512)&2047];
sinang = sintable[k&2047];
xspan = tilesiz[tilenum].x;
xrepeat = spr->xrepeat;
yspan = tilesiz[tilenum].y;
yrepeat = spr->yrepeat;
dax = ((xspan>>1)+xoff)*xrepeat;
day = ((yspan>>1)+yoff)*yrepeat;
x1 = sprx + dmulscale16(sinang, dax, cosang, day);
y1 = spry + dmulscale16(sinang, day, -cosang, dax);
l = xspan*xrepeat;
x2 = x1 - mulscale16(sinang, l);
y2 = y1 + mulscale16(cosang, l);
l = yspan*yrepeat;
k = -mulscale16(cosang, l);
x3 = x2+k;
x4 = x1+k;
k = -mulscale16(sinang, l);
y3 = y2+k;
y4 = y1+k;
ox = x1-cposx;
oy = y1-cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect);
y1 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x2-cposx;
oy = y2-cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x3-cposx;
oy = y3-cposy;
x3 = dmulscale16(ox, xvect, -oy, yvect);
y3 = dmulscale16(oy, xvect2, ox, yvect2);
ox = x4-cposx;
oy = y4-cposy;
x4 = dmulscale16(ox, xvect, -oy, yvect);
y4 = dmulscale16(oy, xvect2, ox, yvect2);
drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col);
drawlinergb(x2+(xdim<<11), y2+(ydim<<11),
x3+(xdim<<11), y3+(ydim<<11), col);
drawlinergb(x3+(xdim<<11), y3+(ydim<<11),
x4+(xdim<<11), y4+(ydim<<11), col);
drawlinergb(x4+(xdim<<11), y4+(ydim<<11),
x1+(xdim<<11), y1+(ydim<<11), col);
break;
}
}
}
//Draw white lines
for (i=numsectors-1; i>=0; i--)
{
if (!gFullMap && !show2dsector[i]) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
k = -1;
for (j=startwall, wal=(uwalltype *)&wall[startwall]; j<endwall; j++, wal++)
{
if (wal->nextwall >= 0) continue;
if (tilesiz[wal->picnum].x == 0) continue;
if (tilesiz[wal->picnum].y == 0) continue;
if (j == k)
{
x1 = x2;
y1 = y2;
}
else
{
ox = wal->x-cposx;
oy = wal->y-cposy;
x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
}
k = wal->point2;
wal2 = (uwalltype *)&wall[k];
ox = wal2->x-cposx;
oy = wal2->y-cposy;
x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
drawlinergb(x1, y1, x2, y2, PalEntry(170, 170, 170));
}
}
videoSetCorrectedAspect();
for (TRAVERSE_CONNECT(p))
{
if (ud.scrollmode && p == screenpeek) continue;
DukePlayer_t const * const pPlayer = g_player[p].ps;
uspritetype const * const pSprite = (uspritetype const *)&sprite[pPlayer->i];
ox = pSprite->x - cposx;
oy = pSprite->y - cposy;
daang = (pSprite->ang - cang) & 2047;
if (p == screenpeek)
{
ox = 0;
oy = 0;
daang = 0;
}
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP))
{
if (pSprite->xvel > 16 && pPlayer->on_ground)
i = TILE_APLAYERTOP+(((int32_t) totalclock>>4)&3);
else
i = TILE_APLAYERTOP;
//i = VM_OnEventWithReturn(EVENT_DISPLAYOVERHEADMAPPLAYER, pPlayer->i, p, i);
if (i < 0)
continue;
j = klabs(pPlayer->truefz - pPlayer->pos.z) >> 8;
j = mulscale16(czoom * (pSprite->yrepeat + j), yxaspect);
if (j < 22000) j = 22000;
else if (j > (65536<<1)) j = (65536<<1);
rotatesprite_win((x1<<4)+(xdim<<15), (y1<<4)+(ydim<<15), j, daang, i, pSprite->shade,
P_GetOverheadPal(pPlayer), 0);
}
}
}
FString G_PrintCoords(int32_t snum)
{
@ -777,7 +490,7 @@ void G_DisplayRest(int32_t smoothratio)
drawbackground();
renderDrawMapView(cposx, cposy, pp->zoom, cang);
}
G_DrawOverheadMap(cposx, cposy, pp->zoom, cang);
drawoverheadmap(cposx, cposy, pp->zoom, cang);
restoreinterpolations();