- render the weapons with the DrawTexture interface and properly handle rotatesprite's alignment modes

This commit is contained in:
Christoph Oelckers 2020-07-16 13:23:26 +02:00
parent a066c5bc4b
commit 55feadd11c
17 changed files with 103 additions and 74 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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.
};

View file

@ -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
{

View file

@ -83,7 +83,6 @@ picanm_t tileConvertAnimFormat(int32_t const picanimraw, int* lo, int* to)
int FTileTexture::CopyPixels(FBitmap* bmp, int conversion)
{
TArray<uint8_t> buffer;
bmp->Create(Width, Height);
auto ppix = GetRawData();
if (ppix)
{

View file

@ -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);
}

View file

@ -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)

View file

@ -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);

View file

@ -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();

View file

@ -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])

View file

@ -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);
}
}
}

View file

@ -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);
}

View file

@ -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

View file

@ -97,7 +97,7 @@ MAIN_LOOP_RESTART:
else
#endif
{
fi.ShowLogo([](bool) {});
//fi.ShowLogo([](bool) {});
}
M_StartControlPanel(false);

View file

@ -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);
}

View file

@ -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);