diff --git a/src/common/textures/formats/startuptexture.cpp b/src/common/textures/formats/startuptexture.cpp index 064e7bf83..1d17fb91c 100644 --- a/src/common/textures/formats/startuptexture.cpp +++ b/src/common/textures/formats/startuptexture.cpp @@ -46,13 +46,30 @@ #define ST_NETNOTCH_WIDTH 4 #define ST_NETNOTCH_HEIGHT 16 +struct StrifeStartupInfo +{ + char name[9]; + uint8_t width, height; +}; + +static StrifeStartupInfo StrifeRawPics[] = +{ + { "STRTPA1", 32, 64}, + { "STRTPB1", 32, 64}, + { "STRTPC1", 32, 64}, + { "STRTPD1", 32, 64}, + { "STRLZ1", 16, 16}, + { "STRLZ2", 16, 16}, + { "STRTBOT", 48, 48} +}; + // there is only one palette for all these images. static uint8_t startuppalette8[16]; static uint32_t startuppalette32[16]; //========================================================================== // -// A raw 320x200 graphic used by Heretic and Hexen fullscreen images +// // //========================================================================== @@ -72,6 +89,19 @@ public: int CopyPixels(FBitmap *bmp, int conversion) override; }; +class FStrifeStartupTexture : public FImageSource +{ +public: + FStrifeStartupTexture (int lumpnum, int w, int h); + TArray CreatePalettedPixels(int conversion) override; +}; + +class FStrifeStartupBackground : public FImageSource +{ +public: + FStrifeStartupBackground (int lumpnum); + TArray CreatePalettedPixels(int conversion) override; +}; //========================================================================== // @@ -83,7 +113,7 @@ bool CheckIfRaw(FileReader & data, int desiredsize); //========================================================================== // -// +// loads all raw images for Hexen's and Strife's startup screens // //========================================================================== @@ -104,6 +134,19 @@ FImageSource *StartupPageImage_TryCreate(FileReader & file, int lumpnum) if (!CheckIfRaw(file, ST_NETNOTCH_WIDTH * ST_NETNOTCH_HEIGHT / 2)) return nullptr; return new FNotchTexture(lumpnum, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT); } + if (fileSystem.CheckFileName(lumpnum, "STARTUP0")) + { + if (!CheckIfRaw(file, 64000)) return nullptr; + return new FStrifeStartupBackground(lumpnum); + } + for(auto& sst : StrifeRawPics) + { + if (fileSystem.CheckFileName(lumpnum, sst.name)) + { + if (!CheckIfRaw(file, sst.width * sst.height)) return nullptr; + return new FStrifeStartupTexture(lumpnum, sst.width, sst.height); + } + } return nullptr; } @@ -286,3 +329,67 @@ int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion) } return 0; } + + +//========================================================================== +// +// +// +//========================================================================== + +FStrifeStartupTexture::FStrifeStartupTexture (int lumpnum, int w, int h) +: FImageSource(lumpnum) +{ + Width = w; + Height = h; +} + +//========================================================================== +// +// +// +//========================================================================== + +TArray FStrifeStartupTexture::CreatePalettedPixels(int conversion) +{ + FileData lump = fileSystem.ReadFile (SourceLump); + const uint8_t *source = (const uint8_t *)lump.GetMem(); + TArray Pixels(Width*Height, true); + const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); + ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), source, Width, Height, Width, remap); + return Pixels; +} + +//========================================================================== +// +// +// +//========================================================================== + +FStrifeStartupBackground::FStrifeStartupBackground (int lumpnum) +: FImageSource(lumpnum) +{ + Width = 320; + Height = 200; +} + +//========================================================================== +// +// this image is very messy but let's prepare it just like Strife does +// so that the screen can be replaced with a whole image. +// +//========================================================================== + +TArray FStrifeStartupBackground::CreatePalettedPixels(int conversion) +{ + TArray source(64000, true); + memset(source.Data(), 0xF0, 64000); + auto lumpr = fileSystem.OpenFileReader(SourceLump); + lumpr.Seek(57 * 320, FileReader::SeekSet); + lumpr.Read(source.Data() + 41 * 320, 95 * 320); + + TArray Pixels(Width*Height, true); + const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); + ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), source.Data(), Width, Height, Width, remap); + return Pixels; +} diff --git a/src/common/textures/image.cpp b/src/common/textures/image.cpp index 66d6ebc68..b910c7560 100644 --- a/src/common/textures/image.cpp +++ b/src/common/textures/image.cpp @@ -351,12 +351,12 @@ FImageSource * FImageSource::GetImage(int lumpnum, bool isflat) { StbImage_TryCreate, false }, { TGAImage_TryCreate, false }, { AnmImage_TryCreate, false }, + { StartupPageImage_TryCreate, false }, { RawPageImage_TryCreate, false }, { FlatImage_TryCreate, true }, // flat detection is not reliable, so only consider this for real flats. { PatchImage_TryCreate, false }, { EmptyImage_TryCreate, false }, { AutomapImage_TryCreate, false }, - { StartupPageImage_TryCreate, false }, }; if (lumpnum == -1) return nullptr;