[Scummvm-git-logs] scummvm master -> bc1d661cf8e5ad887f7f68e5de147fa8315090fe

bluegr bluegr at gmail.com
Tue Nov 17 19:24:34 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bc1d661cf8 STARTREK: Further work on the ST 25th demo


Commit: bc1d661cf8e5ad887f7f68e5de147fa8315090fe
    https://github.com/scummvm/scummvm/commit/bc1d661cf8e5ad887f7f68e5de147fa8315090fe
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-11-17T21:24:12+02:00

Commit Message:
STARTREK: Further work on the ST 25th demo

Changed paths:
    engines/startrek/actors.cpp
    engines/startrek/awaymission.cpp
    engines/startrek/menu.cpp
    engines/startrek/resource.cpp
    engines/startrek/room.cpp
    engines/startrek/sound.cpp
    engines/startrek/startrek.cpp


diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp
index 92cdfd4a16..199532a258 100644
--- a/engines/startrek/actors.cpp
+++ b/engines/startrek/actors.cpp
@@ -712,15 +712,18 @@ int StarTrekEngine::findObjectAt(int x, int y) {
 
 Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed8 scale) {
 	Bitmap *bitmapToReturn = nullptr;
+	bool isDemo = getFeatures() & GF_DEMO;
 
 	char basename[5];
 	strncpy(basename, filename.c_str() + 1, 4);
 	basename[4] = '\0';
 
+	char mcCoyChar = !isDemo ? 'm' : 'b';
+
 	char c = filename[0];
 	if ((strcmp(basename, "stnd") == 0 || strcmp(basename, "tele") == 0)
-	        && (c == 'm' || c == 's' || c == 'k' || c == 'r')) {
-		if (c == 'm') {
+	        && (c == mcCoyChar || c == 's' || c == 'k' || c == 'r')) {
+		if (c == mcCoyChar) {
 			// Mccoy has the "base" animations for all crewmen
 			bitmapToReturn = new Bitmap(_resource->loadBitmapFile(filename));
 		} else {
@@ -733,7 +736,9 @@ Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed
 
 			if (bitmapToReturn == nullptr) {
 				Common::String mccoyFilename = filename;
-				mccoyFilename.setChar('m', 0);
+				mccoyFilename.setChar(mcCoyChar, 0);
+				if (isDemo && mccoyFilename.hasPrefix("bstnds"))
+					mccoyFilename.setChar('m', 0);
 				Bitmap *bitmap = new Bitmap(_resource->loadBitmapFile(mccoyFilename));
 
 				uint16 width = bitmap->width;
@@ -756,6 +761,7 @@ Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed
 					colorShift = 0;
 					break;
 				case 'm': // McCoy
+				case 'b': // McCoy (demo)
 					colorShift = 0;
 					break;
 				default:
@@ -779,23 +785,26 @@ Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed
 					}
 				}
 
-				// Redraw face with xor file
-				Common::MemoryReadStreamEndian *xorFile = _resource->loadFile(filename + ".xor");
-				xorFile->seek(0, SEEK_SET);
-				uint16 xoffset = bitmap->xoffset - xorFile->readUint16();
-				uint16 yoffset = bitmap->yoffset - xorFile->readUint16();
-				uint16 xorWidth = xorFile->readUint16();
-				uint16 xorHeight = xorFile->readUint16();
-
-				byte *dest = bitmapToReturn->pixels + yoffset * bitmap->width + xoffset;
+				// Redraw face with XOR file
+				if (!isDemo) {
+					Common::MemoryReadStreamEndian *xorFile = _resource->loadFile(filename + ".xor");
+					xorFile->seek(0, SEEK_SET);
+					uint16 xoffset = bitmap->xoffset - xorFile->readUint16();
+					uint16 yoffset = bitmap->yoffset - xorFile->readUint16();
+					uint16 xorWidth = xorFile->readUint16();
+					uint16 xorHeight = xorFile->readUint16();
+
+					byte *dest = bitmapToReturn->pixels + yoffset * bitmap->width + xoffset;
+
+					for (int i = 0; i < xorHeight; i++) {
+						for (int j = 0; j < xorWidth; j++)
+							*dest++ ^= xorFile->readByte();
+						dest += (bitmap->width - xorWidth);
+					}
 
-				for (int i = 0; i < xorHeight; i++) {
-					for (int j = 0; j < xorWidth; j++)
-						*dest++ ^= xorFile->readByte();
-					dest += (bitmap->width - xorWidth);
+					delete xorFile;
 				}
 
-				delete xorFile;
 				delete bitmap;
 			}
 		}
@@ -904,7 +913,8 @@ int StarTrekEngine::selectObjectForUseAction() {
 }
 
 Common::String StarTrekEngine::getCrewmanAnimFilename(int actorIndex, const Common::String &basename) {
-	const char *crewmanChars = "ksmr";
+	bool isDemo = getFeatures() & GF_DEMO;
+	const char *crewmanChars = !isDemo ? "ksmr" : "ksbr";	// Kirk, Spock, McCoy (Bones), RedShirt
 	assert(actorIndex >= 0 && actorIndex < 4);
 	return crewmanChars[actorIndex] + basename;
 }
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp
index acb75d09fa..19c0119637 100644
--- a/engines/startrek/awaymission.cpp
+++ b/engines/startrek/awaymission.cpp
@@ -94,7 +94,9 @@ void StarTrekEngine::loadRoom(const Common::String &missionName, int roomIndex)
 
 	// Original sets up bytes 0-3 of rdf file as "remote function caller"
 
-	_room->loadMapFile(getScreenName());
+	bool isDemo = getFeatures() & GF_DEMO;
+	if (!isDemo)
+		_room->loadMapFile(getScreenName());
 
 	_awayMission.activeAction = ACTION_WALK;
 
@@ -105,14 +107,16 @@ void StarTrekEngine::loadRoom(const Common::String &missionName, int roomIndex)
 	int16 den = _room->getMaxY() - _room->getMinY() + 1;
 	_playerActorScale = Fixed16(num) / den;
 
-	int16 addr = _room->getBanDataStart();
-	while (addr != _room->getBanDataEnd()) {
-		Common::String name((char *)&_room->_rdfData[addr]);
-		loadBanFile(name);
-		addr += strlen((char *)&_room->_rdfData[addr]) + 1;
-	}
-
 	_actionQueue.clear();
+
+	if (!isDemo) {
+		int16 addr = _room->getBanDataStart();
+		while (addr != _room->getBanDataEnd()) {
+			Common::String name((char *)&_room->_rdfData[addr]);
+			loadBanFile(name);
+			addr += strlen((char *)&_room->_rdfData[addr]) + 1;
+		}
+	}
 }
 
 void StarTrekEngine::initAwayCrewPositions(int warpEntryIndex) {
diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp
index 650f213702..b260201853 100644
--- a/engines/startrek/menu.cpp
+++ b/engines/startrek/menu.cpp
@@ -874,6 +874,9 @@ void StarTrekEngine::chooseMouseBitmapForAction(int action, bool withRedOutline)
 		"lookh3"
 	};
 
+	if (getFeatures() & GF_DEMO)
+		return;
+
 	Common::String bitmapName;
 
 	switch (action) {
diff --git a/engines/startrek/resource.cpp b/engines/startrek/resource.cpp
index d705b711d2..74d17a2fb8 100644
--- a/engines/startrek/resource.cpp
+++ b/engines/startrek/resource.cpp
@@ -98,17 +98,17 @@ ResourceIndex Resource::getIndex(Common::String filename) {
 ResourceIndex Resource::getIndexEntry(Common::SeekableReadStream *indexFile) {
 	ResourceIndex index;
 
-	index.indexOffset = 0;
-	index.foundData = false;
-	index.fileCount = 1;
-	index.uncompressedSize = 0;
-
 	Common::String currentFile;
 	for (byte i = 0; i < 8; i++) {
 		char c = indexFile->readByte();
 		if (c)
 			currentFile += c;
 	}
+
+	// The demo version has an empty entry in the end
+	if (currentFile.size() == 0)
+		return index;
+
 	currentFile += '.';
 
 	// Read extension
@@ -234,18 +234,16 @@ Common::MemoryReadStreamEndian *Resource::loadFile(Common::String filename, int
 	if (!dataFile)
 		error("Could not open data file");
 
+	if (index.fileCount != 1)
+		index.indexOffset = getSequentialFileOffset(index.indexOffset, fileIndex);
+	dataFile->seek(index.indexOffset);
+
 	Common::SeekableReadStream *stream;
 	if (_isDemo && _platform == Common::kPlatformDOS) {
 		stream = dataFile->readStream(index.uncompressedSize);
 	} else {
-		if (index.fileCount != 1) {
-			index.indexOffset = getSequentialFileOffset(index.indexOffset, fileIndex);
-		}
-		dataFile->seek(index.indexOffset);
-
 		uint16 uncompressedSize = (_platform == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
 		uint16   compressedSize = (_platform == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
-
 		stream = decodeLZSS(dataFile->readStream(compressedSize), uncompressedSize);
 	}
 
diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp
index 61526ea921..1055beedde 100644
--- a/engines/startrek/room.cpp
+++ b/engines/startrek/room.cpp
@@ -114,8 +114,11 @@ Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm), _awayMissi
 		_numRoomActions = 0;
 	}
 
-	loadRoomMessages();
-	loadOtherRoomMessages();
+	bool isDemo = _vm->getFeatures() & GF_DEMO;
+	if (!isDemo) {
+		loadRoomMessages();
+		loadOtherRoomMessages();
+	}
 	memset(&_roomVar, 0, sizeof(_roomVar));
 }
 
@@ -376,8 +379,14 @@ bool Room::handleActionWithBitmask(byte type, byte b1, byte b2, byte b3) {
 }
 
 Common::Point Room::getBeamInPosition(int crewmanIndex) {
-	int base = RDF_BEAM_IN_POSITIONS + crewmanIndex * 4;
-	return Common::Point(readRdfWord(base), readRdfWord(base + 2));
+	bool isDemo = _vm->getFeatures() & GF_DEMO;
+	if (!isDemo) {
+		int base = RDF_BEAM_IN_POSITIONS + crewmanIndex * 4;
+		return Common::Point(readRdfWord(base), readRdfWord(base + 2));
+	} else {
+		// TODO
+		return Common::Point(86, 158);
+	}
 }
 
 Common::Point Room::getSpawnPosition(int crewmanIndex) {
diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index 8bb0c3df52..a3460d22a5 100644
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -98,6 +98,10 @@ void Sound::playMidiTrack(int track) {
 	if (!_vm->_musicEnabled || !_vm->_musicWorking)
 		return;
 
+	// TODO: Demo music
+	if (_vm->getFeatures() & GF_DEMO)
+		return;
+
 	assert(loadedSoundData != nullptr);
 
 	// Check if a midi slot for this track exists already
@@ -147,6 +151,8 @@ bool Sound::isMidiPlaying() {
 }
 
 void Sound::loadMusicFile(const Common::String &baseSoundName) {
+	bool isDemo = _vm->getFeatures() & GF_DEMO;
+
 	clearAllMidiSlots();
 
 	if (baseSoundName == _loadedMidiFilename)
@@ -154,14 +160,14 @@ void Sound::loadMusicFile(const Common::String &baseSoundName) {
 
 	_loadedMidiFilename = baseSoundName;
 
-	if (_vm->getPlatform() == Common::kPlatformDOS) {
+	if (_vm->getPlatform() == Common::kPlatformDOS && !isDemo) {
 		loadPCMusicFile(baseSoundName);
+	} else if (_vm->getPlatform() == Common::kPlatformDOS && isDemo) {
+		//playSMFSound(baseSoundName);
 	} else if (_vm->getPlatform() == Common::kPlatformAmiga) {
 		//playAmigaSound(baseSoundName);
 	} else if (_vm->getPlatform() == Common::kPlatformMacintosh) {
 		//playMacSMFSound(baseSoundName);
-	} else if (_vm->getFeatures() & GF_DEMO) {
-		//playSMFSound(baseSoundName);
 	}
 }
 
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 009969688e..21daa8fb34 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -96,7 +96,7 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam
 	_textboxVar6 = 0;
 	_textboxHasMultipleChoices = false;
 
-	_missionToLoad = "DEMON";
+	_missionToLoad = "";
 	_roomIndexToLoad = 0;
 	_mapFile = nullptr;
 	_iwFile = nullptr;
@@ -125,7 +125,8 @@ StarTrekEngine::~StarTrekEngine() {
 }
 
 Common::Error StarTrekEngine::run() {
-	_resource = new Resource(getPlatform(), getFeatures() & GF_DEMO);
+	bool isDemo = getFeatures() & GF_DEMO;
+	_resource = new Resource(getPlatform(), isDemo);
 	_gfx = new Graphics(this);
 	_sound = new Sound(this);
 	setDebugger(new Console(this));
@@ -133,7 +134,7 @@ Common::Error StarTrekEngine::run() {
 	initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT);
 	initializeEventsAndMouse();
 
-	_gfx->setMouseBitmap("pushbtn");
+	_gfx->setMouseBitmap(!isDemo ? "pushbtn" : "cursor");
 	_gfx->toggleMouse(true);
 
 	bool loadedSave = false;
@@ -145,8 +146,14 @@ Common::Error StarTrekEngine::run() {
 	}
 
 	if (!loadedSave) {
-		playIntro();
-		runGameMode(GAMEMODE_BEAMDOWN, false);
+		if (!isDemo) {
+			playIntro();
+			_missionToLoad = "DEMON";
+			runGameMode(GAMEMODE_BEAMDOWN, false);
+		} else {
+			_missionToLoad = "DEMO";
+			runGameMode(GAMEMODE_AWAYMISSION, false);
+		}
 	} else {
 		_roomIndexToLoad = -1;
 		runGameMode(_gameMode, true);




More information about the Scummvm-git-logs mailing list