From 55feadd11c6c48885f0661099dc68cb06f540b9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Jul 2020 13:23:26 +0200 Subject: [PATCH] - render the weapons with the DrawTexture interface and properly handle rotatesprite's alignment modes --- source/build/include/build.h | 3 --- source/build/src/engine.cpp | 9 -------- source/common/2d/v_draw.cpp | 31 +++++++++++++++++++++++---- source/common/2d/v_draw.h | 3 +++ source/core/statusbar.cpp | 2 +- source/core/textures/buildtiles.cpp | 1 - source/exhumed/src/enginesubs.cpp | 4 +--- source/games/duke/src/2d_d.cpp | 22 +++++++++---------- source/games/duke/src/2d_r.cpp | 2 +- source/games/duke/src/d_menu.cpp | 12 +++++------ source/games/duke/src/game_misc.cpp | 6 +++--- source/games/duke/src/hudweapon_d.cpp | 16 +++++++------- source/games/duke/src/hudweapon_r.cpp | 28 ++++++++++++------------ source/games/duke/src/inlines.h | 14 +++++------- source/games/duke/src/zz_game.cpp | 2 +- source/glbackend/glbackend.cpp | 20 +++++++++++++++++ source/glbackend/glbackend.h | 2 ++ 17 files changed, 103 insertions(+), 74 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index ef3da8baa..89a38e1f7 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -344,9 +344,6 @@ EXTERN int32_t wx1, wy1, wx2, wy2; EXTERN int32_t xdim, ydim, numpages, upscalefactor; EXTERN int32_t yxaspect, viewingrange; -EXTERN int32_t rotatesprite_y_offset; -EXTERN int32_t rotatesprite_yxaspect; - #ifndef GEKKO #define MAXVALIDMODES 256 #else diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 00b50d430..5e4416c32 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1128,9 +1128,6 @@ int32_t engineInit(void) xyaspect = -1; - rotatesprite_y_offset = 0; - rotatesprite_yxaspect = 65536; - showinvisibility = 0; voxelmemory.Reset(); @@ -1948,8 +1945,6 @@ static int32_t dorotspr_handle_bit2(int32_t* sxptr, int32_t* syptr, int32_t* z, int32_t zoomsc, sx = *sxptr, sy = *syptr; int32_t ouryxaspect = yxaspect, ourxyaspect = xyaspect; - sy += rotatesprite_y_offset; - if (!(dastat & RS_STRETCH) && 4 * ydim <= 3 * xdim) { if ((dastat & RS_ALIGN_MASK) && (dastat & RS_ALIGN_MASK) != RS_ALIGN_MASK) @@ -1964,9 +1959,6 @@ static int32_t dorotspr_handle_bit2(int32_t* sxptr, int32_t* syptr, int32_t* z, ourxyaspect = (10 << 16) / 12; } - ouryxaspect = mulscale16(ouryxaspect, rotatesprite_yxaspect); - ourxyaspect = divscale16(ourxyaspect, rotatesprite_yxaspect); - // screen center to s[xy], 320<<16 coords. const int32_t normxofs = sx - (320 << 15), normyofs = sy - (200 << 15); @@ -1981,7 +1973,6 @@ static int32_t dorotspr_handle_bit2(int32_t* sxptr, int32_t* syptr, int32_t* z, sx = ((twice_midcx) << 15) + scaledxofs; zoomsc = xdimenscale; //= scale(xdimen,yxaspect,320); - zoomsc = mulscale16(zoomsc, rotatesprite_yxaspect); if ((dastat & RS_ALIGN_MASK) == RS_ALIGN_MASK) zoomsc = scale(zoomsc, ydim, oydim); diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index dfc2f5232..c0505a9ac 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -441,7 +441,8 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do // First calculate the destination rect for an image of the given size and then reposition this object in it. DoubleRect rect; CalcFullscreenScale(drawer, parms, parms->virtWidth, parms->virtHeight, parms->fsscalemode, rect); - parms->x = parms->viewport.left + (parms->keepratio? 0 : rect.left) + parms->x * rect.width / parms->virtWidth; + double adder = parms->keepratio < 0 ? 0 : parms->keepratio == 0 ? rect.left : 2 * rect.left; + parms->x = parms->viewport.left + adder + parms->x * rect.width / parms->virtWidth; parms->y = parms->viewport.top + rect.top + parms->y * rect.height / parms->virtHeight; parms->destwidth = parms->destwidth * rect.width / parms->virtWidth; parms->destheight = parms->destheight * rect.height / parms->virtHeight; @@ -454,7 +455,7 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do { DoubleRect rect; CalcFullscreenScale(drawer, parms, parms->texwidth, parms->texheight, parms->fsscalemode, rect); - parms->keepratio = true; + parms->keepratio = -1; parms->x = parms->viewport.left + rect.left; parms->y = parms->viewport.top + rect.top; parms->destwidth = rect.width; @@ -872,6 +873,16 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->left = ListGetDouble(tags); break; + case DTA_TopLeft: + assert(fortext == false); + if (fortext) return false; + if (ListGetInt(tags)) + { + parms->left = 0; + parms->top = 0; + } + break; + case DTA_CenterOffset: assert(fortext == false); if (fortext) return false; @@ -882,6 +893,16 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double } break; + case DTA_CenterOffsetRel: + assert(fortext == false); + if (fortext) return false; + if (ListGetInt(tags)) + { + parms->left = img->GetDisplayLeftOffset() + img->GetDisplayWidth() * 0.5; + parms->top = img->GetDisplayTopOffset() + img->GetDisplayHeight() * 0.5; + } + break; + case DTA_CenterBottomOffset: assert(fortext == false); if (fortext) return false; @@ -986,8 +1007,10 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_KeepRatio: - // I think this is a terribly misleading name, since it actually turns - // *off* aspect ratio correction. + parms->keepratio = ListGetInt(tags) ? 0 : -1; + break; + + case DTA_Pin: parms->keepratio = ListGetInt(tags); break; diff --git a/source/common/2d/v_draw.h b/source/common/2d/v_draw.h index db743e862..4a1005137 100644 --- a/source/common/2d/v_draw.h +++ b/source/common/2d/v_draw.h @@ -100,6 +100,9 @@ enum DTA_ViewportY, DTA_ViewportWidth, DTA_ViewportHeight, + DTA_CenterOffsetRel, // Apply texture offsets relative to center, instead of top left. This is standard alignment for Build's 2D content. + DTA_TopLeft, // always align to top left. Added to have a boolean condition for this alignment. + DTA_Pin, // Pin a non-widescreen image to the left/right edge of the screen. }; diff --git a/source/core/statusbar.cpp b/source/core/statusbar.cpp index 55287ac48..c5a225ac8 100644 --- a/source/core/statusbar.cpp +++ b/source/core/statusbar.cpp @@ -388,7 +388,7 @@ void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, doub int vres = VerticalResolution; ValidateResolution(hres, vres); - VirtualToRealCoords(twod, x, y, w, h, hres, vres, true, true); + VirtualToRealCoords(twod, x, y, w, h, hres, vres, true); } else { diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index 086e012ee..516a311a7 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -83,7 +83,6 @@ picanm_t tileConvertAnimFormat(int32_t const picanimraw, int* lo, int* to) int FTileTexture::CopyPixels(FBitmap* bmp, int conversion) { TArray buffer; - bmp->Create(Width, Height); auto ppix = GetRawData(); if (ppix) { diff --git a/source/exhumed/src/enginesubs.cpp b/source/exhumed/src/enginesubs.cpp index c4fc253d1..a5aa5ffa1 100644 --- a/source/exhumed/src/enginesubs.cpp +++ b/source/exhumed/src/enginesubs.cpp @@ -80,8 +80,7 @@ static int32_t xdim_to_320_16(int32_t x) static int32_t ydim_to_200_16(int32_t y) { - y = scale(y, 200<<16, ydim); - return divscale16(y - (200<<15), rotatesprite_yxaspect) - rotatesprite_y_offset + (200<<15); + return scale(y, 200<<16, ydim); } static int32_t xdim_from_320_16(int32_t x) @@ -92,7 +91,6 @@ static int32_t xdim_from_320_16(int32_t x) static int32_t ydim_from_200_16(int32_t y) { - y = mulscale16(y + rotatesprite_y_offset - (200<<15), rotatesprite_yxaspect) + (200<<15); return scale(y, ydim, 200<<16); } diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 4555de733..714fe26a4 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -223,19 +223,19 @@ public: double scale = clamp(clock - 120, 0, 60) / 64.; if (scale > 0.) DrawTexture(twod, tileGetTexture(DUKENUKEM, true), 160, 104, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffset, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); + DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); scale = clamp(clock - 220, 0, 30) / 32.; if (scale > 0.) DrawTexture(twod, tileGetTexture(THREEDEE, true), 160, 129, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffset, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); + DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); if (PLUTOPAK) { scale = (410 - clamp(clock, 280, 395)) / 16.; if (scale > 0. && clock > 280) DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+1, true), 160, 151, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffset, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); + DTA_CenterOffsetRel, true, DTA_TranslationIndex, translation, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); } if (clock > (860 + 120)) @@ -315,7 +315,7 @@ public: twod->ClearScreen(); DrawTexture(twod, tileGetTexture(VICTORY1, true), 0, 50, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, DTA_TopLeft, true, TAG_DONE); // boss @@ -329,7 +329,7 @@ public: bonuscnt++; } DrawTexture(twod, tileGetTexture(bossmove[t + 2], true), bossmove[t + 3], bossmove[t + 4], DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_TranslationIndex, translation, TAG_DONE); + DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); } // Breathe @@ -338,7 +338,7 @@ public: if (totalclock >= 750) { DrawTexture(twod, tileGetTexture(VICTORY1 + 8, true), 86, 59, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_TranslationIndex, translation, TAG_DONE); + DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); if (totalclock >= 750 && bonuscnt == 2) { S_PlaySound(DUKETALKTOBOSS, CHAN_AUTO, CHANF_UI); @@ -354,7 +354,7 @@ public: bonuscnt++; } DrawTexture(twod, tileGetTexture(breathe[t + 2], true), breathe[t + 3], breathe[t + 4], DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_TranslationIndex, translation, TAG_DONE); + DTA_TranslationIndex, translation, DTA_TopLeft, true, TAG_DONE); } } // Only end after having faded out. @@ -686,9 +686,9 @@ public: int totalclock = int(clock * 120 / 1'000'000'000); twod->ClearScreen(); DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); if (PLUTOPAK) - DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(PLUTOPAKSPRITE+2, true), 260, 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); GameText(160, 58 + 2, GStrings("Multiplayer Totals"), 0, 0); GameText(160, 58 + 10, currentLevel->DisplayName(), 0, 0); @@ -920,7 +920,7 @@ public: else { int tile = val == 2 || val == 3 ? gfx_offset + 4 : gfx_offset + 3; - DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); } } else if (totalclock > (10240 + 120L)) return 0; @@ -928,7 +928,7 @@ public: { int val = (totalclock >> 5) & 3; int tile = val == 2 ? gfx_offset + 2 : gfx_offset + 1; - DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); + DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); } if (totalclock > 10240 && totalclock < 10240 + 10240) diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index addf802ba..e72f9608e 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -271,7 +271,7 @@ public: DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); double scale = 0.36; DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffset, true, DTA_ScaleX, scale, DTA_ScaleY, 0.36, TAG_DONE); + DTA_CenterOffsetRel, true, DTA_ScaleX, scale, DTA_ScaleY, 0.36, TAG_DONE); GameText(160, 58, GStrings("Multiplayer Totals"), 0, 0); GameText(160, 58 + 10, currentLevel->DisplayName(), 0, 0); diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 2ec7b92ef..e4a6cbb23 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -71,7 +71,7 @@ static void Menu_DrawCursor(double x, double y, double scale, bool right) else picnum = TILE_SPINNINGNUKEICON + frames - 1 - ((frames - 1 + ((int)totalclock >> 3)) % frames); int light = int(224 + 31 * sin((int)totalclock / 20.)); PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); } //---------------------------------------------------------------------------- @@ -142,20 +142,20 @@ class DukeMainMenu : public DukeListMenu double x = origin.X + 160; if (isRRRA()) { - DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterBottomOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true, TAG_DONE); } else if (isRR()) { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x+5, origin.Y + 24, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x+5, origin.Y + 24, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true, TAG_DONE); } else { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x, origin.Y + 29, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x, origin.Y + 29, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_CenterOffsetRel, true, TAG_DONE); if (PLUTOPAK) { int light = 224 + 31 * sin(int(totalclock) / 40.); PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(TILE_PLUTOPAKSPRITE + 2), x + 100, origin.Y + 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, pe, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_PLUTOPAKSPRITE + 2), x + 100, origin.Y + 36, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); } } @@ -330,7 +330,7 @@ FSavegameInfo GameInterface::GetSaveSig() void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) { - DrawTexture(twod, tileGetTexture(TILE_MENUBAR), origin.X + 160, origin.Y + 19, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffset, 1, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_MENUBAR), origin.X + 160, origin.Y + 19, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffsetRel, 1, TAG_DONE); FString t = text; size_t newlen = t.Len(); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index bed839da2..33590becb 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -358,8 +358,8 @@ void displayrest(int smoothratio) if (isRR()) crosshair_scale *= .5; DrawTexture(twod, tileGetTexture(a), 160 - (ps[myconnectindex].getlookang() >> 1), 100, - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, - DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x, DTA_ViewportY, windowxy2.y - windowxy1.y, TAG_DONE); + DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true, + DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, TAG_DONE); } } @@ -676,7 +676,7 @@ void cameratext(int i) { auto drawitem = [=](int tile, double x, double y, bool flipx, bool flipy) { - DrawTexture(twod, tileGetTexture(tile), x, y, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_CenterOffset, true, + DrawTexture(twod, tileGetTexture(tile), x, y, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_CenterOffsetRel, true, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, DTA_FlipX, flipx, DTA_FlipY, flipy, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, TAG_DONE); }; if (!hittype[i].temp_data[0]) diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 9da96cb25..2e4c358eb 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -49,9 +49,9 @@ int getavel(int snum) // //--------------------------------------------------------------------------- -inline static void hud_drawpal(int x, int y, int tilenum, int shade, int orientation, int p) +inline static void hud_drawpal(double x, double y, int tilenum, int shade, int orientation, int p) { - hud_drawsprite(x << 16, y << 16, 65536, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 65536, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); } //--------------------------------------------------------------------------- @@ -74,7 +74,7 @@ void displayloogie(short snum) x = (-getavel(snum)) + (sintable[((ps[snum].loogcnt + i) << 6) & 2047] >> 10); hud_drawsprite( - (ps[snum].loogiex[i] + x) << 16, (200 + ps[snum].loogiey[i] - y) << 16, z - (i << 8), 256 - a, + (ps[snum].loogiex[i] + x), (200 + ps[snum].loogiey[i] - y), z - (i << 8), 256 - a, LOOGIE, 0, 0, 2); } } @@ -109,8 +109,8 @@ int animatefist(int gs, int snum) fistpal = sector[ps[snum].cursectnum].floorpal; hud_drawsprite( - (-fisti + 222 + (getavel(snum) >> 4)) << 16, - (looking_arc + fistz) << 16, + (-fisti + 222 + (getavel(snum) >> 4)), + (looking_arc + fistz), fistzoom, 0, FIST, gs, fistpal, 2); return 1; @@ -197,13 +197,13 @@ void displaymasks_d(int snum) { if (ud.screen_size > 4) { - hud_drawsprite(44 << 16, (200 - 8 - tilesiz[SCUBAMASK].y) << 16, 65536, 0, SCUBAMASK, 0, p, 2 + 16); - hud_drawsprite((320 - 43) << 16, (200 - 8 - tilesiz[SCUBAMASK].y) << 16, 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16); + hud_drawsprite(44, (200 - 8 - tilesiz[SCUBAMASK].y), 65536, 0, SCUBAMASK, 0, p, 2 + 16); + hud_drawsprite((320 - 43), (200 - 8 - tilesiz[SCUBAMASK].y), 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16); } else { hud_drawsprite(44 << 16, (200 - tilesiz[SCUBAMASK].y) << 16, 65536, 0, SCUBAMASK, 0, p, 2 + 16); - hud_drawsprite((320 - 43) << 16, (200 - tilesiz[SCUBAMASK].y) << 16, 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16); + hud_drawsprite((320 - 43), (200 - tilesiz[SCUBAMASK].y), 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16); } } } diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index afde542a0..7e0519ec8 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -39,22 +39,22 @@ BEGIN_DUKE_NS // //--------------------------------------------------------------------------- -inline static void hud_drawpal(int x, int y, int tilenum, int shade, int orientation, int p, int scale = 32768) +inline static void hud_drawpal(double x, double y, int tilenum, int shade, int orientation, int p, int scale = 32768) { - hud_drawsprite(x << 16, y << 16, scale, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, scale, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); } -inline static void rdmyospal(int x, int y, int tilenum, int shade, int orientation, int p) +inline static void rdmyospal(double x, double y, int tilenum, int shade, int orientation, int p) { hud_drawpal(x, y, tilenum, shade, orientation, p, 36700); } -inline static void rd2myospal(int x, int y, int tilenum, int shade, int orientation, int p) +inline static void rd2myospal(double x, double y, int tilenum, int shade, int orientation, int p) { hud_drawpal(x, y, tilenum, shade, orientation, p, 44040); } -inline static void rd3myospal(int x, int y, int tilenum, int shade, int orientation, int p) +inline static void rd3myospal(double x, double y, int tilenum, int shade, int orientation, int p) { hud_drawpal(x, y, tilenum, shade, orientation, p, 47040); } @@ -78,11 +78,11 @@ void displaymasks_r(int snum) { int pin = 0; if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_STRETCH; - hud_drawsprite((320 - (tilesiz[SCUBAMASK].x >> 1) - 15) << 16, (200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int)totalclock & 2047] >> 10)) << 16, 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin); - hud_drawsprite((320 - tilesiz[SCUBAMASK + 4].x) << 16, (200 - tilesiz[SCUBAMASK + 4].y) << 16, 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin); - hud_drawsprite(tilesiz[SCUBAMASK + 4].x << 16, (200 - tilesiz[SCUBAMASK + 4].y) << 16, 65536, 1024, SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); - hud_drawsprite(35 << 16, (-1) << 16, 65536, 0, SCUBAMASK + 3, 0, p, 2 + 16 + pin); - hud_drawsprite(285 << 16, 200 << 16, 65536, 1024, SCUBAMASK + 3, 0, p, 2 + 16 + pin); + hud_drawsprite((320 - (tilesiz[SCUBAMASK].x >> 1) - 15), (200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int)totalclock & 2047] >> 10)), 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin); + hud_drawsprite((320 - tilesiz[SCUBAMASK + 4].x), (200 - tilesiz[SCUBAMASK + 4].y), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin); + hud_drawsprite(tilesiz[SCUBAMASK + 4].x, (200 - tilesiz[SCUBAMASK + 4].y), 65536, 1024, SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); + hud_drawsprite(35, (-1), 65536, 0, SCUBAMASK + 3, 0, p, 2 + 16 + pin); + hud_drawsprite(285, 200, 65536, 1024, SCUBAMASK + 3, 0, p, 2 + 16 + pin); } } @@ -92,15 +92,15 @@ void displaymasks_r(int snum) // //--------------------------------------------------------------------------- -void ShowMotorcycle(int x, int y, short tilenum, signed char shade, char orientation, char p, short a) +void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, int a) { - hud_drawsprite(x << 16, y << 16, 34816L, a, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 34816, a, tilenum, shade, p, 2 | orientation); } -void ShowBoat(int x, int y, short tilenum, signed char shade, char orientation, char p, short a) +void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, int a) { - hud_drawsprite(x << 16, y << 16, 66048L, a, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 66048, a, tilenum, shade, p, 2 | orientation); } diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 0412d46a3..d05d730e7 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -1,6 +1,7 @@ #pragma once #include "mathutil.h" +#include "glbackend/glbackend.h" // all inline functions. BEGIN_DUKE_NS @@ -174,12 +175,12 @@ constexpr inline int levelnum(int vol, int map) return vol * 1000 + map; } -constexpr int volfromlevelnum(int num) +constexpr inline int volfromlevelnum(int num) { return num > 0 ? num / 1000 : 0; } -constexpr int mapfromlevelnum(int num) +constexpr inline int mapfromlevelnum(int num) { return num > 0 ? num % 1000 : -1; } @@ -190,15 +191,10 @@ constexpr int mapfromlevelnum(int num) // //--------------------------------------------------------------------------- -inline void hud_drawsprite(int sx, int sy, int z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int dastat) -{ - twod_rotatesprite(&twodpsp, sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); -} - -inline void hud_draw(int x, int y, int tilenum, int shade, int orientation) +inline void hud_draw(double x, double y, int tilenum, int shade, int orientation) { int p = sector[ps[screenpeek].cursectnum].floorpal; - hud_drawsprite(x << 16, y << 16, 65536L, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 65536, (orientation & 4) ? 1024 : 0, tilenum, shade, p, 2 | orientation); } END_DUKE_NS diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 84631c542..db72d29b8 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -97,7 +97,7 @@ MAIN_LOOP_RESTART: else #endif { - fi.ShowLogo([](bool) {}); + //fi.ShowLogo([](bool) {}); } M_StartControlPanel(false); diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index ae75d5eb4..166f2a443 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -532,3 +532,23 @@ void precacheMarkedTiles() } } +void hud_drawsprite(double sx, double sy, int z, int a, int picnum, int dashade, int dapalnum, int dastat) +{ + double dz = z / 65536.; + int light = Scale(numshades - clamp(dashade, 0, numshades - 1), 255, numshades); + PalEntry pe(255, light, light, light); + DrawTexture(&twodpsp, tileGetTexture(picnum, true), sx, sy, + DTA_ScaleX, dz, DTA_ScaleY, dz, + DTA_Color, pe, + DTA_TranslationIndex, TRANSLATION(Translation_Remap + curbasepal, dapalnum), + DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, + DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, + DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_CenterOffsetRel, !(dastat & (RS_TOPLEFT | RS_CENTER)), + DTA_TopLeft, !!(dastat & RS_TOPLEFT), + DTA_CenterOffset, !!(dastat & RS_CENTER), + DTA_FlipX, !!(dastat & RS_YFLIP), // the weapon drawer uses y-flip+180° rotation for x-flip but no other transformation. + DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0, + TAG_DONE); +} + diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index e5bb33873..2bd9bcb8c 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -362,3 +362,5 @@ void renderSetVisibility(float v); void renderBeginScene(); void renderFinishScene(); void DrawRateStuff(); + +void hud_drawsprite(double sx, double sy, int z, int a, int picnum, int dashade, int dapalnum, int dastat);