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(pixelOps.getRmask())
22 , Gmask1(pixelOps.getGmask())
23 , Bmask1(pixelOps.getBmask())
24
25 , Rmask2(((1 << (2 + pixelOps.getRloss())) - 1) <<
26 (10 + pixelOps.getRshift() - 2 * (2 + pixelOps.getRloss())))
27 , Gmask2(((1 << (2 + pixelOps.getGloss())) - 1) <<
28 (10 + pixelOps.getGshift() - 2 * (2 + pixelOps.getGloss())))
29 , Bmask2(((1 << (2 + pixelOps.getBloss())) - 1) <<
30 (10 + pixelOps.getBshift() - 2 * (2 + pixelOps.getBloss())))
31{
32}
33
35{
36 if (factor == f) return;
37 factor = f;
38
39 for (auto [p, t] : enumerate(tab)) {
40 uint32_t r = std::rotl(uint16_t(p & Rmask1), Rshift1) |
41 std::rotl(uint16_t(p & Rmask2), Rshift2);
42 uint32_t g = std::rotl(uint16_t(p & Gmask1), Gshift1) |
43 std::rotl(uint16_t(p & Gmask2), Gshift2);
44 uint32_t b = std::rotl(uint16_t(p & Bmask1), Bshift1) |
45 std::rotl(uint16_t(p & Bmask2), Bshift2);
46 t = (((r * factor) >> 8) << 0) |
47 (((g * factor) >> 8) << 10) |
48 (((b * factor) >> 8) << 20);
49 }
50}
51
52} // 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(From from) noexcept
Definition: narrow.hh:37