NES: HD Packs - Fixed display issues (transparency, missing tiles)

This commit is contained in:
Sour 2023-03-02 19:11:59 -05:00
parent 90ae21e1ac
commit ace23978f7
4 changed files with 7 additions and 2 deletions

View file

@ -318,7 +318,7 @@ public:
uint32_t* pngData = Bitmap->PixelData.data();
HdTileData.resize(Width * Height);
if(Bitmap->PixelData.size() >= bitmapOffset + (Height * Bitmap->Width) + Width) {
if(Bitmap->PixelData.size() >= bitmapOffset + ((Height - 1) * Bitmap->Width) + Width) {
for(uint32_t y = 0; y < Height; y++) {
memcpy(HdTileData.data() + (y * Width), pngData + bitmapOffset, Width * sizeof(uint32_t));
bitmapOffset += Bitmap->Width;

View file

@ -156,6 +156,10 @@ void HdNesPack::OnLineStart(HdPpuPixelInfo &lineFirstPixel, uint8_t y)
for(int layer = 0; layer < 4; layer++) {
for(int i = 0; i < _activeBgCount[layer]; i++) {
HdBgConfig& cfg = _bgConfig[layer * HdNesPack::PriorityLevelsPerLayer + i];
if(cfg.BackgroundIndex < 0) {
continue;
}
HdBackgroundInfo& bgInfo = _hdData->Backgrounds[cfg.BackgroundIndex];
bgInfo.Data->Init();

View file

@ -237,6 +237,7 @@ bool HdPackLoader::ProcessImgTag(string src)
MessageManager::Log("[HDPack] Error loading HDPack: PNG file " + src + " could not be read.");
return false;
}
bitmapInfo.PngName = src;
return true;
}

View file

@ -138,7 +138,7 @@ int PNGHelper::DecodePNG(vector<T>& out_image, unsigned long& image_width, unsig
out_image.resize(out_size / sizeof(T));
if((r = spng_decode_image(ctx, (unsigned char*)out_image.data(), out_size, fmt, 0))) {
if((r = spng_decode_image(ctx, (unsigned char*)out_image.data(), out_size, fmt, SPNG_DECODE_TRNS))) {
spng_ctx_free(ctx);
return r;
}