COMMON: OSystem now has a PaletteManager

svn-id: r55806
This commit is contained in:
Max Horn 2011-02-07 17:52:38 +00:00
parent 8981fa3f16
commit ab039812e7
73 changed files with 367 additions and 203 deletions

View File

@ -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

View File

@ -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() {}

View File

@ -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();

View File

@ -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();

View File

@ -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) {

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -69,7 +69,7 @@ protected:
class Overlay : public DefaultDisplayClient {
public:
Overlay() {}
~Overlay() { }
~Overlay() {}
void init();
bool allocate();

View File

@ -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) {

View File

@ -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);

View File

@ -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,

View File

@ -93,4 +93,3 @@ void OSystem::logMessage(LogMessageType::Type type, const char *message) {
Common::String OSystem::getSystemLanguage() const {
return "en_US";
}

View File

@ -31,6 +31,7 @@
#include "common/rect.h"
#include "common/list.h" // For OSystem::getSupportedFormats()
#include "graphics/palette.h" // for PaletteManager
#include "graphics/pixelformat.h"
namespace Audio {
@ -54,6 +55,7 @@ namespace Common {
class AudioCDManager;
class FilesystemFactory;
class PaletteManager;
/**
* A structure describing time and date. This is a clone of struct tm
@ -517,66 +519,10 @@ public:
virtual int16 getWidth() = 0;
/**
* Replace the specified range of the palette with new colors.
* The palette entries from 'start' till (start+num-1) will be replaced - so
* a full palette update is accomplished via start=0, num=256.
*
* The palette data is specified in interleaved RGBA format. That is, the
* first byte of the memory block 'colors' points at is the red component
* of the first new color; the second byte the green component of the first
* new color; the third byte the blue component, the last byte to the alpha
* (transparency) value. Then the second color starts, and so on. So memory
* looks like this: R1-G1-B1-A1-R2-G2-B2-A2-R3-...
*
* @param colors the new palette data, in interleaved RGBA format
* @param start the first palette entry to be updated
* @param num the number of palette entries to be updated
*
* @note It is an error if start+num exceeds 256, behaviour is undefined
* in that case (the backend may ignore it silently or assert).
* @note It is an error if this function gets called when the pixel format
* in use (the return value of getScreenFormat) has more than one
* byte per pixel.
* @note The alpha value is not actually used, and future revisions of this
* API are probably going to remove it.
*
* @see getScreenFormat
* Return the palette manager singleton. For more information, refer
* to the PaletteManager documentation.
*/
virtual void setPalette(const byte *colors, uint start, uint num) = 0;
/**
* Grabs a specified part of the currently active palette.
* The format is the same as for setPalette.
*
* This should return exactly the same RGB data as was setup via previous
* setPalette calls.
*
* For example, for every valid value of start and num of the following
* code:
*
* byte origPal[num*4];
* // Setup origPal's data however you like
* g_system->setPalette(origPal, start, num);
* byte obtainedPal[num*4];
* g_system->grabPalette(obtainedPal, start, num);
*
* the following should be true:
*
* For each i < num : memcmp(&origPal[i*4], &obtainedPal[i*4], 3) == 0
* (i is an uint here)
*
* @see setPalette
* @param colors the palette data, in interleaved RGBA format
* @param start the first platte entry to be read
* @param num the number of palette entries to be read
*
* @note It is an error if this function gets called when the pixel format
* in use (the return value of getScreenFormat) has more than one
* byte per pixel.
*
* @see getScreenFormat
*/
virtual void grabPalette(byte *colors, uint start, uint num) = 0;
virtual PaletteManager *getPaletteManager() = 0;
/**
* Blit a bitmap to the virtual screen.
@ -1079,7 +1025,7 @@ public:
*
* For information about POSIX locales read here:
* http://en.wikipedia.org/wiki/Locale#POSIX-type_platforms
*
*
* The default implementation returns "en_US".
*
* @return locale of the system

View File

@ -806,7 +806,7 @@ void GfxMgr::initPalette(const uint8 *p, uint colorCount, uint fromBits, uint to
}
void GfxMgr::gfxSetPalette() {
g_system->setPalette(_palette, 0, 256);
g_system->getPaletteManager()->setPalette(_palette, 0, 256);
}
//Gets AGIPAL Data

View File

@ -90,7 +90,7 @@ void MoviePlayer::play() {
uint8 palette[1024];
memset(palette, 0, sizeof(palette));
_vm->clearSurfaces();
_vm->_system->setPalette(palette, 0, 256);
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
}
_vm->fillBackGroundFromBack();

View File

@ -781,7 +781,7 @@ void AGOSEngine::displayScreen() {
_paletteFlag = 0;
if (memcmp(_displayPalette, _currentPalette, 1024)) {
memcpy(_currentPalette, _displayPalette, 1024);
_system->setPalette(_displayPalette, 0, 256);
_system->getPaletteManager()->setPalette(_displayPalette, 0, 256);
}
}
@ -861,7 +861,7 @@ void AGOSEngine::fastFadeIn() {
} else {
_paletteFlag = false;
memcpy(_currentPalette, _displayPalette, 1024);
_system->setPalette(_displayPalette, 0, _fastFadeInFlag);
_system->getPaletteManager()->setPalette(_displayPalette, 0, _fastFadeInFlag);
_fastFadeInFlag = 0;
}
}
@ -889,7 +889,7 @@ void AGOSEngine::slowFadeIn() {
src += 4;
dst += 4;
}
_system->setPalette(_currentPalette, 0, _fastFadeCount);
_system->getPaletteManager()->setPalette(_currentPalette, 0, _fastFadeCount);
delay(5);
}
_fastFadeInFlag = 0;

View File

@ -580,7 +580,7 @@ void AGOSEngine_Simon1::os1_specialFade() {
paletteFadeOut(_currentPalette, 32, 8);
paletteFadeOut(_currentPalette + 4 * 48, 144, 8);
paletteFadeOut(_currentPalette + 4 * 208, 48, 8);
_system->setPalette(_currentPalette, 0, 256);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
delay(5);
}

View File

@ -373,7 +373,7 @@ void AGOSEngine::fullFade() {
srcPal += 3;
dstPal += 4;
}
_system->setPalette(_currentPalette, 0, 256);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
delay(5);
}
}
@ -395,7 +395,7 @@ void AGOSEngine::vc56_fullScreen() {
void AGOSEngine::vc57_blackPalette() {
memset(_currentPalette, 0, sizeof(_currentPalette));
_system->setPalette(_currentPalette, 0, 256);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
}
void AGOSEngine::vc58_checkCodeWheel() {

View File

@ -224,7 +224,7 @@ void AGOSEngine::vc62_fastFadeOut() {
for (i = fadeCount; i != 0; --i) {
paletteFadeOut(_currentPalette, _fastFadeCount, fadeSize);
_system->setPalette(_currentPalette, 0, _fastFadeCount);
_system->getPaletteManager()->setPalette(_currentPalette, 0, _fastFadeCount);
delay(5);
}

View File

@ -26,7 +26,7 @@
#include "cine/cine.h"
#include "cine/various.h"
#include "cine/pal.h"
#include "common/system.h" // For g_system->setPalette
#include "common/system.h" // For g_system->getPaletteManager()->setPalette
namespace Cine {
@ -196,9 +196,9 @@ void Palette::setGlobalOSystemPalette() const {
for (uint i = 0; i < 16 * 4; ++i)
buf[16 * 4 + i] = buf[i] >> 1;
g_system->setPalette(buf, 0, colorCount() * 2);
g_system->getPaletteManager()->setPalette(buf, 0, colorCount() * 2);
} else {
g_system->setPalette(buf, 0, colorCount());
g_system->getPaletteManager()->setPalette(buf, 0, colorCount());
}
}

View File

@ -159,7 +159,7 @@ public:
/** The original color format in which this palette was loaded. */
const Graphics::PixelFormat &colorFormat() const;
/** Sets current palette to global OSystem's palette using g_system->setPalette. */
/** Sets current palette to global OSystem's palette using g_system->getPaletteManager()->setPalette. */
void setGlobalOSystemPalette() const;
/** Get the color at the given palette index. */

View File

@ -282,7 +282,7 @@ void gfxModuleData_updatePalette() {
paletteRGBA[i * 4 + 2] = lpalette[i].B;
paletteRGBA[i * 4 + 3] = 0xFF;
}
g_system->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1);
g_system->getPaletteManager()->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1);
palDirtyMin = 256;
palDirtyMax = -1;
}

View File

@ -75,7 +75,7 @@ void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
_palette[i] <<= 2;
}
_vm->_system->setPalette(_palette, start, num);
_vm->_system->getPaletteManager()->setPalette(_palette, start, num);
}
void Screen::interpolatePalettes(const byte *first, const byte *second, uint16 start, uint16 num, int index, int number) {
@ -97,7 +97,7 @@ void Screen::interpolatePalettes(const byte *first, const byte *second, uint16 s
_palette[i] <<= 2;
}
_vm->_system->setPalette(_palette, start, num);
_vm->_system->getPaletteManager()->setPalette(_palette, start, num);
}
int Screen::interpolate(int first, int second, int index, int number) {

View File

@ -74,7 +74,7 @@ void DrasculaEngine::setPalette(byte *PalBuf) {
pal[i * 4 + 2] = PalBuf[i * 3 + 2] * 4;
pal[i * 4 + 3] = 0;
}
_system->setPalette(pal, 0, 256);
_system->getPaletteManager()->setPalette(pal, 0, 256);
_system->updateScreen();
}

