diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 3d0800185..8b2718bfc 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -976,7 +976,7 @@ static void gameTicker() static void drawBackground() { twod->ClearScreen(); - rotatesprite(160 << 16, 100 << 16, 65536, 0, 2518, 0, 0, 0x4a, 0, 0, xdim - 1, ydim - 1); + DrawTexture(twod, tileGetTexture(2518), 0, 0, DTA_FullscreenEx, 3, TAG_DONE); if (gQuitRequest && !gQuitGame) netBroadcastMyLogoff(gQuitRequest == 2); } diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 45103f7e8..c270cbcb7 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -269,10 +269,17 @@ FSavegameInfo GameInterface::GetSaveSig() void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) { - int height; + int height, width; // font #1, tile #2038. - viewGetFontInfo(1, NULL, NULL, &height); - rotatesprite(int(origin.X * 65536) + (320 << 15), 20 << 16, 65536, 0, 2038, -128, 0, 78, 0, 0, xdim - 1, ydim - 1); + + viewGetFontInfo(1, text, &width, &height); + + double scalex = 1.; // Expand the box if the text is longer + int boxwidth = tileWidth(2038); + if (boxwidth - 10 < width) scalex = double(width) / (boxwidth - 10); + + DrawTexture(twod, tileGetTexture(2038), 160, 20, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex, TAG_DONE); + viewDrawText(1, text, 160, 20 - height / 2, -128, 0, 1, false); } diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index d23418f72..d46e293be 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! #include "build.h" +#include "v_draw.h" #include "common.h" #include "mmulti.h" #include "common_game.h" @@ -54,7 +55,7 @@ void CEndGameMgr::Draw(void) viewLoadingScreenWide(); int nHeight; viewGetFontInfo(1, NULL, NULL, &nHeight); - rotatesprite(160<<16, 20<<16, 65536, 0, 2038, -128, 0, 6, 0, 0, xdim-1, ydim-1); + DrawTexture(twod, tileGetTexture(2038), 160, 20, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); int nY = 20 - nHeight / 2; if (gGameOptions.nGameType == 0) { diff --git a/source/blood/src/map2d.cpp b/source/blood/src/map2d.cpp index e8bffc41a..59cca16d9 100644 --- a/source/blood/src/map2d.cpp +++ b/source/blood/src/map2d.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "map2d.h" #include "view.h" #include "v_2ddrawer.h" +#include "v_draw.h" BEGIN_BLD_NS @@ -156,8 +157,11 @@ void sub_2541C(int x, int y, int z, short a) int nScale = mulscale((pSprite->yrepeat+((floorZ-nBottom)>>8))*z, yxaspect, 16); nScale = ClipRange(nScale, 8000, 65536<<1); // Players on automap - rotatesprite((xdim<<15)+(x1<<4), (ydim<<15)+(y1<<4), nScale, pa, nTile, pSprite->shade, pSprite->pal, (pSprite->cstat&2)>>1, - windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); + double x = xdim/2. + x1 / double(1<<12); + double y = ydim/2. + y1 / double(1<<12); + // This very likely needs fixing later + DrawTexture(twod, tileGetTexture(nTile), x, y, DTA_FullscreenScale, 3, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, + DTA_ViewportWidth, windowxy2.x - windowxy1.x+1, DTA_ViewportHeight, windowxy2.y - windowxy1.y+1, DTA_Alpha, (pSprite->cstat&2? 0.5:1.), TAG_DONE); } } } diff --git a/source/blood/src/qav.cpp b/source/blood/src/qav.cpp index cc4af87cd..429aadaa1 100644 --- a/source/blood/src/qav.cpp +++ b/source/blood/src/qav.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "common_game.h" #include "qav.h" #include "sound.h" +#include "v_draw.h" BEGIN_BLD_NS @@ -47,32 +48,35 @@ int qavRegisterClient(void(*pClient)(int, void *)) void DrawFrame(F2DDrawer *twod, int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum, int basepal, bool to3dview) { stat |= pTile->stat; - int angle = pTile->angle; - if (stat & 0x100) - { - angle = (angle+1024)&2047; - stat &= ~0x100; - stat ^= 0x4; - } - if (stat & kQavOrientationLeft) - { - stat &= ~kQavOrientationLeft; - stat |= 256; - } - if (palnum <= 0) - palnum = pTile->palnum; + x += pTile->x; + y += pTile->y; + auto tex = tileGetTexture(pTile->picnum); + double scale = pTile->z/65536.; + double angle = pTile->angle * (360./2048); + int renderstyle = (stat & RS_NOMASK)? STYLE_Normal : STYLE_Translucent; + double alpha = (stat & RS_TRANS1)? glblend[0].def[!!(stat & RS_TRANS2)].alpha : 1.; + int pin = (stat & kQavOrientationLeft)? -1 : (stat & RS_ALIGN_R)? 1:0; + if (palnum <= 0) palnum = pTile->palnum; + auto translation = TRANSLATION(Translation_Remap + basepal, palnum); + bool topleft = !!(stat & RS_TOPLEFT); + + bool xflip = !!(stat & 0x100); // repurposed flag + bool yflip = !!(stat & RS_YFLIP); + shade = clamp(pTile->shade + shade, 0, numshades-1); + int light = ::scale(numshades-1-shade, 255, numshades-1); + PalEntry color(255,light,light,light); if (!to3dview) { - twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle, - pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat, - 0, 0, 0, 0, twod->GetWidth(), twod->GetHeight(), nullptr, basepal); + DrawTexture(twod, tex, x, y, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Rotate, angle, DTA_LegacyRenderStyle, renderstyle, DTA_Alpha, alpha, DTA_Pin, pin, DTA_TranslationIndex, translation, + DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, !topleft, DTA_Color, color, + DTA_FlipX, xflip, DTA_FlipY, yflip, TAG_DONE); } else { - twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle, - pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat, - 0, 0, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, nullptr, basepal); + DrawTexture(twod, tex, x, y, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Rotate, angle, DTA_LegacyRenderStyle, renderstyle, DTA_Alpha, alpha, DTA_Pin, pin, DTA_TranslationIndex, translation, + DTA_TopLeft, topleft, DTA_CenterOffsetRel, !topleft, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_FlipOffsets, !topleft, DTA_Color, color, + DTA_FlipX, xflip, DTA_FlipY, yflip, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x+1, DTA_ViewportHeight, windowxy2.y - windowxy1.y+1, TAG_DONE); } }