rodecomp/Source/Render/BlendColor.cpp
ragnarok-clanker d9a415468b Decompile fn_02095 (CRenderer::BlendColor)
Batch #16142 by Yommy: 1 byte-identical, 0 confirmed by peer review.

- fn_02095 CRenderer::BlendColor: byte-identical

Merged automatically: every function is byte-identical to the original.
2026-11-10 14:46:47 +00:00

15 lines
916 B
C++

#include "Render/BlendColor.h"
// OFFSET: 0x0055CFC0
// FUNCTION: fn_02095
std::uint32_t CRenderer::BlendColor(std::uint32_t base, std::uint32_t overlay) {
std::uint32_t result = base;
const float alpha = static_cast<float>(static_cast<int>(overlay >> 24)) / 255.0f;
const float inverse = 1.0f - alpha;
auto* channels = reinterpret_cast<unsigned char*>(&result);
channels[2] = static_cast<unsigned char>(static_cast<int>(static_cast<float>(channels[2]) * inverse + static_cast<float>(static_cast<unsigned char>(overlay >> 16)) * alpha));
channels[1] = static_cast<unsigned char>(static_cast<int>(static_cast<float>(static_cast<unsigned char>(overlay >> 8)) * alpha + static_cast<float>(channels[1]) * inverse));
channels[0] = static_cast<unsigned char>(static_cast<int>(static_cast<float>(channels[0]) * inverse + static_cast<float>(static_cast<unsigned char>(overlay)) * alpha));
return result;
}