From 494fe0b1e7a4cd5d7f260fa45d86b0a06e216c6f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 10:34:30 +0200 Subject: [PATCH] revert software screen shit --- src/d_main.c | 6 + src/m_misc.c | 4 +- src/r_bsp.c | 19 +-- src/r_bsp.h | 2 - src/r_defs.h | 4 +- src/r_draw.c | 81 ++++++---- src/r_draw.h | 9 +- src/r_draw8.c | 67 ++++++--- src/r_plane.c | 141 +++++++---------- src/r_plane.h | 20 ++- src/r_segs.c | 401 +++++++++++++++++++++++++------------------------ src/r_segs.h | 2 - src/r_state.h | 2 +- src/r_things.c | 86 ++++------- src/r_things.h | 9 +- src/screen.h | 18 ++- 16 files changed, 445 insertions(+), 426 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f0bd51409..f1c61648d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -452,14 +452,17 @@ static boolean D_Display(void) viewwindowx = 0; viewwindowy = viewheight; } + M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0])); break; case 2: viewwindowx = 0; viewwindowy = viewheight; + M_Memcpy(ylookup, ylookup3, viewheight*sizeof (ylookup[0])); break; case 3: viewwindowx = viewwidth; viewwindowy = viewheight; + M_Memcpy(ylookup, ylookup4, viewheight*sizeof (ylookup[0])); default: break; } @@ -469,6 +472,9 @@ static boolean D_Display(void) } R_RenderPlayerView(&players[displayplayers[i]]); + + if (i > 0) + M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); } } } diff --git a/src/m_misc.c b/src/m_misc.c index be243b7a5..7d0ce6bfc 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -997,7 +997,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) png_init_io(apng_ptr, apng_FILE); #ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_set_user_limits(apng_ptr, MAXVIDWIDTH, MAXVIDHEIGHT); + png_set_user_limits(apng_ptr, MAXPNGWIDTH, MAXPNGHEIGHT); #endif //png_set_filter(apng_ptr, 0, PNG_ALL_FILTERS); @@ -1306,7 +1306,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_init_io(png_ptr, png_FILE); #ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_set_user_limits(png_ptr, MAXVIDWIDTH, MAXVIDHEIGHT); + png_set_user_limits(png_ptr, MAXPNGWIDTH, MAXPNGHEIGHT); #endif //png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); diff --git a/src/r_bsp.c b/src/r_bsp.c index 899ce68d1..0795fea15 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -72,22 +72,11 @@ void R_ClearDrawSegs(void) } // Fix from boom. -static UINT32 maxsegs; +#define MAXSEGS (MAXVIDWIDTH/2+1) // newend is one past the last valid seg static cliprange_t *newend; -static cliprange_t *solidsegs; - -void R_AllocClipSegMemory(void) -{ - UINT32 newendpos = newend - solidsegs; - - maxsegs = max(BASEVIDWIDTH/2+1, viewwidth/2+1); - - solidsegs = Z_Realloc(solidsegs, sizeof(*solidsegs) * maxsegs, PU_STATIC, NULL); - - newend = solidsegs + newendpos; -} +static cliprange_t solidsegs[MAXSEGS]; // // R_ClipSolidWallSegment @@ -114,7 +103,7 @@ static void R_ClipSolidWallSegment(INT32 first, INT32 last) next = newend; newend++; // NO MORE CRASHING! - if (newend - solidsegs > maxsegs) + if (newend - solidsegs > MAXSEGS) I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); while (next != start) @@ -169,7 +158,7 @@ crunch: newend = start + 1; // NO MORE CRASHING! - if (newend - solidsegs > maxsegs) + if (newend - solidsegs > MAXSEGS) I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); } diff --git a/src/r_bsp.h b/src/r_bsp.h index d487d74c1..2803a90e4 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -37,8 +37,6 @@ extern boolean g_walloffscreen; // BSP? void R_ClearClipSegs(void); void R_PortalClearClipSegs(INT32 start, INT32 end); - -void R_AllocClipSegMemory(void); void R_ClearDrawSegs(void); void R_RenderBSPNode(INT32 bspnum); void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2); diff --git a/src/r_defs.h b/src/r_defs.h index f61ee4651..af522623c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -604,11 +604,11 @@ typedef struct drawseg_s struct ffloor_s *thicksides[MAXFFLOORS]; INT16 *thicksidecol; INT32 numthicksides; - fixed_t *frontscale; + fixed_t frontscale[MAXVIDWIDTH]; UINT8 portalpass; // if > 0 and <= portalrender, do not affect sprite clipping - fixed_t *maskedtextureheight; // For handling sloped midtextures + fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes } drawseg_t; diff --git a/src/r_draw.c b/src/r_draw.c index 182cabc21..fa19a6ac2 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -40,6 +40,31 @@ */ INT32 viewwidth, scaledviewwidth, viewheight, viewwindowx, viewwindowy; +/** \brief pointer to the start of each line of the screen, +*/ +UINT8 *ylookup[MAXVIDHEIGHT*4]; + +/** \brief pointer to the start of each line of the screen, for view1 (splitscreen) +*/ +UINT8 *ylookup1[MAXVIDHEIGHT*4]; + +/** \brief pointer to the start of each line of the screen, for view2 (splitscreen) +*/ +UINT8 *ylookup2[MAXVIDHEIGHT*4]; + +/** \brief pointer to the start of each line of the screen, for view3 (splitscreen) +*/ +UINT8 *ylookup3[MAXVIDHEIGHT*4]; + +/** \brief pointer to the start of each line of the screen, for view4 (splitscreen) +*/ +UINT8 *ylookup4[MAXVIDHEIGHT*4]; + +/** \brief x byte offset for columns inside the viewwindow, + so the first column starts at (SCRWIDTH - VIEWWIDTH)/2 +*/ +INT32 columnofs[MAXVIDWIDTH*4]; + UINT8 *topleft; // ========================================================================= @@ -50,6 +75,8 @@ lighttable_t *dc_colormap; INT32 dc_x = 0, dc_yl = 0, dc_yh = 0; fixed_t dc_iscale, dc_texturemid; +UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit, + // soo lets make it a byte on all system for the ASM code UINT8 *dc_source; // ----------------------- @@ -96,9 +123,6 @@ float focallengthf, zeroheight; UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; -// For, uh, tilted lighting, duh. -INT32 *tiltlighting; - // ========================================================================== // OLD DOOM FUZZY EFFECT // ========================================================================== @@ -343,6 +367,16 @@ UINT8 R_GetColorByName(const char *name) } */ +// ========================================================================== +// COMMON DRAWER FOR 8 AND 16 BIT COLOR MODES +// ========================================================================== + +// in a perfect world, all routines would be compatible for either mode, +// and optimised enough +// +// in reality, the few routines that can work for either mode, are +// put here + /** \brief The R_InitViewBuffer function Creates lookup tables for getting the framebuffer address @@ -356,30 +390,9 @@ UINT8 R_GetColorByName(const char *name) */ -static void R_AllocViewMemory(void) -{ - negonearray = Z_Realloc(negonearray, sizeof(*negonearray) * viewwidth, PU_STATIC, NULL); - screenheightarray = Z_Realloc(screenheightarray, sizeof(*screenheightarray) * viewwidth, PU_STATIC, NULL); - - floorclip = Z_Realloc(floorclip, sizeof(*floorclip) * viewwidth, PU_STATIC, NULL); - ceilingclip = Z_Realloc(ceilingclip, sizeof(*ceilingclip) * viewwidth, PU_STATIC, NULL); - - frontscale = Z_Realloc(frontscale, sizeof(*frontscale) * viewwidth, PU_STATIC, NULL); - - xtoviewangle = Z_Realloc(xtoviewangle, sizeof(*xtoviewangle) * (viewwidth + 1), PU_STATIC, NULL); - - tiltlighting = Z_Realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth, PU_STATIC, NULL); - - R_AllocSegMemory(); - R_AllocClipSegMemory(); - R_AllocPlaneMemory(); - //R_AllocFloorSpriteTables(); - R_AllocVisSpriteMemory(); -} - void R_InitViewBuffer(INT32 width, INT32 height) { - INT32 bytesperpixel = vid.bpp; + INT32 i, bytesperpixel = vid.bpp; if (width > MAXVIDWIDTH) width = MAXVIDWIDTH; @@ -388,10 +401,24 @@ void R_InitViewBuffer(INT32 width, INT32 height) if (bytesperpixel < 1 || bytesperpixel > 4) I_Error("R_InitViewBuffer: wrong bytesperpixel value %d\n", bytesperpixel); - R_AllocViewMemory(); - viewwindowx = 0; viewwindowy = 0; + + // Column offset for those columns of the view window, but relative to the entire screen + for (i = 0; i < width; i++) + columnofs[i] = (viewwindowx + i) * bytesperpixel; + + // Precalculate all row offsets. + for (i = 0; i < height; i++) + { + ylookup[i] = ylookup1[i] = screens[0] + i*vid.width*bytesperpixel; + if (splitscreen == 1) + ylookup2[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel; + else + ylookup2[i] = screens[0] + i*vid.width*bytesperpixel + (viewwidth*bytesperpixel); + ylookup3[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel; + ylookup4[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel + (viewwidth*bytesperpixel); + } } /** \brief viewborder patches lump numbers diff --git a/src/r_draw.h b/src/r_draw.h index 80557ce34..58775fe1d 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -20,6 +20,12 @@ // ------------------------------- // COMMON STUFF FOR 8bpp AND 16bpp // ------------------------------- +extern UINT8 *ylookup[MAXVIDHEIGHT*4]; +extern UINT8 *ylookup1[MAXVIDHEIGHT*4]; +extern UINT8 *ylookup2[MAXVIDHEIGHT*4]; +extern UINT8 *ylookup3[MAXVIDHEIGHT*4]; +extern UINT8 *ylookup4[MAXVIDHEIGHT*4]; +extern INT32 columnofs[MAXVIDWIDTH*4]; extern UINT8 *topleft; // ------------------------- @@ -29,6 +35,7 @@ extern UINT8 *topleft; extern lighttable_t *dc_colormap; extern INT32 dc_x, dc_yl, dc_yh; extern fixed_t dc_iscale, dc_texturemid; +extern UINT8 dc_hires; extern UINT8 *dc_source; // first pixel in a column @@ -59,8 +66,6 @@ extern UINT8 *ds_transmap; extern INT32 ds_bgofs; -extern INT32 *tiltlighting; - typedef struct { float x, y, z; } floatv3_t; diff --git a/src/r_draw8.c b/src/r_draw8.c index f309b8ec7..6b5d177db 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -43,14 +43,15 @@ void R_DrawColumn_8(void) // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep)); - + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. @@ -123,13 +124,18 @@ void R_Draw2sMultiPatchColumn_8(void) #endif // Framebuffer destination address. + // Use ylookup LUT to avoid multiply with ScreenWidth. + // Use columnofs LUT for subwindows? + + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. @@ -214,6 +220,10 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) #endif // Framebuffer destination address. + // Use ylookup LUT to avoid multiply with ScreenWidth. + // Use columnofs LUT for subwindows? + + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; @@ -221,7 +231,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; //frac = dc_texturemid + (dc_yl - centery)*fracstep; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. @@ -311,11 +321,14 @@ void R_DrawShadeColumn_8(void) I_Error("R_DrawShadeColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); #endif + // FIXME. As above. + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Here we do an additional index re-mapping. do @@ -347,11 +360,14 @@ void R_DrawTranslucentColumn_8(void) I_Error("R_DrawTranslucentColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); #endif + // FIXME. As above. + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. @@ -416,11 +432,14 @@ void R_DrawTranslatedTranslucentColumn_8(void) if (count <= 0) // Zero length, column does not exceed a pixel. return; + // FIXME. As above. + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + //frac = dc_texturemid + (dc_yl - centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. @@ -489,11 +508,14 @@ void R_DrawTranslatedColumn_8(void) I_Error("R_DrawTranslatedColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); #endif + // FIXME. As above. + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Looks familiar. fracstep = dc_iscale; - frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep); + //frac = dc_texturemid + (dc_yl-centery)*fracstep; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); // Here we do an additional index re-mapping. do @@ -546,7 +568,7 @@ void R_DrawSpan_8 (void) source = ds_source; colormap = ds_colormap; - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; if (dest+8 > deststop) return; @@ -601,6 +623,7 @@ void R_DrawSpan_8 (void) // R_CalcTiltedLighting // Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly. +static INT32 tiltlighting[MAXVIDWIDTH]; void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version @@ -621,7 +644,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } -#define PLANELIGHTFLOAT ((float)(BASEVIDWIDTH * BASEVIDWIDTH) / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! @@ -660,8 +683,9 @@ void R_DrawTiltedSpan_8(void) uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; + //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -795,8 +819,9 @@ void R_DrawTiltedTranslucentSpan_8(void) uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; + //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -931,9 +956,10 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; source = ds_source; + //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1066,8 +1092,9 @@ void R_DrawTiltedSplat_8(void) uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; + //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1200,7 +1227,7 @@ void R_DrawSplat_8 (void) source = ds_source; colormap = ds_colormap; - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; count = ds_x2 - ds_x1 + 1; while (count >= 8) @@ -1319,7 +1346,7 @@ void R_DrawTranslucentSplat_8 (void) source = ds_source; colormap = ds_colormap; - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; count = ds_x2 - ds_x1 + 1; while (count >= 8) @@ -1422,7 +1449,7 @@ void R_DrawTranslucentSpan_8 (void) source = ds_source; colormap = ds_colormap; - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) { @@ -1500,7 +1527,7 @@ void R_DrawTranslucentWaterSpan_8(void) source = ds_source; colormap = ds_colormap; - dest = &topleft[ds_y*vid.width + ds_x1]; + dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; @@ -1564,6 +1591,7 @@ void R_DrawFogSpan_8(void) size_t count; colormap = ds_colormap; + //dest = ylookup[ds_y] + columnofs[ds_x1]; dest = &topleft[ds_y *vid.width + ds_x1]; count = ds_x2 - ds_x1 + 1; @@ -1606,6 +1634,9 @@ void R_DrawFogColumn_8(void) #endif // Framebuffer destination address. + // Use ylookup LUT to avoid multiply with ScreenWidth. + // Use columnofs LUT for subwindows? + //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; // Determine scaling, which is the only mapping to be done. diff --git a/src/r_plane.c b/src/r_plane.c index 1f0142d7c..6a95f9fb3 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -46,7 +46,6 @@ #define MAXVISPLANES ((1<top_memory = Z_Realloc(pl->top_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL); - pl->bottom_memory = Z_Realloc(pl->bottom_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL); - pl->top = pl->top_memory + 1; - pl->bottom = pl->bottom_memory + 1; + // FIXME: unused } -void R_AllocPlaneMemory(void) -{ - visplane_t *check; - - // Alloc visplane top/bottom bounds - for (unsigned i = 0; i < MAXVISPLANES; i++) - { - check = visplanes[i]; - - while (check) - { - R_ReallocPlaneBounds(check); - check = check->next; - } - } - - // Need to do it for "freed" visplanes too - check = freetail; - - while (check) - { - R_ReallocPlaneBounds(check); - check = check->next; - } - - // Alloc ffloor clip tables - ffloor_f_clip = Z_Realloc(ffloor_f_clip, sizeof(*ffloor_f_clip) * (viewwidth * MAXFFLOORS), PU_STATIC, NULL); - ffloor_c_clip = Z_Realloc(ffloor_c_clip, sizeof(*ffloor_c_clip) * (viewwidth * MAXFFLOORS), PU_STATIC, NULL); - - for (unsigned i = 0; i < MAXFFLOORS; i++) - { - ffloor[i].f_clip = ffloor_f_clip + (i * viewwidth); - ffloor[i].c_clip = ffloor_c_clip + (i * viewwidth); - } - - yslopetab = Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL); - - spanstart = Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL); -} - - // R_PortalStoreClipValues // Saves clipping values for later. -Red void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale) @@ -268,18 +229,32 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) planecos = FINECOSINE(angle); planesin = FINESINE(angle); - // [RH] Notice that I dumped the caching scheme used by Doom. - // It did not offer any appreciable speedup. - distance = FixedMul(planeheight, yslope[y]); - span = abs(centery - y); - - if (span) // Don't divide by zero + if (planeheight != cachedheight[y]) { - ds_xstep = FixedMul(planesin, planeheight) / span; - ds_ystep = FixedMul(planecos, planeheight) / span; + cachedheight[y] = planeheight; + cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); + span = abs(centery - y); + + if (span) // don't divide by zero + { + ds_xstep = FixedMul(planesin, planeheight) / span; + ds_ystep = FixedMul(planecos, planeheight) / span; + } + else + { + ds_xstep = FixedMul(distance, basexscale); + ds_ystep = FixedMul(distance, baseyscale); + } + + cachedxstep[y] = ds_xstep; + cachedystep[y] = ds_ystep; } else - ds_xstep = ds_ystep = FRACUNIT; + { + distance = cacheddistance[y]; + ds_xstep = cachedxstep[y]; + ds_ystep = cachedystep[y]; + } ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; @@ -357,16 +332,17 @@ void R_ClearPlanes(void) numffloors = 0; for (i = 0; i < MAXVISPLANES; i++) + for (*freehead = visplanes[i], visplanes[i] = NULL; + freehead && *freehead ;) { - for (*freehead = visplanes[i], visplanes[i] = NULL; - freehead && *freehead ;) - { - freehead = &(*freehead)->next; - } + freehead = &(*freehead)->next; } lastopening = openings; + // texture calculation + memset(cachedheight, 0, sizeof (cachedheight)); + // left to right mapping angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; @@ -380,13 +356,8 @@ static visplane_t *new_visplane(unsigned hash) visplane_t *check = freetail; if (!check) { - check = calloc(1, sizeof (*check)); - if (check == NULL) - I_Error("new_visplane: Out of memory"); - check->top_memory = Z_Malloc(sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL); - check->bottom_memory = Z_Malloc(sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL); - check->top = check->top_memory + 1; - check->bottom = check->bottom_memory + 1; + check = malloc(sizeof (*check)); + if (check == NULL) I_Error("%s: Out of memory", "new_visplane"); // FIXME: ugly } else { @@ -499,8 +470,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, check->slope = slope; check->noencore = noencore; - memset(check->top, 0xff, sizeof(*check->top) * viewwidth); - memset(check->bottom, 0x00, sizeof(*check->bottom) * viewwidth); + memset(check->top, 0xff, sizeof (check->top)); + memset(check->bottom, 0x00, sizeof (check->bottom)); return check; } @@ -577,8 +548,8 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) pl = new_pl; pl->minx = start; pl->maxx = stop; - memset(pl->top, 0xff, sizeof(*pl->top) * viewwidth); - memset(pl->bottom, 0x00, sizeof(*pl->bottom) * viewwidth); + memset(pl->top, 0xff, sizeof pl->top); + memset(pl->bottom, 0x00, sizeof pl->bottom); } return pl; } @@ -965,13 +936,13 @@ void R_DrawSinglePlane(visplane_t *pl) else light = (pl->lightlevel >> LIGHTSEGSHIFT); if (!pl->slope) // Don't mess with angle on slopes! We'll handle this ourselves later + if (viewangle != pl->viewangle+pl->plangle) { - if (viewangle != pl->viewangle+pl->plangle) - { - angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); - } + memset(cachedheight, 0, sizeof (cachedheight)); + angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; + basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); + baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); + viewangle = pl->viewangle+pl->plangle; } currentplane = pl; diff --git a/src/r_plane.h b/src/r_plane.h index 9abcdb4e1..96217b387 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -42,8 +42,9 @@ typedef struct visplane_s // colormaps per sector extracolormap_t *extra_colormap; - UINT16 *top, *top_memory; - UINT16 *bottom, *bottom_memory; + // leave pads for [minx-1]/[maxx+1] + UINT16 padtopstart, top[MAXVIDWIDTH], padtopend; + UINT16 padbottomstart, bottom[MAXVIDWIDTH], padbottomend; INT32 high, low; // R_PlaneBounds should set these. fixed_t xoffs, yoffs; // Scrolling flats. @@ -62,15 +63,18 @@ extern visplane_t *ceilingplane; extern INT16 *lastopening, *openings; extern size_t maxopenings; -extern INT16 *floorclip, *ceilingclip; -extern fixed_t *frontscale, *yslopetab; - +extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH]; +extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16]; +extern fixed_t cachedheight[MAXVIDHEIGHT]; +extern fixed_t cacheddistance[MAXVIDHEIGHT]; +extern fixed_t cachedxstep[MAXVIDHEIGHT]; +extern fixed_t cachedystep[MAXVIDHEIGHT]; extern fixed_t basexscale, baseyscale; extern fixed_t *yslope; extern lighttable_t **planezlight; -void R_AllocPlaneMemory(void); +void R_InitPlanes(void); void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_ClearPlanes(void); @@ -99,8 +103,8 @@ typedef struct planemgr_s fixed_t b_pos; // B for Back sector fixed_t f_frac, f_step; fixed_t b_frac, b_step; - INT16 *f_clip; - INT16 *c_clip; + INT16 f_clip[MAXVIDWIDTH]; + INT16 c_clip[MAXVIDWIDTH]; // For slope rendering; the height at the other end fixed_t f_pos_slope; diff --git a/src/r_segs.c b/src/r_segs.c index f8998da14..817e086df 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1272,6 +1272,14 @@ static void R_RenderSegLoop (void) if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) continue; + // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red + if (curline->polyseg) { + if (ffloor[i].plane->minx > rw_x) + ffloor[i].plane->minx = rw_x; + else if (ffloor[i].plane->maxx < rw_x) + ffloor[i].plane->maxx = rw_x; + } + if (ffloor[i].height < viewz) { INT32 top_w = (ffloor[i].f_frac >> HEIGHTBITS) + 1; @@ -1284,38 +1292,34 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (ffloor[i].polyobj && top_w >= bottom_w) + if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; + } else + + if (top_w <= bottom_w) { - ffloor[i].plane->top[rw_x] = 0xFFFF; - ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 - } - else - { - if (top_w <= bottom_w) + fftop = (INT16)top_w; + ffbottom = (INT16)bottom_w; + + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; + + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "bottom" is the top pixel of the floor column + if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) { - fftop = (INT16)top_w; - ffbottom = (INT16)bottom_w; + rw_floormarked = true; + floorclip[rw_x] = fftop; + if (yh > fftop) + yh = fftop; - ffloor[i].plane->top[rw_x] = fftop; - ffloor[i].plane->bottom[rw_x] = ffbottom; + if (markfloor && floorplane) + floorplane->top[rw_x] = bottom; - // Lactozilla: Cull part of the column by the 3D floor if it can't be seen - // "bottom" is the top pixel of the floor column - if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) + if (rw_silhouette) { - rw_floormarked = true; - floorclip[rw_x] = fftop; - if (yh > fftop) - yh = fftop; - - if (markfloor && floorplane) - floorplane->top[rw_x] = bottom; - - if (rw_silhouette) - { - (*rw_silhouette) |= SIL_BOTTOM; - (*rw_bsilheight) = INT32_MAX; - } + (*rw_silhouette) |= SIL_BOTTOM; + (*rw_bsilheight) = INT32_MAX; } } } @@ -1332,38 +1336,34 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (ffloor[i].polyobj && top_w >= bottom_w) + if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; + } else + + if (top_w <= bottom_w) { - ffloor[i].plane->top[rw_x] = 0xFFFF; - ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 - } - else - { - if (top_w <= bottom_w) + fftop = (INT16)top_w; + ffbottom = (INT16)bottom_w; + + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; + + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "top" is the height of the ceiling column + if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) { - fftop = (INT16)top_w; - ffbottom = (INT16)bottom_w; + rw_ceilingmarked = true; + ceilingclip[rw_x] = ffbottom; + if (yl < ffbottom) + yl = ffbottom; - ffloor[i].plane->top[rw_x] = fftop; - ffloor[i].plane->bottom[rw_x] = ffbottom; + if (markceiling && ceilingplane) + ceilingplane->bottom[rw_x] = top; - // Lactozilla: Cull part of the column by the 3D floor if it can't be seen - // "top" is the height of the ceiling column - if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) + if (rw_silhouette) { - rw_ceilingmarked = true; - ceilingclip[rw_x] = ffbottom; - if (yl < ffbottom) - yl = ffbottom; - - if (markceiling && ceilingplane) - ceilingplane->bottom[rw_x] = top; - - if (rw_silhouette) - { - (*rw_silhouette) |= SIL_TOP; - (*rw_tsilheight) = INT32_MIN; - } + (*rw_silhouette) |= SIL_TOP; + (*rw_tsilheight) = INT32_MIN; } } } @@ -1616,33 +1616,6 @@ static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2) } } -static size_t maxdrawsegs = 0; - -static fixed_t *frontscaletable = NULL; -static fixed_t *maskedheighttable = NULL; - -void R_AllocSegMemory(void) -{ - if (!maxdrawsegs) - return; - - frontscaletable = Z_Realloc(frontscaletable, sizeof(*frontscaletable) * (maxdrawsegs * viewwidth), PU_STATIC, NULL); - maskedheighttable = Z_Realloc(maskedheighttable, sizeof(*maskedheighttable) * (maxdrawsegs * viewwidth), PU_STATIC, NULL); - - drawseg_t *lastseg = drawsegs + maxdrawsegs; - - fixed_t *frontscale_p = frontscaletable; - fixed_t *maskedheight_p = maskedheighttable; - - for (drawseg_t *ds = drawsegs; ds < lastseg; ds++) - { - ds->frontscale = frontscale_p; - ds->maskedtextureheight = maskedheight_p; - frontscale_p += viewwidth; - maskedheight_p += viewwidth; - } -} - // // R_StoreWallRange // A wall segment will be drawn @@ -1661,6 +1634,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) INT32 range; vertex_t segleft, segright; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; + static size_t maxdrawsegs = 0; maskedtextureheight = NULL; //initialize segleft and segright @@ -1678,7 +1652,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) maxdrawsegs = newmax; if (firstseg) firstseg = drawsegs + (size_t)firstseg; - R_AllocSegMemory(); } sidedef = curline->sidedef; @@ -1832,21 +1805,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) } -#define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, segleft.x, segleft.y); \ - end2 = P_GetZAt(slope, segright.x, segright.y); \ - } else \ - end1 = end2 = normalheight; + if (frontsector->c_slope) { + worldtop = P_GetZAt(frontsector->c_slope, segleft.x, segleft.y) - viewz; + worldtopslope = P_GetZAt(frontsector->c_slope, segright.x, segright.y) - viewz; + } else { + worldtopslope = + worldtop = frontsector->ceilingheight - viewz; + } - SLOPEPARAMS(frontsector->c_slope, worldtop, worldtopslope, frontsector->ceilingheight) - SLOPEPARAMS(frontsector->f_slope, worldbottom, worldbottomslope, frontsector->floorheight) - // subtract viewz from these to turn them into - // positions relative to the camera's z position - worldtop -= viewz; - worldtopslope -= viewz; - worldbottom -= viewz; - worldbottomslope -= viewz; + + if (frontsector->f_slope) { + worldbottom = P_GetZAt(frontsector->f_slope, segleft.x, segleft.y) - viewz; + worldbottomslope = P_GetZAt(frontsector->f_slope, segright.x, segright.y) - viewz; + } else { + worldbottomslope = + worldbottom = frontsector->floorheight - viewz; + } midtexture = toptexture = bottomtexture = maskedtexture = 0; ds_p->maskedtexturecol = NULL; @@ -1932,15 +1906,26 @@ void R_StoreWallRange(INT32 start, INT32 stop) else { // two sided line - SLOPEPARAMS(backsector->c_slope, worldhigh, worldhighslope, backsector->ceilingheight) - SLOPEPARAMS(backsector->f_slope, worldlow, worldlowslope, backsector->floorheight) - worldhigh -= viewz; - worldhighslope -= viewz; - worldlow -= viewz; - worldlowslope -= viewz; - + + if (backsector->c_slope) { + worldhigh = P_GetZAt(backsector->c_slope, segleft.x, segleft.y) - viewz; + worldhighslope = P_GetZAt(backsector->c_slope, segright.x, segright.y) - viewz; + } else { + worldhighslope = + worldhigh = backsector->ceilingheight - viewz; + } + + + if (backsector->f_slope) { + worldlow = P_GetZAt(backsector->f_slope, segleft.x, segleft.y) - viewz; + worldlowslope = P_GetZAt(backsector->f_slope, segright.x, segright.y) - viewz; + } else { + worldlowslope = + worldlow = backsector->floorheight - viewz; + } + + // hack to allow height changes in outdoor areas - // This is what gets rid of the upper textures if there should be sky if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { @@ -1951,30 +1936,34 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; - if (worldbottomslope > worldlowslope || worldbottom > worldlow) + if ( + worldbottomslope > worldlowslope || + worldbottom > worldlow) { ds_p->silhouette = SIL_BOTTOM; - if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) + if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) ds_p->bsilheight = INT32_MAX; else ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); } - else if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) + else if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) { ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = INT32_MAX; // ds_p->sprbottomclip = negonearray; } - if (worldtopslope < worldhighslope || worldtop < worldhigh) + if ( + worldtopslope < worldhighslope || + worldtop < worldhigh) { ds_p->silhouette |= SIL_TOP; - if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) + if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) ds_p->tsilheight = INT32_MIN; else ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); } - else if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) + else if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = INT32_MIN; @@ -2062,16 +2051,17 @@ void R_StoreWallRange(INT32 start, INT32 stop) markceiling = false; } - if ((backsector->ceilingheight <= frontsector->floorheight) || - (backsector->floorheight >= frontsector->ceilingheight) || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope) - || (worldlow >= worldtop && worldlowslope >= worldtopslope)) + if (backsector->ceilingheight <= frontsector->floorheight || + backsector->floorheight >= frontsector->ceilingheight) { // closed door markceiling = markfloor = true; } // check TOP TEXTURE - if (worldhigh < worldtop || worldhighslope < worldtopslope) + if (worldhigh < worldtop + || worldhighslope < worldtopslope + ) { fixed_t texheight; // top texture @@ -2165,24 +2155,28 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS)) continue; - if (rover->flags & FF_INVERTSIDES) continue; if (rover->norender == leveltime) continue; - SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) - SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) + if (*rover->t_slope) { + high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); + highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); + } else + high1 = highslope1 = *rover->topheight; + if (*rover->b_slope) { + low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); + lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); + } else + low1 = lowslope1 = *rover->bottomheight; if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; for (r2 = frontsector->ffloors; r2; r2 = r2->next) { - if (r2->master == rover->master) // Skip if same control line. - break; - if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; @@ -2203,8 +2197,16 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) - SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) + if (*r2->t_slope) { + high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); + highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); + } else + high2 = highslope2 = *r2->topheight; + if (*r2->b_slope) { + low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); + lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); + } else + low2 = lowslope2 = *r2->bottomheight; if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2219,28 +2221,33 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->thicksides[i] = rover; i++; } + for (rover = frontsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS)) continue; - if (!(rover->flags & FF_ALLSIDES)) continue; if (rover->norender == leveltime) continue; - SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) - SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) + if (*rover->t_slope) { + high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); + highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); + } else + high1 = highslope1 = *rover->topheight; + if (*rover->b_slope) { + low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); + lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); + } else + low1 = lowslope1 = *rover->bottomheight; if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; for (r2 = backsector->ffloors; r2; r2 = r2->next) { - if (r2->master == rover->master) // Skip if same control line. - break; - if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; @@ -2261,9 +2268,17 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) - SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) -#undef SLOPEPARAMS + if (*r2->t_slope) { + high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); + highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); + } else + high2 = highslope2 = *r2->topheight; + if (*r2->b_slope) { + low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); + lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); + } else + low2 = lowslope2 = *r2->bottomheight; + if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) @@ -2284,15 +2299,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS) || rover->flags & FF_INVERTSIDES) continue; - if (rover->norender == leveltime) continue; // Oy vey. - if ( ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y)) <= worldbottom + viewz - && (P_GetFFloorTopZAt (rover, segright.x, segright.y)) <= worldbottomslope + viewz) - ||((P_GetFFloorBottomZAt(rover, segleft .x, segleft .y)) >= worldtop + viewz - && (P_GetFFloorBottomZAt(rover, segright.x, segright.y)) >= worldtopslope + viewz)) + if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz + && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) + ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz + && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) continue; ds_p->thicksides[i] = rover; @@ -2305,20 +2319,19 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_ALLSIDES)) continue; - if (rover->norender == leveltime) continue; // Oy vey. - if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldbottom + viewz - && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldbottomslope + viewz) - ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldtop + viewz - && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldtopslope + viewz)) + if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz + && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) + ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz + && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) continue; - if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldlow + viewz - && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldlowslope + viewz) - ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldhigh + viewz - && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldhighslope + viewz)) + if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldlow+viewz + && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldlowslope+viewz) + ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldhigh+viewz + && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldhighslope+viewz)) continue; ds_p->thicksides[i] = rover; @@ -2436,13 +2449,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) // and doesn't need to be marked. if (frontsector->heightsec == -1) { - if (frontsector->floorpic != skyflatnum && P_GetSectorFloorZAt(frontsector, viewx, viewy) >= viewz) + if (( + frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : + frontsector->floorheight) >= viewz) { // above view plane markfloor = false; } - if (frontsector->ceilingpic != skyflatnum && P_GetSectorCeilingZAt(frontsector, viewx, viewy) <= viewz) + if (( + frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : + frontsector->ceilingheight) <= viewz && + frontsector->ceilingpic != skyflatnum) { // below view plane markceiling = false; @@ -2494,12 +2512,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) light = &frontsector->lightlist[i]; rlight = &dc_lightlist[p]; - leftheight = P_GetLightZAt(light, segleft.x, segleft.y); - rightheight = P_GetLightZAt(light, segright.x, segright.y); + if (light->slope) { + leftheight = P_GetZAt(light->slope, segleft.x, segleft.y); + rightheight = P_GetZAt(light->slope, segright.x, segright.y); - if (light->slope) // Flag sector as having slopes frontsector->hasslope = true; + } else + leftheight = rightheight = light->height; leftheight -= viewz; rightheight -= viewz; @@ -2523,22 +2543,25 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (light->caster && light->caster->flags & FF_CUTSOLIDS) { - leftheight = P_GetFFloorBottomZAt(light->caster, segleft.x, segleft.y); - rightheight = P_GetFFloorBottomZAt(light->caster, segright.x, segright.y); + if (*light->caster->b_slope) { + leftheight = P_GetZAt(*light->caster->b_slope, segleft.x, segleft.y); + rightheight = P_GetZAt(*light->caster->b_slope, segright.x, segright.y); - if (*light->caster->b_slope) // Flag sector as having slopes frontsector->hasslope = true; + } else + leftheight = rightheight = *light->caster->bottomheight; - leftheight -= viewz; + leftheight -= viewz; rightheight -= viewz; - leftheight >>= 4; + leftheight >>= 4; rightheight >>= 4; rlight->botheight = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->botheightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); + } rlight->lightlevel = *light->lightlevel; @@ -2619,9 +2642,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) backsector->hasslope = true; - roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; - roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; - planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); + roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; + roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; + planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2642,9 +2665,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; - roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; - planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); + roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; + roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; + planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2672,13 +2695,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; + // Let the renderer know this sector is sloped. if (*rover->b_slope || *rover->t_slope) frontsector->hasslope = true; - roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; - roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; - planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); + roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; + roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; + planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2699,9 +2723,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; - roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; - planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); + roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; + roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; + planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2811,22 +2835,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (i = 0; i < numffloors; i++) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } - // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red - if (curline->polyseg) - { - for (i = 0; i < numffloors; i++) - { - if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) - continue; - if (ffloor[i].plane->minx > rw_x) - ffloor[i].plane->minx = rw_x; - - if (ffloor[i].plane->maxx < rw_stopx - 1) - ffloor[i].plane->maxx = rw_stopx - 1; - } - } } - + rw_silhouette = &(ds_p->silhouette); rw_tsilheight = &(ds_p->tsilheight); rw_bsilheight = &(ds_p->bsilheight); @@ -2854,32 +2864,29 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->portalpass = 0; // save sprite clipping info - if (maskedtexture || (ds_p->silhouette & (SIL_TOP | SIL_BOTTOM))) + if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) { - if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) - { - M_Memcpy(lastopening, ceilingclip + start, 2*(rw_stopx - start)); - ds_p->sprtopclip = lastopening - start; - lastopening += rw_stopx - start; - } + M_Memcpy(lastopening, ceilingclip+start, 2*(rw_stopx - start)); + ds_p->sprtopclip = lastopening - start; + lastopening += rw_stopx - start; + } - if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) - { - M_Memcpy(lastopening, floorclip + start, 2*(rw_stopx - start)); - ds_p->sprbottomclip = lastopening - start; - lastopening += rw_stopx - start; - } + if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) + { + M_Memcpy(lastopening, floorclip + start, 2*(rw_stopx-start)); + ds_p->sprbottomclip = lastopening - start; + lastopening += rw_stopx - start; } if (maskedtexture && !(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN : INT32_MAX; + ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN: INT32_MAX; } if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM)) { ds_p->silhouette |= SIL_BOTTOM; - ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX : INT32_MIN; + ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX: INT32_MIN; } ds_p++; } diff --git a/src/r_segs.h b/src/r_segs.h index ddf2e4655..92d0100e2 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -22,6 +22,4 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2); void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor); void R_StoreWallRange(INT32 start, INT32 stop); -void R_AllocSegMemory(void); - #endif diff --git a/src/r_state.h b/src/r_state.h index 3c0f3cc49..670f800d1 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -108,7 +108,7 @@ extern angle_t clipangle; extern angle_t doubleclipangle; extern INT32 viewangletox[FINEANGLES/2]; -extern angle_t *xtoviewangle; +extern angle_t xtoviewangle[MAXVIDWIDTH+1]; extern fixed_t rw_distance; extern angle_t rw_normalangle; diff --git a/src/r_things.c b/src/r_things.c index db1ac357a..2769deaba 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -68,8 +68,8 @@ typedef struct static lighttable_t **spritelights; // constant arrays used for psprite clipping and initializing clipping -INT16 *negonearray; -INT16 *screenheightarray; +INT16 negonearray[MAXVIDWIDTH]; +INT16 screenheightarray[MAXVIDWIDTH]; spriteinfo_t spriteinfo[NUMSPRITES]; @@ -489,7 +489,14 @@ void R_InitSprites(void) #ifdef ROTSPRITE INT32 angle; float fa; +#endif + for (i = 0; i < MAXVIDWIDTH; i++) + { + negonearray[i] = -1; + } + +#ifdef ROTSPRITE for (angle = 1; angle < ROTANGLES; angle++) { fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<> VISSPRITECHUNKBITS]; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS]; - -static void R_AllocVisSpriteChunkMemory(UINT32 chunk) -{ - vissprite_clipbot[chunk] = Z_Realloc(vissprite_clipbot[chunk], sizeof(INT16) * (VISSPRITESPERCHUNK * viewwidth), PU_STATIC, NULL); - vissprite_cliptop[chunk] = Z_Realloc(vissprite_cliptop[chunk], sizeof(INT16) * (VISSPRITESPERCHUNK * viewwidth), PU_STATIC, NULL); - - for (unsigned i = 0; i < VISSPRITESPERCHUNK; i++) - { - vissprite_t *sprite = visspritechunks[chunk] + i; - - sprite->clipbot = vissprite_clipbot[chunk] + (viewwidth * i); - sprite->cliptop = vissprite_cliptop[chunk] + (viewwidth * i); - } -} - -void R_AllocVisSpriteMemory(void) -{ - unsigned numchunks = MAXVISSPRITES >> VISSPRITECHUNKBITS; - - for (unsigned i = 0; i < numchunks; i++) - { - if (visspritechunks[i]) - R_AllocVisSpriteChunkMemory(i); - } -} - // // R_NewVisSprite // @@ -580,16 +559,13 @@ static vissprite_t overflowsprite; static vissprite_t *R_GetVisSprite(UINT32 num) { - UINT32 chunk = num >> VISSPRITECHUNKBITS; + UINT32 chunk = num >> VISSPRITECHUNKBITS; - // Allocate chunk if necessary - if (!visspritechunks[chunk]) - { - Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]); - R_AllocVisSpriteChunkMemory(chunk); - } + // Allocate chunk if necessary + if (!visspritechunks[chunk]) + Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]); - return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); + return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); } static vissprite_t *R_NewVisSprite(void) @@ -656,7 +632,13 @@ void R_DrawMaskedColumn(column_t *column) { dc_source = (UINT8 *)column + 3; dc_texturemid = basetexturemid - (topdelta<length + 4); } @@ -987,9 +969,14 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) // static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) { - sector_t *sector = sprite->sector; + INT32 i, lightnum, lindex; + INT16 cutfrac; + sector_t *sector; + vissprite_t *newsprite; - for (INT32 i = 1; i < sector->numlights; i++) + sector = sprite->sector; + + for (i = 1; i < sector->numlights; i++) { fixed_t testheight = sector->lightlist[i].height; @@ -1004,7 +991,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) if (testheight <= sprite->gz) return; - INT16 cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); + cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); if (cutfrac < 0) continue; if (cutfrac > viewheight) @@ -1012,16 +999,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // Found a split! Make a new sprite, copy the old sprite to it, and // adjust the heights. - vissprite_t *newsprite = R_NewVisSprite(); - - // Needs to keep the new sprite's clipping tables - INT16 *cliptop = newsprite->cliptop; - INT16 *clipbot = newsprite->clipbot; - - M_Memcpy(newsprite, sprite, sizeof (vissprite_t)); - - newsprite->cliptop = cliptop; - newsprite->clipbot = clipbot; + newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t)); sprite->cut |= SC_BOTTOM; sprite->gz = testheight; @@ -1044,7 +1022,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->cut |= SC_TOP; if (!(sector->lightlist[i].caster->flags & FF_NOSHADE)) { - INT32 lightnum = (*sector->lightlist[i].lightlevel >> LIGHTSEGSHIFT); + lightnum = (*sector->lightlist[i].lightlevel >> LIGHTSEGSHIFT); if (lightnum < 0) spritelights = scalelight[0]; @@ -1065,7 +1043,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { - INT32 lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); + lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; diff --git a/src/r_things.h b/src/r_things.h index 348601208..3e2414da1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -44,8 +44,8 @@ // Constant arrays used for psprite clipping // and initializing clipping. -extern INT16 *negonearray; -extern INT16 *screenheightarray; +extern INT16 negonearray[MAXVIDWIDTH]; +extern INT16 screenheightarray[MAXVIDWIDTH]; // vars for R_DrawMaskedColumn extern INT16 *mfloorclip; @@ -179,7 +179,8 @@ typedef struct vissprite_s fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; - INT16 *clipbot, *cliptop; + INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; + boolean precip; boolean vflip; // Flip vertically boolean isScaled; @@ -190,8 +191,6 @@ extern UINT32 visspritecount, numvisiblesprites; void R_ClipSprites(void); -void R_AllocVisSpriteMemory(void); - UINT8 *R_GetSpriteTranslation(vissprite_t *vis); // ---------- diff --git a/src/screen.h b/src/screen.h index 4d26f2138..a6a0eb477 100644 --- a/src/screen.h +++ b/src/screen.h @@ -34,13 +34,19 @@ #define ST_HEIGHT 32 #define ST_WIDTH 320 -// NEVER CHANGE THIS! This is the original resolution of the graphics. -#define BASEVIDWIDTH 320 -#define BASEVIDHEIGHT 200 +// used now as a maximum video mode size for extra vesa modes. -// Max screen size -#define MAXVIDWIDTH 15360 -#define MAXVIDHEIGHT 8640 +// we try to re-allocate a minimum of buffers for stability of the memory, +// so all the small-enough tables based on screen size, are allocated once +// and for all at the maximum size. +#define MAXVIDWIDTH 2560 // don't set this too high because actually +#define MAXVIDHEIGHT 1440 // lots of tables are allocated with the MAX size. +#define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original +#define BASEVIDHEIGHT 200 // resolution of the graphics. + +// max res for png capture; seperated it so both MAXVID values can be lower for software performance reasons; OpenGL does not care about those anyways +#define MAXPNGWIDTH 3840 +#define MAXPNGHEIGHT 2160 // global video state typedef struct viddef_s