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 <cstdint>
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class EventDistributor;
14 class RealTime;
15 class SpeedManager;
16 class ThrottleManager;
17 class Display;
18 class Rasterizer;
19 class VDP;
20 class VDPVRAM;
21 class SpriteChecker;
22 class DisplayMode;
23 class Setting;
24 class VideoSourceSetting;
25 
29 class PixelRenderer final : public Renderer, private Observer<Setting>
30 {
31 public:
32  PixelRenderer(VDP& vdp, Display& display);
33  ~PixelRenderer() override;
34 
35  // Renderer interface:
36  [[nodiscard]] PostProcessor* getPostProcessor() const override;
37  void reInit() override;
38  void frameStart(EmuTime::param time) override;
39  void frameEnd(EmuTime::param time) override;
40  void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override;
41  void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override;
42  void updateBorderMask(bool masked, EmuTime::param time) override;
43  void updateMultiPage(bool multiPage, EmuTime::param time) override;
44  void updateTransparency(bool enabled, EmuTime::param time) override;
45  void updateSuperimposing(const RawFrame* videoSource, EmuTime::param time) override;
46  void updateForegroundColor(int color, EmuTime::param time) override;
47  void updateBackgroundColor(int color, EmuTime::param time) override;
48  void updateBlinkForegroundColor(int color, EmuTime::param time) override;
49  void updateBlinkBackgroundColor(int color, EmuTime::param time) override;
50  void updateBlinkState(bool enabled, EmuTime::param time) override;
51  void updatePalette(int index, int grb, EmuTime::param time) override;
52  void updateVerticalScroll(int scroll, EmuTime::param time) override;
53  void updateHorizontalAdjust(int adjust, EmuTime::param time) override;
54  void updateDisplayEnabled(bool enabled, EmuTime::param time) override;
55  void updateDisplayMode(DisplayMode mode, EmuTime::param time) override;
56  void updateNameBase(int addr, EmuTime::param time) override;
57  void updatePatternBase(int addr, EmuTime::param time) override;
58  void updateColorBase(int addr, EmuTime::param time) override;
59  void updateSpritesEnabled(bool enabled, EmuTime::param time) override;
60  void updateVRAM(unsigned offset, EmuTime::param time) override;
61  void updateWindow(bool enabled, EmuTime::param time) override;
62 
63 private:
65  enum DrawType { DRAW_BORDER, DRAW_DISPLAY };
66 
67  // Observer<Setting> interface:
68  void update(const Setting& setting) noexcept override;
69 
73  void draw(
74  int startX, int startY, int endX, int endY, DrawType drawType,
75  bool atEnd);
76 
84  void subdivide(
85  int startX, int startY, int endX, int endY,
86  int clipL, int clipR, DrawType drawType);
87 
88  [[nodiscard]] inline bool checkSync(int offset, EmuTime::param time);
89 
95  void sync(EmuTime::param time, bool force = false);
96 
103  void renderUntil(EmuTime::param time);
104 
105 private:
108  VDP& vdp;
109 
112  VDPVRAM& vram;
113 
114  EventDistributor& eventDistributor;
115  RealTime& realTime;
116  SpeedManager& speedManager;
117  ThrottleManager& throttleManager;
118  RenderSettings& renderSettings;
119  VideoSourceSetting& videoSourceSetting;
120 
123  SpriteChecker& spriteChecker;
124 
125  const std::unique_ptr<Rasterizer> rasterizer;
126 
127  float finishFrameDuration;
128  float frameSkipCounter;
129 
133  int nextX;
134 
138  int nextY;
139 
140  // internal VDP counter, actually belongs in VDP
141  int textModeCounter;
142 
145  RenderSettings::Accuracy accuracy;
146 
151  bool displayEnabled;
152 
155  bool renderFrame;
156  bool prevRenderFrame;
157 
163  bool paintFrame;
164 
168  uint64_t lastPaintTime = 0;
169 };
170 
171 } // namespace openmsx
172 
173 #endif
BaseSetting * setting
Definition: Interpreter.cc:27
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
Generic implementation of a pixel-based Renderer.
void updateSuperimposing(const RawFrame *videoSource, EmuTime::param time) override
Informs the renderer of a VDP superimposing change.
void updateWindow(bool enabled, EmuTime::param time) override
Informs the observer that the entire VRAM window will change.
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor.
void updateForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP foreground color change.
void updateBorderMask(bool masked, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the border mask has been enabled/disabled.
void updatePatternBase(int addr, EmuTime::param time) override
Informs the renderer of a pattern table base address change.
void updateVerticalScroll(int scroll, EmuTime::param time) override
Informs the renderer of a vertical scroll change.
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.
void updateTransparency(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP transparency enable/disable change.
void updateNameBase(int addr, EmuTime::param time) override
Informs the renderer of a name table base address change.
void updateDisplayMode(DisplayMode mode, EmuTime::param time) override
Informs the renderer of a VDP display mode change.
void updateHorizontalAdjust(int adjust, EmuTime::param time) override
Informs the renderer of a horizontal adjust change.
PixelRenderer(VDP &vdp, Display &display)
void updateVRAM(unsigned offset, EmuTime::param time) override
Informs the observer of a change in VRAM contents.
void frameEnd(EmuTime::param time) override
Signals the end of a frame.
void updateSpritesEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP sprites enabled change.
void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the higher scroll value has changed.
void updatePalette(int index, int grb, EmuTime::param time) override
Informs the renderer of a VDP palette change.
void frameStart(EmuTime::param time) override
Signals the start of a new frame.
void updateBlinkBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink background color change.
void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the lower scroll value has changed.
void updateMultiPage(bool multiPage, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the multi page setting has changed.
void reInit() override
Reinitialize Renderer state.
void updateBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP background color change.
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
void updateBlinkForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink foreground color change.
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.
Accuracy
Render accuracy: granularity of the rendered area.
Abstract base class for Renderers.
Definition: Renderer.hh:23
Manages the desired ratio between emutime and real time.
Definition: SpeedManager.hh:18
Manages the throttle state of openMSX.
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:9