From 1e24c4a22c2b3521d639806299b4506adaf86e8e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 3 Jul 2020 16:59:53 +0200 Subject: [PATCH] - vscrn, aka updateviewport. Just a temporary patch - this function won't work with the new status bar. --- source/games/duke/src/game_main.cpp | 50 +++++++++++++++++++++ source/games/duke/src/zz_premap.cpp | 63 --------------------------- source/games/duke/src/zz_savegame.cpp | 2 +- 3 files changed, 51 insertions(+), 64 deletions(-) diff --git a/source/games/duke/src/game_main.cpp b/source/games/duke/src/game_main.cpp index 153424c84..bc55a4b94 100644 --- a/source/games/duke/src/game_main.cpp +++ b/source/games/duke/src/game_main.cpp @@ -560,5 +560,55 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang) } +//--------------------------------------------------------------------------- +// +// calculate size of 3D viewport. +// Fixme: this needs to be adjusted to the new status bar code, +// once the status bar is a persistent queriable object +// +//--------------------------------------------------------------------------- + +void updateviewport(void) +{ + ud.screen_size = clamp(ud.screen_size, 0, 64); + const int32_t ss = std::max(ud.screen_size - 8, 0); + + int x1 = scale(ss, xdim, 160); + int x2 = xdim - x1; + + int y1 = scale(ss, (200 * 100) - ((tilesiz[TILE_BOTTOMSTATUSBAR].y >> (RR ? 1 : 0)) * ud.statusbarscale), 200 - tilesiz[TILE_BOTTOMSTATUSBAR].y); + int y2 = 200 * 100 - y1; + + if (isRR() && ud.screen_size <= 12) + { + x1 = 0; + x2 = xdim; + y1 = 0; + if (ud.statusbarmode) + y2 = 200 * 100; + } + + int fbh = 0; + if (ud.screen_size > 0 && ud.coop != 1 && ud.multimode > 1) + { + int j = 0; + for (int i = connecthead; i >= 0; i = connectpoint2[i]) + if (i > j) j = i; + + if (j >= 1) fbh += 8; + if (j >= 4) fbh += 8; + if (j >= 8) fbh += 8; + if (j >= 12) fbh += 8; + } + + y1 += fbh * 100; + if (ud.screen_size >= 8 && ud.statusbarmode == 0) + y2 -= (tilesiz[TILE_BOTTOMSTATUSBAR].y >> (isRR() ? 1 : 0)) * ud.statusbarscale; + y1 = scale(y1, ydim, 200 * 100); + y2 = scale(y2, ydim, 200 * 100); + + videoSetViewableArea(x1, y1, x2 - 1, y2 - 1); +} + END_DUKE_NS diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index b500f84d0..c3fdbdc02 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -48,69 +48,6 @@ static int32_t g_precacheCount; int32_t g_skillSoundVoice = -1; - - - -extern int32_t fragbarheight(void) -{ - if (ud.screen_size > 0 && !(ud.statusbarflags & STATUSBAR_NOFRAGBAR) -#ifdef SPLITSCREEN_MOD_HACKS - && !g_fakeMultiMode -#endif - && (g_netServer || ud.multimode > 1) && GTFLAGS(GAMETYPE_FRAGBAR)) - { - int32_t i, j = 0; - - for (TRAVERSE_CONNECT(i)) - if (i > j) - j = i; - - return ((j + 3) >> 2) << 3; - } - - return 0; -} - -void G_UpdateScreenArea(void) -{ - if (!in3dmode()) - return; - - ud.screen_size = clamp(ud.screen_size, 0, 64); - if (ud.screen_size == 0) - renderFlushPerms(); - - { - const int32_t ss = std::max(ud.screen_size-8,0); - - int32_t x1 = scale(ss,xdim,160); - int32_t x2 = xdim-x1; - - int32_t y1 = scale(ss,(200 * 100) - ((tilesiz[TILE_BOTTOMSTATUSBAR].y >> (RR ? 1 : 0)) * ud.statusbarscale),200 - tilesiz[TILE_BOTTOMSTATUSBAR].y); - int32_t y2 = 200*100-y1; - - if (RR && ud.screen_size <= 12) - { - x1 = 0; - x2 = xdim; - y1 = 0; - if (ud.statusbarmode) - y2 = 200*100; - } - - y1 += fragbarheight()*100; - if (ud.screen_size >= 8 && ud.statusbarmode==0) - y2 -= (tilesiz[TILE_BOTTOMSTATUSBAR].y >> (RR ? 1 : 0))*ud.statusbarscale; - y1 = scale(y1,ydim,200*100); - y2 = scale(y2,ydim,200*100); - - videoSetViewableArea(x1,y1,x2-1,y2-1); - } - - pub = NUMPAGES; - pus = NUMPAGES; -} - static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); } void G_InitRRRASkies(void) diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index fb5f0b6f7..a88676e01 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -1430,7 +1430,7 @@ static void postloadplayer(int32_t savegamep) T1(i) = 0; } - G_UpdateScreenArea(); + updateviewport(); FX_SetReverb(0); }