aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/decfile.h
blob: f6946b9b79eaa66de8879024541cf68646abcd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef GOB_DECFILE_H
#define GOB_DECFILE_H

#include "common/system.h"

namespace Common {
	class String;
	class SeekableSubReadStreamEndian;
}

namespace Gob {

class GobEngine;
class Surface;
class CMPFile;

/** A DEC file, describing a "decal" (background).
 *
 *  Used in hardcoded "actiony" parts of gob games.
 *  The principle is similar to a Static in Scenery (see scenery.cpp), but
 *  instead of referencing indices in the sprites array, DECs reference sprites
 *  directly by filename.
 */
class DECFile {
public:
	DECFile(GobEngine *vm, const Common::String &fileName,
	        uint16 width, uint16 height, uint8 bpp = 1);
	~DECFile();

	/** Draw the background, including all default layer parts. */
	void draw(Surface &dest) const;

	/** Explicitly draw the backdrop. */
	void drawBackdrop(Surface &dest) const;

	/** Explicitly draw a layer part. */
	void drawLayer(Surface &dest, uint16 layer, uint16 part,
	               uint16 x, uint16 y, int32 transp = -1) const;

private:
	struct Part {
		uint8 layer;
		uint8 part;

		uint16 x;
		uint16 y;
		bool transp;
	};

	typedef Common::Array<CMPFile *> LayerArray;
	typedef Common::Array<Part>      PartArray;

	GobEngine *_vm;

	uint16 _width;
	uint16 _height;
	uint8  _bpp;

	byte _hasPadding;

	CMPFile *_backdrop;

	LayerArray _layers;
	PartArray  _parts;


	void load(Common::SeekableSubReadStreamEndian &dec, const Common::String &fileName);

	void loadBackdrop(Common::SeekableSubReadStreamEndian &dec);

	CMPFile *loadLayer(Common::SeekableSubReadStreamEndian &dec);

	void loadParts(Common::SeekableSubReadStreamEndian &dec);
	void loadPart(Part &part, Common::SeekableSubReadStreamEndian &dec);
};

} // End of namespace Gob

#endif // GOB_DECFILE_H