Skip to content

Commit

Permalink
minor fixes + pixel opacity fix for megachip
Browse files Browse the repository at this point in the history
  • Loading branch information
coornio committed Jan 15, 2025
1 parent c1f0614 commit aae259f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Assistants/Typedefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ struct alignas(4) RGBA {
constexpr u32 BRG_() const noexcept { return B << 24 | R << 16 | G << 8 | 0; }
constexpr u32 BGR_() const noexcept { return B << 24 | G << 16 | R << 8 | 0; }

constexpr u32 RBGA() const noexcept { return R << 24 | B << 16 | G << 8 | 0; }
constexpr u32 GRBA() const noexcept { return G << 24 | R << 16 | B << 8 | 0; }
constexpr u32 GBRA() const noexcept { return G << 24 | B << 16 | R << 8 | 0; }
constexpr u32 BRGA() const noexcept { return B << 24 | R << 16 | G << 8 | 0; }
constexpr u32 BGRA() const noexcept { return B << 24 | G << 16 | R << 8 | 0; }
constexpr u32 RBGA() const noexcept { return R << 24 | B << 16 | G << 8 | A; }
constexpr u32 GRBA() const noexcept { return G << 24 | R << 16 | B << 8 | A; }
constexpr u32 GBRA() const noexcept { return G << 24 | B << 16 | R << 8 | A; }
constexpr u32 BRGA() const noexcept { return B << 24 | R << 16 | G << 8 | A; }
constexpr u32 BGRA() const noexcept { return B << 24 | G << 16 | R << 8 | A; }
constexpr operator u32() const noexcept { return R << 24 | G << 16 | B << 8 | A; }
};

Expand Down
7 changes: 3 additions & 4 deletions src/Systems/CHIP8/Cores/MEGACHIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,19 @@ void MEGACHIP::initializeFontColors() noexcept {
RGBA MEGACHIP::blendPixel(RGBA src, RGBA dst) const noexcept {
src.A = IntColorMult(src.A, mTexture.opacity);
if (src.A == 0x0) [[unlikely]] { return dst; }

RGBA out{
intBlendAlgo(src.R, dst.R),
intBlendAlgo(src.G, dst.G),
intBlendAlgo(src.B, dst.B)
intBlendAlgo(src.B, dst.B),
};

if (src.A < 0xFF) {
const auto dW{ static_cast<u8>(~src.A) };

out.R = 0xFF & IntColorMult(dst.R, dW) + IntColorMult(out.R, src.A);
out.G = 0xFF & IntColorMult(dst.G, dW) + IntColorMult(out.G, src.A);
out.B = 0xFF & IntColorMult(dst.B, dW) + IntColorMult(out.B, src.A);
out.A = 0xFF & std::min(src.A + ((dst.A * dW) >> 8), 0xFF);
}

return out;
Expand Down
1 change: 0 additions & 1 deletion src/Systems/CHIP8/Cores/MEGACHIP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MEGACHIP final : public Chip8_CoreInterface {
MULTIPLY = 5,
};

//f32(*fpBlendAlgorithm)(const f32 src, const f32 dst) noexcept {};
u8(*intBlendAlgo)(const u8 src, const u8 dst) noexcept {};

void setNewBlendAlgorithm(const s32 mode) noexcept;
Expand Down

0 comments on commit aae259f

Please sign in to comment.