1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef KYRA_SCREEN_H
24 #define KYRA_SCREEN_H
25 
26 #include "common/util.h"
27 #include "common/func.h"
28 #include "common/list.h"
29 #include "common/array.h"
30 #include "common/rect.h"
31 #include "common/rendermode.h"
32 #include "common/stream.h"
33 #include "common/ptr.h"
34 
35 class OSystem;
36 
37 namespace Graphics {
38 class FontSJIS;
39 } // End of namespace Graphics
40 
41 namespace Kyra {
42 
43 typedef Common::Functor0<void> UpdateFunctor;
44 
45 class KyraEngine_v1;
46 class Screen;
47 
48 struct ScreenDim {
49 	uint16 sx;
50 	uint16 sy;
51 	uint16 w;
52 	uint16 h;
53 	uint16 unk8;
54 	uint16 unkA;
55 	uint16 unkC;
56 	uint16 unkE;
57 };
58 
59 /**
60  * A class that handles KYRA fonts.
61  */
62 class Font {
63 public:
~Font()64 	virtual ~Font() {}
65 
66 	/**
67 	 * Tries to load a file from the given stream
68 	 */
69 	virtual bool load(Common::SeekableReadStream &file) = 0;
70 
71 	/**
72 	 * Whether the font draws on the overlay.
73 	 */
usesOverlay()74 	virtual bool usesOverlay() const { return false; }
75 
76 	/**
77 	 * The font height.
78 	 */
79 	virtual int getHeight() const = 0;
80 
81 	/**
82 	 * The font width, this is the maximal character
83 	 * width.
84 	 */
85 	virtual int getWidth() const = 0;
86 
87 	/**
88 	 * Gets the width of a specific character.
89 	 */
90 	virtual int getCharWidth(uint16 c) const = 0;
91 
92 	/**
93 	 * Sets a text palette map. The map contains 16 entries.
94 	 */
95 	virtual void setColorMap(const uint8 *src) = 0;
96 
97 	/**
98 	* Sets a text 16bit palette map. Only used in in EOB II FM-Towns. The map contains 2 entries.
99 	*/
set16bitColorMap(const uint16 * src)100 	virtual void set16bitColorMap(const uint16 *src) {}
101 
102 	/**
103 	 * Draws a specific character.
104 	 *
105 	 * TODO/FIXME: Replace this with a nicer API. Currently
106 	 * the user has to assure that the character fits.
107 	 * We use this API, since it's hard to assure dirty rect
108 	 * handling from outside Screen.
109 	 */
110 	virtual void drawChar(uint16 c, byte *dst, int pitch, int bpp) const = 0;
111 };
112 
113 /**
114  * Implementation of the Font interface for DOS fonts.
115  *
116  * TODO: Clean up the implementation. For example we might be able
117  * to not to keep the whole font in memory.
118  */
119 class DOSFont : public Font {
120 public:
121 	DOSFont();
~DOSFont()122 	~DOSFont() { unload(); }
123 
124 	bool load(Common::SeekableReadStream &file);
getHeight()125 	int getHeight() const { return _height; }
getWidth()126 	int getWidth() const { return _width; }
127 	int getCharWidth(uint16 c) const;
setColorMap(const uint8 * src)128 	void setColorMap(const uint8 *src) { _colorMap = src; }
129 	void drawChar(uint16 c, byte *dst, int pitch, int) const;
130 
131 private:
132 	void unload();
133 
134 	const uint8 *_colorMap;
135 
136 	uint8 *_data;
137 
138 	int _width, _height;
139 
140 	int _numGlyphs;
141 
142 	uint8 *_widthTable;
143 	uint8 *_heightTable;
144 	uint16 *_bitmapOffsets;
145 };
146 
147 #ifdef ENABLE_EOB
148 /**
149 * Implementation of the Font interface for old DOS fonts used
150 * in EOB and EOB II.
151 *
152 */
153 class OldDOSFont : public Font {
154 public:
155 	OldDOSFont(Common::RenderMode mode);
156 	~OldDOSFont();
157 
158 	bool load(Common::SeekableReadStream &file);
getHeight()159 	int getHeight() const { return _height; }
getWidth()160 	int getWidth() const { return _width; }
161 	int getCharWidth(uint16 c) const;
setColorMap(const uint8 * src)162 	void setColorMap(const uint8 *src) { _colorMap8bit = src; }
set16bitColorMap(const uint16 * src)163 	void set16bitColorMap(const uint16 *src) { _colorMap16bit = src; }
164 	void drawChar(uint16 c, byte *dst, int pitch, int bpp) const;
165 
166 private:
167 	void unload();
168 
169 	uint8 *_data;
170 	uint16 *_bitmapOffsets;
171 
172 	int _width, _height;
173 	const uint8 *_colorMap8bit;
174 	const uint16 *_colorMap16bit;
175 
176 	int _numGlyphs;
177 
178 	Common::RenderMode _renderMode;
179 
180 	static uint16 *_cgaDitheringTable;
181 	static int _numRef;
182 };
183 
184 /**
185  * Implementation of the Font interface for native AmigaDOS system fonts (normally to be loaded via diskfont.library)
186  */
187 class Resource;
188 class AmigaDOSFont : public Font {
189 public:
190 	AmigaDOSFont(Resource *res, bool needsLocalizedFont = false);
~AmigaDOSFont()191 	~AmigaDOSFont() { unload(); }
192 
193 	bool load(Common::SeekableReadStream &file);
getHeight()194 	int getHeight() const { return _height; }
getWidth()195 	int getWidth() const { return _width; }
196 	int getCharWidth(uint16 c) const;
setColorMap(const uint8 * src)197 	void setColorMap(const uint8 *src) { _colorMap = src;  }
198 	void drawChar(uint16 c, byte *dst, int pitch, int) const;
199 
200 	static void errorDialog(int index);
201 
202 private:
203 	void unload();
204 
205 	struct TextFont {
TextFontTextFont206 		TextFont() : data(0), bitmap(0), location(0), spacing(0), kerning(0), height(0), width(0), baseLine(0), firstChar(0), lastChar(0), modulo(0) {}
~TextFontTextFont207 		~TextFont() {
208 			delete[] data;
209 		}
210 
211 		uint16 height;
212 		uint16 width;
213 		uint16 baseLine;
214 		uint8 firstChar;
215 		uint8 lastChar;
216 		uint16 modulo;
217 		const uint8 *data;
218 		const uint8 *bitmap;
219 		const uint16 *location;
220 		const int16 *spacing;
221 		const int16 *kerning;
222 	};
223 
224 	TextFont *loadContentFile(const Common::String fileName);
225 	void selectMode(int mode);
226 
227 	struct FontContent {
FontContentFontContent228 		FontContent() : height(0), style(0), flags(0) {}
~FontContentFontContent229 		~FontContent() {
230 			data.reset();
231 		}
232 
233 		Common::String contentFile;
234 		Common::SharedPtr<TextFont> data;
235 		uint16 height;
236 		uint8 style;
237 		uint8 flags;
238 	};
239 
240 	int _width, _height;
241 	uint8 _first, _last;
242 	FontContent *_content;
243 	uint16 _numElements;
244 	uint16 _selectedElement;
245 
246 	const uint8 *_colorMap;
247 	const uint16 _maxPathLen;
248 	const bool _needsLocalizedFont;
249 
250 	static uint8 _errorDialogDisplayed;
251 
252 	Resource *_res;
253 };
254 #endif // ENABLE_EOB
255 
256 /**
257  * Implementation of the Font interface for Kyra 1 style (non-native AmigaDOS) AMIGA fonts.
258  */
259 class AMIGAFont : public Font {
260 public:
261 	AMIGAFont();
~AMIGAFont()262 	~AMIGAFont() { unload(); }
263 
264 	bool load(Common::SeekableReadStream &file);
getHeight()265 	int getHeight() const { return _height; }
getWidth()266 	int getWidth() const { return _width; }
267 	int getCharWidth(uint16 c) const;
setColorMap(const uint8 * src)268 	void setColorMap(const uint8 *src) {}
269 	void drawChar(uint16 c, byte *dst, int pitch, int) const;
270 
271 private:
272 	void unload();
273 
274 	int _width, _height;
275 
276 	struct Character {
277 		uint8 yOffset, xOffset, width;
278 
279 		struct Graphics {
280 			uint16 width, height;
281 			uint8 *bitmap;
282 		} graphics;
283 	};
284 
285 	Character _chars[255];
286 };
287 
288 /**
289  * Implementation of the Font interface for FM-Towns/PC98 fonts
290  */
291 class SJISFont : public Font {
292 public:
293 	SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, bool fatPrint, int extraSpacing);
~SJISFont()294 	virtual ~SJISFont() { unload(); }
295 
usesOverlay()296 	virtual bool usesOverlay() const { return true; }
297 
load(Common::SeekableReadStream &)298 	bool load(Common::SeekableReadStream &) { return true; }
299 	int getHeight() const;
300 	int getWidth() const;
301 	int getCharWidth(uint16 c) const;
302 	void setColorMap(const uint8 *src);
303 	virtual void drawChar(uint16 c, byte *dst, int pitch, int) const;
304 
305 protected:
306 	void unload();
307 
308 	const uint8 *_colorMap;
309 	Graphics::FontSJIS *_font;
310 	int _sjisWidth, _asciiWidth;
311 	int _fontHeight;
312 	const bool _drawOutline;
313 
314 private:
315 	const uint8 _invisColor;
316 	const bool _is16Color;
317 	// We use this for cases where the font width returned by getWidth() or getCharWidth() does not match the original.
318 	// The original Japanese game versions use hard coded sjis font widths of 8 or 9. However, this does not necessarily
319 	// depend on whether an outline is used or not (neither LOL/PC-9801 nor LOL/FM-TOWNS use an outline, but the first
320 	// version uses a font width of 8 where the latter uses a font width of 9).
321 	const int _sjisWidthOffset;
322 };
323 
324 /**
325  * A class that manages KYRA palettes.
326  *
327  * This class stores the palette data as VGA RGB internally.
328  */
329 class Palette {
330 public:
331 	Palette(const int numColors);
332 	~Palette();
333 
334 	enum {
335 		kVGABytesPerColor = 3,
336 		kPC98BytesPerColor = 3,
337 		kAmigaBytesPerColor = 2
338 	};
339 
340 	/**
341 	 * Load a VGA palette from the given stream.
342 	 */
343 	void loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors);
344 
345 	/**
346 	* Load a HiColor palette from the given stream.
347 	*/
348 	void loadHiColorPalette(Common::ReadStream &stream, int startIndex, int colors);
349 
350 	/**
351 	 * Load a EGA palette from the given stream.
352 	 */
353 	void loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors);
354 
355 	/**
356 	 * Set default CGA palette. We only need the cyan/magenta/grey mode.
357 	 */
358 	enum CGAIntensity {
359 		kIntensityLow = 0,
360 		kIntensityHigh = 1
361 	};
362 
363 	void setCGAPalette(int palIndex, CGAIntensity intensity);
364 
365 	/**
366 	 * Load a AMIGA palette from the given stream.
367 	 */
368 	void loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors);
369 
370 	/**
371 	 * Load a PC98 16 color palette from the given stream.
372 	 */
373 	void loadPC98Palette(Common::ReadStream &stream, int startIndex, int colors);
374 
375 	/**
376 	 * Return the number of colors this palette manages.
377 	 */
getNumColors()378 	int getNumColors() const { return _numColors; }
379 
380 	/**
381 	 * Set all palette colors to black.
382 	 */
383 	void clear();
384 
385 	/**
386 	 * Fill the given indexes with the given component value.
387 	 *
388 	 * @param firstCol  the first color, which should be overwritten.
389 	 * @param numCols   number of colors, which schould be overwritten.
390 	 * @param value     color component value, which should be stored.
391 	 */
392 	void fill(int firstCol, int numCols, uint8 value);
393 
394 	/**
395 	 * Copy data from another palette.
396 	 *
397 	 * @param source    palette to copy data from.
398 	 * @param firstCol  the first color of the source which should be copied.
399 	 * @param numCols   number of colors, which should be copied. -1 all remaining colors.
400 	 * @param dstStart  the first color, which should be ovewritten. If -1 firstCol will be used as start.
401 	 */
402 	void copy(const Palette &source, int firstCol = 0, int numCols = -1, int dstStart = -1);
403 
404 	/**
405 	 * Copy data from a raw VGA palette.
406 	 *
407 	 * @param source    source buffer
408 	 * @param firstCol  the first color of the source which should be copied.
409 	 * @param numCols   number of colors, which should be copied.
410 	 * @param dstStart  the first color, which should be ovewritten. If -1 firstCol will be used as start.
411 	 */
412 	void copy(const uint8 *source, int firstCol, int numCols, int dstStart = -1);
413 
414 	/**
415 	 * Fetch a RGB palette.
416 	 *
417 	 * @return a pointer to the RGB palette data, the client must delete[] it.
418 	 */
419 	uint8 *fetchRealPalette() const;
420 
421 	//XXX
422 	uint8 &operator[](const int index) {
423 		assert(index >= 0 && index <= _numColors * 3);
424 		return _palData[index];
425 	}
426 
427 	const uint8 &operator[](const int index) const {
428 		assert(index >= 0 && index <= _numColors * 3);
429 		return _palData[index];
430 	}
431 
432 	/**
433 	 * Gets raw access to the palette.
434 	 *
435 	 * TODO: Get rid of this.
436 	 */
getData()437 	uint8 *getData() { return _palData; }
getData()438 	const uint8 *getData() const { return _palData; }
439 
440 private:
441 	uint8 *_palData;
442 	const int _numColors;
443 
444 	static const uint8 _egaColors[];
445 	static const int _egaNumColors;
446 	static const uint8 _cgaColors[4][12];
447 	static const int _cgaNumColors;
448 };
449 
450 class Screen {
451 public:
452 	enum {
453 		SCREEN_W = 320,
454 		SCREEN_H = 200,
455 		SCREEN_PAGE_SIZE = 320 * 200 + 1024,
456 		SCREEN_OVL_SJIS_SIZE = 640 * 400,
457 		SCREEN_PAGE_NUM = 16,
458 		SCREEN_OVLS_NUM = 6
459 	};
460 
461 	enum CopyRegionFlags {
462 		CR_NO_P_CHECK = 0x01
463 	};
464 
465 	enum DrawShapeFlags {
466 		DSF_X_FLIPPED  = 0x01,
467 		DSF_Y_FLIPPED  = 0x02,
468 		DSF_SCALE      = 0x04,
469 		DSF_WND_COORDS = 0x10,
470 		DSF_CENTER     = 0x20,
471 
472 		DSF_SHAPE_FADING		= 0x100,
473 		DSF_TRANSPARENCY		= 0x1000,
474 		DSF_BACKGROUND_FADING	= 0x2000,
475 		DSF_CUSTOM_PALETTE		= 0x8000
476 	};
477 
478 	enum FontId {
479 		FID_6_FNT = 0,
480 		FID_8_FNT,
481 		FID_9_FNT,
482 		FID_CRED6_FNT,
483 		FID_CRED8_FNT,
484 		FID_BOOKFONT_FNT,
485 		FID_GOLDFONT_FNT,
486 		FID_INTRO_FNT,
487 		FID_SJIS_FNT,
488 		FID_SJIS_LARGE_FNT,
489 		FID_SJIS_SMALL_FNT,
490 		FID_NUM
491 	};
492 
493 	Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize);
494 	virtual ~Screen();
495 
496 	// init
497 	virtual bool init();
498 	virtual void setResolution();
499 	virtual void enableHiColorMode(bool enabled);
500 
501 	void updateScreen();
502 
503 	// debug functions
queryScreenDebug()504 	bool queryScreenDebug() const { return _debugEnabled; }
505 	bool enableScreenDebug(bool enable);
506 
507 	// page cur. functions
508 	int setCurPage(int pageNum);
509 	void clearCurPage();
510 
511 	void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src,
512 	                 int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2);
513 
514 	// page 0 functions
515 	void copyToPage0(int y, int h, uint8 page, uint8 *seqBuf);
516 	void shakeScreen(int times);
517 
518 	// page functions
519 	void copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage, int flags=0);
520 	void copyPage(uint8 srcPage, uint8 dstPage);
521 
522 	void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest);
523 	void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
524 
525 	void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
526 	void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
527 
528 	void clearPage(int pageNum);
529 
530 	int getPagePixel(int pageNum, int x, int y);
531 	void setPagePixel(int pageNum, int x, int y, uint8 color);
532 
533 	const uint8 *getCPagePtr(int pageNum) const;
534 	uint8 *getPageRect(int pageNum, int x, int y, int w, int h);
535 
536 	// palette handling
537 	void fadeFromBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
538 	void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
539 
540 	virtual void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
541 	virtual void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
542 	virtual int fadePalStep(const Palette &pal, int diff);
543 
544 	void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
545 	virtual void setScreenPalette(const Palette &pal);
546 
547 	// AMIGA version only
isInterfacePaletteEnabled()548 	bool isInterfacePaletteEnabled() const { return _interfacePaletteEnabled; }
549 	void enableInterfacePalette(bool e);
550 	void setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b);
551 
552 	virtual void getRealPalette(int num, uint8 *dst);
553 	Palette &getPalette(int num);
554 	void copyPalette(const int dst, const int src);
555 
556 	// gui specific (processing on _curPage)
557 	void drawLine(bool vertical, int x, int y, int length, int color);
558 	void drawClippedLine(int x1, int y1, int x2, int y2, int color);
559 	virtual void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
560 	void drawBox(int x1, int y1, int x2, int y2, int color);
561 
562 	// font/text handling
563 	virtual bool loadFont(FontId fontId, const char *filename);
564 	FontId setFont(FontId fontId);
565 
566 	int getFontHeight() const;
567 	int getFontWidth() const;
568 
569 	int getCharWidth(uint16 c) const;
570 	int getTextWidth(const char *str);
571 
572 	void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
573 
574 	virtual void setTextColorMap(const uint8 *cmap) = 0;
575 	void setTextColor(const uint8 *cmap, int a, int b);
576 	void setTextColor16bit(const uint16 *cmap16);
577 
578 	const ScreenDim *getScreenDim(int dim) const;
579 	void modifyScreenDim(int dim, int x, int y, int w, int h);
screenDimTableCount()580 	int screenDimTableCount() const { return _dimTableCount; }
581 
582 	void setScreenDim(int dim);
curDimIndex()583 	int curDimIndex() const { return _curDimIndex; }
584 
585 	const ScreenDim *_curDim;
586 
587 	// shape handling
588 	uint8 *encodeShape(int x, int y, int w, int h, int flags);
589 
590 	int setNewShapeHeight(uint8 *shape, int height);
591 	int resetShapeHeight(uint8 *shape);
592 
593 	virtual void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...);
594 
595 	// mouse handling
596 	void hideMouse();
597 	void showMouse();
598 	bool isMouseVisible() const;
599 	virtual void setMouseCursor(int x, int y, const byte *shape);
600 
601 	// rect handling
602 	virtual int getRectSize(int w, int h) = 0;
603 
604 	void rectClip(int &x, int &y, int w, int h);
605 
606 	// misc
607 	virtual void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip=false);
608 
609 	virtual bool loadPalette(const char *filename, Palette &pal);
610 	bool loadPaletteTable(const char *filename, int firstPalette);
611 	virtual void loadPalette(const byte *data, Palette &pal, int bytes);
612 
613 	void setAnimBlockPtr(int size);
614 
615 	void setShapePages(int page1, int page2, int minY = -1, int maxY = 201);
616 
617 	virtual byte getShapeFlag1(int x, int y);
618 	virtual byte getShapeFlag2(int x, int y);
619 
620 	virtual int getDrawLayer(int x, int y);
621 	virtual int getDrawLayer2(int x, int y, int height);
622 
623 	void blockInRegion(int x, int y, int width, int height);
624 	void blockOutRegion(int x, int y, int width, int height);
625 
626 	int _charWidth;
627 	int _charOffset;
628 	int _curPage;
629 	uint8 *_shapePages[2];
630 	int _maskMinY, _maskMaxY;
631 	FontId _currentFont;
632 
633 	// decoding functions
634 	static void decodeFrame1(const uint8 *src, uint8 *dst, uint32 size);
635 	static uint16 decodeEGAGetCode(const uint8 *&pos, uint8 &nib);
636 
637 	static void decodeFrame3(const uint8 *src, uint8 *dst, uint32 size, bool isAmiga);
638 	static uint decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize);
639 	static void decodeFrameDelta(uint8 *dst, const uint8 *src, bool noXor = false);
640 	static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch, bool noXor);
641 
642 	static void convertAmigaGfx(uint8 *data, int w, int h, int depth = 5, bool wsa = false, int bytesPerPlane = -1);
643 	static void convertAmigaMsc(uint8 *data);
644 
645 	// This seems to be a variant of shuffleScreen (which is used in LoK). At the time of coding (and long after that) the
646 	// fact that this is a double implementation went unnoticed. My - admittedly limited - efforts to get rid of one of these
647 	// implementations were unsatisfactory, though. Each method seems to be optimized to produce accurate results for its
648 	// specifc purpose (LoK for shuffleScreen, EoB/LoL for crossFadeRegion). Merging these methods has no priority, since we
649 	// can well afford the 20 lines of extra code.
650 	void crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage);
651 
get16bitPalette()652 	uint16 *get16bitPalette() { return _16bitPalette; }
set16bitShadingLevel(int lvl)653 	void set16bitShadingLevel(int lvl) { _16bitShadingLevel = lvl; }
654 
655 protected:
656 	void resetPagePtrsAndBuffers(int pageSize);
657 	uint8 *getPagePtr(int pageNum);
658 	virtual void updateDirtyRects();
659 	void updateDirtyRectsAmiga();
660 	void updateDirtyRectsOvl();
661 
662 	void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);
663 	virtual void mergeOverlay(int x, int y, int w, int h);
664 
665 	// overlay specific
666 	byte *getOverlayPtr(int pageNum);
667 	void clearOverlayPage(int pageNum);
668 	void clearOverlayRect(int pageNum, int x, int y, int w, int h);
669 	void copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int srcPage, int dstPage);
670 
671 	// font/text specific
672 	uint16 fetchChar(const char *&s) const;
673 	void drawChar(uint16 c, int x, int y);
674 
675 	int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size);
676 
677 	template<bool noXor> static void wrapped_decodeFrameDelta(uint8 *dst, const uint8 *src);
678 	template<bool noXor> static void wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch);
679 
680 	uint8 *_pagePtrs[16];
681 	uint8 *_sjisOverlayPtrs[SCREEN_OVLS_NUM];
682 	uint8 _pageMapping[SCREEN_PAGE_NUM];
683 
684 	bool _useOverlays;
685 	bool _useSJIS;
686 	bool _use16ColorMode;
687 	bool _useHiResEGADithering;
688 	bool _useHiColorScreen;
689 	bool _isAmiga;
690 	bool _useAmigaExtraColors;
691 	Common::RenderMode _renderMode;
692 	int _bytesPerPixel;
693 	int _screenPageSize;
694 
695 	uint8 _sjisInvisibleColor;
696 	bool _sjisMixedFontMode;
697 
698 	Palette *_screenPalette;
699 	Common::Array<Palette *> _palettes;
700 	Palette *_internFadePalette;
701 
702 	uint16 shade16bitColor(uint16 col);
703 
704 	uint16 *_16bitPalette;
705 	uint16 *_16bitConversionPalette;
706 	uint8 _16bitShadingLevel;
707 
708 	Font *_fonts[FID_NUM];
709 	uint8 _textColorsMap[16];
710 	uint16 _textColorsMap16bit[2];
711 
712 	uint8 *_decodeShapeBuffer;
713 	int _decodeShapeBufferSize;
714 
715 	uint8 *_animBlockPtr;
716 	int _animBlockSize;
717 
718 	// dimension handling
719 	const ScreenDim *const _dimTable;
720 	ScreenDim **_customDimTable;
721 	const int _dimTableCount;
722 	int _curDimIndex;
723 
724 	// mouse handling
725 	int _mouseLockCount;
726 	const uint8 _cursorColorKey;
727 
postProcessCursor(uint8 * data,int w,int h,int pitch)728 	virtual void postProcessCursor(uint8 *data, int w, int h, int pitch) {}
729 
730 	enum {
731 		kMaxDirtyRects = 50
732 	};
733 
734 	bool _forceFullUpdate;
735 	bool _paletteChanged;
736 	Common::List<Common::Rect> _dirtyRects;
737 
738 	void addDirtyRect(int x, int y, int w, int h);
739 
740 	OSystem *_system;
741 	KyraEngine_v1 *_vm;
742 
743 	// shape
744 	int drawShapeMarginNoScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
745 	int drawShapeMarginNoScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
746 	int drawShapeMarginScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
747 	int drawShapeMarginScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
748 	int drawShapeSkipScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
749 	int drawShapeSkipScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
750 	void drawShapeProcessLineNoScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt, int16 scaleState);
751 	void drawShapeProcessLineNoScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt, int16 scaleState);
752 	void drawShapeProcessLineScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt, int16 scaleState);
753 	void drawShapeProcessLineScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt, int16 scaleState);
754 
755 	void drawShapePlotType0(uint8 *dst, uint8 cmd);
756 	void drawShapePlotType1(uint8 *dst, uint8 cmd);
757 	void drawShapePlotType3_7(uint8 *dst, uint8 cmd);
758 	void drawShapePlotType4(uint8 *dst, uint8 cmd);
759 	void drawShapePlotType5(uint8 *dst, uint8 cmd);
760 	void drawShapePlotType6(uint8 *dst, uint8 cmd);
761 	void drawShapePlotType8(uint8 *dst, uint8 cmd);
762 	void drawShapePlotType9(uint8 *dst, uint8 cmd);
763 	void drawShapePlotType11_15(uint8 *dst, uint8 cmd);
764 	void drawShapePlotType12(uint8 *dst, uint8 cmd);
765 	void drawShapePlotType13(uint8 *dst, uint8 cmd);
766 	void drawShapePlotType14(uint8 *dst, uint8 cmd);
767 	void drawShapePlotType16(uint8 *dst, uint8 cmd);
768 	void drawShapePlotType20(uint8 *dst, uint8 cmd);
769 	void drawShapePlotType21(uint8 *dst, uint8 cmd);
770 	void drawShapePlotType33(uint8 *dst, uint8 cmd);
771 	void drawShapePlotType37(uint8 *dst, uint8 cmd);
772 	void drawShapePlotType48(uint8 *dst, uint8 cmd);
773 	void drawShapePlotType52(uint8 *dst, uint8 cmd);
774 
775 	typedef int (Screen::*DsMarginSkipFunc)(uint8 *&dst, const uint8 *&src, int &cnt);
776 	typedef void (Screen::*DsLineFunc)(uint8 *&dst, const uint8 *&src, int &cnt, int16 scaleState);
777 	typedef void (Screen::*DsPlotFunc)(uint8 *dst, uint8 cmd);
778 
779 	DsMarginSkipFunc _dsProcessMargin;
780 	DsMarginSkipFunc _dsScaleSkip;
781 	DsLineFunc _dsProcessLine;
782 	DsPlotFunc _dsPlot;
783 
784 	const uint8 *_dsShapeFadingTable;
785 	int _dsShapeFadingLevel;
786 	const uint8 *_dsColorTable;
787 	const uint8 *_dsTransparencyTable1;
788 	const uint8 *_dsTransparencyTable2;
789 	const uint8 *_dsBackgroundFadingTable;
790 	int _dsDrawLayer;
791 	uint8 *_dsDstPage;
792 	int _dsTmpWidth;
793 	int _dsOffscreenLeft;
794 	int _dsOffscreenRight;
795 	int _dsScaleW;
796 	int _dsScaleH;
797 	int _dsOffscreenScaleVal1;
798 	int _dsOffscreenScaleVal2;
799 	int _drawShapeVar1;
800 	int _drawShapeVar3;
801 	int _drawShapeVar4;
802 	int _drawShapeVar5;
803 
804 	// AMIGA version
805 	bool _interfacePaletteEnabled;
806 
807 	// debug
808 	bool _debugEnabled;
809 };
810 
811 } // End of namespace Kyra
812 
813 #endif
814