- it continues.

cameratext and the last 3 __STATICs.
This commit is contained in:
Christoph Oelckers 2020-07-03 23:16:12 +02:00
parent d6e021a63d
commit f1a2836877
5 changed files with 97 additions and 50 deletions

View file

@ -45,6 +45,9 @@ EXTERN_CVAR(Int, vid_aspect)
EXTERN_CVAR(Int, uiscale)
CVAR(Bool, ui_screenborder_classic_scaling, true, CVAR_ARCHIVE)
static void VirtualToRealCoords(F2DDrawer* drawer, double Width, double Height, double& x, double& y, double& w, double& h,
double vwidth, double vheight, bool vbottom, bool handleaspect);
// Helper for ActiveRatio and CheckRatio. Returns the forced ratio type, or -1 if none.
int ActiveFakeRatio(int width, int height)
{
@ -332,10 +335,10 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect)
}
static void CalcFullscreenScale(F2DDrawer* drawer, double srcwidth, double srcheight, int autoaspect, DoubleRect &rect)
static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcwidth, double srcheight, int autoaspect, DoubleRect &rect)
{
auto GetWidth = [=]() { return drawer->GetWidth(); };
auto GetHeight = [=]() {return drawer->GetHeight(); };
auto GetWidth = [=]() { return parms->viewport.width; };
auto GetHeight = [=]() {return parms->viewport.height; };
double aspect;
if (srcheight == 200) aspect = srcwidth / 240.;
@ -383,8 +386,8 @@ static void CalcFullscreenScale(F2DDrawer* drawer, double srcwidth, double srche
bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, double xx, double yy)
{
auto GetWidth = [=]() { return drawer->GetWidth(); };
auto GetHeight = [=]() {return drawer->GetHeight(); };
auto GetWidth = [=]() { return parms->viewport.width; };
auto GetHeight = [=]() {return parms->viewport.height; };
if (img != NULL)
{
parms->x = xx;
@ -437,9 +440,9 @@ 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->virtWidth, parms->virtHeight, parms->fsscalemode, rect);
parms->x = (parms->keepratio? 0 : rect.left) + parms->x * rect.width / parms->virtWidth;
parms->y = rect.top + parms->y * rect.height / parms->virtHeight;
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;
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;
return false;
@ -450,10 +453,10 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do
case DTA_FullscreenEx:
{
DoubleRect rect;
CalcFullscreenScale(drawer, parms->texwidth, parms->texheight, parms->fsscalemode, rect);
CalcFullscreenScale(drawer, parms, parms->texwidth, parms->texheight, parms->fsscalemode, rect);
parms->keepratio = true;
parms->x = rect.left;
parms->y = rect.top;
parms->x = parms->viewport.left + rect.left;
parms->y = parms->viewport.top + rect.top;
parms->destwidth = rect.width;
parms->destheight = rect.height;
return false; // Do not call VirtualToRealCoords for this!
@ -482,9 +485,11 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do
}
if (parms->virtWidth != GetWidth() || parms->virtHeight != GetHeight())
{
VirtualToRealCoords(drawer, parms->x, parms->y, parms->destwidth, parms->destheight,
VirtualToRealCoords(drawer, GetWidth(), GetHeight(), parms->x, parms->y, parms->destwidth, parms->destheight,
parms->virtWidth, parms->virtHeight, parms->virtBottom, !parms->keepratio);
}
parms->x += parms->viewport.left;
parms->y += parms->viewport.top;
}
return false;
@ -607,8 +612,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->color = 0xffffffff;
//parms->shadowAlpha = 0;
parms->shadowColor = 0;
parms->virtWidth = drawer->GetWidth();
parms->virtHeight = drawer->GetHeight();
parms->virtWidth = INT_MAX; // these need to match the viewport if not explicitly set, but we do not know that yet.
parms->virtHeight = INT_MAX;
parms->keepratio = false;
parms->style.BlendOp = 255; // Dummy "not set" value
parms->masked = true;
@ -629,6 +634,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->spacing = 0;
parms->fsscalemode = -1;
parms->patchscalex = parms->patchscaley = 1;
parms->viewport = { 0,0,drawer->GetWidth(), drawer->GetHeight() };
// Parse the tag list for attributes. (For floating point attributes,
// consider that the C ABI dictates that all floats be promoted to
@ -1025,11 +1031,29 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->burn = true;
break;
case DTA_ViewportX:
parms->viewport.left = ListGetInt(tags);
break;
case DTA_ViewportY:
parms->viewport.top = ListGetInt(tags);
break;
case DTA_ViewportWidth:
parms->viewport.width = ListGetInt(tags);
break;
case DTA_ViewportHeight:
parms->viewport.height = ListGetInt(tags);
break;
}
tag = ListGetInt(tags);
}
ListEnd(tags);
if (parms->virtWidth == INT_MAX) parms->virtWidth = parms->viewport.width;
if (parms->virtHeight == INT_MAX) parms->virtHeight = parms->viewport.height;
auto clipleft = drawer->clipleft;
auto cliptop = drawer->cliptop;
auto clipwidth = drawer->clipwidth;
@ -1097,11 +1121,9 @@ template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FGameTexture *i
//
//==========================================================================
void VirtualToRealCoords(F2DDrawer *drawer, double &x, double &y, double &w, double &h,
static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height, double &x, double &y, double &w, double &h,
double vwidth, double vheight, bool vbottom, bool handleaspect)
{
auto Width = drawer->GetWidth();
auto Height = drawer->GetHeight();
float myratio = handleaspect ? ActiveRatio (Width, Height) : (4.0f / 3.0f);
// if 21:9 AR, map to 16:9 for all callers.
@ -1142,6 +1164,14 @@ void VirtualToRealCoords(F2DDrawer *drawer, double &x, double &y, double &w, dou
}
}
void VirtualToRealCoords(F2DDrawer* drawer, double& x, double& y, double& w, double& h,
double vwidth, double vheight, bool vbottom, bool handleaspect)
{
auto Width = drawer->GetWidth();
auto Height = drawer->GetHeight();
VirtualToRealCoords(drawer, Width, Height, x, y, w, h, vwidth, vheight, vbottom, handleaspect);
}
DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords)
{
PARAM_PROLOGUE;

View file

@ -2,6 +2,7 @@
#include "v_2ddrawer.h"
#include "c_cvars.h"
#include "intrect.h"
// TagItem definitions for DrawTexture. As far as I know, tag lists
// originated on the Amiga.
@ -92,6 +93,11 @@ enum
DTA_ScaleX,
DTA_ScaleY,
DTA_ViewportX, // Defines the viewport on the screen that should be rendered to.
DTA_ViewportY,
DTA_ViewportWidth,
DTA_ViewportHeight,
};
enum EMonospacing : int
@ -160,6 +166,7 @@ struct DrawParms
double srcx, srcy;
double srcwidth, srcheight;
double patchscalex, patchscaley;
IntRect viewport;
};
struct Va_List

