1 #include "innocent/movie.h"
3 #include "common/file.h"
5 #include "innocent/debug.h"
6 #include "innocent/graphics.h"
7 #include "innocent/innocent.h"
8 #include "innocent/resources.h"
13 Movie
*Movie::fromFile(const char *name
) {
14 Common::File
*f
= new Common::File
;
19 Movie::Movie(Common::ReadStream
*s
) : _f(s
) {}
25 void Movie::setFrameDelay(uint jiffies
) {
30 _s
.create(320, 200, 1);
32 debugC(4, kDebugLevelGraphics
, "creating movie");
33 while (findKeyFrame()) {
40 debugC(3, kDebugLevelGraphics
, "got %d iframes", _iFrames
);
44 if (Eng
.escapePressed())
50 bool Movie::findKeyFrame() {
51 (void) _f
->readUint32LE(); // size of block, we don't want that
52 _iFrames
= _f
->readUint16LE();
56 void Movie::loadKeyFrame() {
57 (void) _f
->readUint16LE(); // no idea what that is
60 w
= _f
->readUint16LE();
61 h
= _f
->readUint16LE();
62 assert (w
== 320 && h
== 200);
64 Resources::decodeImage(_f
, reinterpret_cast<byte
*>(_s
.pixels
), w
* h
);
66 (void) _f
->readByte();
67 Resources::readPalette(_f
, _pal
);
71 void Movie::loadIFrame() {
72 (void) _f
->readUint16LE();
75 skipB
= _f
->readByte();
76 skipW
= _f
->readByte();
78 assert(_s
.pitch
== 320);
81 byte
*dest
= reinterpret_cast<byte
*>(_s
.pixels
);
84 byte b
= _f
->readByte();
87 if (b
== skipB
&& (s
= _f
->readByte())) {
91 } else if (b
== skipW
&& (s
= _f
->readUint16LE())) {
104 void Movie::showFrame() {
105 Engine::instance()._system
->copyRectToScreen(
106 reinterpret_cast<byte
*>(_s
.pixels
), _s
.pitch
, 0, 0, _s
.w
, _s
.h
);
108 Engine::instance()._system
->updateScreen();
111 void Movie::setPalette() {
112 Graf
.setPalette(_pal
, 0, 256);
115 void Movie::delay() {
116 Engine::instance().delay(40 * (1+_delay
));
119 } // end of namespace Innocent