diff --git a/src/gx/Texture.cpp b/src/gx/Texture.cpp index fc76162..929b79d 100644 --- a/src/gx/Texture.cpp +++ b/src/gx/Texture.cpp @@ -20,7 +20,6 @@ namespace Texture { int32_t s_createBlpAsync; // Invented name MipBits* s_mipBits; int32_t s_mipBitsValid; - size_t s_mipBitsSize; TSHashTable s_textureCache; EGxTexFormat s_pixelFormatToGxTexFormat[10] = { @@ -381,28 +380,6 @@ MipBits* TextureAllocMippedImg(PIXEL_FORMAT pixelFormat, uint32_t width, uint32_ return nullptr; } -bool MippedImgSet(MipBits* image, uint32_t fourCC, uint32_t width, uint32_t height) { - uint32_t levelCount = CalcLevelCount(width, height); - uint32_t levelDataSize = CalcLevelOffset(levelCount, width, height, fourCC); - size_t imageSize = (sizeof(MipBits::mip) * levelCount) + levelDataSize + MIPPED_IMG_ALIGN; - - if (Texture::s_mipBitsSize && imageSize > Texture::s_mipBitsSize) { - return false; - } - - auto imageData = reinterpret_cast(image); - auto mipBase = imageData + (sizeof(MipBits::mip) * levelCount); - auto alignedMipBase = static_cast(ALIGN_PTR(mipBase, MIPPED_IMG_ALIGN)); - - uint32_t levelOffset = 0; - for (int32_t level = 0; level < levelCount; level++) { - image->mip[level] = reinterpret_cast(alignedMipBase + levelOffset); - levelOffset += CalcLevelSize(level, width, height, fourCC); - } - - return true; -} - void GxTexUpdate(CGxTex* texId, int32_t minX, int32_t minY, int32_t maxX, int32_t maxY, int32_t immediate) { CiRect rect = { minY, minX, maxY, maxX }; GxTexUpdate(texId, rect, immediate); @@ -669,11 +646,6 @@ int32_t PumpBlpTextureAsync(CTexture* texture, void* buf) { GetTextureFormats(&pixFormat, &gxTexFormat, preferredFormat, alphaSize); - if (image.m_header.colorEncoding == COLOR_PAL) { - pixFormat = PIXEL_ARGB8888; - gxTexFormat = GxTex_Argb8888; - } - int32_t mipLevel = texture->bestMip; Texture::s_mipBitsValid = 1; @@ -1151,7 +1123,6 @@ void TextureIncreasePriority(CTexture* texture) { void TextureInitialize() { uint32_t v0 = MippedImgCalcSize(2, 1024, 1024); Texture::s_mipBits = reinterpret_cast(SMemAlloc(v0, __FILE__, __LINE__, 0)); - Texture::s_mipBitsSize = v0; // TODO // - rest of function diff --git a/src/gx/blp/CBLPFile.cpp b/src/gx/blp/CBLPFile.cpp index 0b2b8ad..dcfe90c 100644 --- a/src/gx/blp/CBLPFile.cpp +++ b/src/gx/blp/CBLPFile.cpp @@ -29,67 +29,8 @@ int32_t CBLPFile::Lock2(const char* fileName, PIXEL_FORMAT format, uint32_t mipL switch (this->m_header.colorEncoding) { case COLOR_PAL: - if (format != PIXEL_ARGB8888) { - return 0; - } - - { - uint32_t width = this->m_header.width >> mipLevel; - uint32_t height = this->m_header.height >> mipLevel; - - if (!width) { - width = 1; - } - - if (!height) { - height = 1; - } - - uint32_t pixelCount = width * height; - auto indices = reinterpret_cast(mipData); - const uint8_t* alpha = nullptr; - - if (this->m_header.alphaSize) { - alpha = indices + pixelCount; - } - - const BlpPalPixel* palette = this->m_header.extended.palette; - auto out = reinterpret_cast(data); - - for (uint32_t i = 0; i < pixelCount; ++i) { - const auto& pal = palette[indices[i]]; - uint8_t a = 0xFF; - - switch (this->m_header.alphaSize) { - case 1: { - uint8_t byte = alpha[i >> 3]; - a = ((byte >> (i & 7)) & 0x1) ? 0xFF : 0x00; - break; - } - - case 4: { - uint8_t byte = alpha[i >> 1]; - uint8_t nibble = (i & 1) ? (byte >> 4) : (byte & 0x0F); - a = static_cast((nibble << 4) | nibble); - break; - } - - case 8: - a = alpha[i]; - break; - - default: - break; - } - - out[i] = (static_cast(a) << 24) - | (static_cast(static_cast(pal.r)) << 16) - | (static_cast(static_cast(pal.g)) << 8) - | static_cast(static_cast(pal.b)); - } - } - - return 1; + // TODO + return 0; case COLOR_DXT: switch (format) { @@ -155,9 +96,9 @@ int32_t CBLPFile::LockChain2(const char* fileName, PIXEL_FORMAT format, MipBits* v14 = 1; } - if (!MippedImgSet(images, format, v14, v13)) { - return 0; - } + + // TODO + // MippedImgSet(format, v14, v13, mipLevel); } else { uint32_t v9 = this->m_header.height >> mipLevel;