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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
/* 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 SHERLOCK_SCREEN_H
#define SHERLOCK_SCREEN_H
#include "common/list.h"
#include "common/rect.h"
#include "common/serializer.h"
#include "sherlock/surface.h"
#include "sherlock/resources.h"
namespace Sherlock {
#define PALETTE_SIZE 768
#define PALETTE_COUNT 256
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
enum {
INFO_BLACK = 1,
INFO_FOREGROUND = 11,
INFO_BACKGROUND = 1,
BORDER_COLOR = 237,
INV_FOREGROUND = 14,
INV_BACKGROUND = 1,
COMMAND_HIGHLIGHTED = 10,
COMMAND_FOREGROUND = 15,
COMMAND_BACKGROUND = 4,
COMMAND_NULL = 248,
BUTTON_TOP = 233,
BUTTON_MIDDLE = 244,
BUTTON_BOTTOM = 248,
TALK_FOREGROUND = 12,
TALK_NULL = 16,
PEN_COLOR = 250
};
class SherlockEngine;
class Screen : public Surface {
private:
SherlockEngine *_vm;
int _fontNumber;
Common::List<Common::Rect> _dirtyRects;
uint32 _transitionSeed;
ImageFile *_font;
int _fontHeight;
Surface _sceneSurface;
// Rose Tattoo fields
int _fadeBytesRead, _fadeBytesToRead;
int _oldFadePercent;
byte _lookupTable[PALETTE_COUNT];
byte _lookupTable1[PALETTE_COUNT];
private:
/**
* Merges together overlapping dirty areas of the screen
*/
void mergeDirtyRects();
/**
* Returns the union of two dirty area rectangles
*/
bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2);
/**
* Draws the given string into the back buffer using the images stored in _font
*/
void writeString(const Common::String &str, const Common::Point &pt, byte color);
protected:
/**
* Adds a rectangle to the list of modified areas of the screen during the
* current frame
*/
virtual void addDirtyRect(const Common::Rect &r);
public:
Surface _backBuffer1, _backBuffer2;
Surface *_backBuffer;
bool _fadeStyle;
byte _cMap[PALETTE_SIZE];
byte _sMap[PALETTE_SIZE];
byte _tMap[PALETTE_SIZE];
bool _flushScreen;
public:
Screen(SherlockEngine *vm);
virtual ~Screen();
/**
* Set the font to use for writing text on the screen
*/
void setFont(int fontNumber);
/**
* Handles updating any dirty areas of the screen Surface object to the physical screen
*/
void update();
/**
* Return the currently active palette
*/
void getPalette(byte palette[PALETTE_SIZE]);
/**
* Set the palette
*/
void setPalette(const byte palette[PALETTE_SIZE]);
/**
* Fades from the currently active palette to the passed palette
*/
int equalizePalette(const byte palette[PALETTE_SIZE]);
/**
* Fade out the palette to black
*/
void fadeToBlack(int speed = 2);
/**
* Fade in a given palette
*/
void fadeIn(const byte palette[PALETTE_SIZE], int speed = 2);
/**
* Do a random pixel transition in from _backBuffer surface to the screen
*/
void randomTransition();
/**
* Transition to the surface from _backBuffer using a vertical transition
*/
void verticalTransition();
/**
* Prints the text passed onto the back buffer at the given position and color.
* The string is then blitted to the screen
*/
void print(const Common::Point &pt, byte color, const char *formatStr, ...) GCC_PRINTF(4, 5);
/**
* Print a strings onto the back buffer without blitting it to the screen
*/
void gPrint(const Common::Point &pt, byte color, const char *formatStr, ...) GCC_PRINTF(4, 5);
/**
* Copies a section of the second back buffer into the main back buffer
*/
void restoreBackground(const Common::Rect &r);
/**
* Copies a given area to the screen
*/
void slamArea(int16 xp, int16 yp, int16 width, int16 height);
/**
* Copies a given area to the screen
*/
void slamRect(const Common::Rect &r);
/**
* Copy an image from the back buffer to the screen, taking care of both the
* new area covered by the shape as well as the old area, which must be restored
*/
void flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width, int16 *height);
/**
* Similar to flushImage, this method takes in an extra parameter for the scale proporation,
* which affects the calculated bounds accordingly
*/
void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width, int16 *height, int scaleVal);
/**
* Copies data from the back buffer to the screen, taking into account scrolling position
*/
void blockMove(const Common::Rect &r, const Common::Point &scrollPos);
/**
* Copies the entire screen from the back buffer, taking into account scrolling position
*/
void blockMove(const Common::Point &scorllPos);
/**
* Returns the width of a string in pixels
*/
int stringWidth(const Common::String &str);
/**
* Returns the width of a character in pixels
*/
int charWidth(char c);
/**
* Fills an area on the back buffer, and then copies it to the screen
*/
void vgaBar(const Common::Rect &r, int color);
/**
* Draws a button for use in the inventory, talk, and examine dialogs.
*/
void makeButton(const Common::Rect &bounds, int textX, const Common::String &str);
/**
* Prints an interface command with the first letter highlighted to indicate
* what keyboard shortcut is associated with it
*/
void buttonPrint(const Common::Point &pt, byte color, bool slamIt, const Common::String &str);
/**
* Draw a panel in the back buffer with a raised area effect around the edges
*/
void makePanel(const Common::Rect &r);
/**
* Draw a field in the back buffer with a raised area effect around the edges,
* suitable for text input.
*/
void makeField(const Common::Rect &r);
/**
* Sets the active back buffer pointer to a restricted sub-area of the first back buffer
*/
void setDisplayBounds(const Common::Rect &r);
/**
* Resets the active buffer pointer to point back to the full first back buffer
*/
void resetDisplayBounds();
/**
* Return the size of the current display window
*/
Common::Rect getDisplayBounds();
int fontNumber() const { return _fontNumber; }
/**
* Synchronize the data for a savegame
*/
void synchronize(Common::Serializer &s);
// Rose Tattoo specific methods
void initPaletteFade(int bytesToRead);
int fadeRead(Common::SeekableReadStream &stream, byte *buf, int totalSize);
void setupBGArea(const byte cMap[PALETTE_SIZE]);
/**
* Translate a palette from 6-bit RGB values to full 8-bit values suitable for passing
* to the underlying palette manager
*/
static void translatePalette(byte palette[PALETTE_SIZE]);
};
} // End of namespace Sherlock
#endif
|