openMSX
Multiply32.hh
Go to the documentation of this file.
1#ifndef MULTIPLY32_HH
2#define MULTIPLY32_HH
3
4#include <bit>
5#include <concepts>
6#include <cstdint>
7
8namespace openmsx {
9
10template<std::unsigned_integral Pixel> class PixelOperations;
11
16template<std::unsigned_integral Pixel> class Multiply32;
17
18template<> class Multiply32<uint32_t>
19{
20public:
22
23 inline void setFactor32(unsigned f)
24 {
25 factor = f;
26 }
27
28 [[nodiscard]] inline uint32_t mul32(uint32_t p) const
29 {
30 return ((((p & 0x00FF00FF) * factor) & 0xFF00FF00) >> 8)
31 | ((((p >> 8) & 0x00FF00FF) * factor) & 0xFF00FF00);
32 }
33
34 [[nodiscard]] inline uint32_t conv32(uint32_t p) const
35 {
36 return p;
37 }
38
39private:
40 unsigned factor;
41};
42
43template<> class Multiply32<uint16_t>
44{
45public:
46 explicit Multiply32(const PixelOperations<uint16_t>& pixelOps);
47
48 void setFactor32(unsigned factor);
49
50 [[nodiscard]] inline uint32_t mul32(uint16_t p) const
51 {
52 return tab[p];
53 }
54
55 [[nodiscard]] inline uint16_t conv32(uint32_t p) const
56 {
57 return (std::rotr(p, Rshift3) & Rmask1) |
58 (std::rotr(p, Gshift3) & Gmask1) |
59 (std::rotr(p, Bshift3) & Bmask1);
60 }
61
62private:
63 uint32_t tab[0x10000];
64 unsigned factor;
65 unsigned Rshift1, Gshift1, Bshift1;
66 unsigned Rshift2, Gshift2, Bshift2;
67 unsigned Rshift3, Gshift3, Bshift3;
68 uint16_t Rmask1, Gmask1, Bmask1;
69 uint16_t Rmask2, Gmask2, Bmask2;
70};
71
72} // namespace openmsx
73
74#endif
uint16_t conv32(uint32_t p) const
Definition: Multiply32.hh:55
uint32_t mul32(uint16_t p) const
Definition: Multiply32.hh:50
uint32_t mul32(uint32_t p) const
Definition: Multiply32.hh:28
uint32_t conv32(uint32_t p) const
Definition: Multiply32.hh:34
void setFactor32(unsigned f)
Definition: Multiply32.hh:23
Helper class to perform 'pixel x scalar' calculations.
Definition: Multiply32.hh:16
void format(SectorAccessibleDisk &disk, bool dos1)
Format the given disk (= a single partition).
This file implemented 3 utility functions:
Definition: Autofire.cc:9