aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/modules/module2600.cpp
blob: ff4ed24f631b40fc911dc206d7364afd73cb521c (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/* 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/module2600.h"
#include "neverhood/modules/module2600_sprites.h"

namespace Neverhood {

static const uint32 kModule2600SoundList[] = {
	0xB288D450,
	0x90804450,
	0x99801500,
	0xB288D455,
	0x93825040,
	0
};

Module2600::Module2600(NeverhoodEngine *vm, Module *parentModule, int which)
	: Module(vm, parentModule) {

	if (which < 0)
		createScene(_vm->gameState().sceneNum, -1);
	else if (which == 1)
		createScene(4, 1);
	else
		createScene(0, 1);

	_vm->_soundMan->addSoundList(0x40271018, kModule2600SoundList);
	_vm->_soundMan->setSoundListParams(kModule2600SoundList, true, 50, 600, 5, 150);
	_vm->_soundMan->playTwoSounds(0x40271018, 0x41861371, 0x43A2507F, 0);

}

Module2600::~Module2600() {
	_vm->_soundMan->deleteGroup(0x40271018);
}

void Module2600::createScene(int sceneNum, int which) {
	debug(1, "Module2600::createScene(%d, %d)", sceneNum, which);
	_sceneNum = sceneNum;
	switch (_sceneNum) {
	case 0:
		_vm->gameState().sceneNum = 0;
		createNavigationScene(0x004B8608, which);
		break;
	case 1:
		_vm->gameState().sceneNum = 1;
		createNavigationScene(0x004B8638, which);
		break;
	case 2:
		_vm->gameState().sceneNum = 2;
		createNavigationScene(0x004B86C8, which);
		break;
	case 3:
		_vm->gameState().sceneNum = 3;
		if (getGlobalVar(V_CREATURE_ANGRY))
			createNavigationScene(0x004B8758, which);
		else
			createNavigationScene(0x004B86F8, which);
		break;
	case 4:
		_vm->gameState().sceneNum = 4;
		createNavigationScene(0x004B87B8, which);
		break;
	case 6:
		_vm->gameState().sceneNum = 6;
		createNavigationScene(0x004B8698, which);
		break;
	case 7:
		_vm->gameState().sceneNum = 7;
		_vm->_soundMan->deleteGroup(0x40271018);
		createSmackerScene(0x30090001, true, true, false);
		break;
	case 8:
		_vm->gameState().sceneNum = 8;
		_childObject = new Scene2609(_vm, this, which);
		break;
	case 1002:
		_vm->gameState().sceneNum = 2;
		if (getGlobalVar(V_FRUIT_COUNTING_INDEX) == 1)
			createSmackerScene(0x018C0404, true, true, false);
		else if (getGlobalVar(V_FRUIT_COUNTING_INDEX) == 2)
			createSmackerScene(0x018C0407, true, true, false);
		else
			createSmackerScene(0x818C0405, true, true, false);
		if (getGlobalVar(V_FRUIT_COUNTING_INDEX) >= 2)
			setGlobalVar(V_FRUIT_COUNTING_INDEX, 0);
		else
			incGlobalVar(V_FRUIT_COUNTING_INDEX, +1);
		break;
	case 1003:
		_vm->gameState().sceneNum = 3;
		createSmackerScene(0x001C0007, true, true, false);
		break;
	case 1006:
		_vm->gameState().sceneNum = 6;
		if (getGlobalVar(V_WATER_RUNNING))
			createSmackerScene(0x049A1181, true, true, false);
		else
			createSmackerScene(0x04981181, true, true, false);
		break;
	case 1008:
		_vm->gameState().sceneNum = 8;
		if (getGlobalVar(V_WATER_RUNNING))
			createSmackerScene(0x42B80941, true, true, false);
		else
			createSmackerScene(0x42980941, true, true, false);
		break;
	case 9999:
		createDemoScene();
		break;
	default:
		break;
	}
	SetUpdateHandler(&Module2600::updateScene);
	_childObject->handleUpdate();
}

void Module2600::updateScene() {
	if (!updateChild()) {
		switch (_sceneNum) {
		case 0:
			if (_moduleResult == 1)
				createScene(1, 3);
			else
				leaveModule(0);
			break;
		case 1:
			if (_moduleResult == 0)
				createScene(6, 0);
			else if (_moduleResult == 1)
				createScene(0, 0);
			else if (_moduleResult == 2)
				createScene(2, 1);
			else if (_moduleResult == 3)
				createScene(3, 0);
			break;
		case 2:
			if (_moduleResult == 0)
				createScene(1, 0);
			else if (_moduleResult == 1) {
				if (_vm->isDemo())
					createScene(9999, -1);
				else
					createScene(1002, -1);
			}
			break;
		case 3:
			if (_moduleResult == 0) {
				if (getGlobalVar(V_CREATURE_ANGRY))
					createScene(4, 0);
				else
					createScene(1003, -1);
			} else if (_moduleResult == 2)
				createScene(1, 1);
			else if (_moduleResult == 3) {
				if (getGlobalVar(V_CREATURE_ANGRY))
					createScene(4, 0);
				else {
					setGlobalVar(V_CREATURE_ANGRY, 1);
					createScene(7, -1);
				}
			}
			break;
		case 4:
			if (_moduleResult == 0)
				leaveModule(1);
			else
				createScene(3, 1);
			break;
		case 6:
			if (_moduleResult == 0) {
				if (_vm->isDemo())
					createScene(9999, -1);
				else
					createScene(1006, -1);
			}
			else if (_moduleResult == 1)
				createScene(1, 2);
			break;
		case 7:
			leaveModule(0);
			break;
		case 8:
			createScene(1008, -1);
			break;
		case 1002:
			createScene(2, 1);
			break;
		case 1003:
			createScene(3, 0);
			break;
		case 1006:
			createScene(8, -1);
			break;
		case 1008:
			createScene(6, 0);
			break;
		case 9999:
			createScene(_vm->gameState().sceneNum, -1);
			break;
		default:
			break;
		}
	}
}

Scene2609::Scene2609(NeverhoodEngine *vm, Module *parentModule, int which)
	: Scene(vm, parentModule), _isBusy(false) {

	SetUpdateHandler(&Scene::update);
	SetMessageHandler(&Scene2609::handleMessage);

	setBackground(0x51409A16);
	setPalette(0x51409A16);
	_asWater = insertSprite<AsScene2609Water>();
	_ssButton = insertSprite<SsScene2609Button>(this);
	addCollisionSprite(_ssButton);
	insertPuzzleMouse(0x09A1251C, 20, 620);
	insertStaticSprite(0x02138002, 1200);
	insertStaticSprite(0x825E2827, 1200);
}

uint32 Scene2609::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
	Scene::handleMessage(messageNum, param, sender);
	switch (messageNum) {
	case NM_MOUSE_CLICK:
		if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !_isBusy)
			leaveScene(0);
		break;
	case NM_ANIMATION_UPDATE:
		_isBusy = true;
		break;
	case 0x2001:
		_isBusy = false;
		sendMessage(_asWater, 0x2001, 0);
		break;
	case NM_POSITION_CHANGE:
		_isBusy = false;
		sendMessage(_asWater, NM_POSITION_CHANGE, 0);
		break;
	default:
		break;
	}
	return 0;
}

} // End of namespace Neverhood