aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/modules/module2700_sprites.cpp
blob: 8dd2fa3461cb903cd8144b5341b71afcba48dc34 (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
/* 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.
 *
 */

#include "neverhood/modules/module2700_sprites.h"

namespace Neverhood {

static const NRect kScene2710ClipRect = { 0, 0, 626, 480 };

static const uint32 kScene2710StaticSprites[] = {
	0x0D2016C0,
	0
};

static const NRect kScene2711ClipRect = { 0, 0, 521, 480 };

static const uint32 kScene2711FileHashes1[] = {
	0,
	0x100801A1,
	0x201081A0,
	0x006800A4,
	0x40390120,
	0x000001B1,
	0x001000A1,
	0
};

static const uint32 kScene2711FileHashes2[] = {
	0,
	0x40403308,
	0x71403168,
	0x80423928,
	0x224131A8,
	0x50401328,
	0x70423328,
	0
};

static const uint32 kScene2711FileHashes3[] = {
	0,
	0x1088A021,
	0x108120E5,
	0x18A02321,
	0x148221A9,
	0x10082061,
	0x188820E1,
	0
};

static const NRect kScene2724ClipRect = { 0, 141, 640, 480 };

static const uint32 kScene2724StaticSprites[] = {
	0xC20D00A5,
	0
};

static const NRect kScene2725ClipRect = { 0, 0, 640, 413 };

static const uint32 kScene2725StaticSprites[] = {
	0xC20E00A5,
	0
};

static const NPoint kCarShadowOffsets[] = {
	{-63,  3}, {-48, 40}, {-33, 58},
	{  0, 65}, { 40, 53}, { 56, 27},
	{ 63,  0}, {-30, 26}, {  0, 30},
	{ 26, 25}
};

SsCommonTrackShadowBackground::SsCommonTrackShadowBackground(NeverhoodEngine *vm, uint32 fileHash)
	: StaticSprite(vm, 0) {

	loadSprite(fileHash, kSLFDefDrawOffset | kSLFDefPosition, 0);
}

AsCommonCarShadow::AsCommonCarShadow(NeverhoodEngine *vm, AnimatedSprite *asCar, BaseSurface *shadowSurface, uint index)
	: AnimatedSprite(vm, 1100), _asCar(asCar), _index(index), _animFileHash(0) {

	SetUpdateHandler(&AsCommonCarShadow::update);
	createShadowSurface(shadowSurface, 211, 147, 100);
	updateShadow();
}

void AsCommonCarShadow::update() {
	updateShadow();
	AnimatedSprite::update();
}

void AsCommonCarShadow::updateShadow() {
	if (_asCar->getFrameIndex() != _currFrameIndex || _asCar->getCurrAnimFileHash() != _animFileHash) {
		uint32 fileHash = _asCar->getCurrAnimFileHash();
		if (fileHash == 0x35698F78 || fileHash == 0x192ADD30 || fileHash == 0x9C220DA4 ||
			fileHash == 0x9966B138 || fileHash == 0xB579A77C || fileHash == 0xA86A9538 ||
			fileHash == 0xD4220027 || fileHash == 0xD00A1364 || fileHash == 0xD4AA03A4 ||
			fileHash == 0xF46A0324) {
			startAnimation(fileHash, _asCar->getFrameIndex(), -1);
			_newStickFrameIndex = _asCar->getFrameIndex();
		}
		_animFileHash = fileHash;
	}
	_x = _asCar->getX() + kCarShadowOffsets[_index].x;
	_y = _asCar->getY() + kCarShadowOffsets[_index].y;
	if (!_asCar->getVisible()) {
		startAnimation(0x1209E09F, 0, -1);
		_newStickFrameIndex = 0;
	}
	setDoDeltaX(_asCar->isDoDeltaX() ? 1 : 0);
}

AsCommonCarConnectorShadow::AsCommonCarConnectorShadow(NeverhoodEngine *vm, Sprite *asCar, BaseSurface *shadowSurface, uint index)
	: AnimatedSprite(vm, 1100), _asCar(asCar), _index(index) {

	SetUpdateHandler(&AsCommonCarConnectorShadow::update);
	createShadowSurface1(shadowSurface, 0x60281C10, 150);
	startAnimation(0x60281C10, -1, -1);
	_newStickFrameIndex = STICK_LAST_FRAME;
}

void AsCommonCarConnectorShadow::update() {
	_x = _asCar->getX() + kCarShadowOffsets[_index].x;
	_y = _asCar->getY() + kCarShadowOffsets[_index].y;
	AnimatedSprite::update();
}

AsCommonCarTrackShadow::AsCommonCarTrackShadow(NeverhoodEngine *vm, Sprite *asCar, BaseSurface *shadowSurface, int16 frameIndex)
	: AnimatedSprite(vm, 1100), _asCar(asCar) {

	SetUpdateHandler(&AsCommonCarTrackShadow::update);
	createShadowSurface1(shadowSurface, 0x0759129C, 100);
	startAnimation(0x0759129C, frameIndex, -1);
	_newStickFrameIndex = frameIndex;
}

void AsCommonCarTrackShadow::update() {
	_x = _asCar->getX();
	_y = _asCar->getY();
	AnimatedSprite::update();
}

KmScene2732::KmScene2732(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 y)
	: Klaymen(vm, parentScene, x, y) {

	// Empty
}

uint32 KmScene2732::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4804:
		GotoState(&Klaymen::stPeekInside);
		break;
	case 0x483C:
		GotoState(&Klaymen::stPeekInsideReturn);
		break;
	}
	return 0;
}

} // End of namespace Neverhood