openMSX
BitmapConverter.hh
Go to the documentation of this file.
1#ifndef BITMAPCONVERTER_HH
2#define BITMAPCONVERTER_HH
3
4#include "DisplayMode.hh"
5#include "openmsx.hh"
6#include <array>
7#include <concepts>
8#include <cstdint>
9#include <span>
10
11namespace openmsx {
12
13template<int N> struct DoublePixel;
14template<> struct DoublePixel<2> { using type = uint32_t; };
15template<> struct DoublePixel<4> { using type = uint64_t; };
16
19template<std::unsigned_integral Pixel>
21{
22public:
44 BitmapConverter(std::span<const Pixel, 16 * 2> palette16,
45 std::span<const Pixel, 256> palette256,
46 std::span<const Pixel, 32768> palette32768);
47
56 void convertLine(std::span<Pixel> buf, std::span<const byte, 128> vramPtr);
57
67 void convertLinePlanar(std::span<Pixel> buf,
68 std::span<const byte, 128> vramPtr0,
69 std::span<const byte, 128> vramPtr1);
70
74 inline void setDisplayMode(DisplayMode mode_)
75 {
76 mode = mode_;
77 }
78
81 inline void palette16Changed()
82 {
83 dPaletteValid = false;
84 }
85
86private:
87 void calcDPalette();
88
89 inline void renderGraphic4(std::span<Pixel, 256> buf,
90 std::span<const byte, 128> vramPtr0);
91 inline void renderGraphic5(std::span<Pixel, 512> buf,
92 std::span<const byte, 128> vramPtr0);
93 inline void renderGraphic6(std::span<Pixel, 512> buf,
94 std::span<const byte, 128> vramPtr0,
95 std::span<const byte, 128> vramPtr1);
96 inline void renderGraphic7(std::span<Pixel, 256> buf,
97 std::span<const byte, 128> vramPtr0,
98 std::span<const byte, 128> vramPtr1);
99 inline void renderYJK( std::span<Pixel, 256> buf,
100 std::span<const byte, 128> vramPtr0,
101 std::span<const byte, 128> vramPtr1);
102 inline void renderYAE( std::span<Pixel, 256> buf,
103 std::span<const byte, 128> vramPtr0,
104 std::span<const byte, 128> vramPtr1);
105 inline void renderBogus( std::span<Pixel, 256> buf);
106
107private:
108 std::span<const Pixel, 16 * 2> palette16;
109 std::span<const Pixel, 256> palette256;
110 std::span<const Pixel, 32768> palette32768;
111
112 using DPixel = typename DoublePixel<sizeof(Pixel)>::type;
113 std::array<DPixel, 16 * 16> dPalette;
114 DisplayMode mode;
115 bool dPaletteValid = false;
116};
117
118} // namespace openmsx
119
120#endif
Utility class for converting VRAM contents to host pixels.
void convertLine(std::span< Pixel > buf, std::span< const byte, 128 > vramPtr)
Convert a line of V9938 VRAM to 256 or 512 host pixels.
void setDisplayMode(DisplayMode mode_)
Select the display mode to use for scanline conversion.
void convertLinePlanar(std::span< Pixel > buf, std::span< const byte, 128 > vramPtr0, std::span< const byte, 128 > vramPtr1)
Convert a line of V9938 VRAM to 256 or 512 host pixels.
BitmapConverter(std::span< const Pixel, 16 *2 > palette16, std::span< const Pixel, 256 > palette256, std::span< const Pixel, 32768 > palette32768)
Create a new bitmap scanline converter.
void palette16Changed()
Inform this class about changes in the palette16 array.
Represents a VDP display mode.
Definition: DisplayMode.hh:16
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel