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 <class 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;
32 
33  // Rasterizer interface:
34  PostProcessor* getPostProcessor() const override;
35  bool isActive() override;
36  void reset() override;
37  void frameStart() override;
38  void frameEnd(EmuTime::param time) override;
39  void setDisplayMode(V9990DisplayMode displayMode) override;
40  void setColorMode(V9990ColorMode colorMode) override;
41  void setPalette(int index, byte r, byte g, byte b, bool ys) override;
42  void setSuperimpose(bool enabled) override;
43  void drawBorder(int fromX, int fromY, int limitX, int limitY) override;
44  void drawDisplay(int fromX, int fromY, int toX, int toY,
45  int displayX,
46  int displayY, int displayYA, int displayYB) override;
47  bool isRecording() const override;
48 
49 private:
52  static constexpr int SCREEN_WIDTH = 320;
53 
56  static constexpr int SCREEN_HEIGHT = 240;
57 
60  V9990& vdp;
61 
64  V9990VRAM& vram;
65 
68  OutputSurface& screen;
69 
72  std::unique_ptr<RawFrame> workFrame;
73 
76  RenderSettings& renderSettings;
77 
81  int lineRenderTop;
82 
87  int colZero;
88 
91  V9990DisplayMode displayMode;
92  V9990ColorMode colorMode;
93 
96  Pixel palette32768[32768];
97 
100  Pixel palette256[256]; // from index to host Pixel color
101  int16_t palette256_32768[256]; // from index to 15bpp V9990 color
102  // invariant: palette256[i] == palette32768[palette256_32768[i]]
103 
107  Pixel palette64[64]; // from index to host Pixel color
108  int16_t palette64_32768[64]; // from index to 15bpp V9990 color
109  // invariant: palette64[i] == palette32768[palette64_32768[i]]
110 
114  const std::unique_ptr<PostProcessor> postProcessor;
115 
116  V9990BitmapConverter<Pixel> bitmapConverter;
117  V9990P1Converter<Pixel> p1Converter;
118  V9990P2Converter<Pixel> p2Converter;
119 
122  void preCalcPalettes();
123  void resetPalette();
124 
125  void drawP1Mode(int fromX, int fromY, int displayX,
126  int displayY, int displayYA, int displayYB,
127  int displayWidth, int displayHeight, bool drawSprites);
128  void drawP2Mode(int fromX, int fromY, int displayX,
129  int displayY, int displayYA,
130  int displayWidth, int displayHeight, bool drawSprites);
131  void drawBxMode(int fromX, int fromY, int displayX,
132  int displayY, int displayYA,
133  int displayWidth, int displayHeight, bool drawSprites);
134 
135  // Observer<Setting>
136  void update(const Setting& setting) override;
137 };
138 
139 } // namespace openmsx
140 
141 #endif
openmsx::V9990VRAM
Video RAM for the V9990.
Definition: V9990VRAM.hh:15
openmsx::V9990SDLRasterizer::setDisplayMode
void setDisplayMode(V9990DisplayMode displayMode) override
The display mode determines the screens geometry and how V9990 pixels are mapped to pixels on screen.
Definition: V9990SDLRasterizer.cc:106
openmsx::V9990SDLRasterizer::isRecording
bool isRecording() const override
Is video recording active?
Definition: V9990SDLRasterizer.cc:369
openmsx::V9990SDLRasterizer::~V9990SDLRasterizer
~V9990SDLRasterizer() override
Definition: V9990SDLRasterizer.cc:45
openmsx::V9990SDLRasterizer::getPostProcessor
PostProcessor * getPostProcessor() const override
See V9990::getPostProcessor().
Definition: V9990SDLRasterizer.cc:54
openmsx::RenderSettings
Class containing all settings for renderers.
Definition: RenderSettings.hh:21
openmsx::V9990SDLRasterizer::drawDisplay
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.
Definition: V9990SDLRasterizer.cc:156
openmsx::V9990SDLRasterizer::drawBorder
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
Definition: V9990SDLRasterizer.cc:120
openmsx::V9990SDLRasterizer::frameStart
void frameStart() override
Indicates the start of a new frame.
Definition: V9990SDLRasterizer.cc:76
openmsx::V9990SDLRasterizer::setSuperimpose
void setSuperimpose(bool enabled) override
Is superimpose enabled?
Definition: V9990SDLRasterizer.cc:363
openmsx::V9990ColorMode
V9990ColorMode
Definition: V9990ModeEnum.hh:11
openmsx::Setting
Definition: Setting.hh:119
openmsx::V9990SDLRasterizer::V9990SDLRasterizer
V9990SDLRasterizer(V9990 &vdp, Display &display, OutputSurface &screen, std::unique_ptr< PostProcessor > postProcessor)
Definition: V9990SDLRasterizer.cc:21
openmsx::V9990SDLRasterizer::setPalette
void setPalette(int index, byte r, byte g, byte b, bool ys) override
Set RGB values for a palette entry.
Definition: V9990SDLRasterizer.cc:338
openmsx::V9990SDLRasterizer::isActive
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
Definition: V9990SDLRasterizer.cc:60
openmsx::Pixel
uint32_t Pixel
Definition: GLHQLiteScaler.cc:93
openmsx::V9990
V9990
Definition: V9990.cc:974
Observer.hh
V9990PxConverter.hh
V9990BitmapConverter.hh
V9990Rasterizer.hh
openmsx::V9990DisplayMode
V9990DisplayMode
Definition: V9990ModeEnum.hh:6
openmsx::PostProcessor
Abstract base class for post processors.
Definition: PostProcessor.hh:29
openmsx::V9990BitmapConverter
Utility class to convert VRAM content to host pixels.
Definition: V9990BitmapConverter.hh:15
openmsx::V9990SDLRasterizer::reset
void reset() override
Resynchronize with VDP - flush caches etc.
Definition: V9990SDLRasterizer.cc:68
g
int g
Definition: ScopedAssign_test.cc:20
openmsx::Display
Represents the output window/screen of openMSX.
Definition: Display.hh:31
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:19
openmsx::V9990P1Converter
Definition: V9990PxConverter.hh:10
openmsx::V9990P2Converter
Definition: V9990PxConverter.hh:27
openmsx::V9990SDLRasterizer::setColorMode
void setColorMode(V9990ColorMode colorMode) override
The color mode determines how the V9990 VRAM data gets converted to pixel colors.
Definition: V9990SDLRasterizer.cc:113
openmsx::V9990VRAM
V9990VRAM
Definition: V9990VRAM.cc:59
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::V9990Rasterizer
If this seems awfully familiar, take a look at Rasterizer.hh It's virtually the same class,...
Definition: V9990Rasterizer.hh:15
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
openmsx::V9990SDLRasterizer::frameEnd
void frameEnd(EmuTime::param time) override
Indicates the end of the current frame.
Definition: V9990SDLRasterizer.cc:96
openmsx::V9990SDLRasterizer
Rasterizer using SDL.
Definition: V9990SDLRasterizer.hh:24
openmsx::V9990
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition: V9990.hh:29