diff options
| author | Matthew Stewart | 2018-05-13 23:58:58 -0400 | 
|---|---|---|
| committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 | 
| commit | 0187c795d5e1569105d4cb49a16810f6a50cc261 (patch) | |
| tree | 3f4da1e75b8d0ec147eb3a772c289fb99844190c | |
| parent | dbeb58f3926dba1bd0e5cb1556eb71040dd94afc (diff) | |
| download | scummvm-rg350-0187c795d5e1569105d4cb49a16810f6a50cc261.tar.gz scummvm-rg350-0187c795d5e1569105d4cb49a16810f6a50cc261.tar.bz2 scummvm-rg350-0187c795d5e1569105d4cb49a16810f6a50cc261.zip  | |
STARTREK: Initialization of away mission.
Crew successfully beams in and does their idle animation.
| -rw-r--r-- | engines/startrek/awaymission.cpp | 237 | ||||
| -rw-r--r-- | engines/startrek/awaymission.h | 40 | ||||
| -rw-r--r-- | engines/startrek/graphics.cpp | 23 | ||||
| -rw-r--r-- | engines/startrek/graphics.h | 7 | ||||
| -rw-r--r-- | engines/startrek/module.mk | 1 | ||||
| -rw-r--r-- | engines/startrek/object.h | 5 | ||||
| -rw-r--r-- | engines/startrek/room.cpp | 5 | ||||
| -rw-r--r-- | engines/startrek/room.h | 11 | ||||
| -rw-r--r-- | engines/startrek/startrek.cpp | 98 | ||||
| -rw-r--r-- | engines/startrek/startrek.h | 53 | 
10 files changed, 434 insertions, 46 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp new file mode 100644 index 0000000000..73526eeaa2 --- /dev/null +++ b/engines/startrek/awaymission.cpp @@ -0,0 +1,237 @@ +/* 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::initAwayMission() { +	_awayMission = AwayMission(); // Initialize members to 0 + +	// memset(bitmapBuffer->pixels, 0, 0xfa00); +	// sub_15ab1("ground"); +	// sub_23a60(); +	_sound->loadMusicFile("ground"); + +	loadRoom(_missionToLoad, _roomIndexToLoad); + +	// Load crew positions for beaming in +	initAwayCrewPositions(4); +} + +void StarTrekEngine::runAwayMission() { +	while (true) { +		handleAwayMissionEvents(); + +		Common::Point mousePos = _gfx->getMousePos(); +		_awayMission.mouseX = mousePos.x; +		_awayMission.mouseY = mousePos.y; + +		assert(_commandQueue.size() <= 16); +		if (!_commandQueue.empty()) { +			// sub_200e7(); +			// sub_20118(); +			runAwayMissionCycle(); +		} +	} +} + +void StarTrekEngine::cleanupAwayMission() { +	// TODO +} + +void StarTrekEngine::loadRoom(const Common::String &missionName, int roomIndex) { +	if (_room != nullptr) +		delete _room; + +	_keyboardControlsMouse = true; + +	_missionName = _missionToLoad; +	_roomIndex = _roomIndexToLoad; + +	_roomFrameCounter = 0; +	_awayMission.field1d = 0; + +	_gfx->fadeoutScreen(); +	_sound->stopAllVocSounds(); + +	_screenName = _missionName + (char)(_roomIndex + '0'); + +	_gfx->setBackgroundImage(_gfx->loadBitmap(_screenName)); +	_gfx->loadPri(_screenName + ".pri"); +	_gfx->loadPalette("palette"); +	_gfx->copyBackgroundScreen(); + +	_room = new Room(this, _screenName); + +	// Original sets up bytes 0-3 of rdf file as "remote function caller" + +	// Load map file +	_awayMission.mapFileLoaded = 1; +	_mapFilename = _screenName; +	_mapFile = loadFile(_mapFilename + ".map"); +	// loadIWFile(_mapFilename); + +	objectFunc1(); +	initObjects(); + +	double num = _room->readRdfWord(0x0c) - _room->readRdfWord(0x0a); +	double den = _room->readRdfWord(0x06) - _room->readRdfWord(0x08) + 1; +	_playerObjectScale = (int32)(num * 256 / den); + +	// TODO: RDF vars 1e/1f and 20/21; relates to BAN files? + +	_commandQueue.clear(); +} + +void StarTrekEngine::initAwayCrewPositions(int warpEntryIndex) { +	_sound->stopAllVocSounds(); + +	memset(_awayMission.field25, 0xff, 4); + +	switch (warpEntryIndex) { +	case 0: +		break; +	case 1: +		break; +	case 2: +		break; +	case 3: +		break; +	case 4: // Crew is beaming in. +		warpEntryIndex -= 4; +		for (int i = 0; i < (_awayMission.redshirtDead ? 3 : 4); i++) { +			Common::String animFilename = getCrewmanAnimFilename(i, "tele"); +			Common::Point warpPos = _room->getBeamInPosition(i); +			loadObjectAnimWithRoomScaling(i, animFilename, warpPos.x, warpPos.y); +		} +		_kirkObject->field64 = 1; +		_kirkObject->field66 = 0xff; +		_awayMission.field1d = 1; +		playSoundEffectIndex(0x09); +		// word_466f2 = 0; +		break; +	case 5: +		break; +	case 6: +		break; +	} +} + +void StarTrekEngine::handleAwayMissionEvents() { +	TrekEvent event; + +	if (popNextEvent(&event)) { +		switch (event.type) { +		case TREKEVENT_TICK: +			updateObjectAnimations(); +			// sub_236bb(); +			// sub_2325d(); +			// doSomethingWithBanData1(); +			_gfx->drawAllSprites(); +			// doSomethingWithBanData2(); +			// updateMusic(); // Is this needed? +			// sub_22de0(); +			_frameIndex++; +			_roomFrameCounter++; +			// sub_20099(0, _roomFrameCounter & 0xff, (_roomFrameCounter >> 8) & 0xff, 0); +			if (_roomFrameCounter >= 2) +				_gfx->incPaletteFadeLevel(); +			break; +		case TREKEVENT_LBUTTONDOWN: +			if (_awayMission.field1d != 0) +				break; +			switch (_awayMission.mapFileLoaded) { +			case 0: +				if (_awayMission.field1c == 0) { +					_kirkObject->sprite.drawMode = 1; // Hide these objects for function call below? +					_spockObject->sprite.drawMode = 1; +					_mccoyObject->sprite.drawMode = 1; +					_redshirtObject->sprite.drawMode = 1; + +					// findObjectClickedOn(); +					// ... + +					_kirkObject->sprite.drawMode = 0; +					_spockObject->sprite.drawMode = 0; +					_mccoyObject->sprite.drawMode = 0; +					_redshirtObject->sprite.drawMode = 0; + +					Common::String animFilename = getCrewmanAnimFilename(0, "walk"); +					Common::Point mousePos = _gfx->getMousePos(); +					// objectWalkToPosition(0, animFilename, _kirkObject->pos.x, _kirkObject->pos.y, mousePos.x, mousePos.y); +				} +				break; +			case 1: +				break; +			case 2: +				break; +			case 3: +				break; +			case 4: +				break; +			case 5: +				break; +			} +			break; +		case TREKEVENT_MOUSEMOVE: +			break; +		case TREKEVENT_RBUTTONDOWN: +			break; +		case TREKEVENT_KEYDOWN: +			break; +		default: +			break; +		} +	} +} + +/** + * Similar to loadObjectAnim, but scale is determined by the y-position in the room. The + * further up (away) the object is, the smaller it is. + */ +int StarTrekEngine::loadObjectAnimWithRoomScaling(int objectIndex, const Common::String &animName, int16 x, int16 y) { +	uint16 scale = getObjectScaleAtPosition(y); +	return loadObjectAnim(objectIndex, animName, x, y, scale); +} + +uint16 StarTrekEngine::getObjectScaleAtPosition(int16 y) { +	int16 var06 = _room->getVar06(); +	int16 var08 = _room->getVar08(); +	int16 var0a = _room->getVar0a(); + +	if (var06 < y) +		y = var06; +	if (var08 > y) +		y = var08; + +	return ((_playerObjectScale * (y - var08)) >> 8) + var0a; +} + +Room *StarTrekEngine::getRoom() { +	return _room; +} + +void StarTrekEngine::runAwayMissionCycle() { +} + +} diff --git a/engines/startrek/awaymission.h b/engines/startrek/awaymission.h new file mode 100644 index 0000000000..290e5e39f5 --- /dev/null +++ b/engines/startrek/awaymission.h @@ -0,0 +1,40 @@ +/* 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_AWAYMISSION_H +#define STARTREK_AWAYMISSION_H + +// All variables here get cleared to 0 upon starting an away mission. +struct AwayMission { +	int16 mouseX; +	int16 mouseY; +	byte field1c; +	byte field1d; +	bool redshirtDead; +	byte mapFileLoaded; +	int8 field25[4]; + +	bool rdfRunNextCommand; +}; +// Size: 0x129 bytes + +#endif diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index c94d9f7b1f..2a9902560e 100644 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -44,8 +44,6 @@ Graphics::Graphics(StarTrekEngine *vm) : _vm(vm), _egaMode(false) {  	if (_vm->getGameType() == GType_ST25 && _vm->getPlatform() == Common::kPlatformDOS)  		_font = new Font(_vm); -	_backgroundImage = loadBitmap("DEMON0"); -  	_numSprites = 0;  	_textDisplayMode = TEXTDISPLAY_WAIT;  	_textboxVar2 = 0; @@ -142,7 +140,22 @@ void Graphics::setPaletteFadeLevel(byte *palData, int fadeLevel) {  	_vm->_system->updateScreen();  } -void Graphics::loadPri(const char *priFile) { +void Graphics::incPaletteFadeLevel() { +	if (_paletteFadeLevel < 100) { +		_paletteFadeLevel += 10; +		setPaletteFadeLevel(_palData, _paletteFadeLevel); +	} +} + +void Graphics::decPaletteFadeLevel() { +	if (_paletteFadeLevel > 0) { +		_paletteFadeLevel -= 10; +		setPaletteFadeLevel(_palData, _paletteFadeLevel); +	} +} + + +void Graphics::loadPri(const Common::String &priFile) {  	SharedPtr<Common::SeekableReadStream> priStream = _vm->loadFile(priFile);  	priStream->read(_priData, SCREEN_WIDTH * SCREEN_HEIGHT / 2);  } @@ -468,6 +481,10 @@ void Graphics::delSprite(Sprite *sprite) {  } +void Graphics::copyBackgroundScreen() { +	drawDirectToScreen(_backgroundImage); +} +  void Graphics::drawDirectToScreen(SharedPtr<Bitmap> bitmap) {  	int xoffset = bitmap->xoffset;  	int yoffset = bitmap->yoffset; diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h index c50a39fdb5..f7d94020d9 100644 --- a/engines/startrek/graphics.h +++ b/engines/startrek/graphics.h @@ -76,8 +76,10 @@ public:  	void fadeinScreen();  	void fadeoutScreen();  	void setPaletteFadeLevel(byte *palData, int fadeLevel); +	void incPaletteFadeLevel(); +	void decPaletteFadeLevel(); -	void loadPri(const char *priFile); +	void loadPri(const Common::String &priFile);  	void clearPri();  	byte getPriValue(int x, int y); @@ -94,6 +96,7 @@ public:  	void delSprite(Sprite *sprite); +	void copyBackgroundScreen();  	void drawDirectToScreen(SharedPtr<Bitmap> bitmap);  	void loadEGAData(const char *egaFile);  	void drawBackgroundImage(const char *filename); @@ -106,7 +109,7 @@ private:  	byte *_egaData;  	byte *_palData;  	byte *_lutData; -	byte _priData[SCREEN_WIDTH*SCREEN_HEIGHT / 2]; +	byte _priData[SCREEN_WIDTH * SCREEN_HEIGHT / 2];  	int16 _paletteFadeLevel; diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk index 3b93fbc439..b79126a794 100644 --- a/engines/startrek/module.mk +++ b/engines/startrek/module.mk @@ -1,6 +1,7 @@  MODULE := engines/startrek  MODULE_OBJS = \ +	awaymission.o \  	bitmap.o \  	common.o \  	detection.o \ diff --git a/engines/startrek/object.h b/engines/startrek/object.h index 41bf1f96c2..d9b16da875 100644 --- a/engines/startrek/object.h +++ b/engines/startrek/object.h @@ -44,7 +44,7 @@ struct Object {  	uint16 numAnimFrames;  	uint16 animFrame;  	uint32 frameToStartNextAnim; -	uint16 field5e; +	Common::Point pos;  	uint16 field60;  	uint16 field62;  	uint16 field64; @@ -67,7 +67,8 @@ struct Object {  	uint16 field8c;  	uint16 field8e;  	uint16 field90; -	uint16 field92; +	byte field92; +	char direction; // Can 'n', 's', 'e', 'w', or 0 for uninitialized?  	uint16 field94;  	uint16 field96;  	char animationString[9]; diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index a68737454f..8cef65d13a 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -46,4 +46,9 @@ uint16 Room::readRdfWord(int offset) {  	return _rdfData[offset] | (_rdfData[offset+1]<<8);  } +Common::Point Room::getBeamInPosition(int crewmanIndex) { +	int base = 0xaa + crewmanIndex * 4; +	return Common::Point(readRdfWord(base), readRdfWord(base + 2)); +} +  } diff --git a/engines/startrek/room.h b/engines/startrek/room.h index afe366b8de..a06d2af94f 100644 --- a/engines/startrek/room.h +++ b/engines/startrek/room.h @@ -17,11 +17,13 @@   * 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" @@ -38,8 +40,17 @@ public:  	Room(StarTrekEngine *vm, Common::String name);  	~Room(); +	// Helper stuff for RDF access  	uint16 readRdfWord(int offset); +	// Scale-related stuff (rename these later) +	int16 getVar06() { return readRdfWord(0x06); } +	int16 getVar08() { return readRdfWord(0x08); } +	int16 getVar0a() { return readRdfWord(0x0a); } +	int16 getVar0c() { return readRdfWord(0x0c); } + +	Common::Point getBeamInPosition(int crewmanIndex); +  	byte *_rdfData;  private: diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 7c3f728518..346cb91081 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -55,8 +55,6 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam  	_macResFork = nullptr;  	_room = nullptr; -	_redshirtDead = false; -  	_clockTicks = 0;  	_musicEnabled = true; @@ -70,6 +68,9 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam  	_keyboardControlsMouse = true;  	_inQuitGameMenu = false; + +	_missionToLoad = "DEMON"; +	_roomIndexToLoad = 0;  }  StarTrekEngine::~StarTrekEngine() { @@ -140,11 +141,11 @@ Common::Error StarTrekEngine::runGameMode(int mode) {  			// Cleanup previous game mode  			switch (_lastGameMode) {  			case GAMEMODE_BRIDGE: -				//cleanupBridgeMode(); +				//cleanupBridge();  				break;  			case GAMEMODE_AWAYMISSION: -				//cleanupAwayMissionMode(); +				cleanupAwayMission();  				break;  			case GAMEMODE_BEAMDOWN: @@ -162,11 +163,11 @@ Common::Error StarTrekEngine::runGameMode(int mode) {  				break;  			case GAMEMODE_AWAYMISSION: -				//initAwayMission(); +				initAwayMission();  				break;  			case GAMEMODE_BEAMDOWN: -				_redshirtDead = false; +				_awayMission.redshirtDead = false;  				_sound->loadMusicFile("ground");  				runTransportSequence("teled");  				_gameMode = GAMEMODE_AWAYMISSION; @@ -190,9 +191,7 @@ Common::Error StarTrekEngine::runGameMode(int mode) {  			break;  		case GAMEMODE_AWAYMISSION: -			popNextEvent(&event); -			_system->updateScreen(); -			//runAwayMission(); +			runAwayMission();  			break;  		case GAMEMODE_BEAMDOWN: @@ -225,29 +224,29 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {  	_gfx->drawDirectToScreen(bgImage);  	_system->updateScreen(); -	for (int i = 0; i < (_redshirtDead ? 3 : 4); i++) { +	for (int i = 0; i < (_awayMission.redshirtDead ? 3 : 4); i++) {  		Common::String filename = getCrewmanAnimFilename(i, name);  		int x = crewmanTransportPositions[i][0];  		int y = crewmanTransportPositions[i][1]; -		loadAnimationForObject(i, filename, x, y, 256); +		loadObjectAnim(i, filename, x, y, 256);  		_objectList[i].animationString[0] = '\0';  	}  	if (_missionToLoad.equalsIgnoreCase("feather") && name[4] == 'b') { -		loadAnimationForObject(9, "qteleb", 0x61, 0x79, 0x100); +		loadObjectAnim(9, "qteleb", 0x61, 0x79, 0x100);  	}  	else if (_missionToLoad.equalsIgnoreCase("trial")) {  		if (name[4] == 'd') { -			loadAnimationForObject(9, "qteled", 0x61, 0x79, 0x100); +			loadObjectAnim(9, "qteled", 0x61, 0x79, 0x100);  		}  		/* TODO  		else if (word_51156 >= 3) { -			loadAnimationForObject(9, "qteleb", 0x61, 0x79, 0x100); +			loadObjectAnim(9, "qteleb", 0x61, 0x79, 0x100);  		}  		*/  	} -	loadAnimationForObject(8, "transc", 0, 0, 0x100); +	loadObjectAnim(8, "transc", 0, 0, 0x100);  	// TODO: redraw mouse and sprite_52c4e? @@ -281,10 +280,6 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {  	initObjects();  } -Room *StarTrekEngine::getRoom() { -	return _room; -} -  void StarTrekEngine::playSoundEffectIndex(int index) {  	switch (index) {  	case 0x04: @@ -358,7 +353,10 @@ void StarTrekEngine::initObjects() {  	strcpy(_redshirtObject->animationString, "rstnd");  } -int StarTrekEngine::loadAnimationForObject(int objectIndex, const Common::String &animName, uint16 x, uint16 y, uint16 scale) { +/** + * Set an object's animation, position, and scale. + */ +int StarTrekEngine::loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, uint16 scale) {  	debugC(6, kDebugGraphics, "Load animation '%s' on object %d", animName.c_str(), objectIndex);  	Object *object; @@ -412,10 +410,8 @@ void StarTrekEngine::updateObjectAnimations() {  				if (object->animFrame >= object->numAnimFrames) {  					if (object->animationString[0] == '\0')  						removeObjectFromScreen(i); -					/* -					else // TODO +					else  						initStandAnim(i); -						*/  				}  				else {  					Sprite *sprite = &object->sprite; @@ -434,9 +430,9 @@ void StarTrekEngine::updateObjectAnimations() {  					uint16 basePriority = object->animFile->readUint16();  					uint16 frames = object->animFile->readUint16(); -					sprite->pos.x = xOffset + object->field5e; -					sprite->pos.y = yOffset + object->field60; -					sprite->drawPriority = _gfx->getPriValue(0, yOffset + object->field60) + basePriority; +					sprite->pos.x = xOffset + object->pos.x; +					sprite->pos.y = yOffset + object->pos.y; +					sprite->drawPriority = _gfx->getPriValue(0, yOffset + object->pos.y) + basePriority;  					sprite->bitmapChanged = true;  					object->frameToStartNextAnim = frames + _frameIndex; @@ -491,8 +487,8 @@ void StarTrekEngine::drawObjectToScreen(Object *object, const Common::String &_a  	object->animFile = loadFile(animFilename + ".anm");  	object->numAnimFrames = object->animFile->size() / 22;  	object->animFrame = 0; -	object->field5e = x; -	object->field60 = y; +	object->pos.x = x; +	object->pos.y = y;  	object->field62 = 0;  	object->scale = scale; @@ -518,9 +514,9 @@ void StarTrekEngine::drawObjectToScreen(Object *object, const Common::String &_a  	uint16 yOffset = object->animFile->readUint16();  	uint16 basePriority = object->animFile->readUint16(); -	sprite->pos.x = xOffset + object->field5e; -	sprite->pos.y = yOffset + object->field60; -	sprite->drawPriority = _gfx->getPriValue(0, yOffset + object->field60) + basePriority; +	sprite->pos.x = xOffset + object->pos.x; +	sprite->pos.y = yOffset + object->pos.y; +	sprite->drawPriority = _gfx->getPriValue(0, yOffset + object->pos.y) + basePriority;  	sprite->bitmapChanged = true;  	object->spriteDrawn = 1; @@ -537,13 +533,44 @@ void StarTrekEngine::releaseAnim(Object *object) {  		warning("Unimplemented anim type %d", object->animType);  		break;  	default: -		error("Invalid anim type."); +		error("Invalid anim type");  		break;  	}  	object->spriteDrawn = 0;  } +void StarTrekEngine::initStandAnim(int objectIndex) { +	Object *object = &_objectList[objectIndex]; + +	if (!object->spriteDrawn) +		error("initStandAnim: dead anim"); + +	//////////////////// +	// sub_239d2 +	const char *directions = "nsew"; + +	if (objectIndex >= 0 && objectIndex <= 3) { +		int8 dir = _awayMission.field25[objectIndex]; +		if (dir != -1) { +			object->direction = directions[dir]; +			_awayMission.field25[objectIndex] = -1; +		} +	} +	// end of sub_239d2 +	//////////////////// + +	Common::String animName; +	if (object->direction != 0) +		animName = Common::String(object->animationString) + (char)object->direction; +	else // Default to facing south +		animName = Common::String(object->animationString) + 's'; + +	uint16 scale = getObjectScaleAtPosition(object->pos.y); +	loadObjectAnim(objectIndex, animName, object->pos.x, object->pos.y, scale); +	object->animType = 0; +} +  SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, uint16 scale) {  	SharedPtr<Bitmap> bitmapToReturn; @@ -581,13 +608,13 @@ SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filen  				// Change uniform color  				int16 colorShift;  				switch (c) { -				case 'k': +				case 'k': // Kirk  					colorShift = 8;  					break; -				case 'r': +				case 'r': // Redshirt  					colorShift = -8;  					break; -				case 's': +				case 's': // Spock  					colorShift = 0;  					break;  				} @@ -727,6 +754,7 @@ SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, uint16 s  }  /** + * This takes a row of an unscaled bitmap, and copies it to a row of a scaled bitmap.   * This was heavily optimized in the original game (manually constructed an unrolled   * loop).   */ diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index 67c2c8080f..52157f4a0c 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -17,6 +17,7 @@   * 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_H @@ -34,6 +35,7 @@  #include "engines/engine.h" +#include "startrek/awaymission.h"  #include "startrek/filestream.h"  #include "startrek/graphics.h"  #include "startrek/object.h" @@ -95,6 +97,18 @@ struct TrekEvent {  	uint32 tick;  }; +enum Commands { +	COMMAND_TICK = 0, +	COMMAND_CLICKED_ON_OBJECT +}; + +struct Command { +	byte type; +	byte b1; // These depend on command type? +	byte b2; +	byte b3; +}; +  const int MAX_OBJECTS = 0x20;  struct StarTrekGameDescription; @@ -108,6 +122,23 @@ protected:  private:  	// Game modes  	Common::Error runGameMode(int mode); + +	// Away missions +	void initAwayMission(); +	void runAwayMission(); +	void cleanupAwayMission(); +	void loadRoom(const Common::String &missionName, int roomIndex); +	void initAwayCrewPositions(int warpEntryIndex); +	void handleAwayMissionEvents(); +	int loadObjectAnimWithRoomScaling(int objectIndex, const Common::String &animName, int16 x, int16 y); +	uint16 getObjectScaleAtPosition(int16 y); +	void runAwayMissionCycle(); + +public: +	Room *getRoom(); + +private: +	// Transporter room  	void runTransportSequence(const Common::String &name);  public: @@ -115,20 +146,20 @@ public:  	virtual ~StarTrekEngine();  	// Running the game -	Room *getRoom(); -  	void playSoundEffectIndex(int index);  	void playSpeech(const Common::String &filename);  	void stopPlayingSpeech();  	// Objects  	void initObjects(); -	int loadAnimationForObject(int objectIndex, const Common::String &animName, uint16 x, uint16 y, uint16 arg8); +	int loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, uint16 arg8); +	bool objectWalkToPosition(int objectIndex, Common::Point src, Common::Point dest);  	void updateObjectAnimations();  	void removeObjectFromScreen(int objectIndex);  	void objectFunc1();  	void drawObjectToScreen(Object *object, const Common::String &animName, uint16 field5e, uint16 field60, uint16 arg8, bool addSprite);  	void releaseAnim(Object *object); +	void initStandAnim(int objectIndex);  	SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, uint16 arg2);  	Common::String getCrewmanAnimFilename(int objectIndex, const Common::String &basename); @@ -179,8 +210,21 @@ public:  public:  	int _gameMode;  	int _lastGameMode; -	bool _redshirtDead; +  	Common::String _missionToLoad; +	int _roomIndexToLoad; + +	Common::String _missionName; +	int _roomIndex; +	Common::String _screenName; // _screenName = _missionName + _roomIndex +	Common::String _mapFilename; // Similar to _screenName, but used for .map files? +	SharedPtr<FileStream> _mapFile; +	int32 _playerObjectScale; + +	// Queue of "commands" (ie. next frame, clicked on object) for away mission or bridge +	Common::Queue<Command> _commandQueue; + +	AwayMission _awayMission;  	Object _objectList[MAX_OBJECTS];  	Object * const _kirkObject; @@ -196,6 +240,7 @@ public:  	// Updates 18.206 times every second.  	uint32 _clockTicks;  	uint32 _frameIndex; +	uint32 _roomFrameCounter; // Resets to 0 on loading a room  	bool _musicEnabled;  	bool _sfxEnabled;  | 
