2008-06-07 19:40:43 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/palette.h"
|
|
|
|
|
2008-06-07 19:40:43 +00:00
|
|
|
#include "drascula/drascula.h"
|
|
|
|
|
|
|
|
namespace Drascula {
|
|
|
|
|
2010-03-09 23:35:30 +00:00
|
|
|
static const char colorTable[][3] = {
|
2008-09-09 11:20:34 +00:00
|
|
|
{ 0, 0, 0 }, { 0x10, 0x3E, 0x28 },
|
|
|
|
{ 0, 0, 0 }, // unused
|
|
|
|
{ 0x16, 0x3F, 0x16 }, { 0x09, 0x3F, 0x12 },
|
|
|
|
{ 0x3F, 0x3F, 0x15 },
|
|
|
|
{ 0, 0, 0 }, // unused
|
|
|
|
{ 0x38, 0, 0 }, { 0x3F, 0x27, 0x0B },
|
|
|
|
{ 0x2A, 0, 0x2A }, { 0x30, 0x30, 0x30 },
|
|
|
|
{ 98, 91, 100 }
|
|
|
|
};
|
|
|
|
|
2008-06-07 19:40:43 +00:00
|
|
|
void DrasculaEngine::setRGB(byte *pal, int colorCount) {
|
|
|
|
int x, cnt = 0;
|
|
|
|
|
|
|
|
for (x = 0; x < colorCount; x++) {
|
|
|
|
gamePalette[x][0] = pal[cnt++] / 4;
|
|
|
|
gamePalette[x][1] = pal[cnt++] / 4;
|
|
|
|
gamePalette[x][2] = pal[cnt++] / 4;
|
|
|
|
}
|
|
|
|
setPalette((byte *)&gamePalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::black() {
|
|
|
|
int color, component;
|
|
|
|
DacPalette256 blackPalette;
|
|
|
|
|
|
|
|
for (color = 0; color < 256; color++)
|
|
|
|
for (component = 0; component < 3; component++)
|
|
|
|
blackPalette[color][component] = 0;
|
|
|
|
|
|
|
|
blackPalette[254][0] = 0x3F;
|
|
|
|
blackPalette[254][1] = 0x3F;
|
|
|
|
blackPalette[254][2] = 0x15;
|
|
|
|
|
|
|
|
setPalette((byte *)&blackPalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::setPalette(byte *PalBuf) {
|
2011-02-19 20:19:45 +00:00
|
|
|
byte pal[256 * 3];
|
2008-06-07 19:40:43 +00:00
|
|
|
|
2011-02-19 20:19:45 +00:00
|
|
|
for (int i = 0; i < 3 * 256; ++i) {
|
|
|
|
pal[i] = PalBuf[i] * 4;
|
2008-06-07 19:40:43 +00:00
|
|
|
}
|
2011-02-19 20:19:45 +00:00
|
|
|
|
2011-02-07 17:52:38 +00:00
|
|
|
_system->getPaletteManager()->setPalette(pal, 0, 256);
|
2008-06-07 19:40:43 +00:00
|
|
|
_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::color_abc(int cl) {
|
|
|
|
_color = cl;
|
|
|
|
|
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
gamePalette[254][i] = colorTable[cl][i];
|
|
|
|
|
|
|
|
setPalette((byte *)&gamePalette);
|
|
|
|
}
|
|
|
|
|
2008-06-17 21:52:58 +00:00
|
|
|
signed char DrasculaEngine::adjustToVGA(signed char value) {
|
2008-06-07 19:40:43 +00:00
|
|
|
return (value & 0x3F) * (value > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::fadeToBlack(int fadeSpeed) {
|
2008-06-17 21:52:58 +00:00
|
|
|
signed char fade;
|
2008-06-07 19:40:43 +00:00
|
|
|
unsigned int color, component;
|
|
|
|
|
|
|
|
DacPalette256 palFade;
|
|
|
|
|
|
|
|
for (fade = 63; fade >= 0; fade--) {
|
|
|
|
for (color = 0; color < 256; color++) {
|
|
|
|
for (component = 0; component < 3; component++) {
|
|
|
|
palFade[color][component] = adjustToVGA(gamePalette[color][component] - 63 + fade);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pause(fadeSpeed);
|
|
|
|
|
|
|
|
setPalette((byte *)&palFade);
|
2010-06-15 10:24:38 +00:00
|
|
|
|
|
|
|
updateEvents();
|
2008-06-07 19:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::fadeFromBlack(int fadeSpeed) {
|
2008-06-17 21:52:58 +00:00
|
|
|
signed char fade;
|
2008-06-07 19:40:43 +00:00
|
|
|
unsigned int color, component;
|
|
|
|
|
|
|
|
DacPalette256 palFade;
|
|
|
|
|
|
|
|
for (fade = 0; fade < 64; fade++) {
|
|
|
|
for (color = 0; color < 256; color++) {
|
|
|
|
for (component = 0; component < 3; component++) {
|
|
|
|
palFade[color][component] = adjustToVGA(gamePalette[color][component] - 63 + fade);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pause(fadeSpeed);
|
|
|
|
|
|
|
|
setPalette((byte *)&palFade);
|
2010-06-15 10:24:38 +00:00
|
|
|
|
|
|
|
updateEvents();
|
2008-06-07 19:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-10 12:03:42 +00:00
|
|
|
void DrasculaEngine::assignPalette(DacPalette256 pal) {
|
2008-06-07 19:40:43 +00:00
|
|
|
int color, component;
|
|
|
|
|
|
|
|
for (color = 235; color < 253; color++)
|
|
|
|
for (component = 0; component < 3; component++)
|
2008-09-10 12:03:42 +00:00
|
|
|
pal[color][component] = gamePalette[color][component];
|
2008-06-07 19:40:43 +00:00
|
|
|
}
|
|
|
|
|
2008-09-10 12:03:42 +00:00
|
|
|
void DrasculaEngine::setDefaultPalette(DacPalette256 pal) {
|
2008-06-07 19:40:43 +00:00
|
|
|
int color, component;
|
|
|
|
|
|
|
|
for (color = 235; color < 253; color++) {
|
|
|
|
for (component = 0; component < 3; component++) {
|
2008-09-10 12:03:42 +00:00
|
|
|
gamePalette[color][component] = pal[color][component];
|
2008-06-07 19:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setPalette((byte *)&gamePalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrasculaEngine::setPaletteBase(int darkness) {
|
2008-06-17 21:52:58 +00:00
|
|
|
signed char fade;
|
2008-06-07 19:40:43 +00:00
|
|
|
unsigned int color, component;
|
|
|
|
|
|
|
|
for (fade = darkness; fade >= 0; fade--) {
|
|
|
|
for (color = 235; color < 253; color++) {
|
|
|
|
for (component = 0; component < 3; component++)
|
|
|
|
gamePalette[color][component] = adjustToVGA(gamePalette[color][component] - 8 + fade);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setPalette((byte *)&gamePalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Drascula
|