ScummVM API documentation
osystem_ds.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 
23 #ifndef _OSYSTEM_DS_H_
24 #define _OSYSTEM_DS_H_
25 
26 #include "backends/modular-backend.h"
27 #include "backends/events/ds/ds-events.h"
28 #include "backends/mixer/mixer.h"
29 #include "backends/platform/ds/background.h"
30 #include "backends/platform/ds/keyboard.h"
31 #include "graphics/surface.h"
32 #include "graphics/paletteman.h"
33 
34 enum {
35  GFX_NOSCALE = 0,
36  GFX_HWSCALE = 1,
37  GFX_SWSCALE = 2
38 };
39 
41 protected:
42  enum TransactionMode {
43  kTransactionNone = 0,
44  kTransactionActive = 1,
45  kTransactionRollback = 2
46  };
47 
51  TransactionMode _transactionMode;
52 
53  //
54  // Transaction support
55  //
56  struct VideoState {
57  constexpr VideoState() : width(0), height(0), format(),
58  graphicsMode(GFX_HWSCALE), stretchMode(100) {
59  }
60 
61  uint width, height;
62  Graphics::PixelFormat format;
63  int graphicsMode;
64  int stretchMode;
65  };
66 
71 
76 
81 
82  Graphics::Surface _framebuffer, _overlay;
83  DS::Background *_screen, *_overlayScreen;
84 #ifdef DISABLE_TEXT_CONSOLE
85  DS::Background *_subScreen;
86  DS::TiledBackground *_banner;
87 #endif
88  bool _subScreenActive;
89  Graphics::Surface _cursor;
90  bool _hiresHack;
91  bool _paletteDirty, _cursorDirty;
92 
93  static OSystem_DS *_instance;
94 
95  u16 _palette[256];
96  u16 _cursorPalette[256];
97 
98  u16 *_cursorSprite;
99  Common::Point _cursorPos;
100  int _cursorHotX;
101  int _cursorHotY;
102  uint32 _cursorKey;
103  bool _cursorVisible;
104  bool _overlayInGUI;
105 
106  DSEventSource *_eventSource;
107  DS::Keyboard *_keyboard;
108 
109  void initGraphics();
110 
111  bool _disableCursorPalette;
112 
113  const Graphics::PixelFormat _pfCLUT8, _pfABGR1555;
114 
115  bool _engineRunning;
116 
117 public:
118  OSystem_DS();
119  virtual ~OSystem_DS();
120 
121  static OSystem_DS *instance() { return _instance; }
122 
123  virtual bool hasFeature(Feature f);
124  virtual void setFeatureState(Feature f, bool enable);
125  virtual bool getFeatureState(Feature f);
126 
127  virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
128  virtual int getDefaultGraphicsMode() const;
129  virtual bool setGraphicsMode(int mode, uint flags);
130  virtual int getGraphicsMode() const;
131 
132  virtual const GraphicsMode *getSupportedStretchModes() const;
133  virtual int getDefaultStretchMode() const;
134  virtual bool setStretchMode(int mode);
135  virtual int getStretchMode() const;
136 
137  virtual Graphics::PixelFormat getScreenFormat() const;
138  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
139 
140  virtual void beginGFXTransaction();
142 
143  virtual int getScreenChangeID() const;
144 
145  virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
146  virtual int16 getHeight();
147  virtual int16 getWidth();
148 
149  virtual PaletteManager *getPaletteManager() { return this; }
150 protected:
151  // PaletteManager API
152  virtual void setPalette(const byte *colors, uint start, uint num);
153  virtual void grabPalette(byte *colors, uint start, uint num) const;
154 
155 public:
156  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
157  virtual void updateScreen();
158  virtual void setShakePos(int shakeXOffset, int shakeYOffset);
159 
160  virtual void showOverlay(bool inGUI);
161  virtual void hideOverlay();
162  virtual bool isOverlayVisible() const;
163  virtual void clearOverlay();
164  virtual void grabOverlay(Graphics::Surface &surface);
165  virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h);
166  virtual int16 getOverlayHeight() const;
167  virtual int16 getOverlayWidth() const;
168  virtual Graphics::PixelFormat getOverlayFormat() const;
169 
170  Common::Point transformPoint(int16 x, int16 y);
171  virtual bool showMouse(bool visible);
172 
173  virtual void warpMouse(int x, int y);
174  virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask);
175 
176  virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
177 
178  virtual uint32 getMillis(bool skipRecord = false);
179  virtual void delayMillis(uint msecs);
180  virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
181  void doTimerCallback(int interval = 10);
183 
184  virtual Common::EventSource *getDefaultEventSource() { return _eventSource; }
186 
187  virtual Common::String getSystemLanguage() const;
188 
189  virtual void engineInit();
190  virtual void engineDone();
191  virtual void quit();
192 
193  virtual void setFocusRectangle(const Common::Rect& rect);
194  virtual void clearFocusRectangle();
195 
196  virtual void initBackend();
197 
198  virtual Graphics::Surface *lockScreen();
199  virtual void unlockScreen();
200 
201  virtual void setCursorPalette(const byte *colors, uint start, uint num);
202 
203  void setSwapLCDs(bool swap);
204 
205  void refreshCursor(u16 *dst, const Graphics::Surface &src, const uint16 *palette);
206 
207  virtual void logMessage(LogMessageType::Type type, const char *message);
208  virtual void messageBox(LogMessageType::Type type, const char *message);
209 
210  void setMainScreen(int32 x, int32 y, int32 sx, int32 sy);
211  void setSubScreen(int32 x, int32 y, int32 sx, int32 sy);
212 
213  int _currentTimeMillis, _callbackTimer;
214 };
215 
216 #endif
Definition: modular-backend.h:152
virtual void messageBox(LogMessageType::Type type, const char *message)
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)
Definition: system.h:108
virtual int getGraphicsMode() const
Definition: str.h:59
virtual bool hasFeature(Feature f)
Definition: surface.h:67
virtual void getTimeAndDate(TimeDate &td, bool skipRecord=false) const
Definition: osystem_ds.h:56
Definition: background.h:33
virtual int getDefaultGraphicsMode() const
VideoState _currentState
Definition: osystem_ds.h:70
virtual void updateScreen()
virtual void showOverlay(bool inGUI)
virtual int16 getHeight()
Definition: pixelformat.h:138
virtual void setFeatureState(Feature f, bool enable)
Definition: system.h:721
Feature
Definition: system.h:405
virtual int16 getWidth()
Definition: list.h:44
virtual void grabOverlay(Graphics::Surface &surface)
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
virtual void engineInit()
Definition: rect.h:524
virtual PaletteManager * getPaletteManager()
Definition: osystem_ds.h:149
virtual void beginGFXTransaction()
virtual Graphics::PixelFormat getOverlayFormat() const
virtual void clearOverlay()
virtual void delayMillis(uint msecs)
virtual int getScreenChangeID() const
Type
Definition: log.h:33
Definition: ds-events.h:30
virtual Common::String getSystemLanguage() const
virtual void initBackend()
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask)
Definition: keyboard.h:29
virtual void unlockScreen()
virtual void quit()
virtual bool setStretchMode(int mode)
VideoState _oldState
Definition: osystem_ds.h:75
virtual const GraphicsMode * getSupportedStretchModes() const
TransactionError
Definition: system.h:1168
virtual void warpMouse(int x, int y)
virtual void engineDone()
Definition: archive.h:330
virtual void setShakePos(int shakeXOffset, int shakeYOffset)
virtual int16 getOverlayHeight() const
virtual uint32 getMillis(bool skipRecord=false)
virtual const OSystem::GraphicsMode * getSupportedGraphicsModes() const
Definition: hardware-input.h:199
virtual int getStretchMode() const
virtual void clearFocusRectangle()
Definition: rect.h:144
virtual bool isOverlayVisible() const
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format)
virtual void logMessage(LogMessageType::Type type, const char *message)
int _screenChangeID
Definition: osystem_ds.h:80
Definition: osystem_ds.h:40
virtual int16 getOverlayWidth() const
virtual void grabPalette(byte *colors, uint start, uint num) const
virtual bool setGraphicsMode(int mode, uint flags)
virtual void hideOverlay()
virtual Graphics::Surface * lockScreen()
virtual void setFocusRectangle(const Common::Rect &rect)
void initGraphics(int width, int height)
virtual void setCursorPalette(const byte *colors, uint start, uint num)
TransactionMode _transactionMode
Definition: osystem_ds.h:51
virtual bool showMouse(bool visible)
Definition: events.h:270
Definition: mutex.h:40
virtual bool getFeatureState(Feature f)
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h)
virtual Common::HardwareInputSet * getHardwareInputSet()
virtual void setPalette(const byte *colors, uint start, uint num)
Definition: paletteman.h:47
virtual int getDefaultStretchMode() const
virtual Common::MutexInternal * createMutex()
virtual OSystem::TransactionError endGFXTransaction()
Definition: background.h:62