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_LOK_H
24 #define KYRA_SCREEN_LOK_H
25 
26 #include "kyra/graphics/screen.h"
27 
28 namespace Kyra {
29 
30 class KyraEngine_LoK;
31 
32 class Screen_LoK : public Screen {
33 public:
34 	Screen_LoK(KyraEngine_LoK *vm, OSystem *system);
35 	~Screen_LoK() override;
36 
37 	bool init() override;
38 
39 	void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip = false) override;
40 
41 	int getRectSize(int w, int h) override;
42 
43 	void setTextColorMap(const uint8 *cmap) override;
44 
45 	void fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime);
46 
47 	void savePageToDisk(const char *file, int page);
48 	void loadPageFromDisk(const char *file, int page);
49 	void queryPageFromDisk(const char *file, int page, uint8 *buffer);
50 	void deletePageFromDisk(int page);
51 
52 	void copyBackgroundBlock(int x, int page, int flag);
53 	void copyBackgroundBlock2(int x);
54 
55 	void addBitBlitRect(int x, int y, int w, int h);
56 	void bitBlitRects();
57 
58 	// AMIGA specific
59 	void setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b);
60 	void postProcessCursor(uint8 *data, int width, int height, int pitch) override;
61 
62 protected:
63 	enum {
64 		kNumBitBlitRects = 10
65 	};
66 
67 	KyraEngine_LoK *_vm;
68 
69 	static const ScreenDim _screenDimTable[];
70 	static const int _screenDimTableCount;
71 
72 	Common::Rect _bitBlitRects[kNumBitBlitRects];
73 	int _bitBlitNum;
74 	uint8 *_unkPtr1, *_unkPtr2;
75 
76 	uint8 *_saveLoadPage[8];
77 	uint8 *_saveLoadPageOvl[8];
78 };
79 
80 class Screen_LoK_16 : public Screen_LoK {
81 public:
82 	Screen_LoK_16(KyraEngine_LoK *vm, OSystem *system);
83 
84 	void setScreenPalette(const Palette &pal) override;
85 
86 	void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0) override;
87 	void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff) override;
88 	int fadePalStep(const Palette &pal, int diff) override;
89 private:
90 	void updateDirtyRectsOvl();
91 
92 	void convertTo16Colors(uint8 *page, int w, int h, int pitch, int keyColor = -1);
postProcessCursor(uint8 * data,int width,int height,int pitch)93 	void postProcessCursor(uint8 *data, int width, int height, int pitch) override {
94 		convertTo16Colors(data, width, height, pitch, _cursorColorKey);
95 	}
96 	void mergeOverlay(int x, int y, int w, int h) override;
97 
98 	void set16ColorPalette(const uint8 *pal);
99 
100 	void paletteMap(uint8 idx, int r, int g, int b);
101 
102 	struct PaletteDither {
103 		uint8 bestMatch;
104 		uint8 invertMatch;
105 	};
106 
107 	PaletteDither _paletteDither[256];
108 
109 	static const uint8 _palette16[48];
110 };
111 
112 } // End of namespace Kyra
113 
114 #endif
115