openMSX
PixelRenderer.hh
Go to the documentation of this file.
1 #ifndef PIXELRENDERER_HH
2 #define PIXELRENDERER_HH
3 
4 #include "Renderer.hh"
5 #include "Observer.hh"
6 #include "RenderSettings.hh"
7 #include "openmsx.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class EventDistributor;
13 class RealTime;
14 class Display;
15 class Rasterizer;
16 class VDP;
17 class VDPVRAM;
18 class SpriteChecker;
19 class DisplayMode;
20 class Setting;
21 class VideoSourceSetting;
22 
26 class PixelRenderer final : public Renderer, private Observer<Setting>
27 {
28 public:
29  PixelRenderer(VDP& vdp, Display& display);
31 
32  // Renderer interface:
33  PostProcessor* getPostProcessor() const override;
34  void reInit() override;
35  void frameStart(EmuTime::param time) override;
36  void frameEnd(EmuTime::param time) override;
37  void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override;
38  void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override;
39  void updateBorderMask(bool masked, EmuTime::param time) override;
40  void updateMultiPage(bool multiPage, EmuTime::param time) override;
41  void updateTransparency(bool enabled, EmuTime::param time) override;
42  void updateSuperimposing(const RawFrame* videoSource, EmuTime::param time) override;
43  void updateForegroundColor(int color, EmuTime::param time) override;
44  void updateBackgroundColor(int color, EmuTime::param time) override;
45  void updateBlinkForegroundColor(int color, EmuTime::param time) override;
46  void updateBlinkBackgroundColor(int color, EmuTime::param time) override;
47  void updateBlinkState(bool enabled, EmuTime::param time) override;
48  void updatePalette(int index, int grb, EmuTime::param time) override;
49  void updateVerticalScroll(int scroll, EmuTime::param time) override;
50  void updateHorizontalAdjust(int adjust, EmuTime::param time) override;
51  void updateDisplayEnabled(bool enabled, EmuTime::param time) override;
52  void updateDisplayMode(DisplayMode mode, EmuTime::param time) override;
53  void updateNameBase(int addr, EmuTime::param time) override;
54  void updatePatternBase(int addr, EmuTime::param time) override;
55  void updateColorBase(int addr, EmuTime::param time) override;
56  void updateSpritesEnabled(bool enabled, EmuTime::param time) override;
57  void updateVRAM(unsigned offset, EmuTime::param time) override;
58  void updateWindow(bool enabled, EmuTime::param time) override;
59 
60 private:
62  enum DrawType { DRAW_BORDER, DRAW_DISPLAY };
63 
64  // Observer<Setting> interface:
65  void update(const Setting& setting) override;
66 
70  void draw(
71  int startX, int startY, int endX, int endY, DrawType drawType,
72  bool atEnd);
73 
81  void subdivide(
82  int startX, int startY, int endX, int endY,
83  int clipL, int clipR, DrawType drawType );
84 
85  inline bool checkSync(int offset, EmuTime::param time);
86 
92  void sync(EmuTime::param time, bool force = false);
93 
100  void renderUntil(EmuTime::param time);
101 
104  VDP& vdp;
105 
108  VDPVRAM& vram;
109 
110  EventDistributor& eventDistributor;
111  RealTime& realTime;
112  RenderSettings& renderSettings;
113  VideoSourceSetting& videoSourceSetting;
114 
117  SpriteChecker& spriteChecker;
118 
119  const std::unique_ptr<Rasterizer> rasterizer;
120 
121  float finishFrameDuration;
122  int frameSkipCounter;
123 
127  int nextX;
128 
132  int nextY;
133 
134  // internal VDP counter, actually belongs in VDP
135  int textModeCounter;
136 
139  RenderSettings::Accuracy accuracy;
140 
145  bool displayEnabled;
146 
149  bool renderFrame;
150  bool prevRenderFrame;
151 };
152 
153 } // namespace openmsx
154 
155 #endif
void updateSuperimposing(const RawFrame *videoSource, EmuTime::param time) override
Informs the renderer of a VDP superimposing change.
void updateHorizontalAdjust(int adjust, EmuTime::param time) override
Informs the renderer of a horizontal adjust change.
void updatePalette(int index, int grb, EmuTime::param time) override
Informs the renderer of a VDP palette change.
Represents the output window/screen of openMSX.
Definition: Display.hh:32
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor.
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void updateBorderMask(bool masked, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the border mask has been enabled/disabled.
void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the higher scroll value has changed.
Represents a VDP display mode.
Definition: DisplayMode.hh:14
void reInit() override
Reinitialise Renderer state.
void updateColorBase(int addr, EmuTime::param time) override
Informs the renderer of a color table base address change.
void updateBlinkState(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP blinking state change.
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the lower scroll value has changed.
void updateDisplayMode(DisplayMode mode, EmuTime::param time) override
Informs the renderer of a VDP display mode change.
Abstract base class for Renderers.
Definition: Renderer.hh:22
Generic implementation of a pixel-based Renderer.
Accuracy
Render accuracy: granularity of the rendered area.
void updateVerticalScroll(int scroll, EmuTime::param time) override
Informs the renderer of a vertical scroll change.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void frameEnd(EmuTime::param time) override
Signals the end of a frame.
void updateMultiPage(bool multiPage, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the multi page setting has changed.
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
void updateTransparency(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP transparency enable/disable change.
PixelRenderer(VDP &vdp, Display &display)
void updateNameBase(int addr, EmuTime::param time) override
Informs the renderer of a name table base address change.
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:61
Abstract base class for post processors.
void updateBlinkBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink background color change.
void updatePatternBase(int addr, EmuTime::param time) override
Informs the renderer of a pattern table base address change.
Class containing all settings for renderers.
Manages VRAM contents and synchronises the various users of the VRAM.
Definition: VDPVRAM.hh:384
void updateForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP foreground color change.
void updateBlinkForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink foreground color change.
void updateBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP background color change.
void updateSpritesEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP sprites enabled change.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
void frameStart(EmuTime::param time) override
Signals the start of a new frame.
void updateWindow(bool enabled, EmuTime::param time) override
Informs the observer that the entire VRAM window will change.
void updateVRAM(unsigned offset, EmuTime::param time) override
Informs the observer of a change in VRAM contents.