mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- re-added the sprite drawer for Duke's automap.
This commit is contained in:
parent
9d39f770d4
commit
2d547a4ef1
3 changed files with 201 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
|
#include "palentry.h"
|
||||||
|
|
||||||
class FSerializer;
|
class FSerializer;
|
||||||
struct event_t;
|
struct event_t;
|
||||||
|
@ -18,6 +19,7 @@ void ClearAutomap();
|
||||||
void MarkSectorSeen(int sect);
|
void MarkSectorSeen(int sect);
|
||||||
void DrawOverheadMap(int x, int y, int ang);
|
void DrawOverheadMap(int x, int y, int ang);
|
||||||
bool AM_Responder(event_t* ev, bool last);
|
bool AM_Responder(event_t* ev, bool last);
|
||||||
|
void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p);
|
||||||
|
|
||||||
enum AM_Mode
|
enum AM_Mode
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,7 @@ struct GameInterface : public ::GameInterface
|
||||||
void NextLevel(MapRecord* map, int skill) override;
|
void NextLevel(MapRecord* map, int skill) override;
|
||||||
void NewGame(MapRecord* map, int skill) override;
|
void NewGame(MapRecord* map, int skill) override;
|
||||||
void LevelCompleted(MapRecord* map, int skill) override;
|
void LevelCompleted(MapRecord* map, int skill) override;
|
||||||
|
bool DrawAutomapPlayer(int x, int y, int z, int a) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,204 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
|
||||||
return new GameInterface;
|
return new GameInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool GameInterface::DrawAutomapPlayer(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;
|
||||||
|
|
||||||
|
xvect = sintable[(-cang) & 2047] * czoom;
|
||||||
|
yvect = sintable[(1536 - cang) & 2047] * czoom;
|
||||||
|
xvect2 = mulscale16(xvect, yxaspect);
|
||||||
|
yvect2 = mulscale16(yvect, yxaspect);
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
||||||
|
{
|
||||||
|
ox = sprite[ps[p].i].x - cposx;
|
||||||
|
oy = sprite[ps[p].i].y - cposy;
|
||||||
|
daang = (sprite[ps[p].i].ang - cang) & 2047;
|
||||||
|
|
||||||
|
x1 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||||
|
y1 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||||
|
|
||||||
|
if (p == screenpeek || ud.coop == 1)
|
||||||
|
{
|
||||||
|
auto& pp = ps[p];
|
||||||
|
if (sprite[pp.i].xvel > 16 && pp.on_ground)
|
||||||
|
i = TILE_APLAYERTOP + ((ud.levelclock >> 4) & 3);
|
||||||
|
else
|
||||||
|
i = TILE_APLAYERTOP;
|
||||||
|
|
||||||
|
j = klabs(pp.truefz - pp.posz) >> 8;
|
||||||
|
j = mulscale(czoom * (sprite[pp.i].yrepeat + j), yxaspect, 16);
|
||||||
|
|
||||||
|
if (j < 22000) j = 22000;
|
||||||
|
else if (j > (65536 << 1)) j = (65536 << 1);
|
||||||
|
|
||||||
|
DrawTexture(twod, tileGetTexture(i), xdim / 2. + x1 / 4096., ydim / 2. + y1 / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + pp.palette, sprite[pp.i].pal), DTA_CenterOffset, true,
|
||||||
|
DTA_Rotate, daang * (-360./2048), DTA_Color, shadeToLight(sprite[pp.i].shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
END_DUKE_NS
|
END_DUKE_NS
|
||||||
|
|
Loading…
Reference in a new issue