From c0aa630c6352d5663d3656f2ff69f3774f6b927a Mon Sep 17 00:00:00 2001 From: SeventhSentinel Date: Tue, 26 Jun 2018 10:14:59 -0400 Subject: [PATCH] Fade-in intro Also made flashing not-local, again. --- src/d_clisrv.c | 2 +- src/g_game.c | 2 +- src/hardware/hw_draw.c | 42 +++++++++++++++++++++++------------------- src/hardware/hw_main.h | 2 +- src/k_kart.c | 12 ++++++++++-- src/lua_hudlib.c | 25 +++++++++++++++++++++++++ src/m_menu.c | 2 +- src/p_user.c | 29 +++++++++++++++-------------- src/v_video.c | 37 +++++++++++++++++++++++-------------- src/v_video.h | 2 +- 10 files changed, 101 insertions(+), 54 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0d3b9141..43c728b7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1166,7 +1166,7 @@ static inline void CL_DrawConnectionStatus(void) INT32 ccstime = I_GetTime(); // Draw background fade - V_DrawFadeScreen(); + V_DrawFadeScreen(0xFF00, 16); // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); diff --git a/src/g_game.c b/src/g_game.c index 4b692ed9..618df06e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -207,7 +207,7 @@ UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; // SRB2kart -tic_t introtime = 108; +tic_t introtime = 108+5; // plus 5 for white fade tic_t starttime = 6*TICRATE + (3*TICRATE/4); INT32 hyudorotime = 7*TICRATE; INT32 stealtime = TICRATE/2; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index c142e74c..5bf00527 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -576,29 +576,33 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum // | /| // |/ | // 0--1 -void HWR_FadeScreenMenuBack(UINT32 color, INT32 height) +void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) { - FOutVector v[4]; - FSurfaceInfo Surf; + FOutVector v[4]; + FSurfaceInfo Surf; - // setup some neat-o translucency effect - if (!height) //cool hack 0 height is full height - height = vid.height; + v[0].x = v[3].x = -1.0f; + v[2].x = v[1].x = 1.0f; + v[0].y = v[1].y = -1.0f; + v[2].y = v[3].y = 1.0f; + v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].x = v[3].x = -1.0f; - v[2].x = v[1].x = 1.0f; - v[0].y = v[1].y = 1.0f-((height<<1)/(float)vid.height); - v[2].y = v[3].y = 1.0f; - v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; + v[0].sow = v[3].sow = 0.0f; + v[2].sow = v[1].sow = 1.0f; + v[0].tow = v[1].tow = 1.0f; + v[2].tow = v[3].tow = 0.0f; - v[0].sow = v[3].sow = 0.0f; - v[2].sow = v[1].sow = 1.0f; - v[0].tow = v[1].tow = 1.0f; - v[2].tow = v[3].tow = 0.0f; - - Surf.FlatColor.rgba = UINT2RGBA(color); - Surf.FlatColor.s.alpha = (UINT8)((0xff/2) * ((float)height / vid.height)); //calum: varies console alpha - HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); + if (color & 0xFF00) // Do COLORMAP fade. + { + Surf.FlatColor.rgba = UINT2RGBA(0x01010160); + Surf.FlatColor.s.alpha = (strength*8); + } + else // Do TRANSMAP** fade. + { + Surf.FlatColor.rgba = pLocalPalette[color].rgba; + Surf.FlatColor.s.alpha = (UINT8)(strength*25.5f); + } + HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } // Draw the console background with translucency support diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index fce17062..0459205b 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -33,7 +33,7 @@ void HWR_Shutdown(void); void HWR_clearAutomap(void); void HWR_drawAMline(const fline_t *fl, INT32 color); -void HWR_FadeScreenMenuBack(UINT32 color, INT32 height); +void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_DrawConsoleBack(UINT32 color, INT32 height); void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); diff --git a/src/k_kart.c b/src/k_kart.c index 5fe80dc1..ca36f55d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4786,7 +4786,7 @@ static void K_drawBattleFullscreen(void) if (stplyr->exiting) { if (stplyr == &players[displayplayer]) - V_DrawFadeScreen(); + V_DrawFadeScreen(0xFF00, 16); if (stplyr->kartstuff[k_balloon]) V_DrawFixedPatch(x< maxstrength) + return luaL_error(L, "%s fade strength %d out of range (0 - %d)", ((color & 0xFF00) ? "COLORMAP" : "TRANSMAP"), strength, maxstrength); + + if (strength == maxstrength) // Allow as a shortcut for drawfill... + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, ((color & 0xFF00) ? 31 : color)); + return 0; + } + + V_DrawFadeScreen(color, strength); + return 0; +} + static int libd_drawString(lua_State *L) { fixed_t x = luaL_checkinteger(L, 1); @@ -568,6 +592,7 @@ static luaL_Reg lib_draw[] = { {"drawNum", libd_drawNum}, {"drawPaddedNum", libd_drawPaddedNum}, {"drawFill", libd_drawFill}, + {"fadeScreen", libd_fadeScreen}, {"drawString", libd_drawString}, {"stringWidth", libd_stringWidth}, {"getColormap", libd_getColormap}, diff --git a/src/m_menu.c b/src/m_menu.c index bd4d0260..6126da07 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2677,7 +2677,7 @@ void M_Drawer(void) { // now that's more readable with a faded background (yeah like Quake...) if (!WipeInAction) - V_DrawFadeScreen(); + V_DrawFadeScreen(0xFF00, 16); if (currentMenu->drawroutine) currentMenu->drawroutine(); // call current menu Draw routine diff --git a/src/p_user.c b/src/p_user.c index f4d489ca..f601967c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8184,6 +8184,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam4_rotate.value; else camrotate = 0; + if (leveltime < introtime) // Whoooshy camera! + { + const INT32 introcam = (introtime - leveltime); + camrotate += introcam*5; + } thiscam->angle = focusangle + FixedAngle(camrotate*FRACUNIT); P_ResetCamera(player, thiscam); return true; @@ -9555,21 +9560,17 @@ void P_PlayerThink(player_t *player) player->losstime--; // Flash player after being hit. - if (!(player->pflags & PF_NIGHTSMODE)) + if (!(player->pflags & PF_NIGHTSMODE + || player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. + || player->kartstuff[k_growshrinktimer] > 0 // Grow doesn't flash either. + || (G_BattleGametype() && player->kartstuff[k_balloon] <= 0 && player->kartstuff[k_comebacktimer]) + || leveltime < starttime)) // Level intro { - // SRB2kart - fixes Hyudoro not flashing when it should. Grow doesn't flash either. Flashing is local. - if ((player == &players[displayplayer] - || (splitscreen && player == &players[secondarydisplayplayer]) - || (splitscreen > 1 && player == &players[thirddisplayplayer]) - || (splitscreen > 2 && player == &players[fourthdisplayplayer])) - && player->kartstuff[k_hyudorotimer] == 0 && player->kartstuff[k_growshrinktimer] <= 0 - && (player->kartstuff[k_comebacktimer] == 0 || (G_RaceGametype() || player->kartstuff[k_balloon] > 0))) - { - if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < K_GetKartFlashing() && (leveltime & 1)) - player->mo->flags2 |= MF2_DONTDRAW; - else - player->mo->flags2 &= ~MF2_DONTDRAW; - } + if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < K_GetKartFlashing() + && (leveltime & 1)) + player->mo->flags2 |= MF2_DONTDRAW; + else + player->mo->flags2 &= ~MF2_DONTDRAW; } else if (player->mo->tracer) { diff --git a/src/v_video.c b/src/v_video.c index 6435e413..11294896 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -953,25 +953,34 @@ void V_DrawPatchFill(patch_t *pat) // // Fade all the screen buffer, so that the menu is more readable, // especially now that we use the small hufont in the menus... +// If color is 0x00 to 0xFF, draw transtable (strength range 0-9). +// Else, use COLORMAP lump (strength range 0-31). +// IF YOU ARE NOT CAREFUL, THIS CAN AND WILL CRASH! +// I have kept the safety checks out of this function; +// the v.fadeScreen Lua interface handles those. // -void V_DrawFadeScreen(void) +void V_DrawFadeScreen(UINT16 color, UINT8 strength) { - const UINT8 *fadetable = (UINT8 *)colormaps + 16*256; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - UINT8 *buf = screens[0]; - #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - { - HWR_FadeScreenMenuBack(0x01010160, 0); // hack, 0 means full height - return; - } + if (rendermode != render_soft && rendermode != render_none) + { + HWR_FadeScreenMenuBack(color, strength); + return; + } #endif - // heavily simplified -- we don't need to know x or y - // position when we're doing a full screen fade - for (; buf < deststop; ++buf) - *buf = fadetable[*buf]; + { + const UINT8 *fadetable = ((color & 0xFF00) // Color is not palette index? + ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. + : ((UINT8 *)transtables + ((9-strength)<