rodecomp/Source/Render/BlendColor.cpp
ragnarok-clanker 3170364197 Decompile 3 functions in Source/Render/BlendColor.cpp, Source/Render/BlendColor.h, ...
Batch #11581 by cremane: 1 byte-identical, 2 confirmed by peer review.

- fn_02095 CRenderer::BlendColor: logic confirmed by peer review
- fn_02078 CRendererDX7::ClearWorld: logic confirmed by peer review
- fn_02215 CRendererDX9::ClearWorld: byte-identical

Peer-reviewed-by: Yommy, KWDev
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-05 03:41:18 +00:00

14 lines
795 B
C++

#include "Render/BlendColor.h"
// OFFSET: 0x0055CFC0
// FUNCTION: fn_02095
std::uint32_t CRenderer::BlendColor(std::uint32_t base, std::uint32_t overlay) {
const float alpha = static_cast<float>(overlay >> 24) / 255.0f;
const float inverse = 1.0f - alpha;
const auto channel = [](std::uint32_t color, unsigned shift) { return static_cast<float>((color >> shift) & 255u); };
const unsigned red = static_cast<unsigned>(channel(base, 16) * inverse + channel(overlay, 16) * alpha);
const unsigned green = static_cast<unsigned>(channel(overlay, 8) * alpha + channel(base, 8) * inverse);
const unsigned blue = static_cast<unsigned>(channel(base, 0) * inverse + channel(overlay, 0) * alpha);
return (base & 0xFF000000u) | ((red & 255u) << 16) | ((green & 255u) << 8) | (blue & 255u);
}