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/sdl/i_video.c b/src/sdl/i_video.c index 3cf8c2939..32b99d3e0 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"; @@ -943,6 +943,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); } @@ -1141,9 +1142,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; @@ -1177,7 +1180,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; @@ -1322,8 +1325,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); @@ -1340,6 +1343,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(); + } } // @@ -1388,7 +1396,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(); } @@ -1655,11 +1664,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); } @@ -1762,6 +1773,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; @@ -1992,7 +2004,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); } 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;