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 "noncopyable.hh"
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class EventDistributor;
14 class RealTime;
15 class Display;
16 class Rasterizer;
17 class VDP;
18 class VDPVRAM;
19 class SpriteChecker;
20 class DisplayMode;
21 class Setting;
22 class VideoSourceSetting;
23 
27 class PixelRenderer : public Renderer, private Observer<Setting>,
28  private noncopyable
29 {
30 public:
31  PixelRenderer(VDP& vdp, Display& display);
32  virtual ~PixelRenderer();
33 
34  // Renderer interface:
35  virtual PostProcessor* getPostProcessor() const;
36  virtual void reInit();
37  virtual void frameStart(EmuTime::param time);
38  virtual void frameEnd(EmuTime::param time);
39  virtual void updateHorizontalScrollLow(byte scroll, EmuTime::param time);
40  virtual void updateHorizontalScrollHigh(byte scroll, EmuTime::param time);
41  virtual void updateBorderMask(bool masked, EmuTime::param time);
42  virtual void updateMultiPage(bool multiPage, EmuTime::param time);
43  virtual void updateTransparency(bool enabled, EmuTime::param time);
44  virtual void updateSuperimposing(const RawFrame* videoSource, EmuTime::param time);
45  virtual void updateForegroundColor(int color, EmuTime::param time);
46  virtual void updateBackgroundColor(int color, EmuTime::param time);
47  virtual void updateBlinkForegroundColor(int color, EmuTime::param time);
48  virtual void updateBlinkBackgroundColor(int color, EmuTime::param time);
49  virtual void updateBlinkState(bool enabled, EmuTime::param time);
50  virtual void updatePalette(int index, int grb, EmuTime::param time);
51  virtual void updateVerticalScroll(int scroll, EmuTime::param time);
52  virtual void updateHorizontalAdjust(int adjust, EmuTime::param time);
53  virtual void updateDisplayEnabled(bool enabled, EmuTime::param time);
54  virtual void updateDisplayMode(DisplayMode mode, EmuTime::param time);
55  virtual void updateNameBase(int addr, EmuTime::param time);
56  virtual void updatePatternBase(int addr, EmuTime::param time);
57  virtual void updateColorBase(int addr, EmuTime::param time);
58  virtual void updateSpritesEnabled(bool enabled, EmuTime::param time);
59  virtual void updateVRAM(unsigned offset, EmuTime::param time);
60  virtual void updateWindow(bool enabled, EmuTime::param time);
61 
62 private:
64  enum DrawType { DRAW_BORDER, DRAW_DISPLAY };
65 
66  // Observer<Setting> interface:
67  virtual void update(const Setting& setting);
68 
72  void draw(
73  int startX, int startY, int endX, int endY, DrawType drawType,
74  bool atEnd);
75 
83  void subdivide(
84  int startX, int startY, int endX, int endY,
85  int clipL, int clipR, DrawType drawType );
86 
87  inline bool checkSync(int offset, EmuTime::param time);
88 
94  void sync(EmuTime::param time, bool force = false);
95 
102  void renderUntil(EmuTime::param time);
103 
106  VDP& vdp;
107 
110  VDPVRAM& vram;
111 
112  EventDistributor& eventDistributor;
113  RealTime& realTime;
114  RenderSettings& renderSettings;
115  VideoSourceSetting& videoSourceSetting;
116 
119  SpriteChecker& spriteChecker;
120 
121  const std::unique_ptr<Rasterizer> rasterizer;
122 
123  double finishFrameDuration;
124  int frameSkipCounter;
125 
129  int nextX;
130 
134  int nextY;
135 
136  // internal VDP counter, actually belongs in VDP
137  int textModeCounter;
138 
141  RenderSettings::Accuracy accuracy;
142 
147  bool displayEnabled;
148 
151  bool renderFrame;
152  bool prevRenderFrame;
153 };
154 
155 } // namespace openmsx
156 
157 #endif
signed char offset
Definition: CPUCore.cc:252
Represents the output window/screen of openMSX.
Definition: Display.hh:32
virtual void updateBackgroundColor(int color, EmuTime::param time)
Informs the renderer of a VDP background color change.
virtual void updateBlinkBackgroundColor(int color, EmuTime::param time)
Informs the renderer of a VDP blink background color change.
virtual void updateSuperimposing(const RawFrame *videoSource, EmuTime::param time)
Informs the renderer of a VDP superimposing change.
virtual void frameEnd(EmuTime::param time)
Signals the end of a frame.
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
virtual void updateVerticalScroll(int scroll, EmuTime::param time)
Informs the renderer of a vertical scroll change.
Represents a VDP display mode.
Definition: DisplayMode.hh:14
virtual void updateHorizontalScrollHigh(byte scroll, EmuTime::param time)
Informs the renderer of a horizontal scroll change: the higher scroll value has changed.
virtual void updatePalette(int index, int grb, EmuTime::param time)
Informs the renderer of a VDP palette change.
virtual void reInit()
Reinitialise Renderer state.
virtual void updatePatternBase(int addr, EmuTime::param time)
Informs the renderer of a pattern table base address change.
virtual void updateBorderMask(bool masked, EmuTime::param time)
Informs the renderer of a horizontal scroll change: the border mask has been enabled/disabled.
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
virtual void updateMultiPage(bool multiPage, EmuTime::param time)
Informs the renderer of a horizontal scroll change: the multi page setting has changed.
Abstract base class for Renderers.
Definition: Renderer.hh:22
virtual void updateWindow(bool enabled, EmuTime::param time)
Informs the observer that the entire VRAM window will change.
Generic implementation of a pixel-based Renderer.
virtual PostProcessor * getPostProcessor() const
See VDP::getPostProcessor.
Accuracy
Render accuracy: granularity of the rendered area.
virtual void updateBlinkState(bool enabled, EmuTime::param time)
Informs the renderer of a VDP blinking state change.
virtual void updateColorBase(int addr, EmuTime::param time)
Informs the renderer of a color table base address change.
PixelRenderer(VDP &vdp, Display &display)
virtual void updateDisplayMode(DisplayMode mode, EmuTime::param time)
Informs the renderer of a VDP display mode change.
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:66
Abstract base class for post processors.
virtual void updateNameBase(int addr, EmuTime::param time)
Informs the renderer of a name table base address change.
virtual void updateVRAM(unsigned offset, EmuTime::param time)
Informs the observer of a change in VRAM contents.
virtual void updateTransparency(bool enabled, EmuTime::param time)
Informs the renderer of a VDP transparency enable/disable change.
virtual void frameStart(EmuTime::param time)
Signals the start of a new frame.
Class containing all settings for renderers.
Manages VRAM contents and synchronises the various users of the VRAM.
Definition: VDPVRAM.hh:383
virtual void updateSpritesEnabled(bool enabled, EmuTime::param time)
Informs the renderer of a VDP sprites enabled change.
virtual void updateHorizontalScrollLow(byte scroll, EmuTime::param time)
Informs the renderer of a horizontal scroll change: the lower scroll value has changed.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
virtual void updateDisplayEnabled(bool enabled, EmuTime::param time)
Informs the renderer of a VDP display enabled change.
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
virtual void updateHorizontalAdjust(int adjust, EmuTime::param time)
Informs the renderer of a horizontal adjust change.
virtual void updateForegroundColor(int color, EmuTime::param time)
Informs the renderer of a VDP foreground color change.
virtual void updateBlinkForegroundColor(int color, EmuTime::param time)
Informs the renderer of a VDP blink foreground color change.