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" 91 virtual Type getType()
const = 0;
96 virtual int getHeight()
const = 0;
102 virtual int getWidth()
const = 0;
107 virtual int getCharWidth(uint16 c)
const = 0;
118 virtual void setColorMap(
const uint8 *src) = 0;
127 kStyleLeftShadow = 1 << 0,
128 kStyleBorder = 1 << 1,
130 kStyleNarrow1 = 1 << 3,
131 kStyleNarrow2 = 1 << 4,
132 kStyleFullWidth = 1 << 5,
133 kStyleForceOneByte = 1 << 6
149 virtual void drawChar(uint16 c, byte *dst,
int pitch,
int bpp)
const = 0;
151 virtual void drawChar(uint16 c, byte *dst,
int pitch,
int xOffs,
int yOffs)
const {}
163 ~
DOSFont()
override { unload(); }
166 Type
getType()
const override {
return kASCII; }
169 int getCharWidth(uint16 c)
const override;
171 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
176 const uint8 *_colorMap;
186 uint16 *_bitmapOffsets;
198 Type
getType()
const override {
return kASCII; }
201 int getCharWidth(uint16 c)
const override;
203 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
211 uint8 yOffset, xOffset, width;
214 uint16 width, height;
219 Character _chars[255];
231 Type
getType()
const override {
return kSJIS; }
234 int getHeight()
const override;
235 int getWidth()
const override;
236 int getCharWidth(uint16 c)
const override;
237 void setColorMap(
const uint8 *src)
override;
239 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
242 const uint8 *_colorMap;
244 const bool _drawOutline;
248 const uint8 _invisColor;
249 const bool _isTextMode;
254 const int _sjisWidthOffset;
259 ChineseFont(
int pitch,
int renderWidth,
int renderHeight,
int spacingWidth,
int spacingHeight,
int extraSpacingWidth,
int extraSpacingHeight);
262 virtual Type
getType()
const override {
return kBIG5; }
266 void setStyles(
int styles)
override { _border = (styles & kStyleBorder); }
267 int getHeight()
const override {
return _spacingHeight + (_border ? _borderExtraSpacingHeight : 0); }
268 int getWidth()
const override {
return _spacingWidth + (_border ? _borderExtraSpacingWidth : 0); }
269 int getCharWidth(uint16 c)
const override {
return hasGlyphForCharacter(c) ? getWidth() : -1; }
270 int getCharHeight(uint16 c)
const override {
return hasGlyphForCharacter(c) ? _renderHeight + (_border ? _borderExtraSpacingHeight : 0) : -1; }
271 void setColorMap(
const uint8 *src)
override;
272 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
275 uint32 getGlyphDataSize()
const {
return _glyphDataSize; }
276 uint16 _textColor[2];
277 bool _pixelColorShading;
278 const uint8 *_colorMap;
282 virtual bool hasGlyphForCharacter(uint16 c)
const = 0;
283 virtual uint32 getFontOffset(uint16 c)
const = 0;
284 virtual void processColorMap() = 0;
286 const int _spacingWidth, _spacingHeight;
287 const int _borderExtraSpacingWidth, _borderExtraSpacingHeight;
288 const int _renderWidth, _renderHeight;
290 const uint8 *_glyphData;
291 uint32 _glyphDataSize;
297 JohabFontLoK(
Font *&font8fat,
const uint16 *lookupTable, uint32 lookupTableSize);
307 Type
getType()
const override {
return kJohab; }
310 int getCharWidth(uint16 c)
const override;
311 int getCharHeight(uint16 c)
const override;
312 void setColorMap(
const uint8 *src)
override;
313 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
316 const uint8 *createGlyph(uint16 chr)
const;
317 void processColorMap();
318 void renderGlyph(byte *dst,
const uint8 *glyph, uint8 col,
int pitch)
const;
321 const uint8 *_colorMap;
324 const uint8 *_fileData;
325 const uint8 *_glyphData[3];
326 const uint16 *_2byteTables[7];
334 bool hasGlyphForCharacter(uint16 c)
const override {
return !(c & 0x80); }
335 uint32 getFontOffset(uint16 c)
const override {
return (c & 0x7F) * 14; }
336 void processColorMap()
override;
343 bool hasGlyphForCharacter(uint16 c)
const override;
344 uint32 getFontOffset(uint16 c)
const override;
345 void processColorMap()
override;
347 const uint16 *_lookupTable;
348 uint32 _lookupTableSize;
355 bool hasGlyphForCharacter(uint16 c)
const override {
return (c == 0x6187) || !(c & 0x80); }
356 uint32 getFontOffset(uint16 c)
const override {
return ((c == 0x6187) ? 128 : (c & 0x7F)) * 14; }
357 void processColorMap()
override;
364 bool hasGlyphForCharacter(uint16 c)
const override {
return (c != 0x6187) && (c & 0x80); }
365 uint32 getFontOffset(uint16 c)
const override;
366 void processColorMap()
override;
371 class ChineseOneByteFontLoL final :
public ChineseFont {
373 ChineseOneByteFontLoL(
int pitch) :
ChineseFont(pitch, 8, 14, 8, 16, 0, 0) { _pixelColorShading =
false; }
374 void setStyles(
int styles)
override {}
377 bool hasGlyphForCharacter(uint16 c)
const override {
return !(c & 0x80); }
378 uint32 getFontOffset(uint16 c)
const override {
return (c & 0x7F) * 14; }
379 void processColorMap()
override;
382 class ChineseTwoByteFontLoL final :
public ChineseFont {
384 ChineseTwoByteFontLoL(
int pitch) :
ChineseFont(pitch, 16, 14, 16, 16, 0, 0) { _pixelColorShading =
false; }
385 void setStyles(
int styles)
override {}
388 bool hasGlyphForCharacter(uint16 c)
const override {
return (c & 0x80) && getFontOffset(c) < getGlyphDataSize(); }
389 uint32 getFontOffset(uint16 c)
const override;
390 void processColorMap()
override;
399 bool hasGlyphForCharacter(uint16 c)
const override {
return !(c & 0x80); }
400 uint32 getFontOffset(uint16 c)
const override {
return (c & 0x7F) * 14; }
401 void processColorMap()
override;
408 bool hasGlyphForCharacter(uint16 c)
const override {
return (c & 0x80); }
409 uint32 getFontOffset(uint16 c)
const override;
410 void processColorMap()
override;
417 Type
getType()
const override {
return kBIG5; }
427 void setStyles(
int styles)
override;
428 int getHeight()
const override;
429 int getWidth()
const override;
430 int getCharWidth(uint16 c)
const override;
431 int getCharHeight(uint16 c)
const override;
432 void setColorMap(
const uint8 *src)
override;
433 void drawChar(uint16 c, byte *dst,
int pitch,
int)
const override;
450 kVGABytesPerColor = 3,
451 kPC98BytesPerColor = 3,
452 kAmigaBytesPerColor = 2
478 void setCGAPalette(
int palIndex,
CGAIntensity intensity);
507 void fill(
int firstCol,
int numCols, uint8 value);
517 void copy(
const Palette &source,
int firstCol = 0,
int numCols = -1,
int dstStart = -1);
527 void copy(
const uint8 *source,
int firstCol,
int numCols,
int dstStart = -1);
534 uint8 *fetchRealPalette()
const;
537 uint8 &operator[](
const int index) {
538 assert(index >= 0 && index <= _numColors * 3);
539 return _palData[index];
542 const uint8 &operator[](
const int index)
const {
543 assert(index >= 0 && index <= _numColors * 3);
544 return _palData[index];
553 const uint8 *getData()
const {
return _palData; }
557 const int _numColors;
559 static const uint8 _egaColors[];
560 static const int _egaNumColors;
561 static const uint8 _cgaColors[4][12];
562 static const int _cgaNumColors;
570 SCREEN_H_SEGA_NTSC = 224,
571 SCREEN_PAGE_SIZE = 320 * 200 + 1024,
572 SCREEN_OVL_SJIS_SIZE = 640 * 400,
573 SCREEN_PAGE_NUM = 16,
576 SCREEN_IDLEREFRESH_RESTART_MSEC = 250,
577 SCREEN_IDLEREFRESH_RATE_MSEC = 16
580 enum CopyRegionFlags {
584 enum DrawShapeFlags {
585 kDRAWSHP_XFLIP = 0x01,
586 kDRAWSHP_YFLIP = 0x02,
587 kDRAWSHP_SCALE = 0x04,
588 kDRAWSHP_WINREL = 0x10,
589 kDRAWSHP_CENTER = 0x20,
590 kDRAWSHP_FADE = 0x100,
591 kDRAWSHP_PREDATOR = 0x200,
592 kDRAWSHP_COMPACT = 0x400,
593 kDRAWSHP_PRIORITY = 0x800,
594 kDRAWSHP_TRANSPARENT = 0x1000,
595 kDRAWSHP_BCKGRNDFADE = 0x2000,
596 kDRAWSHP_MORPH = 0x4000,
597 kDRAWSHP_COLOR = 0x8000
610 FID_SJIS_TEXTMODE_FNT,
623 virtual void setResolution();
624 virtual void enableHiColorMode(
bool enabled);
628 void updateBackendScreen(
bool force);
630 uint32 _idleUpdateTimer;
633 bool queryScreenDebug()
const {
return _debugEnabled; }
634 bool enableScreenDebug(
bool enable);
637 int setCurPage(
int pageNum);
640 void copyWsaRect(
int x,
int y,
int w,
int h,
int dimState,
int plotFunc,
const uint8 *src,
641 int unk1,
const uint8 *unkPtr1,
const uint8 *unkPtr2);
644 void copyToPage0(
int y,
int h, uint8 page, uint8 *seqBuf);
645 void shakeScreen(
int times);
648 void copyRegion(
int x1,
int y1,
int x2,
int y2,
int w,
int h,
int srcPage,
int dstPage,
int flags=0);
649 void copyPage(uint8 srcPage, uint8 dstPage);
651 void copyRegionToBuffer(
int pageNum,
int x,
int y,
int w,
int h, uint8 *dest);
652 void copyBlockToPage(
int pageNum,
int x,
int y,
int w,
int h,
const uint8 *src);
654 void shuffleScreen(
int sx,
int sy,
int w,
int h,
int srcPage,
int dstPage,
int ticks,
bool transparent);
655 void fillRect(
int x1,
int y1,
int x2,
int y2, uint8 color,
int pageNum = -1,
bool xored =
false);
657 void clearPage(
int pageNum);
659 int getPagePixel(
int pageNum,
int x,
int y);
660 void setPagePixel(
int pageNum,
int x,
int y, uint8 color);
662 const uint8 *getCPagePtr(
int pageNum)
const;
663 uint8 *getPageRect(
int pageNum,
int x,
int y,
int w,
int h);
666 void fadeFromBlack(
int delay=0x54,
const UpdateFunctor *upFunc = 0);
667 void fadeToBlack(
int delay=0x54,
const UpdateFunctor *upFunc = 0);
669 virtual void fadePalette(
const Palette &pal,
int delay,
const UpdateFunctor *upFunc = 0);
670 virtual void getFadeParams(
const Palette &pal,
int delay,
int &delayInc,
int &diff);
671 virtual int fadePalStep(
const Palette &pal,
int diff);
673 void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
674 virtual void setScreenPalette(
const Palette &pal);
679 void transposeScreenOutputY(
int yAdd);
682 bool isInterfacePaletteEnabled()
const {
return _dualPaletteModeSplitY; }
683 void enableDualPaletteMode(
int splitY);
684 void disableDualPaletteMode();
686 virtual void getRealPalette(
int num, uint8 *dst);
688 void copyPalette(
const int dst,
const int src);
691 void drawLine(
bool vertical,
int x,
int y,
int length,
int color);
692 void drawClippedLine(
int x1,
int y1,
int x2,
int y2,
int color);
693 virtual void drawShadedBox(
int x1,
int y1,
int x2,
int y2,
int color1,
int color2);
694 void drawBox(
int x1,
int y1,
int x2,
int y2,
int color);
697 virtual bool loadFont(FontId fontId,
const char *filename);
698 FontId setFont(FontId fontId);
700 int getFontHeight()
const;
701 int getFontWidth()
const;
703 int getCharWidth(uint16 c)
const;
704 int getCharHeight(uint16 c)
const;
705 int getTextWidth(
const char *str,
bool nextWordOnly =
false);
706 int getNumberOfCharacters(
const char *str);
708 void printText(
const char *str,
int x,
int y, uint8 color1, uint8 color2,
int pitch = -1);
710 virtual void setTextColorMap(
const uint8 *cmap) = 0;
711 void setTextColor(
const uint8 *cmap,
int a,
int b);
712 void setTextColor16bit(
const uint16 *cmap16);
713 int setFontStyles(FontId fontId,
int styles);
715 const ScreenDim *getScreenDim(
int dim)
const;
716 void modifyScreenDim(
int dim,
int x,
int y,
int w,
int h);
717 int screenDimTableCount()
const {
return _dimTableCount; }
719 void setScreenDim(
int dim);
720 int curDimIndex()
const {
return _curDimIndex; }
722 void setTextMarginRight(
int x) { _textMarginRight = x; }
723 uint16 _textMarginRight;
724 bool _overdrawMargin;
731 uint8 *encodeShape(
int x,
int y,
int w,
int h,
int flags);
733 int setNewShapeHeight(uint8 *shape,
int height);
734 int resetShapeHeight(uint8 *shape);
736 virtual void drawShape(uint8 pageNum,
const uint8 *shapeData,
int x,
int y,
int sd,
int flags, ...);
741 bool isMouseVisible()
const;
742 virtual void setMouseCursor(
int x,
int y,
const byte *shape);
745 virtual int getRectSize(
int w,
int h) = 0;
747 void rectClip(
int &x,
int &y,
int w,
int h);
750 virtual void loadBitmap(
const char *filename,
int tempPage,
int dstPage,
Palette *pal,
bool skip=
false);
752 virtual bool loadPalette(
const char *filename,
Palette &pal);
753 bool loadPaletteTable(
const char *filename,
int firstPalette);
754 virtual void loadPalette(
const byte *data,
Palette &pal,
int bytes);
756 void setAnimBlockPtr(
int size);
758 void setShapePages(
int page1,
int page2,
int minY = -1,
int maxY = 201);
760 virtual byte getShapeFlag1(
int x,
int y);
761 virtual byte getShapeFlag2(
int x,
int y);
763 virtual int getDrawLayer(
int x,
int y);
764 virtual int getDrawLayer2(
int x,
int y,
int height);
766 void blockInRegion(
int x,
int y,
int width,
int height);
767 void blockOutRegion(
int x,
int y,
int width,
int height);
772 uint8 *_shapePages[2];
773 int _maskMinY, _maskMaxY;
777 static void decodeFrame1(
const uint8 *src, uint8 *dst, uint32 size);
778 static uint16 decodeEGAGetCode(
const uint8 *&pos, uint8 &nib);
780 static void decodeFrame3(
const uint8 *src, uint8 *dst, uint32 size,
bool isAmiga);
781 static uint decodeFrame4(
const uint8 *src, uint8 *dst, uint32 dstSize);
782 static void decodeFrameDelta(uint8 *dst,
const uint8 *src,
bool noXor =
false);
783 static void decodeFrameDeltaPage(uint8 *dst,
const uint8 *src,
const int pitch,
bool noXor);
785 static void convertAmigaGfx(uint8 *data,
int w,
int h,
int depth = 5,
bool wsa =
false,
int bytesPerPlane = -1);
786 static void convertAmigaMsc(uint8 *data);
793 void crossFadeRegion(
int x1,
int y1,
int x2,
int y2,
int w,
int h,
int srcPage,
int dstPage);
795 uint16 *get16bitPalette() {
return _16bitPalette; }
796 void set16bitShadingLevel(
int lvl) { _16bitShadingLevel = lvl; }
799 void resetPagePtrsAndBuffers(
int pageSize);
800 uint8 *getPagePtr(
int pageNum);
801 virtual void updateDirtyRects();
802 void updateDirtyRectsAmiga();
803 void updateDirtyRectsOvl();
805 template<
typename srcType,
typename scaleToType>
void scale2x(uint8 *dst,
int dstPitch,
const uint8 *src,
int srcPitch,
int w,
int h);
806 template<
typename pixelType>
void mergeOverlayImpl(
int x,
int y,
int w,
int h);
807 virtual void mergeOverlay(
int x,
int y,
int w,
int h) {
808 if (_useHiColorScreen)
809 mergeOverlayImpl<uint16>(x, y, w, h);
811 mergeOverlayImpl<uint8>(x, y, w, h);
815 byte *getOverlayPtr(
int pageNum);
816 void clearOverlayPage(
int pageNum);
817 void clearOverlayRect(
int pageNum,
int x,
int y,
int w,
int h);
818 void copyOverlayRegion(
int x,
int y,
int x2,
int y2,
int w,
int h,
int srcPage,
int dstPage);
821 uint16 fetchChar(
const char *&s)
const;
822 void drawChar(uint16 c,
int x,
int y,
int pitch = -1);
824 int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to,
int size);
826 template<
bool noXor>
static void wrapped_decodeFrameDelta(uint8 *dst,
const uint8 *src);
827 template<
bool noXor>
static void wrapped_decodeFrameDeltaPage(uint8 *dst,
const uint8 *src,
const int pitch);
829 uint8 *_pagePtrs[16];
830 const uint8 *_pagePtrsBuff;
831 uint8 *_sjisOverlayPtrs[SCREEN_OVLS_NUM];
832 uint8 _pageMapping[SCREEN_PAGE_NUM];
838 Font *_fonts[FID_NUM];
839 uint8 _textColorsMap[16];
840 uint16 _textColorsMap16bit[2];
842 uint8 *_textRenderBuffer;
843 int _textRenderBufferSize;
846 uint8 _sjisInvisibleColor;
847 bool _sjisMixedFontMode;
850 bool _use16ColorMode;
851 bool _useShapeShading;
852 bool _4bitPixelPacking;
853 bool _useHiResEGADithering;
854 bool _useHiColorScreen;
856 bool _useAmigaExtraColors;
861 const int _screenHeight;
868 uint16 shade16bitColor(uint16 col);
870 uint16 *_16bitPalette;
871 uint16 *_16bitConversionPalette;
872 uint8 _16bitShadingLevel;
874 uint8 *_animBlockPtr;
880 const int _dimTableCount;
885 const uint8 _cursorColorKey;
887 virtual void postProcessCursor(uint8 *data,
int w,
int h,
int pitch) {}
893 bool _forceFullUpdate;
894 bool _paletteChanged;
897 void addDirtyRect(
int x,
int y,
int w,
int h);
903 typedef void (
Screen::*DsPlotFunc)(uint8*, uint8);
904 typedef int (
Screen::*DsMarginSkipFunc)(uint8*&,
const uint8*&,
int&);
905 typedef void (
Screen::*DsLineFunc)(uint8*&,
const uint8*&,
const DsPlotFunc,
int&, int16);
907 int drawShapeMarginNoScaleUpwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
908 int drawShapeMarginNoScaleDownwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
909 int drawShapeMarginScaleUpwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
910 int drawShapeMarginScaleDownwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
911 int drawShapeSkipScaleUpwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
912 int drawShapeSkipScaleDownwind(uint8 *&dst,
const uint8 *&src,
int &cnt);
913 void drawShapeProcessLineNoScaleUpwind(uint8 *&dst,
const uint8 *&src,
const DsPlotFunc plot,
int &cnt, int16);
914 void drawShapeProcessLineNoScaleDownwind(uint8 *&dst,
const uint8 *&src,
const DsPlotFunc plot,
int &cnt, int16);
915 void drawShapeProcessLineScaleUpwind(uint8 *&dst,
const uint8 *&src,
const DsPlotFunc plot,
int &cnt, int16 scaleState);
916 void drawShapeProcessLineScaleDownwind(uint8 *&dst,
const uint8 *&src,
const DsPlotFunc plot,
int &cnt, int16 scaleState);
918 void drawShapePlotType0(uint8 *dst, uint8 cmd);
919 void drawShapePlotType1(uint8 *dst, uint8 cmd);
920 void drawShapePlotType3_7(uint8 *dst, uint8 cmd);
921 void drawShapePlotType4(uint8 *dst, uint8 cmd);
922 void drawShapePlotType5(uint8 *dst, uint8 cmd);
923 void drawShapePlotType6(uint8 *dst, uint8 cmd);
924 void drawShapePlotType8(uint8 *dst, uint8 cmd);
925 void drawShapePlotType9(uint8 *dst, uint8 cmd);
926 void drawShapePlotType11_15(uint8 *dst, uint8 cmd);
927 void drawShapePlotType12(uint8 *dst, uint8 cmd);
928 void drawShapePlotType13(uint8 *dst, uint8 cmd);
929 void drawShapePlotType14(uint8 *dst, uint8 cmd);
930 void drawShapePlotType16(uint8 *dst, uint8 cmd);
931 void drawShapePlotType20(uint8 *dst, uint8 cmd);
932 void drawShapePlotType21(uint8 *dst, uint8 cmd);
933 void drawShapePlotType33(uint8 *dst, uint8 cmd);
934 void drawShapePlotType37(uint8 *dst, uint8 cmd);
935 void drawShapePlotType48(uint8 *dst, uint8 cmd);
936 void drawShapePlotType52(uint8 *dst, uint8 cmd);
938 const uint8 *_dsShapeFadingTable;
939 int _dsShapeFadingLevel;
940 const uint8 *_dsColorTable;
941 const uint8 *_dsTransparencyTable1;
942 const uint8 *_dsTransparencyTable2;
943 const uint8 *_dsBackgroundFadingTable;
947 int _dsOffscreenLeft;
948 int _dsOffscreenRight;
951 int _dsOffscreenScaleVal1;
952 int _dsOffscreenScaleVal2;
959 int _dualPaletteModeSplitY;
void setColorMap(const uint8 *src) override
Definition: screen.h:202
int getNumColors() const
Definition: screen.h:493
uint8 * getData()
Definition: screen.h:552
int getHeight() const override
Definition: screen.h:308
bool load(Common::SeekableReadStream &) override
Definition: screen.h:233
int getHeight() const override
Definition: screen.h:167
bool usesOverlay() const override
Definition: screen.h:230
virtual void setStyles(int styles)
Definition: screen.h:139
Definition: kyra_v1.h:126
Type getType() const override
Definition: screen.h:198
RenderMode
Definition: rendermode.h:48
virtual Type getType() const override
Definition: screen.h:262
Definition: atari-screen.h:60
void setStyles(int style) override
Definition: screen.h:238
virtual bool usesOverlay() const
Definition: screen.h:86
int getHeight() const override
Definition: screen.h:199
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
virtual void set16bitColorMap(const uint16 *src)
Definition: screen.h:123
Definition: formatinfo.h:28
Type getType() const override
Definition: screen.h:166
int getCharHeight(uint16 c) const override
Definition: screen.h:270
void setStyles(int styles) override
Definition: screen.h:266
void setColorMap(const uint8 *src) override
Definition: screen.h:170
Definition: detection.h:27
int getWidth() const override
Definition: screen.h:309
int getWidth() const override
Definition: screen.h:200
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Type getType() const override
Definition: screen.h:231
int getCharWidth(uint16 c) const override
Definition: screen.h:269
Type getType() const override
Definition: screen.h:417
Type getType() const override
Definition: screen.h:307
int getWidth() const override
Definition: screen.h:168
CGAIntensity
Definition: screen.h:473
int getHeight() const override
Definition: screen.h:267
int getWidth() const override
Definition: screen.h:268
virtual int getCharHeight(uint16 c) const
Definition: screen.h:113