aboutsummaryrefslogtreecommitdiff
path: root/engines/prince/hero.h
blob: d2ad0d9c95dca40e515f9b5417a61caec5995c56 (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* 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 PRINCE_HERO_H
#define PRINCE_HERO_H

#include "common/scummsys.h"
#include "common/array.h"
#include "common/memstream.h"

#include "graphics/surface.h"
#include "graphics/primitives.h"

namespace Prince {

class Animation;
class PrinceEngine;
class GraphicsMan;
struct InventoryItem;

class Hero {
public:
	static const int16 kMaxPicWidth = 1280;
	static const int16 kMaxPicHeight = 480;
	static const uint32 kMoveSetSize = 26;
	static const int16 kZoomStep = 4;
	static const int32 kZoomBitmapLen = kMaxPicHeight / kZoomStep * kMaxPicWidth / kZoomStep;
	static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
	static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
	static const int16 kShadowLineArraySize = 2 * 1280 * 4;
	static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
	static const int16 kScreenWidth = 640;
	static const int16 kStepLeftRight = 8;
	static const int16 kStepUpDown = 4;

	enum State {
		kHeroStateStay,
		kHeroStateTurn,
		kHeroStateMove,
		kHeroStateBore,
		kHeroStateSpec,
		kHeroStateTalk,
		kHeroStateMvan,
		kHeroStateTran,
		kHeroStateRun,
		kHeroStateDelayMove
	};

	enum Direction {
		kHeroDirLeft = 1,
		kHeroDirRight = 2,
		kHeroDirUp = 3,
		kHeroDirDown = 4
	};

	enum MoveSet {
		kMove_SL,
		kMove_SR,
		kMove_SU,
		kMove_SD,
		kMove_ML,
		kMove_MR,
		kMove_MU,
		kMove_MD,
		kMove_TL,
		kMove_TR,
		kMove_TU,
		kMove_TD,
		kMove_MLU,
		kMove_MLD,
		kMove_MLR,
		kMove_MRU,
		kMove_MRD,
		kMove_MRL,
		kMove_MUL,
		kMove_MUR,
		kMove_MUD,
		kMove_MDL,
		kMove_MDR,
		kMove_MDU,
		kMove_BORED1,
		kMove_BORED2
	};

	// Used instead of offset in getData
	enum AttrId {
		kHeroLastDir = 26,
		kHeroAnimSet = 120
	};

	uint16 getData(AttrId dataId);

	Hero(PrinceEngine *vm, GraphicsMan *graph);
	~Hero();
	bool loadAnimSet(uint32 heroAnimNumber);

	Graphics::Surface *getSurface();

	void setPos(int16 x, int16 y) { _middleX = x; _middleY = y; }
	void setVisible(bool flag) { _visible = flag; }

	void showHero();
	void heroStanding();
	void heroMoveGotIt(int x, int y, int dir);
	int rotateHero(int oldDirection, int newDirection);
	void scrollHero();
	void setScale(int8 zoomBitmapValue);
	int getScaledValue(int size);
	void selectZoom();
	void countDrawPosition();
	Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame);
	void line(int x1, int y1, int x2, int y2);
	void plotPoint(int x, int y);
	void showHeroShadow(Graphics::Surface *heroFrame);
	void setShadowScale(int32 shadowScale);
	void freeOldMove();
	void freeHeroAnim();

//private:
	PrinceEngine *_vm;
	GraphicsMan *_graph;
	
	uint16 _number;
	uint16 _visible;
	int16 _state;
	int16 _middleX; // middle of X
	int16 _middleY; // lower part of hero
	int16 _moveSetType;
	
	int8 _zoomFactor;
	int16 _scaleValue;
	int16 _frameXSize;
	int16 _frameYSize;
	int16 _scaledFrameXSize;
	int16 _scaledFrameYSize;
	int16 _drawX;
	int16 _drawY;
	int16 _drawZ;
	
	int16 _lightX; // for hero's shadow
	int16 _lightY;
	int32 _shadZoomFactor;
	int32 _shadScaleValue;
	int32 _shadLineLen;
	int16 _shadDrawX;
	int16 _shadDrawY;

	byte *_coords; // array of coordinates
	byte *_dirTab; // array of directions
	byte *_currCoords; // current coordinations
	byte *_currDirTab; // current direction
	int16 _lastDirection; // previous move direction
	int16 _destDirection;
	int16 _leftRightMainDir; // left or right - dominant direction
	int16 _upDownMainDir; // up or down - dominant direction
	int32 _phase; // Phase animation phase
	int16 _step; // Step x/y step size depends on direction
	int16 _maxBoredom; // stand still timeout
	int16 _boredomTime; // Boredom current boredom time in frames
	uint16 _boreNum; // Bore anim frame
	int16 _talkTime; // TalkTime time of talk anim
	Animation *_specAnim; // additional anim

	uint16 _currHeight; // height of current anim phase

	Common::Array<int> _inventory; // Inventory array of items
	Common::Array<int> _inventory2; // Inventory2 array of items
	// Font subtitiles font
	int _color; // Color Subtitles color
	// AnimSet number of animation set
	Common::Array<Animation *> _moveSet; // MoveAnims MoveSet
	int16 _turnAnim;
	byte *_zoomBitmap;
	byte *_shadowBitmap;
	byte *_shadowLine;
	
	uint32 _moveDelay;
	uint32 _shadMinus;
};

}

#endif

/* vim: set tabstop=4 noexpandtab: */