From 184631ec9eefa3f53cf3fb55681983144979e76c Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 12 Nov 2026 13:44:19 +0000 Subject: [PATCH] Decompile fn_01854 (CDCBitmap::UpdateCache) Batch #18354 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_01854 CDCBitmap::UpdateCache: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, alisonrag, bibinir Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Render/DeviceContext/DCBitmap.h | 1 + Source/Render/Textures/BitmapTextureCache.cpp | 42 +++++++++---------- Source/Render/Textures/BitmapTextureCache.h | 1 - 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/Render/DeviceContext/DCBitmap.h b/Source/Render/DeviceContext/DCBitmap.h index edf3a56e0..48fc590af 100644 --- a/Source/Render/DeviceContext/DCBitmap.h +++ b/Source/Render/DeviceContext/DCBitmap.h @@ -39,6 +39,7 @@ public: void Brighten(int x, int y, int width, int height, int amount) override; void Dim(int x, int y, int width, int height, int percent) override; void UploadTexture(CTexture*& texture); + void UpdateCache(); HGDIOBJ Create(int width, int height); void ApplyPixelFilter(int filter, unsigned int* red, unsigned int* green, unsigned int* blue); void SetAlpha(unsigned char maxLuminance); diff --git a/Source/Render/Textures/BitmapTextureCache.cpp b/Source/Render/Textures/BitmapTextureCache.cpp index c02ce62b4..e7a6d31da 100644 --- a/Source/Render/Textures/BitmapTextureCache.cpp +++ b/Source/Render/Textures/BitmapTextureCache.cpp @@ -18,50 +18,50 @@ BitmapTextureCache::~BitmapTextureCache() { // OFFSET: 0x00548380 // FUNCTION: fn_01854 -void BitmapTextureCache::Update(BitmapPixels& bitmap) { - if (!bitmap.dirty) { +void CDCBitmap::UpdateCache() { + if (!this->m_bitmap.dirty) { return; } - if (this->m_alpha == true) { - if (this->m_textures.empty()) { - CTexture* texture = g_texMgr.CreateTexture(bitmap.width, bitmap.height, TextureFormat::A8R8G8B8, false, false); + if (this->m_cache.m_alpha == true) { + if (this->m_cache.m_textures.empty()) { + CTexture* texture = g_texMgr.CreateTexture(this->m_bitmap.width, this->m_bitmap.height, TextureFormat::A8R8G8B8, false, false); if (texture) { - this->m_textures.push_back(texture); + this->m_cache.m_textures.push_back(texture); } } - for (CTexture* texture : this->m_textures) { - texture->Upload(0, 0, bitmap.width, bitmap.height, bitmap.pixels, 0, bitmap.width); + for (CTexture* texture : this->m_cache.m_textures) { + texture->Upload(0, 0, this->m_bitmap.width, this->m_bitmap.height, this->m_bitmap.pixels, 0, this->m_bitmap.width); } } else { - if (this->m_textures.empty()) { - for (unsigned y = 0; y < bitmap.height; y += 256) { - for (unsigned x = 0; x < bitmap.width; x += 256) { - this->m_textures.push_back( - g_texMgr.CreateTexture(std::min(256u, bitmap.width - x), std::min(256u, bitmap.height - y), TextureFormat::A1R5G5B5, false, false) + if (this->m_cache.m_textures.empty()) { + for (unsigned y = 0; y < this->m_bitmap.height; y += 256) { + for (unsigned x = 0; x < this->m_bitmap.width; x += 256) { + this->m_cache.m_textures.push_back( + g_texMgr.CreateTexture(std::min(256u, this->m_bitmap.width - x), std::min(256u, this->m_bitmap.height - y), TextureFormat::A1R5G5B5, false, false) ); } } } - const std::int32_t bytes = static_cast(4u * bitmap.width * bitmap.height); + const std::int32_t bytes = static_cast(4u * this->m_bitmap.width * this->m_bitmap.height); for (std::int32_t offset = 0; offset < bytes; offset += 4) { - reinterpret_cast(bitmap.pixels)[offset + 3] = 255; + reinterpret_cast(this->m_bitmap.pixels)[offset + 3] = 255; } - auto texture = this->m_textures.begin(); + auto texture = this->m_cache.m_textures.begin(); - for (unsigned y = 0; y < bitmap.height; y += 256) { - for (unsigned x = 0; x < bitmap.width; x += 256) { - (*texture)->Upload(0, 0, std::min(256u, bitmap.width - x), std::min(256u, bitmap.height - y), bitmap.pixels + x + y * bitmap.width, 0, bitmap.width); + for (unsigned y = 0; y < this->m_bitmap.height; y += 256) { + for (unsigned x = 0; x < this->m_bitmap.width; x += 256) { + (*texture)->Upload(0, 0, std::min(256u, this->m_bitmap.width - x), std::min(256u, this->m_bitmap.height - y), this->m_bitmap.pixels + x + y * this->m_bitmap.width, 0, this->m_bitmap.width); ++texture; } } } - bitmap.dirty = false; + this->m_bitmap.dirty = false; } // OFFSET: 0x00547B80 @@ -71,7 +71,7 @@ void CDCBitmap::Draw(int x, int y, int width, int height, std::uint32_t color) { return; } - this->m_cache.Update(this->m_bitmap); + this->UpdateCache(); if (this->m_cache.m_textures.empty()) { return; } diff --git a/Source/Render/Textures/BitmapTextureCache.h b/Source/Render/Textures/BitmapTextureCache.h index 672cbd79a..1239af5a1 100644 --- a/Source/Render/Textures/BitmapTextureCache.h +++ b/Source/Render/Textures/BitmapTextureCache.h @@ -14,7 +14,6 @@ public: BitmapTextureCache(); ~BitmapTextureCache(); void Clear(); - void Update(BitmapPixels& bitmap); protected: friend class CDCBitmap;