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
11namespace openmsx {
12
13class EventDistributor;
14class RealTime;
15class SpeedManager;
16class ThrottleManager;
17class Display;
18class Rasterizer;
19class VDP;
20class VDPVRAM;
21class SpriteChecker;
22class DisplayMode;
23class Setting;
24class VideoSourceSetting;
25
29class PixelRenderer final : public Renderer, private Observer<Setting>
30{
31public:
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(byte color, EmuTime::param time) override;
47 void updateBackgroundColor(byte color, EmuTime::param time) override;
48 void updateBlinkForegroundColor(byte color, EmuTime::param time) override;
49 void updateBlinkBackgroundColor(byte color, EmuTime::param time) override;
50 void updateBlinkState(bool enabled, EmuTime::param time) override;
51 void updatePalette(unsigned 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(unsigned addr, EmuTime::param time) override;
57 void updatePatternBase(unsigned addr, EmuTime::param time) override;
58 void updateColorBase(unsigned 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
63private:
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]] bool checkSync(unsigned offset, EmuTime::param time) const;
89
95 void sync(EmuTime::param time, bool force = false);
96
103 void renderUntil(EmuTime::param time);
104
105private:
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 = 0.0f;
128 float frameSkipCounter = 999.0f; // force drawing of frame
129
133 int nextX;
134
138 int nextY;
139
140 // internal VDP counter, actually belongs in VDP
141 int textModeCounter;
142
146
151 bool displayEnabled;
152
155 bool renderFrame;
156 bool prevRenderFrame = false;
157
163 bool paintFrame;
164
168 uint64_t lastPaintTime = 0;
169};
170
171} // namespace openmsx
172
173#endif
BaseSetting * setting
Represents a VDP display mode.
Represents the output window/screen of openMSX.
Definition Display.hh:31
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 updateColorBase(unsigned addr, EmuTime::param time) override
Informs the renderer of a color table base address 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 updateVerticalScroll(int scroll, EmuTime::param time) override
Informs the renderer of a vertical scroll 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 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.
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 frameStart(EmuTime::param time) override
Signals the start of a new frame.
void updateBackgroundColor(byte color, EmuTime::param time) override
Informs the renderer of a VDP 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 updatePatternBase(unsigned addr, EmuTime::param time) override
Informs the renderer of a pattern table base address change.
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 updateNameBase(unsigned addr, EmuTime::param time) override
Informs the renderer of a name table base address change.
void updatePalette(unsigned index, int grb, EmuTime::param time) override
Informs the renderer of a VDP palette change.
void updateBlinkBackgroundColor(byte color, EmuTime::param time) override
Informs the renderer of a VDP blink background color change.
void updateForegroundColor(byte color, EmuTime::param time) override
Informs the renderer of a VDP foreground color change.
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
void updateBlinkForegroundColor(byte color, EmuTime::param time) override
Informs the renderer of a VDP blink foreground color change.
A post processor builds the frame that is displayed from the MSX frame, while applying effects such a...
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition RawFrame.hh:16
Class containing all settings for renderers.
Accuracy
Render accuracy: granularity of the rendered area.
Abstract base class for Renderers.
Definition Renderer.hh:24
Manages the desired ratio between EmuTime and real time.
Manages the throttle state of openMSX.
Manages VRAM contents and synchronizes the various users of the VRAM.
Definition VDPVRAM.hh:399
Unified implementation of MSX Video Display Processors (VDPs).
Definition VDP.hh:67
This file implemented 3 utility functions:
Definition Autofire.cc:11