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 <cstdint>
7 
8 namespace openmsx {
9 
10 template<int N> struct DoublePixel;
11 template<> struct DoublePixel<2> { using type = uint32_t; };
12 template<> struct DoublePixel<4> { using type = uint64_t; };
13 
16 template <class Pixel>
18 {
19 public:
41  BitmapConverter(const Pixel* palette16,
42  const Pixel* palette256,
43  const Pixel* palette32768);
44 
50  void convertLine(Pixel* linePtr, const byte* vramPtr);
51 
58  void convertLinePlanar(Pixel* linePtr,
59  const byte* vramPtr0, const byte* vramPtr1);
60 
64  inline void setDisplayMode(DisplayMode mode_)
65  {
66  mode = mode_;
67  }
68 
71  inline void palette16Changed()
72  {
73  dPaletteValid = false;
74  }
75 
76 private:
77  void calcDPalette();
78 
79  inline void renderGraphic4(Pixel* pixelPtr, const byte* vramPtr0);
80  inline void renderGraphic5(Pixel* pixelPtr, const byte* vramPtr0);
81  inline void renderGraphic6(
82  Pixel* pixelPtr, const byte* vramPtr0, const byte* vramPtr1);
83  inline void renderGraphic7(
84  Pixel* pixelPtr, const byte* vramPtr0, const byte* vramPtr1);
85  inline void renderYJK(
86  Pixel* pixelPtr, const byte* vramPtr0, const byte* vramPtr1);
87  inline void renderYAE(
88  Pixel* pixelPtr, const byte* vramPtr0, const byte* vramPtr1);
89  inline void renderBogus(Pixel* pixelPtr);
90 
91  const Pixel* const __restrict palette16;
92  const Pixel* const __restrict palette256;
93  const Pixel* const __restrict palette32768;
94 
95  using DPixel = typename DoublePixel<sizeof(Pixel)>::type;
96  DPixel dPalette[16 * 16];
97  DisplayMode mode;
98  bool dPaletteValid;
99 };
100 
101 } // namespace openmsx
102 
103 #endif
Utility class for converting VRAM contents to host pixels.
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
Represents a VDP display mode.
Definition: DisplayMode.hh:14
uint32_t Pixel
void palette16Changed()
Inform this class about changes in the palette16 array.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setDisplayMode(DisplayMode mode_)
Select the display mode to use for scanline conversion.