DIRECTOR: Add "info" command to debugger

This commit is contained in:
Scott Percival 2023-03-04 14:23:39 +08:00 committed by Eugene Sandulenko
parent 06eba975b2
commit 570bbfb7f1
9 changed files with 89 additions and 7 deletions

View File

@ -246,6 +246,15 @@ void Archive::dumpChunk(Resource &res, Common::DumpFile &out) {
free(data);
}
Common::String Archive::formatArchiveInfo() {
Common::String result = "unknown, ";
if (_isBigEndian)
result += "big endian,";
else
result += "little endian, ";
return result;
}
// Mac Archive code
MacArchive::MacArchive() : Archive(), _resFork(nullptr) {
@ -353,6 +362,15 @@ Common::SeekableReadStreamEndian *MacArchive::getResource(uint32 tag, uint16 id)
return new Common::SeekableReadStreamEndianWrapper(stream, true, DisposeAfterUse::YES);
}
Common::String MacArchive::formatArchiveInfo() {
Common::String result = "Mac resource fork, ";
if (_isBigEndian)
result += "big endian";
else
result += "little endian";
return result;
}
// RIFF Archive code
bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOffset) {
@ -472,6 +490,15 @@ Common::SeekableReadStreamEndian *RIFFArchive::getResource(uint32 tag, uint16 id
return new Common::SeekableReadStreamEndianWrapper(stream, true, DisposeAfterUse::YES);
}
Common::String RIFFArchive::formatArchiveInfo() {
Common::String result = "RIFF, ";
if (_isBigEndian)
result += "big endian";
else
result += "little endian";
return result;
}
// RIFX Archive code
RIFXArchive::RIFXArchive() : Archive() {
@ -979,4 +1006,15 @@ Resource RIFXArchive::getResourceDetail(uint32 tag, uint16 id) {
return resMap[id];
}
Common::String RIFXArchive::formatArchiveInfo() {
Common::String result = "RIFX, ";
if (_isBigEndian)
result += "big endian, ";
else
result += "little endian, ";
result += "type ";
result += tag2str(_rifxType);
return result;
}
} // End of namespace Director

View File

@ -76,6 +76,8 @@ public:
bool _isBigEndian;
static uint32 convertTagToUppercase(uint32 tag);
virtual Common::String formatArchiveInfo();
protected:
void dumpChunk(Resource &res, Common::DumpFile &out);
Common::SeekableReadStream *_stream;
@ -97,6 +99,7 @@ public:
bool openFile(const Common::String &fileName) override;
bool openStream(Common::SeekableReadStream *stream, uint32 startOffset = 0) override;
Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id) override;
Common::String formatArchiveInfo() override;
private:
Common::MacResManager *_resFork;
@ -111,6 +114,7 @@ public:
bool openStream(Common::SeekableReadStream *stream, uint32 startOffset = 0) override;
Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id) override;
Common::String formatArchiveInfo() override;
uint32 _startOffset;
};
@ -126,6 +130,7 @@ public:
Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id) override;
virtual Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id, bool fileEndianness);
Resource getResourceDetail(uint32 tag, uint16 id) override;
Common::String formatArchiveInfo() override;
private:
bool readMemoryMap(Common::SeekableReadStreamEndian &stream, uint32 moreOffset, Common::SeekableMemoryWriteStream *dumpStream, uint32 movieStartOffset);

View File

