diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 41de2053f..229bc2a43 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -401,11 +401,10 @@ 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 xrepeat, yrepeat, tilenum, daang; int xvect, yvect, xvect2, yvect2; int p; PalEntry col; - walltype* wal, * wal2; spritetype* spr; xvect = sintable[(-cang) & 2047] * czoom; diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 64ee08af6..f47740433 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1872,4 +1872,207 @@ bool GameInterface::GenerateSavePic() } + + +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; + walltype* wal, * wal2; + spritetype* spr; + short p; + static int pspr_ndx[8] = { 0,0,0,0,0,0,0,0 }; + bool sprisplayer = false; + short txt_x, txt_y; + + xvect = sintable[(2048 - cang) & 2047] * czoom; + yvect = sintable[(1536 - cang) & 2047] * czoom; + xvect2 = mulscale16(xvect, yxaspect); + yvect2 = mulscale16(yvect, yxaspect); + + + // Draw sprites + k = Player[screenpeek].PlayerSprite; + for (i = 0; i < numsectors; i++) + for (j = headspritesect[i]; j >= 0; j = nextspritesect[j]) + { + for (p = connecthead; p >= 0; p = connectpoint2[p]) + { + if (Player[p].PlayerSprite == j) + { + if (sprite[Player[p].PlayerSprite].xvel > 16) + pspr_ndx[myconnectindex] = ((PlayClock >> 4) & 3); + sprisplayer = TRUE; + + goto SHOWSPRITE; + } + } + if (gFullMap || show2dsprite[j]) + { + SHOWSPRITE: + spr = &sprite[j]; + + PalEntry col = GPalette.BaseColors[56]; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple + if ((spr->cstat & 1) > 0) + col = GPalette.BaseColors[248]; + if (j == k) + col = GPalette.BaseColors[31]; + + sprx = spr->x; + spry = spr->y; + + k = spr->statnum; + if ((k >= 1) && (k <= 8) && (k != 2)) // Interpolate moving + { + sprx = sprite[j].x; + spry = sprite[j].y; + } + + switch (spr->cstat & 48) + { + case 0: // Regular sprite + if (Player[p].PlayerSprite == j) + { + ox = sprx - cposx; + oy = spry - cposy; + x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + if (((gotsector[i >> 3] & (1 << (i & 7))) > 0) && (czoom > 192)) + { + daang = (spr->ang - cang) & 2047; + + // Special case tiles + if (spr->picnum == 3123) break; + + int spnum = -1; + if (sprisplayer) + { + if (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite) + spnum = 1196 + pspr_ndx[myconnectindex]; + } + else spnum = spr->picnum; + + double xd = ((x1 << 4) + (xdim << 15)) / 65536.; + double yd = ((y1 << 4) + (ydim << 15)) / 65536.; + double sc = mulscale16(czoom * (spr->yrepeat), yxaspect) / 32768.; + if (spnum >= 0) + { + DrawTexture(twod, tileGetTexture(5407, true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * (-360. / 2048), + DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade), + DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE); + } + } + } + break; + case 16: // Rotated sprite + x1 = sprx; + y1 = spry; + tilenum = spr->picnum; + xoff = (int)tileLeftOffset(tilenum) + (int)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 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + ox = x2 - cposx; + oy = y2 - cposy; + x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + drawlinergb(x1 + (xdim << 11), y1 + (ydim << 11), + x2 + (xdim << 11), y2 + (ydim << 11), col); + + break; + case 32: // Floor sprite + if (automapMode == am_overlay) + { + tilenum = spr->picnum; + xoff = (int)tileLeftOffset(tilenum) + (int)spr->xoffset; + yoff = (int)tileTopOffset(tilenum) + (int)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]; + 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 + mulscale16(sinang, dax) + mulscale16(cosang, day); + y1 = spry + mulscale16(sinang, day) - mulscale16(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 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + ox = x2 - cposx; + oy = y2 - cposy; + x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + ox = x3 - cposx; + oy = y3 - cposy; + x3 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y3 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2); + + ox = x4 - cposx; + oy = y4 - cposy; + x4 = mulscale16(ox, xvect) - mulscale16(oy, yvect); + y4 = mulscale16(oy, xvect2) + mulscale16(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; + } + } + } + return true; +} + + + END_SW_NS diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 7b367eb15..eefdad74d 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2212,6 +2212,7 @@ struct GameInterface : ::GameInterface void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill) override; + bool DrawAutomapPlayer(int x, int y, int z, int a) override; GameStats getStats() override;