STARTREK: Further work on the ST 25th demo

This commit is contained in:
Filippos Karapetis 2020-11-17 21:23:50 +02:00
parent 082985ee82
commit bc1d661cf8
7 changed files with 85 additions and 48 deletions

View File

@ -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();
// 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;
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;
}

View File

@ -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) {

View File

@ -874,6 +874,9 @@ void StarTrekEngine::chooseMouseBitmapForAction(int action, bool withRedOutline)
"lookh3"
};
if (getFeatures() & GF_DEMO)
return;
Common::String bitmapName;
switch (action) {

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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);