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  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) 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  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 
107  VDP& vdp;
108 
111  VDPVRAM& vram;
112 
113  EventDistributor& eventDistributor;
114  RealTime& realTime;
115  SpeedManager& speedManager;
116  ThrottleManager& throttleManager;
117  RenderSettings& renderSettings;
118  VideoSourceSetting& videoSourceSetting;
119 
122  SpriteChecker& spriteChecker;
123 
124  const std::unique_ptr<Rasterizer> rasterizer;
125 
126  float finishFrameDuration;
127  float frameSkipCounter;
128 
132  int nextX;
133 
137  int nextY;
138 
139  // internal VDP counter, actually belongs in VDP
140  int textModeCounter;
141 
144  RenderSettings::Accuracy accuracy;
145 
150  bool displayEnabled;
151 
154  bool renderFrame;
155  bool prevRenderFrame;
156 
162  bool paintFrame;
163 
167  uint64_t lastPaintTime = 0;
168 };
169 
170 } // namespace openmsx
171 
172 #endif
openmsx::VDPVRAM
Manages VRAM contents and synchronises the various users of the VRAM.
Definition: VDPVRAM.hh:385
openmsx::adjust
constexpr AdjustTables adjust
Definition: Y8950.cc:204
openmsx::VideoSourceSetting
Definition: VideoSourceSetting.hh:11
openmsx.hh
openmsx::PixelRenderer::frameStart
void frameStart(EmuTime::param time) override
Signals the start of a new frame.
Definition: PixelRenderer.cc:167
openmsx::VDPVRAM
VDPVRAM
Definition: VDPVRAM.cc:343
openmsx::VDP
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:63
openmsx::RenderSettings
Class containing all settings for renderers.
Definition: RenderSettings.hh:22
openmsx::PixelRenderer::reInit
void reInit() override
Reinitialise Renderer state.
Definition: PixelRenderer.cc:150
openmsx::PixelRenderer::updateBorderMask
void updateBorderMask(bool masked, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the border mask has been enabled/disabled.
Definition: PixelRenderer.cc:269
openmsx::SpriteChecker
SpriteChecker
Definition: SpriteChecker.cc:524
openmsx::Renderer
Abstract base class for Renderers.
Definition: Renderer.hh:23
openmsx::PixelRenderer::getPostProcessor
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor.
Definition: PixelRenderer.cc:145
openmsx::PixelRenderer::~PixelRenderer
~PixelRenderer() override
Definition: PixelRenderer.cc:139
openmsx::PixelRenderer::updateVerticalScroll
void updateVerticalScroll(int scroll, EmuTime::param time) override
Informs the renderer of a vertical scroll change.
Definition: PixelRenderer.cc:353
openmsx::Setting
Definition: Setting.hh:120
openmsx::RenderSettings::Accuracy
Accuracy
Render accuracy: granularity of the rendered area.
Definition: RenderSettings.hh:32
openmsx::EventDistributor
Definition: EventDistributor.hh:17
openmsx::PixelRenderer::updatePatternBase
void updatePatternBase(int addr, EmuTime::param time) override
Informs the renderer of a pattern table base address change.
Definition: PixelRenderer.cc:387
openmsx::PixelRenderer::updateWindow
void updateWindow(bool enabled, EmuTime::param time) override
Informs the observer that the entire VRAM window will change.
Definition: PixelRenderer.cc:524
openmsx::DisplayMode
Represents a VDP display mode.
Definition: DisplayMode.hh:16
openmsx::PixelRenderer::updateBackgroundColor
void updateBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP background color change.
Definition: PixelRenderer.cc:302
openmsx::PixelRenderer::updateMultiPage
void updateMultiPage(bool multiPage, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the multi page setting has changed.
Definition: PixelRenderer.cc:276
openmsx::PixelRenderer::updateSuperimposing
void updateSuperimposing(const RawFrame *videoSource, EmuTime::param time) override
Informs the renderer of a VDP superimposing change.
Definition: PixelRenderer.cc:289
openmsx::PixelRenderer::updateHorizontalScrollLow
void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the lower scroll value has changed.
Definition: PixelRenderer.cc:256
openmsx::PixelRenderer::frameEnd
void frameEnd(EmuTime::param time) override
Signals the end of a frame.
Definition: PixelRenderer.cc:221
openmsx::PixelRenderer::PixelRenderer
PixelRenderer(VDP &vdp, Display &display)
Definition: PixelRenderer.cc:112
Renderer.hh
Observer.hh
openmsx::PixelRenderer::updatePalette
void updatePalette(int index, int grb, EmuTime::param time) override
Informs the renderer of a VDP palette change.
Definition: PixelRenderer.cc:331
openmsx::SpriteChecker
Definition: SpriteChecker.hh:19
openmsx::SpeedManager
Manages the desired ratio between emutime and real time.
Definition: SpeedManager.hh:18
openmsx::PixelRenderer::updateNameBase
void updateNameBase(int addr, EmuTime::param time) override
Informs the renderer of a name table base address change.
Definition: PixelRenderer.cc:381
openmsx::PostProcessor
Abstract base class for post processors.
Definition: PostProcessor.hh:30
openmsx::PixelRenderer::updateColorBase
void updateColorBase(int addr, EmuTime::param time) override
Informs the renderer of a color table base address change.
Definition: PixelRenderer.cc:393
openmsx::PixelRenderer
Generic implementation of a pixel-based Renderer.
Definition: PixelRenderer.hh:30
openmsx::RawFrame
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:26
RenderSettings.hh
openmsx::RealTime
Definition: RealTime.hh:25
openmsx::PixelRenderer::updateTransparency
void updateTransparency(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP transparency enable/disable change.
Definition: PixelRenderer.cc:282
openmsx::PixelRenderer::updateSpritesEnabled
void updateSpritesEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP sprites enabled change.
Definition: PixelRenderer.cc:399
openmsx::VDP
VDP
Definition: VDP.cc:1917
openmsx::PixelRenderer::updateBlinkForegroundColor
void updateBlinkForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink foreground color change.
Definition: PixelRenderer.cc:309
openmsx::PixelRenderer::updateHorizontalScrollHigh
void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the higher scroll value has changed.
Definition: PixelRenderer.cc:263
openmsx::Display
Represents the output window/screen of openMSX.
Definition: Display.hh:33
openmsx::PixelRenderer::updateDisplayMode
void updateDisplayMode(DisplayMode mode, EmuTime::param time) override
Informs the renderer of a VDP display mode change.
Definition: PixelRenderer.cc:366
openmsx::PixelRenderer::updateForegroundColor
void updateForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP foreground color change.
Definition: PixelRenderer.cc:296
openmsx::PixelRenderer::updateBlinkBackgroundColor
void updateBlinkBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink background color change.
Definition: PixelRenderer.cc:315
openmsx::PixelRenderer::updateHorizontalAdjust
void updateHorizontalAdjust(int adjust, EmuTime::param time) override
Informs the renderer of a horizontal adjust change.
Definition: PixelRenderer.cc:359
openmsx::PixelRenderer::updateBlinkState
void updateBlinkState(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP blinking state change.
Definition: PixelRenderer.cc:321
openmsx::PixelRenderer::updateDisplayEnabled
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
Definition: PixelRenderer.cc:161
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::PixelRenderer::updateVRAM
void updateVRAM(unsigned offset, EmuTime::param time) override
Informs the observer of a change in VRAM contents.
Definition: PixelRenderer.cc:513
openmsx::ThrottleManager
Manages the throttle state of openMSX.
Definition: ThrottleManager.hh:19
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10