diff options
-rw-r--r-- | engines/chewy/console.cpp | 31 | ||||
-rw-r--r-- | engines/chewy/console.h | 2 | ||||
-rw-r--r-- | engines/chewy/resource.cpp | 21 | ||||
-rw-r--r-- | engines/chewy/resource.h | 21 |
4 files changed, 74 insertions, 1 deletions
diff --git a/engines/chewy/console.cpp b/engines/chewy/console.cpp index 8d55651ffc..bf7e49c2d0 100644 --- a/engines/chewy/console.cpp +++ b/engines/chewy/console.cpp @@ -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)); } @@ -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"); diff --git a/engines/chewy/console.h b/engines/chewy/console.h index bca8ea0b6a..ab8b8de60a 100644 --- a/engines/chewy/console.h +++ b/engines/chewy/console.h @@ -43,6 +43,8 @@ private: 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); }; diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp index eae3896826..6a1b860d5b 100644 --- a/engines/chewy/resource.cpp +++ b/engines/chewy/resource.cpp @@ -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 diff --git a/engines/chewy/resource.h b/engines/chewy/resource.h index cfaa802834..238f0f2b60 100644 --- a/engines/chewy/resource.h +++ b/engines/chewy/resource.h @@ -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; @@ -111,7 +122,7 @@ protected: Common::File _stream; uint16 _chunkCount; ResourceType _resType; - byte _encrypted; + bool _encrypted; ChunkList _chunkList; }; @@ -140,6 +151,14 @@ public: 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 |