Permalink
Browse files

STARTREK: Mission 1 finished

  • Loading branch information...
Drenn1 authored and sev- committed May 31, 2018
1 parent 1290b7e commit fe5658ca175810f7ea6cbcaa078e6fc86faf36f1
@@ -38,13 +38,22 @@ void StarTrekEngine::initAwayMission() {
_sound->loadMusicFile("ground");

loadRoom(_missionToLoad, _roomIndexToLoad);
_roomIndexToLoad = -1;

// Load crew positions for beaming in
initAwayCrewPositions(4);
}

void StarTrekEngine::runAwayMission() {
while (true) {
// Original game manipulates the stack when the room changes to return execution
// to this point. Instead of doing that, just check if a variable is set.
if (_roomIndexToLoad != -1 && _spawnIndexToLoad != -1) {
loadRoomIndex(_roomIndexToLoad, _spawnIndexToLoad);
_roomIndexToLoad = -1;
_spawnIndexToLoad = -1;
}

handleAwayMissionEvents();

Common::Point mousePos = _gfx->getMousePos();
@@ -55,6 +55,7 @@ struct AwayMission {
struct {
bool wasRudeToPrelate; // 0x29
bool insultedStephen; // 0x2b
bool field2d; // 0x2d
bool beatKlingons; // 0x2f
bool tookKlingonHand; // 0x31

@@ -75,25 +76,26 @@ struct AwayMission {
byte field41; // 0x41
bool foundMiner; // 0x43
bool field45; // 0x45
bool field47; // 0x47
bool gaveSkullToNauian; // 0x47
bool warpsDisabled; // 0x48
bool boulder1Gone; // 0x49
bool boulder2Gone; // 0x4a
bool boulder3Gone; // 0x4b
bool boulder4Gone; // 0x4c
bool doorOpened; // 0x4d
bool field4e; // 0x4e
bool solvedSunPuzzle; // 0x4e
byte itemsTakenFromCase; // 0x4f
bool gotBerries; // 0x50
bool madeHypoDytoxin; // 0x51
bool metNauian; // 0x53
bool gavePointsForDytoxin; // 0x54
bool lookedAtComputer; // 0x55
byte field56; // 0x56
bool foundAlienRoom; // 0x57
} demon;
};

int16 missionScore;
int16 missionScore; // 0x58
};
// Size: 0x129 bytes

@@ -653,7 +653,6 @@ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool arg4
switch(event.type) {

case TREKEVENT_TICK: {
case TREKEVENT_MOUSEMOVE: // FIXME: actual game only uses TICK event here
Common::Point mousePos = _gfx->getMousePos();
int buttonIndex = getMenuButtonAt(_activeMenu->sprites, _activeMenu->numButtons, mousePos.x, mousePos.y);
if (buttonIndex != -1) {
@@ -676,19 +675,19 @@ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool arg4
}
// Not added: updating mouse position (scummvm handles that)

// sub_10492();
// sub_10A91();
// sub_10492(); // TODO
// updateActorAnimations(); // TODO: uncomment and fix animations under textboxes
_gfx->drawAllSprites();
// sub_10BE7();
// sub_2A4B1();
// sub_10BE7(); // TODO
_sound->checkLoopMusic();

if (_finishedPlayingSpeech != 0) {
_finishedPlayingSpeech = 0;
if (_textDisplayMode != TEXTDISPLAY_WAIT) {
return TEXTBUTTON_SPEECH_DONE;
}
}
// sub_1E88C();
_gfx->incPaletteFadeLevel();
_frameIndex++;

if (ticksUntilClickingEnabled != 0 && _clockTicks >= tickWhenClickingEnabled)
@@ -236,17 +236,24 @@ void Room::loadRoomIndex(int roomIndex, int spawnIndex) {
if (_vm->_awayMission.crewDownBitset != 0)
return;

_vm->loadRoomIndex(roomIndex, spawnIndex);
_vm->_missionToLoad = _vm->_missionName;
_vm->_roomIndexToLoad = roomIndex;
_vm->_spawnIndexToLoad = spawnIndex;

// This room has now been deleted, don't do anything else here.
// FIXME: this could a bit dangerous since this is generally called from room-specific
// code, which isn't guaranteed to do nothing afterward. Original game would
// manipulate the stack to jump directly back to the start of "runAwayMission"...
// WORKAROUND: original game manipulates the stack to return directly to the start of
// "runAwayMission". Instead, we set some variables and the room will be changed
// later. (We wouldn't want to delete the room we're currently in...)
}

void Room::loseItem(int item) {
assert(item >= ITEMS_START && item < ITEMS_END);
_vm->_itemList[item - ITEMS_START].have = false;

if (_vm->_awayMission.activeAction == ACTION_USE && _vm->_awayMission.activeObject == item) {
_vm->_awayMission.activeAction = ACTION_WALK;
_vm->chooseMouseBitmapForAction(ACTION_WALK, false);
_vm->hideInventoryIcons();
}
}

void Room::walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam) {
@@ -286,6 +293,30 @@ void Room::playMidiMusicTracks(int startTrack, int loopTrack) {
_vm->playMidiMusicTracks(startTrack, loopTrack);
}

void Room::endMission(int16 score, int16 arg1, int16 arg2) {
_vm->_awayMission.disableInput = true;

for (int i = 0; i < (_vm->_awayMission.redshirtDead ? 3 : 4); i++) {
Actor *actor = &_vm->_actorList[i];
Common::String anim = _vm->getCrewmanAnimFilename(i, "teled");
_vm->loadActorAnimWithRoomScaling(i, anim, actor->sprite.pos.x, actor->sprite.pos.y);
}

_vm->_kirkActor->animationString[0] = '\0';
_vm->_spockActor->animationString[0] = '\0';
_vm->_mccoyActor->animationString[0] = '\0';
_vm->_redshirtActor->animationString[0] = '\0';

playSoundEffectIndex(8);

while (_vm->_kirkActor->spriteDrawn)
_vm->handleAwayMissionEvents();

_vm->_awayMission.disableInput = false;

// TODO: game mode switch
}

void Room::showGameOverMenu() {
_vm->showGameOverMenu();
}
@@ -103,6 +103,7 @@ class Room {
int showText(int speaker, int text); // Cmd 0x03
int showText(int text); // Cmd 0x03
void giveItem(int item); // Cmd 0x04
// Command 0x05: "demon4ShowSunPuzzle"
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
@@ -111,6 +112,7 @@ class Room {
Common::Point getActorPos(int actorIndex); // Cmd 0x0d
void playSoundEffectIndex(int soundEffect); // Cmd 0x0f
void playMidiMusicTracks(int startTrack, int loopTrack); // Cmd 0x10
void endMission(int16 score, int16 arg2, int16 arg3); // Cmd 0x11
void showGameOverMenu(); // Cmd 0x12
void playVoc(Common::String filename); // Cmd 0x15

@@ -310,9 +312,26 @@ class Room {
void demon4FinishedAnimation1();
void demon4FinishedAnimation2();
void demon4FinishedAnimation3();
void demon4Timer0Expired();
void demon4Timer1Expired();
void demon4CrewmanReachedBeamoutPosition();
void demon4Timer2Expired();
void demon4Timer3Expired();
void demon4Timer4Expired();
void demon4Timer5Expired();
void demon4Timer6Expired();
void demon4UsePhaserOnNauian();
void demon4UseMetalOnSecurityEquipment();
void demon4KirkReachedSecurityEquipment();
void demon4KirkFinishedUsingSecurityEquipment();
void demon4UseMetalOnNauian();
void demon4KirkReachedNauian();
void demon4UseSkullOnNauian();
void demon4KirkReachedNauianWithSkull();
void demon4UsePhaserOnPanel();
void demon4UsePhaserOnPattern();
void demon4UsePhaserOnMccoy();
void demon4TalkToNauian();
void demon4LookAtPattern();
void demon4LookAtAlien();
void demon4LookAnywhere();
@@ -330,6 +349,22 @@ class Room {
void demon4UseRedshirtOnPanel();
void demon4UseCrewmanOnPanel();
void demon4CrewmanReachedPanel();
bool demon4ShowSunPuzzle();
void demon4TalkToKirk();
void demon4TalkToMccoy();
void demon4TalkToSpock();
void demon4TalkToRedshirt();
void demon4UseSTricorderOnChamber();
void demon4UseSTricorderOnPattern();
void demon4UseMTricorderOnPattern();
void demon4UseSTricorderOnPanel();
void demon4UseMTricorderOnPanel();
void demon4UseSTricorderOnAnything();
void demon4UseMTricorderOnAnything();
void demon4UseSTricorderOnNauian();
void demon4UseMTricorderOnNauian();
void demon4UseSTricorderOnSecurityEquipment();
void demon4UseMTricorderOnSecurityEquipment();

// DEMON5
void demon5Tick1();
@@ -461,7 +496,11 @@ class Room {
} demon3;

struct {
bool cb; // 0xcb
bool triedToShootNauian; // 0xca
bool nauianEmerged; // 0xcb
bool disabledSecurity; // 0xcc
bool cd; // 0xcd
byte crewReadyToBeamOut; // 0xce
int16 crewmanUsingPanel; // 0xcf
} demon4;

@@ -381,8 +381,10 @@ void Room::demon1UseSTricorderOnHand() {
}

void Room::demon1UseSTricorderOnKlingon1() {
// NOTE: it sets up the stack, but doesn't call the function...
//loadActorAnim2(OBJECT_SPOCK, "sscann", -1, -1, 0);
// BUGFIX: Original game sets up the stack for this function call, but doesn't
// actually call the function...
loadActorAnim2(OBJECT_SPOCK, "sscann", -1, -1, 0);

playSoundEffectIndex(0x04);

if (_roomVar.demon1.numKlingonsKilled == 3 && !_vm->_awayMission.demon.tookKlingonHand && _rdfData[0xcf] != 1) {
Oops, something went wrong.

0 comments on commit fe5658c

Please sign in to comment.