aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/module2300.cpp
blob: 60f8134929a7c88f507ed26e4177259b4d17b523 (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
/* 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/module2300.h"

namespace Neverhood {

Module2300::Module2300(NeverhoodEngine *vm, Module *parentModule, int which)
	: Module(vm, parentModule), _volume(0) {
	
	debug("Create Module2300(%d)", which);

	// TODO Sound1ChList_addSoundResources(0x1A214010, dword_4B6938, true);
	// TODO Sound1ChList_setSoundValuesMulti(dword_4B6938, true, 50, 600, 10, 10, 150);

	_flag = getGlobalVar(0x10938830) == 0;
	
	if (_flag) {
		// TODO Sound1ChList_setVolume(0x90F0D1C3, 0);
		// TODO Sound1ChList_playLooping(0x90F0D1C3);
	} else {
		// TODO Sound1ChList_setSoundValues(0x90F0D1C3, false, 0, 0, 0, 0);
	}

	// TODO Sound1ChList_sub_407C70(0x1A214010, 0x48498E46, 0x50399F64, 0);
	// TODO Sound1ChList_sub_407C70(0x1A214010, 0x41861371, 0x43A2507F, 0);

	if (which < 0) {
		switch (_vm->gameState().sceneNum) {
		case 0:
			createScene2301(-1);
			break;
		case 1:
			createScene2302(-1);
			break;
		case 2:
			createScene2303(-1);
			break;
		case 3:
			createScene2304(-1);
			break;
		case 4:
			createScene2305(-1);
			break;
		}
	} else if (which == 1) {
		createScene2303(0);
	} else if (which == 2) {
		createScene2304(0);
	} else if (which == 3) {
		createScene2305(-1);
	} else if (which == 4) {
		createScene2302(3);
	} else {
		createScene2301(1);
	}

}

Module2300::~Module2300() {
	// TODO Sound1ChList_sub_407A50(0x1A214010);
}

void Module2300::createScene2301(int which) {
	_vm->gameState().sceneNum = 0;
	createNavigationScene(0x004B67B8, which);
	SetUpdateHandler(&Module2300::updateScene2301);
}
			
void Module2300::createScene2302(int which) {
	_vm->gameState().sceneNum = 1;
	createNavigationScene(0x004B67E8, which);
	SetUpdateHandler(&Module2300::updateScene2302);
	if (_flag) {
		_volume = 15;
		// TODO Sound1ChList_setVolume(0x90F0D1C3, 15);
	}
}

void Module2300::createScene2303(int which) {
	_vm->gameState().sceneNum = 2;
	createNavigationScene(0x004B6878, which);
	SetUpdateHandler(&Module2300::updateScene2303);
}

void Module2300::createScene2304(int which) {
	_vm->gameState().sceneNum = 3;
	if (getGlobalVar(0x10938830)) {
		createNavigationScene(0x004B68F0, which);
	} else {
		// TODO Sound1ChList_setVolume(0x90F0D1C3, _volume);
		createNavigationScene(0x004B68A8, which);
		if (_flag) {
			_volume = 87;
			// TODO Sound1ChList_setVolume(0x90F0D1C3, 87);
		}
	}
	SetUpdateHandler(&Module2300::updateScene2304);
}

void Module2300::createScene2305(int which) {
	_vm->gameState().sceneNum = 4;
	// TODO Sound1ChList_sub_4080B0(true);
	createSmackerScene(0x20080A0B, true, true, false);
	SetUpdateHandler(&Module2300::updateScene2305);
}

void Module2300::updateScene2301() {
	if (!updateChild()) {
		if (_field20 == 1) {
			createScene2302(4);
			_childObject->handleUpdate();
		} else {
			sendMessage(_parentModule, 0x1009, 0);
		}
	}
}

void Module2300::updateScene2302() {
	if (!updateChild()) {
		if (_field20 == 1) {
			createScene2301(0);
			_childObject->handleUpdate();
		} else if (_field20 == 2) {
			createScene2303(1);
			_childObject->handleUpdate();
		} else if (_field20 == 3) {
			createScene2302(3);
			_childObject->handleUpdate();
		} else if (_field20 == 4) {
			createScene2304(1);
			_childObject->handleUpdate();
		} else if (_field20 == 5) {
			sendMessage(_parentModule, 0x1009, 3);
		} else {
			sendMessage(_parentModule, 0x1009, 4);
		}
	} else {
#if 0 // TODO
		NavigationScene *navigationScene = (NavigationScene*)_childObject; 
		if (_flag && navigationScene->getSoundFlag1() && navigationScene->getNavigationIndex() == 4 && 
			navigationScene->getSmackerPlayer() && navigationScene->getSmackerPlayer()->getFrameNumber() % 2) {
			_volume++;
			Sound1ChList_setVolume(0x90F0D1C3, _volume);
		}
#endif
#if 0 // TODO
		if (navigationScene->getSoundFlag1() && navigationScene->getNavigationIndex() == 0 && 
			navigationScene->getSmackerPlayer() && navigationScene->getSmackerPlayer()->getFrameNumber() == 50) {
			Sound1ChList_sub_407C70(0x1A214010, 0x48498E46, 0x50399F64);
			Sound1ChList_setVolume(0x48498E46, 70);
			Sound1ChList_setVolume(0x50399F64, 70);
		}
#endif
	}
}
			
void Module2300::updateScene2303() {
	if (!updateChild()) {
		if (_field20 == 1) {
			sendMessage(_parentModule, 0x1009, 3);
		} else {
			createScene2302(5);
			_childObject->handleUpdate();
		}
	}
}
			
void Module2300::updateScene2304() {
	if (!updateChild()) {
		if (_field20 == 1) {
			sendMessage(_parentModule, 0x1009, 2);
		} else {
			createScene2302(1);
			_childObject->handleUpdate();
		}
	} else {
#if 0 // TODO
		NavigationScene *navigationScene = (NavigationScene*)_childObject; 
		if (_flag && navigationScene->getSoundFlag1() && navigationScene->getSmackerPlayer() && 
			navigationScene->getSmackerPlayer()->getFrameNumber() % 2) {
			_volume--;
			Sound1ChList_setVolume(0x90F0D1C3, _volume);
		}
#endif
	}
}
			
void Module2300::updateScene2305() {
	if (!updateChild()) {
		// TODO Sound1ChList_sub_4080B0(false);
		createScene2302(2);
		_childObject->handleUpdate();
	}
}
			
} // End of namespace Neverhood