aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst_stacks/intro.cpp
blob: 9b4e41d2d759abdeeeb82a1960d98b40d60f5886 (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.
 *
 * $URL$
 * $Id$
 *
 */

#include "mohawk/myst.h"
#include "mohawk/graphics.h"
#include "mohawk/myst_areas.h"
#include "mohawk/sound.h"
#include "mohawk/video.h"
#include "mohawk/myst_stacks/intro.h"

#include "gui/message.h"

namespace Mohawk {

MystScriptParser_Intro::MystScriptParser_Intro(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
	setupOpcodes();
}

MystScriptParser_Intro::~MystScriptParser_Intro() {
}

#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Intro::x, #x))

void MystScriptParser_Intro::setupOpcodes() {
	// "Stack-Specific" Opcodes
	OPCODE(100, o_useLinkBook);

	// "Init" Opcodes
	OPCODE(200, o_playIntroMovies);
	OPCODE(201, opcode_201);

	// "Exit" Opcodes
	OPCODE(300, opcode_300);
}

#undef OPCODE

void MystScriptParser_Intro::disablePersistentScripts() {
}

void MystScriptParser_Intro::runPersistentScripts() {
}

void MystScriptParser_Intro::o_useLinkBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
	// Hard coded SoundId valid only for Intro Stack.
	// Other stacks use Opcode 40, which takes SoundId values as arguments.
	const uint16 soundIdLinkSrc = 5;

	debugC(kDebugScript, "Opcode %d: o_useLinkBook", op);
	debugC(kDebugScript, "\tvar: %d", var);

	// TODO: Merge with changeStack (Opcode 40) Implementation?
	if (_vm->_varStore->getVar(var) == 5 || _vm->_varStore->getVar(var) > 7) {
		// TODO: Dead Book i.e. Released Sirrus/Achenar
	} else {
		// Play Linking Sound, blocking...
		_vm->_sound->stopSound();
		Audio::SoundHandle *handle = _vm->_sound->playSound(soundIdLinkSrc);
		while (_vm->_mixer->isSoundHandleActive(*handle))
			_vm->_system->delayMillis(10);

		// Play Flyby Entry Movie on Masterpiece Edition. The Macintosh version is currently hooked
		// up to the Cinepak versions of the video (the 'c' suffix) until the SVQ1 decoder is completed.
		if ((_vm->getFeatures() & GF_ME)) {
			switch (_stackMap[_vm->_varStore->getVar(var)]) {
			case kSeleniticStack:
				if (_vm->getPlatform() == Common::kPlatformMacintosh)
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("FLY_SEc", kMasterpieceOnly));
				else
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("selenitic flyby", kMasterpieceOnly));
				break;
			case kStoneshipStack:
				if (_vm->getPlatform() == Common::kPlatformMacintosh)
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("FLY_STc", kMasterpieceOnly));
				else
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("stoneship flyby", kMasterpieceOnly));
				break;
			// Myst Flyby Movie not used in Original Masterpiece Edition Engine
			case kMystStack:
				if (_vm->_tweaksEnabled) {
					if (_vm->getPlatform() == Common::kPlatformMacintosh)
						_vm->_video->playMovieCentered(_vm->wrapMovieFilename("FLY_MYc", kMasterpieceOnly));
					else
						_vm->_video->playMovieCentered(_vm->wrapMovieFilename("myst flyby", kMasterpieceOnly));
				}
				break;
			case kMechanicalStack:
				if (_vm->getPlatform() == Common::kPlatformMacintosh)
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("FLY_MEc", kMasterpieceOnly));
				else
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("mech age flyby", kMasterpieceOnly));
				break;
			case kChannelwoodStack:
				if (_vm->getPlatform() == Common::kPlatformMacintosh)
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("FLY_CHc", kMasterpieceOnly));
				else
					_vm->_video->playMovieCentered(_vm->wrapMovieFilename("channelwood flyby", kMasterpieceOnly));
				break;
			default:
				break;
			}
		}

		uint16 varValue = _vm->_varStore->getVar(var);
		_vm->changeToStack(_stackMap[varValue]);
		_vm->changeToCard(_startCard[varValue], true);

		// TODO: No soundIdLinkDst for Opcode 100 link? Check Original.
	}
}

void MystScriptParser_Intro::o_playIntroMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
	varUnusedCheck(op, var);

	// TODO:  Clicking during the intro movies does not stop them and change to Card 5.
	//        This is due to the movies playing blocking, but making them non-blocking causes
	//        the card change here to prevent them playing. Need to move the following to the
	//        opcode_200_run process and wait for all movies to finish playing before the card
	//        change is performed.

	// Play Intro Movies..
	if ((_vm->getFeatures() & GF_ME) && _vm->getPlatform() == Common::kPlatformMacintosh) {
		_vm->_video->playMovieCentered(_vm->wrapMovieFilename("mattel", kIntroStack));
		_vm->_video->playMovieCentered(_vm->wrapMovieFilename("presto", kIntroStack));
	} else
		_vm->_video->playMovieCentered(_vm->wrapMovieFilename("broder", kIntroStack));

	_vm->_video->playMovieCentered(_vm->wrapMovieFilename("cyanlogo", kIntroStack));

	if (!(_vm->getFeatures() & GF_DEMO)) { // The demo doesn't have the intro video
		if ((_vm->getFeatures() & GF_ME) && _vm->getPlatform() == Common::kPlatformMacintosh)
			// intro.mov uses Sorenson, introc uses Cinepak. Otherwise, they're the same.
			_vm->_video->playMovieCentered(_vm->wrapMovieFilename("introc", kIntroStack));
		else
			_vm->_video->playMovieCentered(_vm->wrapMovieFilename("intro", kIntroStack));
	}

	_vm->changeToCard(_vm->getCurCard() + 1, true);
}

void MystScriptParser_Intro::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
	varUnusedCheck(op, var);

	_vm->_gfx->updateScreen();
	_vm->_system->delayMillis(4 * 1000);
	_vm->_gfx->copyImageToScreen(4, Common::Rect(0, 0, 544, 333));
	// TODO: Wait until video ends, then change to card 5
}

void MystScriptParser_Intro::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
	varUnusedCheck(op, var);
	// In the original engine, this opcode stopped Intro Movies if playing,
	// upon card change, but this behavior is now default in this engine.
}

} // End of namespace Mohawk