View File

@ -325,7 +325,7 @@ void Util::clearPalette() {
if (_vm->_global->_setAllPalette) {
if (_vm->getPixelFormat().bytesPerPixel == 1) {
memset(colors, 0, 1024);
g_system->setPalette(colors, 0, 256);
g_system->getPaletteManager()->setPalette(colors, 0, 256);
}
return;

View File

@ -355,7 +355,7 @@ void Video::setPalElem(int16 index, char red, char green, char blue,
setPalColor(pal, red, green, blue);
if (_vm->getPixelFormat().bytesPerPixel == 1)
g_system->setPalette(pal, index, 1);
g_system->getPaletteManager()->setPalette(pal, index, 1);
}
void Video::setPalette(PalDesc *palDesc) {
@ -369,7 +369,7 @@ void Video::setPalette(PalDesc *palDesc) {
setPalColor(pal + i * 4, palDesc->vgaPal[i]);
if (_vm->getPixelFormat().bytesPerPixel == 1)
g_system->setPalette(pal, 0, numcolors);
g_system->getPaletteManager()->setPalette(pal, 0, numcolors);
}
void Video::setFullPalette(PalDesc *palDesc) {
@ -385,7 +385,7 @@ void Video::setFullPalette(PalDesc *palDesc) {
}
if (_vm->getPixelFormat().bytesPerPixel == 1)
g_system->setPalette(pal, 0, 256);
g_system->getPaletteManager()->setPalette(pal, 0, 256);
} else
Video::setPalette(palDesc);
}

View File

@ -138,7 +138,7 @@ bool Debugger::cmd_playref(int argc, const char **argv) {
bool Debugger::cmd_dumppal(int argc, const char **argv) {
uint16 i;
byte palettedump[256 * 4];
_vm->_system->grabPalette(palettedump, 0, 256);
_vm->_system->getPaletteManager()->grabPalette(palettedump, 0, 256);
for (i = 0; i < 256; i++) {
DebugPrintf("%3d: %3d,%3d,%3d,%3d\n", i, palettedump[(i * 4)], palettedump[(i * 4) + 1], palettedump[(i * 4) + 2], palettedump[(i * 4) + 3]);

View File

@ -124,7 +124,7 @@ void GraphicsMan::fadeOut() {
_fadeStartTime = _vm->_system->getMillis();
// Get the current palette
_vm->_system->grabPalette(_paletteFull, 0, 256);
_vm->_system->getPaletteManager()->grabPalette(_paletteFull, 0, 256);
// Set the current fading
_fading = 2;
@ -159,7 +159,7 @@ void GraphicsMan::applyFading(int step) {
}
// Set the screen palette
_vm->_system->setPalette(newpal, 0, 256);
_vm->_system->getPaletteManager()->setPalette(newpal, 0, 256);
// Request a screen update
change();

View File

@ -96,7 +96,7 @@ ROQPlayer::ROQPlayer(GroovieEngine *vm) :
}
#endif // DITHER
_syst->setPalette(pal, 0, 256);
_syst->getPaletteManager()->setPalette(pal, 0, 256);
}
}

View File

@ -563,7 +563,7 @@ void VDXPlayer::setPalette(uint8 *palette) {
palBuf[(i * 4) + 2] = palette[(i * 3) + 2];
palBuf[(i * 4) + 3] = 0;
}
_syst->setPalette(palBuf, 0, 256);
_syst->getPaletteManager()->setPalette(palBuf, 0, 256);
}
} // End of Groovie namespace

View File

@ -79,7 +79,7 @@ Screen::~Screen() {
void Screen::createPal() {
debugC(1, kDebugDisplay, "createPal");
g_system->setPalette(_mainPalette, 0, _paletteSize / 4);
g_system->getPaletteManager()->setPalette(_mainPalette, 0, _paletteSize / 4);
}
void Screen::setCursorPal() {
@ -146,7 +146,7 @@ void Screen::remapPal(const uint16 oldIndex, const uint16 newIndex) {
pal[2] = _curPalette[4 * oldIndex + 2] = _mainPalette[newIndex * 4 + 2];
pal[3] = _curPalette[4 * oldIndex + 3] = _mainPalette[newIndex * 4 + 3];
g_system->setPalette(pal, oldIndex, 1);
g_system->getPaletteManager()->setPalette(pal, oldIndex, 1);
}
/**
@ -175,7 +175,7 @@ void Screen::restorePal(Common::SeekableReadStream *f) {
pal[1] = _curPalette[i * 4 + 1];
pal[2] = _curPalette[i * 4 + 2];
pal[3] = _curPalette[i * 4 + 3];
g_system->setPalette(pal, i, 1);
g_system->getPaletteManager()->setPalette(pal, i, 1);
}
}

View File

@ -145,7 +145,7 @@ bool Screen::init() {
palette[i * 4 + 2] = ((i >> 0) & 1) * 0xFF;
palette[i * 4 + 3] = 0;
_system->setPalette(palette, 16, 8);
_system->getPaletteManager()->setPalette(palette, 16, 8);
}
}
@ -181,7 +181,7 @@ bool Screen::enableScreenDebug(bool enable) {
void Screen::setResolution() {
byte palette[4*256];
_system->grabPalette(palette, 0, 256);
_system->getPaletteManager()->grabPalette(palette, 0, 256);
int width = 320, height = 200;
bool defaultTo1xScaler = false;
@ -203,7 +203,7 @@ void Screen::setResolution() {
initGraphics(width, height, defaultTo1xScaler);
_system->setPalette(palette, 0, 256);
_system->getPaletteManager()->setPalette(palette, 0, 256);
}
void Screen::updateScreen() {
@ -711,7 +711,7 @@ void Screen::setScreenPalette(const Palette &pal) {
}
_paletteChanged = true;
_system->setPalette(screenPal, 0, pal.getNumColors());
_system->getPaletteManager()->setPalette(screenPal, 0, pal.getNumColors());
}
void Screen::enableInterfacePalette(bool e) {
@ -747,7 +747,7 @@ void Screen::setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b)
}
_paletteChanged = true;
_system->setPalette(screenPal, 32, pal.getNumColors());
_system->getPaletteManager()->setPalette(screenPal, 32, pal.getNumColors());
}
void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) {

View File

@ -455,7 +455,7 @@ void Screen_LoK_16::set16ColorPalette(const uint8 *pal) {
palette[i * 4 + 3] = 0;
}
_system->setPalette(palette, 0, 16);
_system->getPaletteManager()->setPalette(palette, 0, 16);
}
} // End of namespace Kyra

View File

@ -801,7 +801,7 @@ void Screen_LoL::copyColor(int dstColorIndex, int srcColorIndex) {
ci[2] = (d[2] << 2) | (d[2] & 3);
ci[3] = 0;
_system->setPalette(ci, dstColorIndex, 1);
_system->getPaletteManager()->setPalette(ci, dstColorIndex, 1);
}
bool Screen_LoL::fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedTicks, uint32 totalTicks) {

View File

@ -44,7 +44,7 @@ Screen::Screen(OSystem &system): _system(system),
_palette(new Palette(GAME_PALETTE_RESOURCE_ID, RGB64)) {
int_disk = this;
_screen->empty();
_system.setPalette(_palette->data(), 0, GAME_COLOURS);
_system.getPaletteManager()->setPalette(_palette->data(), 0, GAME_COLOURS);
}
Screen::~Screen() {
@ -57,13 +57,13 @@ Screen::~Screen() {
void Screen::setPaletteEmpty(int numEntries) {
Palette emptyPalette(numEntries, NULL, RGB64);
_system.setPalette(emptyPalette.data(), 0, numEntries);
_system.getPaletteManager()->setPalette(emptyPalette.data(), 0, numEntries);
_palette->copyFrom(&emptyPalette);
/*
delete _palette;
_palette = new Palette();
_system.setPalette(_palette->data(), 0, numEntries);
_system.getPaletteManager()->setPalette(_palette->data(), 0, numEntries);
*/
_system.updateScreen();
}
@ -73,7 +73,7 @@ void Screen::setPaletteEmpty(int numEntries) {
void Screen::setPalette(Palette *p) {
_palette->copyFrom(p);
_system.setPalette(_palette->data(), 0, GAME_COLOURS);
_system.getPaletteManager()->setPalette(_palette->data(), 0, GAME_COLOURS);
_system.updateScreen();
}
@ -82,7 +82,7 @@ void Screen::setPalette(Palette *p) {
void Screen::setPalette(Palette *p, uint16 start, uint16 num) {
_palette->palette()->copyFrom(p->palette(), start * 4, start * 4, num * 4);
_system.setPalette(_palette->data(), start, num);
_system.getPaletteManager()->setPalette(_palette->data(), start, num);
_system.updateScreen();
}
@ -114,7 +114,7 @@ void Screen::paletteFadeIn(Palette *p) {
}
if (changed) {
_system.setPalette(_palette->data(), 0, p->numEntries());
_system.getPaletteManager()->setPalette(_palette->data(), 0, p->numEntries());
_system.updateScreen();
_system.delayMillis(20);
while (events.pollEvent())
@ -147,7 +147,7 @@ void Screen::paletteFadeOut(int numEntries) {
}
if (changed) {
_system.setPalette(_palette->data(), 0, numEntries);
_system.getPaletteManager()->setPalette(_palette->data(), 0, numEntries);
_system.updateScreen();
_system.delayMillis(20);
while (events.pollEvent())

View File

@ -1031,17 +1031,17 @@ Palette::Palette(MadsM4Engine *vm) : _vm(vm) {
}
void Palette::setPalette(const byte *colors, uint start, uint num) {
g_system->setPalette(colors, start, num);
g_system->getPaletteManager()->setPalette(colors, start, num);
reset();
}
void Palette::setPalette(const RGB8 *colors, uint start, uint num) {
g_system->setPalette((const byte *)colors, start, num);
g_system->getPaletteManager()->setPalette((const byte *)colors, start, num);
reset();
}
void Palette::grabPalette(byte *colors, uint start, uint num) {
g_system->grabPalette(colors, start, num);
g_system->getPaletteManager()->grabPalette(colors, start, num);
}
void Palette::setEntry(uint index, uint8 r, uint8 g, uint8 b) {
@ -1050,7 +1050,7 @@ void Palette::setEntry(uint index, uint8 r, uint8 g, uint8 b) {
c.g = g;
c.b = b;
c.u = 255;
g_system->setPalette((const byte *)&c, index, 1);
g_system->getPaletteManager()->setPalette((const byte *)&c, index, 1);
}
uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
@ -1060,7 +1060,7 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
int Rdiff, Gdiff, Bdiff;
if (paletteData == NULL) {
g_system->grabPalette((byte *)palData, 0, 256);
g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
paletteData = &palData[0];
}
@ -1080,7 +1080,7 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
void Palette::reset() {
RGB8 palData[256];
g_system->grabPalette((byte *)palData, 0, 256);
g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
BLACK = palIndexFromRgb(0, 0, 0, palData);
BLUE = palIndexFromRgb(0, 0, 255, palData);
@ -1260,7 +1260,7 @@ void Palette::addRange(RGBList *list) {
RGB8 *data = list->data();
byte *palIndexes = list->palIndexes();
RGB8 palData[256];
g_system->grabPalette((byte *)&palData[0], 0, 256);
g_system->getPaletteManager()->grabPalette((byte *)&palData[0], 0, 256);
bool paletteChanged = false;
for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
@ -1300,7 +1300,7 @@ void Palette::addRange(RGBList *list) {
}
if (paletteChanged) {
g_system->setPalette((byte *)&palData[0], 0, 256);
g_system->getPaletteManager()->setPalette((byte *)&palData[0], 0, 256);
reset();
}
}

View File

@ -322,7 +322,7 @@ void WoodScript::update() {
{
// FIXME: This should be done when a new palette is set
byte palette[1024];
g_system->grabPalette(palette, 0, 256);
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
for (int i = 0; i < 256; i++) {
_mainPalette[i].r = palette[i * 4 + 0];
_mainPalette[i].g = palette[i * 4 + 1];

View File

@ -227,7 +227,7 @@ void Screen::setRGBPalette(byte *palRGB, int start, int count) {
_screenPalette[i * 4 + 3] = 0;
}
_vm->_system->setPalette(_screenPalette, start, count);
_vm->_system->getPaletteManager()->setPalette(_screenPalette, start, count);
}
uint16 Screen::updateChannel(uint16 channelIndex) {

View File

@ -147,7 +147,7 @@ void GraphicsManager::setPalette(uint16 id) {
delete tpalStream;
getVM()->_system->setPalette(palette, colorStart, colorCount);
getVM()->_system->getPaletteManager()->setPalette(palette, colorStart, colorCount);
delete[] palette;
}
@ -1016,7 +1016,7 @@ void LBGraphics::setPalette(uint16 id) {
delete ctblStream;
_vm->_system->setPalette(palette, 0, colorCount);
_vm->_system->getPaletteManager()->setPalette(palette, 0, colorCount);
delete[] palette;
} else {
GraphicsManager::setPalette(id);

View File

@ -3018,7 +3018,7 @@ void LBPaletteItem::update() {
// TODO: actual fading-in
if (_visible && _globalVisible) {
_vm->_system->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
_vm->_system->getPaletteManager()->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
_vm->_needsRedraw = true;
}
}
@ -3130,9 +3130,9 @@ void LBLiveTextItem::paletteUpdate(uint16 word, bool on) {
}
if (on) {
_vm->_system->setPalette(_highlightColor, _paletteIndex + word, 1);
_vm->_system->getPaletteManager()->setPalette(_highlightColor, _paletteIndex + word, 1);
} else {
_vm->_system->setPalette(_foregroundColor, _paletteIndex + word, 1);
_vm->_system->getPaletteManager()->setPalette(_foregroundColor, _paletteIndex + word, 1);
}
}

View File

@ -431,7 +431,7 @@ void View::setColors(Common::SeekableReadStream *tpalStream) {
}
// TODO: copy into temporary buffer
_vm->_system->setPalette(palette, colorStart, colorCount);
_vm->_system->getPaletteManager()->setPalette(palette, colorStart, colorCount);
delete[] palette;
// original does pdLightenUp here..

View File

@ -225,7 +225,7 @@ void Gfx::setPalette(Palette pal) {
byte sysPal[256*4];
uint n = pal.fillRGBA(sysPal);
_vm->_system->setPalette(sysPal, 0, n);
_vm->_system->getPaletteManager()->setPalette(sysPal, 0, n);
}
void Gfx::setBlackPalette() {

View File

@ -167,7 +167,7 @@ void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) {
tempPal[4 * i + 2] = *pal++;
tempPal[4 * i + 3] = 0;
}
_system->setPalette(tempPal, start, numColors);
_system->getPaletteManager()->setPalette(tempPal, start, numColors);
if (updateScreen) {
_vm->input()->delay(20);
}

View File

@ -216,7 +216,7 @@ void Gfx::setPalette(const PalEntry *pal, bool full) {
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
memset(&_currentPal[255 * 4], 0, 4);
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
void Gfx::setPaletteColor(int n, int r, int g, int b) {
@ -243,7 +243,7 @@ void Gfx::setPaletteColor(int n, int r, int g, int b) {
}
if (update)
_system->setPalette(_currentPal, n, 1);
_system->getPaletteManager()->setPalette(_currentPal, n, 1);
}
void Gfx::getCurrentPal(PalEntry *src_pal) {
@ -325,7 +325,7 @@ void Gfx::palToBlack(PalEntry *srcPal, double percent) {
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
memset(&_currentPal[255 * 4], 0, 4);
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
void Gfx::blackToPal(PalEntry *srcPal, double percent) {
@ -392,7 +392,7 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) {
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
memset(&_currentPal[255 * 4], 0, 4);
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
#ifdef ENABLE_IHNM
@ -455,7 +455,7 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num
// Color 0 should always be black in IHNM
memset(&fadePal[0 * 4], 0, 4);
_system->setPalette(&fadePal[start * 4], start, numColors);
_system->getPaletteManager()->setPalette(&fadePal[start * 4], start, numColors);
}
#endif

View File

@ -511,7 +511,7 @@ void GfxScreen::getPalette(Palette *pal) {
// just copy palette to system
byte bpal[4 * 256];
// Get current palette, update it and put back
g_system->grabPalette(bpal, 0, 256);
g_system->getPaletteManager()->grabPalette(bpal, 0, 256);
for (int16 i = 1; i < 255; i++) {
pal->colors[i].r = bpal[i * 4];
pal->colors[i].g = bpal[i * 4 + 1];
@ -523,7 +523,7 @@ void GfxScreen::setPalette(Palette *pal) {
// just copy palette to system
byte bpal[4 * 256];
// Get current palette, update it and put back
g_system->grabPalette(bpal, 0, 256);
g_system->getPaletteManager()->grabPalette(bpal, 0, 256);
for (int16 i = 0; i < 256; i++) {
if (!pal->colors[i].used)
continue;
@ -532,7 +532,7 @@ void GfxScreen::setPalette(Palette *pal) {
bpal[i * 4 + 2] = CLIP(pal->colors[i].b * pal->intensity[i] / 100, 0, 255);
bpal[i * 4 + 3] = 100;
}
g_system->setPalette(bpal, 0, 256);
g_system->getPaletteManager()->setPalette(bpal, 0, 256);
}
void GfxScreen::setVerticalShakePos(uint16 shakePos) {

View File

@ -309,7 +309,7 @@ void GfxTransitions::fadeOut() {
// several pictures (e.g. qfg3 demo/intro), so the fading looked weird
int16 tillColorNr = getSciVersion() >= SCI_VERSION_1_1 ? 256 : 255;
g_system->grabPalette(oldPalette, 0, 256);
g_system->getPaletteManager()->grabPalette(oldPalette, 0, 256);
for (stepNr = 100; stepNr >= 0; stepNr -= 10) {
for (colorNr = 1; colorNr < tillColorNr; colorNr++){
@ -317,7 +317,7 @@ void GfxTransitions::fadeOut() {
workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100;
workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100;
}
g_system->setPalette(workPalette + 4, 1, 254);
g_system->getPaletteManager()->setPalette(workPalette + 4, 1, 254);
g_sci->getEngineState()->wait(2);
}
}

View File

@ -127,7 +127,7 @@ void CUP_Player::copyRectToScreen(const Common::Rect &r) {
void CUP_Player::updateScreen() {
if (_paletteChanged) {
_system->setPalette(_paletteData, 0, 256);
_system->getPaletteManager()->setPalette(_paletteData, 0, 256);
_paletteChanged = false;
}
_system->updateScreen();

View File

@ -394,7 +394,7 @@ void ScummEngine_v99he::updatePalette() {
*p++ = 0;
}
_system->setPalette(palette_colors, _palDirtyMin, num);
_system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, num);
_palDirtyMax = -1;
_palDirtyMin = 256;

View File

@ -223,11 +223,11 @@ void ScummEngine::resetPalette() {
_townsClearLayerFlag = 0;
#ifdef USE_RGB_COLOR
else if (_game.id == GID_LOOM)
towns_setTextPaletteFromPtr(tableTownsLoomPalette);
towns_setTextPaletteFromPtr(tableTownsLoomPalette);
else if (_game.version == 3)
towns_setTextPaletteFromPtr(tableTownsV3Palette);
#endif
_townsScreen->toggleLayers(_townsActiveLayerFlags);
#endif // DISABLE_TOWNS_DUAL_LAYER_MODE
}
@ -1133,7 +1133,7 @@ void ScummEngine::updatePalette() {
#endif
#endif
_system->setPalette(palette_colors, first, num);
_system->getPaletteManager()->setPalette(palette_colors, first, num);
}
} // End of namespace Scumm

View File

@ -1229,7 +1229,7 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
*p++ = 0;
}
_vm->_system->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1);
_vm->_system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1);
_palDirtyMax = -1;
_palDirtyMin = 256;

View File

@ -83,7 +83,7 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) {
}
//set the palette
_system->setPalette(tmpPal, 0, VGA_COLOURS);
_system->getPaletteManager()->setPalette(tmpPal, 0, VGA_COLOURS);
_currentPalette = 0;
_seqInfo.framesLeft = 0;
@ -110,7 +110,7 @@ void Screen::setFocusRectangle(const Common::Rect& rect) {
//set a new palette, pal is a pointer to dos vga rgb components 0..63
void Screen::setPalette(uint8 *pal) {
convertPalette(pal, _palette);
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
}
@ -123,7 +123,7 @@ void Screen::setPaletteEndian(uint8 *pal) {
#else
convertPalette(pal, _palette);
#endif
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
}
@ -135,7 +135,7 @@ void Screen::halvePalette() {
halfPalette[(cnt << 2) | 2] = _palette[(cnt << 2) | 2] >> 1;
halfPalette[(cnt << 2) | 3] = 0;
}
_system->setPalette(halfPalette, 0, GAME_COLOURS);
_system->getPaletteManager()->setPalette(halfPalette, 0, GAME_COLOURS);
}
void Screen::setPalette(uint16 fileNum) {
@ -249,7 +249,7 @@ void Screen::fnFadeDown(uint32 scroll) {
for (uint8 cnt = 0; cnt < 32; cnt++) {
delayTime += 20;
palette_fadedown_helper((uint32 *)_palette, GAME_COLOURS);
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
int32 waitTime = (int32)delayTime - _system->getMillis();
if (waitTime < 0)
@ -308,7 +308,7 @@ void Screen::paletteFadeUp(uint8 *pal) {
_palette[(colCnt << 2) | 1] = (tmpPal[(colCnt << 2) | 1] * cnt) >> 5;
_palette[(colCnt << 2) | 2] = (tmpPal[(colCnt << 2) | 2] * cnt) >> 5;
}
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
int32 waitTime = (int32)delayTime - _system->getMillis();
if (waitTime < 0)

View File

@ -176,7 +176,7 @@ void MoviePlayer::play() {
byte pal[4 * 256];
memset(pal, 0, sizeof(pal));
_system->setPalette(pal, 0, 256);
_system->getPaletteManager()->setPalette(pal, 0, 256);
}
void MoviePlayer::performPostProcessing(byte *screen) {

View File

@ -256,7 +256,7 @@ void Control::askForCd() {
}
palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0;
_resMan->resClose(SR_PALETTE);
_system->setPalette(palOut, 0, 256);
_system->getPaletteManager()->setPalette(palOut, 0, 256);
free(palOut);
char fName[10];
@ -326,7 +326,7 @@ uint8 Control::runPanel() {
}
palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0;
_resMan->resClose(SR_PALETTE);
_system->setPalette(palOut, 0, 256);
_system->getPaletteManager()->setPalette(palOut, 0, 256);
free(palOut);
uint8 mode = 0, newMode = BUTTON_MAIN_PANEL;
bool fullRefresh = false;

View File

@ -154,14 +154,14 @@ void Screen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp) {
_fadingStep = 1;
_fadingDirection = FADE_UP;
memset(_currentPalette, 0, 256 * 4);
_system->setPalette(_currentPalette, 0, 256);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
} else
_system->setPalette(_targetPalette + 4 * start, start, length);
_system->getPaletteManager()->setPalette(_targetPalette + 4 * start, start, length);
}
void Screen::fullRefresh() {
_fullRefresh = true;
_system->setPalette(_targetPalette, 0, 256);
_system->getPaletteManager()->setPalette(_targetPalette, 0, 256);
}
bool Screen::stillFading() {
@ -197,7 +197,7 @@ void Screen::updateScreen() {
}
if (_fadingStep) {
fadePalette();
_system->setPalette(_currentPalette, 0, 256);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
}
uint16 scrlX = (uint16)Logic::_scriptVars[SCROLL_OFFSET_X];

View File

@ -293,7 +293,7 @@ void Screen::setSystemPalette(const byte *colors, uint start, uint num) {
} else
palette = colors;
_vm->_system->setPalette(palette, start, num);
_vm->_system->getPaletteManager()->setPalette(palette, start, num);
}
} // End of namespace Sword2

View File

@ -1185,7 +1185,7 @@ void Scene::setPalette(unsigned mul) {
p[i * 4 + c] = (unsigned)palette[i * 3 + c] * mul;
}
_system->setPalette(p, 0, 256);
_system->getPaletteManager()->setPalette(p, 0, 256);
}
Object *Scene::getObject(int id, int scene_id) {

View File

@ -301,7 +301,7 @@ bool TeenAgentEngine::showCDLogo() {
palette[idx + 1] *= 4;
palette[idx + 2] *= 4;
}
_system->setPalette(palette, 0, 0x100);
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
_system->copyRectToScreen(bg, 320, 0, 0, 320, 200);
_system->updateScreen();
@ -338,7 +338,7 @@ bool TeenAgentEngine::showLogo() {
palette[idx + 1] *= 4;
palette[idx + 2] *= 4;
}
_system->setPalette(palette, 0, 0x100);
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
uint n = logo.fileCount();
for(uint f = 0; f < 4; ++f)
@ -386,7 +386,7 @@ bool TeenAgentEngine::showMetropolis() {
}
}
_system->setPalette(palette, 0, 0x100);
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
byte varia_6[21760], varia_9[18302];
varia.read(6, varia_6, sizeof(varia_6));

View File

@ -44,7 +44,7 @@ GFXTestSuite::GFXTestSuite() {
// Initialize color palettes
// The fourth field is for alpha channel which is unused
// Assuming 8bpp as of now
g_system->setPalette(_palette, 0, 3);
g_system->getPaletteManager()->setPalette(_palette, 0, 3);
// Init Mouse Palette (White-black-yellow)
GFXtests::initMousePalette();
@ -88,7 +88,7 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) {
_palette[absIndx + 1] = 173;
_palette[absIndx + 2] = 255;
_palette[absIndx + 3] = 47;
g_system->setPalette(_palette, 0, 256);
g_system->getPaletteManager()->setPalette(_palette, 0, 256);
}
// Helper functions used by GFX tests
@ -982,7 +982,7 @@ TestExitStatus GFXtests::paletteRotation() {
}
// Initialize this palette.
g_system->setPalette(palette, 0, 256);
g_system->getPaletteManager()->setPalette(palette, 0, 256);
// Draw 256 Rectangles, each 1 pixel wide and 10 pixels long
// one for 0-255 color range other for 0-127-255 range
@ -1020,7 +1020,7 @@ TestExitStatus GFXtests::paletteRotation() {
rotatePalette(palette, 256);
g_system->delayMillis(10);
g_system->setPalette(palette, 0, 256);
g_system->getPaletteManager()->setPalette(palette, 0, 256);
g_system->updateScreen();
}

View File

@ -165,7 +165,7 @@ void PalettesToVideoDAC() {
}
// update the system palette
g_system->setPalette((const byte *)pColours, pDACtail->destDACindex, pDACtail->numColours);
g_system->getPaletteManager()->setPalette((const byte *)pColours, pDACtail->destDACindex, pDACtail->numColours);
// update tail pointer
pDACtail++;

View File

@ -930,7 +930,7 @@ void ToonEngine::flushPalette(bool deferFlushToNextRender) {
vmpalette[i*4+2] = _finalPalette[i*3+2];
vmpalette[i*4+3] = 0;
}
_system->setPalette(vmpalette, 0, 256);
_system->getPaletteManager()->setPalette(vmpalette, 0, 256);
}
void ToonEngine::setPaletteEntries(uint8 *palette, int32 offset, int32 num) {
memcpy(_finalPalette + offset * 3, palette, num * 3);
@ -1758,7 +1758,7 @@ void ToonEngine::fadeIn(int32 numFrames) {
vmpalette[i*4+2] = f * _finalPalette[i*3+2] / (numFrames - 1);
vmpalette[i*4+3] = 0;
}
_system->setPalette(vmpalette, 0, 256);
_system->getPaletteManager()->setPalette(vmpalette, 0, 256);
_system->updateScreen();
_system->delayMillis(_tickLength);
}
@ -1767,7 +1767,7 @@ void ToonEngine::fadeIn(int32 numFrames) {
void ToonEngine::fadeOut(int32 numFrames) {
uint8 oldpalette[1024];
_system->grabPalette(oldpalette, 0, 256);
_system->getPaletteManager()->grabPalette(oldpalette, 0, 256);
for (int32 f = 0; f < numFrames; f++) {
uint8 vmpalette[1024];
@ -1777,7 +1777,7 @@ void ToonEngine::fadeOut(int32 numFrames) {
vmpalette[i*4+2] = (numFrames - f - 1) * oldpalette[i*4+2] / (numFrames - 1);
vmpalette[i*4+3] = 255;
}
_system->setPalette(vmpalette, 0, 256);
_system->getPaletteManager()->setPalette(vmpalette, 0, 256);
_system->updateScreen();
_system->delayMillis(_tickLength);
}

View File

@ -3259,7 +3259,7 @@ void ToucheEngine::setPalette(int firstColor, int colorCount, int rScale, int gS
pal[i * 4 + 3] = 0;
}
_system->setPalette(&pal[firstColor * 4], firstColor, colorCount);
_system->getPaletteManager()->setPalette(&pal[firstColor * 4], firstColor, colorCount);
}
void ToucheEngine::updateScreenArea(int x, int y, int w, int h) {
@ -3294,7 +3294,7 @@ void ToucheEngine::updateDirtyScreenAreas() {
}
void ToucheEngine::updatePalette() {
_system->setPalette(_paletteBuffer, 0, 256);
_system->getPaletteManager()->setPalette(_paletteBuffer, 0, 256);
}
bool ToucheEngine::canLoadGameStateCurrently() {

View File

@ -1798,7 +1798,7 @@ void TuckerEngine::execData3PreUpdate_locationNum29() {
scrollPal[i * 4 + 1] = g[i + d];
scrollPal[i * 4 + 2] = b[i + d];
}
_system->setPalette(scrollPal, 118, 5);
_system->getPaletteManager()->setPalette(scrollPal, 118, 5);
if (_flagsTable[143] == 1) {
_locationObjectsTable[2].xPos = 999;
_locationObjectsTable[3].xPos = 187;

View File

@ -550,7 +550,7 @@ void AnimationSequencePlayer::mainLoop() {
updateSounds();
}
_system->copyRectToScreen(_offscreenBuffer, kScreenWidth, 0, 0, kScreenWidth, kScreenHeight);
_system->setPalette(_animationPalette, 0, 256);
_system->getPaletteManager()->setPalette(_animationPalette, 0, 256);
_system->updateScreen();
syncTime();
} while (_seqNum != 1);
@ -691,7 +691,7 @@ void AnimationSequencePlayer::fadeInPalette() {
fadeColors = true;
}
}
_system->setPalette(paletteBuffer, 0, 256);
_system->getPaletteManager()->setPalette(paletteBuffer, 0, 256);
_system->updateScreen();
}
_system->delayMillis(1000 / 60);
@ -712,7 +712,7 @@ void AnimationSequencePlayer::fadeOutPalette() {
fadeColors = true;
}
}
_system->setPalette(paletteBuffer, 0, 256);
_system->getPaletteManager()->setPalette(paletteBuffer, 0, 256);
_system->updateScreen();
}
_system->delayMillis(1000 / 60);

View File

@ -943,46 +943,46 @@ void TuckerEngine::updateFlagsForCharPosition() {
void TuckerEngine::fadeOutPalette(int colorsCount) {
uint8 pal[256 * 4];
_system->grabPalette(pal, 0, colorsCount);
_system->getPaletteManager()->grabPalette(pal, 0, colorsCount);
for (int color = 0; color < colorsCount; ++color) {
for (int i = 0; i < 3; ++i) {
const int c = int(pal[color * 4 + i]) + kFadePaletteStep * 4;
pal[color * 4 + i] = MIN<int>(c, _currentPalette[color * 3 + i]);
}
}
_system->setPalette(pal, 0, colorsCount);
_system->getPaletteManager()->setPalette(pal, 0, colorsCount);
_system->updateScreen();
waitForTimer(1);
}
void TuckerEngine::fadeInPalette(int colorsCount) {
uint8 pal[256 * 4];
_system->grabPalette(pal, 0, colorsCount);
_system->getPaletteManager()->grabPalette(pal, 0, colorsCount);
for (int color = 0; color < colorsCount; ++color) {
for (int i = 0; i < 3; ++i) {
const int c = int(pal[color * 4 + i]) - kFadePaletteStep * 4;
pal[color * 4 + i] = MAX<int>(c, 0);
}
}
_system->setPalette(pal, 0, colorsCount);
_system->getPaletteManager()->setPalette(pal, 0, colorsCount);
_system->updateScreen();
waitForTimer(1);
}
void TuckerEngine::fadePaletteColor(int color, int step) {
uint8 rgb[4];
_system->grabPalette(rgb, color, 1);
_system->getPaletteManager()->grabPalette(rgb, color, 1);
for (int i = 0; i < 3; ++i) {
const int c = _currentPalette[color * 3 + i] + step * 4;
rgb[i] = MIN(c, 255);
}
_system->setPalette(rgb, color, 1);
_system->getPaletteManager()->setPalette(rgb, color, 1);
}
void TuckerEngine::setBlackPalette() {
uint8 pal[256 * 4];
memset(pal, 0, sizeof(pal));
_system->setPalette(pal, 0, 256);
_system->getPaletteManager()->setPalette(pal, 0, 256);
}
void TuckerEngine::updateCursor() {

107
graphics/palette.h Normal file
View File

@ -0,0 +1,107 @@
/* 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 GRAPHICS_PALETTE_H
#define GRAPHICS_PALETTE_H
#include "common/noncopyable.h"
/**
* The PaletteManager is part of the OSystem backend API and responsible
* for handling the (possibly emulated) "hardware" palette needed for
* many old games (e.g. in EGA and VGA mode).
*
* By itself it is a pure abstract class, i.e. an "interface"; you can
* use the OSystem::getPaletteManager() method to obtain an instance
* that you can use to perform actual palette modifications.
*/
class PaletteManager : Common::NonCopyable {
public:
virtual ~PaletteManager() {}
/**
* Replace the specified range of the palette with new colors.
* The palette entries from 'start' till (start+num-1) will be replaced - so
* a full palette update is accomplished via start=0, num=256.
*
* The palette data is specified in interleaved RGBA format. That is, the
* first byte of the memory block 'colors' points at is the red component
* of the first new color; the second byte the green component of the first
* new color; the third byte the blue component, the last byte to the alpha
* (transparency) value. Then the second color starts, and so on. So memory
* looks like this: R1-G1-B1-A1-R2-G2-B2-A2-R3-...
*
* @param colors the new palette data, in interleaved RGBA format
* @param start the first palette entry to be updated
* @param num the number of palette entries to be updated
*
* @note It is an error if start+num exceeds 256, behaviour is undefined
* in that case (the backend may ignore it silently or assert).
* @note It is an error if this function gets called when the pixel format
* in use (the return value of getScreenFormat) has more than one
* byte per pixel.
* @note The alpha value is not actually used, and future revisions of this
* API are probably going to remove it.
*
* @see getScreenFormat
*/
virtual void setPalette(const byte *colors, uint start, uint num) = 0;
/**
* Grabs a specified part of the currently active palette.
* The format is the same as for setPalette.
*
* This should return exactly the same RGB data as was setup via previous
* setPalette calls.
*
* For example, for every valid value of start and num of the following
* code:
*
* byte origPal[num*4];
* // Setup origPal's data however you like
* g_system->setPalette(origPal, start, num);
* byte obtainedPal[num*4];
* g_system->grabPalette(obtainedPal, start, num);
*
* the following should be true:
*
* For each i < num : memcmp(&origPal[i*4], &obtainedPal[i*4], 3) == 0
* (i is an uint here)
*
* @see setPalette
* @param colors the palette data, in interleaved RGBA format
* @param start the first platte entry to be read
* @param num the number of palette entries to be read
*
* @note It is an error if this function gets called when the pixel format
* in use (the return value of getScreenFormat) has more than one
* byte per pixel.
*
* @see getScreenFormat
*/
virtual void grabPalette(byte *colors, uint start, uint num) = 0;
};
#endif

View File

@ -110,7 +110,7 @@ static bool grabScreen565(Graphics::Surface *surf) {
if (screenFormat.bytesPerPixel == 1) {
palette = new byte[256 * 4];
assert(palette);
g_system->grabPalette(palette, 0, 256);
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
}
for (uint y = 0; y < screen->h; ++y) {

View File

@ -320,7 +320,7 @@ int MidiDriver_MT32::open() {
171, 0, 0, 0 // fill
};
g_system->setPalette(dummy_palette, 0, 3);
g_system->getPaletteManager()->setPalette(dummy_palette, 0, 3);
}
_initialising = true;

View File

@ -60,7 +60,7 @@ void VideoDecoder::setSystemPalette() {
sysPalette[i * 4 + 3] = 0;
}
g_system->setPalette(sysPalette, 0, 256);
g_system->getPaletteManager()->setPalette(sysPalette, 0, 256);
delete[] sysPalette;
}