- removed screen tilting code for software renderer.

Since this doesn't work anymore the code is no longer needed - and it stands in the way of doing camera textures purely in hardware.
This commit is contained in:
Christoph Oelckers 2020-03-29 08:36:39 +02:00
parent 2cbbe9ec61
commit 8f3cc0b5af
6 changed files with 11 additions and 319 deletions

View file

@ -3190,46 +3190,21 @@ void viewDrawScreen(bool sceneonly)
char v10 = 0; char v10 = 0;
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0; bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0;
static bool bDeliriumOld = false; static bool bDeliriumOld = false;
int tiltcs, tiltdim; //int tiltcs, tiltdim;
char v4 = powerupCheck(gView, kPwUpCrystalBall) > 0; char v4 = powerupCheck(gView, kPwUpCrystalBall) > 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
renderSetRollAngle(0); renderSetRollAngle(0);
#endif #endif
if (v78 || bDelirium) if (v78 || bDelirium)
{ {
if (videoGetRenderMode() == REND_CLASSIC) if (videoGetRenderMode() != REND_CLASSIC)
{ {
int vr = viewingrange;
if (!tileData(TILTBUFFER))
{
tileAllocTile(TILTBUFFER, 640, 640, 0, 0);
}
if (xdim >= 640 && ydim >= 640)
{
tiltcs = 1;
tiltdim = 640;
}
else
{
tiltcs = 0;
tiltdim = 320;
}
renderSetTarget(TILTBUFFER, tiltdim, tiltdim);
int nAng = v78 & 511;
if (nAng > 256)
{
nAng = 512 - nAng;
}
renderSetAspect(mulscale16(vr, dmulscale32(Cos(nAng), 262144, Sin(nAng), 163840)), yxaspect);
}
#ifdef USE_OPENGL
else
renderSetRollAngle(v78); renderSetRollAngle(v78);
#endif }
} }
else if (v4 && gNetPlayers > 1) else if (v4 && gNetPlayers > 1)
{ {
#if 0 // needs to be redone for pure hardware rendering.
int tmp = ((int)totalclock / 240) % (gNetPlayers - 1); int tmp = ((int)totalclock / 240) % (gNetPlayers - 1);
int i = connecthead; int i = connecthead;
while (1) while (1)
@ -3247,7 +3222,7 @@ void viewDrawScreen(bool sceneonly)
{ {
tileAllocTile(4079, 128, 128, 0, 0); tileAllocTile(4079, 128, 128, 0, 0);
} }
renderSetTarget(4079, 128, 128); r enderSetTarget(4079, 128, 128);
renderSetAspect(65536, 78643); renderSetAspect(65536, 78643);
screen->BeginScene(); screen->BeginScene();
int vd8 = pOther->pSprite->x; int vd8 = pOther->pSprite->x;
@ -3314,6 +3289,7 @@ void viewDrawScreen(bool sceneonly)
renderDrawMasks(); renderDrawMasks();
screen->FinishScene(); screen->FinishScene();
renderRestoreTarget(); renderRestoreTarget();
#endif
} }
else else
{ {
@ -3413,20 +3389,6 @@ void viewDrawScreen(bool sceneonly)
{ {
if (videoGetRenderMode() == REND_CLASSIC) if (videoGetRenderMode() == REND_CLASSIC)
{ {
dassert(tileData(TILTBUFFER) != 0);
renderRestoreTarget();
int vrc = 64 + 4 + 2 + 1024;
if (bDelirium)
{
vrc = 64 + 32 + 4 + 2 + 1 + 1024;
}
int nAng = v78 & 511;
if (nAng > 256)
{
nAng = 512 - nAng;
}
int nScale = dmulscale32(Cos(nAng), 262144, Sin(nAng), 163840) >> tiltcs;
rotatesprite(160 << 16, 100 << 16, nScale, v78 + 512, TILTBUFFER, 0, 0, vrc, gViewX0, gViewY0, gViewX1, gViewY1);
} }
#ifdef USE_OPENGL #ifdef USE_OPENGL
else else

View file

@ -78,7 +78,7 @@ void G_CheckCommandLine()
auto val = Args->CheckValue("-skill"); auto val = Args->CheckValue("-skill");
if (val) if (val)
{ {
ud.m_player_skill = ud.player_skill = std::clamp((int)strtol(val, nullptr, 0), 0, 5); ud.m_player_skill = ud.player_skill = clamp((int)strtol(val, nullptr, 0), 0, 5);
if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1; if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1;
} }
val = Args->CheckValue("-respawn"); val = Args->CheckValue("-respawn");

View file

@ -697,16 +697,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
else else
{ {
int32_t floorZ, ceilZ; int32_t floorZ, ceilZ;
int32_t tiltcx, tiltcy, tiltcs=0; // JBF 20030807
int vr = divscale22(1, sprite[pPlayer->i].yrepeat + 28); int vr = divscale22(1, sprite[pPlayer->i].yrepeat + 28);
int screenTilting = (videoGetRenderMode() == REND_CLASSIC
&& ((ud.screen_tilting && pPlayer->rotscrnang
#ifdef SPLITSCREEN_MOD_HACKS
&& !g_fakeMultiMode
#endif
)));
vr = Blrintf(double(vr) * tan(r_fov * (PI/360.))); vr = Blrintf(double(vr) * tan(r_fov * (PI/360.)));
@ -715,86 +707,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
else else
renderSetAspect(mulscale16(vr, viewingrange), yxaspect); renderSetAspect(mulscale16(vr, viewingrange), yxaspect);
if (screenTilting) if (videoGetRenderMode() >= REND_POLYMOST)
{
int32_t oviewingrange = viewingrange; // save it from renderSetAspect()
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
if (tang == 1024)
screenTilting = 2;
else
{
// Maximum possible allocation size passed to allocache() below
// since there is no equivalent of free() for allocache().
#if MAXYDIM >= 640
int const maxTiltSize = 640*640;
#else
int const maxTiltSize = 320*320;
#endif
// To render a tilted screen in high quality, we need at least
// 640 pixels of *Y* dimension.
#if MAXYDIM >= 640
// We also need
// * xdim >= 640 since tiltcx will be passed as setview()'s x2
// which must be less than xdim.
// * ydim >= 640 (sic!) since the tile-to-draw-to will be set
// up with dimension 400x640, but the engine's arrays like
// lastx[] are alloc'd with *xdim* elements! (This point is
// the dynamic counterpart of the #if above since we now
// allocate these engine arrays tightly.)
// XXX: The engine should be in charge of setting up everything
// so that no oob access occur.
if (xdim >= 640 && ydim >= 640)
{
tiltcs = 2;
tiltcx = 640;
tiltcy = 400;
}
else
#endif
{
// JBF 20030807: Increased tilted-screen quality
tiltcs = 1;
// NOTE: The same reflections as above apply here, too.
// TILT_SETVIEWTOTILE_320.
tiltcx = 320;
tiltcy = 200;
}
// If the view is rotated (not 0 or 180 degrees modulo 360 degrees),
// we render onto a square tile and display a portion of that
// rotated on-screen later on.
const int32_t viewtilexsiz = (tang&1023) ? tiltcx : tiltcy;
const int32_t viewtileysiz = tiltcx;
TileFiles.tileCreate(TILE_TILT, tiltcx, tiltcx);
renderSetTarget(TILE_TILT, viewtilexsiz, viewtileysiz);
if ((tang&1023) == 512)
{
//Block off unscreen section of 90ø tilted screen
int const j = tiltcx-(60*tiltcs);
for (bssize_t i=(60*tiltcs)-1; i>=0; i--)
{
startumost[i] = 1;
startumost[i+j] = 1;
startdmost[i] = 0;
startdmost[i+j] = 0;
}
}
int vRange = (tang & 511);
if (vRange > 256)
vRange = 512 - vRange;
vRange = sintable[vRange + 512] * 8 + sintable[vRange] * 5;
renderSetAspect(mulscale16(oviewingrange, vRange >> 1), yxaspect);
}
}
else if (videoGetRenderMode() >= REND_POLYMOST)
{ {
if (ud.screen_tilting) if (ud.screen_tilting)
{ {
@ -950,50 +863,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
#endif #endif
screen->FinishScene(); screen->FinishScene();
} }
if (screenTilting)
{
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
if (screenTilting == 2) // tang == 1024
{
videoBeginDrawing();
{
const int32_t height = windowxy2.y-windowxy1.y+1;
const int32_t width = windowxy2.x-windowxy1.x+1;
uint8_t *f = (uint8_t *)(frameplace + ylookup[windowxy1.y]);
int32_t x, y;
for (y=0; y < (height>>1); y++)
swapbufreverse(f + y*bytesperline + windowxy2.x,
f + (height-1-y)*bytesperline + windowxy1.x,
width);
f += (height>>1)*bytesperline + windowxy1.x;
if (height&1)
for (x=0; x<(width>>1); x++)
swapchar(&f[x], &f[width-1-x]);
}
videoEndDrawing();
}
else
{
renderRestoreTarget();
picanm[TILE_TILT].xofs = picanm[TILE_TILT].yofs = 0;
int tiltZoom = (tang&511);
if (tiltZoom > 256)
tiltZoom = 512 - tiltZoom;
tiltZoom = sintable[tiltZoom + 512] * 8 + sintable[tiltZoom] * 5;
tiltZoom >>= tiltcs; // JBF 20030807
rotatesprite_win(160 << 16, 100 << 16, tiltZoom, tang + 512, TILE_TILT, 0, 0, 4 + 2 + 64 + 1024);
}
}
} }
G_RestoreInterpolations(); G_RestoreInterpolations();

View file

@ -34,6 +34,7 @@
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <vector>
#include "wglext.h" #include "wglext.h"
#include "gl_sysfb.h" #include "gl_sysfb.h"

View file

@ -76,7 +76,7 @@ void G_CheckCommandLine()
auto val = Args->CheckValue("-skill"); auto val = Args->CheckValue("-skill");
if (val) if (val)
{ {
ud.m_player_skill = ud.player_skill = std::clamp((int)strtol(val, nullptr, 0), 0, 5); ud.m_player_skill = ud.player_skill = clamp((int)strtol(val, nullptr, 0), 0, 5);
if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1; if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1;
} }
val = Args->CheckValue("-respawn"); val = Args->CheckValue("-respawn");

View file

@ -904,14 +904,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
else else
{ {
int32_t floorZ, ceilZ; int32_t floorZ, ceilZ;
int32_t tiltcx, tiltcy, tiltcs=0; // JBF 20030807
int const vr = divscale22(1, RR ? 64 : (sprite[pPlayer->i].yrepeat + 28)); int const vr = divscale22(1, RR ? 64 : (sprite[pPlayer->i].yrepeat + 28));
int screenTilting = (videoGetRenderMode() == REND_CLASSIC && (((ud.screen_tilting && pPlayer->rotscrnang) || (RR && pPlayer->drink_amt > 89)
#ifdef SPLITSCREEN_MOD_HACKS
&& !g_fakeMultiMode
#endif
)));
viewingRange = Blrintf(float(vr) * tanf(r_fov * (PI/360.f))); viewingRange = Blrintf(float(vr) * tanf(r_fov * (PI/360.f)));
@ -927,98 +921,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
} }
} }
if (g_screenCapture) if (videoGetRenderMode() >= REND_POLYMOST && (ud.screen_tilting
{
TileFiles.tileCreate(TILE_SAVESHOT, 200, 320);
//if (videoGetRenderMode() == REND_CLASSIC)
renderSetTarget(TILE_SAVESHOT, 200, 320);
}
else if (screenTilting)
{
int32_t oviewingrange = viewingrange; // save it from setaspect()
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
if (tang == 1024)
screenTilting = 2;
else
{
// Maximum possible allocation size passed to allocache() below
// since there is no equivalent of free() for allocache().
#if MAXYDIM >= 640
int const maxTiltSize = 640*640;
#else
int const maxTiltSize = 320*320;
#endif
// To render a tilted screen in high quality, we need at least
// 640 pixels of *Y* dimension.
#if MAXYDIM >= 640
// We also need
// * xdim >= 640 since tiltcx will be passed as setview()'s x2
// which must be less than xdim.
// * ydim >= 640 (sic!) since the tile-to-draw-to will be set
// up with dimension 400x640, but the engine's arrays like
// lastx[] are alloc'd with *xdim* elements! (This point is
// the dynamic counterpart of the #if above since we now
// allocate these engine arrays tightly.)
// XXX: The engine should be in charge of setting up everything
// so that no oob access occur.
if (xdim >= 640 && ydim >= 640 && (!RRRA || pPlayer->drink_amt <= 89))
{
tiltcs = 2;
tiltcx = 640;
tiltcy = 400;
}
else
#endif
{
// JBF 20030807: Increased tilted-screen quality
tiltcs = 1;
// NOTE: The same reflections as above apply here, too.
// TILT_SETVIEWTOTILE_320.
tiltcx = 320;
tiltcy = 200;
}
// If the view is rotated (not 0 or 180 degrees modulo 360 degrees),
// we render onto a square tile and display a portion of that
// rotated on-screen later on.
const int32_t viewtilexsiz = (tang&1023) ? tiltcx : tiltcy;
const int32_t viewtileysiz = tiltcx;
TileFiles.tileCreate(TILE_TILT, tiltcx, tiltcx);
renderSetTarget(TILE_TILT, viewtilexsiz, viewtileysiz);
if ((tang&1023) == 512)
{
//Block off unscreen section of 90ø tilted screen
int const j = tiltcx-(60*tiltcs);
for (bssize_t i=(60*tiltcs)-1; i>=0; i--)
{
startumost[i] = 1;
startumost[i+j] = 1;
startdmost[i] = 0;
startdmost[i+j] = 0;
}
}
int vRange = (tang & 511);
if (vRange > 256)
vRange = 512 - vRange;
vRange = sintable[vRange + 512] * 8 + sintable[vRange] * 5;
// setaspect(i>>1, yxaspect);
renderSetAspect(mulscale16(oviewingrange, vRange >> 1), yxaspect);
viewingRange = vRange >> 1;
yxAspect = tabledivide32_noinline(65536 * ydim * 8, xdim * 5);
}
}
else if (videoGetRenderMode() >= REND_POLYMOST && (ud.screen_tilting
#ifdef SPLITSCREEN_MOD_HACKS #ifdef SPLITSCREEN_MOD_HACKS
&& !g_fakeMultiMode && !g_fakeMultiMode
#endif #endif
@ -1375,49 +1278,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
// G_ReadGLFrame(); // G_ReadGLFrame();
#endif #endif
} }
else if (screenTilting)
{
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
if (screenTilting == 2) // tang == 1024
{
videoBeginDrawing();
{
const int32_t height = windowxy2.y-windowxy1.y+1;
const int32_t width = windowxy2.x-windowxy1.x+1;
uint8_t *f = (uint8_t *)(frameplace + ylookup[windowxy1.y]);
int32_t x, y;
for (y=0; y < (height>>1); y++)
swapbufreverse(f + y*bytesperline + windowxy2.x,
f + (height-1-y)*bytesperline + windowxy1.x,
width);
f += (height>>1)*bytesperline + windowxy1.x;
if (height&1)
for (x=0; x<(width>>1); x++)
swapchar(&f[x], &f[width-1-x]);
}
videoEndDrawing();
}
else
{
renderRestoreTarget();
picanm[TILE_TILT].xofs = picanm[TILE_TILT].yofs = 0;
int tiltZoom = (tang&511);
if (tiltZoom > 256)
tiltZoom = 512 - tiltZoom;
tiltZoom = sintable[tiltZoom + 512] * 8 + sintable[tiltZoom] * 5;
tiltZoom >>= tiltcs; // JBF 20030807
rotatesprite_win(160 << 16, 100 << 16, tiltZoom, tang + 512, TILE_TILT, 0, 0, 4 + 2 + 64 + 1024);
}
}
} }
G_RestoreInterpolations(); G_RestoreInterpolations();