From 50a2dc7b4d332afde8161712e943cad0e5eceb87 Mon Sep 17 00:00:00 2001 From: Wolfy Date: Sun, 17 Dec 2017 00:09:32 -0600 Subject: [PATCH] player views 4p still crashes for some reason --- src/d_main.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/r_draw.c | 10 ++++++++++ src/r_draw.h | 2 ++ src/r_main.c | 4 ++-- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 367bd012..5173f0b7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -401,7 +401,7 @@ static void D_Display(void) } // render the second screen - if (splitscreen && players[secondarydisplayplayer].mo) + if ((splitscreen || splitscreen3 || splitscreen4) && players[secondarydisplayplayer].mo) { #ifdef HWRENDER if (rendermode != render_soft) @@ -410,6 +410,9 @@ static void D_Display(void) #endif if (rendermode != render_none) { + if (splitscreen3 || splitscreen4) + viewwindowx = vid.width / 2; + viewwindowy = vid.height / 2; M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0])); @@ -422,11 +425,59 @@ static void D_Display(void) } } + if ((splitscreen3 || splitscreen4) && players[thirddisplayplayer].mo) + { +#ifdef HWRENDER + if (rendermode != render_soft) + HWR_RenderPlayerView(2, &players[thirddisplayplayer]); + else +#endif + if (rendermode != render_none) + { + viewwindowx = vid.width / 2; + viewwindowy = vid.height / 2; + M_Memcpy(ylookup2, ylookup3, viewheight*sizeof (ylookup[0])); + + topleft = screens[0] + viewwindowy*vid.width + viewwindowx; + + R_RenderPlayerView(&players[thirddisplayplayer]); + + viewwindowy = 0; + M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); + } + } + + if (splitscreen4 && players[fourthdisplayplayer].mo) + { +#ifdef HWRENDER + if (rendermode != render_soft) + HWR_RenderPlayerView(3, &players[fourthdisplayplayer]); + else +#endif + if (rendermode != render_none) + { + viewwindowx = vid.width / 2; + viewwindowy = vid.height / 2; + M_Memcpy(ylookup3, ylookup4, viewheight*sizeof (ylookup[0])); + + topleft = screens[0] + viewwindowy*vid.width + viewwindowx; + + R_RenderPlayerView(&players[fourthdisplayplayer]); + + viewwindowy = 0; + M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); + } + } + // Image postprocessing effect if (postimgtype) V_DoPostProcessor(0, postimgtype, postimgparam); if (postimgtype2) V_DoPostProcessor(1, postimgtype2, postimgparam2); + if (postimgtype3) + V_DoPostProcessor(2, postimgtype3, postimgparam3); + if (postimgtype4) + V_DoPostProcessor(3, postimgtype4, postimgparam4); } if (lastdraw) diff --git a/src/r_draw.c b/src/r_draw.c index ac7d263d..7ec91928 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -51,6 +51,14 @@ UINT8 *ylookup1[MAXVIDHEIGHT*4]; */ 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 */ @@ -632,6 +640,8 @@ void R_InitViewBuffer(INT32 width, INT32 height) { ylookup[i] = ylookup1[i] = screens[0] + (i+viewwindowy)*vid.width*bytesperpixel; ylookup2[i] = screens[0] + (i+(vid.height>>1))*vid.width*bytesperpixel; // for splitscreen + ylookup3[i] = screens[0] + (i+(vid.height>>1))*vid.width*bytesperpixel; + ylookup3[i] = screens[0] + (i+(vid.height>>1))*vid.width*bytesperpixel; } } diff --git a/src/r_draw.h b/src/r_draw.h index 419586c6..ae70cd8a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -22,6 +22,8 @@ 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; diff --git a/src/r_main.c b/src/r_main.c index 66869145..b494f86b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -660,11 +660,11 @@ void R_ExecuteSetViewSize(void) if (splitscreen || splitscreen3 || splitscreen4) viewheight >>= 1; + viewwidth = scaledviewwidth; + if (splitscreen3 || splitscreen4) viewwidth >>= 1; - viewwidth = scaledviewwidth; - centerx = viewwidth/2; centery = viewheight/2; centerxfrac = centerx<