From aae259f421d5f8f044342915b861bb3745acac4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3=CF=84=CE=AD=CF=86=CE=B1=CE=BD=CE=BF=CF=82=20=22Coor?= =?UTF-8?q?nio/8924th=22=20=CE=92=CE=BB=CE=B1=CF=83=CF=84=CF=8C=CF=82?= <8924th@gmail.com> Date: Thu, 16 Jan 2025 01:37:27 +0200 Subject: [PATCH] minor fixes + pixel opacity fix for megachip --- src/Assistants/Typedefs.hpp | 10 +++++----- src/Systems/CHIP8/Cores/MEGACHIP.cpp | 7 +++---- src/Systems/CHIP8/Cores/MEGACHIP.hpp | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Assistants/Typedefs.hpp b/src/Assistants/Typedefs.hpp index bef4440..b28b172 100644 --- a/src/Assistants/Typedefs.hpp +++ b/src/Assistants/Typedefs.hpp @@ -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; } }; diff --git a/src/Systems/CHIP8/Cores/MEGACHIP.cpp b/src/Systems/CHIP8/Cores/MEGACHIP.cpp index 9da388c..4075322 100644 --- a/src/Systems/CHIP8/Cores/MEGACHIP.cpp +++ b/src/Systems/CHIP8/Cores/MEGACHIP.cpp @@ -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(~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; diff --git a/src/Systems/CHIP8/Cores/MEGACHIP.hpp b/src/Systems/CHIP8/Cores/MEGACHIP.hpp index 8645729..ceabb11 100644 --- a/src/Systems/CHIP8/Cores/MEGACHIP.hpp +++ b/src/Systems/CHIP8/Cores/MEGACHIP.hpp @@ -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;