aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/default-palette.h63
-rw-r--r--backends/graphics/graphics.h4
-rw-r--r--backends/graphics/opengl/opengl-graphics.h4
-rw-r--r--backends/graphics/sdl/sdl-graphics.h5
-rw-r--r--backends/modular-backend.cpp8
-rw-r--r--backends/modular-backend.h3
-rw-r--r--backends/platform/android/android.cpp8
-rw-r--r--backends/platform/dc/dc.h7
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h10
-rw-r--r--backends/platform/iphone/osys_main.h8
-rw-r--r--backends/platform/n64/osys_n64.h8
-rw-r--r--backends/platform/ps2/systemps2.h10
-rw-r--r--backends/platform/psp/default_display_client.h2
-rw-r--r--backends/platform/psp/osys_psp.cpp4
-rw-r--r--backends/platform/psp/osys_psp.h6
-rw-r--r--backends/platform/wii/osystem.h6
16 files changed, 134 insertions, 22 deletions
diff --git a/backends/graphics/default-palette.h b/backends/graphics/default-palette.h
new file mode 100644
index 0000000000..6e3a75350e
--- /dev/null
+++ b/backends/graphics/default-palette.h
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BACKENDS_GRAPHICS_DEFAULT_PALETTE_H
+#define BACKENDS_GRAPHICS_DEFAULT_PALETTE_H
+
+#include "graphics/palette.h"
+
+/**
+ * This is a default implementation of the PaletteManager interface
+ * which ensures that grabPalette works as specified. Of course
+ * it is still necessary to provide code that actually updates
+ * the (possibly emulated) "hardware" palette of the backend.
+ * For this purpose, implement the abstract setPaletteIntern
+ * method.
+ */
+class DefaultPaletteManager : public PaletteManager {
+protected:
+ byte _palette[4 * 256];
+
+ /**
+ * Subclasses should only implement this method and none of the others.
+ * Its semantics are like that of setPalette, only that it does not need
+ * to worry about making it possible to query the palette values once they
+ * have been set.
+ */
+ virtual void setPaletteIntern(const byte *colors, uint start, uint num) = 0;
+
+public:
+ void setPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ memcpy(_palette + 4 * start, colors, 4 * num);
+ setPaletteIntern(colors, start, num);
+ }
+ void grabPalette(byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ memcpy(colors, _palette + 4 * start, 4 * num);
+ }
+};
+
+#endif
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index d2ce6534e1..953171d089 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -30,11 +30,13 @@
#include "common/noncopyable.h"
#include "common/keyboard.h"
+#include "graphics/palette.h"
+
/**
* Abstract class for graphics manager. Subclasses
* implement the real functionality.
*/
-class GraphicsManager : Common::NonCopyable {
+class GraphicsManager : public PaletteManager {
public:
virtual ~GraphicsManager() {}
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index b0334471f1..27c850f0ab 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -81,8 +81,12 @@ public:
virtual int16 getHeight();
virtual int16 getWidth();
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual Graphics::Surface *lockScreen();
virtual void unlockScreen();
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index 6a55a3d489..0daaab104c 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -101,8 +101,13 @@ public:
virtual int16 getHeight();
virtual int16 getWidth();
+
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual Graphics::Surface *lockScreen();
virtual void unlockScreen();
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index df3d631007..52edcebd24 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -132,12 +132,8 @@ int16 ModularBackend::getWidth() {
return _graphicsManager->getWidth();
}
-void ModularBackend::setPalette(const byte *colors, uint start, uint num) {
- _graphicsManager->setPalette(colors, start, num);
-}
-
-void ModularBackend::grabPalette(byte *colors, uint start, uint num) {
- _graphicsManager->grabPalette(colors, start, num);
+PaletteManager *ModularBackend::getPaletteManager() {
+ return _graphicsManager;
}
void ModularBackend::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 5b031880ed..0f9b604de4 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -87,8 +87,7 @@ public:
virtual int16 getHeight();
virtual int16 getWidth();
- virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual PaletteManager *getPaletteManager();
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual Graphics::Surface *lockScreen();
virtual void unlockScreen();
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 7a4ae24e6b..b790dab036 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -153,7 +153,7 @@ static void checkGlError(const char* file, int line) {
#define CHECK_GL_ERROR() do {} while (false)
#endif
-class OSystem_Android : public BaseBackend {
+class OSystem_Android : public BaseBackend, public PaletteManager {
private:
jobject _back_ptr; // back pointer to (java) peer instance
jmethodID MID_displayMessageOnOSD;
@@ -238,8 +238,14 @@ public:
virtual int getScreenChangeID() const { return _screen_changeid; }
virtual int16 getHeight();
virtual int16 getWidth();
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void updateScreen();
virtual Graphics::Surface *lockScreen();
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index b78e5f13df..f1d7454007 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -69,7 +69,7 @@ class DCCDManager : public DefaultAudioCDManager {
void updateCD();
};
-class OSystem_Dreamcast : private DCHardware, public BaseBackend, public FilesystemFactory {
+class OSystem_Dreamcast : private DCHardware, public BaseBackend, public PaletteManager, public FilesystemFactory {
public:
OSystem_Dreamcast();
@@ -98,9 +98,14 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys
int getGraphicsMode() const;
// Set colors of the palette
+ PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
void setPalette(const byte *colors, uint start, uint num);
void grabPalette(byte *colors, uint start, uint num);
+public:
+
// Determine the pixel format currently in use for screen rendering.
Graphics::PixelFormat getScreenFormat() const;
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 50a4353e18..27d75e5124 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -37,7 +37,7 @@
#include "graphics/surface.h"
#include "graphics/colormasks.h"
-class OSystem_DS : public BaseBackend {
+class OSystem_DS : public BaseBackend, public PaletteManager {
protected:
int eventNum;
@@ -92,8 +92,14 @@ public:
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
virtual int16 getHeight();
virtual int16 getWidth();
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(unsigned char *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
void restoreHardwarePalette();
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index c925078b46..df01af798a 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -51,7 +51,7 @@ typedef struct AQCallbackStruct {
AudioStreamBasicDescription dataFormat;
} AQCallbackStruct;
-class OSystem_IPHONE : public BaseBackend {
+class OSystem_IPHONE : public BaseBackend, public PaletteManager {
protected:
static const OSystem::GraphicsMode s_supportedGraphicsModes[];
@@ -132,8 +132,14 @@ public:
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
virtual int16 getHeight();
virtual int16 getWidth();
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void updateScreen();
virtual Graphics::Surface *lockScreen();
diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h
index f0dc6959c1..4b2164cc9f 100644
--- a/backends/platform/n64/osys_n64.h
+++ b/backends/platform/n64/osys_n64.h
@@ -75,7 +75,7 @@ enum GraphicModeID {
OVERS_MPAL_340X240
};
-class OSystem_N64 : public BaseBackend {
+class OSystem_N64 : public BaseBackend, public PaletteManager {
protected:
Common::SaveFileManager *_savefile;
Audio::MixerImpl *_mixer;
@@ -158,8 +158,14 @@ public:
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
virtual int16 getHeight();
virtual int16 getWidth();
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+
+public:
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void updateScreen();
virtual Graphics::Surface *lockScreen();
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 78973ed3f0..37575f399f 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -54,7 +54,7 @@ namespace Audio {
class MixerImpl;
};
-class OSystem_PS2 : public BaseBackend {
+class OSystem_PS2 : public BaseBackend, public PaletteManager {
public:
OSystem_PS2(const char *elfPath);
virtual ~OSystem_PS2(void);
@@ -64,10 +64,16 @@ public:
virtual int16 getHeight(void);
virtual int16 getWidth(void);
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num);
+public:
+
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void setShakePos(int shakeOffset);
- virtual void grabPalette(byte *colors, uint start, uint num);
virtual bool grabRawScreen(Graphics::Surface *surf);
virtual Graphics::Surface *lockScreen();
virtual void unlockScreen();
diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h
index 2e33632eb1..c7189b0168 100644
--- a/backends/platform/psp/default_display_client.h
+++ b/backends/platform/psp/default_display_client.h
@@ -69,7 +69,7 @@ protected:
class Overlay : public DefaultDisplayClient {
public:
Overlay() {}
- ~Overlay() { }
+ ~Overlay() {}
void init();
bool allocate();
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 025edeb684..73a030f5d1 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -273,11 +273,11 @@ void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i
}
int16 OSystem_PSP::getOverlayWidth() {
- return (int16) _overlay.getWidth();
+ return (int16)_overlay.getWidth();
}
int16 OSystem_PSP::getOverlayHeight() {
- return (int16) _overlay.getHeight();
+ return (int16)_overlay.getHeight();
}
void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) {
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index d21c7e78ef..8d274bb5bd 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -44,7 +44,7 @@
#include "backends/timer/psp/timer.h"
#include "backends/platform/psp/thread.h"
-class OSystem_PSP : public BaseBackend {
+class OSystem_PSP : public BaseBackend, public PaletteManager {
private:
Common::SaveFileManager *_savefile;
@@ -94,8 +94,12 @@ public:
int16 getHeight();
// Palette related
+ PaletteManager *getPaletteManager() { return this; }
+protected:
+ // PaletteManager API
void setPalette(const byte *colors, uint start, uint num);
void grabPalette(byte *colors, uint start, uint num);
+public:
void setCursorPalette(const byte *colors, uint start, uint num);
void disableCursorPalette(bool disable);
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index ddfa905a77..9ed4b16d79 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -54,7 +54,7 @@ extern void wii_memstats(void);
}
#endif
-class OSystem_Wii : public BaseBackend {
+class OSystem_Wii : public BaseBackend, public PaletteManager {
private:
s64 _startup_time;
@@ -164,8 +164,12 @@ public:
const Graphics::PixelFormat *format);
virtual int16 getWidth();
virtual int16 getHeight();
+
+ virtual PaletteManager *getPaletteManager() { return this; }
+protected:
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(byte *colors, uint start, uint num);
+public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual void disableCursorPalette(bool disable);
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y,