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
|
/* 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 PLATFORM_3DS_H
#define PLATFORM_3DS_H
#include <citro3d.h>
#include "backends/mutex/mutex.h"
#include "backends/base-backend.h"
#include "graphics/palette.h"
#include "base/main.h"
#include "audio/mixer_intern.h"
#include "backends/graphics/graphics.h"
#include "backends/platform/3ds/sprite.h"
#include "common/rect.h"
#include "common/queue.h"
#define TICKS_PER_MSEC 268123
namespace _3DS {
enum {
GFX_LINEAR = 0,
GFX_NEAREST = 1
};
enum InputMode {
MODE_HOVER,
MODE_DRAG,
};
static const OSystem::GraphicsMode s_graphicsModes[] = {
{"default", "Default Test", GFX_LINEAR},
{ 0, 0, 0 }
};
class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
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);
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &t) const;
virtual MutexRef createMutex();
virtual void lockMutex(MutexRef mutex);
virtual void unlockMutex(MutexRef mutex);
virtual void deleteMutex(MutexRef mutex);
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::String getDefaultConfigFileName();
// Graphics
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
int getDefaultGraphicsMode() const;
bool setGraphicsMode(int mode);
void resetGraphicsScale();
int getGraphicsMode() const;
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 0; };
void beginGFXTransaction();
OSystem::TransactionError endGFXTransaction();
int16 getHeight(){ return _gameHeight; }
int16 getWidth(){ return _gameWidth; }
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 shakeOffset);
void setFocusRectangle(const Common::Rect &rect);
void clearFocusRectangle();
void showOverlay();
void hideOverlay();
Graphics::PixelFormat getOverlayFormat() const;
void clearOverlay();
void grabOverlay(void *buf, int pitch);
void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w,
int h);
virtual int16 getOverlayHeight();
virtual int16 getOverlayWidth();
virtual void displayMessageOnOSD(const char *msg);
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);
void setCursorPalette(const byte *colors, uint start, uint num);
// Transform point from touchscreen coords into gamescreen coords
void transformPoint(touchPosition &point);
void setCursorDelta(float deltaX, float deltaY);
void updateFocus();
void updateConfig();
void updateSize();
private:
void initGraphics();
void destroyGraphics();
void initAudio();
void destroyAudio();
void initEvents();
void destroyEvents();
void flushGameScreen();
void flushCursor();
protected:
Audio::MixerImpl *_mixer;
private:
u16 _gameWidth, _gameHeight;
u16 _gameTopX, _gameTopY;
u16 _gameBottomX, _gameBottomY;
// Audio
Thread audioThread;
// Graphics
Graphics::PixelFormat _pfGame;
Graphics::PixelFormat _pfGameTexture;
Graphics::PixelFormat _pfCursor;
byte _palette[3 * 256];
byte _cursorPalette[3 * 256];
Graphics::Surface _gameScreen;
Sprite _gameTopTexture;
Sprite _gameBottomTexture;
Sprite _overlay;
int _screenShakeOffset;
bool _overlayVisible;
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 _cursorX, _cursorY;
float _cursorDeltaX, _cursorDeltaY;
int _cursorHotspotX, _cursorHotspotY;
uint32 _cursorKeyColor;
};
} // namespace _3DS
#endif
|