ScummVM API documentation
screen.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef KYRA_SCREEN_H
23#define KYRA_SCREEN_H
24
25#include "common/util.h"
26#include "common/func.h"
27#include "common/list.h"
28#include "common/array.h"
29#include "common/rect.h"
30#include "common/rendermode.h"
31#include "common/stream.h"
32#include "common/ptr.h"
33#include "common/error.h"
34#include "graphics/pixelformat.h"
35
36class OSystem;
37
38namespace Graphics {
39class FontSJIS;
40} // End of namespace Graphics
41
42namespace Kyra {
43
44typedef Common::Functor0<void> UpdateFunctor;
45
46class KyraEngine_v1;
47class Screen;
48
49struct ScreenDim {
50 uint16 sx;
51 uint16 sy;
52 uint16 w;
53 uint16 h;
54 uint16 col1;
55 uint16 col2;
56 uint16 line;
57 uint16 column;
58};
59
63class Font {
64public:
65 /* Font types
66 * Currently, we actually only care about oneByte and twoByte, but
67 * naming it like this makes it easier to extend if the need arises.
68 */
69 enum Type {
70 kASCII = 0,
71 kJIS_X0201,
72 kSJIS,
73 kBIG5,
74 kJohab
75 };
76
77public:
78 virtual ~Font() {}
79
83 virtual bool load(Common::SeekableReadStream &file) = 0;
84
88 virtual bool usesOverlay() const { return false; }
89
93 virtual Type getType() const = 0;
94
98 virtual int getHeight() const = 0;
99
104 virtual int getWidth() const = 0;
105
109 virtual int getCharWidth(uint16 c) const = 0;
110
115 virtual int getCharHeight(uint16 c) const { return getHeight(); }
116
120 virtual void setColorMap(const uint8 *src) = 0;
121
125 virtual void setHiColorMap(const uint32 *src) {}
126
127 enum FontStyle {
128 kStyleNone = 0,
129 kStyleLeftShadow = 1 << 0,
130 kStyleBorder = 1 << 1,
131 kStyleFat = 1 << 2,
132 kStyleNarrow1 = 1 << 3,
133 kStyleNarrow2 = 1 << 4,
134 kStyleFullWidth = 1 << 5,
135 kStyleForceOneByte = 1 << 6
136 };
137
141 virtual void setStyles(int styles) {}
142
151 virtual void drawChar(uint16 c, byte *dst, int pitch, int bpp) const = 0;
152
153 virtual void drawChar(uint16 c, byte *dst, int pitch, int xOffs, int yOffs) const {}
154};
155
162class DOSFont : public Font {
163public:
164 DOSFont();
165 ~DOSFont() override { unload(); }
166
167 bool load(Common::SeekableReadStream &file) override;
168 Type getType() const override { return kASCII; }
169 int getHeight() const override { return _height; }
170 int getWidth() const override { return _width; }
171 int getCharWidth(uint16 c) const override;
172 void setColorMap(const uint8 *src) override { _colorMap = src; }
173 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
174
175private:
176 void unload();
177
178 const uint8 *_colorMap;
179
180 uint8 *_data;
181
182 int _width, _height;
183
184 int _numGlyphs;
185
186 uint8 *_widthTable;
187 uint8 *_heightTable;
188 uint16 *_bitmapOffsets;
189};
190
194class AMIGAFont : public Font {
195public:
196 AMIGAFont();
197 ~AMIGAFont() override { unload(); }
198
199 bool load(Common::SeekableReadStream &file) override;
200 Type getType() const override { return kASCII; }
201 int getHeight() const override { return _height; }
202 int getWidth() const override { return _width; }
203 int getCharWidth(uint16 c) const override;
204 void setColorMap(const uint8 *src) override {}
205 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
206
207private:
208 void unload();
209
210 int _width, _height;
211
212 struct Character {
213 uint8 yOffset, xOffset, width;
214
215 struct Graphics {
216 uint16 width, height;
217 uint8 *bitmap;
218 } graphics;
219 };
220
221 Character _chars[255];
222};
223
227class SJISFont : public Font {
228public:
229 SJISFont(Common::SharedPtr<Graphics::FontSJIS> &font, const uint8 invisColor, bool is16Color, bool drawOutline, int extraSpacing);
230 ~SJISFont() override {}
231
232 bool usesOverlay() const override { return true; }
233 Type getType() const override { return kSJIS; }
234
235 bool load(Common::SeekableReadStream &) override { return true; }
236 int getHeight() const override;
237 int getWidth() const override;
238 int getCharWidth(uint16 c) const override;
239 void setColorMap(const uint8 *src) override;
240 void setStyles(int style) override { _style = style; }
241 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
242
243protected:
244 const uint8 *_colorMap;
246 const bool _drawOutline;
247 int _style;
248
249private:
250 const uint8 _invisColor;
251 const bool _isTextMode;
252 // We use this for cases where the font width returned by getWidth() or getCharWidth() does not match the original.
253 // The original Japanese game versions use hard coded sjis font widths of 8 or 9. However, this does not necessarily
254 // depend on whether an outline is used or not (neither LOL/PC-9801 nor LOL/FM-TOWNS use an outline, but the first
255 // version uses a font width of 8 where the latter uses a font width of 9).
256 const int _sjisWidthOffset;
257};
258
259class ChineseFont : public Font {
260public:
261 ChineseFont(int pitch, int renderWidth, int renderHeight, int spacingWidth, int spacingHeight, int extraSpacingWidth, int extraSpacingHeight);
262 ~ChineseFont() override;
263
264 virtual Type getType() const override { return kBIG5; }
265
266 bool load(Common::SeekableReadStream &data) override;
267
268 void setStyles(int styles) override { _border = (styles & kStyleBorder); }
269 int getHeight() const override { return _spacingHeight + (_border ? _borderExtraSpacingHeight : 0); }
270 int getWidth() const override { return _spacingWidth + (_border ? _borderExtraSpacingWidth : 0); }
271 int getCharWidth(uint16 c) const override { return hasGlyphForCharacter(c) ? getWidth() : -1; }
272 int getCharHeight(uint16 c) const override { return hasGlyphForCharacter(c) ? _renderHeight + (_border ? _borderExtraSpacingHeight : 0) : -1; }
273 void setColorMap(const uint8 *src) override;
274 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
275
276protected:
277 uint32 getGlyphDataSize() const { return _glyphDataSize; }
278 uint16 _textColor[2];
279 bool _pixelColorShading;
280 const uint8 *_colorMap;
281 bool _border;
282
283private:
284 virtual bool hasGlyphForCharacter(uint16 c) const = 0;
285 virtual uint32 getFontOffset(uint16 c) const = 0;
286 virtual void processColorMap() = 0;
287
288 const int _spacingWidth, _spacingHeight;
289 const int _borderExtraSpacingWidth, _borderExtraSpacingHeight;
290 const int _renderWidth, _renderHeight;
291
292 const uint8 *_glyphData;
293 uint32 _glyphDataSize;
294 const uint16 _pitch;
295};
296
297class JohabFontLoK final : public Font {
298public:
299 JohabFontLoK(Font *&font8fat, const uint16 *lookupTable, uint32 lookupTableSize);
300 ~JohabFontLoK() override;
301
302 enum {
303 kNumJongseong = 191,
304 kNumJungseong = 85,
305 kNumChoseong = 109
306 };
307
308 bool load(Common::SeekableReadStream &data) override;
309 Type getType() const override { return kJohab; }
310 int getHeight() const override { return _height; }
311 int getWidth() const override { return _width; }
312 int getCharWidth(uint16 c) const override;
313 int getCharHeight(uint16 c) const override;
314 void setColorMap(const uint8 *src) override;
315 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
316
317private:
318 const uint8 *createGlyph(uint16 chr) const;
319 void processColorMap();
320 void renderGlyph(byte *dst, const uint8 *glyph, uint8 col, int pitch) const;
321
322 int _width, _height;
323 const uint8 *_colorMap;
324
325 Font *&_font8fat;
326 const uint8 *_fileData;
327 const uint8 *_glyphData[3];
328 const uint16 *_2byteTables[7];
329 uint8 *_glyphTemp;
330};
331
332class ChineseOneByteFontLoK final : public ChineseFont {
333public:
334 ChineseOneByteFontLoK(int pitch);
335private:
336 bool hasGlyphForCharacter(uint16 c) const override { return !(c & 0x80); }
337 uint32 getFontOffset(uint16 c) const override { return (c & 0x7F) * 14; }
338 void processColorMap() override;
339};
340
341class ChineseTwoByteFontLoK final : public ChineseFont {
342public:
343 ChineseTwoByteFontLoK(int pitch, const uint16 *lookupTable, uint32 lookupTableSize);
344private:
345 bool hasGlyphForCharacter(uint16 c) const override;
346 uint32 getFontOffset(uint16 c) const override;
347 void processColorMap() override;
348
349 const uint16 *_lookupTable;
350 uint32 _lookupTableSize;
351};
352
353class ChineseOneByteFontMR final : public ChineseFont {
354public:
355 ChineseOneByteFontMR(int pitch) : ChineseFont(pitch, 7, 14, 9, 14, 0, 2) {}
356private:
357 bool hasGlyphForCharacter(uint16 c) const override { return (c == 0x6187) || !(c & 0x80); }
358 uint32 getFontOffset(uint16 c) const override { return ((c == 0x6187) ? 128 : (c & 0x7F)) * 14; }
359 void processColorMap() override;
360};
361
362class ChineseTwoByteFontMR final : public ChineseFont {
363public:
364 ChineseTwoByteFontMR(int pitch) : ChineseFont(pitch, 15, 14, 18, 14, 0, 2) {}
365private:
366 bool hasGlyphForCharacter(uint16 c) const override { return (c != 0x6187) && (c & 0x80); }
367 uint32 getFontOffset(uint16 c) const override;
368 void processColorMap() override;
369};
370
371#ifdef ENABLE_LOL
372
373class ChineseOneByteFontLoL final : public ChineseFont {
374public:
375 ChineseOneByteFontLoL(int pitch) : ChineseFont(pitch, 8, 14, 8, 16, 0, 0) { _pixelColorShading = false; }
376 void setStyles(int styles) override {}
377
378private:
379 bool hasGlyphForCharacter(uint16 c) const override { return !(c & 0x80); }
380 uint32 getFontOffset(uint16 c) const override { return (c & 0x7F) * 14; }
381 void processColorMap() override;
382};
383
384class ChineseTwoByteFontLoL final : public ChineseFont {
385public:
386 ChineseTwoByteFontLoL(int pitch) : ChineseFont(pitch, 16, 14, 16, 16, 0, 0) { _pixelColorShading = false; }
387 void setStyles(int styles) override {}
388
389private:
390 bool hasGlyphForCharacter(uint16 c) const override { return (c & 0x80) && getFontOffset(c) < getGlyphDataSize(); }
391 uint32 getFontOffset(uint16 c) const override;
392 void processColorMap() override;
393};
394
395#endif
396
397class ChineseOneByteFontHOF final : public ChineseFont {
398public:
399 ChineseOneByteFontHOF(int pitch) : ChineseFont(pitch, 8, 14, 9, 15, 0, 0) {}
400private:
401 bool hasGlyphForCharacter(uint16 c) const override { return !(c & 0x80); }
402 uint32 getFontOffset(uint16 c) const override { return (c & 0x7F) * 14; }
403 void processColorMap() override;
404};
405
406class ChineseTwoByteFontHOF final : public ChineseFont {
407public:
408 ChineseTwoByteFontHOF(int pitch) : ChineseFont(pitch, 16, 14, 18, 15, 0, 0) {}
409private:
410 bool hasGlyphForCharacter(uint16 c) const override { return (c & 0x80); }
411 uint32 getFontOffset(uint16 c) const override;
412 void processColorMap() override;
413};
414
415class KoreanOneByteFontHOF final : public ChineseFont {
416public:
417 KoreanOneByteFontHOF(int pitch) : ChineseFont(pitch, 8, 9, 8, 10, 0, 0) {}
418 Type getType() const override { return kJohab; }
419private:
420 bool hasGlyphForCharacter(uint16 c) const override { return !(c & 0x80); }
421 uint32 getFontOffset(uint16 c) const override { return (c & 0x7F) * 9; }
422 void processColorMap() override;
423};
424
425class KoreanTwoByteFontHOF final : public ChineseFont {
426public:
427 KoreanTwoByteFontHOF(int pitch) : ChineseFont(pitch, 10, 9, 10, 10, 0, 0) {}
428 Type getType() const override { return kJohab; }
429private:
430 bool hasGlyphForCharacter(uint16 c) const override { return (c & 0x80); }
431 uint32 getFontOffset(uint16 c) const override;
432 void processColorMap() override;
433};
434
435class MultiSubsetFont final : public Font {
436public:
437 MultiSubsetFont(Common::Array<Font*> *subsets) : Font(), _subsets(subsets) {}
438 ~MultiSubsetFont() override;
439 Type getType() const override { return kBIG5; }
440
441 // Caveat: This method will try to load a font into the first subset slot it finds.
442 // It expects the load method of the subset font to return false if the slot has
443 // already been filled. It will then try the next slot. So, unlike other fonts the
444 // subset fonts cannot be allowed to call the load method as often as they want
445 // (which we never did anyway - we only ever load each font exactly one time).
446 // But this also means that different
447 bool load(Common::SeekableReadStream &data) override;
448
449 void setStyles(int styles) override;
450 int getHeight() const override;
451 int getWidth() const override;
452 int getCharWidth(uint16 c) const override;
453 int getCharHeight(uint16 c) const override;
454 void setColorMap(const uint8 *src) override;
455 void drawChar(uint16 c, byte *dst, int pitch, int) const override;
456
457private:
458 Common::Array<Font*> *_subsets;
459};
460
466class Palette {
467public:
468 Palette(const int numColors);
469 ~Palette();
470
471 enum {
472 kVGABytesPerColor = 3,
473 kPC98BytesPerColor = 3,
474 kAmigaBytesPerColor = 2
475 };
476
480 void loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors);
481
485 void loadHiColorPalette(Common::ReadStream &stream, int startIndex, int colors);
486
490 void loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors);
491
496 kIntensityLow = 0,
497 kIntensityHigh = 1
498 };
499
500 void setCGAPalette(int palIndex, CGAIntensity intensity);
501
505 void loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors);
506
510 void loadPC98Palette(Common::ReadStream &stream, int startIndex, int colors);
511
515 int getNumColors() const { return _numColors; }
516
520 void clear();
521
529 void fill(int firstCol, int numCols, uint8 value);
530
539 void copy(const Palette &source, int firstCol = 0, int numCols = -1, int dstStart = -1);
540
549 void copy(const uint8 *source, int firstCol, int numCols, int dstStart = -1);
550
556 uint8 *fetchRealPalette() const;
557
558 //XXX
559 uint8 &operator[](const int index) {
560 assert(index >= 0 && index <= _numColors * 3);
561 return _palData[index];
562 }
563
564 const uint8 &operator[](const int index) const {
565 assert(index >= 0 && index <= _numColors * 3);
566 return _palData[index];
567 }
568
574 uint8 *getData() { return _palData; }
575 const uint8 *getData() const { return _palData; }
576
577private:
578 uint8 *_palData;
579 const int _numColors;
580
581 static const uint8 _egaColors[];
582 static const int _egaNumColors;
583 static const uint8 _cgaColors[4][12];
584 static const int _cgaNumColors;
585};
586
587class Screen {
588public:
589 enum {
590 SCREEN_W = 320,
591 SCREEN_H = 200,
592 SCREEN_H_SEGA_NTSC = 224,
593 SCREEN_PAGE_SIZE = 320 * 200 + 1024,
594 SCREEN_OVL_SJIS_SIZE = 640 * 400,
595 SCREEN_PAGE_NUM = 16,
596 SCREEN_OVLS_NUM = 6,
597
598 SCREEN_IDLEREFRESH_RESTART_MSEC = 250,
599 SCREEN_IDLEREFRESH_RATE_MSEC = 16
600 };
601
602 enum CopyRegionFlags {
603 CR_NO_P_CHECK = 0x01
604 };
605
606 enum DrawShapeFlags {
607 kDRAWSHP_XFLIP = 0x01,
608 kDRAWSHP_YFLIP = 0x02,
609 kDRAWSHP_SCALE = 0x04,
610 kDRAWSHP_WINREL = 0x10,
611 kDRAWSHP_CENTER = 0x20,
612 kDRAWSHP_FADE = 0x100,
613 kDRAWSHP_PREDATOR = 0x200,
614 kDRAWSHP_COMPACT = 0x400,
615 kDRAWSHP_PRIORITY = 0x800,
616 kDRAWSHP_TRANSPARENT = 0x1000,
617 kDRAWSHP_BCKGRNDFADE = 0x2000,
618 kDRAWSHP_MORPH = 0x4000,
619 kDRAWSHP_COLOR = 0x8000
620 };
621
622 enum FontId {
623 FID_6_FNT = 0,
624 FID_8_FNT,
625 FID_9_FNT,
626 FID_CRED6_FNT,
627 FID_CRED8_FNT,
628 FID_BOOKFONT_FNT,
629 FID_GOLDFONT_FNT,
630 FID_INTRO_FNT,
631 FID_SJIS_FNT,
632 FID_SJIS_TEXTMODE_FNT,
633 FID_SJIS_LARGE_FNT,
634 FID_SJIS_SMALL_FNT,
635 FID_CHINESE_FNT,
636 FID_KOREAN_FNT,
637 FID_NUM
638 };
639
640 Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, const int dimTableSize);
641 virtual ~Screen();
642
643 // init
644 virtual bool init();
645 virtual Common::Error setResolution();
646 virtual void enableHiColorMode(bool enabled);
647
648 // refresh
649 int updateScreen();
650 void updateBackendScreen(bool force);
651
652 uint32 _idleUpdateTimer;
653
654 // debug functions
655 bool queryScreenDebug() const { return _debugEnabled; }
656 bool enableScreenDebug(bool enable);
657
658 // page cur. functions
659 int setCurPage(int pageNum);
660 void clearCurPage();
661
662 void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src,
663 int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2);
664
665 // page 0 functions
666 void copyToPage0(int y, int h, uint8 page, uint8 *seqBuf);
667 void shakeScreen(int times);
668
669 // page functions
670 void copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage, int flags=0);
671 void copyPage(uint8 srcPage, uint8 dstPage);
672
673 void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest);
674 void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
675
676 void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
677 void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
678
679 void clearPage(int pageNum);
680
681 int getPagePixel(int pageNum, int x, int y) {
682 assert(_getPagePixelProc);
683 return (this->*_getPagePixelProc)(pageNum, x, y);
684 }
685 void setPagePixel(int pageNum, int x, int y, uint8 color) {
686 assert(_setPagePixelProc);
687 (this->*_setPagePixelProc)(pageNum, x, y, color);
688 }
689
690 const uint8 *getCPagePtr(int pageNum) const;
691 uint8 *getPageRect(int pageNum, int x, int y, int w, int h);
692
693 // palette handling
694 void fadeFromBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
695 void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
696
697 virtual void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
698 virtual void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
699 virtual int fadePalStep(const Palette &pal, int diff);
700
701 void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
702 virtual void setScreenPalette(const Palette &pal);
703
704 // SegaCD version
705 // This is a somewhat hacky but probably least invasive way to
706 // move the whole ingame screen output down a couple of lines.
707 void transposeScreenOutputY(int yAdd);
708
709 // AMIGA version only
710 bool isInterfacePaletteEnabled() const { return _dualPaletteModeSplitY; }
711 void enableDualPaletteMode(int splitY);
712 void disableDualPaletteMode();
713
714 virtual void getRealPalette(int num, uint8 *dst);
715 Palette &getPalette(int num);
716 void copyPalette(const int dst, const int src);
717
718 // gui specific (processing on _curPage)
719 void drawLine(bool vertical, int x, int y, int length, int color);
720 void drawClippedLine(int x1, int y1, int x2, int y2, int color);
721 virtual void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
722 void drawBox(int x1, int y1, int x2, int y2, int color);
723
724 // font/text handling
725 virtual bool loadFont(FontId fontId, const char *filename);
726 FontId setFont(FontId fontId);
727
728 int getFontHeight() const;
729 int getFontWidth() const;
730
731 int getCharWidth(uint16 c) const;
732 int getCharHeight(uint16 c) const;
733 int getTextWidth(const char *str, bool nextWordOnly = false);
734 int getNumberOfCharacters(const char *str);
735
736 void printText(const char *str, int x, int y, uint8 color1, uint8 color2, int pitch = -1);
737
738 virtual void setTextColorMap(const uint8 *cmap) = 0;
739 void setTextColor(const uint8 *cmap, int a, int b);
740 void setTextColorHiCol(const uint32 *cmap);
741 int setFontStyles(FontId fontId, int styles);
742
743 const ScreenDim *getScreenDim(int dim) const;
744 void modifyScreenDim(int dim, int x, int y, int w, int h);
745 int screenDimTableCount() const { return _dimTableCount; }
746
747 void setScreenDim(int dim);
748 int curDimIndex() const { return _curDimIndex; }
749
750 void setTextMarginRight(int x) { _textMarginRight = x; }
751 uint16 _textMarginRight;
752 bool _overdrawMargin;
753
754 const ScreenDim *_curDim;
755
756 Common::String _lineBreakChars;
757
758 // shape handling
759 uint8 *encodeShape(int x, int y, int w, int h, int flags);
760
761 int setNewShapeHeight(uint8 *shape, int height);
762 int resetShapeHeight(uint8 *shape);
763
764 virtual void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...);
765
766 // mouse handling
767 void hideMouse();
768 void showMouse();
769 bool isMouseVisible() const;
770 virtual void setMouseCursor(int x, int y, const byte *shape);
771
772 // rect handling
773 virtual int getRectSize(int w, int h) = 0;
774
775 void rectClip(int &x, int &y, int w, int h);
776
777 // misc
778 virtual void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip=false);
779
780 virtual bool loadPalette(const char *filename, Palette &pal);
781 bool loadPaletteTable(const char *filename, int firstPalette);
782 virtual void loadPalette(const byte *data, Palette &pal, int bytes);
783
784 void setAnimBlockPtr(int size);
785
786 void setShapePages(int page1, int page2, int minY = -1, int maxY = 201);
787
788 virtual byte getShapeFlag1(int x, int y);
789 virtual byte getShapeFlag2(int x, int y);
790
791 virtual int getDrawLayer(int x, int y);
792 virtual int getDrawLayer2(int x, int y, int height);
793
794 void blockInRegion(int x, int y, int width, int height);
795 void blockOutRegion(int x, int y, int width, int height);
796
797 int _charSpacing;
798 int _lineSpacing;
799 int _curPage;
800 uint8 *_shapePages[2];
801 int _maskMinY, _maskMaxY;
802 FontId _currentFont;
803
804 // decoding functions
805 static void decodeFrame1(const uint8 *src, uint8 *dst, uint32 size);
806 static uint16 decodeEGAGetCode(const uint8 *&pos, uint8 &nib);
807
808 static void decodeFrame3(const uint8 *src, uint8 *dst, uint32 size, bool isAmiga);
809 static uint decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize);
810 static void decodeFrameDelta(uint8 *dst, const uint8 *src, bool noXor = false);
811 static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch, bool noXor);
812
813 static void convertAmigaGfx(uint8 *data, int w, int h, int depth = 5, bool wsa = false, int bytesPerPlane = -1);
814 static void convertAmigaMsc(uint8 *data);
815
816 // This seems to be a variant of shuffleScreen (which is used in LoK). At the time of coding (and long after that) the
817 // fact that this is a double implementation went unnoticed. My - admittedly limited - efforts to get rid of one of these
818 // implementations were unsatisfactory, though. Each method seems to be optimized to produce accurate results for its
819 // specifc purpose (LoK for shuffleScreen, EoB/LoL for crossFadeRegion). Merging these methods has no priority, since we
820 // can well afford the 20 lines of extra code.
821 void crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage);
822
823 const void *getHiColorPalette() const { return _hiColorNativePalettes; }
824 void set16bitShadingLevel(int lvl) { _hiColorShadingLevel = lvl; }
825
826protected:
827 void resetPagePtrsAndBuffers(int pageSize);
828 uint8 *getPagePtr(int pageNum);
829 virtual void updateDirtyRects();
830 void updateDirtyRectsAmiga();
831 void updateDirtyRectsOvl();
832
833 template<typename srcPixelType, typename dstPixelType> void scale2x(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h);
834 template<typename pixelType> void mergeOverlayImpl(int x, int y, int w, int h);
835 virtual void mergeOverlay(int x, int y, int w, int h) {
836 assert(_mergeOverlayProc);
837 (this->*_mergeOverlayProc)(x, y, w, h);
838 }
839
840 // overlay specific
841 byte *getOverlayPtr(int pageNum);
842 void clearOverlayPage(int pageNum);
843 void clearOverlayRect(int pageNum, int x, int y, int w, int h);
844 void copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int srcPage, int dstPage);
845
846 // font/text specific
847 uint16 fetchChar(const char *&s) const;
848 void drawChar(uint16 c, int x, int y, int pitch = -1);
849
850 int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size);
851
852 template<bool noXor> static void wrapped_decodeFrameDelta(uint8 *dst, const uint8 *src);
853 template<bool noXor> static void wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch);
854
855 typedef void (Screen::*MergeOverlayFunc)(int, int, int, int);
856 MergeOverlayFunc _mergeOverlayProc;
857 static const MergeOverlayFunc _mergeOverlayProcs[];
858 typedef void (Screen::*Scale2xFunc)(uint8*, int, const uint8*, int, int, int);
859 Scale2xFunc _scale2xProc;
860 static const Scale2xFunc _scale2xProcs[];
861
862 template<typename T> int getPagePixelImpl(int pageNum, int x, int y);
863 template<typename T> void setPagePixelImpl(int pageNum, int x, int y, uint8 color);
864
865 typedef int (Screen::*GetPagePixelProc)(int, int, int);
866 GetPagePixelProc _getPagePixelProc;
867 static const GetPagePixelProc _getPagePixelProcs[];
868 typedef void (Screen::*SetPagePixelProc)(int, int, int, uint8);
869 SetPagePixelProc _setPagePixelProc;
870 static const SetPagePixelProc _setPagePixelProcs[];
871
872 uint8 *_pagePtrs[16];
873 const uint8 *_pagePtrsBuff;
874 uint8 *_sjisOverlayPtrs[SCREEN_OVLS_NUM];
875 uint8 _pageMapping[SCREEN_PAGE_NUM];
876
877 bool _useOverlays;
878 bool _useSJIS;
879 int _fontStyles;
880
881 Font *_fonts[FID_NUM];
882 uint8 _textColorsMap[16];
883 uint32 _textColorsMapHiCol[2];
884
885 uint8 *_textRenderBuffer;
886 int _textRenderBufferSize;
887
889 uint8 _sjisInvisibleColor;
890 bool _sjisMixedFontMode;
891
892 // colors/palette specific
893 bool _use16ColorMode;
894 bool _4bitPixelPacking;
895 bool _useHiResEGADithering;
896 Graphics::PixelFormat _outputPixelFormat;
897 bool _isAmiga;
898 bool _useAmigaExtraColors;
899 bool _isSegaCD;
900 Common::RenderMode _renderMode;
901 int _internalBytesPerPixel;
902 int _screenPageSize;
903 const int _screenHeight;
904 int _yTransOffs;
905
906 Palette *_screenPalette;
907 Common::Array<Palette *> _palettes;
908 Palette *_internFadePalette;
909
910 uint32 shadeRGBColor(uint32 col);
911
912 void *_hiColorNativePalettes;
913 void *_hiColorConversionPalette;
914 uint8 _hiColorShadingLevel;
915
916 uint8 *_animBlockPtr;
917 int _animBlockSize;
918
919 // dimension handling
920 const ScreenDim *const _dimTable;
921 ScreenDim **_customDimTable;
922 const int _dimTableCount;
923 int _curDimIndex;
924
925 // mouse handling
926 int _mouseLockCount;
927 const uint8 _cursorColorKey;
928
929 virtual void postProcessCursor(uint8 *data, int w, int h, int pitch) {}
930
931 enum {
932 kMaxDirtyRects = 50
933 };
934
935 bool _forceFullUpdate;
936 bool _paletteChanged;
937 Common::List<Common::Rect> _dirtyRects;
938
939 void addDirtyRect(int x, int y, int w, int h);
940
941 OSystem *_system;
942 KyraEngine_v1 *_vm;
943
944 // shape
945 typedef void (Screen::*DsPlotFunc)(uint8*, uint8);
946 typedef int (Screen::*DsMarginSkipFunc)(uint8*&, const uint8*&, int&);
947 typedef void (Screen::*DsLineFunc)(uint8*&, const uint8*&, const DsPlotFunc, int&, int16);
948
949 int drawShapeMarginNoScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
950 int drawShapeMarginNoScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
951 int drawShapeMarginScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
952 int drawShapeMarginScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
953 int drawShapeSkipScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt);
954 int drawShapeSkipScaleDownwind(uint8 *&dst, const uint8 *&src, int &cnt);
955 void drawShapeProcessLineNoScaleUpwind(uint8 *&dst, const uint8 *&src, const DsPlotFunc plot, int &cnt, int16);
956 void drawShapeProcessLineNoScaleDownwind(uint8 *&dst, const uint8 *&src, const DsPlotFunc plot, int &cnt, int16);
957 void drawShapeProcessLineScaleUpwind(uint8 *&dst, const uint8 *&src, const DsPlotFunc plot, int &cnt, int16 scaleState);
958 void drawShapeProcessLineScaleDownwind(uint8 *&dst, const uint8 *&src, const DsPlotFunc plot, int &cnt, int16 scaleState);
959
960 void drawShapePlotType0(uint8 *dst, uint8 cmd);
961 void drawShapePlotType1(uint8 *dst, uint8 cmd);
962 void drawShapePlotType3_7(uint8 *dst, uint8 cmd);
963 void drawShapePlotType4(uint8 *dst, uint8 cmd);
964 void drawShapePlotType5(uint8 *dst, uint8 cmd);
965 void drawShapePlotType6(uint8 *dst, uint8 cmd);
966 void drawShapePlotType8(uint8 *dst, uint8 cmd);
967 void drawShapePlotType9(uint8 *dst, uint8 cmd);
968 void drawShapePlotType11_15(uint8 *dst, uint8 cmd);
969 void drawShapePlotType12(uint8 *dst, uint8 cmd);
970 void drawShapePlotType13(uint8 *dst, uint8 cmd);
971 void drawShapePlotType14(uint8 *dst, uint8 cmd);
972 void drawShapePlotType16(uint8 *dst, uint8 cmd);
973 void drawShapePlotType20(uint8 *dst, uint8 cmd);
974 void drawShapePlotType21(uint8 *dst, uint8 cmd);
975 void drawShapePlotType33(uint8 *dst, uint8 cmd);
976 void drawShapePlotType37(uint8 *dst, uint8 cmd);
977 void drawShapePlotType48(uint8 *dst, uint8 cmd);
978 void drawShapePlotType52(uint8 *dst, uint8 cmd);
979
980 const uint8 *_dsShapeFadingTable;
981 int _dsShapeFadingLevel;
982 const uint8 *_dsColorTable;
983 const uint8 *_dsTransparencyTable1;
984 const uint8 *_dsTransparencyTable2;
985 const uint8 *_dsBackgroundFadingTable;
986 int _dsDrawLayer;
987 uint8 *_dsDstPage;
988 int _dsTmpWidth;
989 int _dsOffscreenLeft;
990 int _dsOffscreenRight;
991 int _dsScaleW;
992 int _dsScaleH;
993 int _dsOffscreenScaleVal1;
994 int _dsOffscreenScaleVal2;
995 int _drawShapeVar1;
996 int _drawShapeVar3;
997 int _drawShapeVar4;
998 int _drawShapeVar5;
999
1000 // AMIGA version
1001 int _dualPaletteModeSplitY;
1002
1003 // debug
1004 bool _debugEnabled;
1005};
1006
1007} // End of namespace Kyra
1008
1009#endif
Definition: array.h:52
Definition: error.h:81
Definition: stream.h:385
Definition: stream.h:745
Definition: str.h:59
Definition: screen.h:194
bool load(Common::SeekableReadStream &file) override
int getHeight() const override
Definition: screen.h:201
int getWidth() const override
Definition: screen.h:202
void setColorMap(const uint8 *src) override
Definition: screen.h:204
void drawChar(uint16 c, byte *dst, int pitch, int) const override
Type getType() const override
Definition: screen.h:200
int getCharWidth(uint16 c) const override
Definition: screen.h:259
virtual Type getType() const override
Definition: screen.h:264
int getCharHeight(uint16 c) const override
Definition: screen.h:272
void setColorMap(const uint8 *src) override
bool load(Common::SeekableReadStream &data) override
void setStyles(int styles) override
Definition: screen.h:268
int getHeight() const override
Definition: screen.h:269
void drawChar(uint16 c, byte *dst, int pitch, int) const override
int getCharWidth(uint16 c) const override
Definition: screen.h:271
int getWidth() const override
Definition: screen.h:270
Definition: screen.h:397
Definition: screen.h:332
Definition: screen.h:353
Definition: screen.h:406
Definition: screen.h:341
Definition: screen.h:362
Definition: screen.h:162
Type getType() const override
Definition: screen.h:168
int getCharWidth(uint16 c) const override
void setColorMap(const uint8 *src) override
Definition: screen.h:172
bool load(Common::SeekableReadStream &file) override
int getWidth() const override
Definition: screen.h:170
int getHeight() const override
Definition: screen.h:169
void drawChar(uint16 c, byte *dst, int pitch, int) const override
Definition: screen.h:63
virtual int getHeight() const =0
virtual bool load(Common::SeekableReadStream &file)=0
virtual void setStyles(int styles)
Definition: screen.h:141
virtual int getCharHeight(uint16 c) const
Definition: screen.h:115
virtual int getCharWidth(uint16 c) const =0
virtual bool usesOverlay() const
Definition: screen.h:88
virtual void setColorMap(const uint8 *src)=0
virtual void drawChar(uint16 c, byte *dst, int pitch, int bpp) const =0
virtual int getWidth() const =0
virtual void setHiColorMap(const uint32 *src)
Definition: screen.h:125
virtual Type getType() const =0
Definition: screen.h:297
bool load(Common::SeekableReadStream &data) override
Type getType() const override
Definition: screen.h:309
int getHeight() const override
Definition: screen.h:310
int getCharHeight(uint16 c) const override
int getCharWidth(uint16 c) const override
void setColorMap(const uint8 *src) override
void drawChar(uint16 c, byte *dst, int pitch, int) const override
int getWidth() const override
Definition: screen.h:311
Definition: screen.h:415
Type getType() const override
Definition: screen.h:418
Definition: screen.h:425
Type getType() const override
Definition: screen.h:428
Definition: kyra_v1.h:126
Definition: screen.h:435
bool load(Common::SeekableReadStream &data) override
void drawChar(uint16 c, byte *dst, int pitch, int) const override
void setColorMap(const uint8 *src) override
int getCharWidth(uint16 c) const override
int getHeight() const override
int getCharHeight(uint16 c) const override
int getWidth() const override
void setStyles(int styles) override
Type getType() const override
Definition: screen.h:439
Definition: screen.h:466
void loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors)
void loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors)
uint8 * getData()
Definition: screen.h:574
void fill(int firstCol, int numCols, uint8 value)
void copy(const Palette &source, int firstCol=0, int numCols=-1, int dstStart=-1)
void loadPC98Palette(Common::ReadStream &stream, int startIndex, int colors)
void loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors)
void copy(const uint8 *source, int firstCol, int numCols, int dstStart=-1)
int getNumColors() const
Definition: screen.h:515
void loadHiColorPalette(Common::ReadStream &stream, int startIndex, int colors)
CGAIntensity
Definition: screen.h:495
uint8 * fetchRealPalette() const
Definition: screen.h:227
int getCharWidth(uint16 c) const override
void drawChar(uint16 c, byte *dst, int pitch, int) const override
void setStyles(int style) override
Definition: screen.h:240
bool usesOverlay() const override
Definition: screen.h:232
bool load(Common::SeekableReadStream &) override
Definition: screen.h:235
void setColorMap(const uint8 *src) override
Type getType() const override
Definition: screen.h:233
int getWidth() const override
int getHeight() const override
Definition: screen.h:587
Definition: system.h:166
RenderMode
Definition: rendermode.h:48
Definition: formatinfo.h:28
Definition: detection.h:27
Definition: pixelformat.h:138
Definition: screen.h:49
Definition: atari-screen.h:58