openMSX
V9990SDLRasterizer.hh
Go to the documentation of this file.
1 #ifndef V9990SDLRASTERIZER_HH
2 #define V9990SDLRASTERIZER_HH
3 
4 #include "V9990Rasterizer.hh"
6 #include "V9990P1Converter.hh"
7 #include "V9990P2Converter.hh"
8 #include "Observer.hh"
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class Display;
14 class V9990;
15 class V9990VRAM;
16 class RawFrame;
17 class OutputSurface;
18 class VisibleSurface;
19 class RenderSettings;
20 class Setting;
21 class PostProcessor;
22 
25 template <class Pixel>
26 class V9990SDLRasterizer final : public V9990Rasterizer
27  , private Observer<Setting>
28 {
29 public:
31  V9990& vdp, Display& display, VisibleSurface& screen,
32  std::unique_ptr<PostProcessor> postProcessor);
33  ~V9990SDLRasterizer() override;
34 
35  // Rasterizer interface:
36  PostProcessor* getPostProcessor() const override;
37  bool isActive() override;
38  void reset() override;
39  void frameStart() override;
40  void frameEnd(EmuTime::param time) override;
41  void setDisplayMode(V9990DisplayMode displayMode) override;
42  void setColorMode(V9990ColorMode colorMode) override;
43  void setPalette(int index, byte r, byte g, byte b, bool ys) override;
44  void setSuperimpose(bool enabled) override;
45  void drawBorder(int fromX, int fromY, int limitX, int limitY) override;
46  void drawDisplay(int fromX, int fromY, int toX, int toY,
47  int displayX,
48  int displayY, int displayYA, int displayYB) override;
49  bool isRecording() const override;
50 
51 private:
54  static const int SCREEN_WIDTH = 320;
55 
58  static const int SCREEN_HEIGHT = 240;
59 
62  V9990& vdp;
63 
66  V9990VRAM& vram;
67 
70  OutputSurface& screen;
71 
74  std::unique_ptr<RawFrame> workFrame;
75 
78  RenderSettings& renderSettings;
79 
83  int lineRenderTop;
84 
89  int colZero;
90 
93  V9990DisplayMode displayMode;
94  V9990ColorMode colorMode;
95 
98  Pixel palette32768[32768];
99 
102  Pixel palette256[256]; // from index to host Pixel color
103  int16_t palette256_32768[256]; // from index to 15bpp V9990 color
104  // invariant: palette256[i] == palette32768[palette256_32768[i]]
105 
109  Pixel palette64[64]; // from index to host Pixel color
110  int16_t palette64_32768[64]; // from index to 15bpp V9990 color
111  // invariant: palette64[i] == palette32768[palette64_32768[i]]
112 
116  const std::unique_ptr<PostProcessor> postProcessor;
117 
118  V9990BitmapConverter<Pixel> bitmapConverter;
119  V9990P1Converter<Pixel> p1Converter;
120  V9990P2Converter<Pixel> p2Converter;
121 
124  void preCalcPalettes();
125  void resetPalette();
126 
127  void drawP1Mode(int fromX, int fromY, int displayX,
128  int displayY, int displayYA, int displayYB,
129  int displayWidth, int displayHeight, bool drawSprites);
130  void drawP2Mode(int fromX, int fromY, int displayX,
131  int displayY, int displayYA,
132  int displayWidth, int displayHeight, bool drawSprites);
133  void drawBxMode(int fromX, int fromY, int displayX,
134  int displayY, int displayYA,
135  int displayWidth, int displayHeight, bool drawSprites);
136 
137  // Observer<Setting>
138  void update(const Setting& setting) override;
139 };
140 
141 } // namespace openmsx
142 
143 #endif
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition: V9990.hh:29
void setColorMode(V9990ColorMode colorMode) override
The color mode determines how the V9990 VRAM data gets converted to pixel colors. ...
void reset() override
Resynchronize with VDP - flush caches etc.
Represents the output window/screen of openMSX.
Definition: Display.hh:31
void setSuperimpose(bool enabled) override
Is superimpose enabled?
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
Rasterizer using SDL.
A frame buffer where pixels can be written to.
uint32_t Pixel
V9990SDLRasterizer(V9990 &vdp, Display &display, VisibleSurface &screen, std::unique_ptr< PostProcessor > postProcessor)
If this seems awfully familiar, take a look at Rasterizer.hh It&#39;s virtually the same class...
bool isRecording() const override
Is video recording active?
void setPalette(int index, byte r, byte g, byte b, bool ys) override
Set RGB values for a palette entry.
An OutputSurface which is visible to the user, such as a window or a full screen display.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void frameStart() override
Indicates the start of a new frame.
void setDisplayMode(V9990DisplayMode displayMode) override
The display mode determines the screens geometry and how V9990 pixels are mapped to pixels on screen...
Video RAM for the V9990.
Definition: V9990VRAM.hh:15
int g
PostProcessor * getPostProcessor() const override
See V9990::getPostProcessor().
Abstract base class for post processors.
Utility class to convert VRAM content to host pixels.
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
void frameEnd(EmuTime::param time) override
Indicates the end of the current frame.
Class containing all settings for renderers.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
void drawDisplay(int fromX, int fromY, int toX, int toY, int displayX, int displayY, int displayYA, int displayYB) override
Render a rectangle of display pixels on the host screen.