From 50ab68b53bd6bf76ec5392465e07461073e43ef6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 May 2020 23:53:38 +0200 Subject: [PATCH] - moved filesa to common --- source/CMakeLists.txt | 16 +- .../textures/formats/ddstexture.cpp | 0 .../textures/formats/jpegtexture.cpp | 0 .../textures/formats/pcxtexture.cpp | 0 .../textures/formats/pngtexture.cpp | 0 .../textures/formats/stb_image.h | 0 .../textures/formats/stbtexture.cpp | 0 .../textures/formats/tgatexture.cpp | 0 source/{core => common}/textures/image.cpp | 0 source/{core => common}/textures/image.h | 0 source/core/textures/formats/arttexture.cpp | 175 ------------------ 11 files changed, 8 insertions(+), 183 deletions(-) rename source/{core => common}/textures/formats/ddstexture.cpp (100%) rename source/{core => common}/textures/formats/jpegtexture.cpp (100%) rename source/{core => common}/textures/formats/pcxtexture.cpp (100%) rename source/{core => common}/textures/formats/pngtexture.cpp (100%) rename source/{core => common}/textures/formats/stb_image.h (100%) rename source/{core => common}/textures/formats/stbtexture.cpp (100%) rename source/{core => common}/textures/formats/tgatexture.cpp (100%) rename source/{core => common}/textures/image.cpp (100%) rename source/{core => common}/textures/image.h (100%) delete mode 100644 source/core/textures/formats/arttexture.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index de5e6e22f..8405b0106 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -752,6 +752,13 @@ set (PCH_SOURCES common/textures/animtexture.cpp common/textures/bitmap.cpp common/textures/m_png.cpp + common/textures/image.cpp + common/textures/formats/ddstexture.cpp + common/textures/formats/jpegtexture.cpp + common/textures/formats/pcxtexture.cpp + common/textures/formats/pngtexture.cpp + common/textures/formats/tgatexture.cpp + common/textures/formats/stbtexture.cpp common/console/c_commandline.cpp common/console/c_buttons.cpp common/console/c_bind.cpp @@ -821,16 +828,8 @@ set (PCH_SOURCES core/textures/buildtiles.cpp core/textures/texture.cpp - core/textures/image.cpp core/textures/imagetexture.cpp core/textures/imagehelpers.cpp - core/textures/formats/ddstexture.cpp - core/textures/formats/jpegtexture.cpp - core/textures/formats/pcxtexture.cpp - core/textures/formats/pngtexture.cpp - core/textures/formats/tgatexture.cpp - core/textures/formats/stbtexture.cpp - core/textures/formats/arttexture.cpp core/music/s_advsound.cpp @@ -1104,6 +1103,7 @@ source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOUR source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+") source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+") source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+") +source_group("Common\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/formats.+") source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+") source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+") source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+") diff --git a/source/core/textures/formats/ddstexture.cpp b/source/common/textures/formats/ddstexture.cpp similarity index 100% rename from source/core/textures/formats/ddstexture.cpp rename to source/common/textures/formats/ddstexture.cpp diff --git a/source/core/textures/formats/jpegtexture.cpp b/source/common/textures/formats/jpegtexture.cpp similarity index 100% rename from source/core/textures/formats/jpegtexture.cpp rename to source/common/textures/formats/jpegtexture.cpp diff --git a/source/core/textures/formats/pcxtexture.cpp b/source/common/textures/formats/pcxtexture.cpp similarity index 100% rename from source/core/textures/formats/pcxtexture.cpp rename to source/common/textures/formats/pcxtexture.cpp diff --git a/source/core/textures/formats/pngtexture.cpp b/source/common/textures/formats/pngtexture.cpp similarity index 100% rename from source/core/textures/formats/pngtexture.cpp rename to source/common/textures/formats/pngtexture.cpp diff --git a/source/core/textures/formats/stb_image.h b/source/common/textures/formats/stb_image.h similarity index 100% rename from source/core/textures/formats/stb_image.h rename to source/common/textures/formats/stb_image.h diff --git a/source/core/textures/formats/stbtexture.cpp b/source/common/textures/formats/stbtexture.cpp similarity index 100% rename from source/core/textures/formats/stbtexture.cpp rename to source/common/textures/formats/stbtexture.cpp diff --git a/source/core/textures/formats/tgatexture.cpp b/source/common/textures/formats/tgatexture.cpp similarity index 100% rename from source/core/textures/formats/tgatexture.cpp rename to source/common/textures/formats/tgatexture.cpp diff --git a/source/core/textures/image.cpp b/source/common/textures/image.cpp similarity index 100% rename from source/core/textures/image.cpp rename to source/common/textures/image.cpp diff --git a/source/core/textures/image.h b/source/common/textures/image.h similarity index 100% rename from source/core/textures/image.h rename to source/common/textures/image.h diff --git a/source/core/textures/formats/arttexture.cpp b/source/core/textures/formats/arttexture.cpp deleted file mode 100644 index 35de68b95..000000000 --- a/source/core/textures/formats/arttexture.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* -** arttexture.cpp -** Texture class for ART-based hightiles -** -**--------------------------------------------------------------------------- -** Copyright 2019 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 "files.h" -#include "templates.h" -#include "bitmap.h" -#include "image.h" -#include "palettecontainer.h" - -#include "build.h" - -#if 0 -//========================================================================== -// -// an AET texture -// -//========================================================================== - -class FArtTexture : public FImageSource -{ - -public: - FArtTexture (int width, int height, int p); - void CreatePalettedPixels(uint8_t* buffer) override; - int CopyPixels(FBitmap *bmp, int conversion) override; - int32_t picanmdisk; // Todo: Get this out again on the other side. -}; - -//========================================================================== -// -// -// -//========================================================================== - -FImageSource *ArtImage_TryCreate(FileReader & file) -{ - auto buffer = file.Read(); - - // Cannot load if smaller than the header. - if (buffer.Size() < ARTv1_UNITOFFSET) return nullptr; - uint32_t* header = (uint32_t *) buffer.Data(); - int ver = LittleLong(header[0]); - if (ver != 1) return nullptr; - - // Only allow files with one tile. - int firsttile = LittleLong(header[1]); - int lasttile = LittleLong(header[2]); - if (firsttile != lasttile) return nullptr; - - int32_t picanmdisk = LittleLong(header[5]); - int Width = LittleShort(B_UNBUF16(&buffer[16])); - int Height = LittleShort(B_UNBUF16(&buffer[18])); - - if (Width <= 0 || Height <= 0) - { - return nullptr; - } - - int32_t NumPixels = Width * Height; - - if (ARTv1_UNITOFFSET + NumPixels > (int)buffer.Size()) - { - return nullptr; - } - - return new FArtTexture(Width, Height, picanmdisk); -} - -//========================================================================== -// -// -// -//========================================================================== - -FArtTexture::FArtTexture(int width, int height, int p) -{ - Width = width; - Height = height; - picanmdisk = p; -} - -//========================================================================== -// -// This will never be called by the software renderer but let's be safe. -// -//========================================================================== - -void FArtTexture::CreatePalettedPixels(uint8_t* buffer) -{ - FileReader fr = fileSystem.OpenFileReader(Name); - if (!fr.isOpen()) return; - int numpixels = Width * Height; - fr.Read(buffer, numpixels); - auto remap = GPalette.Remap; - for (int i = 0; i < numpixels; i++) - { - buffer[i] = remap[buffer[i]]; - } -} - -//=========================================================================== -// -// FArtTexture::CopyPixels -// -// This format is special because it ignores the game palettes and -// only outputs a true color image with the primary palette. -// -//=========================================================================== - -int FArtTexture::CopyPixels(FBitmap *bmp, int conversion) -{ - // Treat both buffer as linear contiguous blocks. - // Both Src and Dst are ordered the same with no padding. - int numpixels = Width * Height; - bool hasalpha = false; - FileReader fr = fileSystem.OpenFileReader(Name); - if (!fr.isOpen()) return 0; - TArray source(numpixels, true); - fr.Read(source.Data(), numpixels); - auto dest = bmp->GetPixels(); - - auto remap = GPalette.Remap; - auto pal = GPalette.BaseColors; - for (int y = 0; y < numpixels; ++y) - { - int index = remap[source[y]]; - if (index == TRANSPARENT_INDEX) - { - hasalpha = true; - continue; - } - - dest[0] = pal[index].b; - dest[1] = pal[index].g; - dest[2] = pal[index].r; - dest[3] = 255; - dest += 4; - } - bMasked = hasalpha; - return 0; -} - -#endif \ No newline at end of file