2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2006-07-09 11:47:17 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 02:34:19 +01:00
|
|
|
*
|
2006-07-09 11:47:17 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:19 +01:00
|
|
|
*
|
2006-07-09 11:47:17 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-07-05 16:11:11 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2006-07-09 11:47:17 +00:00
|
|
|
*/
|
2009-01-01 15:06:43 +00:00
|
|
|
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
#ifndef _OSYSTEM_DS_H_
|
|
|
|
#define _OSYSTEM_DS_H_
|
2009-01-30 03:35:47 +00:00
|
|
|
|
2018-04-07 17:45:47 +01:00
|
|
|
// Allow use of stuff in <nds.h>
|
|
|
|
#define FORBIDDEN_SYMBOL_EXCEPTION_printf
|
|
|
|
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
|
2017-11-14 23:00:56 +00:00
|
|
|
|
2009-01-30 03:35:47 +00:00
|
|
|
#include "backends/base-backend.h"
|
2020-08-06 15:04:24 +01:00
|
|
|
#include "backends/events/ds/ds-events.h"
|
2006-07-09 11:47:17 +00:00
|
|
|
#include "nds.h"
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer_intern.h"
|
2007-08-18 11:10:41 +00:00
|
|
|
#include "graphics/surface.h"
|
2011-04-28 22:19:35 +03:00
|
|
|
#include "graphics/palette.h"
|
2006-10-25 19:18:38 +00:00
|
|
|
|
2020-08-11 22:28:25 +01:00
|
|
|
enum {
|
|
|
|
GFX_NOSCALE = 0,
|
|
|
|
GFX_HWSCALE = 1,
|
|
|
|
GFX_SWSCALE = 2
|
|
|
|
};
|
|
|
|
|
2020-08-06 15:04:24 +01:00
|
|
|
class OSystem_DS : public BaseBackend, public PaletteManager {
|
2007-12-21 18:36:40 +00:00
|
|
|
protected:
|
2010-07-05 16:10:22 +00:00
|
|
|
Audio::MixerImpl *_mixer;
|
2020-08-11 17:37:26 +01:00
|
|
|
Graphics::Surface _framebuffer, _overlay, _cursor;
|
2020-08-09 22:54:32 +01:00
|
|
|
bool _graphicsEnable, _isOverlayShown;
|
2020-08-11 22:28:25 +01:00
|
|
|
int _graphicsMode, _stretchMode;
|
2006-11-03 23:16:29 +00:00
|
|
|
|
2010-07-05 16:10:22 +00:00
|
|
|
static OSystem_DS *_instance;
|
2008-09-15 22:43:20 +00:00
|
|
|
|
|
|
|
u16 _palette[256];
|
|
|
|
u16 _cursorPalette[256];
|
|
|
|
|
2020-08-11 17:37:26 +01:00
|
|
|
u16 *_cursorSprite;
|
|
|
|
Common::Point _cursorPos;
|
2008-09-15 22:43:20 +00:00
|
|
|
int _cursorHotX;
|
|
|
|
int _cursorHotY;
|
|
|
|
byte _cursorKey;
|
2020-08-11 17:37:26 +01:00
|
|
|
bool _cursorVisible;
|
2008-09-15 22:43:20 +00:00
|
|
|
|
2020-08-06 15:04:24 +01:00
|
|
|
DSEventSource *_eventSource;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2010-07-05 16:10:22 +00:00
|
|
|
Graphics::Surface *createTempFrameBuffer();
|
2008-09-15 22:43:20 +00:00
|
|
|
bool _disableCursorPalette;
|
2006-07-09 11:47:17 +00:00
|
|
|
|
|
|
|
public:
|
2007-12-21 18:36:40 +00:00
|
|
|
typedef int (*TimerProc)(int interval);
|
2006-07-09 11:47:17 +00:00
|
|
|
|
|
|
|
OSystem_DS();
|
|
|
|
virtual ~OSystem_DS();
|
|
|
|
|
2007-12-21 18:36:40 +00:00
|
|
|
static OSystem_DS *instance() { return _instance; }
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual bool hasFeature(Feature f);
|
|
|
|
virtual void setFeatureState(Feature f, bool enable);
|
|
|
|
virtual bool getFeatureState(Feature f);
|
2020-08-11 22:28:25 +01:00
|
|
|
|
|
|
|
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
|
|
|
|
virtual int getDefaultGraphicsMode() const;
|
|
|
|
virtual bool setGraphicsMode(int mode);
|
|
|
|
virtual int getGraphicsMode() const;
|
|
|
|
|
|
|
|
virtual const GraphicsMode *getSupportedStretchModes() const;
|
|
|
|
virtual int getDefaultStretchMode() const;
|
|
|
|
virtual bool setStretchMode(int mode);
|
|
|
|
virtual int getStretchMode() const;
|
|
|
|
|
2009-09-27 16:06:06 +00:00
|
|
|
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual int16 getHeight();
|
|
|
|
virtual int16 getWidth();
|
2011-02-07 17:52:38 +00:00
|
|
|
|
|
|
|
virtual PaletteManager *getPaletteManager() { return this; }
|
|
|
|
protected:
|
|
|
|
// PaletteManager API
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual void setPalette(const byte *colors, uint start, uint num);
|
2017-10-15 13:46:41 -05:00
|
|
|
virtual void grabPalette(byte *colors, uint start, uint num) const;
|
2011-02-07 17:52:38 +00:00
|
|
|
|
|
|
|
public:
|
2012-06-16 02:18:01 +02:00
|
|
|
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual void updateScreen();
|
2019-11-15 01:38:21 -08:00
|
|
|
virtual void setShakePos(int shakeXOffset, int shakeYOffset);
|
2006-07-09 11:47:17 +00:00
|
|
|
|
|
|
|
virtual void showOverlay();
|
|
|
|
virtual void hideOverlay();
|
2020-09-14 13:11:57 +01:00
|
|
|
virtual bool isOverlayVisible() const;
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual void clearOverlay();
|
2012-06-16 04:17:14 +02:00
|
|
|
virtual void grabOverlay(void *buf, int pitch);
|
|
|
|
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h);
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual int16 getOverlayHeight();
|
|
|
|
virtual int16 getOverlayWidth();
|
2020-08-09 22:54:32 +01:00
|
|
|
virtual Graphics::PixelFormat getOverlayFormat() const;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2020-08-09 22:54:32 +01:00
|
|
|
Common::Point transformPoint(uint16 x, uint16 y);
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual bool showMouse(bool visible);
|
|
|
|
|
|
|
|
virtual void warpMouse(int x, int y);
|
2012-06-16 03:10:43 +02:00
|
|
|
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, bool dontScale, const Graphics::PixelFormat *format);
|
2006-07-09 11:47:17 +00:00
|
|
|
|
2013-05-17 00:18:09 +03:00
|
|
|
virtual uint32 getMillis(bool skipRecord = false);
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual void delayMillis(uint msecs);
|
2009-10-08 19:41:38 +00:00
|
|
|
virtual void getTimeAndDate(TimeDate &t) const;
|
2006-07-09 11:47:17 +00:00
|
|
|
|
2020-08-06 15:04:24 +01:00
|
|
|
virtual Common::EventSource *getDefaultEventSource() { return _eventSource; }
|
|
|
|
virtual Common::HardwareInputSet *getHardwareInputSet();
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual MutexRef createMutex(void);
|
|
|
|
virtual void lockMutex(MutexRef mutex);
|
|
|
|
virtual void unlockMutex(MutexRef mutex);
|
|
|
|
virtual void deleteMutex(MutexRef mutex);
|
|
|
|
|
|
|
|
virtual void quit();
|
|
|
|
|
|
|
|
virtual void setFocusRectangle(const Common::Rect& rect);
|
|
|
|
virtual void clearFocusRectangle();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2020-08-09 22:54:32 +01:00
|
|
|
virtual void engineInit();
|
|
|
|
virtual void engineDone();
|
|
|
|
|
2006-07-09 11:47:17 +00:00
|
|
|
virtual void initBackend();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2007-08-18 11:10:41 +00:00
|
|
|
virtual Graphics::Surface *lockScreen();
|
|
|
|
virtual void unlockScreen();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2010-07-05 16:10:22 +00:00
|
|
|
virtual Audio::Mixer *getMixer() { return _mixer; }
|
2008-07-09 16:50:23 +00:00
|
|
|
|
2006-11-03 23:16:29 +00:00
|
|
|
static int timerHandler(int t);
|
2007-06-30 23:03:03 +00:00
|
|
|
|
2008-09-15 22:43:20 +00:00
|
|
|
virtual void setCursorPalette(const byte *colors, uint start, uint num);
|
|
|
|
|
2020-08-11 17:37:26 +01:00
|
|
|
void refreshCursor(u16 *dst, const Graphics::Surface &src, const uint16 *palette);
|
2009-09-27 22:42:21 +00:00
|
|
|
|
2011-06-06 10:55:28 +02:00
|
|
|
virtual void logMessage(LogMessageType::Type type, const char *message);
|
2006-07-09 11:47:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|