@ -62,6 +62,8 @@ Cast::Cast(Movie *movie, uint16 castLibID, bool isShared) {
_version = 0;
_platform = Common::kPlatformMacintosh;
_isProtected = false;
_stageColor = 0;
_loadedStxts = nullptr;
@ -357,6 +359,7 @@ bool Cast::loadConfig() {
_platform = platformFromID(platform);
int16 protection = stream->readSint16();
_isProtected = (protection % 23) == 0;
/* int32 field29 = */ stream->readSint32();
uint32 checksum = stream->readUint32();

View File

@ -143,6 +143,8 @@ public:
FontXPlatformMap _fontXPlatformMap;
FontMap _fontMap;
bool _isProtected;
Common::HashMap<int, CastMember *> *_loadedCast;
Common::HashMap<int, const Stxt *> *_loadedStxts;
uint16 _castIDoffset;

View File

@ -20,6 +20,7 @@
*/
#include "common/language.h"
#include "common/platform.h"
#include "director/director.h"
#include "director/debugger.h"
#include "director/cast.h"
@ -46,6 +47,7 @@ Debugger::Debugger(): GUI::Debugger() {
registerCmd("help", WRAP_METHOD(Debugger, cmdHelp));
registerCmd("version", WRAP_METHOD(Debugger, cmdVersion));
registerCmd("info", WRAP_METHOD(Debugger, cmdInfo));
registerCmd("movie", WRAP_METHOD(Debugger, cmdMovie));
registerCmd("m", WRAP_METHOD(Debugger, cmdMovie));
registerCmd("frame", WRAP_METHOD(Debugger, cmdFrame));
@ -141,8 +143,8 @@ bool Debugger::cmdHelp(int argc, const char **argv) {
debugPrintf("--------\n");
debugPrintf("Player:\n");
debugPrintf(" version - Shows the Director version\n");
debugPrintf(" info - Shows information about the current movie\n");
debugPrintf(" movie / m [moviePath] - Get or sets the current movie\n");
//debugPrintf(" movieinfo / mi - Show information for the current movie\n");
debugPrintf(" frame / f [frameNum] - Gets or sets the current score frame\n");
debugPrintf(" channels / chan [frameNum] - Shows channel information for a score frame\n");
debugPrintf(" cast [castNum] - Shows the cast list or castNum for the current movie\n");
@ -205,6 +207,32 @@ bool Debugger::cmdVersion(int argc, const char **argv) {
return true;
}
bool Debugger::cmdInfo(int argc, const char **argv) {
Movie *movie = g_director->getCurrentMovie();
Score *score = movie->getScore();
Archive *archive = movie->getArchive();
Cast *cast = movie->getCast();
debugPrintf("Movie path: %s\n", archive->getPathName().c_str());
debugPrintf("Movie file size: %d\n", archive->getFileSize());
debugPrintf("Movie archive format: %s\n", archive->formatArchiveInfo().c_str());
debugPrintf("Movie platform: %s (%s)\n", Common::getPlatformCode(movie->_platform), Common::getPlatformDescription(movie->_platform));
debugPrintf("Movie format version: 0x%x\n", movie->_version);
debugPrintf("Created by: %s\n", movie->_createdBy.c_str());
debugPrintf("Modified by: %s\n", movie->_changedBy.c_str());
debugPrintf("Original directory: %s\n", movie->_origDirectory.c_str());
debugPrintf("Stage size: %dx%d\n", movie->_movieRect.width(), movie->_movieRect.height());
debugPrintf("Default palette ID: %d\n", cast->_defaultPalette);
debugPrintf("Default stage color: %d\n", cast->_stageColor);
debugPrintf("Copy protected: %d\n", cast->_isProtected);
debugPrintf("Remap palettes when needed flag: %d\n", movie->_remapPalettesWhenNeeded);
debugPrintf("Allow outdated Lingo flag: %d\n", movie->_allowOutdatedLingo);
debugPrintf("Frame count: %d\n", score->_frames.size());
debugPrintf("Cast member count: %d\n", cast->getCastSize());
debugPrintf("\n");
return true;
}
bool Debugger::cmdFrame(int argc, const char **argv) {
Lingo *lingo = g_director->getLingo();
Score *score = g_director->getCurrentMovie()->getScore();

View File

@ -125,6 +125,7 @@ private:
bool cmdHelp(int argc, const char **argv);
bool cmdVersion(int argc, const char **argv);
bool cmdInfo(int argc, const char **argv);
bool cmdMovie(int argc, const char **argv);
bool cmdFrame(int argc, const char **argv);
bool cmdChannels(int argc, const char **argv);

View File

@ -22,6 +22,7 @@
#include "common/config-manager.h"
#include "common/substream.h"
#include "director/types.h"
#include "engines/util.h"
#include "graphics/macgui/macwindowmanager.h"
@ -68,6 +69,7 @@ Movie::Movie(Window *window) {
_version = 0;
_platform = Common::kPlatformMacintosh;
_allowOutdatedLingo = false;
_remapPalettesWhenNeeded = false;
_movieArchive = nullptr;
@ -244,6 +246,7 @@ void Movie::loadFileInfo(Common::SeekableReadStreamEndian &stream) {
InfoEntries fileInfo = Movie::loadInfoEntries(stream, _version);
_allowOutdatedLingo = (fileInfo.flags & kMovieFlagAllowOutdatedLingo) != 0;
_remapPalettesWhenNeeded = (fileInfo.flags & kMovieFlagRemapPalettesWhenNeeded) != 0;
_script = fileInfo.strings[0].readString(false);
@ -255,7 +258,7 @@ void Movie::loadFileInfo(Common::SeekableReadStreamEndian &stream) {
_changedBy = fileInfo.strings[1].readString();
_createdBy = fileInfo.strings[2].readString();
_createdBy = fileInfo.strings[3].readString();
_origDirectory = fileInfo.strings[3].readString();
uint16 preload = 0;
if (fileInfo.strings[4].len) {
@ -271,7 +274,7 @@ void Movie::loadFileInfo(Common::SeekableReadStreamEndian &stream) {
debug("VWFI: script: '%s'", _script.c_str());
debug("VWFI: changed by: '%s'", _changedBy.c_str());
debug("VWFI: created by: '%s'", _createdBy.c_str());
debug("VWFI: directory: '%s'", _createdBy.c_str());
debug("VWFI: original directory: '%s'", _origDirectory.c_str());
debug("VWFI: preload: %d (0x%x)", preload, preload);
for (uint i = 5; i < fileInfo.strings.size(); i++) {

View File

@ -146,6 +146,10 @@ public:
uint32 _stageColor;
Cast *_sharedCast;
bool _allowOutdatedLingo;
bool _remapPalettesWhenNeeded;
Common::String _createdBy;
Common::String _changedBy;
Common::String _origDirectory;
bool _videoPlayback;
@ -183,10 +187,7 @@ private:
uint32 _flags;
Common::String _macName;
Common::String _createdBy;
Common::String _changedBy;
Common::String _script;
Common::String _directory;
bool _mouseDownWasInButton;
Channel *_currentDraggedChannel;

View File

@ -33,6 +33,7 @@ enum {
#define kQuirksCacheArchive "quirks"
enum MovieFlag {
kMovieFlagRemapPalettesWhenNeeded = (1 << 6),
kMovieFlagAllowOutdatedLingo = (1 << 8)
};
@ -326,7 +327,7 @@ enum ChunkType {
kChunkLine
};
enum {
enum FileVer {
kFileVer300 = 0x404,
kFileVer310 = 0x405,
kFileVer400 = 0x45B,