- activated the newly added render code and deleted the old one.

This commit is contained in:
Christoph Oelckers 2020-07-05 21:21:39 +02:00
parent 7ead48b9d9
commit cfe1e531c5
4 changed files with 33 additions and 500 deletions

View file

@ -5232,7 +5232,7 @@ int32_t setaspect_new_use_dimen = 0;
void videoSetCorrectedAspect()
{
if (r_usenewaspect && newaspect_enable && videoGetRenderMode() != REND_POLYMER)
if (/*r_usenewaspect &&*/ newaspect_enable && videoGetRenderMode() != REND_POLYMER)
{
// In DOS the game world is displayed with an aspect of 1.28 instead 1.333,
// meaning we have to stretch it by a factor of 1.25 instead of 1.2

View file

@ -220,12 +220,12 @@ void renderMirror(int cposx, int cposy, int cposz, int cang, int choriz, int smo
{
int tposx, tposy, tposz, tang;
renderPrepareMirror(cposx, cposy, cposz, cang, choriz, mirrorwall[i], &tposx, &tposy, &tang);
renderPrepareMirror(cposx, cposy, cposz, cang << FRACBITS, choriz<<FRACBITS, mirrorwall[i], &tposx, &tposy, &tang);
int j = g_visibility;
g_visibility = (j >> 1) + (j >> 2);
drawrooms(tposx, tposy, cposz, tang, choriz, mirrorsector[i] + MAXSECTORS);
renderDrawRoomsQ16(tposx, tposy, cposz, tang, choriz << FRACBITS, mirrorsector[i] + MAXSECTORS);
display_mirror = 1;
fi.animatesprites(tposx, tposy, tang, smoothratio);
@ -282,7 +282,7 @@ void animatecamsprite(int smoothRatio)
//---------------------------------------------------------------------------
//
//
// RRRA's drug distortion effect
//
//---------------------------------------------------------------------------
@ -371,13 +371,13 @@ void setdrugmode(player_struct *p, int oyrepeat)
//---------------------------------------------------------------------------
//
//
// used by RR to inject some external geometry into a scene.
//
//---------------------------------------------------------------------------
void tag848Hackery(int cposx, int cposy, int cposz, int cang, int choriz, int sect, int smoothratio)
static void geometryEffect(int cposx, int cposy, int cposz, int cang, int choriz, int sect, int smoothratio)
{
short gs, tgsect, nextspr, geosect, geoid;
short gs, tgsect, nextspr, geosect, geoid = 0;
int spr;
drawrooms(cposx, cposy, cposz, cang, choriz, sect);
fi.animatesprites(cposx, cposy, cang, smoothratio);
@ -485,6 +485,8 @@ void displayrooms(short snum, int smoothratio)
g_visibility = p->visibility;
newaspect_enable = 1;
videoSetCorrectedAspect();
smoothratio = min(max(smoothratio, 0), 65536);
if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536;
@ -535,8 +537,13 @@ void displayrooms(short snum, int smoothratio)
cposx = omyx + mulscale16((int)(myx - omyx), smoothratio);
cposy = omyy + mulscale16((int)(myy - omyy), smoothratio);
cposz = omyz + mulscale16((int)(myz - omyz), smoothratio);
#if 0
cang = omyang + mulscale16((int)(((myang + 1024 - omyang) & 2047) - 1024), smoothratio);
choriz = omyhoriz + omyhorizoff + mulscale16((int)(myhoriz + myhorizoff - omyhoriz - omyhorizoff), smoothratio);
#else
cang = myang >> 16;
choriz = (myhoriz + myhorizoff) >> 16;
#endif
sect = mycursectnum;
}
else
@ -544,9 +551,15 @@ void displayrooms(short snum, int smoothratio)
cposx = p->oposx + mulscale16((int)(p->posx - p->oposx), smoothratio);
cposy = p->oposy + mulscale16((int)(p->posy - p->oposy), smoothratio);
cposz = p->oposz + mulscale16((int)(p->posz - p->oposz), smoothratio);
#if 0
// Original code for when the values are passed through the sync struct
cang = p->getoang() + mulscale16((int)(((p->getang() + 1024 - p->getoang()) & 2047) - 1024), smoothratio);
//choriz = p->ohoriz+p->ohorizoff+mulscale16((int)(p->gethorizsum()-p->ohoriz-p->ohorizoff),smoothratio);
choriz = mulscale16((int)(p->gethorizsum()), smoothratio);
choriz = p->ohoriz+p->ohorizoff+mulscale16((int)(p->gethorizsum()-p->ohoriz-p->ohorizoff),smoothratio);
#else
// This is for real time updating of the view direction.
cang = p->getang();
choriz = p->gethorizsum();
#endif
}
cang += p->look_ang;
@ -598,7 +611,7 @@ void displayrooms(short snum, int smoothratio)
if (isRR() && sector[sect].lotag == 848)
{
tag848Hackery(cposx, cposy, cposz, cang, choriz, sect, smoothratio);
geometryEffect(cposx, cposy, cposz, cang, choriz, sect, smoothratio);
}
else
{
@ -623,4 +636,12 @@ void displayrooms(short snum, int smoothratio)
}
}
bool GameInterface::GenerateSavePic()
{
displayrooms(myconnectindex, 65536);
return true;
}
END_DUKE_NS

View file

@ -87,494 +87,6 @@ static void gameTimerHandler(void)
}
}
void se40code(int x, int y, int z, int a, int h, int smoothratio);
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz, int32_t smoothratio)
{
if ((gotpic[TILE_MIRROR>>3]&(1<<(TILE_MIRROR&7))))
{
if (mirrorcnt == 0)
{
// NOTE: We can have mirrorcnt==0 but gotpic'd TILE_MIRROR,
// for example in LNGA2.
gotpic[TILE_MIRROR>>3] &= ~(1<<(TILE_MIRROR&7));
return;
}
int32_t i = 0, dst = INT32_MAX;
for (bssize_t k=mirrorcnt-1; k>=0; k--)
{
if (!wallvisible(x, y, mirrorwall[k]))
continue;
const int32_t j =
klabs(wall[mirrorwall[k]].x - x) +
klabs(wall[mirrorwall[k]].y - y);
if (j < dst)
dst = j, i = k;
}
if (wall[mirrorwall[i]].overpicnum != TILE_MIRROR)
{
// Try to find a new mirror wall in case the original one was broken.
int32_t startwall = sector[mirrorsector[i]].wallptr;
int32_t endwall = startwall + sector[mirrorsector[i]].wallnum;
for (bssize_t k=startwall; k<endwall; k++)
{
int32_t j = wall[k].nextwall;
if (j >= 0 && (wall[j].cstat&32) && wall[j].overpicnum==TILE_MIRROR) // cmp. premap.c
{
mirrorwall[i] = j;
break;
}
}
}
if (wall[mirrorwall[i]].overpicnum == TILE_MIRROR)
{
int32_t tposx, tposy;
fix16_t tang;
renderPrepareMirror(x, y, z, a, q16horiz, mirrorwall[i], &tposx, &tposy, &tang);
int32_t j = g_visibility;
g_visibility = (j>>1) + (j>>2);
renderDrawRoomsQ16(tposx,tposy,z,tang,q16horiz,mirrorsector[i]+MAXSECTORS);
display_mirror = 1;
fi.animatesprites(tposx,tposy,fix16_to_int(tang),smoothratio);
display_mirror = 0;
renderDrawMasks();
renderCompleteMirror(); //Reverse screen x-wise in this function
g_visibility = j;
}
gotpic[TILE_MIRROR>>3] &= ~(1<<(TILE_MIRROR&7));
}
}
void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
{
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
int yxAspect = yxaspect;
int viewingRange = viewingrange;
//if (g_networkMode == NET_DEDICATED_SERVER) return;
totalclocklock = totalclock;
if (pub > 0 || videoGetRenderMode() >= REND_POLYMOST) // JBF 20040101: redraw background always
{
//videoClearScreen(0);
if (ud.screen_size >= 8)
drawbackground();
pub = 0;
}
if (ud.overhead_on == 2 || (pPlayer->cursectnum == -1 && videoGetRenderMode() != REND_CLASSIC))
return;
if (r_usenewaspect)
{
newaspect_enable = 1;
videoSetCorrectedAspect();
}
if (ud.pause_on || pPlayer->on_crane > -1)
smoothRatio = 65536;
else
smoothRatio = calc_smoothratio(totalclock, ototalclock);
if (RRRA && fogactive)
pPlayer->visibility = ud.const_visibility;
int const playerVis = pPlayer->visibility;
g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis);
CAMERA(sect) = pPlayer->cursectnum;
dointerpolations(smoothRatio);
//G_AnimateCamSprite(smoothRatio);
if (ud.camerasprite >= 0)
{
spritetype *const pSprite = &sprite[ud.camerasprite];
// XXX: what?
if (pSprite->yvel < 0) pSprite->yvel = -100;
else if (pSprite->yvel > 199) pSprite->yvel = 300;
CAMERA(q16ang) = fix16_from_int(actor[ud.camerasprite].tempang
+ mulscale16(((pSprite->ang + 1024 - actor[ud.camerasprite].tempang) & 2047) - 1024, smoothRatio));
if (!RR)
se40code(pSprite->x, pSprite->y, pSprite->z, CAMERA(q16ang), fix16_from_int(pSprite->yvel), smoothRatio);
renderDrawRoomsQ16(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, CAMERA(q16ang), fix16_from_int(pSprite->yvel), pSprite->sectnum);
fi.animatesprites(pSprite->x, pSprite->y, fix16_to_int(CAMERA(q16ang)), smoothRatio);
renderDrawMasks();
}
else
{
int32_t floorZ, ceilZ;
int const vr = divscale22(1, RR ? 64 : (sprite[pPlayer->i].yrepeat + 28));
viewingRange = Blrintf(float(vr) * tanf(r_fov * (PI/360.f)));
if (!RRRA || !pPlayer->DrugMode)
{
if (!r_usenewaspect)
renderSetAspect(viewingRange, yxaspect);
else
{
yxAspect = tabledivide32_noinline(65536 * ydim * 8, xdim * 5);
renderSetAspect(mulscale16(viewingRange,viewingrange), yxaspect);
}
}
if (videoGetRenderMode() >= REND_POLYMOST && (ud.screen_tilting
))
{
#ifdef USE_OPENGL
renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio));
#endif
pPlayer->orotscrnang = pPlayer->rotscrnang;
}
if (RRRA && pPlayer->DrugMode > 0)
{
while (pPlayer->drug_timer < totalclock && !(pPlayer->gm & MODE_MENU) && !ud.pause_on && !System_WantGuiCapture())
{
int aspect;
if (pPlayer->drug_stat[0] == 0)
{
pPlayer->drug_stat[1]++;
aspect = viewingRange + pPlayer->drug_stat[1] * 5000;
if (viewingRange * 3 < aspect)
{
pPlayer->drug_aspect = viewingRange * 3;
pPlayer->drug_stat[0] = 2;
}
else
{
pPlayer->drug_aspect = aspect;
}
setpal(pPlayer);
}
else if (pPlayer->drug_stat[0] == 3)
{
pPlayer->drug_stat[1]--;
aspect = viewingRange + pPlayer->drug_stat[1] * 5000;
if (aspect < viewingRange)
{
pPlayer->DrugMode = 0;
pPlayer->drug_stat[0] = 0;
pPlayer->drug_stat[2] = 0;
pPlayer->drug_stat[1] = 0;
pPlayer->drug_aspect = viewingRange;
}
else
{
pPlayer->drug_aspect = aspect;
}
setpal(pPlayer);
}
else if (pPlayer->drug_stat[0] == 2)
{
if (pPlayer->drug_stat[2] > 30)
{
pPlayer->drug_stat[0] = 1;
}
else
{
pPlayer->drug_stat[2]++;
aspect = pPlayer->drug_stat[2] * 500 + viewingRange * 3;
pPlayer->drug_aspect = aspect;
setpal(pPlayer);
}
}
else
{
if (pPlayer->drug_stat[2] < 1)
{
pPlayer->drug_stat[0] = 2;
pPlayer->DrugMode--;
if (pPlayer->DrugMode == 1)
pPlayer->drug_stat[0] = 3;
}
else
{
pPlayer->drug_stat[2]--;
aspect = pPlayer->drug_stat[2] * 500 + viewingRange * 3;
pPlayer->drug_aspect = aspect;
setpal(pPlayer);
}
}
pPlayer->drug_timer += TICSPERFRAME / 2;
}
if (!r_usenewaspect)
renderSetAspect(pPlayer->drug_aspect, yxaspect);
else
{
viewingRange = pPlayer->drug_aspect;
yxAspect = tabledivide32_noinline(65536 * ydim * 8, xdim * 5);
renderSetAspect(mulscale16(viewingRange, viewingrange), yxaspect);
}
setpal(pPlayer);
}
if (pPlayer->newowner < 0)
{
if (playerNum == myconnectindex && numplayers > 1)
{
vec3_t const camVect = { omypos.x + mulscale16(mypos.x - omypos.x, smoothRatio),
omypos.y + mulscale16(mypos.y - omypos.y, smoothRatio),
omypos.z + mulscale16(mypos.z - omypos.z, smoothRatio) };
CAMERA(pos) = camVect;
CAMERA(q16ang) = myang + fix16_from_int(pPlayer->look_ang);
CAMERA(q16horiz) = myhoriz + myhorizoff;
CAMERA(sect) = mycursectnum;
}
else
{
vec3_t const camVect = { pPlayer->opos.x + mulscale16(pPlayer->pos.x - pPlayer->opos.x, smoothRatio),
pPlayer->opos.y + mulscale16(pPlayer->pos.y - pPlayer->opos.y, smoothRatio),
pPlayer->opos.z + mulscale16(pPlayer->pos.z - pPlayer->opos.z, smoothRatio) };
CAMERA(pos) = camVect;
CAMERA(q16ang) = pPlayer->q16ang + fix16_from_int(pPlayer->look_ang);
CAMERA(q16horiz) = pPlayer->q16horiz + pPlayer->q16horizoff;
}
if (cl_viewbob)
{
int zAdd = (pPlayer->opyoff + mulscale16(pPlayer->pyoff-pPlayer->opyoff, smoothRatio));
if (pPlayer->over_shoulder_on)
zAdd >>= 3;
CAMERA(pos.z) += zAdd;
}
if (pPlayer->over_shoulder_on)
{
CAMERA(pos.z) -= 3072;
if (!view(pPlayer, &ud.camerapos.x, &ud.camerapos.y, &ud.camerapos.z, &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz))))
{
CAMERA(pos.z) += 3072;
view(pPlayer, &ud.camerapos.x, &ud.camerapos.y, &ud.camerapos.z, &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz)));
}
}
}
else
{
vec3_t const camVect = { 0,0,0 };// G_GetCameraPosition(pPlayer->newowner, smoothRatio);
// looking through viewscreen
CAMERA(pos) = camVect;
CAMERA(q16ang) = pPlayer->q16ang + fix16_from_int(pPlayer->look_ang);
CAMERA(q16horiz) = fix16_from_int(100 + sprite[pPlayer->newowner].shade);
CAMERA(sect) = sprite[pPlayer->newowner].sectnum;
}
ceilZ = actor[pPlayer->i].ceilingz;
floorZ = actor[pPlayer->i].floorz;
if (g_earthquakeTime > 0 && pPlayer->on_ground == 1)
{
CAMERA(pos.z) += 256 - (((g_earthquakeTime)&1) << 9);
CAMERA(q16ang) += fix16_from_int((2 - ((g_earthquakeTime)&2)) << 2);
}
if (sprite[pPlayer->i].pal == 1)
CAMERA(pos.z) -= (18<<8);
if (pPlayer->newowner < 0 && pPlayer->spritebridge == 0)
{
// NOTE: when shrunk, p->pos.z can be below the floor. This puts the
// camera into the sector again then.
if (CAMERA(pos.z) < (pPlayer->truecz + ZOFFSET6))
CAMERA(pos.z) = ceilZ + ZOFFSET6;
else if (CAMERA(pos.z) > (pPlayer->truefz - ZOFFSET6))
CAMERA(pos.z) = floorZ - ZOFFSET6;
}
while (CAMERA(sect) >= 0) // if, really
{
getzsofslope(CAMERA(sect),CAMERA(pos.x),CAMERA(pos.y),&ceilZ,&floorZ);
if (CAMERA(pos.z) < ceilZ+ZOFFSET6)
CAMERA(pos.z) = ceilZ+ZOFFSET6;
if (CAMERA(pos.z) > floorZ-ZOFFSET6)
CAMERA(pos.z) = floorZ-ZOFFSET6;
break;
}
CAMERA(q16horiz) = fix16_clamp(CAMERA(q16horiz), F16(HORIZ_MIN), F16(HORIZ_MAX));
G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio);
if (!RR || RRRA) se40code(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio);
// for G_PrintCoords
dr_viewingrange = viewingrange;
dr_yxaspect = yxaspect;
if (RR && sector[CAMERA(sect)].lotag == 848)
{
renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),CAMERA(sect));
fi.animatesprites(CAMERA(pos.x),CAMERA(pos.y),fix16_to_int(CAMERA(q16ang)),smoothRatio);
renderDrawMasks();
int geoSector = 0;
for (bsize_t gs = 0; gs < geocnt; gs++)
{
int spriteNum = headspritesect[geosector[gs]];
while (spriteNum != -1)
{
int spriteNext = nextspritesect[spriteNum];
changespritesect(spriteNum, geosectorwarp[gs]);
sprite[spriteNum].x -= geox[gs];
sprite[spriteNum].y -= geoy[gs];
setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]);
spriteNum = spriteNext;
}
if (CAMERA(sect) == geosector[gs])
geoSector = gs;
}
CAMERA(pos.x) -= geox[geoSector];
CAMERA(pos.y) -= geoy[geoSector];
renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),geosectorwarp[geoSector]);
CAMERA(pos.x) += geox[geoSector];
CAMERA(pos.y) += geoy[geoSector];
for (bsize_t gs = 0; gs < geocnt; gs++)
{
int spriteNum = headspritesect[geosectorwarp[gs]];
while (spriteNum != -1)
{
int spriteNext = nextspritesect[spriteNum];
changespritesect(spriteNum, geosector[gs]);
sprite[spriteNum].x += geox[gs];
sprite[spriteNum].y += geoy[gs];
setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]);
spriteNum = spriteNext;
}
}
fi.animatesprites(CAMERA(pos.x),CAMERA(pos.y),fix16_to_int(CAMERA(q16ang)),smoothRatio);
renderDrawMasks();
for (bsize_t gs = 0; gs < geocnt; gs++)
{
int spriteNum = headspritesect[geosector[gs]];
while (spriteNum != -1)
{
int spriteNext = nextspritesect[spriteNum];
changespritesect(spriteNum, geosectorwarp2[gs]);
sprite[spriteNum].x -= geox2[gs];
sprite[spriteNum].y -= geoy2[gs];
setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]);
spriteNum = spriteNext;
}
if (CAMERA(sect) == geosector[gs])
geoSector = gs;
}
CAMERA(pos.x) -= geox2[geoSector];
CAMERA(pos.y) -= geoy2[geoSector];
renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),geosectorwarp2[geoSector]);
CAMERA(pos.x) += geox2[geoSector];
CAMERA(pos.y) += geoy2[geoSector];
for (bsize_t gs = 0; gs < geocnt; gs++)
{
int spriteNum = headspritesect[geosectorwarp2[gs]];
while (spriteNum != -1)
{
int spriteNext = nextspritesect[spriteNum];
changespritesect(spriteNum, geosector[gs]);
sprite[spriteNum].x += geox2[gs];
sprite[spriteNum].y += geoy2[gs];
setsprite(spriteNum, (vec3_t*)&sprite[spriteNum]);
spriteNum = spriteNext;
}
}
fi.animatesprites(CAMERA(pos.x),CAMERA(pos.y),fix16_to_int(CAMERA(q16ang)),smoothRatio);
}
else
{
renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),CAMERA(sect));
//if (!RR && (unsigned)ror_sprite < MAXSPRITES && drawing_ror == 1) // viewing from bottom
// G_OROR_DupeSprites(&sprite[ror_sprite]);
fi.animatesprites(CAMERA(pos.x),CAMERA(pos.y),fix16_to_int(CAMERA(q16ang)),smoothRatio);
}
renderDrawMasks();
}
restoreinterpolations();
if (!RRRA || !fogactive)
{
// Totalclock count of last step of p->visibility converging towards
// ud.const_visibility.
static int32_t lastvist;
const int32_t visdif = ud.const_visibility-pPlayer->visibility;
// Check if totalclock was cleared (e.g. restarted game).
if (totalclock < lastvist)
lastvist = 0;
// Every 2nd totalclock increment (each 1/60th second), ...
while (totalclock >= lastvist+2)
{
// ... approximately three-quarter the difference between
// p->visibility and ud.const_visibility.
const int32_t visinc = visdif>>2;
if (klabs(visinc) == 0)
{
pPlayer->visibility = ud.const_visibility;
break;
}
pPlayer->visibility += visinc;
lastvist = (int32_t) totalclock;
}
}
if (r_usenewaspect)
{
newaspect_enable = 0;
renderSetAspect(viewingRange, yxAspect);
}
}
bool GameInterface::GenerateSavePic()
{
G_DrawRooms(myconnectindex, 65536);
return true;
}
static int G_MaybeTakeOnFloorPal(tspritetype *pSprite, int sectNum)
{
int const floorPal = sector[sectNum].floorpal;
@ -1488,7 +1000,7 @@ MAIN_LOOP_RESTART:
drawtime.Reset();
drawtime.Clock();
G_DrawRooms(screenpeek, smoothRatio);
displayrooms(screenpeek, smoothRatio);
if (videoGetRenderMode() >= REND_POLYMOST)
drawbackground();
G_DisplayRest(smoothRatio);

View file

@ -480,7 +480,7 @@ int G_EnterLevel(int gameMode)
updateviewport();
videoClearViewableArea(0L);
drawbackground();
G_DrawRooms(myconnectindex,65536);
displayrooms(myconnectindex,65536);
Net_WaitForEverybody();
return 0;