openMSX
Multiply32.cc
Go to the documentation of this file.
1#include "Multiply32.hh"
2#include "PixelOperations.hh"
3#include "enumerate.hh"
4#include "narrow.hh"
5
6namespace openmsx {
7
9 : Rshift1(narrow<int>(((2 + pixelOps.getRloss()) - pixelOps.getRshift()) & 31))
10 , Gshift1(narrow<int>(((2 + pixelOps.getGloss()) - pixelOps.getGshift()) & 31))
11 , Bshift1(narrow<int>(((2 + pixelOps.getBloss()) - pixelOps.getBshift()) & 31))
12
13 , Rshift2(narrow<int>((2 * (2 + pixelOps.getRloss()) - pixelOps.getRshift() - 10) & 31))
14 , Gshift2(narrow<int>((2 * (2 + pixelOps.getGloss()) - pixelOps.getGshift() - 10) & 31))
15 , Bshift2(narrow<int>((2 * (2 + pixelOps.getBloss()) - pixelOps.getBshift() - 10) & 31))
16
17 , Rshift3((Rshift1 + 0) & 31)
18 , Gshift3((Gshift1 + 10) & 31)
19 , Bshift3((Bshift1 + 20) & 31)
20
21 , Rmask1(narrow_cast<uint16_t>(pixelOps.getRmask()))
22 , Gmask1(narrow_cast<uint16_t>(pixelOps.getGmask()))
23 , Bmask1(narrow_cast<uint16_t>(pixelOps.getBmask()))
24
25 , Rmask2(narrow_cast<uint16_t>(
26 ((1 << (2 + pixelOps.getRloss())) - 1) <<
27 (10 + pixelOps.getRshift() - 2 * (2 + pixelOps.getRloss()))))
28 , Gmask2(narrow_cast<uint16_t>(
29 ((1 << (2 + pixelOps.getGloss())) - 1) <<
30 (10 + pixelOps.getGshift() - 2 * (2 + pixelOps.getGloss()))))
31 , Bmask2(narrow_cast<uint16_t>(
32 ((1 << (2 + pixelOps.getBloss())) - 1) <<
33 (10 + pixelOps.getBshift() - 2 * (2 + pixelOps.getBloss()))))
34{
35}
36
38{
39 if (factor == f) return;
40 factor = f;
41
42 for (auto [p, t] : enumerate(tab)) {
43 uint32_t r = std::rotl(uint16_t(p & Rmask1), Rshift1) |
44 std::rotl(uint16_t(p & Rmask2), Rshift2);
45 uint32_t g = std::rotl(uint16_t(p & Gmask1), Gshift1) |
46 std::rotl(uint16_t(p & Gmask2), Gshift2);
47 uint32_t b = std::rotl(uint16_t(p & Bmask1), Bshift1) |
48 std::rotl(uint16_t(p & Bmask2), Bshift2);
49 t = (((r * factor) >> 8) << 0) |
50 (((g * factor) >> 8) << 10) |
51 (((b * factor) >> 8) << 20);
52 }
53}
54
55} // namespace openmsx
int g
TclObject t
Helper class to perform 'pixel x scalar' calculations.
Definition: Multiply32.hh:17
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
Definition: enumerate.hh:28
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr To narrow_cast(From &&from) noexcept
Definition: narrow.hh:21
constexpr To narrow(From from) noexcept
Definition: narrow.hh:37