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.
This commit is contained in:
ragnarok-clanker 2026-11-10 22:48:05 +00:00
commit a1fc6809e7
6 changed files with 34 additions and 59 deletions

View file

@ -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<const SpriteFrameCell> 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,

View file

@ -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 SpriteFrameCell>, 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

View file

@ -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<const SpriteFrameCell> 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,

View file

@ -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<const SpriteFrameCell> 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,

View file

@ -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<const SpriteFrameCell> 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<unsigned>(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<const std::uint8_t*>(&cell.color);
const std::uint8_t* channels = reinterpret_cast<const std::uint8_t*>(&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<int>(static_cast<float>(cell.x) * scaleX + static_cast<float>(offsetX)),
static_cast<int>(static_cast<float>(cell.y) * scaleY + static_cast<float>(offsetY)), static_cast<int>(record.u0 * 256), static_cast<int>(record.v0 * 256)
x, y, drawWidth, drawHeight, surface, image->width, image->height, scaleX, scaleY, color, cell->mirrored != 0,
static_cast<int>(static_cast<float>(cell->x) * scaleX + static_cast<float>(offsetX)),
static_cast<int>(static_cast<float>(cell->y) * scaleY + static_cast<float>(offsetY)), static_cast<int>(record.u0 * 256), static_cast<int>(record.v0 * 256)
);
}
}

View file

@ -3293,11 +3293,7 @@ void UIWindow::DrawActionSprite(
}
if (frames.size() > static_cast<unsigned>(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<const SpriteFrameCell>(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<const SpriteFrameCell>(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<const SpriteFrameCell>(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<CActRes*>(ResourceMgr::Instance().Load(g_session.GetHeadActName(look.job, look.sex, &look.head)));
sprites[1] = static_cast<CSprRes*>(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<CPaletteRes*>(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<const SpriteFrameCell>(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<const SpriteFrameCell>(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<const SpriteFrameCell>(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<const SpriteFrameCell>(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);
}
}
}