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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
/* 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 KYRA_SCREEN_EOB_H
#define KYRA_SCREEN_EOB_H
#ifdef ENABLE_EOB
#include "kyra/graphics/screen.h"
namespace Kyra {
class EoBCoreEngine;
class Screen_EoB : public Screen {
public:
Screen_EoB(EoBCoreEngine *vm, OSystem *system);
virtual ~Screen_EoB();
bool init();
void setClearScreenDim(int dim);
void clearCurDim();
void clearCurDimOvl(int pageNum);
void setMouseCursor(int x, int y, const byte *shape);
void setMouseCursor(int x, int y, const byte *shape, const uint8 *ovl);
void loadFileDataToPage(Common::SeekableReadStream *s, int pageNum, uint32 size);
void printShadedText(const char *string, int x, int y, int col1, int col2, int shadowCol);
virtual void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip = false);
void loadEoBBitmap(const char *file, const uint8 *cgaMapping, int tempPage, int destPage, int convertToPage);
void loadShapeSetBitmap(const char *file, int tempPage, int destPage);
void convertPage(int srcPage, int dstPage, const uint8 *cgaMapping);
void setScreenPalette(const Palette &pal);
void getRealPalette(int num, uint8 *dst);
uint8 *encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool encode8bit = false, const uint8 *cgaMapping = 0);
void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd = -1, int flags = 0, ...);
const uint8 *scaleShape(const uint8 *shapeData, int blockDistance);
const uint8 *scaleShapeStep(const uint8 *shp);
const uint8 *generateShapeOverlay(const uint8 *shp, const uint8 *fadingTable);
void setShapeFrame(int x1, int y1, int x2, int y2);
void enableShapeBackgroundFading(bool enable);
void setShapeFadingLevel(int val);
void setGfxParameters(int x, int y, int col);
void drawExplosion(int scale, int radius, int numElements, int stepSize, int aspectRatio, const uint8 *colorTable, int colorTableSize);
void drawVortex(int numElements, int radius, int stepSize, int, int disorder, const uint8 *colorTable, int colorTableSize);
void fadeTextColor(Palette *pal, int color, int rate);
bool delayedFadePalStep(Palette *fadePal, Palette *destPal, int rate);
void setTextColorMap(const uint8 *cmap) {}
int getRectSize(int w, int h);
void setFadeTable(const uint8 *table);
void createFadeTable(const uint8 *palData, uint8 *dst, uint8 rootColor, uint8 weight);
void createFadeTable16bit(const uint16 *palData, uint16 *dst, uint16 rootColor, uint8 weight);
const uint16 *getCGADitheringTable(int index);
const uint8 *getEGADitheringTable();
bool loadFont(FontId fontId, const char *filename);
// FM-Towns specific
void decodeSHP(const uint8 *data, int dstPage);
void convertToHiColor(int page);
void shadeRect(int x1, int y1, int x2, int y2, int shadingLevel);
// PC-98 specific
void selectPC98Palette(int paletteIndex, Palette &dest, int brightness = 0, bool set = false);
void decodeBIN(const uint8 *src, uint8 *dst, uint16 inSize);
void decodePC98PlanarBitmap(uint8 *srcDstBuffer, uint8 *tmpBuffer, uint16 size = 64000);
struct PalCycleData {
const int8 *data;
uint8 delay;
};
void initPC98PaletteCycle(int paletteIndex, PalCycleData *data);
void updatePC98PaletteCycle(int brightness);
PalCycleData *_activePalCycle;
uint8 *_cyclePalette;
// Amiga specific
void loadSpecialAmigaCPS(const char *fileName, int destPage, bool isGraphics);
// This is a simple way of emulating the Amiga copper list palette magic for more than 32 colors.
// I use colors 32 to 63 for these extra colors (which the Amiga copper sends to the color
// registers on the fly at vertical beam position 120).
void setDualPalettes(Palette &top, Palette &bottom);
private:
void updateDirtyRects();
void ditherRect(const uint8 *src, uint8 *dst, int dstPitch, int srcW, int srcH, int colorKey = -1);
void drawShapeSetPixel(uint8 *dst, uint8 col);
void scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, uint32 transOffsetDst, uint32 transOffsetSrc);
void scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src);
bool posWithinRect(int posX, int posY, int x1, int y1, int x2, int y2);
void setPagePixel16bit(int pageNum, int x, int y, uint16 color);
void generateEGADitheringTable(const Palette &pal);
void generateCGADitheringTables(const uint8 *mappingData);
int _dsDiv, _dsRem, _dsScaleTrans;
uint8 *_cgaScaleTable;
int16 _gfxX, _gfxY;
uint16 _gfxCol;
const uint8 *_gfxMaxY;
int16 _dsX1, _dsX2, _dsY1, _dsY2;
bool _dsBackgroundFading;
int16 _dsBackgroundFadingXOffs;
uint8 _shapeOverlay[16];
uint8 *_dsTempPage;
uint8 *_shpBuffer;
uint8 *_convertHiColorBuffer;
uint16 *_cgaDitheringTables[2];
const uint8 *_cgaMappingDefault;
uint8 *_egaDitheringTable;
uint8 *_egaDitheringTempPage;
// hard coded 16 color palettes for PC98 version of EOB1
const uint8 *_palette16c[10];
Common::String _cpsFilePattern;
const uint16 _cursorColorKey16Bit;
static const uint8 _egaMatchTable[];
static const ScreenDim _screenDimTable[];
static const int _screenDimTableCount;
};
/**
* Implementation of the Font interface for old DOS fonts used
* in EOB and EOB II.
*
*/
class OldDOSFont : public Font {
public:
OldDOSFont(Common::RenderMode mode, uint8 shadowColor);
virtual ~OldDOSFont();
virtual bool load(Common::SeekableReadStream &file);
int getHeight() const { return _height; }
int getWidth() const { return _width; }
int getCharWidth(uint16 c) const;
void setColorMap(const uint8 *src);
void set16bitColorMap(const uint16 *src) { _colorMap16bit = src; }
virtual void setStyle(FontStyle style) { _style = style; }
void drawChar(uint16 c, byte *dst, int pitch, int bpp) const;
protected:
void unload();
FontStyle _style;
const uint8 *_colorMap8bit;
uint8 *_data;
uint16 *_bitmapOffsets;
int _width, _height;
int _numGlyphs;
uint8 _shadowColor;
private:
void drawCharIntern(uint16 c, byte *dst, int pitch, int bpp, int col1, int col2) const;
virtual uint16 convert(uint16 c) const;
Common::RenderMode _renderMode;
const uint16 *_colorMap16bit;
static uint16 *_cgaDitheringTable;
static int _numRef;
};
/**
* Implementation of the Font interface for native AmigaDOS system fonts (normally to be loaded via diskfont.library)
*/
class Resource;
class AmigaDOSFont : public Font {
public:
AmigaDOSFont(Resource *res, bool needsLocalizedFont = false);
~AmigaDOSFont() { unload(); }
bool load(Common::SeekableReadStream &file);
int getHeight() const { return _height; }
int getWidth() const { return _width; }
int getCharWidth(uint16 c) const;
void setColorMap(const uint8 *src) { _colorMap = src; }
void drawChar(uint16 c, byte *dst, int pitch, int) const;
static void errorDialog(int index);
private:
void unload();
struct TextFont {
TextFont() : data(0), bitmap(0), location(0), spacing(0), kerning(0), height(0), width(0), baseLine(0), firstChar(0), lastChar(0), modulo(0) {}
~TextFont() {
delete[] data;
}
uint16 height;
uint16 width;
uint16 baseLine;
uint8 firstChar;
uint8 lastChar;
uint16 modulo;
const uint8 *data;
const uint8 *bitmap;
const uint16 *location;
const int16 *spacing;
const int16 *kerning;
};
TextFont *loadContentFile(const Common::String fileName);
void selectMode(int mode);
struct FontContent {
FontContent() : height(0), style(0), flags(0) {}
~FontContent() {
data.reset();
}
Common::String contentFile;
Common::SharedPtr<TextFont> data;
uint16 height;
uint8 style;
uint8 flags;
};
int _width, _height;
uint8 _first, _last;
FontContent *_content;
uint16 _numElements;
uint16 _selectedElement;
const uint8 *_colorMap;
const uint16 _maxPathLen;
const bool _needsLocalizedFont;
static uint8 _errorDialogDisplayed;
Resource *_res;
};
/**
* SJIS Font variant used in EOB I PC-98. It converts 1-byte characters into 2-byte characters and has a specific shadowing to the left.
*/
class SJISFontEoB1PC98 : public SJISFont {
public:
SJISFontEoB1PC98(Common::SharedPtr<Graphics::FontSJIS> &font, uint8 shadowColor, const uint16 *convTable1, const uint16 *convTable2);
virtual ~SJISFontEoB1PC98() {}
virtual int getCharWidth(uint16 c) const;
virtual void drawChar(uint16 c, byte *dst, int pitch, int) const;
private:
uint16 convert(uint16 c) const;
const uint16 *_convTable1, *_convTable2;
bool _defaultConv;
uint8 _shadowColor;
};
/**
* OldDOSFont variant used in EOB I PC-98. It uses the same drawing routine, but has a different loader. It contains
* ASCII and Katakana characters and requires several conversion tables to display these. It gets drawn on the SJIS overlay.
*/
class Font12x12PC98 : public OldDOSFont{
public:
Font12x12PC98(uint8 shadowColor, const uint16 *convTable1, const uint16 *convTable2, const uint8 *lookupTable);
virtual ~Font12x12PC98();
bool usesOverlay() const { return true; }
int getHeight() const { return _height >> 1; }
int getWidth() const { return _width >> 1; }
int getCharWidth(uint16 c) const { return _width >> 1; };
virtual bool load(Common::SeekableReadStream &file);
private:
virtual uint16 convert(uint16 c) const;
const uint16 *_convTable1, *_convTable2;
uint16 *_bmpOffs;
};
/**
* SJIS Font variant used in the intro and outro of EOB II FM-Towns. It appears twice as large, since it is not rendered on the hires overlay pages.
*/
class SJISFontLarge : public SJISFont {
public:
SJISFontLarge(Common::SharedPtr<Graphics::FontSJIS> &font);
virtual ~SJISFontLarge() {}
virtual bool usesOverlay() const { return false; }
virtual void drawChar(uint16 c, byte *dst, int pitch, int) const;
};
/**
* 12 x 12 SJIS font for EOB II FM-Towns. The data for this font comes from a file, not from the font rom.
*/
class SJISFont12x12 : public Font {
public:
SJISFont12x12(const uint16 *searchTable);
virtual ~SJISFont12x12() { unload(); }
virtual bool load(Common::SeekableReadStream &file);
virtual bool usesOverlay() const { return true; }
virtual int getHeight() const { return _height; }
virtual int getWidth() const { return _width; }
virtual int getCharWidth(uint16 c) const { return _width; }
virtual void setColorMap(const uint8 *src) { _colorMap = src; }
virtual void drawChar(uint16 c, byte *dst, int pitch, int) const;
private:
void unload();
uint8 *_data;
Common::HashMap<uint16, uint8> _searchTable;
const uint8 *_colorMap;
const int _height, _width;
};
} // End of namespace Kyra
#endif // ENABLE_EOB
#endif
|