Skip to content

Commit

Permalink
DIRECTOR: Remove extra movie archive open
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent 44e46db commit d7f1c98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion engines/director/director.cpp
Expand Up @@ -71,7 +71,7 @@ Common::Error DirectorEngine::run() {
_mainArchive->openFile("bookshelf_example.mmm");

Common::SeekableReadStream *scr = _mainArchive->getResource(MKTAG('V','W','S','C'), 1024);
Score score(*scr);
Score score(*scr, *_mainArchive);

Common::SeekableReadStream *conf = _mainArchive->getResource(MKTAG('V','W','C','F'), 1024);
score.loadConfig(*conf);
Expand Down
17 changes: 7 additions & 10 deletions engines/director/score.cpp
Expand Up @@ -34,16 +34,16 @@

namespace Director {

Score::Score(Common::SeekableReadStream &stream) {

Score::Score(Common::SeekableReadStream &stream, Archive &movie) {
_movieArchive = &movie;
uint32 size = stream.readUint32BE();
size -= 4;
uint16 channelSize;
uint16 channelOffset;

Frame *initial = new Frame();
_frames.push_back(initial);

while (size != 0) {
uint16 frameSize = stream.readUint16BE();
size -= frameSize;
Expand Down Expand Up @@ -185,7 +185,7 @@ void Score::display() {
if (g_system->getMillis() < _nextFrameTime)
return;

_frames[_currentFrame]->display();
_frames[_currentFrame]->display(*_movieArchive);
_currentFrame++;
byte tempo = _frames[_currentFrame]->_tempo;
if (tempo) {
Expand Down Expand Up @@ -393,13 +393,10 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16
}
}

void Frame::display() {
//FIXME
RIFFArchive riff;
riff.openFile("bookshelf_example.mmm");
void Frame::display(Archive &_movie) {

DIBDecoder palette;
Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025);
Common::SeekableReadStream *pal = _movie.getResource(MKTAG('C', 'L', 'U', 'T'), 1025);
palette.loadPalette(*pal);
g_system->getPaletteManager()->setPalette(palette.getPalette(), 0, 255);

Expand All @@ -408,7 +405,7 @@ void Frame::display() {
DIBDecoder img;
//TODO check cast type
uint32 imgId = 1024 + _sprites[i]->_castId;
img.loadStream(*riff.getResource(MKTAG('D', 'I', 'B', ' '), imgId));
img.loadStream(*_movie.getResource(MKTAG('D', 'I', 'B', ' '), imgId));
uint32 regX = static_cast<BitmapCast *>(_sprites[i]->_cast)->regX;
uint32 regY = static_cast<BitmapCast *>(_sprites[i]->_cast)->regY;
uint32 rectLeft = static_cast<BitmapCast *>(_sprites[i]->_cast)->initialRect.left;
Expand Down
5 changes: 3 additions & 2 deletions engines/director/score.h
Expand Up @@ -135,7 +135,7 @@ class Frame {
~Frame();
Frame(const Frame &frame);
void readChannel(Common::SeekableReadStream &stream, uint16 offset, uint16 size);
void display();
void display(Archive &_movie);

private:
void readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 size);
Expand All @@ -160,7 +160,7 @@ class Frame {

class Score {
public:
Score(Common::SeekableReadStream &stream);
Score(Common::SeekableReadStream &stream, Archive &movie);
void readVersion(uint32 rid);
void loadConfig(Common::SeekableReadStream &stream);
void loadCastData(Common::SeekableReadStream &stream);
Expand All @@ -185,6 +185,7 @@ class Score {
bool _stopPlay;
uint16 _castArrayEnd;
Common::Rect _movieRect;
Archive *_movieArchive;
};

} //End of namespace Director

0 comments on commit d7f1c98

Please sign in to comment.