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).
14 lines
795 B
C++
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);
|
|
}
|