ScummVM API documentation
osystem.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 #ifndef _WII_OSYSTEM_H_
23 #define _WII_OSYSTEM_H_
24 
25 #include <gctypes.h>
26 #include <gccore.h>
27 
28 #include <gxflux/gfx.h>
29 
30 #include "base/main.h"
31 #include "common/fs.h"
32 #include "common/rect.h"
33 #include "common/events.h"
34 #include "backends/base-backend.h"
35 #include "graphics/blit.h"
36 #include "graphics/paletteman.h"
37 #include "graphics/surface.h"
38 #include "audio/mixer_intern.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 extern bool reset_btn_pressed;
45 extern bool power_btn_pressed;
46 
47 #ifdef DEBUG_WII_MEMSTATS
48 extern void wii_memstats(void);
49 #endif
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 class OSystem_Wii final : virtual public BaseBackend, public Common::EventSource, public PaletteManager {
56 private:
57  s64 _startup_time;
58 
59  float _cursorScaleX;
60  float _cursorScaleY;
61  bool _cursorPaletteDisabled;
62  u16 *_cursorPalette;
63  bool _cursorPaletteDirty;
64 
65  bool _gameRunning;
66  u16 _gameWidth, _gameHeight;
67  u8 *_gamePixels, *_gamePixelsTexture;
68  Graphics::Surface _surface;
69  gfx_screen_coords_t _coordsGame;
70  gfx_tex_t _texGame;
71  bool _gameDirty;
72 
73  bool _overlayVisible;
74  u16 _overlayWidth, _overlayHeight;
75  u32 _overlaySize;
76  uint16 *_overlayPixels;
77  gfx_screen_coords_t _coordsOverlay;
78  gfx_tex_t _texOverlay;
79  bool _overlayDirty;
80  bool _overlayInGUI;
81 
82  Graphics::FastBlitFunc _blitFunc;
83  u32 _lastScreenUpdate;
84  u16 _currentWidth, _currentHeight;
85  f32 _currentXScale, _currentYScale;
86 
87  s32 _configGraphicsMode;
88  s32 _actualGraphicsMode;
89  bool _bilinearFilter;
90  const Graphics::PixelFormat _pfRGB565;
91  const Graphics::PixelFormat _pfRGB3444;
92  Graphics::PixelFormat _pfGame;
93  Graphics::PixelFormat _pfGameTexture;
94  Graphics::PixelFormat _pfCursor;
95 
96  bool _consoleVisible;
97  bool _optionsDlgActive;
98  bool _fullscreen;
99  bool _arCorrection;
100 
101  bool _mouseVisible;
102  s32 _mouseX, _mouseY;
103  s32 _mouseHotspotX, _mouseHotspotY;
104  u16 _mouseKeyColor;
105  gfx_tex_t _texMouse;
106 
107  bool _kbd_active;
108 
109  bool _event_quit;
110 
111  u32 _lastPadCheck;
112  u8 _padSensitivity;
113  u8 _padAcceleration;
114 
115  void initGfx();
116  void deinitGfx();
117  void updateScreenResolution();
118  void switchVideoMode(int mode);
119  bool needsScreenUpdate();
120  void updateMousePalette();
121 
122  void initSfx();
123  void deinitSfx();
124 
125  void initEvents();
126  void deinitEvents();
127  void updateEventScreenResolution();
128  bool pollKeyboard(Common::Event &event);
129 
130  void showOptionsDialog();
131 
132 protected:
133  Audio::MixerImpl *_mixer;
134 
135 public:
136  enum {
137  gmStandard = 0,
138  gmStandardFiltered,
139  gmDoubleStrike,
140  gmDoubleStrikeFiltered
141  };
142 
143  OSystem_Wii();
144  virtual ~OSystem_Wii();
145 
146  void initBackend() override;
147  void engineInit() override;
148  void engineDone() override;
149 
150  bool hasFeature(Feature f) override;
151  void setFeatureState(Feature f, bool enable) override;
152  bool getFeatureState(Feature f) override;
153  const GraphicsMode *getSupportedGraphicsModes() const override;
154  int getDefaultGraphicsMode() const override;
155  bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) override;
156 #ifdef USE_RGB_COLOR
157  Graphics::PixelFormat getScreenFormat() const override;
158  Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
159 #endif
160  int getGraphicsMode() const override;
161  virtual void initSize(uint width, uint height,
162  const Graphics::PixelFormat *format) override;
163  int16 getWidth() override;
164  int16 getHeight() override;
165 
166  PaletteManager *getPaletteManager() override { return this; }
167 protected:
168  void setPalette(const byte *colors, uint start, uint num) override;
169  void grabPalette(byte *colors, uint start, uint num) const override;
170 public:
171  void setCursorPalette(const byte *colors, uint start, uint num) override;
172  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
173  int w, int h) override;
174  void updateScreen() override;
175  Graphics::Surface *lockScreen() override;
176  void unlockScreen() override;
177  void setShakePos(int shakeXOffset, int shakeYOffset) override;
178 
179  void showOverlay(bool inGUI) override;
180  void hideOverlay() override;
181  bool isOverlayVisible() const override { return _overlayVisible; }
182  void clearOverlay() override;
183  void grabOverlay(Graphics::Surface &surface) override;
184  virtual void copyRectToOverlay(const void *buf, int pitch,
185  int x, int y, int w, int h) override;
186  int16 getOverlayWidth() const override;
187  int16 getOverlayHeight() const override;
188  Graphics::PixelFormat getOverlayFormat() const override;
189 
190  bool showMouse(bool visible) override;
191 
192  void warpMouse(int x, int y) override;
193  virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
194  int hotspotY, uint32 keycolor,
195  const Graphics::PixelFormat *format, const byte *mask,
196  frac_t scaleX, frac_t scaleY) override;
197 
198  bool pollEvent(Common::Event &event) override;
199  uint32 getMillis(bool skipRecord = false) override;
200  void delayMillis(uint msecs) override;
201 
203 
204  typedef void (*SoundProc)(void *param, byte *buf, int len);
205 
206  void quit() override;
207 
208  Audio::Mixer *getMixer() override;
210  void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
211 
212  void logMessage(LogMessageType::Type type, const char *message) override;
213 
214 #ifndef GAMECUBE
215  Common::String getSystemLanguage() const override;
216 #endif // GAMECUBE
217 };
218 
219 #endif
Audio::Mixer * getMixer() override
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const override
Definition: system.h:111
void engineInit() override
Definition: str.h:59
void engineDone() override
Definition: surface.h:67
Definition: system.h:790
void hideOverlay() override
Definition: fs-factory.h:31
void warpMouse(int x, int y) override
Definition: pixelformat.h:138
Definition: system.h:741
Feature
Definition: system.h:415
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format) override
Common::MutexInternal * createMutex() override
Definition: list.h:44
void clearOverlay() override
const GraphicsMode * getSupportedGraphicsModes() const override
int getGraphicsMode() const override
void quit() override
PaletteManager * getPaletteManager() override
Definition: osystem.h:166
int16 getOverlayHeight() const override
FilesystemFactory * getFilesystemFactory() override
void setPalette(const byte *colors, uint start, uint num) override
Type
Definition: log.h:33
Definition: mixer_intern.h:58
void grabPalette(byte *colors, uint start, uint num) const override
void setCursorPalette(const byte *colors, uint start, uint num) override
void unlockScreen() override
Definition: mixer.h:70
void updateScreen() override
bool setGraphicsMode(int mode, uint flags=kGfxModeNoFlags) override
int16 getHeight() override
Definition: base-backend.h:31
int16 getOverlayWidth() const override
bool hasFeature(Feature f) override
Definition: events.h:218
Common::String getSystemLanguage() const override
bool showMouse(bool visible) override
bool isOverlayVisible() const override
Definition: osystem.h:181
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override
void setFeatureState(Feature f, bool enable) override
bool pollEvent(Common::Event &event) override
void delayMillis(uint msecs) override
Graphics::PixelFormat getOverlayFormat() const override
void grabOverlay(Graphics::Surface &surface) override
int getDefaultGraphicsMode() const override
void showOverlay(bool inGUI) override
Definition: events.h:278
Definition: mutex.h:40
Definition: osystem.h:55
void setShakePos(int shakeXOffset, int shakeYOffset) override
uint32 getMillis(bool skipRecord=false) override
Definition: paletteman.h:47
int32 frac_t
Definition: frac.h:52
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format, const byte *mask, frac_t scaleX, frac_t scaleY) override
int16 getWidth() override
void initBackend() override
Graphics::Surface * lockScreen() override
void logMessage(LogMessageType::Type type, const char *message) override
bool getFeatureState(Feature f) override