From ae473585b7849e72c8debc4e66d6896f4f2b438f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 8 Apr 2019 23:21:11 -0500 Subject: [PATCH] Add VHS pause/rewind effect --- src/d_main.c | 6 +++++ src/d_netcmd.c | 2 ++ src/screen.c | 4 ++++ src/screen.h | 2 +- src/v_video.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 3 +++ 6 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index d1a820c8..6feedb18 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -571,6 +571,9 @@ static void D_Display(void) if (demo.rewinding) V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM); + if (cv_vhseffect.value && (paused || (demo.playback && cv_playbackspeed.value > 1))) + V_DrawVhsEffect(demo.rewinding); + // vid size change is now finished if it was on... vid.recalc = 0; @@ -628,6 +631,9 @@ static void D_Display(void) V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s); } + if (cv_shittyscreen.value) + V_DrawVhsEffect(cv_shittyscreen.value == 2); + I_FinishUpdate(); // page flip or blit buffer } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 21a8e2a3..36774a80 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -932,6 +932,8 @@ void D_RegisterClientCommands(void) // screen.c CV_RegisterVar(&cv_fullscreen); CV_RegisterVar(&cv_renderview); + CV_RegisterVar(&cv_vhseffect); + CV_RegisterVar(&cv_shittyscreen); CV_RegisterVar(&cv_scr_depth); CV_RegisterVar(&cv_scr_width); CV_RegisterVar(&cv_scr_height); diff --git a/src/screen.c b/src/screen.c index 4de2abd0..4cb8bac5 100644 --- a/src/screen.c +++ b/src/screen.c @@ -59,6 +59,8 @@ INT32 setmodeneeded; //video mode change needed if > 0 (the mode number to set + static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}}; +static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}}; + //added : 03-02-98: default screen mode, as loaded/saved in config #ifdef WII consvar_t cv_scr_width = {"scr_width", "640", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -70,6 +72,8 @@ consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, N consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static void SCR_ChangeFullscreen (void); diff --git a/src/screen.h b/src/screen.h index 5b4a8e58..2e4d29b9 100644 --- a/src/screen.h +++ b/src/screen.h @@ -158,7 +158,7 @@ extern INT32 setmodeneeded; // mode number to set if needed, or 0 extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders -extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_fullscreen; +extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; // wait for page flipping to end or not extern consvar_t cv_vidwait; diff --git a/src/v_video.c b/src/v_video.c index dfad4c3a..16d784f4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1214,6 +1214,65 @@ void V_DrawPatchFill(patch_t *pat) } } +void V_DrawVhsEffect(boolean rewind) +{ + static fixed_t upbary = 100, downbary = 150; + + UINT8 *buf = screens[0], *tmp = screens[4]; + UINT16 x, y; + UINT32 pos = 0; + + UINT8 *normalmapstart = ((UINT8 *)transtables + (8<>1; + + if (rewind) + V_DrawVhsEffect(false); // experimentation + + upbary -= vid.dupy * (rewind ? 3 : 1.8f); + downbary += vid.dupy * (rewind ? 2 : 1); + if (upbary < -barsize) upbary = vid.height; + if (downbary > vid.height) downbary = -barsize; + + for (y = 0; y < vid.height; y++) + { + randommask = 0x0700; + thismapstart = normalmapstart; + offs = 0; + + if (y >= upbary && y < upbary+barsize) + { + //randommask = 0x0300; + thismapstart -= (2<= downbary && y < downbary+barsize) + { + //randommask = 0x0300; + //thismapstart = barmapstart; + thismapstart -= (2< 0) offs = 0; + + for (x = 0; x < vid.rowbytes; x++, pos++) + tmp[pos] = thismapstart[/*(M_RandomFixed()&randommask)|*/buf[pos+offs]]; + } + (void)randommask; + + memcpy(buf, tmp, vid.rowbytes*vid.height); +} + // // Fade all the screen buffer, so that the menu is more readable, // especially now that we use the small hufont in the menus... diff --git a/src/v_video.h b/src/v_video.h index c48c7a11..c8485c17 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -153,6 +153,9 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c); // fill a box with a flat as a pattern void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); +// draw wobbly VHS pause stuff +void V_DrawVhsEffect(boolean rewind); + // fade down the screen buffer before drawing the menu over void V_DrawFadeScreen(UINT16 color, UINT8 strength);