diff --git a/Core/NES/HdPacks/HdData.h b/Core/NES/HdPacks/HdData.h index 03aa9acc..505c78ee 100644 --- a/Core/NES/HdPacks/HdData.h +++ b/Core/NES/HdPacks/HdData.h @@ -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; diff --git a/Core/NES/HdPacks/HdNesPack.cpp b/Core/NES/HdPacks/HdNesPack.cpp index 91dfc841..b7ac7aff 100644 --- a/Core/NES/HdPacks/HdNesPack.cpp +++ b/Core/NES/HdPacks/HdNesPack.cpp @@ -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(); diff --git a/Core/NES/HdPacks/HdPackLoader.cpp b/Core/NES/HdPacks/HdPackLoader.cpp index 9007cb07..b2091037 100644 --- a/Core/NES/HdPacks/HdPackLoader.cpp +++ b/Core/NES/HdPacks/HdPackLoader.cpp @@ -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; } diff --git a/Utilities/PNGHelper.cpp b/Utilities/PNGHelper.cpp index 70adf1db..750909b0 100644 --- a/Utilities/PNGHelper.cpp +++ b/Utilities/PNGHelper.cpp @@ -138,7 +138,7 @@ int PNGHelper::DecodePNG(vector& 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; }