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
|
/* 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 "startrek/startrek.h"
namespace StarTrek {
void StarTrekEngine::playIntro() {
// TODO: .MT audio file
initStarfieldPosition();
initStarfield(10, 20, 309, 169, 128);
SharedPtr<Bitmap> fakeStarfieldBitmap(new StubBitmap(0, 0));
_starfieldSprite.bitmap = fakeStarfieldBitmap;
initStarfieldSprite(&_starfieldSprite, fakeStarfieldBitmap, _starfieldRect);
//delR3(&_enterpriseR3); // TODO: uncomment
R3 planetR3 = R3();
planetR3.matrix = initMatrix();
planetR3.field1e = 3;
planetR3.funcPtr1 = 0;
planetR3.funcPtr2 = 0;
planetR3.bitmapOffset = 0;
_gfx->clearScreenAndPriBuffer();
_gfx->fadeoutScreen();
_gfx->loadPalette("gold");
_gfx->setBackgroundImage(_gfx->loadBitmap("goldlogo"));
_sound->playVoc("logo");
_gfx->copyBackgroundScreen();
_system->updateScreen();
_system->delayMillis(10);
_gfx->fadeinScreen();
uint32 clockTicks = _clockTicks;
Sprite subtitleSprite;
_gfx->addSprite(&subtitleSprite);
subtitleSprite.setXYAndPriority(0, 0, 12);
subtitleSprite.bitmap = _gfx->loadBitmap("blank");
subtitleSprite.drawPriority2 = 16;
int index = 12;
while (index >= 0) {
Common::String file = Common::String::format("credit%02d.shp", index);
// TODO: This loads the file, but does not do anything with the resulting data, so
// this is just for caching it?
// Remember to deal with similar commented function calls below, too.
//loadFileWithParams(file, false, true, false);
index -= 1;
}
//loadFileWithParams("legal.bmp", false, true, false);
index = 6;
while (index >= 0) {
Common::String file = Common::String::format("tittxt%02d.bmp", index);
//loadFileWithParams(file, false, true, false);
index -= 1;
}
//loadFileWithParams("planet.shp", false, true, false);
index = 6;
while (index >= 0) {
Common::String file = Common::String::format("ent%d3.r3s", index);
//loadFileWithParams(file, false, true, false);
index -= 1;
}
// TODO: kirkintr
clockTicks += 540;
while (_clockTicks < clockTicks && _sound->isMidiPlaying()) {
waitForNextTick(true);
}
// TODO: MT audio file
_gfx->fadeoutScreen();
_gfx->loadPalette("bridge");
_gfx->clearScreenAndPriBuffer();
_sound->loadMusicFile("title");
clockTicks = _clockTicks;
int32 starfieldZoomSpeed = 0;
int16 frame = 0;
bool buttonPressed = false;
while (frame != 0x180 || (_sound->isMidiPlaying() && !buttonPressed)) {
if (!buttonPressed) {
TrekEvent event;
while (popNextEvent(&event, false)) {
if (event.type == TREKEVENT_KEYDOWN) {
_gfx->fadeoutScreen();
buttonPressed = true;
} else if (event.type == TREKEVENT_TICK)
break;
}
}
switch (frame) {
case 0:
starfieldZoomSpeed = 10;
playMidiMusicTracks(MIDITRACK_0, -1);
_byte_45b3c = 0;
break;
case 30:
_sound->playVoc("kirkintr");
loadSubtitleSprite(0, &subtitleSprite);
break;
case 36:
loadSubtitleSprite(1, &subtitleSprite);
break;
case 42: // Enterprise moves toward camera
loadSubtitleSprite(-1, &subtitleSprite);
addR3(&_enterpriseR3);
_enterpriseR3.field1e = 2;
initIntroR3ObjectToMove(&_enterpriseR3, 330, 5000, 0, 0, 18);
break;
case 60: // Enterprise moves away from camera
initIntroR3ObjectToMove(&_enterpriseR3, 0, 0, 30, 5000, 6);
break;
case 66: // Cut to scene with planet
loadSubtitleSprite(2, &subtitleSprite);
planetR3.field22 = 2000;
planetR3.field24 = 10000 / _starfieldPointDivisor;
planetR3.shpFile = loadFile("planet.shp");
initIntroR3ObjectToMove(&planetR3, 6, 10000, 6, 10000, 0);
addR3(&planetR3);
initIntroR3ObjectToMove(&_enterpriseR3, -15, 250, 15, 500, 18);
starfieldZoomSpeed = 0;
break;
case 186:
delR3(&_enterpriseR3);
// TODO: the rest
break;
case 366:
planetR3.shpFile.reset();
delR3(&planetR3);
break;
case 378:
_gfx->delSprite(&subtitleSprite);
_byte_45b3c = 1;
break;
}
if (!buttonPressed) {
updateStarfieldAndShips(false);
_gfx->drawAllSprites();
_gfx->incPaletteFadeLevel();
clockTicks += 3;
while (_clockTicks < clockTicks)
waitForNextTick();
}
_starfieldPosition.z += starfieldZoomSpeed;
frame++;
if (frame >= 0x186)
frame = 0x186;
}
_gfx->fadeoutScreen();
_gfx->delSprite(&_starfieldSprite);
// TODO: the rest
}
void StarTrekEngine::initIntroR3ObjectToMove(R3 *r3, int16 srcAngle, int16 srcDepth, int16 destAngle, int16 destDepth, int16 ticks) {
Fixed8 a1 = Fixed8::fromRaw((srcAngle << 8) / 90);
Fixed8 a2 = Fixed8::fromRaw((destAngle << 8) / 90);
r3->pos.x = sin(a1).multToInt(srcDepth) + _starfieldPosition.x;
r3->pos.z = cos(a1).multToInt(srcDepth) + _starfieldPosition.z;
r3->pos.y = 0;
int32 deltaX = sin(a2).multToInt(destDepth) + _starfieldPosition.x - r3->pos.x;
int32 deltaZ = cos(a2).multToInt(destDepth) + _starfieldPosition.z - r3->pos.z;
debug("Z: %d, %d", r3->pos.z - _starfieldPosition.z, cos(a2).multToInt(destDepth));
Angle angle = atan2(deltaX, deltaZ);
r3->matrix = initSpeedMatrixForXZMovement(angle, initMatrix());
debugCN(5, kDebugSpace, "initIntroR3ObjectToMove: pos %x,%x,%x; ", r3->pos.x, r3->pos.y, r3->pos.z);
if (ticks != 0) {
debugC(5, kDebugSpace, "speed %x,%x,%x\n", r3->speed.x, r3->speed.y, r3->speed.z);
r3->speed.x = deltaX / ticks;
r3->speed.z = deltaZ / ticks;
r3->speed.y = 0;
} else {
debugC(5, kDebugSpace, "speed 0\n");
r3->speed.x = 0;
r3->speed.z = 0;
r3->speed.y = 0;
}
}
void StarTrekEngine::loadSubtitleSprite(int index, Sprite *sprite) {
if (_showSubtitles) {
if (index == -1)
sprite->setBitmap(_gfx->loadBitmap("blank"));
else {
Common::String file = Common::String::format("tittxt%02d", index);
sprite->setBitmap(_gfx->loadBitmap(file));
}
}
}
} // End of namespace StarTrek
|