From a1fc6809e7701698d48de0d52dedeb79a3a81ffc Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 10 Nov 2026 22:48:05 +0000 Subject: [PATCH] Decompile fn_01869 (CDCSurface::DrawScaledSprite) Batch #16604 by eAthena: 1 byte-identical, 0 confirmed by peer review. - fn_01869 CDCSurface::DrawScaledSprite: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/Render/DeviceContext/DCBitmap.h | 4 +- Source/Render/DeviceContext/DCSurface.cpp | 4 +- Source/Render/DeviceContext/DCSurface.h | 4 +- Source/Render/DeviceContext/DeviceContext.h | 4 +- Source/Render/Textures/BitmapPixels.cpp | 35 +++++++++-------- Source/UI/Window/UIWindow.cpp | 42 ++++----------------- 6 files changed, 34 insertions(+), 59 deletions(-) diff --git a/Source/Render/DeviceContext/DCBitmap.h b/Source/Render/DeviceContext/DCBitmap.h index 168437165..b5ad767c3 100644 --- a/Source/Render/DeviceContext/DCBitmap.h +++ b/Source/Render/DeviceContext/DCBitmap.h @@ -29,8 +29,8 @@ public: void Fill(const RECT* rectangle, std::uint32_t color) override; void Draw(CRenderSystemBase& system, int x, int y, int width, int height, std::uint32_t color) override; void DrawScaledSprite( - int x, int y, int width, int height, std::span cells, const SpriteRleImage* const* const* images, int cellCount, int offsetX, - int offsetY, float scale, const std::uint32_t* palette + int x, int y, int width, int height, const CSprRes* sprite, const ActionFrame* frame, int offsetX, int offsetY, float scale, + const std::uint32_t* palette ) override; void DrawScaledSurface( int x, int y, int width, int height, CSurface* source, int sourceWidth, int sourceHeight, float scaleX, float scaleY, std::uint32_t color, bool mirrored, diff --git a/Source/Render/DeviceContext/DCSurface.cpp b/Source/Render/DeviceContext/DCSurface.cpp index 7d5b6743a..ec9a2395d 100644 --- a/Source/Render/DeviceContext/DCSurface.cpp +++ b/Source/Render/DeviceContext/DCSurface.cpp @@ -266,9 +266,7 @@ void CDCSurface::DrawSurface(int, int, CSurface*, int, int, int, int, bool, int, // OFFSET: 0x00549220 // FUNCTION: fn_01869 -void CDCSurface::DrawScaledSprite( - int, int, int, int, std::span, const SpriteRleImage* const* const*, int, int, int, float, const std::uint32_t* -) { +void CDCSurface::DrawScaledSprite(int, int, int, int, const CSprRes*, const ActionFrame*, int, int, float, const std::uint32_t*) { } // OFFSET: 0x00549250 diff --git a/Source/Render/DeviceContext/DCSurface.h b/Source/Render/DeviceContext/DCSurface.h index cdb6e407d..e142e2f0c 100644 --- a/Source/Render/DeviceContext/DCSurface.h +++ b/Source/Render/DeviceContext/DCSurface.h @@ -74,8 +74,8 @@ public: void Fill(const RECT* rectangle, std::uint32_t color) override; void Draw(CRenderSystemBase& system, int x, int y, int width, int height, std::uint32_t color) override; void DrawScaledSprite( - int x, int y, int width, int height, std::span cells, const SpriteRleImage* const* const* images, int cellCount, int offsetX, - int offsetY, float scale, const std::uint32_t* palette + int x, int y, int width, int height, const CSprRes* sprite, const ActionFrame* frame, int offsetX, int offsetY, float scale, + const std::uint32_t* palette ) override; void DrawScaledSurface( int x, int y, int width, int height, CSurface* source, int sourceWidth, int sourceHeight, float scaleX, float scaleY, std::uint32_t color, bool mirrored, diff --git a/Source/Render/DeviceContext/DeviceContext.h b/Source/Render/DeviceContext/DeviceContext.h index 8db7723dd..0d80be11f 100644 --- a/Source/Render/DeviceContext/DeviceContext.h +++ b/Source/Render/DeviceContext/DeviceContext.h @@ -35,8 +35,8 @@ public: virtual void Fill(const RECT* rectangle, std::uint32_t color) = 0; virtual void Draw(CRenderSystemBase& system, int x, int y, int width, int height, std::uint32_t color) = 0; virtual void DrawScaledSprite( - int x, int y, int width, int height, std::span cells, const SpriteRleImage* const* const* images, int cellCount, int offsetX, - int offsetY, float scale, const std::uint32_t* palette + int x, int y, int width, int height, const CSprRes* sprite, const ActionFrame* frame, int offsetX, int offsetY, float scale, + const std::uint32_t* palette ) = 0; virtual void DrawScaledSurface( int x, int y, int width, int height, CSurface* source, int sourceWidth, int sourceHeight, float scaleX, float scaleY, std::uint32_t color, bool mirrored, diff --git a/Source/Render/Textures/BitmapPixels.cpp b/Source/Render/Textures/BitmapPixels.cpp index b25844967..c6a1baf41 100644 --- a/Source/Render/Textures/BitmapPixels.cpp +++ b/Source/Render/Textures/BitmapPixels.cpp @@ -766,32 +766,37 @@ void CDCBitmap::DrawRleSprite(int x, int y, const CSprRes& sprite, const ActionF // OFFSET: 0x00545C40 // FUNCTION: fn_01837 void CDCBitmap::DrawScaledSprite( - int x, int y, int drawWidth, int drawHeight, std::span cells, const SpriteRleImage* const* const* images, int cellCount, int offsetX, - int offsetY, float scale, const std::uint32_t* palette + int x, int y, int drawWidth, int drawHeight, const CSprRes* sprite, const ActionFrame* frame, int offsetX, int offsetY, float scale, + const std::uint32_t* palette ) { - if (!images) { + if (!sprite || !frame) { return; } - const SpriteFrameCell missing{0, 0, -1, 0, 0xFFFFFFFF, 1, 1, 0, 0}; + if (!palette) { + palette = sprite->palette; + } + SpriteAtlasRecord record{}; - for (int index = 0; index < cellCount; ++index) { - const SpriteFrameCell& cell = static_cast(index) < cells.size() ? cells[index] : missing; - if (cell.image == -1) { + for (int index = 0; index < frame->cellCount; ++index) { + const SpriteFrameCell* cell = &frame->Cell(index); + if (!cell || cell->image == -1) { continue; } - const SpriteRleImage* image = images[cell.imageType][cell.image]; + const SpriteRleImage* image = sprite->images[cell->imageType][cell->image]; if (!image) { continue; } - const float scaleX = scale * cell.scaleX; - const float scaleY = scale * cell.scaleY; + const float scaleX = scale * cell->scaleX; + const float scaleY = scale * cell->scaleY; + record.u0 = 0; + record.v0 = 0; CSurface* surface; - if (!cell.imageType) { + if (!cell->imageType) { surface = g_renderer->atlas.Find(image, palette, record); if (!surface) { surface = g_renderer->atlas.Insert(*GetRenderSystemHolder()->system, image, palette, record, g_serviceType, g_resourceReuseDelay); @@ -804,12 +809,12 @@ void CDCBitmap::DrawScaledSprite( continue; } - const std::uint8_t* channels = reinterpret_cast(&cell.color); + const std::uint8_t* channels = reinterpret_cast(&cell->color); const std::uint32_t color = PackPixel(channels[3], channels[0], channels[1], channels[2]); this->DrawScaledSurface( - x, y, drawWidth, drawHeight, surface, image->width, image->height, scaleX, scaleY, color, cell.mirrored != 0, - static_cast(static_cast(cell.x) * scaleX + static_cast(offsetX)), - static_cast(static_cast(cell.y) * scaleY + static_cast(offsetY)), static_cast(record.u0 * 256), static_cast(record.v0 * 256) + x, y, drawWidth, drawHeight, surface, image->width, image->height, scaleX, scaleY, color, cell->mirrored != 0, + static_cast(static_cast(cell->x) * scaleX + static_cast(offsetX)), + static_cast(static_cast(cell->y) * scaleY + static_cast(offsetY)), static_cast(record.u0 * 256), static_cast(record.v0 * 256) ); } } diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index b5d9db093..25c275cb3 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -3293,11 +3293,7 @@ void UIWindow::DrawActionSprite( } if (frames.size() > static_cast(index)) { - const ActionFrame& frame = frames[index]; - const SpriteRleImage* const* images[2] = {sprite->images[0].data(), sprite->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x, y, width, height, std::span(frame.cells), images, frame.cellCount, offsetX, offsetY, scale, sprite->palette - ); + this->geometry.surface->DrawScaledSprite(x, y, width, height, sprite, &frames[index], offsetX, offsetY, scale, nullptr); } } @@ -3710,10 +3706,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co if (robeFrames && !robeFrames->empty()) { const ActionFrame* robeFrame = &(*robeFrames)[bodyFrame]; if (robeFrame) { - const SpriteRleImage* const* images[2] = {sprites[8]->images[0].data(), sprites[8]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x, y, width, height, std::span(robeFrame->cells), images, robeFrame->cellCount, offsetX, offsetY, scale, sprites[8]->palette - ); + this->geometry.surface->DrawScaledSprite(x, y, width, height, sprites[8], robeFrame, offsetX, offsetY, scale, nullptr); } } } @@ -3730,12 +3723,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co } const ActionFrame* body = &(*bodyFrames)[bodyFrame]; - { - const SpriteRleImage* const* images[2] = {sprites[0]->images[0].data(), sprites[0]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x, y, width, height, std::span(body->cells), images, body->cellCount, offsetX, offsetY, 1.0f, bodyPalette - ); - } + this->geometry.surface->DrawScaledSprite(x, y, width, height, sprites[0], body, offsetX, offsetY, 1.0f, bodyPalette); actions[1] = static_cast(ResourceMgr::Instance().Load(g_session.GetHeadActName(look.job, look.sex, &look.head))); sprites[1] = static_cast(ResourceMgr::Instance().Load(g_session.GetHeadSprName(look.job, look.sex, &look.head))); @@ -3751,11 +3739,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co headPalette = static_cast(ResourceMgr::Instance().Load(paletteName.c_str()))->palette; } - const SpriteRleImage* const* images[2] = {sprites[1]->images[0].data(), sprites[1]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x + headX, y + headY, width, height, std::span(headFrame->cells), images, headFrame->cellCount, offsetX, offsetY, scale, - headPalette - ); + this->geometry.surface->DrawScaledSprite(x + headX, y + headY, width, height, sprites[1], headFrame, offsetX, offsetY, scale, headPalette); } } @@ -3774,11 +3758,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co const ActionFrame* frame = &(*accessoryFrames)[accessoryFrame0]; const int accessoryX = body->anchors[0].x - frame->anchors[0].x; const int accessoryY = body->anchors[0].y - frame->anchors[0].y; - const SpriteRleImage* const* images[2] = {sprites[2]->images[0].data(), sprites[2]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x + accessoryX, y + accessoryY, width, height, std::span(frame->cells), images, frame->cellCount, offsetX, offsetY, - scale, sprites[2]->palette - ); + this->geometry.surface->DrawScaledSprite(x + accessoryX, y + accessoryY, width, height, sprites[2], frame, offsetX, offsetY, scale, nullptr); } } } @@ -3798,11 +3778,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co const ActionFrame* frame = &(*accessoryFrames)[accessoryFrame1]; const int accessoryX = body->anchors[0].x - frame->anchors[0].x; const int accessoryY = body->anchors[0].y - frame->anchors[0].y; - const SpriteRleImage* const* images[2] = {sprites[3]->images[0].data(), sprites[3]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x + accessoryX, y + accessoryY, width, height, std::span(frame->cells), images, frame->cellCount, offsetX, offsetY, - scale, sprites[3]->palette - ); + this->geometry.surface->DrawScaledSprite(x + accessoryX, y + accessoryY, width, height, sprites[3], frame, offsetX, offsetY, scale, nullptr); } } } @@ -3822,11 +3798,7 @@ void UINavigationV4Wnd::DrawTargetSprite(int x, int y, int width, int height, co const ActionFrame* frame = &(*accessoryFrames)[accessoryFrame2]; const int accessoryX = body->anchors[0].x - frame->anchors[0].x; const int accessoryY = body->anchors[0].y - frame->anchors[0].y; - const SpriteRleImage* const* images[2] = {sprites[4]->images[0].data(), sprites[4]->images[1].data()}; - this->geometry.surface->DrawScaledSprite( - x + accessoryX, y + accessoryY, width, height, std::span(frame->cells), images, frame->cellCount, offsetX, offsetY, - scale, sprites[4]->palette - ); + this->geometry.surface->DrawScaledSprite(x + accessoryX, y + accessoryY, width, height, sprites[4], frame, offsetX, offsetY, scale, nullptr); } } }