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 DS_BACKGROUND_H
24 #define DS_BACKGROUND_H
25 
26 #include "graphics/surface.h"
27 #include "common/rect.h"
28 
29 namespace DS {
30 
31 class Background : public Graphics::Surface {
32 public:
33 	Background();
34 
35 	size_t getRequiredVRAM(uint16 width, uint16 height, bool isRGB, bool swScale);
36 	void create(uint16 width, uint16 height, bool isRGB);
37 	void create(uint16 width, uint16 height, bool isRGB, int layer, bool isSub, int mapBase, bool swScale);
38 	void init(Background *surface);
39 	void init(Background *surface, int layer, bool isSub, int mapBase, bool swScale);
40 
41 	void update();
42 	void reset();
43 
44 	void show();
45 	void hide();
isVisible()46 	inline bool isVisible() const { return _visible; }
47 
48 	void setScalef(int32 sx, int32 sy);
setScale(int sx,int sy)49 	inline void setScale(int sx, int sy) { setScalef(sx << 8, sy << 8); }
50 	void setScrollf(int32 x, int32 y);
setScroll(int x,int y)51 	inline void setScroll(int x, int y) { setScrollf(x << 8, y << 8); }
52 
53 	Common::Point realToScaled(int16 x, int16 y);
54 	Common::Point scaledToReal(int16 x, int16 y);
55 
clear()56 	inline void clear() {
57 		memset(getPixels(), 0, pitch * h);
58 	}
59 
grab(byte * dst,int dstPitch)60 	inline void grab(byte *dst, int dstPitch) {
61 		for (int y = 0; y < h; ++y) {
62 			memcpy(dst, getBasePtr(0, y), w * format.bytesPerPixel);
63 			dst += dstPitch;
64 		}
65 	}
66 
67 protected:
68 	int _bg;
69 	bool _visible, _swScale;
70 	uint16 _realPitch, _realHeight;
71 	const Graphics::PixelFormat _pfCLUT8, _pfABGR1555;
72 	int32 _scrollX, _scrollY, _scaleX, _scaleY;
73 };
74 
75 } // End of namespace DS
76 
77 #endif // #ifndef DS_BACKGROUND_H
78