From aa06459c09550ac7fb9a92ef3ba11e35f26c809e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Oct 2025 11:23:13 +0200 Subject: [PATCH 1/5] set special case for console key when using native keyboard input ALWAYS make sure that remains in the same physical place otherwise things might get very annoying it already does so with my german layout --- src/sdl/i_video.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 9ce860cb4..df4b80e20 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -412,6 +412,10 @@ static INT32 GetTypedChar(SDL_Keysym keysym) break; } + // Special case for console key + if (scancode == SDL_SCANCODE_GRAVE) + return '`'; + if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 && next_event.type == SDL_TEXTINPUT) { if (next_event.text.text[1] == '\0') // limit to ASCII From 852aa74d62dd7dae75f55a56b77a716cac17c792 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Oct 2025 11:24:32 +0200 Subject: [PATCH 2/5] random style fixes and stuff --- src/hu_stuff.c | 22 +++++++++++----------- src/k_kart.c | 3 --- src/v_video.c | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3a01aedc0..7f034f8ad 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -431,7 +431,7 @@ void HU_Start(void) void HU_Shiftform(void) { - shiftxform = cv_keyboardlayout.value == 3 ? french_shiftxform : english_shiftxform; + shiftxform = (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform; } //====================================================================== @@ -465,8 +465,8 @@ static INT16 addy = 0; // use this to make the messages scroll smoothly when one static void HU_removeChatText_Mini(void) { // MPC: Don't create new arrays, just iterate through an existing one - size_t i; - for(i=0;i 0) stop_spamming[i]--; } // handle chat timers - for (i=0; (i 0) chat_timers[i]--; @@ -1231,7 +1231,7 @@ static void HU_SendChatMessage(void) nodenum[2] = '\0'; // check for undesirable characters in our "number" - if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) + if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) { // check if nodenum[1] is a space if (nodenum[1] == ' ') @@ -1499,7 +1499,7 @@ static void HU_drawMiniChat(void) if (splitscreen > 1) boxw = max(64, boxw/2); - for (; i>0; i--) + for (; i > 0; i--) { char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); size_t j = 0; @@ -1572,7 +1572,7 @@ static void HU_drawMiniChat(void) i = 0; prev_linereturn = false; - for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages + for (; i <= (chat_nummsg_min-1); i++) // iterate through our hot messages { INT32 clrflag = 0; INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below... @@ -1749,7 +1749,6 @@ static void HU_drawChatLog(INT32 offset) Z_Free(msg); } - if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling. { atbottom = true; // we should scroll @@ -2284,6 +2283,7 @@ static void HU_DrawSongCreditsBox(void) V_DrawFill(x, y, strwidth*dup, BOXCREDITHEIGHT*dup, 28|flags|(bgt<= MAXTRANSLATIONS) I_Error("Invalid skin color #%hu.", (UINT16)color); - if (skinnum < 0 && skinnum > TC_DEFAULT) - I_Error("Invalid translation colormap index %d.", skinnum); - starttranscolor = (skinnum != TC_DEFAULT) ? K_GetSkinArray(local)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; if (starttranscolor >= NUM_PALETTE_ENTRIES) diff --git a/src/v_video.c b/src/v_video.c index 0104cf78c..9e7ece0d1 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -641,8 +641,8 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, } } -static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; -static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; +static const UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; +static const UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; UINT8 hudtrans = 0; static const UINT8 *v_colormap = NULL; From b84d1013374bdcbfeb42ba5e0c94bb9d5659ea75 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Oct 2025 01:52:53 +0200 Subject: [PATCH 3/5] initialize sdl window,renderer and texture to something --- src/sdl/i_video.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index df4b80e20..7393d8e4b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -156,9 +156,9 @@ static SDL_bool usesdl2soft = SDL_FALSE; static SDL_bool borderlesswindow = SDL_FALSE; // SDL2 vars -SDL_Window *window; -SDL_Renderer *renderer; -static SDL_Texture *texture; +SDL_Window *window = NULL; +SDL_Renderer *renderer = NULL; +static SDL_Texture *texture = NULL; static SDL_bool havefocus = SDL_TRUE; static const char *fallback_resolution_name = "Fallback"; @@ -909,6 +909,7 @@ static void Impl_HandleControllerAddedEvent(SDL_Event evt) cv_usejoystick[i].value = 0; else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys && cv_usejoystick[i].value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); } @@ -1111,9 +1112,11 @@ void I_OsPolling(void) I_GetEvent(); mod = SDL_GetModState(); + /* Handle here so that our state is always synched with the system. */ shiftdown = ctrldown = altdown = 0; capslock = false; + if (mod & KMOD_LSHIFT) shiftdown |= 1; if (mod & KMOD_RSHIFT) shiftdown |= 2; if (mod & KMOD_LCTRL) ctrldown |= 1; @@ -1147,7 +1150,7 @@ static void VID_Command_Mode_f (void) { INT32 modenum; - if (COM_Argc()!= 2) + if (COM_Argc() != 2) { CONS_Printf("vid_mode : set video mode, current video mode %i\n", vid.modenum); return; @@ -1292,8 +1295,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) #endif OglSdlSurface(vid.width, vid.height); } + else #endif - if (rendermode == render_soft) { SDL_RenderClear(renderer); @@ -1358,7 +1361,8 @@ void I_FinishUpdate(void) const boolean isserverplayer = consoleplayer == serverplayer; - if (cv_showping.value && ((netgame && !isserverplayer) || (simulated_lag != 0 && isserverplayer && Playing()))) + if (cv_showping.value && ((netgame && !isserverplayer) || + (simulated_lag != 0 && isserverplayer && Playing()))) SCR_DisplayLocalPing(); } @@ -1625,11 +1629,13 @@ static SDL_bool Impl_CreateContext(void) if (!renderer) renderer = SDL_CreateRenderer(window, -1, flags); + if (renderer == NULL) { CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); return SDL_FALSE; } + SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); } @@ -1732,6 +1738,7 @@ void I_StartupGraphics(void) #endif { const char *vd = SDL_GetCurrentVideoDriver(); + //CONS_Printf(M_GetText("Starting up with video driver: %s\n"), vd); if (vd && (strncasecmp(vd, "fbcon", 6) == 0)) framebuffer = SDL_TRUE; @@ -1962,7 +1969,7 @@ static void Impl_SetVsync(void) #endif #ifdef HWRENDER if (!renderer && rendermode == render_opengl && - sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) { SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); } From 0e2ffdeb1dedfd9954ddd4897d8d180ead70a014 Mon Sep 17 00:00:00 2001 From: "James R." Date: Sat, 30 Sep 2023 16:07:53 -0700 Subject: [PATCH 4/5] SDLSetMode: render immediately after resolution change to avoid 1-frame of texture presented at wrong size --- src/sdl/i_video.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 7393d8e4b..229008352 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1313,6 +1313,11 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); } + + if (graphics_started) + { + I_UpdateNoVsync(); + } } // From 383d55cac669d1e76ef170410fe9bd68fdbb8c89 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Oct 2025 03:37:45 +0200 Subject: [PATCH 5/5] smol cleanup V_DrawVhsEffect dont need to assign all the software stuff in gl mode --- src/hardware/hw_draw.c | 57 +++++++++++++++++++++--------------------- src/r_data.c | 1 + src/r_main.cpp | 2 ++ src/v_video.c | 43 +++++++++++++++++++++---------- 4 files changed, 62 insertions(+), 41 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index cf8ab29e3..4797f21de 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -46,9 +46,9 @@ typedef struct UINT8 image_descriptor; //18 } ATTRPACK TGAHeader; // sizeof is 18 -static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255}; -static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; -static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; +static const UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255}; +static const UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; +static const UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH; static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT; @@ -87,15 +87,15 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p switch (option & V_SCALEPATCHMASK) { - case V_NOSCALEPATCH: - dup = 1.0f; - break; - case V_SMALLSCALEPATCH: - dup = (float)vid.smalldup; - break; - case V_MEDSCALEPATCH: - dup = (float)vid.meddup; - break; + case V_NOSCALEPATCH: + dup = 1.0f; + break; + case V_SMALLSCALEPATCH: + dup = (float)vid.smalldup; + break; + case V_MEDSCALEPATCH: + dup = (float)vid.meddup; + break; } fscalew = fscaleh = FIXED_TO_FLOAT(pscale); @@ -269,15 +269,15 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, switch (option & V_SCALEPATCHMASK) { - case V_NOSCALEPATCH: - dup = 1.0f; - break; - case V_SMALLSCALEPATCH: - dup = (float)vid.smalldup; - break; - case V_MEDSCALEPATCH: - dup = (float)vid.meddup; - break; + case V_NOSCALEPATCH: + dup = 1.0f; + break; + case V_SMALLSCALEPATCH: + dup = (float)vid.smalldup; + break; + case V_MEDSCALEPATCH: + dup = (float)vid.meddup; + break; } fscale = FIXED_TO_FLOAT(pscale); @@ -506,7 +506,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) if (color & 0xFF00) // Do COLORMAP fade. { - if (HWR_ShouldUsePaletteRendering() && cv_glscreentextures.value) + if (cv_glscreentextures.value && HWR_ShouldUsePaletteRendering()) { const hwdscreentexture_t scr_tex = HWD_SCREENTEXTURE_GENERIC2; @@ -518,12 +518,10 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) GL_UnSetShader(); return; } - else - { - Surf.PolyColor.rgba = UINT2RGBA(0x01010160); - Surf.PolyColor.s.alpha = (strength*8); - poly_flags |= PF_Translucent; - } + + Surf.PolyColor.rgba = UINT2RGBA(0x01010160); + Surf.PolyColor.s.alpha = (strength*8); + poly_flags |= PF_Translucent; } else // Do TRANSMAP** fade. { @@ -890,11 +888,13 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fx >= vid.width || fy >= vid.height) return; + if (fx < 0) { fw += fx; fx = 0; } + if (fy < 0) { fh += fy; @@ -906,6 +906,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fx + fw > vid.width) fw = fvw - fx; + if (fy + fh > vid.height) fh = fvh - fy; diff --git a/src/r_data.c b/src/r_data.c index a796de138..93ad621fa 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1391,6 +1391,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) // Load in the light tables, now 64k aligned for smokie... lump = W_GetNumForName(colormap); + if (lump == LUMPERROR) lump = basecolormaplump; else diff --git a/src/r_main.cpp b/src/r_main.cpp index 5313357d6..339e34548 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -253,6 +253,7 @@ void SplitScreen_OnChange(void) if (playeringame[i] && i != consoleplayer) { UINT8 j; + for (j = 1; j < MAXSPLITSCREENPLAYERS; j++) { if (displayplayers[j] == consoleplayer) @@ -268,6 +269,7 @@ void SplitScreen_OnChange(void) } } } + static void Fov_OnChange(void) { R_SetViewSize(); diff --git a/src/v_video.c b/src/v_video.c index 9e7ece0d1..dd5091fa1 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1739,22 +1739,24 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch) void V_DrawVhsEffect(boolean rewind) { + fixed_t uby, dby; static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; - UINT8 *buf = vid.screens[0], *tmp = vid.screens[4]; - UINT16 y; - UINT32 x, pos = 0; + UINT8 barsize, updistort, downdistort; - UINT8 *normalmapstart = ((UINT8 *)transtables + (8<>1; + barsize = vid.dup << 5; + updistort = vid.dup << (rewind ? 5 : 3); + downdistort = updistort >> 1; if (rewind) V_DrawVhsEffect(false); // experimentation @@ -1763,11 +1765,12 @@ void V_DrawVhsEffect(boolean rewind) downbary += renderdeltatics * (vid.dup * (rewind ? 2 : 1)); if (upbary < -barsize*FRACUNIT) - upbary = vid.height< vid.height< vid.height << FRACBITS) downbary = -barsize*FRACUNIT; - fixed_t uby = upbary>>FRACBITS, dby = downbary>>FRACBITS; + uby = upbary >> FRACBITS; + dby = downbary >> FRACBITS; #ifdef HWRENDER if (rendermode == render_opengl) @@ -1777,6 +1780,16 @@ void V_DrawVhsEffect(boolean rewind) } #endif + buf = vid.screens[0]; + tmp = vid.screens[4]; + + normalmapstart = ((UINT8 *)transtables + (8<> V_CHARCOLORSHIFT); + if (!colorflags || colorflags > 15) // INT32 is signed, but V_CHARCOLORMASK is a very restrictive mask. return NULL; + return (purplemap+((colorflags-1)<<8)); #endif } @@ -1920,7 +1935,6 @@ UINT8 *V_GetStringColormap(INT32 colorflags) void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) { INT32 w, flags; - const UINT8 *colormap = V_GetStringColormap(c); flags = c & ~(V_CHARCOLORMASK | V_PARAMMASK); c &= 0x7f; @@ -1936,6 +1950,8 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) if (x + w > vid.width) return; + const UINT8 *colormap = V_GetStringColormap(c); + if (colormap != NULL) V_DrawMappedPatch(x, y, flags, hu_font[c], colormap); else @@ -2000,6 +2016,7 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) for (i = 0; i < slen; ++i) { c = newstring[i]; + if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 continue;