1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/* 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.
*
*/
#ifndef SCI_GRAPHICS_REMAP_H
#define SCI_GRAPHICS_REMAP_H
#include "common/array.h"
#include "sci/graphics/helpers.h"
namespace Sci {
class GfxScreen;
enum ColorRemappingType {
kRemappingNone = 0,
kRemappingByRange = 1,
kRemappingByPercent = 2,
kRemappingToGray = 3,
kRemappingToPercentGray = 4
};
#define REMAP_COLOR_COUNT 9
#define NON_REMAPPED_COLOR_COUNT 236
/**
* Remap class, handles color remapping
*/
class GfxRemap {
public:
GfxRemap(GfxPalette *_palette);
~GfxRemap();
void resetRemapping();
void setRemappingPercent(byte color, byte percent);
void setRemappingRange(byte color, byte from, byte to, byte base);
bool isRemapped(byte color) const {
return _remapOn && (_remappingType[color] != kRemappingNone);
}
byte remapColor(byte remappedColor, byte screenColor);
void updateRemapping();
private:
GfxScreen *_screen;
GfxPalette *_palette;
bool _remapOn;
ColorRemappingType _remappingType[256];
byte _remappingByPercent[256];
byte _remappingByRange[256];
uint16 _remappingPercentToSet;
};
#ifdef ENABLE_SCI32
struct RemapParams {
byte from;
byte to;
byte base;
byte gray;
byte oldGray;
byte percent;
byte oldPercent;
ColorRemappingType type;
Color curColor[256];
Color targetColor[256];
byte distance[256];
byte remap[256];
bool colorChanged[256];
RemapParams() {
from = to = base = gray = oldGray = percent = oldPercent = 0;
type = kRemappingNone;
// curColor and targetColor are initialized in GfxRemap32::initColorArrays
memset(curColor, 0, 256 * sizeof(Color));
memset(targetColor, 0, 256 * sizeof(Color));
memset(distance, 0, 256);
for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++)
remap[i] = i;
Common::fill(colorChanged, colorChanged + ARRAYSIZE(colorChanged), true);
}
RemapParams(byte from_, byte to_, byte base_, byte gray_, byte percent_, ColorRemappingType type_) {
from = from_;
to = to_;
base = base_;
gray = oldGray = gray_;
percent = oldPercent = percent_;
type = type_;
// curColor and targetColor are initialized in GfxRemap32::initColorArrays
memset(curColor, 0, 256 * sizeof(Color));
memset(targetColor, 0, 256 * sizeof(Color));
memset(distance, 0, 256);
for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++)
remap[i] = i;
Common::fill(colorChanged, colorChanged + ARRAYSIZE(colorChanged), true);
}
};
class GfxRemap32 {
public:
GfxRemap32(GfxPalette32 *palette);
~GfxRemap32() {}
void remapOff(byte color);
void setRemappingRange(byte color, byte from, byte to, byte base);
void setRemappingPercent(byte color, byte percent);
void setRemappingToGray(byte color, byte gray);
void setRemappingToPercentGray(byte color, byte gray, byte percent);
void setNoMatchRange(byte from, byte count);
bool remapEnabled(byte color) const;
byte remapColor(byte color, byte target);
bool remapAllTables(bool palChanged);
int getRemapCount() const { return _remapCount; }
int getStartColor() const { return _remapEndColor - REMAP_COLOR_COUNT + 1; }
int getEndColor() const { return _remapEndColor; }
private:
GfxPalette32 *_palette;
RemapParams _remaps[REMAP_COLOR_COUNT];
bool _update;
byte _noMapStart, _noMapCount;
bool _targetChanged[NON_REMAPPED_COLOR_COUNT];
byte _remapEndColor;
int _remapCount;
void initColorArrays(byte index);
bool applyRemap(byte index);
bool updateRemap(byte index, bool palChanged);
};
#endif
} // End of namespace Sci
#endif
|