2009-10-06 16:14:40 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-01-05 01:37:57 +00:00
|
|
|
#ifndef SCI_GRAPHICS_PALETTE_H
|
|
|
|
#define SCI_GRAPHICS_PALETTE_H
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2011-02-07 18:32:42 +00:00
|
|
|
#include "common/array.h"
|
2010-01-05 01:37:57 +00:00
|
|
|
#include "sci/graphics/helpers.h"
|
2009-10-06 16:14:40 +00:00
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
2011-02-07 18:32:42 +00:00
|
|
|
class ResourceManager;
|
|
|
|
class GfxScreen;
|
|
|
|
|
2012-07-25 00:58:16 +03:00
|
|
|
enum ColorRemappingType {
|
|
|
|
kRemappingNone = 0,
|
|
|
|
kRemappingByRange = 1,
|
|
|
|
kRemappingByPercent = 2
|
|
|
|
};
|
|
|
|
|
2010-02-05 15:48:45 +00:00
|
|
|
/**
|
|
|
|
* Palette class, handles palette operations like changing intensity, setting up the palette, merging different palettes
|
|
|
|
*/
|
2010-07-23 07:36:55 +00:00
|
|
|
class GfxPalette : public Common::Serializable {
|
2009-10-06 16:14:40 +00:00
|
|
|
public:
|
2011-10-19 23:44:34 +03:00
|
|
|
GfxPalette(ResourceManager *resMan, GfxScreen *screen);
|
2010-01-31 16:21:11 +00:00
|
|
|
~GfxPalette();
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2010-06-25 10:04:31 +00:00
|
|
|
bool isMerging();
|
|
|
|
|
2010-06-08 22:00:59 +00:00
|
|
|
void setDefault();
|
2010-06-23 11:47:14 +00:00
|
|
|
void createFromData(byte *data, int bytesLeft, Palette *paletteOut);
|
2009-10-06 16:14:40 +00:00
|
|
|
bool setAmiga();
|
2010-01-25 11:15:40 +00:00
|
|
|
void modifyAmigaPalette(byte *data);
|
2009-10-06 16:14:40 +00:00
|
|
|
void setEGA();
|
2010-01-26 22:45:52 +00:00
|
|
|
void set(Palette *sciPal, bool force, bool forceRealMerge = false);
|
2010-06-22 17:13:44 +00:00
|
|
|
bool insert(Palette *newPalette, Palette *destPalette);
|
2010-06-20 13:15:45 +00:00
|
|
|
bool merge(Palette *pFrom, bool force, bool forceRealMerge);
|
|
|
|
uint16 matchColor(byte r, byte g, byte b);
|
2010-01-05 01:37:57 +00:00
|
|
|
void getSys(Palette *pal);
|
2011-03-04 21:56:14 +02:00
|
|
|
uint16 getTotalColorCount() const { return _totalScreenColors; }
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2012-07-24 22:34:03 +03:00
|
|
|
void resetRemapping();
|
|
|
|
void setRemappingPercent(byte color, byte percent);
|
2012-08-21 03:31:00 +03:00
|
|
|
void setRemappingPercentGray(byte color, byte percent);
|
2012-07-24 22:34:03 +03:00
|
|
|
void setRemappingRange(byte color, byte from, byte to, byte base);
|
2012-07-25 00:58:16 +03:00
|
|
|
bool isRemapped(byte color) const {
|
|
|
|
return _remapOn && (_remappingType[color] != kRemappingNone);
|
|
|
|
}
|
|
|
|
byte remapColor(byte remappedColor, byte screenColor);
|
2012-07-24 03:53:44 +03:00
|
|
|
|
2009-10-06 16:14:40 +00:00
|
|
|
void setOnScreen();
|
2011-02-17 13:13:30 -05:00
|
|
|
void copySysPaletteToScreen();
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2010-06-20 20:52:31 +00:00
|
|
|
void drewPicture(GuiResourceId pictureId);
|
2010-06-20 13:25:08 +00:00
|
|
|
|
2010-01-31 16:21:11 +00:00
|
|
|
bool kernelSetFromResource(GuiResourceId resourceId, bool force);
|
|
|
|
void kernelSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
|
|
|
void kernelUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
|
|
|
void kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
|
2010-01-31 16:29:02 +00:00
|
|
|
int16 kernelFindColor(uint16 r, uint16 g, uint16 b);
|
2010-01-31 16:21:11 +00:00
|
|
|
bool kernelAnimate(byte fromColor, byte toColor, int speed);
|
|
|
|
void kernelAnimateSet();
|
2010-07-27 17:51:44 +00:00
|
|
|
reg_t kernelSave();
|
|
|
|
void kernelRestore(reg_t memoryHandle);
|
2010-02-07 12:00:06 +00:00
|
|
|
void kernelAssertPalette(GuiResourceId resourceId);
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2010-07-11 10:11:31 +00:00
|
|
|
void kernelSyncScreenPalette();
|
|
|
|
|
2010-06-20 18:20:05 +00:00
|
|
|
bool kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, uint16 direction);
|
|
|
|
int16 kernelPalVaryReverse(int16 ticks, uint16 stepStop, int16 direction);
|
2010-06-20 17:08:39 +00:00
|
|
|
int16 kernelPalVaryGetCurrentStep();
|
2010-06-22 17:05:00 +00:00
|
|
|
int16 kernelPalVaryChangeTarget(GuiResourceId resourceId);
|
2010-06-20 21:12:15 +00:00
|
|
|
void kernelPalVaryChangeTicks(uint16 ticks);
|
2010-06-20 17:08:39 +00:00
|
|
|
void kernelPalVaryPause(bool pause);
|
2010-06-20 15:01:31 +00:00
|
|
|
void kernelPalVaryDeinit();
|
|
|
|
void palVaryUpdate();
|
2010-06-20 20:52:31 +00:00
|
|
|
void palVaryPrepareForTransition();
|
2010-06-20 16:31:24 +00:00
|
|
|
void palVaryProcess(int signal, bool setPalette);
|
2010-02-04 23:17:33 +00:00
|
|
|
|
2010-01-05 01:37:57 +00:00
|
|
|
Palette _sysPalette;
|
2009-10-06 16:14:40 +00:00
|
|
|
|
2010-07-23 07:36:55 +00:00
|
|
|
virtual void saveLoadWithSerializer(Common::Serializer &s);
|
2010-07-27 17:51:44 +00:00
|
|
|
void palVarySaveLoadPalette(Common::Serializer &s, Palette *palette);
|
2010-07-23 07:36:55 +00:00
|
|
|
|
2011-02-17 13:13:30 -05:00
|
|
|
byte findMacIconBarColor(byte r, byte g, byte b);
|
|
|
|
bool colorIsFromMacClut(byte index);
|
|
|
|
|
2011-02-13 17:22:07 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
bool loadClut(uint16 clutId);
|
|
|
|
byte matchClutColor(uint16 color);
|
|
|
|
void unloadClut();
|
|
|
|
#endif
|
|
|
|
|
2009-10-06 16:14:40 +00:00
|
|
|
private:
|
2010-06-20 15:01:31 +00:00
|
|
|
void palVaryInit();
|
2010-06-20 18:20:05 +00:00
|
|
|
void palVaryInstallTimer();
|
2012-11-15 14:57:55 +02:00
|
|
|
void palVaryRemoveTimer();
|
2010-06-20 20:52:31 +00:00
|
|
|
bool palVaryLoadTargetPalette(GuiResourceId resourceId);
|
2010-02-04 23:17:33 +00:00
|
|
|
static void palVaryCallback(void *refCon);
|
2010-06-20 15:01:31 +00:00
|
|
|
void palVaryIncreaseSignal();
|
2010-02-04 23:17:33 +00:00
|
|
|
|
2010-01-31 16:21:11 +00:00
|
|
|
GfxScreen *_screen;
|
2009-10-08 08:00:30 +00:00
|
|
|
ResourceManager *_resMan;
|
2010-06-20 15:01:31 +00:00
|
|
|
|
2010-04-02 18:48:17 +00:00
|
|
|
bool _sysPaletteChanged;
|
2010-06-25 10:04:31 +00:00
|
|
|
bool _useMerging;
|
2010-04-02 18:48:17 +00:00
|
|
|
|
2010-01-05 01:37:57 +00:00
|
|
|
Common::Array<PalSchedule> _schedules;
|
2010-06-20 16:31:24 +00:00
|
|
|
|
|
|
|
GuiResourceId _palVaryResourceId;
|
|
|
|
Palette _palVaryOriginPalette;
|
|
|
|
Palette _palVaryTargetPalette;
|
2010-06-20 18:20:05 +00:00
|
|
|
int16 _palVaryStep;
|
|
|
|
int16 _palVaryStepStop;
|
2010-06-20 16:31:24 +00:00
|
|
|
int16 _palVaryDirection;
|
2010-06-20 18:20:05 +00:00
|
|
|
uint16 _palVaryTicks;
|
2010-06-20 16:31:24 +00:00
|
|
|
int _palVaryPaused;
|
|
|
|
int _palVarySignal;
|
2011-03-04 21:56:14 +02:00
|
|
|
uint16 _totalScreenColors;
|
2011-02-17 13:13:30 -05:00
|
|
|
|
2012-07-24 03:53:44 +03:00
|
|
|
bool _remapOn;
|
2012-07-25 00:58:16 +03:00
|
|
|
ColorRemappingType _remappingType[256];
|
|
|
|
byte _remappingByPercent[256];
|
|
|
|
byte _remappingByRange[256];
|
2012-07-24 22:34:03 +03:00
|
|
|
uint16 _remappingPercentToSet;
|
2012-07-24 03:53:44 +03:00
|
|
|
|
2011-02-17 13:13:30 -05:00
|
|
|
void loadMacIconBarPalette();
|
|
|
|
byte *_macClut;
|
2011-06-20 00:59:48 +02:00
|
|
|
|
2011-02-13 17:22:07 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
byte *_clutTable;
|
|
|
|
#endif
|
2009-10-06 16:14:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Sci
|
|
|
|
|
|
|
|
#endif
|