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