openMSX
V9990PixelRenderer.hh
Go to the documentation of this file.
1 #ifndef V9990PIXELRENDERER_HH
2 #define V9990PIXELRENDERER_HH
3 
4 #include "V9990Renderer.hh"
5 #include "Observer.hh"
6 #include "RenderSettings.hh"
7 #include "openmsx.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class V9990;
13 class V9990Rasterizer;
14 class Setting;
15 class EventDistributor;
16 class RealTime;
17 class VideoSourceSetting;
18 
19 /** Generic pixel based renderer for the V9990.
20  * Uses a rasterizer to plot actual pixels for a specific video system
21  *
22  * @see PixelRenderer.cc
23  */
24 class V9990PixelRenderer final : public V9990Renderer
25  , private Observer<Setting>
26 {
27 public:
28  explicit V9990PixelRenderer(V9990& vdp);
29  ~V9990PixelRenderer() override;
30 
31  // V9990Renderer interface:
32  PostProcessor* getPostProcessor() const override;
33  void reset(EmuTime::param time) override;
34  void frameStart(EmuTime::param time) override;
35  void frameEnd(EmuTime::param time) override;
36  void updateDisplayEnabled(bool enabled, EmuTime::param time) override;
37  void setDisplayMode(V9990DisplayMode mode, EmuTime::param time) override;
38  void setColorMode(V9990ColorMode mode, EmuTime::param time) override;
39  void updatePalette(int index, byte r, byte g, byte b, bool ys,
40  EmuTime::param time) override;
41  void updateSuperimposing(bool enabled, EmuTime::param time) override;
42  void updateBackgroundColor(int index, EmuTime::param time) override;
43  void updateScrollAX(EmuTime::param time) override;
44  void updateScrollBX(EmuTime::param time) override;
45  void updateScrollAYLow(EmuTime::param time) override;
46  void updateScrollBYLow(EmuTime::param time) override;
47 
48 private:
49  void sync(EmuTime::param time, bool force = false);
50  void renderUntil(EmuTime::param time) override;
51 
52  /** Type of drawing to do.
53  */
54  enum DrawType {
55  DRAW_BORDER,
56  DRAW_DISPLAY
57  };
58 
59  /** The V9990 VDP
60  */
61  V9990& vdp;
62 
63  EventDistributor& eventDistributor;
64  RealTime& realTime;
65 
66  /** Settings shared between all renderers
67  */
68  RenderSettings& renderSettings;
69  VideoSourceSetting& videoSourceSetting;
70 
71  /** The Rasterizer
72  */
73  const std::unique_ptr<V9990Rasterizer> rasterizer;
74 
75  /** Frameskip
76  */
77  float finishFrameDuration;
78  int frameSkipCounter;
79 
80  /** Accuracy setting for current frame.
81  */
82  RenderSettings::Accuracy accuracy;
83 
84  /** The last sync point's vertical position. In lines, starting
85  * from VSYNC
86  */
87  int lastY;
88 
89  /** The last sync point's horizontal position in UC ticks, starting
90  * from HSYNC
91  */
92  int lastX;
93 
94  /** Apparently V9990 keeps an internal counter that indicates which line
95  * to display. That counter is initialized at the top of the screen and
96  * increased after every line. The counter is also reset when the
97  * vertical scroll register is written to (even when same value is
98  * written). Note: this is different from V99x8 behaviour!
99  * TODO we don't actually store the counter but an offset (so that the
100  * V99x8 drawing algorithm can still be used. Code might become
101  * simpler if we do store the counter.
102  */
103  int verticalOffsetA;
104  int verticalOffsetB;
105 
106  /** Is display enabled?
107  * Enabled means the current line is in the display area and
108  * forced blanking is off.
109  */
110  bool displayEnabled;
111 
112  /** Should current frame be draw or can it be skipped.
113  */
114  bool drawFrame;
115  bool prevDrawFrame;
116 
117  /**
118  */
119  void draw(int fromX, int fromY, int toX, int toY, DrawType type);
120 
121  /** Subdivide an area specified by two scan positions into a series of
122  * rectangles
123  */
124  void subdivide(int fromX, int fromY, int toX, int toY,
125  int clipL, int clipR, DrawType drawType);
126 
127  // Observer<Setting>
128  void update(const Setting& setting) override;
129 };
130 
131 } // namespace openmsx
132 
133 #endif
void frameStart(EmuTime::param time) override
Signal the start of a new frame.
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
bool getEnum() const noexcept
Definition: EnumSetting.hh:96
void setDisplayMode(V9990DisplayMode mode, EmuTime::param time) override
Set screen mode.
void updateBackgroundColor(int index, EmuTime::param time) override
Set background color.
Abstract base class for V9990 renderers.
void updateScrollAX(EmuTime::param time) override
Set scroll register.
If this seems awfully familiar, take a look at Rasterizer.hh It&#39;s virtually the same class...
void setColorMode(V9990ColorMode mode, EmuTime::param time) override
Set color mode.
PostProcessor * getPostProcessor() const override
See V9990::getPostProcessor.
void updateScrollBX(EmuTime::param time) override
void updateScrollAYLow(EmuTime::param time) override
void reset(EmuTime::param time) override
Re-initialise the V9990Renderer&#39;s state.
void updatePalette(int index, byte r, byte g, byte b, bool ys, EmuTime::param time) override
Set a palette entry.
void updateScrollBYLow(EmuTime::param time) override
void frameEnd(EmuTime::param time) override
Signal the end of the current frame.
void updateSuperimposing(bool enabled, EmuTime::param time) override
Change superimpose status.