Skip to content

Commit

Permalink
DIRECTOR: Refactoring renderSprite
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 cc9d17c commit 9ba86b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 16 additions & 5 deletions engines/director/score.cpp
Expand Up @@ -328,6 +328,7 @@ void Score::loadScriptText(Common::SeekableReadStream &stream) {
}
script += ch;
}

if (script != "")
_lingo->addCode(script, kMovieScript, _movieScriptCount);

Expand Down Expand Up @@ -888,8 +889,8 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16
}

void Frame::prepareFrame(Score *score) {
renderSprites(*score->_movieArchive, *score->_surface, score->_movieRect, false);
renderSprites(*score->_movieArchive, *score->_trailSurface, score->_movieRect, true);
renderSprites(*score->_surface, false);
renderSprites(*score->_trailSurface, true);

if (_transType != 0)
//TODO Handle changing area case
Expand Down Expand Up @@ -1051,20 +1052,26 @@ void Frame::playTransition(Score *score) {
}
}

void Frame::renderSprites(Archive &_movie, Graphics::ManagedSurface &surface, Common::Rect movieRect, bool renderTrail) {
void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
for (uint16 i = 0; i < CHANNEL_COUNT; i++) {
if (_sprites[i]->_enabled) {
if ((_sprites[i]->_trails == 0 && renderTrail) || (_sprites[i]->_trails == 1 && !renderTrail))
continue;

Cast *cast = _vm->_currentScore->_casts[_sprites[i]->_castId];
if (cast->type == kCastText) {
renderText(surface, i);
continue;
}

DIBDecoder img;
uint32 imgId = 1024 + _sprites[i]->_castId;

if (!_movie.hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) {
if (!_vm->_currentScore->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) {
continue;
}

img.loadStream(*_movie.getResource(MKTAG('D', 'I', 'B', ' '), imgId));
img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId));

uint32 regX = static_cast<BitmapCast *>(_sprites[i]->_cast)->regX;
uint32 regY = static_cast<BitmapCast *>(_sprites[i]->_cast)->regY;
Expand Down Expand Up @@ -1104,6 +1111,10 @@ void Frame::renderSprites(Archive &_movie, Graphics::ManagedSurface &surface, Co
}
}

void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID) {
warning("STUB: renderText()");
}

void Frame::drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect) {
uint8 skipColor = _vm->getPaletteColorCount() - 1; //FIXME is it always white (last entry in pallette) ?

Expand Down
4 changes: 3 additions & 1 deletion engines/director/score.h
Expand Up @@ -297,7 +297,8 @@ class Frame {
private:
void playTransition(Score *score);
void playSoundChannel();
void renderSprites(Archive &_movie, Graphics::ManagedSurface &surface, Common::Rect movieRect, bool renderTrail);
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
void renderText(Graphics::ManagedSurface &surface, uint16 spriteID);
void readPaletteInfo(Common::SeekableReadStream &stream);
void readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 size);
void readMainChannels(Common::SeekableReadStream &stream, uint16 offset, uint16 size);
Expand Down Expand Up @@ -336,6 +337,7 @@ class Score {
void setStartToLabel(Common::String label);
void startLoop();
void processEvents();
Archive *getArchive() const { return _movieArchive; };

Common::String getMacName() const { return _macName; }
private:
Expand Down

0 comments on commit 9ba86b9

Please sign in to comment.