aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/scenery.h
blob: 9ce1f7ededc084d063ff4b99a64c2782f3e8b057 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 Ivan Dubrov
 * Copyright (C) 2004-2006 The ScummVM project
 *
 * 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.
 *
 * $URL$
 * $Id$
 *
 */
#ifndef GOB_SCENERY_H
#define GOB_SCENERY_H

namespace Gob {

class Scenery {
public:

#if defined(START_PACK_STRUCTS)
#pragma START_PACK_STRUCTS
#endif

	struct PieceDesc {
		int16 left;		//NOTE:
		int16 right;		//These are stored in Little Endian format
		int16 top;		//And should be converted by client code when accessed
		int16 bottom;		//i.e. use FROM_LE_16()
	} GCC_PACK;

	struct StaticPlane {
		int8 pictIndex;
		int8 pieceIndex;
		int8 drawOrder;
		int16 destX;
		int16 destY;
		int8 transp;
	} GCC_PACK;

	struct StaticLayer {
		int16 backResId;
		int16 planeCount;
		StaticPlane *planes;
	} GCC_PACK;

	// Animations

	struct AnimFramePiece {
		byte pictIndex;
		byte pieceIndex;
		int8 destX;
		int8 destY;
		int8 notFinal;
	} GCC_PACK;

	struct AnimLayer {
		int16 unknown0;
		int16 posX;
		int16 posY;
		int16 animDeltaX;
		int16 animDeltaY;
		int8 transp;
		int16 framesCount;
		AnimFramePiece *frames;
	} GCC_PACK;

#if defined(END_PACK_STRUCTS)
#pragma END_PACK_STRUCTS
#endif

	struct Static {
		int16 layersCount;
		StaticLayer *layers;
		PieceDesc **pieces;
		int8 *piecesFromExt;
		Static() : layersCount(0), layers(0), pieces(0),
				   piecesFromExt(0) {}
	};

	struct Animation {
		int16 layersCount;
		AnimLayer *layers;
		PieceDesc **pieces;
		int8 *piecesFromExt;
		Animation() : layersCount(0), layers(0), pieces(0),
			              piecesFromExt(0) {}
	};

	// Global variables

	char _spriteRefs[20];
	int16 _spriteResId[20];

	char _staticPictToSprite[70];
	int16 _staticPictCount[10];
	Static _statics[10];
	int16 _staticResId[10];

	char _animPictToSprite[70];
	int16 _animPictCount[10];
	Animation _animations[10];
	int16 _animResId[10];

	int16 _curStatic;
	int16 _curStaticLayer;

	int16 _toRedrawLeft;
	int16 _toRedrawRight;
	int16 _toRedrawTop;
	int16 _toRedrawBottom;

	int16 _animTop;
	int16 _animLeft;
	int16 _animBottom;
	int16 _animRight;

	int16 *_pCaptureCounter;

	// Functions

	int16 loadStatic(char search);
	void freeStatic(int16 index);
	void renderStatic(int16 scenery, int16 layer);
	void updateStatic(int16 orderFrom);
	int16 loadAnim(char search);
	void freeAnim(int16 animation);
	void interStoreParams(void);

	virtual void updateAnim(int16 layer, int16 frame, int16 animation,
			int16 flags, int16 drawDeltaX, int16 drawDeltaY, char doDraw) = 0;

	Scenery(GobEngine *vm);
	virtual ~Scenery() {};

protected:
	GobEngine *_vm;
};

class Scenery_v1 : public Scenery {
public:
	virtual void updateAnim(int16 layer, int16 frame, int16 animation,
			int16 flags, int16 drawDeltaX, int16 drawDeltaY, char doDraw);

	Scenery_v1(GobEngine *vm);
	virtual ~Scenery_v1() {};
};

class Scenery_v2 : public Scenery_v1 {
public:
	virtual void updateAnim(int16 layer, int16 frame, int16 animation,
			int16 flags, int16 drawDeltaX, int16 drawDeltaY, char doDraw);

	Scenery_v2(GobEngine *vm);
	virtual ~Scenery_v2() {};
};

}				// End of namespace Gob

#endif	/* __SCENERY_H */