aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_stacks/aspit.cpp
blob: a31aa902ec3cf7fa97e4be7829d2307f5a3b913a (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/* 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 "mohawk/riven_stacks/aspit.h"

#include "mohawk/riven.h"
#include "mohawk/riven_card.h"
#include "mohawk/riven_graphics.h"
#include "mohawk/riven_inventory.h"
#include "mohawk/riven_sound.h"
#include "mohawk/riven_video.h"

#include "common/translation.h"

#include "gui/message.h"

namespace Mohawk {
namespace RivenStacks {

ASpit::ASpit(MohawkEngine_Riven *vm) :
		RivenStack(vm, kStackAspit) {

	REGISTER_COMMAND(ASpit, xastartupbtnhide);
	REGISTER_COMMAND(ASpit, xasetupcomplete);
	REGISTER_COMMAND(ASpit, xaatrusopenbook);
	REGISTER_COMMAND(ASpit, xaatrusbookback);
	REGISTER_COMMAND(ASpit, xaatrusbookprevpage);
	REGISTER_COMMAND(ASpit, xaatrusbooknextpage);
	REGISTER_COMMAND(ASpit, xacathopenbook);
	REGISTER_COMMAND(ASpit, xacathbookback);
	REGISTER_COMMAND(ASpit, xacathbookprevpage);
	REGISTER_COMMAND(ASpit, xacathbooknextpage);
	REGISTER_COMMAND(ASpit, xtrapbookback);
	REGISTER_COMMAND(ASpit, xatrapbookclose);
	REGISTER_COMMAND(ASpit, xatrapbookopen);
	REGISTER_COMMAND(ASpit, xarestoregame);
	REGISTER_COMMAND(ASpit, xadisablemenureturn);
	REGISTER_COMMAND(ASpit, xaenablemenureturn);
	REGISTER_COMMAND(ASpit, xalaunchbrowser);
	REGISTER_COMMAND(ASpit, xadisablemenuintro);
	REGISTER_COMMAND(ASpit, xaenablemenuintro);
	REGISTER_COMMAND(ASpit, xademoquit);
	REGISTER_COMMAND(ASpit, xaexittomain);
}

void ASpit::xastartupbtnhide(const ArgumentArray &args) {
	// The original game hides the start/setup buttons depending on an ini entry.
	// It's safe to ignore this command.
}

void ASpit::xasetupcomplete(const ArgumentArray &args) {
	// The original game sets an ini entry to disable the setup button and use the
	// start button only. It's safe to ignore this part of the command.
	uint16 menuCardId = getCardStackId(0xE2E);
	RivenScriptPtr goToMenuScript = _vm->_scriptMan->createScriptFromData(1, kRivenCommandChangeCard, 1, menuCardId);
	_vm->_scriptMan->runScript(goToMenuScript, false);
}

void ASpit::xaatrusopenbook(const ArgumentArray &args) {
	// Get the variable
	uint32 &page = _vm->_vars["aatrusbook"];

	// Set hotspots depending on the page
	RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook");
	RivenHotspot *nextPage = _vm->getCard()->getHotspotByName("nextpage");
	RivenHotspot *prevPage = _vm->getCard()->getHotspotByName("prevpage");
	if (page == 1) {
		prevPage->enable(false);
		nextPage->enable(false);
		openBook->enable(true);
	} else {
		prevPage->enable(true);
		nextPage->enable(true);
		openBook->enable(false);
	}

	// Draw the image of the page
	_vm->getCard()->drawPicture(page);
}

void ASpit::xaatrusbookback(const ArgumentArray &args) {
	_vm->_inventory->backFromItemScript();
}

void ASpit::xaatrusbookprevpage(const ArgumentArray &args) {
	// Get the page variable
	uint32 &page = _vm->_vars["aatrusbook"];

	// Keep turning pages while the mouse is pressed
	bool firstPageTurn = true;
	while (mouseIsDown() || firstPageTurn) {
		// Check for the first page
		if (page == 1)
			return;

		if (!pageTurn(kRivenTransitionWipeRight)) {
			return;
		}

		// Update the page number
		page--;
		firstPageTurn = false;

		_vm->getCard()->drawPicture(page);
		_vm->doFrame();
	}
}

void ASpit::xaatrusbooknextpage(const ArgumentArray &args) {
	// Get the page variable
	uint32 &page = _vm->_vars["aatrusbook"];

	// Keep turning pages while the mouse is pressed
	bool firstPageTurn = true;
	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
		// Check for the last page
		if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10)
			return;

		if (!pageTurn(kRivenTransitionWipeLeft)) {
			return;
		}

		// Update the page number
		page++;
		firstPageTurn = false;

		_vm->getCard()->drawPicture(page);
		_vm->doFrame();
	}
}

void ASpit::xacathopenbook(const ArgumentArray &args) {
	// Get the variable
	uint32 page = _vm->_vars["acathbook"];

	// Set hotspots depending on the page
	RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook");
	RivenHotspot *nextPage = _vm->getCard()->getHotspotByName("nextpage");
	RivenHotspot *prevPage = _vm->getCard()->getHotspotByName("prevpage");
	if (page == 1) {
		prevPage->enable(false);
		nextPage->enable(false);
		openBook->enable(true);
	} else {
		prevPage->enable(true);
		nextPage->enable(true);
		openBook->enable(false);
	}

	cathBookDrawPage(page);
}

void ASpit::cathBookDrawPage(uint32 page) {// Draw the image of the page
	_vm->getCard()->drawPicture(page);

	// Draw the white page edges
	if (page > 1 && page < 5)
		_vm->getCard()->drawPicture(50);
	else if (page > 5)
		_vm->getCard()->drawPicture(51);

	if (page == 28) {
		cathBookDrawTelescopeCombination();
	}
}

void ASpit::cathBookDrawTelescopeCombination() {// Draw the telescope combination
	// The images for the numbers are tBMP's 13 through 17.
	// The start point is at (156, 247)
	uint32 teleCombo = _vm->_vars["tcorrectorder"];
	static const uint16 kNumberWidth = 32;
	static const uint16 kNumberHeight = 25;
	static const uint16 kDstX = 156;
	static const uint16 kDstY = 247;

	for (byte i = 0; i < 5; i++) {
			uint16 offset = (getComboDigit(teleCombo, i) - 1) * kNumberWidth;
			Common::Rect srcRect = Common::Rect(offset, 0, offset + kNumberWidth, kNumberHeight);
			Common::Rect dstRect = Common::Rect(i * kNumberWidth + kDstX, kDstY, (i + 1) * kNumberWidth + kDstX, kDstY + kNumberHeight);
			_vm->_gfx->drawImageRect(i + 13, srcRect, dstRect);
		}
}

void ASpit::xacathbookback(const ArgumentArray &args) {
	_vm->_inventory->backFromItemScript();
}

void ASpit::xacathbookprevpage(const ArgumentArray &args) {
	// Get the variable
	uint32 &page = _vm->_vars["acathbook"];

	// Keep turning pages while the mouse is pressed
	bool firstPageTurn = true;
	while (mouseIsDown() || firstPageTurn) {
		// Check for the first page
		if (page == 1)
			return;

		if (!pageTurn(kRivenTransitionWipeDown)) {
			return;
		}

		// Update the page number
		page--;
		firstPageTurn = false;

		cathBookDrawPage(page);

		_vm->doFrame();
	}
}

void ASpit::xacathbooknextpage(const ArgumentArray &args) {
	// Get the variable
	uint32 &page = _vm->_vars["acathbook"];

	// Keep turning pages while the mouse is pressed
	bool firstPageTurn = true;
	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
		// Check for the last page
		if (page == 49)
			return;

		if (!pageTurn(kRivenTransitionWipeUp)) {
			return;
		}

		// Update the page number
		page++;
		firstPageTurn = false;

		cathBookDrawPage(page);

		_vm->doFrame();
	}
}

void ASpit::xtrapbookback(const ArgumentArray &args) {
	// Return to where we were before entering the book
	_vm->_vars["atrap"] = 0;
	_vm->_inventory->backFromItemScript();
}

void ASpit::xatrapbookclose(const ArgumentArray &args) {
	// Close the trap book
	_vm->_vars["atrap"] = 0;

	pageTurn(kRivenTransitionWipeRight);

	// Stop the flyby movie to prevent a glitch where the book does not actually
	// close because the movie continues to draw over the closed book picture.
	// This glitch also happened in the original engine with transitions disabled.
	RivenVideo *flyby = _vm->_video->getSlot(1);
	flyby->close();

	_vm->getCard()->enter(false);
}

void ASpit::xatrapbookopen(const ArgumentArray &args) {
	// Open the trap book
	_vm->_vars["atrap"] = 1;

	pageTurn(kRivenTransitionWipeLeft);

	_vm->getCard()->enter(false);
}

void ASpit::xarestoregame(const ArgumentArray &args) {
	// Launch the load game dialog
	_vm->runLoadDialog();
}

void ASpit::xadisablemenureturn(const ArgumentArray &args) {
	// This function would normally enable the Windows menu item for
	// returning to the main menu. Ctrl+r will do this instead.
	// The original also had this shortcut.
}

void ASpit::xaenablemenureturn(const ArgumentArray &args) {
	// This function would normally enable the Windows menu item for
	// returning to the main menu. Ctrl+r will do this instead.
	// The original also had this shortcut.
}

void ASpit::xalaunchbrowser(const ArgumentArray &args) {
	// Well, we can't launch a browser for obvious reasons ;)
	// The original text is as follows (for reference):

	// If you have an auto-dial configured connection to the Internet,
	// please select YES below.
	//
	// America Online and CompuServe users may experience difficulty. If
	// you find that you are unable to connect, please quit the Riven
	// Demo, launch your browser and type in the following URL:
	//
	//     www.redorb.com/buyriven
	//
	// Would you like to attempt to make the connection?
	//
	// [YES] [NO]

	GUI::MessageDialog dialog(_("At this point, the Riven Demo would\n"
			                          "ask if you would like to open a web browser\n"
			                          "to bring you to the Red Orb store to buy\n"
			                          "the game. ScummVM cannot do that and\n"
			                          "the site no longer exists."));
	dialog.runModal();
}

void ASpit::xadisablemenuintro(const ArgumentArray &args) {
	// This function would normally enable the Windows menu item for
	// playing the intro. Ctrl+p will play the intro movies instead.
	// The original also had this shortcut.

	_vm->_inventory->forceHidden(true);
}

void ASpit::xaenablemenuintro(const ArgumentArray &args) {
	// This function would normally enable the Windows menu item for
	// playing the intro. Ctrl+p will play the intro movies instead.
	// The original also had this shortcut.

	// Show the "exit" button here
	_vm->_inventory->forceHidden(false);
}

void ASpit::xademoquit(const ArgumentArray &args) {
	// Exactly as it says on the tin. In the demo, this function quits.
	_vm->setGameEnded();
}

void ASpit::xaexittomain(const ArgumentArray &args) {
	// One could potentially implement this function, but there would be no
	// point. This function is only used in the demo's aspit card 9 update
	// screen script. However, card 9 is not accessible from the game without
	// jumping to the card and there's nothing going on in the card so it
	// never gets called. There's also no card 9 in the full game, so the
	// functionality of this card was likely removed before release. The
	// demo executable references some other external commands relating to
	// setting and getting the volume, as well as drawing the volume. I'd
	// venture to guess that this would have been some sort of options card
	// replaced with the Windows/Mac API in the final product.
	//
	// Yeah, this function is just dummied and holds a big comment ;)
}

} // End of namespace RivenStacks
} // End of namespace Mohawk