View file

@ -606,6 +606,39 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
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,
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])
{
drawitem(TILE_CAMCORNER, 24, 33, false, false);
drawitem(TILE_CAMCORNER + 1, 320 - 26, 33, false, false);
drawitem(TILE_CAMCORNER + 1, 24, 163, true, true);
drawitem(TILE_CAMCORNER + 1, 320 - 26, 163, false, true);
if ((int)totalclock & 16)
drawitem(TILE_CAMLIGHT, 46, 32, false, false);
}
else
{
int flipbits = ((int)totalclock << 1) & 48;
for (int x = -64; x < 394; x += 64)
for (int y = 0; y < 200; y += 64)
drawitem(TILE_STATIC, x, y, !!((int)totalclock & 8), !!((int)totalclock & 16));
}
}
//---------------------------------------------------------------------------
//
// calculate size of 3D viewport.
@ -657,5 +690,7 @@ void updateviewport(void)
videoSetViewableArea(x1, y1, x2 - 1, y2 - 1);
}
END_DUKE_NS

View file

@ -423,20 +423,17 @@ int G_EnterLevel(int gameMode)
for (TRAVERSE_CONNECT(i))
{
switch (DYNAMICTILEMAP(sector[sprite[g_player[i].ps->i].sectnum].floorpicnum))
int pn = sector[sprite[g_player[i].ps->i].sectnum].floorpicnum;
if (pn == TILE_HURTRAIL || pn == TILE_FLOORSLIME || pn == TILE_FLOORPLASMA)
{
case HURTRAIL__STATIC:
case FLOORSLIME__STATIC:
case FLOORPLASMA__STATIC:
resetweapons(i);
resetinventory(i);
resetweapons(i);
resetinventory(i);
g_player[i].ps->gotweapon.Clear(PISTOL_WEAPON);
g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0;
g_player[i].ps->gotweapon.Clear(PISTOL_WEAPON);
g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0;
g_player[i].ps->curr_weapon = KNEE_WEAPON;
g_player[i].ps->kickback_pic = 0;
break;
g_player[i].ps->curr_weapon = KNEE_WEAPON;
g_player[i].ps->kickback_pic = 0;
}
}

View file

@ -117,28 +117,6 @@ static int32_t gtextsc(int32_t sc)
////////// DISPLAYREST //////////
static void G_DrawCameraText(int16_t i)
{
if (!T1(i))
{
rotatesprite_win(24<<16, 33<<16, 65536L, 0, TILE_CAMCORNER, 0, 0, 2);
rotatesprite_win((320-26)<<16, 34<<16, 65536L, 0, TILE_CAMCORNER+1, 0, 0, 2);
rotatesprite_win(22<<16, 163<<16, 65536L, 512, TILE_CAMCORNER+1, 0, 0, 2+4);
rotatesprite_win((310-10)<<16, 163<<16, 65536L, 512, TILE_CAMCORNER+1, 0, 0, 2);
if ((int32_t) totalclock&16)
rotatesprite_win(46<<16, 32<<16, 65536L, 0, TILE_CAMLIGHT, 0, 0, 2);
}
else
{
int32_t flipbits = ((int32_t) totalclock<<1)&48;
for (bssize_t x=-64; x<394; x+=64)
for (bssize_t y=0; y<200; y+=64)
rotatesprite_win(x<<16, y<<16, 65536L, 0, TILE_STATIC, 0, 0, 2+flipbits);
}
}
static inline void G_MoveClouds(void)
{
int32_t i;