aboutsummaryrefslogtreecommitdiff
path: root/engines/director/score.cpp
diff options
context:
space:
mode:
authorDmitry Iskrich2016-05-27 20:29:10 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commitce2889bbf41ec56984019626657f025c1003a66a (patch)
tree5ae3c2cf029c1713fed82b14380408bda45add25 /engines/director/score.cpp
parentd17805e132bfb54988351e1ecb1a596066815e63 (diff)
downloadscummvm-rg350-ce2889bbf41ec56984019626657f025c1003a66a.tar.gz
scummvm-rg350-ce2889bbf41ec56984019626657f025c1003a66a.tar.bz2
scummvm-rg350-ce2889bbf41ec56984019626657f025c1003a66a.zip
DIRECTOR: Display objects with offsets
Diffstat (limited to 'engines/director/score.cpp')
-rw-r--r--engines/director/score.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 7e03c7482f..6dfd16b592 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -113,7 +113,8 @@ void Score::loadCastData(Common::SeekableReadStream &stream) {
for (uint16 i = 0; i < _frames.size(); i++) {
for (uint16 j = 0; j < _frames[i]->_sprites.size(); j++) {
byte castId = _frames[i]->_sprites[j]->_castId;
- _frames[i]->_sprites[j]->_cast = _casts[castId];
+ if (_casts.contains(castId))
+ _frames[i]->_sprites[j]->_cast = _casts.find(castId)->_value;
}
}
}
@@ -124,8 +125,8 @@ BitmapCast *Score::getBitmapCast(Common::SeekableReadStream &stream) {
/*uint16 someFlaggyThing = */ stream.readUint16BE();
cast->initialRect = readRect(stream);
cast->boundingRect = readRect(stream);
- cast->regX = stream.readUint16BE();
cast->regY = stream.readUint16BE();
+ cast->regX = stream.readUint16BE();
/*uint16 unk1 =*/ stream.readUint16BE();
/*uint16 unk2 =*/ stream.readUint16BE();
return cast;
@@ -182,12 +183,12 @@ ButtonCast *Score::getButtonCast(Common::SeekableReadStream &stream) {
}
Common::Rect Score::readRect(Common::SeekableReadStream &stream) {
- Common::Rect rect;
- rect.top = stream.readUint16BE();
- rect.left = stream.readUint16BE();
- rect.bottom = stream.readUint16BE();
- rect.right = stream.readUint16BE();
- return rect;
+ Common::Rect *rect = new Common::Rect();
+ rect->top = stream.readUint16BE();
+ rect->left = stream.readUint16BE();
+ rect->bottom = stream.readUint16BE();
+ rect->right = stream.readUint16BE();
+ return *rect;
}
void Score::play() {
@@ -206,7 +207,7 @@ void Score::play() {
_frames[frameId]->display();
frameId++;
g_system->updateScreen();
- g_system->delayMillis(200);
+ g_system->delayMillis(50);
}
}
@@ -408,14 +409,26 @@ void Frame::display() {
if (_sprites[i]->_enabled) {
DIBDecoder img;
//TODO check cast type
- uint32 castId = 1024 + _sprites[i]->_castId;
- img.loadStream(*riff.getResource(MKTAG('D', 'I', 'B', ' '), castId));
-
- g_system->copyRectToScreen(img.getSurface()->getPixels(), img.getSurface()->pitch,
- _sprites[i]->_startPoint.x,
- _sprites[i]->_startPoint.y,
- _sprites[i]->_height,
- _sprites[i]->_width);
+ uint32 imgId = 1024 + _sprites[i]->_castId;
+ img.loadStream(*riff.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;
+ uint32 rectTop = static_cast<BitmapCast *>(_sprites[i]->_cast)->initialRect.top;
+
+ int x = _sprites[i]->_startPoint.x - regX + rectLeft;
+ int y = _sprites[i]->_startPoint.y - regY + rectTop;
+ int height = _sprites[i]->_height;
+ int width = _sprites[i]->_width;
+ if (x < 0) {
+ width += x;
+ x = 0;
+ }
+ if (y < 0) {
+ height += y;
+ y = 0;
+ }
+ g_system->copyRectToScreen(img.getSurface()->getPixels(), img.getSurface()->pitch, x, y, height, width);
}
}
}