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 "V9990PxConverter.hh"
7 #include "Observer.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class Display;
13 class V9990;
14 class V9990VRAM;
15 class RawFrame;
16 class OutputSurface;
17 class RenderSettings;
18 class Setting;
19 class PostProcessor;
20 
23 template<typename Pixel>
24 class V9990SDLRasterizer final : public V9990Rasterizer
25  , private Observer<Setting>
26 {
27 public:
29  V9990& vdp, Display& display, OutputSurface& screen,
30  std::unique_ptr<PostProcessor> postProcessor);
31  ~V9990SDLRasterizer() override;
34 
35  // Rasterizer interface:
36  [[nodiscard]] PostProcessor* getPostProcessor() const override;
37  [[nodiscard]] 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  [[nodiscard]] bool isRecording() const override;
50 
53  void preCalcPalettes();
54  void resetPalette();
55 
56  void drawP1Mode(int fromX, int fromY, int displayX,
57  int displayY, int displayYA, int displayYB,
58  int displayWidth, int displayHeight, bool drawSprites);
59  void drawP2Mode(int fromX, int fromY, int displayX,
60  int displayY, int displayYA,
61  int displayWidth, int displayHeight, bool drawSprites);
62  void drawBxMode(int fromX, int fromY, int displayX,
63  int displayY, int displayYA,
64  int displayWidth, int displayHeight, bool drawSprites);
65 
66  // Observer<Setting>
67  void update(const Setting& setting) noexcept override;
68 
69 private:
72  static constexpr int SCREEN_WIDTH = 320;
73 
76  static constexpr int SCREEN_HEIGHT = 240;
77 
80  V9990& vdp;
81 
84  V9990VRAM& vram;
85 
88  OutputSurface& screen;
89 
92  std::unique_ptr<RawFrame> workFrame;
93 
96  RenderSettings& renderSettings;
97 
101  int lineRenderTop;
102 
107  int colZero;
108 
111  V9990DisplayMode displayMode;
112  V9990ColorMode colorMode;
113 
116  Pixel palette32768[32768];
117 
120  Pixel palette256[256]; // from index to host Pixel color
121  int16_t palette256_32768[256]; // from index to 15bpp V9990 color
122  // invariant: palette256[i] == palette32768[palette256_32768[i]]
123 
127  Pixel palette64[64]; // from index to host Pixel color
128  int16_t palette64_32768[64]; // from index to 15bpp V9990 color
129  // invariant: palette64[i] == palette32768[palette64_32768[i]]
130 
134  const std::unique_ptr<PostProcessor> postProcessor;
135 
136  V9990BitmapConverter<Pixel> bitmapConverter;
137  V9990P1Converter<Pixel> p1Converter;
138  V9990P2Converter<Pixel> p2Converter;
139 };
140 
141 } // namespace openmsx
142 
143 #endif
BaseSetting * setting
Definition: Interpreter.cc:30
int g
Represents the output window/screen of openMSX.
Definition: Display.hh:33
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
A frame buffer where pixels can be written to.
Abstract base class for post processors.
Class containing all settings for renderers.
Utility class to convert VRAM content to host pixels.
If this seems awfully familiar, take a look at Rasterizer.hh It's virtually the same class,...
void drawP1Mode(int fromX, int fromY, int displayX, int displayY, int displayYA, int displayYB, int displayWidth, int displayHeight, bool drawSprites)
void frameStart() override
Indicates the start of a new frame.
void setPalette(int index, byte r, byte g, byte b, bool ys) override
Set RGB values for a palette entry.
void reset() override
Resynchronize with VDP - flush caches etc.
void setSuperimpose(bool enabled) override
Is superimpose enabled?
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
bool isRecording() const override
Is video recording active?
void drawBxMode(int fromX, int fromY, int displayX, int displayY, int displayYA, int displayWidth, int displayHeight, bool drawSprites)
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
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.
V9990SDLRasterizer(const V9990SDLRasterizer &)=delete
void drawP2Mode(int fromX, int fromY, int displayX, int displayY, int displayYA, int displayWidth, int displayHeight, bool drawSprites)
PostProcessor * getPostProcessor() const override
See V9990::getPostProcessor().
void setDisplayMode(V9990DisplayMode displayMode) override
The display mode determines the screens geometry and how V9990 pixels are mapped to pixels on screen.
void update(const Setting &setting) noexcept override
V9990SDLRasterizer & operator=(const V9990SDLRasterizer &)=delete
void preCalcPalettes()
Fill the palettes.
void frameEnd(EmuTime::param time) override
Indicates the end of the current frame.
void setColorMode(V9990ColorMode colorMode) override
The color mode determines how the V9990 VRAM data gets converted to pixel colors.
V9990SDLRasterizer(V9990 &vdp, Display &display, OutputSurface &screen, std::unique_ptr< PostProcessor > postProcessor)
Video RAM for the V9990.
Definition: V9990VRAM.hh:16
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition: V9990.hh:31
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel