Skip to content

Commit

Permalink
CHEWY: Initial work on game videos
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Oct 2, 2016
1 parent b60f502 commit f017940
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
31 changes: 31 additions & 0 deletions engines/chewy/console.cpp
Expand Up @@ -37,6 +37,8 @@ Console::Console(ChewyEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("play_sound", WRAP_METHOD(Console, Cmd_PlaySound));
registerCmd("play_speech", WRAP_METHOD(Console, Cmd_PlaySpeech));
registerCmd("play_music", WRAP_METHOD(Console, Cmd_PlayMusic));
registerCmd("play_video", WRAP_METHOD(Console, Cmd_PlayVideo));
registerCmd("video_info", WRAP_METHOD(Console, Cmd_VideoInfo));
registerCmd("text", WRAP_METHOD(Console, Cmd_Text));
}

Expand Down Expand Up @@ -149,6 +151,35 @@ bool Console::Cmd_PlayMusic(int argc, const char **argv) {
return true;
}

bool Console::Cmd_PlayVideo(int argc, const char **argv) {
if (argc < 2) {
debugPrintf("Usage: play_video <number>\n");
return true;
}

int resNum = atoi(argv[1]);
debugPrintf("TODO: Play video %d", resNum);
// TODO

return true;
}

bool Console::Cmd_VideoInfo(int argc, const char **argv) {
if (argc < 2) {
debugPrintf("Usage: video_info <number>\n");
return true;
}

int resNum = atoi(argv[1]);
VideoResource *res = new VideoResource("cut.tap");
VideoChunk *header = res->getVideoHeader(resNum);
debugPrintf("Size: %d, %d x %d, %d frames, %d ms frame delay, first frame at %d\n", header->size, header->width, header->height, header->frameCount, header->frameDelay, header->firstFrameOffset);
delete header;
delete res;

return true;
}

bool Console::Cmd_Text(int argc, const char **argv) {
if (argc < 2) {
debugPrintf("Usage: <file> <text number>\n");
Expand Down
2 changes: 2 additions & 0 deletions engines/chewy/console.h
Expand Up @@ -43,6 +43,8 @@ class Console : public GUI::Debugger {
bool Cmd_PlaySound(int argc, const char **argv);
bool Cmd_PlaySpeech(int argc, const char **argv);
bool Cmd_PlayMusic(int argc, const char **argv);
bool Cmd_PlayVideo(int argc, const char **argv);
bool Cmd_VideoInfo(int argc, const char **argv);
bool Cmd_Text(int argc, const char **argv);
};

Expand Down
21 changes: 21 additions & 0 deletions engines/chewy/resource.cpp
Expand Up @@ -226,4 +226,25 @@ Common::String TextResource::getText(uint num) {
return str;
}

VideoChunk *VideoResource::getVideoHeader(uint num) {
assert(num < _chunkList.size());

Chunk *chunk = &_chunkList[num];
VideoChunk *vid = new VideoChunk();

_stream.seek(chunk->pos, SEEK_SET);

if (_stream.readUint32BE() != MKTAG('C', 'F', 'O', '\0'))
error("Corrupt video resource");

vid->size = _stream.readUint32LE(); // always 0
vid->frameCount = _stream.readUint16LE();
vid->width = _stream.readUint16LE();
vid->height = _stream.readUint16LE();
vid->frameDelay = _stream.readUint32LE();
vid->firstFrameOffset = _stream.readUint32LE(); // always 22

return vid;
}

} // End of namespace Chewy
21 changes: 20 additions & 1 deletion engines/chewy/resource.h
Expand Up @@ -94,6 +94,17 @@ struct SoundChunk {
byte *data;
};

// Video chunk header
struct VideoChunk {
// ID (CFA, followed by a zero)
uint32 size;
uint16 frameCount;
uint16 width;
uint16 height;
uint32 frameDelay; // in ms
uint32 firstFrameOffset;
};

typedef Common::Array<Chunk> ChunkList;
typedef Common::Array<TBFChunk> TBFChunkList;

Expand All @@ -111,7 +122,7 @@ class Resource {
Common::File _stream;
uint16 _chunkCount;
ResourceType _resType;
byte _encrypted;
bool _encrypted;

ChunkList _chunkList;
};
Expand Down Expand Up @@ -140,6 +151,14 @@ class TextResource : public Resource {
Common::String getText(uint num);
};

class VideoResource : public Resource {
public:
VideoResource(Common::String filename) : Resource(filename) {}
~VideoResource() {}

VideoChunk *getVideoHeader(uint num);
};

} // End of namespace Chewy

#endif

0 comments on commit f017940

Please sign in to comment.