From 0efedae2c3ffbdbcd422bdb358f23e5b6f4aa94e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Sep 2025 00:16:45 +0200 Subject: [PATCH] remove vid.rowbytes it was just vid.width lel --- src/d_main.c | 2 +- src/r_draw_span.cpp | 2 +- src/screen.h | 1 - src/sdl/i_video.c | 39 +++++++++++++++++++------------------ src/v_video.c | 47 ++++++++++++++++++++++++--------------------- src/y_inter.c | 2 +- 6 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 061be7537..afd480565 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -610,7 +610,7 @@ static boolean D_Display(void) { if (rendermode == render_soft) { - VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.rowbytes); + VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); } lastdraw = false; diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index 818b19182..92d64fd6e 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -104,7 +104,7 @@ static void R_DrawSpanTemplate(drawspandata_t* ds) UINT8 * restrict dest = R_Address(ds->x1, ds->y); UINT8 * restrict dsrc; - const UINT8 * restrict deststop = vid.screens[0] + vid.rowbytes * vid.height; + const UINT8 * restrict deststop = vid.screens[0] + vid.width * vid.height; if (dest+8 > deststop) { diff --git a/src/screen.h b/src/screen.h index 665466dde..e860be6fa 100644 --- a/src/screen.h +++ b/src/screen.h @@ -58,7 +58,6 @@ typedef struct viddef_s // screens[4] = fade screen end, postimage tempoarary buffer UINT8 *buffer; // invisible screens buffer - size_t rowbytes; // bytes per scanline of the VIDEO mode INT32 width; // PIXELS per scanline INT32 height; boolean recalc; // if true, recalc vid-based stuff diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index db2c8d90a..86615dfe2 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1207,7 +1207,7 @@ void I_OsPolling(void) if (consolevent) I_GetConsoleEvents(); - if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) + if (SDL_WasInit(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerUpdate(); @@ -1415,7 +1415,7 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale) if (rendermode != render_soft) I_Error ("I_ReadScreen: called while in non-software mode"); else if (scale == 1) - VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.rowbytes, vid.rowbytes); + VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width); else { UINT8 * restrict source = vid.screens[0]; @@ -1546,6 +1546,7 @@ INT32 VID_SetMode(INT32 modeNum) // just set the desktop resolution as a fallback SDL_DisplayMode mode; SDL_GetWindowDisplayMode(window, &mode); + if (mode.w >= 2048) { vid.width = 1920; @@ -1556,6 +1557,7 @@ INT32 VID_SetMode(INT32 modeNum) vid.width = mode.w; vid.height = mode.h; } + vid.modenum = -1; } @@ -1594,8 +1596,11 @@ static SDL_bool Impl_CreateContext(void) if (rendermode == render_soft) { int flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + { flags |= SDL_RENDERER_SOFTWARE; + } else if (cv_vidwait.value) { #if SDL_VERSION_ATLEAST(2, 0, 18) @@ -1650,9 +1655,9 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) flags |= SDL_WINDOW_OPENGL; if (msaa) - { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa); + { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa); } // Without a 24-bit depth buffer many visuals are ruined by z-fighting. @@ -1667,8 +1672,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) #endif // Create a window - window = SDL_CreateWindow("SRB2Kart "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - realwidth, realheight, flags); + window = SDL_CreateWindow("SRB2Kart "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, realwidth, realheight, flags); if (window == NULL) { @@ -1694,12 +1698,10 @@ static void Impl_VideoSetupBuffer(void) // Set up game's software render buffer size_t size; - vid.rowbytes = vid.width; - if (vid.buffer) free(vid.buffer); - size = vid.rowbytes*vid.height * NUMSCREENS; + size = vid.width*vid.height * NUMSCREENS; vid.buffer = calloc(size, NUMSCREENS); @@ -1709,8 +1711,7 @@ static void Impl_VideoSetupBuffer(void) } } -static FILE * -OpenRendererFile (const char * mode) +static FILE * OpenRendererFile(const char * mode) { char * path = va(pandf,srb2home,"renderer.txt"); return fopen(path, mode); @@ -1727,11 +1728,11 @@ void I_StartupGraphics(void) if (graphics_started) return; - COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f); - COM_AddCommand ("vid_modelist", VID_Command_ModeList_f); - COM_AddCommand ("vid_mode", VID_Command_Mode_f); - CV_RegisterVar (&cv_vidwait); - CV_RegisterVar (&cv_stretch); + COM_AddCommand("vid_nummodes", VID_Command_NumModes_f); + COM_AddCommand("vid_modelist", VID_Command_ModeList_f); + COM_AddCommand("vid_mode", VID_Command_Mode_f); + CV_RegisterVar(&cv_vidwait); + CV_RegisterVar(&cv_stretch); disable_mouse = M_CheckParm("-nomouse"); disable_fullscreen = M_CheckParm("-win") ? 1 : 0; @@ -1830,7 +1831,6 @@ void I_StartupGraphics(void) if (strcasecmp(word, "a2c") == 0) { a2c = true; - CONS_Printf("Using a2c because it was specified to be used earlier\n"); } } @@ -1984,7 +1984,8 @@ static void Impl_SetVsync(void) SDL_RenderSetVSync(renderer, cv_vidwait.value); #endif #ifdef HWRENDER - if (!renderer && rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + if (!renderer && rendermode == render_opengl && + sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) { SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); } diff --git a/src/v_video.c b/src/v_video.c index 1522d9fd9..9faa6dcb4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -612,8 +612,7 @@ static void CV_constextsize_OnChange(void) // -------------------------------------------------------------------------- // Copy a rectangular area from one bitmap to another (8bpp) // -------------------------------------------------------------------------- -void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, - size_t destrowbytes) +void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes) { if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)width) { @@ -790,7 +789,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (!desttop) return; - deststop = desttop + vid.rowbytes * vid.height; + deststop = desttop + vid.width * vid.height; if (scrn & V_NOSCALESTART) { @@ -1041,7 +1040,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!desttop) return; - deststop = desttop + vid.rowbytes * vid.height; + deststop = desttop + vid.width * vid.height; if (scrn & V_NOSCALESTART) { @@ -1191,7 +1190,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const #endif dest = vid.screens[scrn] + y*vid.width + x; - deststop = vid.screens[scrn] + vid.rowbytes * vid.height; + deststop = vid.screens[scrn] + vid.width * vid.height; while (height--) { @@ -1288,7 +1287,7 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) h = vid.height-y; dest = vid.screens[0] + y*vid.width + x; - deststop = vid.screens[0] + vid.rowbytes * vid.height; + deststop = vid.screens[0] + vid.width * vid.height; if (alphalevel) { @@ -1573,7 +1572,7 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c) h = w; dest = vid.screens[0] + y*vid.width + x; - deststop = vid.screens[0] + vid.rowbytes * vid.height; + deststop = vid.screens[0] + vid.width * vid.height; c &= 255; @@ -1645,7 +1644,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) dupx = dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); dest = vid.screens[0] + y*dupy*vid.width + x*dupx; - deststop = vid.screens[0] + vid.rowbytes * vid.height; + deststop = vid.screens[0] + vid.width * vid.height; // from V_DrawScaledPatch if (vid.width != BASEVIDWIDTH * dupx) @@ -1767,8 +1766,10 @@ void V_DrawVhsEffect(boolean rewind) upbary -= renderdeltatics * (vid.dupy * (rewind ? 3 : 1.8f)); downbary += renderdeltatics * (vid.dupy * (rewind ? 2 : 1)); - if (upbary < -barsize*FRACUNIT) upbary = vid.height< vid.height< vid.height<>FRACBITS, dby = downbary>>FRACBITS; @@ -1790,18 +1791,20 @@ void V_DrawVhsEffect(boolean rewind) thismapstart -= (2<= dby && y < dby+barsize) { thismapstart -= (2<= vid.height-2 && offs > 0) offs = 0; + if ((y == 0 && offs < 0) || (y >= vid.height-2 && offs > 0)) + offs = 0; - for (x = min(pos+vid.rowbytes*2, vid.rowbytes*vid.height); pos < x; pos++) + for (x = min(pos+(size_t)vid.width*2, (size_t)vid.width*vid.height); pos < x; pos++) { tmp[pos] = thismapstart[buf[pos+offs]]; #ifdef HQ_VHS @@ -1810,7 +1813,7 @@ void V_DrawVhsEffect(boolean rewind) } } - memcpy(buf, tmp, vid.rowbytes*vid.height); + memcpy(buf, tmp, vid.width*vid.height); } // @@ -1825,11 +1828,11 @@ void V_DrawVhsEffect(boolean rewind) void V_DrawFadeScreen(UINT16 color, UINT8 strength) { #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - { - HWR_FadeScreenMenuBack(color, strength); - return; - } + if (rendermode == render_opengl) + { + HWR_FadeScreenMenuBack(color, strength); + return; + } #endif const UINT8 *fadetable = @@ -1838,7 +1841,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) : ((color & 0xFF00) // Color is not palette index? ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. : ((UINT8 *)transtables + ((9-strength)<