OXYGENHUB
◆ main openmsx / src / video / v9990 / V9990BitmapConverter.hh
2.0 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef V9990BITMAPCONVERTER_HH
2
#define V9990BITMAPCONVERTER_HH
3
4
#include "V9990ModeEnum.hh"
5
#include "one_of.hh"
6
#include <cstdint>
7
#include <span>
8
9
namespace openmsx {
10
11
class V9990;
12
class V9990VRAM;
13
14
/** Utility class to convert VRAM content to host pixels.
15
  */
16
class V9990BitmapConverter
17
{
18
public:
19
	using Pixel = uint32_t;
20
21
	V9990BitmapConverter(
22
		V9990& vdp,
23
		std::span<const Pixel,    64> palette64,  std::span<const int16_t,  64> palette64_32768,
24
		std::span<const Pixel,   256> palette256, std::span<const int16_t, 256> palette256_32768,
25
		std::span<const Pixel, 32768> palette32768);
26
27
	/** Convert a line of VRAM into host pixels.
28
	  */
29
	void convertLine(std::span<Pixel> dst, unsigned x, unsigned y,
30
		         int cursorY, bool drawCursors) const;
31
32
	/** Set a different rendering mode.
33
	  */
34
	void setColorMode(V9990ColorMode colorMode_, V9990DisplayMode display) {
35
		colorMode = colorMode_;
36
		highRes = isHighRes(display);
37
	}
38
39
private:
40
	[[nodiscard]] static bool isHighRes(V9990DisplayMode display) {
41
		using enum V9990DisplayMode;
42
		return display == one_of(B4, B5, B6, B7);
43
	}
44
45
private:
46
	/** Reference to VDP
47
	  */
48
	V9990& vdp;
49
50
	/** Reference to VDP VRAM
51
	  */
52
	V9990VRAM& vram;
53
54
	/** The 64 color palette for P1, P2 and BP* modes
55
	  * This is the palette manipulated through the palette port and register
56
	  */
57
	std::span<const Pixel, 64> const palette64;
58
	std::span<const int16_t, 64> const palette64_32768;
59
60
	/** The 256 color palette for BD8 mode
61
	  * A fixed palette; sub-color space within the 32768 color palette
62
	  */
63
	std::span<const Pixel, 256> const palette256;
64
	std::span<const int16_t, 256> const palette256_32768;
65
66
	/** The 15-bits color palette for BD16, BYJK* and BYUV modes
67
	  * This is the complete color space for the V9990
68
	  */
69
	std::span<const Pixel, 32768> const palette32768;
70
71
	/** Remember last color and display mode. This is always the same as
72
	  * vdp.getColorMode() and vdp.getDisplayMode() because these two only
73
	  * change at the end of a display line.
74
	  */
75
	V9990ColorMode colorMode;
76
	bool highRes;
77
};
78
79
} // namespace openmsx
80
81
#endif