File: room495.cpp

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (286 lines) | stat: -rw-r--r-- 5,899 bytes parent folder | download | duplicates (2)
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* 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 3 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, see <http://www.gnu.org/licenses/ },.
 *
 */

#include "m4/riddle/rooms/section4/room495.h"
#include "m4/graphics/gr_series.h"
#include "m4/riddle/vars.h"

namespace M4 {
namespace Riddle {
namespace Rooms {

void Room495::preload() {
	_G(player).walker_in_this_scene = false;
}

void Room495::init() {
	updateFlags1();
	updateFlags2();
	interface_hide();
	player_set_commands_allowed(false);
	digi_preload("950_s46");

	_G(player).disable_hyperwalk = true;
	_G(player).walker_in_this_scene = false;
	_val1 = 255;

	series_show("495 peiping", 0xf00);
	series_show("495 new york", 0xf00);

	if (_G(flags)[V056])
		series_show("495 danzig", 0xf00);
	if (_G(flags)[V110]) {
		series_show("495 sikkim", 0xf00);
		series_show("495 lima", 0xf00);
	}

	if (player_been_here(501))
		series_show("495 easter island", 0xf00);
	digi_play("950_s46", 3);

	switch (_G(game).previous_room) {
	case 201:
		_G(flags)[V092] = 1;

		switch (_G(flags)[kTravelDest]) {
		case 1:
			play("495 peiping to ny", "495pg03s", 93, 3);
			break;
		case 2:
			play("495 peiping to danzig", "495pg02s", 38, 7);
			break;
		case 3:
			play("495 peiping to sikkim", "495pg01s", 17, 14);
			break;
		case 4:
			play("495 peiping to lima", "495pg04s", 11, 3);
			break;
		default:
			break;
		}
		break;

	case 301:
		switch (_G(flags)[kTravelDest]) {
		case 0:
			play("495 ny to peiping", "495ny03s", 108, 3);
			break;
		case 2:
			play("495 ny to danzig", "495ny02s", 47, 4);
			break;
		case 3:
			play("495 ny to sikkim", "495ny04s", 96, 3);
			break;
		case 4:
			play("495 ny to lima", "495ny01s", 28, 5);
			break;
		default:
			break;
		}
		break;

	case 401:
		switch (_G(flags)[kTravelDest]) {
		case 0:
			play("495 danzig to peiping", "495dg04s", 51, 4);
			break;
		case 1:
			play("495 danzig to ny", "495dg02s", 43, 4);
			break;
		case 3:
			play("495 danzig to sikkim", "495dg03s", 38, 4);
			break;
		case 4:
			play("495 danzig to lima", "495dg01s", 65, 4);
			break;
		default:
			break;
		}
		break;

	case 501:
		switch (_G(flags)[kTravelDest]) {
		case 0:
			play("495 lima to peiping", "495lm05s", 115, 3);
			break;
		case 1:
			play("495 lima to ny", "495lm02s", 18, 10);
			break;
		case 2:
			play("495 lima to danzig", "495m03s", 70, 4);
			break;
		case 3:
			play("495 lima to sikkim", "495lm04s", 100, 3);
			break;
		case 5:
			play("495 lima to easter isle", "495lm01s", 16, 12);
			break;
		default:
			break;
		}
		break;

	case 603:
	case 615:
		if (_G(flags)[kTravelDest] == 4)
			play("495 easter isle to lima", "495eis", 16, 12);
		break;

	case 701:
		switch (_G(flags)[kTravelDest]) {
		case 0:
			play("495 sikkim to peiping", "495sm02s", 17, 10);
			break;
		case 1:
			play("495 sikkim to ny", "495sm04s", 93, 3);
			break;
		case 2:
			play("495 sikkim to danzig", "495sm03s", 38, 5);
			break;
		case 4:
			play("495 sikkim to lima", "495sm01s", 100, 3);
			break;
		default:
			break;
		}
		break;

	default:
		break;
	}
}

void Room495::daemon() {
	switch (_G(kernel).trigger) {
	case 500:
		kernel_timing_trigger(1, 502);
		disable_player_commands_and_fade_init(-1);

		series_play(_seriesName1, 0, 16, -1, 5, 0, 100, 0, 0,
			_lastFrame + 1, -1);
		series_play(_seriesName2, 0xf00, 16, -1, 5, 0, 100, 0, 0,
			_lastFrame + 1, -1);
		break;

	case 501:
		interface_show();

		switch (_G(flags)[kTravelDest]) {
		case 0:
			_G(flags)[V092] = 0;
			_G(game).setRoom(201);
			break;
		case 1:
			_G(game).setRoom(301);
			break;
		case 2:
			_G(flags)[V092] = 0;
			_G(game).setRoom(401);
			break;
		case 3:
			_G(flags)[V092] = 0;
			_G(game).setRoom(701);
			break;
		case 4:
			_G(flags)[V092] = 0;
			_G(game).setRoom(501);
			break;
		case 5:
			_G(flags)[V092] = 0;
			_G(game).setRoom(603);
			break;
		case 6:
			_G(flags)[V092] = 0;
			_G(game).setRoom(504);
			break;
		default:
			break;
		}
		break;

	case 502:
		_val1 -= 5;
		digi_change_panning(3, _val1);
		kernel_timing_trigger(1, 502);

		if (_val1 <= 0) {
			digi_stop(3);
			kernel_timing_trigger(1, 501);
		}
		break;

	default:
		break;
	}
}

void Room495::pre_parser() {
	_G(player).resetWalk();
}

void Room495::updateFlags1() {
	int numPlaced = getNumKeyItemsPlaced();

	if (numPlaced < 3)
		_G(flags)[V088] = 1;
	else if (numPlaced < 6)
		_G(flags)[V088] = 3;
	else if (numPlaced < 9)
		_G(flags)[V088] = 4;
	else
		_G(flags)[V088] = 5;
}

void Room495::updateFlags2() {
	if (_G(flags)[V045]) {
		_G(flags)[V045] = 0;
		if (++_G(flags)[V090] > 3)
			_G(flags)[V090] = 3;

		switch (_G(flags)[V090]) {
		case 1:
			_G(flags)[V367] = 1;
			break;
		case 2:
			_G(flags)[V368] = 1;
			break;
		case 3:
			_G(flags)[V369] = 1;
			break;
		default:
			break;
		}
	}
}

void Room495::play(const char *seriesName1, const char *seriesName2,
		int lastFrame, int frameRate) {
	_lastFrame = lastFrame;
	_seriesName1 = seriesName1;
	_seriesName2 = seriesName2;

	series_play(_seriesName1, 0, 0, 500, frameRate, 0, 100, 0, 0, 0, lastFrame);
	series_play(_seriesName2, 0xf00, 0, -1, frameRate, 0, 100, 0, 0, 0, lastFrame);
}

} // namespace Rooms
} // namespace Riddle
} // namespace M4