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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
/* 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.
*
*/
#ifndef STARTREK_ROOM_H
#define STARTREK_ROOM_H
#include "common/rect.h"
#include "common/ptr.h"
#include "common/str.h"
#include "startrek/startrek.h"
#include "startrek/text.h"
using Common::SharedPtr;
namespace StarTrek {
class StarTrekEngine;
class Room;
// Per-room action functions
struct RoomAction {
const Action action;
void (Room::*funcPtr)();
};
// Offsets of data in RDF files
const int RDF_WARP_ROOM_INDICES = 0x22;
const int RDF_ROOM_ENTRY_POSITIONS = 0x2a;
const int RDF_BEAM_IN_POSITIONS = 0xaa;
class Room {
public:
Room(StarTrekEngine *vm, const Common::String &name);
~Room();
// Helper stuff for RDF access
uint16 readRdfWord(int offset);
// Scale-related stuff (rename these later)
uint16 getVar06() { return readRdfWord(0x06); }
uint16 getVar08() { return readRdfWord(0x08); }
uint16 getVar0a() { return readRdfWord(0x0a); }
uint16 getVar0c() { return readRdfWord(0x0c); }
// words 0x0e and 0x10 in RDF file are pointers to start and end of event code.
// That code is instead rewritten on a per-room basis.
bool actionHasCode(const Action &action);
bool handleAction(const Action &action);
// Same as above, but if any byte in the action is -1 (0xff), it matches any value.
bool handleActionWithBitmask(const Action &action);
uint16 getFirstHotspot() { return readRdfWord(0x12); }
uint16 getHotspotEnd() { return readRdfWord(0x14); }
// Warp-related stuff
uint16 getFirstWarpPolygonOffset() { return readRdfWord(0x16); }
uint16 getWarpPolygonEndOffset() { return readRdfWord(0x18); }
uint16 getFirstDoorPolygonOffset() { return readRdfWord(0x1a); }
uint16 getDoorPolygonEndOffset() { return readRdfWord(0x1c); }
Common::Point getBeamInPosition(int crewmanIndex);
public:
byte *_rdfData;
private:
StarTrekEngine *_vm;
RoomAction *_roomActionList;
int _numRoomActions;
// Interface for room-specific code
void loadActorAnim(int actorIndex, Common::String anim, int16 x, int16 y, uint16 field66); // Cmd 0x00
void loadActorStandAnim(int actorIndex); // Cmd 0x01
void loadActorAnim2(int actorIndex, Common::String anim, int16 x, int16 y, uint16 field66);// Cmd 0x02
int showRoomSpecificText(const char **textAddr); // (Deprecated, use function below) // Cmd 0x03
int showText(const int *text); // Cmd 0x03
int showText(int speaker, int text); // Cmd 0x03
int showText(int text); // Cmd 0x03
void giveItem(int item); // Cmd 0x04
void loadRoomIndex(int roomIndex, int spawnIndex); // Cmd 0x06
void loseItem(int item); // Cmd 0x07
void walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam);// Cmd 0x08
void loadMapFile(const Common::String &name); // Cmd 0x09
// Command 0x0c: "demon6ShowCase"
Common::Point getActorPos(int actorIndex); // Cmd 0x0d
void playSoundEffectIndex(int soundEffect); // Cmd 0x0f
void playMidiMusicTracks(int startTrack, int loopTrack); // Cmd 0x10
void showGameOverMenu(); // Cmd 0x12
void playVoc(Common::String filename); // Cmd 0x15
// Room-specific code
public:
// DEMON0
void demon0Tick1();
void demon0Tick2();
void demon0Tick60();
void demon0Tick100();
void demon0Tick140();
void demon0TouchedWarp0();
void demon0WalkToBottomDoor();
void demon0TouchedHotspot1();
void demon0ReachedBottomDoor();
void demon0WalkToTopDoor();
void demon0TouchedHotspot0();
void demon0ReachedTopDoor();
void demon0TalkToPrelate();
void demon0LookAtPrelate();
void demon0UsePhaserOnSnow();
void demon0UsePhaserOnSign();
void demon0UsePhaserOnShelter();
void demon0UsePhaserOnPrelate();
void demon0LookAtSign();
void demon0LookAtTrees();
void demon0LookAtSnow();
void demon0LookAnywhere();
void demon0LookAtBushes();
void demon0LookAtKirk();
void demon0LookAtMcCoy();
void demon0LookAtRedShirt();
void demon0LookAtSpock();
void demon0LookAtShelter();
void demon0TalkToKirk();
void demon0TalkToRedshirt();
void demon0TalkToMcCoy();
void demon0TalkToSpock();
void demon0AskPrelateAboutSightings();
void demon0UseSTricorderAnywhere();
void demon0UseMTricorderAnywhere();
void demon0UseMTricorderOnPrelate();
void demon0BadResponse();
// DEMON1
void demon1Tick1();
void demon1WalkToCave();
void demon1TouchedTopWarp();
void demon1TouchedBottomWarp();
void demon1Timer2Expired();
void demon1Timer0Expired();
void demon1Timer3Expired();
void demon1Timer1Expired();
void demon1KlingonFinishedAimingWeapon();
void demon1KirkShot();
void demon1UsePhaserOnAnything();
void demon1UsePhaserOnKlingon1();
void demon1ShootKlingon1();
void demon1KlingonDropsHand();
void demon1UsePhaserOnKlingon2();
void demon1ShootKlingon2();
void demon1UsePhaserOnKlingon3();
void demon1ShootKlingon3();
void demon1AllKlingonsDead();
void demon1Timer5Expired();
void demon1UseMTricorderOnKlingon();
void demon1UseSTricorderOnTulips();
void demon1UseSTricorderOnPods();
void demon1UseSTricorderOnCattails();
void demon1UseSTricorderOnFerns();
void demon1UseSTricorderOnHand();
void demon1UseSTricorderOnKlingon1();
void demon1UseSTricorderOnKlingon2Or3();
void demon1UseMTricorderOnKirk();
void demon1UseMTricorderOnSpock();
void demon1UseMTricorderOnRedshirt();
void demon1UseMTricorderOnCrewman();
void demon1GetHand();
void demon1ReachedHand();
void demon1PickedUpHand();
void demon1FinishedGettingHand();
void demon1LookAtKlingon();
void demon1LookAtCattails();
void demon1LookAtTulips();
void demon1LookAtPods();
void demon1LookAtFerns();
void demon1LookAtStream();
void demon1LookAtMine();
void demon1LookAtMountain();
void demon1LookAtHand();
void demon1LookAnywhere();
void demon1LookAtKirk();
void demon1LookAtSpock();
void demon1LookAtMcCoy();
void demon1LookAtRedshirt();
void demon1TalkToKirk();
void demon1TalkToSpock();
void demon1TalkToMcCoy();
void demon1TalkToRedshirt();
void demon1TalkToUnconsciousCrewman();
// DEMON2
void demon2Tick1();
void demon2WalkToCave();
void demon2ReachedCave();
void demon2TouchedWarp1();
void demon2LookAtCave();
void demon2LookAtMountain();
void demon2LookAtBerries();
void demon2LookAtFern();
void demon2LookAtMoss();
void demon2LookAtLights();
void demon2LookAtAnything();
void demon2LookAtKirk();
void demon2LookAtSpock();
void demon2LookAtMcCoy();
void demon2LookAtRedshirt();
void demon2TalkToKirk();
void demon2TalkToSpock();
void demon2TalkToMcCoy();
void demon2TalkToRedshirt();
void demon2UsePhaserOnBerries();
void demon2UseSTricorderOnBerries();
void demon2UseSTricorderOnMoss();
void demon2UseSTricorderOnFern();
void demon2UseSTricorderOnCave();
void demon2UseMTricorderOnBerries();
void demon2GetBerries();
void demon2ReachedBerries();
void demon2PickedUpBerries();
// DEMON3
void demon3Tick1();
void demon3Timer0Expired();
void demon3Timer1Expired();
void demon3Timer3Expired();
void demon3FinishedAnimation1();
void demon3FinishedAnimation2();
void demon3FinishedWalking5();
void demon3McCoyInFiringPosition();
void demon3SpockInFiringPosition();
void demon3RedShirtInFiringPosition();
void demon3KirkInFiringPosition();
void demon3CrewmanInFiringPosition();
void demon3PullOutPhaserAndFireAtBoulder();
void demon3FireAtBoulder();
void demon3UsePhaserOnRedshirt();
void demon3UseStunPhaserOnBoulder();
void demon3UsePhaserOnBoulder1();
void demon3UsePhaserOnBoulder2();
void demon3UsePhaserOnBoulder3();
void demon3UsePhaserOnBoulder4();
void demon3BoulderCommon();
void demon3UseSTricorderOnMiner();
void demon3UseSTricorderOnPanel();
void demon3UseSTricorderOnBoulder();
void demon3UseMTricorderOnBoulder();
void demon3UseCrewmanOnPanel();
void demon3UseRedshirtOnPanel();
void demon3RedshirtReachedPanel();
void demon3RedshirtUsedPanel();
void demon3RedshirtElectrocuted();
void demon3UseSTricorderOnDoor();
void demon3UseSTricorderOnAnything();
void demon3UseMTricorderOnDoor();
void demon3UsePhaserOnDoor();
void demon3UseHandOnPanel();
void demon3KirkReachedHandPanel();
void demon3KirkUsedHandPanel();
void demon3UseMTricorderOnMiner();
void demon3UseMedkitOnMiner();
void demon3McCoyReachedMiner();
void demon3McCoyFinishedHealingMiner();
void demon3GetMiner();
void demon3TalkToMiner();
void demon3TalkToKirk();
void demon3TalkToSpock();
void demon3TalkToMccoy();
void demon3TalkToRedshirt();
void demon3LookAtKirk();
void demon3LookAtSpock();
void demon3LookAtMccoy();
void demon3LookAtRedshirt();
void demon3LookAnywhere();
void demon3LookAtMiner();
void demon3LookAtBoulder1();
void demon3LookAtBoulder2();
void demon3LookAtBoulder3();
void demon3LookAtBoulder4();
void demon3LookAtStructure();
void demon3LookAtDoor();
void demon3LookAtPanel();
void demon3LookAtLight();
// DEMON4
void demon4Tick1();
void demon4FinishedAnimation1();
void demon4FinishedAnimation2();
void demon4FinishedAnimation3();
void demon4UsePhaserOnPanel();
void demon4UsePhaserOnPattern();
void demon4UsePhaserOnMccoy();
void demon4LookAtPattern();
void demon4LookAtAlien();
void demon4LookAnywhere();
void demon4LookAtSecurityEquipment();
void demon4LookAtFloor();
void demon4LookAtKirk();
void demon4LookAtMccoy();
void demon4LookAtSpock();
void demon4LookAtRedshirt();
void demon4LookAtChamber();
void demon4LookAtPanel();
void demon4UseKirkOnPanel();
void demon4UseSpockOnPanel();
void demon4UseMccoyOnPanel();
void demon4UseRedshirtOnPanel();
void demon4UseCrewmanOnPanel();
void demon4CrewmanReachedPanel();
// DEMON5
void demon5Tick1();
void demon5WalkToDoor();
void demon5TouchedDoorOpenTrigger();
void demon5DoorOpenedOrReachedDoor();
void demon5UseSTricorderOnCrate();
void demon5UsePhaserOnAnything();
void demon5UseHandOnStephen();
void demon5UseBerryOnStephen();
void demon5UseHypoDytoxinOnChub();
void demon5MccoyReachedChub();
void demon5MccoyHealedChub();
void demon5UseHypoDytoxinOnAnything();
void demon5UseBerryOnChub();
void demon5LookAtRoberts();
void demon5LookAtGrisnash();
void demon5LookAtStephen();
void demon5LookAtKirk();
void demon5LookAtSpock();
void demon5LookAtMccoy();
void demon5LookAtRedshirt();
void demon5LookAtMountain();
void demon5LookAtCrate();
void demon5LookAnywhere();
void demon5LookAtChub();
void demon5TalkToRoberts();
void demon5TalkToChub();
void demon5TalkToGrisnash();
void demon5TalkToStephen();
void demon5TalkToKirk();
void demon5TalkToSpock();
void demon5TalkToRedshirt();
void demon5TalkToMccoy();
void demon5UseMTricorderOnRoberts();
void demon5UseMTricorderOnChub();
void demon5UseMTricorderOnGrisnash();
void demon5UseMTricorderOnStephen();
void demon5CheckCompletedStudy();
void demon5GetCrate();
// DEMON6
void demon6Tick1();
void demon6Tick30();
void demon6SpockReachedComputer();
void demon6WalkToDoor();
void demon6TouchedDoorOpenTrigger();
void demon6DoorOpenedOrReachedDoor();
void demon6UsePhaserOnStephen();
void demon6UsePhaserOnCase();
void demon6LookAtWorkspace();
void demon6LookAtCase();
void demon6LookAtTable();
void demon6LookAtMineral();
void demon6LookAtShells();
void demon6LookAtSkull();
void demon6LookAtMetal();
void demon6LookAtMeteor();
void demon6LookAtMountain();
void demon6LookAtSynthesizer();
void demon6LookAtKirk();
void demon6LookAtSpock();
void demon6LookAtMccoy();
void demon6LookAtRedshirt();
void demon6LookAtComputer();
void demon6LookAnywhere();
void demon6LookAtStephen();
void demon6TalkToMccoy();
void demon6TalkToSpock();
void demon6TalkToKirk();
void demon6TalkToRedshirt();
void demon6TalkToStephen();
void demon6UseBerryOnStephen();
void demon6UseBerryOnSynthesizer();
void demon6MccoyReachedSynthesizer();
void demon6FinishedMakingHypoDytoxin();
void demon6UseHandOnWorkspace();
void demon6SpockReachedWorkspace();
void demon6SpockFinishedRepairingHand();
void demon6UseAnythingOnWorkspace();
void demon6UseCrewmanOnCase();
void demon6UseKirkOnComputer();
void demon6UseMccoyOnComputer();
void demon6UseRedshirtOnComputer();
void demon6UseSpockOnComputer();
void demon6UseMineralOnStephen();
void demon6UseShellsOnStephen();
void demon6UseMeteorOnStephen();
void demon6UseSkullOnStephen();
void demon6UseMetalOnStephen();
void demon6ReturnItemToStephen(int item);
void demon6UseHandOnStephen();
void demon6UseMTricoderOnStephen();
void demon6UseSTricoderOnTable();
void demon6UseSTricoderOnComputer();
void demon6UseSTricoderOnMineral();
void demon6UseSTricoderOnShells();
void demon6UseSTricoderOnSkull();
void demon6UseSTricoderOnMetal();
void demon6UseSTricoderOnMeteor();
void demon6UseSTricoderOnCase();
void demon6UseSTricoderOnSynthesizer();
void demon6GetCase();
void demon6KirkReachedCase();
int demon6ShowCase(int visible);
private:
// Room-specific variables. This is memset'ed to 0 when the room is initialized.
union {
struct {
int numKlingonsKilled;
byte attackIndex;
bool kirkShooting;
char d6[10];
} demon1;
struct {
bool shootingBoulder; // 0xca
bool boulder1Shot; // 0xcb
byte boulderBeingShot; // 0xcc
bool kirkInPosition; // 0xcd
bool redshirtInPosition; // 0xce
bool spockInPosition; // 0xcf
bool mccoyInPosition; // 0xd0
bool inFiringPosition; // 0xd1
bool kirkPhaserOut; // 0xd3
char boulderAnim[10]; // 0xd4
int16 usedPhaserOnDoor; // 0xd6
} demon3;
struct {
bool cb; // 0xcb
int16 crewmanUsingPanel; // 0xcf
} demon4;
struct {
bool scannedRoberts; // 0xca
bool scannedChub; // 0xcb
bool scannedGrisnash; // 0xcc
bool scannedStephen; // 0xcd
byte numScanned; // 0xce
byte numTalkedTo; // 0xcf
bool talkedToRoberts; // 0xd0
bool talkedToChub; // 0xd1
bool talkedToGrisnash; // 0xd2
bool talkedToStephen; // 0xd3
byte doorCounter; // 0xd4
bool movingToDoor; // 0xd5
} demon5;
struct {
bool insultedStephenRecently; // 0xca
bool stephenInRoom; // 0xcb
bool caseOpened; // 0xcd
byte doorCounter; // 0xce
bool movingToDoor; // 0xcf
} demon6;
} _roomVar;
};
}
#endif
|