openMSX
SDLRasterizer.hh
Go to the documentation of this file.
1 #ifndef SDLRASTERIZER_HH
2 #define SDLRASTERIZER_HH
3 
4 #include "Rasterizer.hh"
5 #include "BitmapConverter.hh"
6 #include "CharacterConverter.hh"
7 #include "SpriteConverter.hh"
8 #include "Observer.hh"
9 #include "openmsx.hh"
10 #include <memory>
11 
12 namespace openmsx {
13 
14 class Display;
15 class VDP;
16 class VDPVRAM;
17 class OutputSurface;
18 class RawFrame;
19 class RenderSettings;
20 class Setting;
21 class PostProcessor;
22 
26 template<typename Pixel>
27 class SDLRasterizer final : public Rasterizer
28  , private Observer<Setting>
29 {
30 public:
31  SDLRasterizer(const SDLRasterizer&) = delete;
33 
35  VDP& vdp, Display& display, OutputSurface& screen,
36  std::unique_ptr<PostProcessor> postProcessor);
37  ~SDLRasterizer() override;
38 
39  // Rasterizer interface:
40  [[nodiscard]] PostProcessor* getPostProcessor() const override;
41  [[nodiscard]] bool isActive() override;
42  void reset() override;
43  void frameStart(EmuTime::param time) override;
44  void frameEnd() override;
45  void setDisplayMode(DisplayMode mode) override;
46  void setPalette(int index, int grb) override;
47  void setBackgroundColor(int index) override;
48  void setHorizontalAdjust(int adjust) override;
49  void setHorizontalScrollLow(byte scroll) override;
50  void setBorderMask(bool masked) override;
51  void setTransparency(bool enabled) override;
52  void setSuperimposeVideoFrame(const RawFrame* videoSource) override;
53  void drawBorder(int fromX, int fromY, int limitX, int limitY) override;
54  void drawDisplay(
55  int fromX, int fromY,
56  int displayX, int displayY,
57  int displayWidth, int displayHeight) override;
58  void drawSprites(
59  int fromX, int fromY,
60  int displayX, int displayY,
61  int displayWidth, int displayHeight) override;
62  [[nodiscard]] bool isRecording() const override;
63 
64 private:
65  inline void renderBitmapLine(Pixel* buf, unsigned vramLine);
66 
69  void resetPalette();
70 
75  void precalcPalette();
76 
81  void precalcColorIndex0(DisplayMode mode, bool transparency,
82  const RawFrame* superimposing, byte bgcolorIndex);
83 
84  // Get the border color(s). These are 16bpp or 32bpp host pixels.
85  std::pair<Pixel, Pixel> getBorderColors();
86 
87  // Observer<Setting>
88  void update(const Setting& setting) noexcept override;
89 
90 private:
93  VDP& vdp;
94 
97  VDPVRAM& vram;
98 
101  OutputSurface& screen;
102 
106  const std::unique_ptr<PostProcessor> postProcessor;
107 
110  std::unique_ptr<RawFrame> workFrame;
111 
114  RenderSettings& renderSettings;
115 
118  CharacterConverter<Pixel> characterConverter;
119 
122  BitmapConverter<Pixel> bitmapConverter;
123 
126  SpriteConverter<Pixel> spriteConverter;
127 
131  int lineRenderTop;
132 
140  Pixel palFg[16 * 2], palBg[16];
141 
144  Pixel palGraphic7Sprites[16];
145 
149  Pixel V9938_COLORS[8][8][8];
150 
154  Pixel PALETTE256[256];
155 
158  Pixel V9958_COLORS[32768];
159 };
160 
161 } // namespace openmsx
162 
163 #endif
Utility class for converting VRAM contents to host pixels.
Utility class for converting VRAM contents to host pixels.
Represents a VDP display mode.
Definition: DisplayMode.hh:16
Represents the output window/screen of openMSX.
Definition: Display.hh:33
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
A frame buffer where pixels can be written to.
Abstract base class for post processors.
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:14
Class containing all settings for renderers.
Rasterizer using a frame buffer approach: it writes pixels to a single rectangular pixel buffer.
void setHorizontalScrollLow(byte scroll) override
void setDisplayMode(DisplayMode mode) override
Precalc several values that depend on the display mode.
void setTransparency(bool enabled) override
SDLRasterizer & operator=(const SDLRasterizer &)=delete
void setPalette(int index, int grb) override
Change an entry in the palette.
void setHorizontalAdjust(int adjust) override
void setBackgroundColor(int index) override
Changes the background color.
bool isRecording() const override
Is video recording active?
void drawDisplay(int fromX, int fromY, int displayX, int displayY, int displayWidth, int displayHeight) override
Render a rectangle of display pixels on the host screen.
void reset() override
Resynchronize with VDP: all cached states are flushed.
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
void setSuperimposeVideoFrame(const RawFrame *videoSource) override
void frameEnd() override
Indicates the end of the current frame.
void frameStart(EmuTime::param time) override
Indicates the start of a new frame.
void setBorderMask(bool masked) override
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
void drawSprites(int fromX, int fromY, int displayX, int displayY, int displayWidth, int displayHeight) override
Render a rectangle of sprite pixels on the host screen.
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor().
SDLRasterizer(const SDLRasterizer &)=delete
Utility class for converting VRAM contents to host pixels.
Manages VRAM contents and synchronizes the various users of the VRAM.
Definition: VDPVRAM.hh:387
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:63
This file implemented 3 utility functions:
Definition: Autofire.cc:5
uint32_t Pixel