scummvm/backends/platform/wii/osystem.h

218 lines
6.1 KiB
C
Raw Normal View History

/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _WII_OSYSTEM_H_
#define _WII_OSYSTEM_H_
#include <gctypes.h>
#include <gccore.h>
#include <gxflux/gfx.h>
#include "base/main.h"
#include "common/fs.h"
#include "common/rect.h"
#include "common/events.h"
#include "backends/base-backend.h"
2011-04-28 19:51:22 +03:00
#include "graphics/palette.h"
#include "graphics/surface.h"
#include "audio/mixer_intern.h"
#ifdef __cplusplus
extern "C" {
#endif
extern bool reset_btn_pressed;
extern bool power_btn_pressed;
#ifdef DEBUG_WII_MEMSTATS
extern void wii_memstats(void);
#endif
#ifdef __cplusplus
}
#endif
2020-10-16 17:46:43 +01:00
class OSystem_Wii final : public EventsBaseBackend, public PaletteManager {
private:
s64 _startup_time;
bool _cursorDontScale;
bool _cursorPaletteDisabled;
u16 *_cursorPalette;
bool _cursorPaletteDirty;
bool _gameRunning;
u16 _gameWidth, _gameHeight;
u8 *_gamePixels;
Graphics::Surface _surface;
gfx_screen_coords_t _coordsGame;
gfx_tex_t _texGame;
bool _gameDirty;
bool _overlayVisible;
u16 _overlayWidth, _overlayHeight;
u32 _overlaySize;
2012-06-20 17:14:51 +02:00
uint16 *_overlayPixels;
gfx_screen_coords_t _coordsOverlay;
gfx_tex_t _texOverlay;
bool _overlayDirty;
u32 _lastScreenUpdate;
u16 _currentWidth, _currentHeight;
f32 _currentXScale, _currentYScale;
s32 _configGraphicsMode;
s32 _actualGraphicsMode;
bool _bilinearFilter;
const Graphics::PixelFormat _pfRGB565;
const Graphics::PixelFormat _pfRGB3444;
#ifdef USE_RGB_COLOR
Graphics::PixelFormat _pfGame;
Graphics::PixelFormat _pfGameTexture;
Graphics::PixelFormat _pfCursor;
#endif
bool _consoleVisible;
bool _optionsDlgActive;
bool _fullscreen;
bool _arCorrection;
bool _mouseVisible;
s32 _mouseX, _mouseY;
s32 _mouseHotspotX, _mouseHotspotY;
u16 _mouseKeyColor;
gfx_tex_t _texMouse;
bool _kbd_active;
bool _event_quit;
u32 _lastPadCheck;
u8 _padSensitivity;
u8 _padAcceleration;
void initGfx();
void deinitGfx();
void updateScreenResolution();
void switchVideoMode(int mode);
bool needsScreenUpdate();
void initSfx();
void deinitSfx();
void initEvents();
void deinitEvents();
void updateEventScreenResolution();
bool pollKeyboard(Common::Event &event);
void showOptionsDialog();
protected:
Audio::MixerImpl *_mixer;
public:
enum {
gmStandard = 0,
gmStandardFiltered,
gmDoubleStrike,
gmDoubleStrikeFiltered
};
OSystem_Wii();
virtual ~OSystem_Wii();
2020-10-16 17:46:43 +01:00
virtual void initBackend() override;
virtual void engineInit() override;
virtual void engineDone() override;
2020-10-16 17:46:43 +01:00
virtual bool hasFeature(Feature f) override;
virtual void setFeatureState(Feature f, bool enable) override;
virtual bool getFeatureState(Feature f) override;
virtual const GraphicsMode *getSupportedGraphicsModes() const override;
virtual int getDefaultGraphicsMode() const override;
virtual bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) override;
#ifdef USE_RGB_COLOR
2020-10-16 17:46:43 +01:00
virtual Graphics::PixelFormat getScreenFormat() const override;
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
#endif
2020-10-16 17:46:43 +01:00
virtual int getGraphicsMode() const override;
virtual void initSize(uint width, uint height,
2020-10-16 17:46:43 +01:00
const Graphics::PixelFormat *format) override;
virtual int16 getWidth() override;
virtual int16 getHeight() override;
2020-10-16 17:46:43 +01:00
virtual PaletteManager *getPaletteManager() override { return this; }
protected:
2020-10-16 17:46:43 +01:00
virtual void setPalette(const byte *colors, uint start, uint num) override;
virtual void grabPalette(byte *colors, uint start, uint num) const override;
public:
2020-10-16 17:46:43 +01:00
virtual void setCursorPalette(const byte *colors, uint start, uint num) override;
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
2020-10-16 17:46:43 +01:00
int w, int h) override;
virtual void updateScreen() override;
virtual Graphics::Surface *lockScreen() override;
virtual void unlockScreen() override;
virtual void setShakePos(int shakeXOffset, int shakeYOffset) override;
virtual void showOverlay() override;
virtual void hideOverlay() override;
virtual bool isOverlayVisible() const override { return _overlayVisible; }
virtual void clearOverlay() override;
BACKENDS: fixed segfault in EventRecorder with buffer out of bounds writes ==3124361== Invalid write of size 8 ==3124361== at 0x483F803: memmove (vg_replace_strmem.c:1270) ==3124361== by 0x4DBF61: SurfaceSdlGraphicsManager::grabOverlay(void*, int) const (surfacesdl-graphics.cpp:1753) ==3124361== by 0x482051: ModularGraphicsBackend::grabOverlay(void*, int) (modular-backend.cpp:215) ==3124361== by 0x434EE1: GUI::ThemeEngine::clearAll() (ThemeEngine.cpp:376) ==3124361== by 0x40128E: GUI::EventRecorder::preDrawOverlayGui() (EventRecorder.cpp:558) ==3124361== by 0x481DB2: ModularGraphicsBackend::updateScreen() (modular-backend.cpp:173) ==3124361== by 0x559967: Graphics::Screen::updateScreen() (screen.cpp:62) ==3124361== by 0x55991C: Graphics::Screen::update() (screen.cpp:56) ==3124361== by 0x38AFC7: TwinE::TwineScreen::update() (twine.cpp:126) ==3124361== by 0x3B8759: TwinE::Screens::adjustPalette(unsigned char, unsigned char, unsigned char, unsigned int const*, int) (screens.cpp:150) ==3124361== by 0x3B8A89: TwinE::Screens::fadeToPal(unsigned int const*) (screens.cpp:207) ==3124361== by 0x3B8403: TwinE::Screens::loadImage(int, int, bool) (screens.cpp:80) ==3124361== Address 0x31453050 is 16 bytes after a block of size 512,000 alloc'd ==3124361== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==3124361== by 0x55B38C: Graphics::Surface::create(unsigned short, unsigned short, Graphics::PixelFormat const&) (surface.cpp:75) ==3124361== by 0x551111: Graphics::ManagedSurface::create(unsigned short, unsigned short, Graphics::PixelFormat const&) (managed_surface.cpp:153) ==3124361== by 0x4352D5: GUI::ThemeEngine::setGraphicsMode(GUI::ThemeEngine::GraphicsMode) (ThemeEngine.cpp:453) ==3124361== by 0x434A52: GUI::ThemeEngine::init() (ThemeEngine.cpp:324) ==3124361== by 0x43501B: GUI::ThemeEngine::refresh() (ThemeEngine.cpp:394) ==3124361== by 0x405780: GUI::GuiManager::screenChange() (gui-manager.cpp:603) ==3124361== by 0x405C6B: GUI::GuiManager::processEvent(Common::Event const&, GUI::Dialog*) (gui-manager.cpp:677) ==3124361== by 0x404EBA: GUI::GuiManager::runLoop() (gui-manager.cpp:429) ==3124361== by 0x3FD847: GUI::Dialog::runModal() (dialog.cpp:77) ==3124361== by 0x36D747: launcherDialog() (main.cpp:106) ==3124361== by 0x36FF92: scummvm_main (main.cpp:552) It looks like the _videoMode.overlayHeight in SurfaceSdlGraphicsManager::grabOverlay and ThemeEngine::_backBuffer::h are somehow out of sync after starting the game in a different resolution as the gui was started with. So the overlayHeight is updated - but the backbuffer (Surface) is not resized. This is with event recorder being active - right after starting the game and switching the resolution.
2021-06-16 20:05:03 +02:00
virtual void grabOverlay(Graphics::Surface &surface) override;
virtual void copyRectToOverlay(const void *buf, int pitch,
2020-10-16 17:46:43 +01:00
int x, int y, int w, int h) override;
virtual int16 getOverlayWidth() override;
virtual int16 getOverlayHeight() override;
virtual Graphics::PixelFormat getOverlayFormat() const override;
2020-10-16 17:46:43 +01:00
virtual bool showMouse(bool visible) override;
2020-10-16 17:46:43 +01:00
virtual void warpMouse(int x, int y) override;
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
int hotspotY, uint32 keycolor,
bool dontScale,
2020-10-16 17:46:43 +01:00
const Graphics::PixelFormat *format) override;
2020-10-16 17:46:43 +01:00
virtual bool pollEvent(Common::Event &event) override;
virtual uint32 getMillis(bool skipRecord = false) override;
virtual void delayMillis(uint msecs) override;
virtual Common::MutexInternal *createMutex() override;
typedef void (*SoundProc)(void *param, byte *buf, int len);
2020-10-16 17:46:43 +01:00
virtual void quit() override;
2020-10-16 17:46:43 +01:00
virtual Audio::Mixer *getMixer() override;
virtual FilesystemFactory *getFilesystemFactory() override;
virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
2020-10-16 17:46:43 +01:00
virtual void logMessage(LogMessageType::Type type, const char *message) override;
2011-06-06 10:43:48 +02:00
#ifndef GAMECUBE
2020-10-16 17:46:43 +01:00
virtual Common::String getSystemLanguage() const override;
#endif // GAMECUBE
};
#endif