diff --git a/src/d_main.c b/src/d_main.c index f05827fae..1f1774dc1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -118,7 +118,6 @@ boolean devparm = false; // started game with -devparm boolean singletics = false; // timedemo boolean lastdraw = false; -postimg_t postimgtype[MAXSPLITSCREENPLAYERS]; INT32 postimgparam[MAXSPLITSCREENPLAYERS]; // These variables are only true if @@ -515,15 +514,12 @@ static boolean D_Display(void) if (rendermode == render_soft) { - if (!splitscreen) - R_ApplyViewMorph(); + if (!splitscreen) + R_ApplyViewMorph(); for (i = 0; i <= splitscreen; i++) { - if (!postimgtype[i]) - continue; - - V_DoPostProcessor(i, postimgtype[i], postimgparam[i]); + V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]); } } diff --git a/src/d_player.h b/src/d_player.h index c2a5d32ce..09400fa9b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -413,6 +413,8 @@ typedef struct player_s // See pflags_t, above. pflags_t pflags; + UINT16 postimgflags; + // playing animation. panim_t panim; diff --git a/src/doomstat.h b/src/doomstat.h index ccf69e1cc..cdbb5d685 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -112,7 +112,6 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand extern boolean nodrawers; extern boolean noblit; extern boolean lastdraw; -extern postimg_t postimgtype[MAXSPLITSCREENPLAYERS]; extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; extern INT32 viewwindowx, viewwindowy; diff --git a/src/doomtype.h b/src/doomtype.h index 1dcf47ea7..d7ad320c8 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -344,14 +344,12 @@ typedef union FColorRGBA RGBA_t; typedef enum { - postimg_none, - postimg_water, - postimg_motion, - postimg_flip, - postimg_heat, - postimg_mirror, - postimg_mirrorflip -} postimg_t; + POSTIMG_WATER = 1, // Underwater screen effect. + POSTIMG_MOTION = 1<<1, // Unused motion blur effect. + POSTIMG_FLIP = 1<<2, // Flipcam screen effect. + POSTIMG_HEAT = 1<<3, // Heatwave screen effect. + POSTIMG_MIRROR = 1<<4, // encore screen effect. +} postimgflag_t; typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) #define LUMPERROR UINT32_MAX diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 169f4ad88..8818a213d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5241,9 +5241,6 @@ static void HWR_SetTransformAiming(FTransform *trans) void HWR_SetTransform(float fpov, player_t *player) { - postimg_t *postprocessor = &postimgtype[0]; - INT32 i; - gr_viewx = FIXED_TO_FLOAT(viewx); gr_viewy = FIXED_TO_FLOAT(viewy); gr_viewz = FIXED_TO_FLOAT(viewz); @@ -5272,24 +5269,16 @@ void HWR_SetTransform(float fpov, player_t *player) HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = splitscreen; - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - postprocessor = &postimgtype[i]; - } - atransform.flip = false; - if (*postprocessor == postimg_flip) + if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) atransform.flip = true; atransform.mirror = false; - if (*postprocessor == postimg_mirror) + if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) atransform.mirror = true; atransform.mirrorflip = false; - if (*postprocessor == postimg_mirrorflip) + if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR)) atransform.mirrorflip = true; // Set transform. @@ -5859,20 +5848,8 @@ INT32 HWR_GetTextureUsed(void) void HWR_DoPostProcessor(player_t *player) { - postimg_t *type = &postimgtype[0]; - UINT8 i; - HWD.pfnUnSetShader(); - for (i = splitscreen; i > 0; i--) - { - if (player != &players[displayplayers[i]]) - continue; - - type = &postimgtype[i]; - break; - } - // Armageddon Blast Flash! // Could this even be considered postprocessor? if (!HWR_PalRenderFlashpal() && player->flashcount) @@ -5909,7 +5886,7 @@ void HWR_DoPostProcessor(player_t *player) return; // Drunken vision! WooOOooo~ - if (*type == postimg_water || *type == postimg_heat) + if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; @@ -5921,7 +5898,7 @@ void HWR_DoPostProcessor(player_t *player) INT32 FREQUENCY; // Modifies the wave. - if (*type == postimg_water) + if (player->postimgflags & POSTIMG_WATER) { WAVELENGTH = 5; AMPLITUDE = 20; diff --git a/src/p_mobj.c b/src/p_mobj.c index f7ae70b32..72661c01b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3238,71 +3238,73 @@ void P_DestroyRobots(void) boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) { boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - postimg_t postimg = postimg_none; + UINT16 postimgflags = 0; UINT8 i; // This can happen when joining if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (encoremode && !flipcam) - postimg = postimg_mirror; - else if (!encoremode && flipcam) - postimg = postimg_flip; - else if (encoremode && flipcam) - postimg = postimg_mirrorflip; - else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist + if (encoremode) + postimgflags |= POSTIMG_MIRROR; + if (flipcam) + postimgflags |= POSTIMG_FLIP; + + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; + dummycam.subsector = player->awayviewmobj->subsector; dummycam.x = player->awayviewmobj->x; dummycam.y = player->awayviewmobj->y; dummycam.z = player->awayviewmobj->z; //dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT dummycam.height = 0; // Why? Remote viewpoint cameras have no height. + // Are we in water? if (P_CameraCheckWater(&dummycam)) - postimg = postimg_water; - else if (P_CameraCheckHeat(&dummycam)) - postimg = postimg_heat; + postimgflags |= POSTIMG_WATER; + if (P_CameraCheckHeat(&dummycam)) + postimgflags |= POSTIMG_HEAT; } else { // Are we in water? if (P_CameraCheckWater(thiscam)) - postimg = postimg_water; - else if (P_CameraCheckHeat(thiscam)) - postimg = postimg_heat; + postimgflags |= POSTIMG_WATER; + if (P_CameraCheckHeat(thiscam)) + postimgflags |= POSTIMG_HEAT; } - if (postimg != postimg_none) + for (i = 0; i <= splitscreen; i++) { - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; + if (player != &players[displayplayers[i]]) + continue; - postimgtype[i] = postimg; - } + players[displayplayers[i]].postimgflags = postimgflags; } if (thiscam->momx || thiscam->momy) { - if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) - { // Never fails for 2D mode. + if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode. + { mobj_t dummy; + dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker; dummy.subsector = thiscam->subsector; dummy.x = thiscam->x; dummy.y = thiscam->y; dummy.z = thiscam->z; dummy.height = thiscam->height; + if (player->pflags & PF_TIMEOVER) player->kartstuff[k_timeovercam] = (2*TICRATE)+1; + if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead. P_ResetCamera(player, thiscam); else P_SlideCameraMove(thiscam); + if (resetcalled) // Okay this means the camera is fully reset. return true; } diff --git a/src/p_setup.c b/src/p_setup.c index 39f38cabb..c4ccbef0a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2537,9 +2537,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) P_LevelInitStuff(reloadinggamestate); - for (i = 0; i <= splitscreen; i++) - postimgtype[i] = postimg_none; - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); diff --git a/src/p_tick.c b/src/p_tick.c index 1819d7b84..b6c25a088 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -481,9 +481,6 @@ void P_Ticker(boolean run) return; } - for (i = 0; i <= splitscreen; i++) - postimgtype[i] = postimg_none; - P_MapStart(); if (run) @@ -719,9 +716,6 @@ void P_PreTicker(INT32 frames) INT32 i; ticcmd_t temptic; - for (i = 0; i <= splitscreen; i++) - postimgtype[i] = postimg_none; - hook_defrosting = frames; while (hook_defrosting) diff --git a/src/p_user.c b/src/p_user.c index 6bbbea187..be994fc74 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3871,7 +3871,7 @@ boolean P_SpectatorJoinGame(player_t *player) return false; } -static void P_CalcPostImg(player_t *player) +/*static void P_CalcPostImg(player_t *player) { sector_t *sector = player->mo->subsector->sector; postimg_t *type = NULL; @@ -3974,7 +3974,7 @@ static void P_CalcPostImg(player_t *player) *param = 5; } #endif -} +}*/ void P_DoTimeOver(player_t *player) { @@ -4718,7 +4718,7 @@ void P_PlayerAfterThink(player_t *player) if (!thiscam->chase) // bob view only if looking through the player's eyes { P_CalcHeight(player); - P_CalcPostImg(player); + //P_CalcPostImg(player); } else { diff --git a/src/v_video.c b/src/v_video.c index ae6f19aa0..ffb213e56 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3193,7 +3193,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // Perform a particular image postprocessing function. // -void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) +void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) { #if NUMSCREENS < 5 // do not enable image post processing for ARM, SH and MIPS CPUs @@ -3201,6 +3201,7 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) (void)type; (void)param; #else + (void)param; // unused motion blur stuff INT32 yoffset, xoffset; #ifdef HWRENDER @@ -3221,10 +3222,14 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) else xoffset = 0; - if (type == postimg_water) + UINT8 *tmpscr = screens[4]; + UINT8 *srcscr = screens[0]; + + if (!player->postimgflags) + return; + + if (player->postimgflags & POSTIMG_WATER) { - UINT8 *tmpscr = screens[4]; - UINT8 *srcscr = screens[0]; INT32 y; // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic angle_t disStart = (((leveltime-1)*128) + (rendertimefrac / (FRACUNIT/128))) & FINEMASK; @@ -3261,61 +3266,46 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) } /* - Unoptimized version - for (x = 0; x < vid.width*vid.bpp; x++) - { - newpix = (x + sine); - - if (newpix < 0) - newpix = 0; - else if (newpix >= vid.width) - newpix = vid.width-1; - - tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); - }*/ + * Unoptimized version + * for (x = 0; x < vid.width*vid.bpp; x++) + * { + * newpix = (x + sine); + * + * if (newpix < 0) + * newpix = 0; + * else if (newpix >= vid.width) + * newpix = vid.width-1; + * + * tmpscrwater[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + }*/ disStart += 22;//the offset into the displacement map, increment each game loop disStart &= FINEMASK; //clip it to FINEMASK } - VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, - viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - else if (type == postimg_motion) // Motion Blur! + + /*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur! + * { + * INT32 x, y; + * + * // TODO: Add a postimg_param so that we can pick the translucency level... + * UINT8 *transme = transtables + ((param-1)<postimgflags & POSTIMG_HEAT) // Heat wave { - UINT8 *tmpscr = screens[4]; - UINT8 *srcscr = screens[0]; - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down + { + INT32 y, y2; + + for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--) + M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; + } + else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis { - UINT8 *tmpscr = screens[4]; - UINT8 *srcscr = screens[0]; INT32 y, x, x2; for (y = yoffset; y < yoffset+viewheight; y++) - { for (x = xoffset, x2 = xoffset+((viewwidth*vid.bpp)-1); x < xoffset+(viewwidth*vid.bpp); x++, x2--) tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x]; - } - VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, - viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - else if (type == postimg_mirrorflip) // Flip the screen upside-down and on the x axis + else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis { - UINT8 *tmpscr = screens[4]; - UINT8 *srcscr = screens[0]; INT32 y, x; for (y = yoffset; y < yoffset + viewheight; y++) for (x = xoffset; x < xoffset + viewwidth; x++) tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x]; - VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, - viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } + + VID_BlitLinearScreen(srcscr+vid.width*vid.bpp*yoffset+xoffset, tmpscr+vid.width*vid.bpp*yoffset+xoffset, + viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); #endif } + // Taken from my videos-in-SRB2 project // Generates a color look-up table // which has up to 64 colors at each channel diff --git a/src/v_video.h b/src/v_video.h index bc1e8c546..a06760215 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -251,7 +251,9 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); char V_GetSkincolorChar(INT32 color); -void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param); +typedef struct player_s player_t; + +void V_DoPostProcessor(INT32 view, player_t *player, INT32 param); void V_DrawPatchFill(patch_t *pat);