From ff0a3df3023c56e12a1a86ed8b6ebc5a78bf57fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Apr 2021 21:21:53 +0200 Subject: [PATCH 01/33] - fixed extended music lookup again. # Conflicts: # source/core/parsefuncs.h --- source/core/raze_music.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/source/core/raze_music.cpp b/source/core/raze_music.cpp index b2c3f0aed..c23f0b0ff 100644 --- a/source/core/raze_music.cpp +++ b/source/core/raze_music.cpp @@ -133,21 +133,24 @@ FileReader OpenMusic(const char* musicname) if (!reader.isOpen()) { int lumpnum = LookupMusic(musicname); - if (mus_extendedlookup && lumpnum >= 0) - { - // EDuke also looks in a subfolder named after the main game resource. Do this as well if extended lookup is active. - auto rfn = fileSystem.GetResourceFileName(fileSystem.GetFileContainer(lumpnum)); - auto rfbase = ExtractFileBase(rfn); - FStringf aliasMusicname("music/%s/%s", rfbase.GetChars(), musicname); - int newlumpnum = LookupMusic(aliasMusicname); - if (newlumpnum >= 0) lumpnum = newlumpnum; - } - if (lumpnum == -1) + if (mus_extendedlookup || lumpnum < 0) { + if (lumpnum >= 0) + { + // EDuke also looks in a subfolder named after the main game resource. Do this as well if extended lookup is active. + auto rfn = fileSystem.GetResourceFileName(fileSystem.GetFileContainer(lumpnum)); + auto rfbase = ExtractFileBase(rfn); + FStringf aliasMusicname("music/%s/%s", rfbase.GetChars(), musicname); + int newlumpnum = LookupMusic(aliasMusicname); + if (newlumpnum >= 0) lumpnum = newlumpnum; + } + // Always look in the 'music' subfolder as well. This gets used by multiple setups to store ripped CD tracks. FStringf aliasMusicname("music/%s", musicname); - lumpnum = LookupMusic(aliasMusicname); + int newlumpnum = LookupMusic(aliasMusicname, lumpnum >= 0); + if (newlumpnum >= 0) lumpnum = newlumpnum; } + if (lumpnum == -1 && (g_gameType & GAMEFLAG_SW)) { // Some Shadow Warrior distributions have the music in a subfolder named 'classic'. Check that, too. From 02dedaad4642df80de90c41c41833061f084792e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Apr 2021 22:11:16 +0200 Subject: [PATCH 02/33] - Blood: undid restriction for original QAV for Guns Akimbo shotgun fix. --- source/games/blood/src/weapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 3dd797e90..130074dd5 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -266,7 +266,7 @@ void WeaponDraw(PLAYER *pPlayer, int shade, double xpos, double ypos, int palnum if (pPlayer->weaponTimer == 0) // playing idle QAV? { // Double shotgun fix from BloodGDX. - if (/*!IsOriginalDemo() &&*/ (pPlayer->weaponState == -1 || (pPlayer->curWeapon == 3 && pPlayer->weaponState == 7)) && isOriginalQAV()) + if (/*!IsOriginalDemo() &&*/ (pPlayer->weaponState == -1 || (pPlayer->curWeapon == 3 && pPlayer->weaponState == 7))/* && isOriginalQAV()*/) duration = pQAV->duration - 1; else duration = (PlayClock + MulScale(4, smoothratio, 16)) % pQAV->duration; } From db5fbe3bbb7c1bc1f4e80f189a434eb3d7d4bff0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 Apr 2021 19:14:30 +0200 Subject: [PATCH 03/33] - make the startup banner in the initial console window work. --- source/core/gamecontrol.cpp | 19 +++++++-- source/core/gamecontrol.h | 1 + source/core/searchpaths.cpp | 10 +++++ wadsrc/static/engine/grpinfo.txt | 72 ++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index c9d0f4dfb..094c586f2 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -717,9 +717,6 @@ static TArray SetupGame() if (groupno == -1) return TArray(); auto& group = groups[groupno]; - if (GameStartupInfo.Name.IsNotEmpty()) I_SetWindowTitle(GameStartupInfo.Name); - else I_SetWindowTitle(group.FileInfo.name); - // Now filter out the data we actually need and delete the rest. usedgroups.Push(group); @@ -818,6 +815,8 @@ void CreateStatusBar() int RunGame() { + GameStartupInfo.FgColor = 0xffffff; + // Set up the console before anything else so that it can receive text. C_InitConsole(1024, 768, true); @@ -836,6 +835,19 @@ int RunGame() G_LoadConfig(); auto usedgroups = SetupGame(); + for (auto& grp : usedgroups) + { + if (grp.FileInfo.name.IsNotEmpty()) + { + if (GameStartupInfo.Name.IsEmpty()) GameStartupInfo.Name = grp.FileInfo.name; + if (grp.FileInfo.FgColor != grp.FileInfo.BgColor && (GameStartupInfo.FgColor != 0 || GameStartupInfo.BkColor != 0)) + { + GameStartupInfo.FgColor = grp.FileInfo.FgColor; + GameStartupInfo.BkColor = grp.FileInfo.BgColor; + } + } + } + I_SetIWADInfo(); InitFileSystem(usedgroups); if (usedgroups.Size() == 0) return 0; @@ -927,6 +939,7 @@ int RunGame() lookups.postLoadTables(); PostLoadSetup(); videoInit(); + if (GameStartupInfo.Name.IsNotEmpty()) I_SetWindowTitle(GameStartupInfo.Name); D_CheckNetGame(); UpdateGenericUI(ui_generic); diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 8a1cd1685..292c9a4b4 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -150,6 +150,7 @@ struct GrpInfo TArray tobedeleted; TArray loadfiles; TArray loadart; + uint32_t FgColor = 0, BgColor = 0; }; diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index f2f07e281..61cae25a3 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -460,6 +460,16 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMap Date: Sat, 10 Apr 2021 19:28:46 +0200 Subject: [PATCH 04/33] - activate the progress bar on the startup screen. --- source/core/gamecontrol.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 094c586f2..28516cf0c 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -881,7 +881,8 @@ int RunGame() V_InitScreenSize(); V_InitScreen(); - StartScreen = FStartupScreen::CreateInstance(100); + StartScreen = FStartupScreen::CreateInstance(8); + StartScreen->Progress(); TArray addArt; for (auto& grp : usedgroups) @@ -911,15 +912,20 @@ int RunGame() GameTicRate = 30; CheckUserMap(); GPalette.Init(MAXPALOOKUPS + 2); // one slot for each translation, plus a separate one for the base palettes and the internal one + StartScreen->Progress(); TexMan.Init([]() {}, [](BuildInfo &) {}); V_InitFonts(); + StartScreen->Progress(); TileFiles.Init(); + StartScreen->Progress(); I_InitSound(); + StartScreen->Progress(); Mus_InitMusic(); S_ParseSndInfo(); S_ParseReverbDef(); InitStatistics(); LoadScripts(); + StartScreen->Progress(); SetDefaultStrings(); if (Args->CheckParm("-sounddebug")) C_DoCommand("stat sounddebug"); @@ -927,11 +933,14 @@ int RunGame() enginePreInit(); SetupGameButtons(); gameinfo.mBackButton = "engine/graphics/m_back.png"; + StartScreen->Progress(); gi->app_init(); + StartScreen->Progress(); CreateStatusBar(); SetDefaultMenuColors(); M_Init(); BuildGameMenus(); + StartScreen->Progress(); if (!(paletteloaded & PALETTE_MAIN)) I_FatalError("No palette found."); From 184d9be6b1d00e772a53fdc98d0e63d9d136fdf5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 10 Apr 2021 21:42:53 +0200 Subject: [PATCH 05/33] - fixed palette setup for duplicate base palettes. Due to some old code it could happen that these weren't fully set up and missed their translations. Fixes #301 - Blood's invulnerability palette is identical to the base. --- source/core/palette.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/source/core/palette.cpp b/source/core/palette.cpp index a5c256f41..2625746b3 100644 --- a/source/core/palette.cpp +++ b/source/core/palette.cpp @@ -268,16 +268,13 @@ void LookupTableInfo::postLoadLookups() { const uint8_t* lookup = (uint8_t*)tables[l].Shades.GetChars(); FRemapTable remap; - if (i == 0 || (palette != basepalette && !palette->TwodOnly)) + memcpy(remap.Remap, lookup, 256); + for (int j = 0; j < 256; j++) { - memcpy(remap.Remap, lookup, 256); - for (int j = 0; j < 256; j++) - { - remap.Palette[j] = palette->Palette[remap.Remap[j]]; - } - remap.NumEntries = 256; - GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap); + remap.Palette[j] = palette->Palette[remap.Remap[j]]; } + remap.NumEntries = 256; + GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap); } } } From 0bdbf0f1cbcaf4bb19bb2c8567aa5d5e5fb62438 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 08:26:36 +0200 Subject: [PATCH 06/33] - fixed: alpha was never set for voxels. Fixes #304 --- source/build/src/voxmodel.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 2e3b37e60..64bf05abb 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -137,9 +137,6 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate) float pc[4]; - pc[0] = pc[1] = pc[2] = 1.f; - - if (!shadowHack) { pc[3] = (tspr->cstat & 2) ? glblend[tspr->blend].def[!!(tspr->cstat & 512)].alpha : 1.0f; @@ -152,6 +149,12 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate) } else pc[3] = 1.f; GLInterface.SetShade(std::max(0, globalshade), numshades); + + pc[0] = (float)globalr * (1.f / 255.f); + pc[1] = (float)globalg * (1.f / 255.f); + pc[2] = (float)globalb * (1.f / 255.f); + GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]); + //------------ //transform to Build coords From b3bcedda6ce64e108289fa363653bd9d65177e6f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 08:40:18 +0200 Subject: [PATCH 07/33] - moved backend independent HUD code out of glbackend.cpp. --- source/CMakeLists.txt | 1 + source/core/gamehud.cpp | 139 +++++++++++++++++++++++ source/core/gamehud.h | 8 ++ source/core/mainloop.cpp | 1 + source/games/blood/src/animatesprite.cpp | 1 - source/games/blood/src/credits.cpp | 1 - source/games/blood/src/hudsprites.cpp | 2 +- source/games/blood/src/prediction.cpp | 1 - source/games/blood/src/qav.cpp | 1 - source/games/blood/src/sbar.cpp | 1 - source/games/blood/src/view.cpp | 1 - source/games/duke/src/d_menu.cpp | 1 - source/games/duke/src/game.cpp | 1 - source/games/duke/src/game_misc.cpp | 1 - source/games/duke/src/gameloop.cpp | 1 - source/games/duke/src/inlines.h | 2 +- source/games/duke/src/render.cpp | 1 + source/games/exhumed/src/d_menu.cpp | 1 - source/games/exhumed/src/light.cpp | 1 - source/games/exhumed/src/sequence.cpp | 2 +- source/games/exhumed/src/view.cpp | 1 - source/games/sw/src/d_menu.cpp | 3 - source/games/sw/src/draw.cpp | 1 - source/games/sw/src/jsector.cpp | 1 - source/games/sw/src/panel.cpp | 2 +- source/glbackend/glbackend.cpp | 88 +------------- source/glbackend/glbackend.h | 3 - 27 files changed, 155 insertions(+), 112 deletions(-) create mode 100644 source/core/gamehud.cpp create mode 100644 source/core/gamehud.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 63169478b..c4109c07d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1046,6 +1046,7 @@ set (PCH_SOURCES core/gameconfigfile.cpp core/gamecvars.cpp core/gamecontrol.cpp + core/gamehud.cpp core/gamefuncs.cpp core/gameinput.cpp core/interpolate.cpp diff --git a/source/core/gamehud.cpp b/source/core/gamehud.cpp new file mode 100644 index 000000000..7b94b95a1 --- /dev/null +++ b/source/core/gamehud.cpp @@ -0,0 +1,139 @@ +/* +** gamehud.cpp +** +** Management of HUD elements +** +**--------------------------------------------------------------------------- +** Copyright 2019-2021 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include +#include +#include "gamehud.h" +#include "textures.h" +#include "palette.h" +#include "gamecontrol.h" +#include "v_2ddrawer.h" +#include "v_video.h" +#include "build.h" +#include "v_draw.h" +#include "v_font.h" +#include "gamestruct.h" + +F2DDrawer twodpsp; + + +void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha) +{ + double dz = z / 65536.; + alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + + if (picanm[picnum].sf & PICANM_ANIMTYPE_MASK) + picnum += animateoffs(picnum, 0); + + auto tex = tileGetTexture(picnum); + + DrawTexture(&twodpsp, tex, sx, sy, + DTA_ScaleX, dz, DTA_ScaleY, dz, + DTA_Color, shadeToLight(dashade), + DTA_TranslationIndex, palid, + DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, + DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, + DTA_FullscreenScale, (dastat & RS_STRETCH)? FSMode_ScaleToScreen: FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_CenterOffsetRel, !(dastat & (RS_TOPLEFT | RS_CENTER)), + DTA_TopLeft, !!(dastat & RS_TOPLEFT), + DTA_CenterOffset, !!(dastat & RS_CENTER), + DTA_FlipX, !!(dastat & RS_XFLIPHUD), + DTA_FlipY, !!(dastat & RS_YFLIPHUD), + DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0, + DTA_Rotate, a * -BAngToDegree, + DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)), + DTA_Alpha, alpha, + TAG_DONE); +} + + +//========================================================================== +// +// DFrameBuffer :: DrawRateStuff +// +// Draws the fps counter, dot ticker, and palette debug. +// +//========================================================================== +CVAR(Bool, vid_fps, false, 0) + + +static FString statFPS() +{ + static int32_t frameCount; + static double lastFrameTime; + static double cumulativeFrameDelay; + static double lastFPS; + + FString output; + + double frameTime = I_msTimeF(); + double frameDelay = frameTime - lastFrameTime; + cumulativeFrameDelay += frameDelay; + + frameCount++; + if (frameDelay >= 0) + { + output.AppendFormat("%5.1f fps (%.1f ms)\n", lastFPS, frameDelay); + + if (cumulativeFrameDelay >= 1000.0) + { + lastFPS = 1000. * frameCount / cumulativeFrameDelay; + frameCount = 0; + cumulativeFrameDelay = 0.0; + } + } + lastFrameTime = frameTime; + return output; +} + +void DrawRateStuff() +{ + // Draws frame time and cumulative fps + if (vid_fps) + { + FString fpsbuff = statFPS(); + + int textScale = active_con_scale(twod); + int rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); + twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0)); + DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char*)&fpsbuff[0], + DTA_VirtualWidth, screen->GetWidth() / textScale, + DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_KeepRatio, true, TAG_DONE); + + } +} + diff --git a/source/core/gamehud.h b/source/core/gamehud.h new file mode 100644 index 000000000..56033bdd3 --- /dev/null +++ b/source/core/gamehud.h @@ -0,0 +1,8 @@ +#pragma once + +#include "v_2ddrawer.h" + +extern F2DDrawer twodpsp; + +void DrawRateStuff(); +void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha = 1); diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index efdd496d4..1ffdc6293 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -88,6 +88,7 @@ #include "gamestruct.h" #include "savegamehelp.h" #include "v_draw.h" +#include "gamehud.h" CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index fb9e477a9..918e24916 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_2ddrawer.h" #include "v_video.h" #include "v_font.h" -#include "glbackend/glbackend.h" BEGIN_BLD_NS diff --git a/source/games/blood/src/credits.cpp b/source/games/blood/src/credits.cpp index ea78f4b7b..c18453352 100644 --- a/source/games/blood/src/credits.cpp +++ b/source/games/blood/src/credits.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "SmackerDecoder.h" #include "blood.h" #include "animtexture.h" -#include "../glbackend/glbackend.h" #include "raze_sound.h" #include "v_2ddrawer.h" #include "screenjob.h" diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index 6df0ada96..c570b115d 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -37,7 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gstrings.h" #include "v_2ddrawer.h" #include "v_video.h" -#include "glbackend/glbackend.h" +#include "gamehud.h" BEGIN_BLD_NS diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index 5d8f877c9..156d70588 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_2ddrawer.h" #include "v_video.h" #include "v_font.h" -#include "glbackend/glbackend.h" BEGIN_BLD_NS diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 607a73d40..a17d24df6 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "common_game.h" #include "v_draw.h" -#include "glbackend/glbackend.h" #include "blood.h" BEGIN_BLD_NS diff --git a/source/games/blood/src/sbar.cpp b/source/games/blood/src/sbar.cpp index fe6f16a07..952e40ab8 100644 --- a/source/games/blood/src/sbar.cpp +++ b/source/games/blood/src/sbar.cpp @@ -37,7 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_2ddrawer.h" #include "v_video.h" #include "v_font.h" -#include "glbackend/glbackend.h" #include "statusbar.h" #include "automap.h" #include "v_draw.h" diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 938156aa7..c85cd6c2f 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -42,7 +42,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "automap.h" #include "gamefuncs.h" #include "v_draw.h" -#include "glbackend/glbackend.h" BEGIN_BLD_NS diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 30bcbc469..6af3e4349 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -42,7 +42,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "mapinfo.h" #include "gamestate.h" #include "dukeactor.h" -#include "../../glbackend/glbackend.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 8b284df75..6a23cc55f 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -38,7 +38,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "st_start.h" #include "i_interface.h" #include "prediction.h" -#include "glbackend/glbackend.h" #include "gamestate.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index f5ea986d9..81972423a 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -41,7 +41,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "i_interface.h" #include "prediction.h" #include "sbar.h" -#include "glbackend/glbackend.h" #include "gamestate.h" #include "dukeactor.h" #include "interpolate.h" diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index a8321e7d4..917bdf3f7 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -35,7 +35,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "mapinfo.h" #include "texturemanager.h" #include "interpolate.h" -#include "glbackend/glbackend.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index abdf69b7c..345633f80 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -1,7 +1,7 @@ #pragma once #include "mathutil.h" -#include "glbackend/glbackend.h" +#include "gamehud.h" #include "global.h" // all inline functions. diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 42bcc0c07..e3c46670a 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -33,6 +33,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "automap.h" #include "dukeactor.h" #include "interpolate.h" +#include "glbackend/glbackend.h" BEGIN_DUKE_NS diff --git a/source/games/exhumed/src/d_menu.cpp b/source/games/exhumed/src/d_menu.cpp index 17fd07e4c..79061cb69 100644 --- a/source/games/exhumed/src/d_menu.cpp +++ b/source/games/exhumed/src/d_menu.cpp @@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "vm.h" #include "razemenu.h" -#include "../../glbackend/glbackend.h" BEGIN_PS_NS diff --git a/source/games/exhumed/src/light.cpp b/source/games/exhumed/src/light.cpp index ec4a7741a..84db404ec 100644 --- a/source/games/exhumed/src/light.cpp +++ b/source/games/exhumed/src/light.cpp @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "exhumed.h" #include "view.h" #include "aistuff.h" -#include "../glbackend/glbackend.h" #include #include #include diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index 4845865ae..49e05e1c4 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" -#include "glbackend/glbackend.h" +#include "gamehud.h" #include "sequence.h" #include "engine.h" #include "exhumed.h" diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 8d3e7cf20..485a783d8 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "mapinfo.h" #include "v_video.h" #include "interpolate.h" -#include "glbackend/glbackend.h" #include "v_draw.h" #include diff --git a/source/games/sw/src/d_menu.cpp b/source/games/sw/src/d_menu.cpp index 84ec2c6e6..eff540c1c 100644 --- a/source/games/sw/src/d_menu.cpp +++ b/source/games/sw/src/d_menu.cpp @@ -51,9 +51,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_draw.h" #include "vm.h" -#include "../../glbackend/glbackend.h" - - BEGIN_SW_NS //---------------------------------------------------------------------------- diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 915788055..74e3cc003 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -55,7 +55,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "v_2ddrawer.h" #include "v_video.h" #include "v_draw.h" -#include "glbackend/glbackend.h" BEGIN_SW_NS diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 5f153cc4a..a44326e8f 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -44,7 +44,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "pal.h" #include "parent.h" #include "v_video.h" -#include "glbackend/glbackend.h" BEGIN_SW_NS diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index bfa72e046..5494576b0 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -37,11 +37,11 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "pal.h" #include "player.h" #include "v_2ddrawer.h" +#include "gamehud.h" #include "weapon.h" #include "razemenu.h" #include "raze_sound.h" -#include "glbackend/glbackend.h" BEGIN_SW_NS diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index b1abfbfce..a8be0093c 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -50,10 +50,10 @@ #include "hw_cvars.h" #include "gamestruct.h" #include "gl_models.h" +#include "gamehud.h" CVAR(Bool, gl_texture, true, 0) -F2DDrawer twodpsp; static int BufferLock = 0; TArray matrixArray; @@ -405,62 +405,6 @@ void renderFinishScene() } } -//========================================================================== -// -// DFrameBuffer :: DrawRateStuff -// -// Draws the fps counter, dot ticker, and palette debug. -// -//========================================================================== -CVAR(Bool, vid_fps, false, 0) - - -static FString statFPS() -{ - static int32_t frameCount; - static double lastFrameTime; - static double cumulativeFrameDelay; - static double lastFPS; - - FString output; - - double frameTime = I_msTimeF(); - double frameDelay = frameTime - lastFrameTime; - cumulativeFrameDelay += frameDelay; - - frameCount++; - if (frameDelay >= 0) - { - output.AppendFormat("%5.1f fps (%.1f ms)\n", lastFPS, frameDelay); - - if (cumulativeFrameDelay >= 1000.0) - { - lastFPS = 1000. * frameCount / cumulativeFrameDelay; - frameCount = 0; - cumulativeFrameDelay = 0.0; - } - } - lastFrameTime = frameTime; - return output; -} - -void DrawRateStuff() -{ - // Draws frame time and cumulative fps - if (vid_fps) - { - FString fpsbuff = statFPS(); - - int textScale = active_con_scale(twod); - int rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); - twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0)); - DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char*)&fpsbuff[0], - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, - DTA_KeepRatio, true, TAG_DONE); - - } -} int32_t r_scenebrightness = 0; @@ -533,33 +477,3 @@ void precacheMarkedTiles() } } -void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha) -{ - double dz = z / 65536.; - alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); - - if (picanm[picnum].sf & PICANM_ANIMTYPE_MASK) - picnum += animateoffs(picnum, 0); - - auto tex = tileGetTexture(picnum); - - DrawTexture(&twodpsp, tex, sx, sy, - DTA_ScaleX, dz, DTA_ScaleY, dz, - DTA_Color, shadeToLight(dashade), - DTA_TranslationIndex, palid, - DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, - DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1, - DTA_FullscreenScale, (dastat & RS_STRETCH)? FSMode_ScaleToScreen: FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffsetRel, !(dastat & (RS_TOPLEFT | RS_CENTER)), - DTA_TopLeft, !!(dastat & RS_TOPLEFT), - DTA_CenterOffset, !!(dastat & RS_CENTER), - DTA_FlipX, !!(dastat & RS_XFLIPHUD), - DTA_FlipY, !!(dastat & RS_YFLIPHUD), - DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0, - DTA_Rotate, a * -BAngToDegree, - DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)), - DTA_Alpha, alpha, - TAG_DONE); -} - diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 1a74145e7..3a4f360aa 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -340,13 +340,10 @@ public: }; extern GLInstance GLInterface; -extern F2DDrawer twodpsp; void renderSetProjectionMatrix(const float* p); void renderSetViewMatrix(const float* p); void renderSetVisibility(float v); void renderBeginScene(); void renderFinishScene(); -void DrawRateStuff(); void videoShowFrame(int32_t); -void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha = 1); From 9fd3ab6b5ecfd60fffe3c27e99f682babdb5afa7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 09:59:55 +0200 Subject: [PATCH 08/33] - fixed texture precaching. After the migration to GZDoom's full backend this never created any textureds when precaching things. --- source/CMakeLists.txt | 1 + source/build/include/build.h | 4 - source/build/src/polymost.cpp | 40 ------- source/core/precache.cpp | 133 ++++++++++++++++++++++++ source/core/precache.h | 5 + source/games/blood/src/preload.cpp | 1 + source/games/blood/src/view.cpp | 1 + source/games/duke/src/premap_d.cpp | 1 + source/games/duke/src/premap_r.cpp | 1 + source/games/exhumed/src/enginesubs.cpp | 1 + source/games/sw/src/cache.cpp | 1 + source/glbackend/glbackend.cpp | 38 ------- 12 files changed, 145 insertions(+), 82 deletions(-) create mode 100644 source/core/precache.cpp create mode 100644 source/core/precache.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c4109c07d..11f382b2f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1061,6 +1061,7 @@ set (PCH_SOURCES core/secrets.cpp core/compositesavegame.cpp core/savegamehelp.cpp + core/precache.cpp core/quotes.cpp core/screenshot.cpp core/raze_music.cpp diff --git a/source/build/include/build.h b/source/build/include/build.h index 5accd465f..027be46bb 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -664,7 +664,6 @@ typedef struct s_equation void renderSetRollAngle(float rolla); #endif -void PrecacheHardwareTextures(int nTile); void Polymost_Startup(); typedef uint16_t polytintflags_t; @@ -842,9 +841,6 @@ extern int32_t rintersect(int32_t x1, int32_t y1, int32_t z1, int32_t x3, int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz); -void markTileForPrecache(int tilenum, int palnum); -void precacheMarkedTiles(); - extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar); extern int32_t(*getpalookup_replace)(int32_t davis, int32_t dashade); extern void(*initspritelists_replace)(void); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 496edb870..a4b04a143 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -99,7 +99,6 @@ static int32_t r_parallaxskyclamping = 1; #define Bfabsf fabsf static int32_t drawingskybox = 0; -static int32_t hicprecaching = 0; static hitdata_t polymost_hitdata; @@ -3543,45 +3542,6 @@ _drawsprite_return: static_assert((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); -void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype) -{ - // dapicnum and dapalnum are like you'd expect - // datype is 0 for a wall/floor/ceiling and 1 for a sprite - // basically this just means walls are repeating - // while sprites are clamped - - if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(dapalnum))) return;//dapalnum = 0; - - //Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); - hicprecaching = 1; - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); - auto tex = tileGetTexture(dapicnum); - if (tex->isValid()) - GLInterface.SetTexture(tex, palid, CLAMP_NONE); - hicprecaching = 0; - - if (datype == 0 || !hw_models) return; - - int const mid = md_tilehasmodel(dapicnum, dapalnum); - - if (mid < 0 || models[mid]->mdnum < 2) return; - - int const surfaces = (models[mid]->mdnum == 3) ? ((md3model_t *)models[mid])->head.numsurfs : 0; - - for (int i = 0; i <= surfaces; i++) - { - auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr); - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); - if (tex) GLInterface.SetTexture(tex, palid, CLAMP_NONE); - } -} - -void PrecacheHardwareTextures(int nTile) -{ - // PRECACHE - // This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer. - polymost_precache(nTile, 0, 1); -} extern char* voxfilenames[MAXVOXELS]; void (*PolymostProcessVoxels_Callback)(void) = NULL; diff --git a/source/core/precache.cpp b/source/core/precache.cpp new file mode 100644 index 000000000..3341630e5 --- /dev/null +++ b/source/core/precache.cpp @@ -0,0 +1,133 @@ +/* +** precache.cpp +** +** +** +**--------------------------------------------------------------------------- +** Copyright 2019-2021 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "build.h" +#include "palette.h" +#include "v_video.h" +#include "hw_material.h" +#include "glbackend/gl_models.h" + +static void PrecacheTex(FGameTexture* tex, int palid) +{ + if (!tex || !tex->isValid()) return; + int scaleflags = 0; + if (shouldUpscale(tex, UF_Texture)) scaleflags |= CTF_Upscale; + + auto mat = FMaterial::ValidateTexture(tex, scaleflags); + screen->PrecacheMaterial(mat, palid); +} + +static void doprecache(int32_t dapicnum, int32_t dapalnum, int32_t datype) +{ + // dapicnum and dapalnum are like you'd expect + // datype is 0 for a wall/floor/ceiling and 1 for a sprite + // basically this just means walls are repeating + // while sprites are clamped + + if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(dapalnum))) return;//dapalnum = 0; + + //Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + auto tex = tileGetTexture(dapicnum); + PrecacheTex(tex, palid); + + if (datype == 0 || !hw_models) return; + + int const mid = md_tilehasmodel(dapicnum, dapalnum); + + if (mid < 0 || models[mid]->mdnum < 2) + { + int vox = tiletovox[dapicnum]; + if (vox != -1 && voxmodels[vox] && voxmodels[vox]->model) + { + FHWModelRenderer mr(*screen->RenderState(), 0); + voxmodels[vox]->model->BuildVertexBuffer(&mr); + } + return; + } + + int const surfaces = (models[mid]->mdnum == 3) ? ((md3model_t *)models[mid])->head.numsurfs : 0; + + for (int i = 0; i <= surfaces; i++) + { + auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr); + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + if (tex) PrecacheTex(tex, palid); + } +} + +void PrecacheHardwareTextures(int nTile) +{ + // PRECACHE + // This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer. + doprecache(nTile, 0, 1); +} + + +TMap cachemap; + +void markTileForPrecache(int tilenum, int palnum) +{ + int i, j; + if ((picanm[tilenum].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK) + { + i = tilenum - picanm[tilenum].num; + j = tilenum; + } + else + { + i = tilenum; + j = tilenum + picanm[tilenum].num; + } + + for (; i <= j; i++) + { + int64_t val = i + (int64_t(palnum) << 32); + cachemap.Insert(val, true); + } +} + +void precacheMarkedTiles() +{ + decltype(cachemap)::Iterator it(cachemap); + decltype(cachemap)::Pair* pair; + while (it.NextPair(pair)) + { + int dapicnum = pair->Key & 0x7fffffff; + int dapalnum = pair->Key >> 32; + doprecache(dapicnum, dapalnum, 0); + } +} + diff --git a/source/core/precache.h b/source/core/precache.h new file mode 100644 index 000000000..30c6cea27 --- /dev/null +++ b/source/core/precache.h @@ -0,0 +1,5 @@ +#pragma once + +void PrecacheHardwareTextures(int nTile); +void markTileForPrecache(int tilenum, int palnum); +void precacheMarkedTiles(); diff --git a/source/games/blood/src/preload.cpp b/source/games/blood/src/preload.cpp index 5c998974e..4c0e0661d 100644 --- a/source/games/blood/src/preload.cpp +++ b/source/games/blood/src/preload.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "blood.h" #include "view.h" #include "g_input.h" +#include "precache.h" BEGIN_BLD_NS diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index c85cd6c2f..16e6e8c24 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "automap.h" #include "gamefuncs.h" #include "v_draw.h" +#include "precache.h" BEGIN_BLD_NS diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index e07263069..a3a67e6ea 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -37,6 +37,7 @@ source as it is released. #include "build.h" #include "names_d.h" #include "dukeactor.h" +#include "precache.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 196d6d052..5ff71c275 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -31,6 +31,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "names_r.h" #include "mapinfo.h" #include "dukeactor.h" +#include "precache.h" BEGIN_DUKE_NS diff --git a/source/games/exhumed/src/enginesubs.cpp b/source/games/exhumed/src/enginesubs.cpp index e896bd2be..6f64dcefb 100644 --- a/source/games/exhumed/src/enginesubs.cpp +++ b/source/games/exhumed/src/enginesubs.cpp @@ -17,6 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" #include "engine.h" +#include "precache.h" //#include //#include diff --git a/source/games/sw/src/cache.cpp b/source/games/sw/src/cache.cpp index 654025157..10cec872d 100644 --- a/source/games/sw/src/cache.cpp +++ b/source/games/sw/src/cache.cpp @@ -40,6 +40,7 @@ not load" error messages. #include "misc.h" #include "sounds.h" #include "network.h" +#include "precache.h" BEGIN_SW_NS diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index a8be0093c..1e2ee04ac 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -439,41 +439,3 @@ void videoShowFrame(int32_t w) twod->Clear(); } } - -TMap cachemap; - -void markTileForPrecache(int tilenum, int palnum) -{ - int i, j; - if ((picanm[tilenum].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK) - { - i = tilenum - picanm[tilenum].num; - j = tilenum; - } - else - { - i = tilenum; - j = tilenum + picanm[tilenum].num; - } - - for (; i <= j; i++) - { - int64_t val = i + (int64_t(palnum) << 32); - cachemap.Insert(val, true); - } -} - -void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); - -void precacheMarkedTiles() -{ - decltype(cachemap)::Iterator it(cachemap); - decltype(cachemap)::Pair* pair; - while (it.NextPair(pair)) - { - int dapicnum = pair->Key & 0x7fffffff; - int dapalnum = pair->Key >> 32; - polymost_precache(dapicnum, dapalnum, 0); - } -} - From 387c62d584c92c57e6e5dcdadc6b405159ddff42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 10:20:52 +0200 Subject: [PATCH 09/33] - rewrote SW's precaching code. * made it palette aware * use backend facilities to track precached data. * fixes bug in animation precaching loops - they only precached the base index over and over again. --- source/games/sw/src/cache.cpp | 828 ++++++++++++++++----------------- source/games/sw/src/game.cpp | 3 - source/games/sw/src/misc.h | 3 - source/games/sw/src/save.cpp | 1 - source/games/sw/src/sprite.cpp | 3 - 5 files changed, 392 insertions(+), 446 deletions(-) diff --git a/source/games/sw/src/cache.cpp b/source/games/sw/src/cache.cpp index 10cec872d..0f290f9f1 100644 --- a/source/games/sw/src/cache.cpp +++ b/source/games/sw/src/cache.cpp @@ -48,488 +48,444 @@ BEGIN_SW_NS // It will save out the tile and sound number every time one caches. // // sw -map $bullet -cacheprint > foofile -extern bool PreCaching; -void PreCacheTable(short table[], int num); -void PreCacheGhost(void); - -void -SetupPreCache(void) +void PreCacheRange(int start_pic, int end_pic, int pal = 0) { - if (PreCaching) - { - precache(); - - - // actors cache ranges are called from SpriteSetup - // only caches the actor if its on the level - - // weapons - PreCacheRange(2000, 2227); - PreCacheRange(4090, 4093); - // Explosions - PreCacheRange(3072, 3225); - // ninja player character - PreCacheRange(1024, 1175); - // console - PreCacheRange(2380, 2409); - PreCacheRange(3600, 3645); - PreCacheRange(2434, 2435); - // common - PreCacheRange(204, 208); - // message font - PreCacheRange(4608, 4701); - // gibs - PreCacheRange(1150,1568); - PreCacheRange(1685,1690); - PreCacheRange(900,944); - PreCacheRange(1670,1681); - // blood - PreCacheRange(1710,1715); - PreCacheRange(2410,2425); - PreCacheRange(389,389); // blood puddle by itself in art file - PreCacheRange(2500,2503); - // shrap - PreCacheRange(3840,3911); - PreCacheRange(3924,3947); - PreCacheRange(1397,1398); - // water *** animated tiles, can be deleted now *** - // PreCacheRange(780,794); - // switches - PreCacheRange(561,584); - PreCacheRange(551,552); - PreCacheRange(1846,1847); - PreCacheRange(1850,1859); - // bullet smoke - PreCacheRange(1748,1753); - // small blue font - PreCacheRange(2930,3023); - // gas can - PreCacheRange(3038,3042); - // lava *** animated tiles, can be deleted now *** - // PreCacheRange(175,182); - // gas clouds & teleport effect - PreCacheRange(3240,3277); - // nuke mushroom cloud - PreCacheRange(3280,3300); - // blood drops - PreCacheRange(1718,1721); - // smoke - PreCacheRange(3948,3968); - // footprints - PreCacheRange(2490,2492); - // player fists - PreCacheRange(4070,4077); - PreCacheRange(4050,4051); - PreCacheRange(4090,4093); - // fish actor - PreCacheRange(3760,3771); - PreCacheRange(3780,3795); - // coins - PreCacheRange(2531,2533); - // respawn markers & console keys - PreCacheRange(2440,2467); - // light/torch sprites - PreCacheRange(537,548); - PreCacheRange(521,528); - PreCacheRange(512,515); - PreCacheRange(396,399); - PreCacheRange(443,446); - // bubbles - PreCacheRange(716,720); - // bullet splashes - PreCacheRange(772,776); - } -} - -void PreCacheRipper(void) -{ - PreCacheRange(1580, 1644); -} - -void PreCacheRipper2(void) -{ - PreCacheRange(4320, 4427); -} - -void PreCacheCoolie(void) -{ - PreCacheGhost(); - PreCacheRange(1400, 1440); - PreCacheRange(4260, 4276); // coolie explode -} - -void PreCacheGhost(void) -{ - PreCacheRange(4277, 4312); -} - -void PreCacheSerpent(void) -{ - PreCacheRange(960, 1016); - PreCacheRange(1300, 1314); -} - -void PreCacheGuardian(void) -{ - PreCacheRange(1469,1497); -} - -void PreCacheNinja(void) -{ - PreCacheRange(4096, 4239); -} - -void PreCacheNinjaGirl(void) -{ - PreCacheRange(5162, 5260); -} - -void PreCacheSumo(void) -{ - PreCacheRange(4490, 4544); -} - -void PreCacheZilla(void) -{ - PreCacheRange(4490, 4544); -} - -void PreCacheEel(void) -{ - PreCacheRange(4430, 4479); -} - -void PreCacheToiletGirl(void) -{ - PreCacheRange(5023, 5027); -} - -void PreCacheWashGirl(void) -{ - PreCacheRange(5032, 5035); -} - -void PreCacheCarGirl(void) -{ - PreCacheRange(4594,4597); -} - -void PreCacheMechanicGirl(void) -{ - PreCacheRange(4590,4593); -} - -void PreCacheSailorGirl(void) -{ - PreCacheRange(4600,4602); -} - -void PreCachePruneGirl(void) -{ - PreCacheRange(4604,4604); -} - -void PreCacheTrash(void) -{ - PreCacheRange(2540, 2546); -} - -void PreCacheBunny(void) -{ - PreCacheRange(4550, 4584); -} - -void PreCacheSkel(void) -{ - PreCacheRange(1320, 1396); -} - -void PreCacheHornet(void) -{ - PreCacheRange(800, 811); -} - -void PreCacheSkull(void) -{ - PreCacheRange(820, 854); -} - -void PreCacheBetty(void) -{ - PreCacheRange(817, 819); -} - -void PreCachePachinko(void) -{ - PreCacheRange(618,623); - PreCacheRange(618,623); - PreCacheRange(4768,4790); - PreCacheRange(4792,4814); - PreCacheRange(4816,4838); - PreCacheRange(4840,4863); -} - -void -PreCacheTable(short table[], int num) -{ - short j; - - for (j = 0; j < num; j++) - { - SET(gotpic[table[j]>>3], 1<<(table[j]&7)); - } -} - -void -PreCacheRange(short start_pic, short end_pic) -{ - short j; - - for (j = start_pic; j <= end_pic; j++) - { - SET(gotpic[j>>3], 1<<(j&7)); - } + for (int j = start_pic; j <= end_pic; j++) + { + markTileForPrecache(j, pal); + } } void PreCacheOverride(void) { - int i; + int i; + StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); + while ((i = it.NextIndex()) >= 0) + { + int j = SPRITE_TAG2(i); + if(j >= 0 && j <= MAXTILES) + markTileForPrecache(j, 0); + } +} - StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); - while ((i = it.NextIndex()) >= 0) - { - ASSERT(SPRITE_TAG2(i) >= 0 && SPRITE_TAG2(i) <= MAXTILES); - SET_GOTPIC(SPRITE_TAG2(i)); - } +void precacheMap(void) +{ + int i; + int j; + SECTORp sectp; + WALLp wp; + SPRITEp sp; + + for (sectp = sector; sectp < §or[numsectors]; sectp++) + { + j = sectp->ceilingpicnum; + markTileForPrecache(j, sectp->ceilingpal); + + if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) + { + for (i = 1; i <= picanm[j].num; i++) + { + markTileForPrecache(j + i, sectp->ceilingpal); + } + } + + j = sectp->floorpicnum; + + markTileForPrecache(j, sectp->floorpal); + + if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) + { + for (i = 1; i <= picanm[j].num; i++) + { + markTileForPrecache(j + i, sectp->floorpal); + } + } + + } + + for (wp = wall; wp < &wall[numwalls]; wp++) + { + j = wp->picnum; + + markTileForPrecache(j, wp->pal); + + if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) + { + for (i = 1; i <= picanm[j].num; i++) + { + markTileForPrecache(j + i, wp->pal); + } + } + + if (wp->overpicnum > 0 && wp->overpicnum < MAXTILES) + { + j = wp->overpicnum; + markTileForPrecache(j, wp->pal); + + if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) + { + for (i = 1; i <= picanm[j].num; i++) + { + markTileForPrecache(j + i, wp->pal); + } + } + } + } +} + +void SetupPreCache(void) +{ + precacheMap(); + + + // actors cache ranges are called from SpriteSetup + // only caches the actor if its on the level + + // weapons + PreCacheRange(2000, 2227); + PreCacheRange(4090, 4093); + // Explosions + PreCacheRange(3072, 3225); + // ninja player character + PreCacheRange(1024, 1175); + // console + PreCacheRange(2380, 2409); + PreCacheRange(3600, 3645); + PreCacheRange(2434, 2435); + // common + PreCacheRange(204, 208); + // message font + PreCacheRange(4608, 4701); + // gibs + PreCacheRange(1150,1568); + PreCacheRange(1685,1690); + PreCacheRange(900,944); + PreCacheRange(1670,1681); + // blood + PreCacheRange(1710,1715); + PreCacheRange(2410,2425); + PreCacheRange(389,389); // blood puddle by itself in art file + PreCacheRange(2500,2503); + // shrap + PreCacheRange(3840,3911); + PreCacheRange(3924,3947); + PreCacheRange(1397,1398); + // water *** animated tiles, can be deleted now *** + // PreCacheRange(780,794); + // switches + PreCacheRange(561,584); + PreCacheRange(551,552); + PreCacheRange(1846,1847); + PreCacheRange(1850,1859); + // bullet smoke + PreCacheRange(1748,1753); + // gas can + PreCacheRange(3038,3042); + // lava *** animated tiles, can be deleted now *** + // PreCacheRange(175,182); + // gas clouds & teleport effect + PreCacheRange(3240,3277); + // nuke mushroom cloud + PreCacheRange(3280,3300); + // blood drops + PreCacheRange(1718,1721); + // smoke + PreCacheRange(3948,3968); + // footprints + PreCacheRange(2490,2492); + // player fists + PreCacheRange(4070,4077); + PreCacheRange(4050,4051); + PreCacheRange(4090,4093); + // fish actor + PreCacheRange(3760,3771); + PreCacheRange(3780,3795); + // coins + PreCacheRange(2531,2533); + // respawn markers & console keys + PreCacheRange(2440,2467); + // light/torch sprites + PreCacheRange(537,548); + PreCacheRange(521,528); + PreCacheRange(512,515); + PreCacheRange(396,399); + PreCacheRange(443,446); + // bubbles + PreCacheRange(716,720); + // bullet splashes + PreCacheRange(772,776); +} + +void PreCacheRipper(int pal) +{ + PreCacheRange(1580, 1644, pal); +} + +void PreCacheRipper2(int pal) +{ + PreCacheRange(4320, 4427, pal); +} + +void PreCacheGhost(int pal) +{ + PreCacheRange(4277, 4312, pal); +} + +void PreCacheCoolie(int pal) +{ + PreCacheGhost(pal); + PreCacheRange(1400, 1440, pal); + PreCacheRange(4260, 4276, pal); // coolie explode +} + +void PreCacheSerpent(int pal) +{ + PreCacheRange(960, 1016, pal); + PreCacheRange(1300, 1314, pal); +} + +void PreCacheGuardian(int pal) +{ + PreCacheRange(1469,1497, pal); +} + +void PreCacheNinja(int pal) +{ + PreCacheRange(4096, 4239, pal); +} + +void PreCacheNinjaGirl(int pal) +{ + PreCacheRange(5162, 5260, pal); +} + +void PreCacheSumo(int pal) +{ + PreCacheRange(4490, 4544, pal); +} + +void PreCacheZilla(int pal) +{ + PreCacheRange(4490, 4544, pal); +} + +void PreCacheEel(int pal) +{ + PreCacheRange(4430, 4479, pal); +} + +void PreCacheToiletGirl(int pal) +{ + PreCacheRange(5023, 5027, pal); +} + +void PreCacheWashGirl(int pal) +{ + PreCacheRange(5032, 5035, pal); +} + +void PreCacheCarGirl(int pal) +{ + PreCacheRange(4594,4597, pal); +} + +void PreCacheMechanicGirl(int pal) +{ + PreCacheRange(4590,4593, pal); +} + +void PreCacheSailorGirl(int pal) +{ + PreCacheRange(4600,4602, pal); +} + +void PreCachePruneGirl(int pal) +{ + PreCacheRange(4604,4604, pal); +} + +void PreCacheTrash(int pal) +{ + PreCacheRange(2540, 2546, pal); +} + +void PreCacheBunny(int pal) +{ + PreCacheRange(4550, 4584, pal); +} + +void PreCacheSkel(int pal) +{ + PreCacheRange(1320, 1396, pal); +} + +void PreCacheHornet(int pal) +{ + PreCacheRange(800, 811, pal); +} + +void PreCacheSkull(int pal) +{ + PreCacheRange(820, 854, pal); +} + +void PreCacheBetty(int pal) +{ + PreCacheRange(817, 819, pal); +} + +void PreCachePachinko(int pal) +{ + PreCacheRange(618,623, pal); + PreCacheRange(618,623, pal); + PreCacheRange(4768,4790, pal); + PreCacheRange(4792,4814, pal); + PreCacheRange(4816,4838, pal); + PreCacheRange(4840,4863, pal); } void PreCacheActor(void) { - int i; - short pic; + int i; + int pic; - for (i=0; i < MAXSPRITES; i++) - { - if (sprite[i].statnum >= MAXSTATUS) - continue; + for (i=0; i < MAXSPRITES; i++) + { + if (sprite[i].statnum >= MAXSTATUS) + continue; - if (User[i]) - pic = User[i]->ID; - else - pic = sprite[i].picnum; + if (User[i]) + pic = User[i]->ID; + else + pic = sprite[i].picnum; - switch (pic) - { - case COOLIE_RUN_R0: - PreCacheCoolie(); - break; + switch (pic) + { + case COOLIE_RUN_R0: + PreCacheCoolie(sprite[i].pal); + break; - case NINJA_RUN_R0: - case NINJA_CRAWL_R0: - PreCacheNinja(); - break; + case NINJA_RUN_R0: + case NINJA_CRAWL_R0: + PreCacheNinja(sprite[i].pal); + break; - case GORO_RUN_R0: - PreCacheGuardian(); - break; + case GORO_RUN_R0: + PreCacheGuardian(sprite[i].pal); + break; - case 1441: - case COOLG_RUN_R0: - PreCacheGhost(); - break; + case 1441: + case COOLG_RUN_R0: + PreCacheGhost(sprite[i].pal); + break; - case EEL_RUN_R0: - PreCacheEel(); - break; + case EEL_RUN_R0: + PreCacheEel(sprite[i].pal); + break; - case SUMO_RUN_R0: - PreCacheZilla(); - break; + case SUMO_RUN_R0: + PreCacheZilla(sprite[i].pal); + break; - case ZILLA_RUN_R0: - PreCacheSumo(); - break; + case ZILLA_RUN_R0: + PreCacheSumo(sprite[i].pal); + break; - case TOILETGIRL_R0: - PreCacheToiletGirl(); - break; + case TOILETGIRL_R0: + PreCacheToiletGirl(sprite[i].pal); + break; - case WASHGIRL_R0: - PreCacheWashGirl(); - break; + case WASHGIRL_R0: + PreCacheWashGirl(sprite[i].pal); + break; - case CARGIRL_R0: - PreCacheCarGirl(); - break; + case CARGIRL_R0: + PreCacheCarGirl(sprite[i].pal); + break; - case MECHANICGIRL_R0: - PreCacheMechanicGirl(); - break; + case MECHANICGIRL_R0: + PreCacheMechanicGirl(sprite[i].pal); + break; - case SAILORGIRL_R0: - PreCacheSailorGirl(); - break; + case SAILORGIRL_R0: + PreCacheSailorGirl(sprite[i].pal); + break; - case PRUNEGIRL_R0: - PreCachePruneGirl(); - break; + case PRUNEGIRL_R0: + PreCachePruneGirl(sprite[i].pal); + break; - case TRASHCAN: - PreCacheTrash(); - break; + case TRASHCAN: + PreCacheTrash(sprite[i].pal); + break; - case BUNNY_RUN_R0: - PreCacheBunny(); - break; + case BUNNY_RUN_R0: + PreCacheBunny(sprite[i].pal); + break; - case RIPPER_RUN_R0: - PreCacheRipper(); - break; + case RIPPER_RUN_R0: + PreCacheRipper(sprite[i].pal); + break; - case RIPPER2_RUN_R0: - PreCacheRipper2(); - break; + case RIPPER2_RUN_R0: + PreCacheRipper2(sprite[i].pal); + break; - case SERP_RUN_R0: - PreCacheSerpent(); - break; + case SERP_RUN_R0: + PreCacheSerpent(sprite[i].pal); + break; - case LAVA_RUN_R0: - break; + case LAVA_RUN_R0: + break; - case SKEL_RUN_R0: - PreCacheSkel(); - break; + case SKEL_RUN_R0: + PreCacheSkel(sprite[i].pal); + break; - case HORNET_RUN_R0: - PreCacheHornet(); - break; + case HORNET_RUN_R0: + PreCacheHornet(sprite[i].pal); + break; - case SKULL_R0: - PreCacheSkull(); - break; + case SKULL_R0: + PreCacheSkull(sprite[i].pal); + break; - case BETTY_R0: - PreCacheBetty(); - break; + case BETTY_R0: + PreCacheBetty(sprite[i].pal); + break; - case GIRLNINJA_RUN_R0: - PreCacheNinjaGirl(); - break; + case GIRLNINJA_RUN_R0: + PreCacheNinjaGirl(sprite[i].pal); + break; - case 623: // Pachinko win light - case PACHINKO1: - case PACHINKO2: - case PACHINKO3: - case PACHINKO4: - PreCachePachinko(); - break; - } - } + case 623: // Pachinko win light + case PACHINKO1: + case PACHINKO2: + case PACHINKO3: + case PACHINKO4: + PreCachePachinko(sprite[i].pal); + break; + + default: + markTileForPrecache(pic, sprite[i].pal); + } + } } void DoTheCache(void) { - int i, cnt=0; - - PreCacheActor(); - PreCacheOverride(); - - for (i = 0; i < MAXTILES; i++) - { - if ((TEST(gotpic[i>>3], 1<<(i&7))) && (!tilePtr(i))) - { - // Without palettes this is rather useless... - if (r_precache) PrecacheHardwareTextures(i); - cnt++; - } - } - - memset(gotpic,0,sizeof(gotpic)); + if (r_precache) + { + SetupPreCache(); + PreCacheActor(); + PreCacheOverride(); + precacheMarkedTiles(); + } } -void -precache(void) -{ - int i; - short j; - SECTORp sectp; - WALLp wp; - SPRITEp sp; - - memset(gotpic,0,sizeof(gotpic)); - - for (sectp = sector; sectp < §or[numsectors]; sectp++) - { - j = sectp->ceilingpicnum; - - SET(gotpic[j>>3], 1<<(j&7)); - - if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) - { - for (i = 1; i <= picanm[j].num; i++) - { - SET(gotpic[(j+i)>>3], 1<<((j+i)&7)); - } - } - - j = sectp->floorpicnum; - - SET(gotpic[j>>3], 1<<(j&7)); - - if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) - { - for (i = 1; i <= picanm[j].num; i++) - { - SET(gotpic[(j+i)>>3], 1<<((j+i)&7)); - } - } - - } - - for (wp = wall; wp < &wall[numwalls]; wp++) - { - j = wp->picnum; - - SET(gotpic[j>>3], 1<<(j&7)); - - if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) - { - for (i = 1; i <= picanm[j].num; i++) - { - SET(gotpic[(j+i)>>3], 1<<((j+i)&7)); - } - } - - if (wp->overpicnum > 0 && wp->overpicnum < MAXTILES) - { - j = wp->overpicnum; - SET(gotpic[j>>3], 1<<(j&7)); - - if (TEST(picanm[j].sf, PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT) - { - for (i = 1; i <= picanm[j].num; i++) - { - SET(gotpic[(j+i)>>3], 1<<((j+i)&7)); - } - } - - } - } - - for (sp = sprite; sp < &sprite[MAXSPRITES]; sp++) - { - if (sp->statnum < MAXSTATUS) - { - j = sp->picnum; - - SET(gotpic[j>>3], 1<<(j&7)); - } - } -} END_SW_NS diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 50583459a..064cfc44f 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -106,7 +106,6 @@ bool NewGame = false; bool FinishedLevel = false; short screenpeek = 0; -bool PreCaching = true; int GodMode = false; short Skill = 2; short TotalKillable; @@ -363,8 +362,6 @@ void InitLevel(MapRecord *maprec) STAT_NewLevel(currentLevel->fileName); Player[0].angle.ang = buildang(ang); - SetupPreCache(); - if (sector[0].extra != -1) { NormalVisibility = g_visibility = sector[0].extra; diff --git a/source/games/sw/src/misc.h b/source/games/sw/src/misc.h index 6a8052575..00d518286 100644 --- a/source/games/sw/src/misc.h +++ b/source/games/sw/src/misc.h @@ -11,10 +11,7 @@ enum CACHE_SOUND_PLAY =1 }; -void SetupPreCache(void); -void PreCacheRange(short start_pic, short end_pic); void DoTheCache(void); -void precache(void); void InitCheats(); diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 39f4d62e4..6feeff775 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -990,7 +990,6 @@ bool GameInterface::LoadGame() } #endif - SetupPreCache(); DoTheCache(); // this is ok - just duplicating sector list with pointers diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 4a6002369..3eb4309e3 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1187,9 +1187,6 @@ ActorSpawn(SPRITEp sp) case 1441: case COOLG_RUN_R0: { - - //PreCacheGhost(); - if (!ActorTestSpawn(sp)) { KillSprite(SpriteNum); From e4cf768fa8d3bd158e5f3268d1c856a67f46ed8f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 10:50:04 +0200 Subject: [PATCH 10/33] - call StartPrecaching to keep Vulkan happy. --- source/core/precache.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/core/precache.cpp b/source/core/precache.cpp index 3341630e5..4423f51ab 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -121,6 +121,7 @@ void markTileForPrecache(int tilenum, int palnum) void precacheMarkedTiles() { + screen->StartPrecaching(); decltype(cachemap)::Iterator it(cachemap); decltype(cachemap)::Pair* pair; while (it.NextPair(pair)) From d663d8459687f99c4c48ef46a13180248f5749f1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 10:54:10 +0200 Subject: [PATCH 11/33] - changed precaching setup for Exhumed. This looks overly simplistic - I doubt it's enough to catch everything. --- source/games/exhumed/src/enginesubs.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/games/exhumed/src/enginesubs.cpp b/source/games/exhumed/src/enginesubs.cpp index 6f64dcefb..7223f822e 100644 --- a/source/games/exhumed/src/enginesubs.cpp +++ b/source/games/exhumed/src/enginesubs.cpp @@ -34,11 +34,6 @@ void resettiming() lastTic = -1; } -void doTileLoad(int i) -{ - if (r_precache) PrecacheHardwareTextures(i); -} - void precache() { int i; @@ -46,15 +41,15 @@ void precache() for (i = 0; i < numsectors; i++) { short j = sector[i].ceilingpicnum; - doTileLoad(j); + markTileForPrecache(j, sector[i].ceilingpal); j = sector[i].floorpicnum; - doTileLoad(j); + markTileForPrecache(j, sector[i].floorpal); } for (i = 0; i < numwalls; i++) { short j = wall[i].picnum; - doTileLoad(j); + markTileForPrecache(j, wall[i].pal); } for (i = 0; i < kMaxSprites; i++) @@ -62,8 +57,9 @@ void precache() if (sprite[i].statnum < kMaxStatus) { short j = sprite[i].picnum; - doTileLoad(j); + markTileForPrecache(j, sprite[i].pal); } } + precacheMarkedTiles(); } END_PS_NS From 63429268710e865e8cae13e71df20cf3d8a8b0d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 12:10:52 +0200 Subject: [PATCH 12/33] - disabled the QAV preload calls in Blood. Aside from not having been functional, this is ultimately more harmful than useful as it forces loading of a large number of textures at the same time during gameplay instead of spreading them out. --- source/games/blood/src/d_menu.cpp | 2 +- source/games/blood/src/misc.h | 1 - source/games/blood/src/nnexts.cpp | 2 +- source/games/blood/src/player.cpp | 2 +- source/games/blood/src/preload.cpp | 46 ------------------------------ source/games/blood/src/qav.cpp | 12 -------- source/games/blood/src/qav.h | 1 - source/games/blood/src/seq.cpp | 10 ------- source/games/blood/src/seq.h | 1 - source/games/blood/src/view.cpp | 5 ---- source/games/blood/src/weapon.cpp | 2 +- 11 files changed, 4 insertions(+), 80 deletions(-) diff --git a/source/games/blood/src/d_menu.cpp b/source/games/blood/src/d_menu.cpp index 39c305268..8db9fc494 100644 --- a/source/games/blood/src/d_menu.cpp +++ b/source/games/blood/src/d_menu.cpp @@ -69,7 +69,7 @@ CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widesc data->nSprite = -1; data->x = m_nX; data->y = m_nY; - data->Preload(); + //data->Preload(); duration = data->duration; lastTick = I_GetBuildTime(); } diff --git a/source/games/blood/src/misc.h b/source/games/blood/src/misc.h index 0e5b404e7..09ce772d8 100644 --- a/source/games/blood/src/misc.h +++ b/source/games/blood/src/misc.h @@ -124,7 +124,6 @@ extern int nPrecacheCount; int tileInit(char a1, const char *a2); void tileProcessGLVoxels(void); -void tilePreloadTile(int nTile); void tilePrecacheTile(int nTile, int nType, HitList& hits); char tileGetSurfType(int hit); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index f90fb1199..a708623e0 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1326,7 +1326,7 @@ void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, bool force) { pCtrl->qavScene.qavResrc = pQav; pCtrl->qavScene.dummy = -1; - pCtrl->qavScene.qavResrc->Preload(); + //pCtrl->qavScene.qavResrc->Preload(); pPlayer->sceneQav = pXSource->data2; pPlayer->weaponTimer = pCtrl->qavScene.qavResrc->duration; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 28ae4aec8..3fd2f6aae 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -2319,7 +2319,7 @@ void SerializePlayers(FSerializer& arc) if (pQav) { gPlayerCtrl[i].qavScene.qavResrc = pQav; - gPlayerCtrl[i].qavScene.qavResrc->Preload(); + //gPlayerCtrl[i].qavScene.qavResrc->Preload(); } else { diff --git a/source/games/blood/src/preload.cpp b/source/games/blood/src/preload.cpp index 4c0e0661d..f64f5521f 100644 --- a/source/games/blood/src/preload.cpp +++ b/source/games/blood/src/preload.cpp @@ -36,52 +36,6 @@ void fxPrecache(HitList &hits); void gibPrecache(HitList &hits); -void tilePreloadTile(int nTile) -{ - if (!r_precache) return; - int n = 1; - switch (picanm[nTile].extra & 7) - { - case 0: - n = 1; - break; - case 1: - n = 5; - break; - case 2: - n = 8; - break; - case 3: - n = 2; - break; - case 6: - case 7: - if (voxelIndex[nTile] < 0 || voxelIndex[nTile] >= kMaxVoxels) - { - voxelIndex[nTile] = -1; - picanm[nTile].extra &= ~7; - } - break; - } - - while (n--) - { - if (picanm[nTile].sf & PICANM_ANIMTYPE_MASK) - { - for (int frame = picanm[nTile].num; frame >= 0; frame--) - { - if ((picanm[nTile].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK) - PrecacheHardwareTextures(nTile - frame); - else - PrecacheHardwareTextures(nTile + frame); - } - } - else - PrecacheHardwareTextures(nTile); - nTile += 1 + picanm[nTile].num; - } -} - void tilePrecacheTile(int nTile, int nType, HitList &hits) { int n = 1; diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index a17d24df6..fab15a288 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -146,18 +146,6 @@ void QAV::Play(int start, int end, int nCallback, void *pData) } } -void QAV::Preload(void) -{ - for (int i = 0; i < nFrames; i++) - { - for (int j = 0; j < 8; j++) - { - if (frames[i].tiles[j].picnum >= 0) - tilePreloadTile(frames[i].tiles[j].picnum); - } - } -} - void QAV::Precache(HitList &hits) { for (int i = 0; i < nFrames; i++) diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index d858a042b..07062c67e 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -82,7 +82,6 @@ struct QAV void Draw(int ticks, int stat, int shade, int palnum, bool in3dscene); void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool in3dscene); void Play(int, int, int, void *); - void Preload(void); void Precache(HitList &hits); }; diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index ddbb583a2..7ea06fbdf 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -102,16 +102,6 @@ static void (*seqClientCallback[])(int, DBloodActor*) = { // //--------------------------------------------------------------------------- -void Seq::Preload(void) -{ - if (memcmp(signature, "SEQ\x1a", 4) != 0) - I_Error("Invalid sequence"); - if ((version & 0xff00) != 0x300) - I_Error("Obsolete sequence version"); - for (int i = 0; i < nFrames; i++) - tilePreloadTile(seqGetTile(&frames[i])); -} - void Seq::Precache(HitList& hits) { if (memcmp(signature, "SEQ\x1a", 4) != 0) diff --git a/source/games/blood/src/seq.h b/source/games/blood/src/seq.h index 538f460e9..481431c11 100644 --- a/source/games/blood/src/seq.h +++ b/source/games/blood/src/seq.h @@ -59,7 +59,6 @@ struct Seq { short soundId; int flags; SEQFRAME frames[1]; - void Preload(void); void Precache(HitList&); bool isLooping() diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 16e6e8c24..28cc22f62 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -132,10 +132,6 @@ void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int } -void InitStatusBar(void) -{ - if (r_precache) PrecacheHardwareTextures(2200); -} GameStats GameInterface::getStats() { return { gKillMgr.Kills, gKillMgr.TotalKills, gSecretMgr.Founds, gSecretMgr.Total, gFrameCount / kTicsPerSec, gPlayer[myconnectindex].fragCount }; @@ -168,7 +164,6 @@ extern int dword_172CE0[16][3]; void viewInit(void) { Printf("Initializing status bar\n"); - InitStatusBar(); FontSet(0, 4096, 0); FontSet(1, 4192, 1); FontSet(2, 4288, 1); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 130074dd5..b720fbb80 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -302,7 +302,7 @@ static void StartQAV(PLAYER *pPlayer, int nWeaponQAV, int callback, bool looped pPlayer->weaponTimer = weaponQAV[nWeaponQAV]->duration; pPlayer->qavCallback = callback; pPlayer->qavLoop = looped; - weaponQAV[nWeaponQAV]->Preload(); + //weaponQAV[nWeaponQAV]->Preload(); WeaponPlay(pPlayer); pPlayer->weaponTimer -= 4; } From 32250f704fc956b9ae235d6d96fd87079686590f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 12:42:59 +0200 Subject: [PATCH 13/33] - mograted Blood's precaching to the backend's implementation. --- source/games/blood/src/fx.cpp | 6 +- source/games/blood/src/gib.cpp | 4 +- source/games/blood/src/misc.h | 6 +- source/games/blood/src/preload.cpp | 256 +++++++++++++---------------- source/games/blood/src/qav.cpp | 4 +- source/games/blood/src/qav.h | 2 +- source/games/blood/src/seq.cpp | 8 +- source/games/blood/src/seq.h | 4 +- source/games/blood/src/weapon.cpp | 4 +- 9 files changed, 134 insertions(+), 160 deletions(-) diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index b78946a40..9ee8ec4fe 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -345,13 +345,13 @@ void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4) } } -void fxPrecache(HitList &hits) +void fxPrecache() { for (int i = 0; i < kFXMax; i++) { - tilePrecacheTile(gFXData[i].at12, 0, hits); + tilePrecacheTile(gFXData[i].at12, 0, 0); if (gFXData[i].at2) - seqPrecacheId(gFXData[i].at2, hits); + seqPrecacheId(gFXData[i].at2, 0); } } diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index 449c6da8b..4e4f68264 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -501,7 +501,7 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel) } } -void gibPrecache(HitList &hits) +void gibPrecache() { for (int i = 0; i < kGibMax; i++) { @@ -511,7 +511,7 @@ void gibPrecache(HitList &hits) for (int j = 0; j < gibList[i].atc; j++) { if (pThing[j].Kills >= 0) - tilePrecacheTile(pThing[j].Kills, -1, hits); + tilePrecacheTile(pThing[j].Kills, -1, 0); } } } diff --git a/source/games/blood/src/misc.h b/source/games/blood/src/misc.h index 09ce772d8..0a2ad62fa 100644 --- a/source/games/blood/src/misc.h +++ b/source/games/blood/src/misc.h @@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -using HitList = FixedBitArray; - void playlogos(); unsigned int qrand(void); int wrand(void); @@ -56,7 +54,7 @@ char WeaponUpgrade(PLAYER *pPlayer, char newWeapon); void WeaponProcess(PLAYER *pPlayer); void WeaponUpdateState(PLAYER* pPlayer); void teslaHit(spritetype *pMissile, int a2); -void WeaponPrecache(HitList &hits); +void WeaponPrecache(); struct ZONE { int x, y, z; @@ -124,7 +122,7 @@ extern int nPrecacheCount; int tileInit(char a1, const char *a2); void tileProcessGLVoxels(void); -void tilePrecacheTile(int nTile, int nType, HitList& hits); +void tilePrecacheTile(int nTile, int nType, int palette); char tileGetSurfType(int hit); diff --git a/source/games/blood/src/preload.cpp b/source/games/blood/src/preload.cpp index f64f5521f..06e6703d6 100644 --- a/source/games/blood/src/preload.cpp +++ b/source/games/blood/src/preload.cpp @@ -32,11 +32,11 @@ BEGIN_BLD_NS int nPrecacheCount; -void fxPrecache(HitList &hits); -void gibPrecache(HitList &hits); +void fxPrecache(); +void gibPrecache(); -void tilePrecacheTile(int nTile, int nType, HitList &hits) +void tilePrecacheTile(int nTile, int nType, int palette) { int n = 1; switch (picanm[nTile].extra & 7) @@ -65,20 +65,13 @@ void tilePrecacheTile(int nTile, int nType, HitList &hits) tile = nTile - frame; else tile = nTile + frame; - if (!hits[tile]) - { - nPrecacheCount++; - hits.Set(tile); - } + + markTileForPrecache(tile, palette); } } else { - if (!hits[nTile]) - { - nPrecacheCount++; - hits.Set(nTile); - } + markTileForPrecache(nTile, palette); } nTile += 1 + picanm[nTile].num; } @@ -87,34 +80,34 @@ void tilePrecacheTile(int nTile, int nType, HitList &hits) // To do: This needs to handle the sprite palettes as well to properly precache the needed content. -void viewPrecacheTiles(HitList &hits) +void viewPrecacheTiles() { - tilePrecacheTile(2173, 0, hits); - tilePrecacheTile(2200, 0, hits); - tilePrecacheTile(2201, 0, hits); - tilePrecacheTile(2202, 0, hits); - tilePrecacheTile(2207, 0, hits); - tilePrecacheTile(2208, 0, hits); - tilePrecacheTile(2209, 0, hits); - tilePrecacheTile(2229, 0, hits); - tilePrecacheTile(2260, 0, hits); - tilePrecacheTile(2559, 0, hits); - tilePrecacheTile(2169, 0, hits); - tilePrecacheTile(2578, 0, hits); - tilePrecacheTile(2586, 0, hits); - tilePrecacheTile(2602, 0, hits); + tilePrecacheTile(2173, 0, 0); + tilePrecacheTile(2200, 0, 0); + tilePrecacheTile(2201, 0, 0); + tilePrecacheTile(2202, 0, 0); + tilePrecacheTile(2207, 0, 0); + tilePrecacheTile(2208, 0, 0); + tilePrecacheTile(2209, 0, 0); + tilePrecacheTile(2229, 0, 0); + tilePrecacheTile(2260, 0, 0); + tilePrecacheTile(2559, 0, 0); + tilePrecacheTile(2169, 0, 0); + tilePrecacheTile(2578, 0, 0); + tilePrecacheTile(2586, 0, 0); + tilePrecacheTile(2602, 0, 0); for (int i = 0; i < 10; i++) { - tilePrecacheTile(2190 + i, 0, hits); - tilePrecacheTile(2230 + i, 0, hits); - tilePrecacheTile(2240 + i, 0, hits); - tilePrecacheTile(2250 + i, 0, hits); - tilePrecacheTile(kSBarNumberHealth + i, 0, hits); - tilePrecacheTile(kSBarNumberAmmo + i, 0, hits); - tilePrecacheTile(kSBarNumberInv + i, 0, hits); - tilePrecacheTile(kSBarNumberArmor1 + i, 0, hits); - tilePrecacheTile(kSBarNumberArmor2 + i, 0, hits); - tilePrecacheTile(kSBarNumberArmor3 + i, 0, hits); + tilePrecacheTile(2190 + i, 0, 0); + tilePrecacheTile(2230 + i, 0, 0); + tilePrecacheTile(2240 + i, 0, 0); + tilePrecacheTile(2250 + i, 0, 0); + tilePrecacheTile(kSBarNumberHealth + i, 0, 0); + tilePrecacheTile(kSBarNumberAmmo + i, 0, 0); + tilePrecacheTile(kSBarNumberInv + i, 0, 0); + tilePrecacheTile(kSBarNumberArmor1 + i, 0, 0); + tilePrecacheTile(kSBarNumberArmor2 + i, 0, 0); + tilePrecacheTile(kSBarNumberArmor3 + i, 0, 0); } /* for (int i = 0; i < 5; i++) @@ -125,54 +118,55 @@ void viewPrecacheTiles(HitList &hits) */ for (int i = 0; i < 6; i++) { - tilePrecacheTile(2220 + i, 0, hits); - tilePrecacheTile(2552 + i, 0, hits); + tilePrecacheTile(2220 + i, 0, 0); + tilePrecacheTile(2552 + i, 0, 0); } } -void PrecacheDude(spritetype *pSprite, HitList &hits) +void PrecacheDude(spritetype *pSprite) { + int palette = pSprite->pal; DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - seqPrecacheId(pDudeInfo->seqStartID , hits); - seqPrecacheId(pDudeInfo->seqStartID+5, hits); - seqPrecacheId(pDudeInfo->seqStartID+1, hits); - seqPrecacheId(pDudeInfo->seqStartID+2, hits); + seqPrecacheId(pDudeInfo->seqStartID , palette); + seqPrecacheId(pDudeInfo->seqStartID+5, palette); + seqPrecacheId(pDudeInfo->seqStartID+1, palette); + seqPrecacheId(pDudeInfo->seqStartID+2, palette); switch (pSprite->type) { case kDudeCultistTommy: case kDudeCultistShotgun: case kDudeCultistTesla: case kDudeCultistTNT: - seqPrecacheId(pDudeInfo->seqStartID+6 , hits); - seqPrecacheId(pDudeInfo->seqStartID+7 , hits); - seqPrecacheId(pDudeInfo->seqStartID+8 , hits); - seqPrecacheId(pDudeInfo->seqStartID+9 , hits); - seqPrecacheId(pDudeInfo->seqStartID+13, hits); - seqPrecacheId(pDudeInfo->seqStartID+14, hits); - seqPrecacheId(pDudeInfo->seqStartID+15, hits); + seqPrecacheId(pDudeInfo->seqStartID+6 , palette); + seqPrecacheId(pDudeInfo->seqStartID+7 , palette); + seqPrecacheId(pDudeInfo->seqStartID+8 , palette); + seqPrecacheId(pDudeInfo->seqStartID+9 , palette); + seqPrecacheId(pDudeInfo->seqStartID+13, palette); + seqPrecacheId(pDudeInfo->seqStartID+14, palette); + seqPrecacheId(pDudeInfo->seqStartID+15, palette); break; case kDudeZombieButcher: case kDudeGillBeast: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); - seqPrecacheId(pDudeInfo->seqStartID+8, hits); - seqPrecacheId(pDudeInfo->seqStartID+9, hits); - seqPrecacheId(pDudeInfo->seqStartID+10, hits); - seqPrecacheId(pDudeInfo->seqStartID+11, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); + seqPrecacheId(pDudeInfo->seqStartID+8, palette); + seqPrecacheId(pDudeInfo->seqStartID+9, palette); + seqPrecacheId(pDudeInfo->seqStartID+10, palette); + seqPrecacheId(pDudeInfo->seqStartID+11, palette); break; case kDudeGargoyleStatueFlesh: case kDudeGargoyleStatueStone: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+6, hits); //??? + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); //??? fallthrough__; case kDudeGargoyleFlesh: case kDudeGargoyleStone: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); - seqPrecacheId(pDudeInfo->seqStartID+8, hits); - seqPrecacheId(pDudeInfo->seqStartID+9, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); + seqPrecacheId(pDudeInfo->seqStartID+8, palette); + seqPrecacheId(pDudeInfo->seqStartID+9, palette); break; case kDudePhantasm: case kDudeHellHound: @@ -181,88 +175,89 @@ void PrecacheDude(spritetype *pSprite, HitList &hits) case kDudeSpiderBlack: case kDudeSpiderMother: case kDudeTchernobog: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); - seqPrecacheId(pDudeInfo->seqStartID+8, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); + seqPrecacheId(pDudeInfo->seqStartID+8, palette); break; case kDudeCerberusTwoHead: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); fallthrough__; case kDudeHand: case kDudeBoneEel: case kDudeBat: case kDudeRat: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); break; case kDudeCultistBeast: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); break; case kDudeZombieAxeBuried: - seqPrecacheId(pDudeInfo->seqStartID+12, hits); - seqPrecacheId(pDudeInfo->seqStartID+9, hits); + seqPrecacheId(pDudeInfo->seqStartID+12, palette); + seqPrecacheId(pDudeInfo->seqStartID+9, palette); fallthrough__; case kDudeZombieAxeLaying: - seqPrecacheId(pDudeInfo->seqStartID+10, hits); + seqPrecacheId(pDudeInfo->seqStartID+10, palette); fallthrough__; case kDudeZombieAxeNormal: - seqPrecacheId(pDudeInfo->seqStartID+6, hits); - seqPrecacheId(pDudeInfo->seqStartID+7, hits); - seqPrecacheId(pDudeInfo->seqStartID+8, hits); - seqPrecacheId(pDudeInfo->seqStartID+11, hits); - seqPrecacheId(pDudeInfo->seqStartID+13, hits); - seqPrecacheId(pDudeInfo->seqStartID+14, hits); + seqPrecacheId(pDudeInfo->seqStartID+6, palette); + seqPrecacheId(pDudeInfo->seqStartID+7, palette); + seqPrecacheId(pDudeInfo->seqStartID+8, palette); + seqPrecacheId(pDudeInfo->seqStartID+11, palette); + seqPrecacheId(pDudeInfo->seqStartID+13, palette); + seqPrecacheId(pDudeInfo->seqStartID+14, palette); break; } } -void PrecacheThing(spritetype *pSprite, HitList &hits) { +void PrecacheThing(spritetype *pSprite) +{ + int palette = pSprite->pal; switch (pSprite->type) { case kThingGlassWindow: // worthless... case kThingFluorescent: - seqPrecacheId(12, hits); + seqPrecacheId(12, palette); break; case kThingSpiderWeb: - seqPrecacheId(15, hits); + seqPrecacheId(15, palette); break; case kThingMetalGrate: - seqPrecacheId(21, hits); + seqPrecacheId(21, palette); break; case kThingFlammableTree: - seqPrecacheId(25, hits); - seqPrecacheId(26, hits); + seqPrecacheId(25, palette); + seqPrecacheId(26, palette); break; case kTrapMachinegun: - seqPrecacheId(38, hits); - seqPrecacheId(40, hits); - seqPrecacheId(28, hits); + seqPrecacheId(38, palette); + seqPrecacheId(40, palette); + seqPrecacheId(28, palette); break; case kThingObjectGib: //case kThingObjectExplode: weird that only gib object is precached and this one is not break; } - tilePrecacheTile(pSprite->picnum, -1, hits); + tilePrecacheTile(pSprite->picnum, -1, palette); } -void PreloadTiles(HitList & hits) +void PreloadCache() { - nPrecacheCount = 0; + if (!r_precache) return; int skyTile = -1; - hits.Zero(); // Fonts for (int i = 0; i < numsectors; i++) { - tilePrecacheTile(sector[i].floorpicnum, 0, hits); - tilePrecacheTile(sector[i].ceilingpicnum, 0, hits); + tilePrecacheTile(sector[i].floorpicnum, 0, sector[i].floorpal); + tilePrecacheTile(sector[i].ceilingpicnum, 0, sector[i].ceilingpal); if ((sector[i].ceilingstat&1) != 0 && skyTile == -1) skyTile = sector[i].ceilingpicnum; } for (int i = 0; i < numwalls; i++) { - tilePrecacheTile(wall[i].picnum, 0, hits); + tilePrecacheTile(wall[i].picnum, 0, wall[i].pal); if (wall[i].overpicnum >= 0) - tilePrecacheTile(wall[i].overpicnum, 0, hits); + tilePrecacheTile(wall[i].overpicnum, 0, wall[i].pal); } for (int i = 0; i < kMaxSprites; i++) { @@ -272,13 +267,13 @@ void PreloadTiles(HitList & hits) switch (pSprite->statnum) { case kStatDude: - PrecacheDude(pSprite, hits); + PrecacheDude(pSprite); break; case kStatThing: - PrecacheThing(pSprite, hits); + PrecacheThing(pSprite); break; default: - tilePrecacheTile(pSprite->picnum, -1, hits); + tilePrecacheTile(pSprite->picnum, -1, pSprite->pal); break; } } @@ -287,57 +282,38 @@ void PreloadTiles(HitList & hits) // Precache common SEQs for (int i = 0; i < 100; i++) { - seqPrecacheId(i, hits); + seqPrecacheId(i, 0); } - tilePrecacheTile(1147, -1, hits); // water drip - tilePrecacheTile(1160, -1, hits); // blood drip + tilePrecacheTile(1147, -1, 0); // water drip + tilePrecacheTile(1160, -1, 0); // blood drip // Player SEQs - seqPrecacheId(dudeInfo[31].seqStartID+6, hits); - seqPrecacheId(dudeInfo[31].seqStartID+7, hits); - seqPrecacheId(dudeInfo[31].seqStartID+8, hits); - seqPrecacheId(dudeInfo[31].seqStartID+9, hits); - seqPrecacheId(dudeInfo[31].seqStartID+10, hits); - seqPrecacheId(dudeInfo[31].seqStartID+14, hits); - seqPrecacheId(dudeInfo[31].seqStartID+15, hits); - seqPrecacheId(dudeInfo[31].seqStartID+12, hits); - seqPrecacheId(dudeInfo[31].seqStartID+16, hits); - seqPrecacheId(dudeInfo[31].seqStartID+17, hits); - seqPrecacheId(dudeInfo[31].seqStartID+18, hits); + seqPrecacheId(dudeInfo[31].seqStartID+6, 0); + seqPrecacheId(dudeInfo[31].seqStartID+7, 0); + seqPrecacheId(dudeInfo[31].seqStartID+8, 0); + seqPrecacheId(dudeInfo[31].seqStartID+9, 0); + seqPrecacheId(dudeInfo[31].seqStartID+10, 0); + seqPrecacheId(dudeInfo[31].seqStartID+14, 0); + seqPrecacheId(dudeInfo[31].seqStartID+15, 0); + seqPrecacheId(dudeInfo[31].seqStartID+12, 0); + seqPrecacheId(dudeInfo[31].seqStartID+16, 0); + seqPrecacheId(dudeInfo[31].seqStartID+17, 0); + seqPrecacheId(dudeInfo[31].seqStartID+18, 0); if (skyTile > -1 && skyTile < kMaxTiles) { for (int i = 1; i < gSkyCount; i++) - tilePrecacheTile(skyTile+i, 0, hits); + tilePrecacheTile(skyTile+i, 0, 0); } - WeaponPrecache(hits); - viewPrecacheTiles(hits); - fxPrecache(hits); - gibPrecache(hits); + WeaponPrecache(); + viewPrecacheTiles(); + fxPrecache(); + gibPrecache(); I_GetEvent(); -} - -void PreloadCache() -{ - if (!r_precache) return; - HitList hits; - PreloadTiles(hits); - int cnt = 0; - int percentDisplayed = -1; - - for (int i = 0; i < kMaxTiles; i++) - { - if (hits[i]) - { - PrecacheHardwareTextures(i); - - if ((++cnt & 7) == 0) - I_GetEvent(); - } - } + precacheMarkedTiles(); } END_BLD_NS diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index fab15a288..3194b30cd 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -146,14 +146,14 @@ void QAV::Play(int start, int end, int nCallback, void *pData) } } -void QAV::Precache(HitList &hits) +void QAV::Precache(int palette) { for (int i = 0; i < nFrames; i++) { for (int j = 0; j < 8; j++) { if (frames[i].tiles[j].picnum >= 0) - tilePrecacheTile(frames[i].tiles[j].picnum, 0, hits); + tilePrecacheTile(frames[i].tiles[j].picnum, 0, palette); } } } diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index 07062c67e..8b73ca51c 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -82,7 +82,7 @@ struct QAV void Draw(int ticks, int stat, int shade, int palnum, bool in3dscene); void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool in3dscene); void Play(int, int, int, void *); - void Precache(HitList &hits); + void Precache(int palette = 0); }; #pragma pack(pop) diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 7ea06fbdf..7024d25ea 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -102,20 +102,20 @@ static void (*seqClientCallback[])(int, DBloodActor*) = { // //--------------------------------------------------------------------------- -void Seq::Precache(HitList& hits) +void Seq::Precache(int palette) { if (memcmp(signature, "SEQ\x1a", 4) != 0) I_Error("Invalid sequence"); if ((version & 0xff00) != 0x300) I_Error("Obsolete sequence version"); for (int i = 0; i < nFrames; i++) - tilePrecacheTile(seqGetTile(&frames[i]), -1, hits); + tilePrecacheTile(seqGetTile(&frames[i]), -1, palette); } -void seqPrecacheId(int id, HitList& hits) +void seqPrecacheId(int id, int palette) { auto pSeq = getSequence(id); - if (pSeq) pSeq->Precache(hits); + if (pSeq) pSeq->Precache(palette); } //--------------------------------------------------------------------------- diff --git a/source/games/blood/src/seq.h b/source/games/blood/src/seq.h index 481431c11..724f5b081 100644 --- a/source/games/blood/src/seq.h +++ b/source/games/blood/src/seq.h @@ -59,7 +59,7 @@ struct Seq { short soundId; int flags; SEQFRAME frames[1]; - void Precache(HitList&); + void Precache(int palette); bool isLooping() { @@ -96,7 +96,7 @@ inline int seqGetTile(SEQFRAME* pFrame) } int seqRegisterClient(void(*pClient)(int, int)); -void seqPrecacheId(int id, HitList& hits); +void seqPrecacheId(int id, int palette); SEQINST* GetInstance(int a1, int a2); void UnlockInstance(SEQINST* pInst); void seqSpawn(int a1, int a2, int a3, int a4 = -1); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index b720fbb80..8e168f2ff 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -237,12 +237,12 @@ void WeaponInit(void) } } -void WeaponPrecache(HitList &hits) +void WeaponPrecache() { for (int i = 0; i < kQAVEnd; i++) { if (weaponQAV[i]) - weaponQAV[i]->Precache(hits); + weaponQAV[i]->Precache(); } } From e5e23cd63c6dd644a61d6b3c8ce498bd506bea5f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 13:19:48 +0200 Subject: [PATCH 14/33] - make sure voxels are being precached. In Blood's case it also needs to check the game-side array to find everything. --- source/core/precache.cpp | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/source/core/precache.cpp b/source/core/precache.cpp index 4423f51ab..0a4bc0b58 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -32,13 +32,19 @@ **--------------------------------------------------------------------------- ** */ - +#include "ns.h" #include "build.h" #include "palette.h" #include "v_video.h" #include "hw_material.h" +#include "gamestruct.h" +#include "gamecontrol.h" #include "glbackend/gl_models.h" +BEGIN_BLD_NS +extern short voxelIndex[MAXTILES]; +END_BLD_NS + static void PrecacheTex(FGameTexture* tex, int palid) { if (!tex || !tex->isValid()) return; @@ -49,31 +55,29 @@ static void PrecacheTex(FGameTexture* tex, int palid) screen->PrecacheMaterial(mat, palid); } -static void doprecache(int32_t dapicnum, int32_t dapalnum, int32_t datype) +static void doprecache(int picnum, int palette) { - // dapicnum and dapalnum are like you'd expect - // datype is 0 for a wall/floor/ceiling and 1 for a sprite - // basically this just means walls are repeating - // while sprites are clamped + if ((palette < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(palette))) return; - if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(dapalnum))) return;//dapalnum = 0; - - //Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); - auto tex = tileGetTexture(dapicnum); + int palid = TRANSLATION(Translation_Remap + curbasepal, palette); + auto tex = tileGetTexture(picnum); PrecacheTex(tex, palid); - if (datype == 0 || !hw_models) return; + if (!hw_models) return; - int const mid = md_tilehasmodel(dapicnum, dapalnum); + int const mid = md_tilehasmodel(picnum, palette); if (mid < 0 || models[mid]->mdnum < 2) { - int vox = tiletovox[dapicnum]; - if (vox != -1 && voxmodels[vox] && voxmodels[vox]->model) + if (r_voxels) { - FHWModelRenderer mr(*screen->RenderState(), 0); - voxmodels[vox]->model->BuildVertexBuffer(&mr); + int vox = tiletovox[picnum]; + if (vox == -1 && isBlood()) vox = Blood::voxelIndex[picnum]; + if (vox != -1 && voxmodels[vox] && voxmodels[vox]->model) + { + FHWModelRenderer mr(*screen->RenderState(), 0); + voxmodels[vox]->model->BuildVertexBuffer(&mr); + } } return; } @@ -82,19 +86,12 @@ static void doprecache(int32_t dapicnum, int32_t dapalnum, int32_t datype) for (int i = 0; i <= surfaces; i++) { - auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr); - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + auto tex = mdloadskin((md2model_t *)models[mid], 0, palette, i, nullptr); + int palid = TRANSLATION(Translation_Remap + curbasepal, palette); if (tex) PrecacheTex(tex, palid); } } -void PrecacheHardwareTextures(int nTile) -{ - // PRECACHE - // This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer. - doprecache(nTile, 0, 1); -} - TMap cachemap; @@ -128,7 +125,7 @@ void precacheMarkedTiles() { int dapicnum = pair->Key & 0x7fffffff; int dapalnum = pair->Key >> 32; - doprecache(dapicnum, dapalnum, 0); + doprecache(dapicnum, dapalnum); } } From 0ee28fb45ea1fdee9cdff11632851c2c3b1fc0c1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 13:38:23 +0200 Subject: [PATCH 15/33] - also handle SW's voxels. --- source/build/src/polymost.cpp | 2 +- source/core/gamestruct.h | 2 +- source/core/precache.cpp | 4 +++- source/core/precache.h | 1 + source/games/sw/src/game.cpp | 4 ++-- source/games/sw/src/game.h | 8 ++++---- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index a4b04a143..4901b8155 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -2202,7 +2202,7 @@ void polymost_scansector(int32_t sectnum) { if ((spr->cstat&(64+48))!=(64+16) || (r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || - (r_voxels && gi->Voxelize(spr->picnum)) || + (r_voxels && gi->Voxelize(spr->picnum) > -1) || DMulScale(bcos(spr->ang), -s.x, bsin(spr->ang), -s.y, 6) > 0) if (renderAddTsprite(z, sectnum)) break; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 664c878d3..f6a0dd697 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -101,7 +101,7 @@ struct GameInterface virtual int chaseCamX(binangle ang) { return 0; } virtual int chaseCamY(binangle ang) { return 0; } virtual int chaseCamZ(fixedhoriz horiz) { return 0; } - virtual bool Voxelize(int sprnum) { return false; } + virtual int Voxelize(int sprnum) { return -1; } virtual FString statFPS() { diff --git a/source/core/precache.cpp b/source/core/precache.cpp index 0a4bc0b58..ed660c7cd 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -72,8 +72,9 @@ static void doprecache(int picnum, int palette) if (r_voxels) { int vox = tiletovox[picnum]; + if (vox == -1) vox = gi->Voxelize(picnum); if (vox == -1 && isBlood()) vox = Blood::voxelIndex[picnum]; - if (vox != -1 && voxmodels[vox] && voxmodels[vox]->model) + if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model) { FHWModelRenderer mr(*screen->RenderState(), 0); voxmodels[vox]->model->BuildVertexBuffer(&mr); @@ -127,5 +128,6 @@ void precacheMarkedTiles() int dapalnum = pair->Key >> 32; doprecache(dapicnum, dapalnum); } + cachemap.Clear(); } diff --git a/source/core/precache.h b/source/core/precache.h index 30c6cea27..bcf40813f 100644 --- a/source/core/precache.h +++ b/source/core/precache.h @@ -2,4 +2,5 @@ void PrecacheHardwareTextures(int nTile); void markTileForPrecache(int tilenum, int palnum); +void markVoxelForPrecache(int voxnum); void precacheMarkedTiles(); diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 064cfc44f..e77e64f6c 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -798,9 +798,9 @@ void GameInterface::FreeLevelData() ::GameInterface::FreeLevelData(); } -bool GameInterface::Voxelize(int sprnum) +int GameInterface::Voxelize(int sprnum) { - return (aVoxelArray[sprnum].Voxel >= 0); + return (aVoxelArray[sprnum].Voxel); } END_SW_NS diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 799aa2065..e9ab4c651 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2252,10 +2252,10 @@ struct GameInterface : ::GameInterface void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; void SwitchCoopView() override; - int chaseCamX(binangle ang) { return -ang.bcos(-3); } - int chaseCamY(binangle ang) { return -ang.bsin(-3); } - int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; } - bool Voxelize(int sprnum); + int chaseCamX(binangle ang) override { return -ang.bcos(-3); } + int chaseCamY(binangle ang) override { return -ang.bsin(-3); } + int chaseCamZ(fixedhoriz horiz) override { return horiz.asq16() >> 8; } + int Voxelize(int sprnum) override; GameStats getStats() override; From c33eea25408b33f3d4238b18ac92fdacf9cc004a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 15:23:42 +0200 Subject: [PATCH 16/33] - migrating 'tint .def command. --- source/build/src/defs.cpp | 52 ++------------------------------------- source/core/parsefuncs.h | 36 +++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index dc8300d2e..20b57fb75 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -1446,56 +1446,8 @@ static int32_t defsparser(scriptfile *script) } break; case T_TINT: - { - auto tintpos = scriptfile_getposition(script); - int32_t red=255, green=255, blue=255, shadered=0, shadegreen=0, shadeblue=0, pal=-1, flags=0; - FScanner::SavedPos tintend; - - static const tokenlist tinttokens[] = - { - { "pal", T_PAL }, - { "red", T_RED },{ "r", T_RED }, - { "green", T_GREEN },{ "g", T_GREEN }, - { "blue", T_BLUE },{ "b", T_BLUE }, - { "shadered", T_SHADERED },{ "sr", T_SHADERED }, - { "shadegreen", T_SHADEGREEN },{ "sg", T_SHADEGREEN }, - { "shadeblue", T_SHADEBLUE },{ "sb", T_SHADEBLUE }, - { "flags", T_FLAGS } - }; - - if (scriptfile_getbraces(script,&tintend)) break; - while (!scriptfile_endofblock(script, tintend)) - { - switch (getatoken(script,tinttokens,countof(tinttokens))) - { - case T_PAL: - scriptfile_getsymbol(script,&pal); break; - case T_RED: - scriptfile_getnumber(script,&red); red = min(255,max(0,red)); break; - case T_GREEN: - scriptfile_getnumber(script,&green); green = min(255,max(0,green)); break; - case T_BLUE: - scriptfile_getnumber(script,&blue); blue = min(255,max(0,blue)); break; - case T_SHADERED: - scriptfile_getnumber(script,&shadered); shadered = min(255,max(0,shadered)); break; - case T_SHADEGREEN: - scriptfile_getnumber(script,&shadegreen); shadegreen = min(255,max(0,shadegreen)); break; - case T_SHADEBLUE: - scriptfile_getnumber(script,&shadeblue); shadeblue = min(255,max(0,shadeblue)); break; - case T_FLAGS: - scriptfile_getsymbol(script,&flags); break; - } - } - - if (pal < 0) - { - tintpos.Message(MSG_ERROR, "tint: missing 'palette number'"); - break; - } - - lookups.setPaletteTint(pal,red,green,blue,shadered,shadegreen,shadeblue,flags); - } - break; + parseTint(*script, pos); + break; case T_MAKEPALOOKUP: { int32_t red=0, green=0, blue=0, pal=-1; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index 4704988e8..94dd79dde 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -146,8 +146,6 @@ static void parseTextureSpecialBlock(FScanner& sc, FScriptPosition& pos, int til FString fn; double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; - if (!sc.GetNumber(pal, true)) return; - if (sc.StartBraces(&blockend)) return; while (!sc.FoundEndBrace(blockend)) { @@ -404,3 +402,37 @@ void parseNoFloorpalRange(FScanner& sc, FScriptPosition& pos) for (int i = start; i <= end; i++) lookups.tables[i].noFloorPal = true; } + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseTint(FScanner& sc, FScriptPosition& pos) +{ + int red = 255, green = 255, blue = 255, shadered = 0, shadegreen = 0, shadeblue = 0, pal = -1, flags = 0; + FScanner::SavedPos tintend; + + FScanner::SavedPos blockend; + + if (sc.StartBraces(&blockend)) return; + while (!sc.FoundEndBrace(blockend)) + { + sc.MustGetString(); + if (sc.Compare("pal")) sc.GetNumber(pal, true); + else if (sc.Compare({"red", "r"})) sc.GetNumber(red); + else if (sc.Compare({ "green", "g" })) sc.GetNumber(green); + else if (sc.Compare({ "blue", "b" })) sc.GetNumber(blue); + else if (sc.Compare({ "shadered", "sr" })) sc.GetNumber(shadered); + else if (sc.Compare({ "shadegreen", "sg" })) sc.GetNumber(shadegreen); + else if (sc.Compare({ "shadeblue", "sb" })) sc.GetNumber(shadeblue); + else if (sc.Compare("flags")) sc.GetNumber(flags, true); + } + + if (pal < 0) + pos.Message(MSG_ERROR, "tint: missing palette number"); + else + lookups.setPaletteTint(pal, clamp(red, 0, 255), clamp(green, 0, 255), clamp(blue, 0, 255), + clamp(shadered, 0, 255), clamp(shadegreen, 0, 255), clamp(shadeblue, 0, 255), flags); +} From aebcc13c4a7a195346b8d64ebff1e3675ac27449 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 18:37:11 +0200 Subject: [PATCH 17/33] - migrated voxel parsing stuff. --- source/build/include/build.h | 2 +- source/build/src/defs.cpp | 133 ++------------------------------ source/core/parsefuncs.h | 107 ++++++++++++++++++++++++- source/games/blood/src/tile.cpp | 2 +- 4 files changed, 114 insertions(+), 130 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index ea134212f..1e7fbd436 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -583,7 +583,7 @@ int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, f // int32_t md_tilehasmodel(int32_t tilenume, int32_t pal); EXTERN int32_t nextvoxid; -EXTERN int8_t voxreserve[(MAXVOXELS+7)>>3]; +EXTERN FixedBitArrayvoxreserve; #ifdef USE_OPENGL // TODO: dynamically allocate this diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 20b57fb75..817ab12d9 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -144,7 +144,7 @@ enum scripttoken_t T_SURFACE, T_VIEW, }; -static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; +static int32_t lastmodelid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; static const char *skyfaces[6] = { @@ -853,50 +853,11 @@ static int32_t defsparser(scriptfile *script) } break; case T_DEFINEVOXEL: - { - FString fn; - - if (scriptfile_getstring(script,&fn)) - break; //voxel filename - - while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7)))) - nextvoxid++; - - if (nextvoxid == MAXVOXELS) - { - Printf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS); - break; - } - - if (voxDefine(nextvoxid, fn)) - { - Printf("Failure loading voxel file \"%s\"\n",fn.GetChars()); - break; - } - - lastvoxid = nextvoxid++; - } - break; + parseDefineVoxel(*script, pos); + break; case T_DEFINEVOXELTILES: - { - int32_t ftilenume, ltilenume, tilex; - - if (scriptfile_getsymbol(script,&ftilenume)) break; //1st tile # - if (scriptfile_getsymbol(script,<ilenume)) break; //last tile # - - if (check_tile_range("definevoxeltiles", &ftilenume, <ilenume, script, pos)) - break; - - if (lastvoxid < 0) - { - Printf("Warning: Ignoring voxel tiles definition.\n"); - break; - } - - for (tilex = ftilenume; tilex <= ltilenume; tilex++) - tiletovox[tilex] = lastvoxid; - } - break; + parseDefineVoxelTiles(*script, pos); + break; // NEW (ENCOURAGED) DEFINITION SYNTAX case T_MODEL: @@ -1312,88 +1273,8 @@ static int32_t defsparser(scriptfile *script) } break; case T_VOXEL: - { - auto voxelpos = scriptfile_getposition(script); - FScanner::SavedPos modelend; - FString fn; - int32_t tile0 = MAXTILES, tile1 = -1, tilex = -1; - - static const tokenlist voxeltokens[] = - { - { "tile", T_TILE }, - { "tile0", T_TILE0 }, - { "tile1", T_TILE1 }, - { "scale", T_SCALE }, - { "rotate", T_ROTATE }, - }; - - if (scriptfile_getstring(script,&fn)) - break; //voxel filename - - while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7)))) - nextvoxid++; - - if (nextvoxid == MAXVOXELS) - { - voxelpos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.", MAXVOXELS); - break; - } - - if (voxDefine(nextvoxid, fn)) - { - voxelpos.Message(MSG_ERROR, "Failure loading voxel file \"%s\"",fn.GetChars()); - break; - } - - lastvoxid = nextvoxid++; - - if (scriptfile_getbraces(script,&modelend)) break; - while (!scriptfile_endofblock(script, modelend)) - { - switch (getatoken(script, voxeltokens, countof(voxeltokens))) - { - //case T_ERROR: Printf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break; - case T_TILE: - scriptfile_getsymbol(script,&tilex); - - if (check_tile("voxel", tilex, script, voxelpos)) - break; - - tiletovox[tilex] = lastvoxid; - break; - - case T_TILE0: - scriptfile_getsymbol(script,&tile0); - break; //1st tile # - - case T_TILE1: - scriptfile_getsymbol(script,&tile1); - - if (check_tile_range("voxel", &tile0, &tile1, script, voxelpos)) - break; - - for (tilex=tile0; tilex<=tile1; tilex++) - tiletovox[tilex] = lastvoxid; - break; //last tile number (inclusive) - - case T_SCALE: - { - double scale=1.0; - scriptfile_getdouble(script,&scale); - voxscale[lastvoxid] = (float)scale; - if (voxmodels[lastvoxid]) - voxmodels[lastvoxid]->scale = scale; - break; - } - - case T_ROTATE: - voxrotate.Set(lastvoxid); - break; - } - } - lastvoxid = -1; - } - break; + parseVoxel(*script, pos); + break; case T_SKYBOX: parseSkybox(*script, pos); break; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index 94dd79dde..5d72b0cb8 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -346,6 +346,111 @@ void parseAlphahackRange(FScanner& sc, FScriptPosition& pos) TileFiles.tiledata[i].texture->alphaThreshold = (float)sc.Number; } +//=========================================================================== +// +// +// +//=========================================================================== +static int lastvoxid = -1; + +void parseDefineVoxel(FScanner& sc, FScriptPosition& pos) +{ + sc.MustGetString(); + while (nextvoxid < MAXVOXELS && voxreserve[nextvoxid]) nextvoxid++; + + if (nextvoxid == MAXVOXELS) + { + pos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.\n", MAXVOXELS); + return; + } + + if (voxDefine(nextvoxid, sc.String)) + { + pos.Message(MSG_ERROR, "Unable to load voxel file \"%s\"\n", sc.String); + return; + } + + lastvoxid = nextvoxid++; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseDefineVoxelTiles(FScanner& sc, FScriptPosition& pos) +{ + int tilestart, tileend; + if (!sc.GetNumber(tilestart, true)) return; + if (!sc.GetNumber(tileend, true)) return; + if (!ValidateTileRange("definevoxeltiles", tilestart, tileend, pos)) return; + + if (lastvoxid < 0) + { + pos.Message(MSG_WARNING, "Warning: Ignoring voxel tiles definition without valid voxel.\n"); + return; + } + for (int i = tilestart; i <= tileend; i++) tiletovox[i] = lastvoxid; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseVoxel(FScanner& sc, FScriptPosition& pos) +{ + FScanner::SavedPos blockend; + int tile0 = MAXTILES, tile1 = -1; + FString fn; + + if (!sc.GetString(fn)) return; + + while (nextvoxid < MAXVOXELS && voxreserve[nextvoxid]) nextvoxid++; + + if (nextvoxid == MAXVOXELS) + { + pos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.\n", MAXVOXELS); + return; + } + + if (voxDefine(nextvoxid, fn)) + { + pos.Message(MSG_ERROR, "Unable to load voxel file \"%s\"\n", fn.GetChars()); + return; + } + + int lastvoxid = nextvoxid++; + + if (sc.StartBraces(&blockend)) return; + while (!sc.FoundEndBrace(blockend)) + { + sc.MustGetString(); + if (sc.Compare("tile")) + { + sc.GetNumber(true); + if (ValidateTilenum("voxel", sc.Number, pos)) tiletovox[sc.Number] = lastvoxid; + } + if (sc.Compare("tile0")) sc.GetNumber(tile0, true); + if (sc.Compare("tile1")) + { + sc.GetNumber(tile1, true); + if (ValidateTileRange("voxel", tile0, tile1, pos)) + { + for (int i = tile0; i <= tile1; i++) tiletovox[i] = lastvoxid; + } + } + if (sc.Compare("scale")) + { + sc.GetFloat(true); + voxscale[lastvoxid] = (float)sc.Float; + } + if (sc.Compare("rotate")) voxrotate.Set(lastvoxid); + } +} + //=========================================================================== // // @@ -412,8 +517,6 @@ void parseNoFloorpalRange(FScanner& sc, FScriptPosition& pos) void parseTint(FScanner& sc, FScriptPosition& pos) { int red = 255, green = 255, blue = 255, shadered = 0, shadegreen = 0, shadeblue = 0, pal = -1, flags = 0; - FScanner::SavedPos tintend; - FScanner::SavedPos blockend; if (sc.StartBraces(&blockend)) return; diff --git a/source/games/blood/src/tile.cpp b/source/games/blood/src/tile.cpp index 3d81013e0..a58fd94f6 100644 --- a/source/games/blood/src/tile.cpp +++ b/source/games/blood/src/tile.cpp @@ -74,7 +74,7 @@ int tileInit(char a1, const char *a2) for (int i = 0; i < kMaxTiles; i++) { if (voxelIndex[i] >= 0 && voxelIndex[i] < kMaxVoxels) - SetBitString((char*)voxreserve, voxelIndex[i]); + voxreserve.Set(voxelIndex[i]); } artLoaded = 1; From ef95754e87e77e2617cac22c3efadead12f7cb1c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 18:38:26 +0200 Subject: [PATCH 18/33] - fixed bad texture checks. --- source/core/rendering/scene/hw_flats.cpp | 2 +- source/core/rendering/scene/hw_sprites.cpp | 2 +- source/core/rendering/scene/hw_walls.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index 71a1f50e7..527dacb76 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -179,7 +179,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) state.SetRenderStyle(RenderStyle); state.SetTextureMode(RenderStyle); - if (!texture || !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); + if (texture && !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); else state.AlphaFunc(Alpha_GEqual, 0.f); } state.SetMaterial(texture, UF_Texture, 0, sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1); diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 17934fac3..35af8f331 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -71,7 +71,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) state.SetRenderStyle(RenderStyle); state.SetTextureMode(RenderStyle); - if (!texture || !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); + if (texture && !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); else state.AlphaFunc(Alpha_Greater, 0.f); if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index b41ae6f2a..1bac389ad 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -200,7 +200,7 @@ void HWWall::RenderTranslucentWall(HWDrawInfo *di, FRenderState &state) state.SetRenderStyle(RenderStyle); state.SetTextureMode(RenderStyle); - if (!texture || !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); + if (texture && !checkTranslucentReplacement(texture->GetID(), palette)) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold); else state.AlphaFunc(Alpha_GEqual, 0.f); RenderTexturedWall(di, state, HWWall::RWF_TEXTURED); state.SetRenderStyle(STYLE_Translucent); From fd6a71cac585feff3244403119afe1aff239b59a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 20:37:04 +0200 Subject: [PATCH 19/33] - fixed a random crash with an empty sprite I just experienced. --- source/games/blood/src/actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index a3fcf58f5..1ffdd1d79 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2854,7 +2854,7 @@ spritetype *actDropObject(spritetype *pSprite, int nType) { else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) pSprite2 = actDropAmmo(pSprite, nType); else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) pSprite2 = actDropWeapon(pSprite, nType); - if (pSprite2) { + if (pSprite2 && pSprite->picnum > -1) { int top, bottom; GetSpriteExtents(pSprite2, &top, &bottom); if (bottom >= pSprite2->z) From 6142f9d79581962dd8c738d68715b8b4a012da22 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 21:13:24 +0200 Subject: [PATCH 20/33] - added CHANF_FORCE flag for forcing non-looped sounds to start, even when sound is paused. Blood needs this for its PlayerSound controller, which is run right on map load - so without this it wouldn't start the sound when a map is initiated from the console. --- source/common/audio/sound/i_soundinternal.h | 1 + source/common/audio/sound/s_sound.cpp | 2 +- source/games/blood/src/triggers.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/common/audio/sound/i_soundinternal.h b/source/common/audio/sound/i_soundinternal.h index be3486440..1ef4178d4 100644 --- a/source/common/audio/sound/i_soundinternal.h +++ b/source/common/audio/sound/i_soundinternal.h @@ -31,6 +31,7 @@ enum EChanFlag CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them. CHANF_LOCAL = 16384, // only plays locally for the calling actor CHANF_TRANSIENT = 32768, // Do not record in savegames - used for sounds that get restarted outside the sound system (e.g. ambients in SW and Blood) + CHANF_FORCE = 65536, // Start, even if sound is paused. }; typedef TFlags EChanFlags; diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index 4521ebd90..7fdbd74c6 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -528,7 +528,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, // sound is paused and a non-looped sound is being started. // Such a sound would play right after unpausing which wouldn't sound right. - if (!(chanflags & CHANF_LOOP) && !(chanflags & (CHANF_UI|CHANF_NOPAUSE)) && SoundPaused) + if (!(chanflags & CHANF_LOOP) && !(chanflags & (CHANF_UI|CHANF_NOPAUSE|CHANF_FORCE)) && SoundPaused) { return NULL; } diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 4bbaf9c7f..8da50f7af 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -595,7 +595,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) break; gMe->restTime = 0; } - sndStartSample(pXSprite->data1, -1, 1, 0); + sndStartSample(pXSprite->data1, -1, 1, 0, CHANF_FORCE); break; case kThingObjectGib: case kThingObjectExplode: From 9b977ba96e6692ef77029cde35a62300f8032c2f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 22:42:24 +0200 Subject: [PATCH 21/33] - fixed mixup of values 0 and -1 in sound code. 0 means 'default', -1 means 'silent'. This caused playback issues for useSoundGen. All other places were passing proper volume values along, this is the only one to read the volume from map data. --- source/games/blood/src/sfx.cpp | 7 ++++--- source/games/blood/src/sound.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index b12c01b3e..dd64ab3e4 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -149,7 +149,8 @@ FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int &relvol) auto udata = soundEngine->GetUserData(soundId); if (pitch < 0) pitch = udata ? udata[0] : 0x10000; - if (relvol < 0) relvol = udata && udata[2] ? udata[2] : 80; + if (relvol < 0) relvol = 0; + else if (relvol == 0) relvol = udata && udata[2] ? udata[2] : 80; if (relvol > 255) relvol = 255; // Limit the attenuation. More than 2.0 is simply too much. attenuation = relvol > 0 ? clamp(80.f / relvol, 0.f, 2.f) : 1.f; @@ -167,7 +168,7 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector) float attenuation; int pitch = -1; - int relvol = -1; + int relvol = 0; sid = getSfx(sid, attenuation, pitch, relvol); auto sfx = soundEngine->GetSfx(sid); EChanFlags flags = CHANF_OVERLAP; @@ -225,7 +226,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc void sfxPlay3DSound(spritetype* pSprite, int soundId, int a3, int a4) { - sfxPlay3DSoundCP(pSprite, soundId, a3, a4, -1, -1); + sfxPlay3DSoundCP(pSprite, soundId, a3, a4, -1); } diff --git a/source/games/blood/src/sound.h b/source/games/blood/src/sound.h index 8f9566234..a4c384910 100644 --- a/source/games/blood/src/sound.h +++ b/source/games/blood/src/sound.h @@ -54,7 +54,7 @@ void sfxInit(void); void sfxTerm(void); void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector); void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0); -void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = -1); +void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1); void sfxKillAllSounds(void); void sfxSetReverb(bool toggle); From 135dd1f081c280840ca278054b791cc028d1cc44 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 00:31:23 +0200 Subject: [PATCH 22/33] - added PlaySound CCNDs. --- source/core/raze_sound.cpp | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/source/core/raze_sound.cpp b/source/core/raze_sound.cpp index 463fece92..5d6130895 100644 --- a/source/core/raze_sound.cpp +++ b/source/core/raze_sound.cpp @@ -254,3 +254,46 @@ void S_SerializeSounds(FSerializer& arc) GSnd->UpdateSounds(); } +//========================================================================== +// +// CCMD playsound +// +//========================================================================== + +CCMD(playsound) +{ + if (argv.argc() > 1) + { + FSoundID id = argv[1]; + if (id == 0) + { + Printf("'%s' is not a sound\n", argv[1]); + } + else + { + soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, CHANF_UI | CHANF_NOPAUSE, id, 1.f, ATTN_NORM); + } + } +} + +//========================================================================== +// +// CCMD playsound +// +//========================================================================== + +CCMD(playsoundid) +{ + if (argv.argc() > 1) + { + FSoundID id = soundEngine->FindSoundByResID((int)strtol(argv[1], nullptr, 0)); + if (id == 0) + { + Printf("'%s' is not a sound\n", argv[1]); + } + else + { + soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, CHANF_UI | CHANF_NOPAUSE, id, 1.f, ATTN_NORM); + } + } +} From d25838fe151b38b2a2b2a50bf5315a7404a3cd36 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 00:01:29 +0200 Subject: [PATCH 23/33] - Blood: fixed issue with INI detection when having content added by RFS files. --- source/games/blood/src/levels.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/games/blood/src/levels.cpp b/source/games/blood/src/levels.cpp index 462fbe316..34f1c6d40 100644 --- a/source/games/blood/src/levels.cpp +++ b/source/games/blood/src/levels.cpp @@ -121,7 +121,8 @@ static const char* DefFile(void) int numlumps = fileSystem.GetNumEntries(); for (int i = numlumps - 1; i >= 0; i--) { - if (fileSystem.GetFileContainer(i) <= fileSystem.GetMaxIwadNum()) break; + int fileno = fileSystem.GetFileContainer(i); + if (fileno != -1 && fileno <= fileSystem.GetMaxIwadNum()) break; FString fn = fileSystem.GetFileFullName(i, false); FString ext = fn.Right(4); if (ext.CompareNoCase(".ini") == 0) From f87e40131f266a7b3a26e9eaf6e979a2ca2c0967 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 00:10:43 +0200 Subject: [PATCH 24/33] - Blood: add a dummy sound entry at index 0. Parts of the sound system treat entry 0 as "no sound" so nothing placed there would play. This made the one custom sound in "The Way of Ira" not play because as the last sound being defined it ended up in the first, invalid slot. --- source/core/raze_sound.cpp | 85 +++++++++++++++++++------------- source/games/blood/src/sfx.cpp | 9 ---- source/games/blood/src/sound.cpp | 6 ++- source/games/blood/src/sound.h | 2 - 4 files changed, 54 insertions(+), 48 deletions(-) diff --git a/source/core/raze_sound.cpp b/source/core/raze_sound.cpp index 5d6130895..a306f8520 100644 --- a/source/core/raze_sound.cpp +++ b/source/core/raze_sound.cpp @@ -208,50 +208,50 @@ void S_SerializeSounds(FSerializer& arc) { FSoundChan* chan; - GSnd->Sync(true); +GSnd->Sync(true); - if (arc.isWriting()) +if (arc.isWriting()) +{ + // Count channels and accumulate them so we can store them in + // reverse order. That way, they will be in the same order when + // reloaded later as they are now. + TArray chans = soundEngine->AllActiveChannels(); + + if (chans.Size() > 0 && arc.BeginArray("sounds")) { - // Count channels and accumulate them so we can store them in - // reverse order. That way, they will be in the same order when - // reloaded later as they are now. - TArray chans = soundEngine->AllActiveChannels(); - - if (chans.Size() > 0 && arc.BeginArray("sounds")) + for (unsigned int i = chans.Size(); i-- != 0; ) { - for (unsigned int i = chans.Size(); i-- != 0; ) - { - // Replace start time with sample position. - uint64_t start = chans[i]->StartTime; - chans[i]->StartTime = GSnd ? GSnd->GetPosition(chans[i]) : 0; - arc(nullptr, *chans[i]); - chans[i]->StartTime = start; - } - arc.EndArray(); + // Replace start time with sample position. + uint64_t start = chans[i]->StartTime; + chans[i]->StartTime = GSnd ? GSnd->GetPosition(chans[i]) : 0; + arc(nullptr, *chans[i]); + chans[i]->StartTime = start; } + arc.EndArray(); } - else +} +else +{ + unsigned int count; + + soundEngine->StopAllChannels(); + if (arc.BeginArray("sounds")) { - unsigned int count; - - soundEngine->StopAllChannels(); - if (arc.BeginArray("sounds")) + count = arc.ArraySize(); + for (unsigned int i = 0; i < count; ++i) { - count = arc.ArraySize(); - for (unsigned int i = 0; i < count; ++i) - { - chan = (FSoundChan*)soundEngine->GetChannel(nullptr); - arc(nullptr, *chan); - // Sounds always start out evicted when restored from a save. - chan->ChanFlags |= CHANF_EVICTED | CHANF_ABSTIME; - } - arc.EndArray(); + chan = (FSoundChan*)soundEngine->GetChannel(nullptr); + arc(nullptr, *chan); + // Sounds always start out evicted when restored from a save. + chan->ChanFlags |= CHANF_EVICTED | CHANF_ABSTIME; } - // Add a small delay so that eviction only runs once the game is up and runnnig. - soundEngine->SetRestartTime(I_GetTime() + 2); + arc.EndArray(); } - GSnd->Sync(false); - GSnd->UpdateSounds(); + // Add a small delay so that eviction only runs once the game is up and runnnig. + soundEngine->SetRestartTime(I_GetTime() + 2); +} +GSnd->Sync(false); +GSnd->UpdateSounds(); } //========================================================================== @@ -297,3 +297,18 @@ CCMD(playsoundid) } } } + +//========================================================================== +// +// CCMD listsounds +// +//========================================================================== + +CCMD(listsounds) +{ + auto& S_sfx = soundEngine->GetSounds(); + for (unsigned i = 0; i < S_sfx.Size(); i++) + { + Printf("%4d: name = %s, resId = %d, lumpnum = %d\n", i, S_sfx[i].name.GetChars(), S_sfx[i].ResourceId, S_sfx[i].lumpnum); + } +} diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index dd64ab3e4..f1ac8e609 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -58,15 +58,6 @@ public: }; -void sfxInit(void) -{ - soundEngine = new BloodSoundEngine; -} - -void sfxTerm() -{ -} - //========================================================================== // // diff --git a/source/games/blood/src/sound.cpp b/source/games/blood/src/sound.cpp index eb67e2082..28dae78bb 100644 --- a/source/games/blood/src/sound.cpp +++ b/source/games/blood/src/sound.cpp @@ -106,7 +106,8 @@ static void S_AddBloodSFX(int lumpnum) void sndInit(void) { - sfxInit(); + soundEngine = new BloodSoundEngine; + soundEngine->AddSoundLump("", 0, 0, -1, 6); // add a dummy entry at index #0 for (int i = fileSystem.GetNumEntries() - 1; i >= 0; i--) { auto type = fileSystem.GetResourceType(i); @@ -117,7 +118,8 @@ void sndInit(void) } else if (!stricmp(type, "WAV") || !stricmp(type, "OGG") || !stricmp(type, "FLAC") || !stricmp(type, "VOC")) { - soundEngine->AddSoundLump(fileSystem.GetFileFullName(i), i, 0, fileSystem.GetResourceId(i)| 0x40000000, 6); // mark the resource ID as special. + if (fileSystem.GetFileNamespace(i) != ns_music) + soundEngine->AddSoundLump(fileSystem.GetFileFullName(i), i, 0, fileSystem.GetResourceId(i)| 0x40000000, 6); // mark the resource ID as special. } } soundEngine->HashSounds(); diff --git a/source/games/blood/src/sound.h b/source/games/blood/src/sound.h index a4c384910..7b7659e2f 100644 --- a/source/games/blood/src/sound.h +++ b/source/games/blood/src/sound.h @@ -50,8 +50,6 @@ void sndProcess(void); void sndTerm(void); void sndInit(void); -void sfxInit(void); -void sfxTerm(void); void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector); void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0); void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); From a15ac437225893b4e2f1025782ffce988a390b35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 00:20:45 +0200 Subject: [PATCH 25/33] - enable embedding of blood.rff and sounds.rff in mod archives when playing Blood Some mods provide pregenerated resources, this allows loading them without picking them apart first. --- source/common/filesystem/file_7z.cpp | 2 +- source/common/filesystem/file_directory.cpp | 2 +- source/common/filesystem/file_pak.cpp | 2 +- source/common/filesystem/file_zip.cpp | 2 +- source/common/filesystem/resourcefile.cpp | 15 +++------------ source/common/filesystem/resourcefile.h | 3 ++- source/core/initfs.cpp | 5 +++++ 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/source/common/filesystem/file_7z.cpp b/source/common/filesystem/file_7z.cpp index 8d0d64bb2..f207702d0 100644 --- a/source/common/filesystem/file_7z.cpp +++ b/source/common/filesystem/file_7z.cpp @@ -293,7 +293,7 @@ bool F7ZFile::Open(bool quiet, LumpFilterInfo *filter) lump_p->Owner = this; lump_p->Flags = LUMPF_FULLPATH|LUMPF_COMPRESSED; lump_p->Position = i; - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(filter); lump_p++; } // Resize the lump record array to its actual size diff --git a/source/common/filesystem/file_directory.cpp b/source/common/filesystem/file_directory.cpp index 7654764cb..4f2c94eba 100644 --- a/source/common/filesystem/file_directory.cpp +++ b/source/common/filesystem/file_directory.cpp @@ -209,7 +209,7 @@ void FDirectory::AddEntry(const char *fullpath, int size) lump_p->LumpSize = size; lump_p->Owner = this; lump_p->Flags = 0; - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(nullptr); } diff --git a/source/common/filesystem/file_pak.cpp b/source/common/filesystem/file_pak.cpp index 5ff9ff886..13aafa985 100644 --- a/source/common/filesystem/file_pak.cpp +++ b/source/common/filesystem/file_pak.cpp @@ -109,7 +109,7 @@ bool FPakFile::Open(bool quiet, LumpFilterInfo* filter) Lumps[i].Owner = this; Lumps[i].Position = LittleLong(fileinfo[i].filepos); Lumps[i].LumpSize = LittleLong(fileinfo[i].filelen); - Lumps[i].CheckEmbedded(); + Lumps[i].CheckEmbedded(filter); } GenerateHash(); PostProcessArchive(&Lumps[0], sizeof(Lumps[0]), filter); diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp index 2adca1160..f33b60ba4 100644 --- a/source/common/filesystem/file_zip.cpp +++ b/source/common/filesystem/file_zip.cpp @@ -337,7 +337,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) lump_p->CRC32 = zip_fh->CRC32; lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize); lump_p->Position = LittleLong(zip_fh->LocalHeaderOffset); - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(filter); lump_p++; } diff --git a/source/common/filesystem/resourcefile.cpp b/source/common/filesystem/resourcefile.cpp index d718d74ec..5fc484b23 100644 --- a/source/common/filesystem/resourcefile.cpp +++ b/source/common/filesystem/resourcefile.cpp @@ -122,7 +122,7 @@ static bool IsWadInFolder(const FResourceFile* const archive, const char* const return 0 == filePath.CompareNoCase(resPath); } -void FResourceLump::CheckEmbedded() +void FResourceLump::CheckEmbedded(LumpFilterInfo* lfi) { // Checks for embedded archives const char *c = strstr(FullName, ".wad"); @@ -130,22 +130,13 @@ void FResourceLump::CheckEmbedded() { Flags |= LUMPF_EMBEDDED; } - /* later - else + else if (lfi) for (auto& fstr : lfi->embeddings) { - if (c==NULL) c = strstr(Name, ".zip"); - if (c==NULL) c = strstr(Name, ".pk3"); - if (c==NULL) c = strstr(Name, ".7z"); - if (c==NULL) c = strstr(Name, ".pak"); - if (c && strlen(c) <= 4) + if (!stricmp(FullName, fstr)) { - // Mark all embedded archives in any directory Flags |= LUMPF_EMBEDDED; - memset(Name, 0, 8); } } - */ - } diff --git a/source/common/filesystem/resourcefile.h b/source/common/filesystem/resourcefile.h index bfd20e816..5e9276c76 100644 --- a/source/common/filesystem/resourcefile.h +++ b/source/common/filesystem/resourcefile.h @@ -15,6 +15,7 @@ struct LumpFilterInfo // The following are for checking if the root directory of a zip can be removed. TArray reservedFolders; TArray requiredPrefixes; + TArray embeddings; std::function postprocessFunc; }; @@ -111,7 +112,7 @@ public: virtual int GetIndexNum() const { return -1; } virtual int GetNamespace() const { return 0; } void LumpNameSetup(FString iname); - void CheckEmbedded(); + void CheckEmbedded(LumpFilterInfo* lfi); virtual FCompressedBuffer GetRawData(); void *Lock(); // validates the cache and increases the refcount. diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index 6910d2cdf..3ad2283f4 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -388,6 +388,11 @@ void InitFileSystem(TArray& groups) LumpFilterInfo lfi; for (auto p : iwad_folders) lfi.reservedFolders.Push(p); for (auto p = iwad_reserved(); *p; p++) lfi.requiredPrefixes.Push(*p); + if (isBlood()) + { + lfi.embeddings.Push("blood.rff"); + lfi.embeddings.Push("sounds.rff"); + } lfi.dotFilter = LumpFilter; From 26d737c2793b6276a8bbde8d19ad45adc620157f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 15:50:52 +0200 Subject: [PATCH 26/33] - fixed double-add of xoffset for wall sprites. --- source/core/gamefuncs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 23191157e..f34cd1249 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -205,7 +205,7 @@ void GetWallSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool int x = bsin(spr->ang) * spr->xrepeat; int y = -bcos(spr->ang) * spr->xrepeat; - int xoff = leftofs + spr->xoffset; + int xoff = leftofs; if (spr->cstat & CSTAT_SPRITE_XFLIP) xoff = -xoff; int origin = (width >> 1) + xoff; From 3cc05e55320c7789190b6c9b2ce62ac228b61e56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 16:00:00 +0200 Subject: [PATCH 27/33] - fixed handling of single-tile skies with palette translation. --- source/core/textures/skytexture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/textures/skytexture.cpp b/source/core/textures/skytexture.cpp index f9e178b77..1004353a0 100644 --- a/source/core/textures/skytexture.cpp +++ b/source/core/textures/skytexture.cpp @@ -46,7 +46,7 @@ FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t *tilema char synthname[60]; - if (lognumtiles == 0 || lognumtiles > 4) + if ((lognumtiles == 0 && remap == 0) || lognumtiles > 4) { // no special handling - let the old code do its job as-is return nullptr; From bf019ac0282bb0d42b2849e906530b40c12ae37b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 16:31:44 +0200 Subject: [PATCH 28/33] - Build must draw the sky for completely closed sectors as well. --- source/core/rendering/scene/hw_walls.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 1bac389ad..1d45dc2c4 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -944,11 +944,8 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec float zalign = 0.f; - if (fch1 > ffh1 || fch2 > ffh2) - { - SkyTop(di, wal, frontsector, backsector, v1, v2, fch1, fch2); - SkyBottom(di, wal, frontsector, backsector, v1, v2, ffh1, ffh2); - } + SkyTop(di, wal, frontsector, backsector, v1, v2, fch1, fch2); + SkyBottom(di, wal, frontsector, backsector, v1, v2, ffh1, ffh2); // upper texture if (!(frontsector->ceilingstat & backsector->ceilingstat & CSTAT_SECTOR_SKY)) From efe76a6647977fd53c279689b29ce8244a64df79 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 16:32:42 +0200 Subject: [PATCH 29/33] - Blood: fixed crash with badly defined drop objects. Got -1 for picnum there, this was causing crashes. --- source/games/blood/src/actor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 1ffdd1d79..364373526 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2854,7 +2854,12 @@ spritetype *actDropObject(spritetype *pSprite, int nType) { else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) pSprite2 = actDropAmmo(pSprite, nType); else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) pSprite2 = actDropWeapon(pSprite, nType); - if (pSprite2 && pSprite->picnum > -1) { + if (pSprite2) { + if (pSprite2->picnum == -1) + { + DeleteSprite(pSprite2 - sprite); + return nullptr; + } int top, bottom; GetSpriteExtents(pSprite2, &top, &bottom); if (bottom >= pSprite2->z) From 89be30b72027af167667fce040a943e56dfba0b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 18:57:10 +0200 Subject: [PATCH 30/33] - handle fullbright sprite hackery using negative shade values. --- source/core/rendering/scene/hw_drawstructs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/core/rendering/scene/hw_drawstructs.h b/source/core/rendering/scene/hw_drawstructs.h index 8b051fac7..fc3809c56 100644 --- a/source/core/rendering/scene/hw_drawstructs.h +++ b/source/core/rendering/scene/hw_drawstructs.h @@ -400,12 +400,12 @@ inline void SetSpriteTranslucency(const spritetype* sprite, float& alpha, FRende extern PalEntry GlobalMapFog; extern float GlobalFogDensity; -__forceinline void SetLightAndFog(FRenderState& state, PalEntry fade, int palette, int shade, int visibility, float alpha, bool setcolor = true) +__forceinline void SetLightAndFog(FRenderState& state, PalEntry fade, int palette, int orgshade, int visibility, float alpha, bool setcolor = true) { // Fog must be done before the texture so that the texture selector can override it. bool foggy = (GlobalMapFog || (fade & 0xffffff)); auto ShadeDiv = lookups.tables[palette].ShadeFactor; - shade = clamp(shade, 0, numshades - 1); + int shade = clamp(orgshade, 0, numshades - 1); // Disable brightmaps if non-black fog is used. if (ShadeDiv >= 1 / 1000.f && foggy) { @@ -415,12 +415,12 @@ __forceinline void SetLightAndFog(FRenderState& state, PalEntry fade, int palett state.SetSoftLightLevel(255); state.SetLightParms(128.f, 1 / 1000.f); } - else + else { state.EnableFog(0); state.SetFog(0, 0); state.SetSoftLightLevel(gl_fogmode != 0 && ShadeDiv >= 1 / 1000.f ? 255 - Scale(shade, 255, numshades) : 255); - state.SetLightParms(visibility, ShadeDiv / (numshades - 2)); + state.SetLightParms(visibility, orgshade < -numshades / 2 ? 1 / 1000.f : ShadeDiv / (numshades - 2)); } // The shade rgb from the tint is ignored here. From ac04403292d9e9c83261277e41dcaff93ea009f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 19:35:39 +0200 Subject: [PATCH 31/33] - added native support for Nightfright's Alien World Order" GRP generator. --- wadsrc/static/engine/grpinfo.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wadsrc/static/engine/grpinfo.txt b/wadsrc/static/engine/grpinfo.txt index 305b3dc10..82b2b1e26 100644 --- a/wadsrc/static/engine/grpinfo.txt +++ b/wadsrc/static/engine/grpinfo.txt @@ -285,6 +285,14 @@ grpinfo BkColor 0x8f8f8f } +grpinfo +{ + name "Duke: Alien World Order" + dependency DUKE15_CRC + mustcontain "FIREFLYTROOPER.CON", "FLAMETHROWER.CON", "music/E5L1_BulletDam.ogg", "sound/VO_E5L1_Duke_CreamAndSugar.ogg" + gamefilter "Duke.Worldtour" +} + grpinfo { name "Duke!ZONE II (1.3D)" From aed7e8166e4a3a064b4384f842e85f1e29070f16 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 19:39:42 +0200 Subject: [PATCH 32/33] - fixed setup of startup title. --- source/core/gamecontrol.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 28516cf0c..e2560c4a3 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -835,15 +835,18 @@ int RunGame() G_LoadConfig(); auto usedgroups = SetupGame(); - for (auto& grp : usedgroups) + bool colorset = false; + for (int i = usedgroups.Size()-1; i >= 0; i--) { + auto& grp = usedgroups[i]; if (grp.FileInfo.name.IsNotEmpty()) { if (GameStartupInfo.Name.IsEmpty()) GameStartupInfo.Name = grp.FileInfo.name; - if (grp.FileInfo.FgColor != grp.FileInfo.BgColor && (GameStartupInfo.FgColor != 0 || GameStartupInfo.BkColor != 0)) + if (!colorset && grp.FileInfo.FgColor != grp.FileInfo.BgColor && (GameStartupInfo.FgColor != 0 || GameStartupInfo.BkColor != 0)) { GameStartupInfo.FgColor = grp.FileInfo.FgColor; GameStartupInfo.BkColor = grp.FileInfo.BgColor; + colorset = true; } } } From 1e40e93da4a78af7be88bb89ae45e6b825e1b121 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 19:47:16 +0200 Subject: [PATCH 33/33] - fixed the vertical offsets of the World Tour skies. They were rendered too low. --- source/games/duke/src/game.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 6a23cc55f..da5c038cf 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -194,14 +194,14 @@ static void setupbackdrop() if (isWorldTour()) { defineSky(5284, 65536, 3, defoff); - defineSky(5412, 65536, 3, defoff, 48); - defineSky(5420, 65536, 3, defoff, 48); - defineSky(5450, 65536, 3, defoff7, 48); - defineSky(5540, 65536, 3, defoff, 48); - defineSky(5548, 65536, 3, defoff, 48); - defineSky(5556, 65536, 3, defoff1, 48); - defineSky(5720, 65536, 3, defoff4, 48); - defineSky(5814, 65536, 3, defoff, 48); + defineSky(5412, 65536, 3, defoff, 80); + defineSky(5420, 65536, 3, defoff, 80); + defineSky(5450, 65536, 3, defoff7, 80); + defineSky(5540, 65536, 3, defoff, 80); + defineSky(5548, 65536, 3, defoff, 80); + defineSky(5556, 65536, 3, defoff1, 80); + defineSky(5720, 65536, 3, defoff4, 80); + defineSky(5814, 65536, 3, defoff, 80); } // Ugh... Since we do not know up front which of these tiles are skies we have to set them all...