1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
|
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PLATFORM_3DS_H
#define PLATFORM_3DS_H
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
#include "backends/base-backend.h"
#include "graphics/paletteman.h"
#include "base/main.h"
#include "audio/mixer_intern.h"
#include "backends/graphics/graphics.h"
#include "backends/log/log.h"
#include "backends/platform/3ds/sprite.h"
#include "common/rect.h"
#include "common/queue.h"
#include "common/ustr.h"
#include "engines/engine.h"
#define TICKS_PER_MSEC 268123
namespace N3DS {
enum MagnifyMode {
MODE_MAGON,
MODE_MAGOFF,
};
enum InputMode {
MODE_HOVER,
MODE_DRAG,
};
enum GraphicsModeID {
RGBA8,
RGB565,
RGB555,
RGB5A1,
RGBA4,
CLUT8
};
enum Screen {
kScreenTop = 0x10000002,
kScreenBottom,
kScreenBoth,
};
enum TransactionState {
kTransactionNone = 0,
kTransactionActive = 1,
kTransactionRollback = 2
};
struct TransactionDetails {
bool formatChanged, modeChanged;
TransactionDetails() {
formatChanged = false;
modeChanged = false;
}
};
typedef struct GfxMode3DS {
Graphics::PixelFormat surfaceFormat;
GPU_TEXCOLOR textureFormat;
uint32 textureTransferFlags;
} GfxMode3DS;
struct GfxState {
bool setup;
GraphicsModeID gfxModeID;
const GfxMode3DS *gfxMode;
GfxState() {
setup = false;
gfxModeID = CLUT8;
}
};
class OSystem_3DS : public EventsBaseBackend, public PaletteManager, public Common::EventObserver {
public:
OSystem_3DS();
virtual ~OSystem_3DS();
volatile bool exiting;
volatile bool sleeping;
virtual void initBackend();
virtual bool hasFeature(OSystem::Feature f);
virtual void setFeatureState(OSystem::Feature f, bool enable);
virtual bool getFeatureState(OSystem::Feature f);
bool pollEvent(Common::Event &event) override;
bool notifyEvent(const Common::Event &event) override;
Common::HardwareInputSet *getHardwareInputSet() override;
Common::KeymapArray getGlobalKeymaps() override;
Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() override;
void registerDefaultSettings(const Common::String &target) const override;
GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
void applyBackendSettings() override;
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
virtual Common::MutexInternal *createMutex();
virtual void logMessage(LogMessageType::Type type, const char *message);
virtual Audio::Mixer *getMixer();
virtual PaletteManager *getPaletteManager() { return this; }
virtual Common::String getSystemLanguage() const;
virtual void fatalError();
virtual void quit();
virtual Common::Path getDefaultConfigFileName();
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority) override;
// Graphics
inline Graphics::PixelFormat getScreenFormat() const { return _pfGame; }
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
void initSize(uint width, uint height,
const Graphics::PixelFormat *format = NULL);
virtual int getScreenChangeID() const { return _screenChangeId; };
GraphicsModeID chooseMode(Graphics::PixelFormat *format);
bool setGraphicsMode(GraphicsModeID modeID);
void beginGFXTransaction();
OSystem::TransactionError endGFXTransaction();
int16 getHeight(){ return _gameHeight; }
int16 getWidth(){ return _gameWidth; }
float getScaleRatio() const;
void setPalette(const byte *colors, uint start, uint num);
void grabPalette(byte *colors, uint start, uint num) const;
void copyRectToScreen(const void *buf, int pitch, int x, int y, int w,
int h);
Graphics::Surface *lockScreen();
void unlockScreen();
void updateScreen();
void setShakePos(int shakeXOffset, int shakeYOffset);
void setFocusRectangle(const Common::Rect &rect);
void clearFocusRectangle();
void showOverlay(bool inGUI);
void hideOverlay();
bool isOverlayVisible() const { return _overlayVisible; }
Graphics::PixelFormat getOverlayFormat() const;
void clearOverlay();
void grabOverlay(Graphics::Surface &surface);
void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w,
int h);
virtual int16 getOverlayHeight();
virtual int16 getOverlayWidth();
void displayMessageOnOSD(const Common::U32String &msg) override;
void displayActivityIconOnOSD(const Graphics::Surface *icon) override;
bool showMouse(bool visible);
void warpMouse(int x, int y);
void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
int hotspotY, uint32 keycolor, bool dontScale = false,
const Graphics::PixelFormat *format = NULL, const byte *mask = NULL);
void setCursorPalette(const byte *colors, uint start, uint num);
// Transform point from touchscreen coords into gamescreen coords
void transformPoint(touchPosition &point);
// Clip point to gamescreen coords
void clipPoint(touchPosition &point);
void setCursorDelta(float deltaX, float deltaY);
void updateFocus();
void updateMagnify();
void updateBacklight();
void updateConfig();
void updateSize();
private:
void init3DSGraphics();
void destroy3DSGraphics();
void initAudio();
void destroyAudio();
void initEvents();
void destroyEvents();
void flushGameScreen();
void flushCursor();
virtual Common::Path getDefaultLogFileName();
virtual Common::WriteStream *createLogFile();
protected:
Audio::MixerImpl *_mixer;
Backends::Log::Log *_logger;
private:
u16 _gameWidth, _gameHeight;
u16 _gameTopX, _gameTopY;
u16 _gameBottomX, _gameBottomY;
// Audio
Thread audioThread;
// Graphics
GraphicsModeID _graphicsModeID;
TransactionState _transactionState;
TransactionDetails _transactionDetails;
GfxState _gfxState, _oldGfxState;
Graphics::PixelFormat _pfDefaultTexture;
Graphics::PixelFormat _pfGame, _oldPfGame;
Graphics::PixelFormat _pfCursor;
byte _palette[3 * 256];
byte _cursorPalette[3 * 256];
uint32 _paletteMap[256];
Graphics::Surface _gameScreen;
bool _gameTextureDirty;
Sprite _gameTopTexture;
Sprite _gameBottomTexture;
Sprite _overlay;
Sprite _activityIcon;
Sprite _osdMessage;
bool _filteringEnabled;
enum {
kOSDMessageDuration = 800
};
uint32 _osdMessageEndTime;
int _screenShakeXOffset;
int _screenShakeYOffset;
bool _overlayVisible;
bool _overlayInGUI;
int _screenChangeId;
DVLB_s *_dvlb;
shaderProgram_s _program;
int _projectionLocation;
int _modelviewLocation;
C3D_Mtx _projectionTop;
C3D_Mtx _projectionBottom;
C3D_RenderTarget* _renderTargetTop;
C3D_RenderTarget* _renderTargetBottom;
// Focus
Common::Rect _focusRect;
bool _focusDirty;
C3D_Mtx _focusMatrix;
int _focusPosX, _focusPosY;
int _focusTargetPosX, _focusTargetPosY;
float _focusStepPosX, _focusStepPosY;
float _focusScaleX, _focusScaleY;
float _focusTargetScaleX, _focusTargetScaleY;
float _focusStepScaleX, _focusStepScaleY;
uint32 _focusClearTime;
// Events
Thread _eventThread;
Thread _timerThread;
Common::Queue<Common::Event> _eventQueue;
// Cursor
Graphics::Surface _cursor;
Sprite _cursorTexture;
bool _cursorPaletteEnabled;
bool _cursorVisible;
bool _cursorScalable;
float _cursorScreenX, _cursorScreenY;
float _cursorOverlayX, _cursorOverlayY;
float _cursorDeltaX, _cursorDeltaY;
int _cursorHotspotX, _cursorHotspotY;
uint32 _cursorKeyColor;
// Magnify
MagnifyMode _magnifyMode;
u16 _magX, _magY;
u16 _magWidth, _magHeight;
u16 _magCenterX, _magCenterY;
Common::Path _logFilePath;
public:
// Pause
PauseToken _sleepPauseToken;
bool _showCursor;
bool _snapToBorder;
bool _stretchToFit;
Screen _screen;
};
} // namespace N3DS
#endif
|