[Scummvm-git-logs] scummvm master -> 9c50f9162c6e0ec0b38f1537f5cf47d78cd10e82
npjg
nathanael.gentrydb8 at gmail.com
Fri Jul 10 03:41:02 UTC 2020
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
95aa3144ac DIRECTOR: Restore implicit matte for invert on click
c6d7766209 DIRECTOR: Keep sprite dimensions in channel
4e4c603a6e DIRECTOR: Add check for stretched sprite
206118a341 DIRECTOR: Mostly implement stretch of sprite
9c50f9162c DIRECTOR: LINGO: Implement spriteBox
Commit: 95aa3144accdf9667f6d10782be402a1a16ab3dd
https://github.com/scummvm/scummvm/commit/95aa3144accdf9667f6d10782be402a1a16ab3dd
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-09T23:40:01-04:00
Commit Message:
DIRECTOR: Restore implicit matte for invert on click
Changed paths:
engines/director/stage.cpp
diff --git a/engines/director/stage.cpp b/engines/director/stage.cpp
index 6f5d1d4b5c..661c7e56c1 100644
--- a/engines/director/stage.cpp
+++ b/engines/director/stage.cpp
@@ -64,11 +64,16 @@ Stage::~Stage() {
}
void Stage::invertChannel(Channel *channel) {
+ const Graphics::Surface *mask = channel->getMask(true);
Common::Rect destRect = channel->getBbox();
+
for (int i = 0; i < destRect.height(); i++) {
byte *src = (byte *)_surface.getBasePtr(destRect.left, destRect.top + i);
+ const byte *msk = mask ? (const byte *)mask->getBasePtr(0, i) : nullptr;
+
for (int j = 0; j < destRect.width(); j++, src++)
- *src = ~(*src);
+ if (!mask || (msk && !(*msk++)))
+ *src = ~(*src);
}
}
Commit: c6d7766209374593a232f06a2b9bfb29f0477817
https://github.com/scummvm/scummvm/commit/c6d7766209374593a232f06a2b9bfb29f0477817
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-09T23:40:01-04:00
Commit Message:
DIRECTOR: Keep sprite dimensions in channel
Changed paths:
engines/director/channel.cpp
engines/director/channel.h
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-the.cpp
engines/director/sprite.cpp
engines/director/sprite.h
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 9bfbb4b586..cabec7d356 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -37,6 +37,9 @@ Channel::Channel(Sprite *sp) {
_delta = Common::Point(0, 0);
_constraint = 0;
+ _width = 0;
+ _height = 0;
+
_visible = true;
_dirty = true;
@@ -112,7 +115,6 @@ bool Channel::isDirty(Sprite *nextSprite) {
if (nextSprite) {
isDirty |= _sprite->_castId != nextSprite->_castId ||
_sprite->_ink != nextSprite->_ink ||
- _sprite->getDims() != nextSprite->getDims() ||
(_currentPoint != nextSprite->_startPoint &&
!_sprite->_puppet && !_sprite->_moveable);
}
@@ -121,10 +123,10 @@ bool Channel::isDirty(Sprite *nextSprite) {
}
Common::Rect Channel::getBbox() {
- Common::Rect bbox = _sprite->getDims();
- bbox.moveTo(getPosition());
+ Common::Rect result(_width, _height);
+ result.moveTo(getPosition());
- return bbox;
+ return result;
}
void Channel::setClean(Sprite *nextSprite, int spriteId) {
@@ -142,6 +144,11 @@ void Channel::setClean(Sprite *nextSprite, int spriteId) {
// the moveable is disabled
if (!_sprite->_moveable || newSprite)
_currentPoint = _sprite->_startPoint;
+
+ if (!_sprite->_stretch) {
+ _width = _sprite->_width;
+ _height = _sprite->_height;
+ }
}
_currentPoint += _delta;
diff --git a/engines/director/channel.h b/engines/director/channel.h
index c5484dc8ab..22bc08eb97 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -54,6 +54,9 @@ public:
Common::Point _currentPoint;
Common::Point _delta;
+ int _width;
+ int _height;
+
private:
Graphics::ManagedSurface *getSurface();
MacShape *getShape();
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 0099f8423d..4667088447 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1847,32 +1847,37 @@ void LB::b_zoomBox(int nargs) {
delayTicks = d.asInt();
}
- int endSprite = g_lingo->pop().asInt();
- int startSprite = g_lingo->pop().asInt();
+ int endSpriteId = g_lingo->pop().asInt();
+ int startSpriteId = g_lingo->pop().asInt();
Score *score = g_director->getCurrentMovie()->getScore();
uint16 curFrame = score->getCurrentFrame();
- Common::Rect startRect = score->_channels[startSprite]->getBbox();
+ Common::Rect startRect = score->_channels[startSpriteId]->getBbox();
if (startRect.isEmpty()) {
- warning("b_zoomBox: unknown start sprite #%d", startSprite);
+ warning("b_zoomBox: unknown start sprite #%d", startSpriteId);
return;
}
// Looks for endSprite in the current frame, otherwise
// Looks for endSprite in the next frame
- Common::Rect endRect = score->_channels[endSprite]->getBbox();
+ Common::Rect endRect = score->_channels[endSpriteId]->getBbox();
if (endRect.isEmpty()) {
- if ((uint)curFrame + 1 < score->_frames.size())
- endRect = score->_frames[curFrame + 1]->_sprites[endSprite]->getDims();
+ if ((uint)curFrame + 1 < score->_frames.size()) {
+ Sprite *endSprite = score->_frames[curFrame + 1]->_sprites[endSpriteId];
+ endRect = Common::Rect(endSprite->_width, endSprite->_height);
+ }
}
+
if (endRect.isEmpty()) {
- if ((uint)curFrame - 1 > 0)
- endRect = score->_frames[curFrame - 1]->_sprites[endSprite]->getDims();
+ if ((uint)curFrame - 1 > 0) {
+ Sprite *endSprite = score->_frames[curFrame + 1]->_sprites[endSpriteId];
+ endRect = Common::Rect(endSprite->_width, endSprite->_height);
+ }
}
if (endRect.isEmpty()) {
- warning("b_zoomBox: unknown end sprite #%d", endSprite);
+ warning("b_zoomBox: unknown end sprite #%d", endSpriteId);
return;
}
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index d9fb25dd2f..966b4fcf33 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -751,7 +751,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_foreColor;
break;
case kTheHeight:
- d.u.i = sprite->_height;
+ d.u.i = channel->_height;
break;
case kTheImmediate:
d.u.i = sprite->_immediate;
@@ -815,7 +815,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_volume;
break;
case kTheWidth:
- d.u.i = sprite->_width;
+ d.u.i = channel->_width;
break;
default:
warning("Lingo::getTheSprite(): Unprocessed getting field \"%s\" of sprite", field2str(field));
@@ -885,7 +885,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
case kTheHeight:
if (sprite->_puppet && sprite->_stretch) {
g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
- sprite->_height = d.asInt();
+ channel->_height = d.asInt();
}
break;
case kTheImmediate:
@@ -959,7 +959,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
case kTheWidth:
if (sprite->_puppet && sprite->_stretch) {
g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
- sprite->_width = d.asInt();
+ channel->_width = d.asInt();
}
break;
default:
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 740bb25420..1527625428 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -165,29 +165,14 @@ void Sprite::setCast(uint16 castId) {
((TextCastMember *)_cast)->_buttonType = (ButtonType)(_spriteType - 8);
((TextCastMember *)_cast)->createWidget();
}
- } else {
- warning("Sprite::setCast(): CastMember id %d has null member", castId);
- }
-}
-
-Common::Rect Sprite::getDims() {
- Common::Rect result;
- if (_cast && _cast->_widget) {
- result = Common::Rect(_cast->_widget->_dims.width(), _cast->_widget->_dims.height());
+ if (_cast->_widget) {
+ _width = _cast->_widget->_dims.width();
+ _height = _cast->_widget->_dims.height();
+ }
} else {
- result = Common::Rect(_width, _height);
- }
-
- if (_puppet && _stretch) {
- // TODO: Properly align the bounding box
-
- result.setHeight(_height);
- result.setWidth(_width);
+ warning("Sprite::setCast(): CastMember id %d has null member", castId);
}
-
- return result;
}
-
} // End of namespace Director
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index b2e7d4dd7d..340a6c4a23 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -72,8 +72,6 @@ public:
void setCast(uint16 castid);
bool isQDShape();
- Common::Rect getDims();
-
uint16 _scriptId;
uint16 _scriptCastIndex;
byte _colorcode; // x40 editable, 0x80 moveable
Commit: 4e4c603a6e0c761a302c46c8f267aa1ba607be47
https://github.com/scummvm/scummvm/commit/4e4c603a6e0c761a302c46c8f267aa1ba607be47
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-09T23:40:01-04:00
Commit Message:
DIRECTOR: Add check for stretched sprite
Changed paths:
engines/director/channel.cpp
engines/director/channel.h
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index cabec7d356..1014c45594 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -122,6 +122,11 @@ bool Channel::isDirty(Sprite *nextSprite) {
return isDirty;
}
+bool Channel::isStretched() {
+ return _sprite->_puppet && _sprite->_stretch &&
+ (_sprite->_width != _width || _sprite->_height != _height);
+}
+
Common::Rect Channel::getBbox() {
Common::Rect result(_width, _height);
result.moveTo(getPosition());
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 22bc08eb97..127009b52e 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -40,6 +40,7 @@ public:
const Graphics::Surface *getMask(bool forceMatte = false);
Common::Rect getBbox();
+ bool isStretched();
bool isDirty(Sprite *nextSprite = nullptr);
void setClean(Sprite *nextSprite, int spriteId);
Commit: 206118a341367abb48ebbfc9919ae7b2165c24ae
https://github.com/scummvm/scummvm/commit/206118a341367abb48ebbfc9919ae7b2165c24ae
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-09T23:40:35-04:00
Commit Message:
DIRECTOR: Mostly implement stretch of sprite
Note that the offset is currently not correct. This will be fixed in a future commit.
Changed paths:
engines/director/channel.cpp
engines/director/channel.h
engines/director/lingo/lingo-the.cpp
engines/director/stage.cpp
engines/director/stage.h
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 1014c45594..0c996f1264 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -127,8 +127,10 @@ bool Channel::isStretched() {
(_sprite->_width != _width || _sprite->_height != _height);
}
-Common::Rect Channel::getBbox() {
- Common::Rect result(_width, _height);
+Common::Rect Channel::getBbox(bool unstretched) {
+
+ Common::Rect result(unstretched ? _sprite->_width : _width,
+ unstretched ? _sprite->_height : _height);
result.moveTo(getPosition());
return result;
@@ -170,6 +172,18 @@ void Channel::setClean(Sprite *nextSprite, int spriteId) {
}
}
+void Channel::setWidth(int w) {
+ if (_sprite->_puppet && _sprite->_stretch) {
+ _width = w;
+ }
+}
+
+void Channel::setHeight(int h) {
+ if (_sprite->_puppet && _sprite->_stretch) {
+ _height = h;
+ }
+}
+
void Channel::addRegistrationOffset(Common::Point &pos) {
if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap) {
BitmapCastMember *bc = (BitmapCastMember *)(_sprite->_cast);
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 127009b52e..90851db46b 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -38,10 +38,13 @@ public:
DirectorPlotData getPlotData();
const Graphics::Surface *getMask(bool forceMatte = false);
- Common::Rect getBbox();
+ Common::Rect getBbox(bool unstretched = false);
bool isStretched();
bool isDirty(Sprite *nextSprite = nullptr);
+
+ void setWidth(int w);
+ void setHeight(int h);
void setClean(Sprite *nextSprite, int spriteId);
void addDelta(Common::Point pos);
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 966b4fcf33..67d79c7153 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -883,10 +883,8 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_foreColor = d.asInt();
break;
case kTheHeight:
- if (sprite->_puppet && sprite->_stretch) {
- g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
- channel->_height = d.asInt();
- }
+ g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
+ channel->setHeight(d.asInt());
break;
case kTheImmediate:
sprite->_immediate = d.asInt();
@@ -942,6 +940,13 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
break;
case kTheStretch:
sprite->_stretch = d.asInt();
+
+ if (!d.asInt()) {
+ g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
+
+ channel->_width = sprite->_width;
+ channel->_height = sprite->_height;
+ }
break;
case kTheTrails:
sprite->_trails = d.asInt();
@@ -957,10 +962,8 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_volume = d.asInt();
break;
case kTheWidth:
- if (sprite->_puppet && sprite->_stretch) {
- g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
- channel->_width = d.asInt();
- }
+ g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
+ channel->setWidth(d.asInt());
break;
default:
warning("Lingo::setTheSprite(): Unprocessed setting field \"%s\" of sprite", field2str(field));
diff --git a/engines/director/stage.cpp b/engines/director/stage.cpp
index 661c7e56c1..650d6d40ff 100644
--- a/engines/director/stage.cpp
+++ b/engines/director/stage.cpp
@@ -165,7 +165,12 @@ void Stage::inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::Manag
if (pd.ms) {
inkBlitShape(&pd, srcRect);
} else if (pd.srf) {
- inkBlitSurface(&pd, srcRect, channel->getMask());
+ if (channel->isStretched()) {
+ srcRect = channel->getBbox(true);
+ inkBlitStretchSurface(&pd, srcRect, channel->getMask());
+ } else {
+ inkBlitSurface(&pd, srcRect, channel->getMask());
+ }
} else {
warning("Stage::inkBlitFrom: No source surface");
}
@@ -256,6 +261,29 @@ void Stage::inkBlitSurface(DirectorPlotData *pd, Common::Rect &srcRect, const Gr
}
}
+void Stage::inkBlitStretchSurface(DirectorPlotData *pd, Common::Rect &srcRect, const Graphics::Surface *mask) {
+ if (!pd->srf)
+ return;
+
+ // TODO: Determine why colourization causes problems in Warlock
+ if (pd->sprite == kTextSprite)
+ pd->applyColor = false;
+
+ int scaleX = SCALE_THRESHOLD * srcRect.width() / pd->destRect.width();
+ int scaleY = SCALE_THRESHOLD * srcRect.height() / pd->destRect.height();
+
+ pd->srcPoint.y = MAX(abs(srcRect.top - pd->destRect.top), 0);
+
+ for (int i = 0, scaleYCtr = 0; i < pd->destRect.height(); i++, scaleYCtr += scaleY, pd->srcPoint.y++) {
+ pd->srcPoint.x = MAX(abs(srcRect.left - pd->destRect.left), 0);
+
+ for (int xCtr = 0, scaleXCtr = 0; xCtr < pd->destRect.width(); xCtr++, scaleXCtr += scaleX, pd->srcPoint.x++) {
+ inkDrawPixel(pd->destRect.left + xCtr, pd->destRect.top + i,
+ preprocessColor(pd, *((byte *)pd->srf->getBasePtr(scaleXCtr / SCALE_THRESHOLD, scaleYCtr / SCALE_THRESHOLD))), pd);
+ }
+ }
+}
+
int Stage::preprocessColor(DirectorPlotData *p, int src) {
// HACK: Right now this method is just used for adjusting the colourization on text
// sprites, as it would be costly to colourize the chunks on the fly each
diff --git a/engines/director/stage.h b/engines/director/stage.h
index f642759981..387ed46bc5 100644
--- a/engines/director/stage.h
+++ b/engines/director/stage.h
@@ -38,6 +38,8 @@ class MacWindowManager;
namespace Director {
+const int SCALE_THRESHOLD = 0x100;
+
class Channel;
struct MacShape;
@@ -169,7 +171,9 @@ private:
void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
void inkBlitShape(DirectorPlotData *pd, Common::Rect &srcRect);
+
void inkBlitSurface(DirectorPlotData *pd, Common::Rect &srcRect, const Graphics::Surface *mask);
+ void inkBlitStretchSurface(DirectorPlotData *pd, Common::Rect &srcRect, const Graphics::Surface *mask);
};
} // end of namespace Director
Commit: 9c50f9162c6e0ec0b38f1537f5cf47d78cd10e82
https://github.com/scummvm/scummvm/commit/9c50f9162c6e0ec0b38f1537f5cf47d78cd10e82
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-09T23:40:36-04:00
Commit Message:
DIRECTOR: LINGO: Implement spriteBox
Changed paths:
engines/director/channel.cpp
engines/director/channel.h
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 0c996f1264..4ce3d15194 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -184,12 +184,29 @@ void Channel::setHeight(int h) {
}
}
-void Channel::addRegistrationOffset(Common::Point &pos) {
+void Channel::setBbox(int l, int t, int r, int b) {
+ if (_sprite->_puppet && _sprite->_stretch) {
+ _width = r - l;
+ _height = b - t;
+
+ _currentPoint.x = l;
+ _currentPoint.y = t;
+
+ addRegistrationOffset(_currentPoint, true);
+ }
+}
+
+void Channel::addRegistrationOffset(Common::Point &pos, bool subtract) {
if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap) {
BitmapCastMember *bc = (BitmapCastMember *)(_sprite->_cast);
- pos += Common::Point(bc->_initialRect.left - bc->_regX,
- bc->_initialRect.top - bc->_regY);
+ if (subtract) {
+ pos -= Common::Point(bc->_initialRect.left - bc->_regX,
+ bc->_initialRect.top - bc->_regY);
+ } else {
+ pos += Common::Point(bc->_initialRect.left - bc->_regX,
+ bc->_initialRect.top - bc->_regY);
+ }
}
}
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 90851db46b..1202407a1f 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -45,6 +45,7 @@ public:
void setWidth(int w);
void setHeight(int h);
+ void setBbox(int l, int t, int r, int b);
void setClean(Sprite *nextSprite, int spriteId);
void addDelta(Common::Point pos);
@@ -68,7 +69,7 @@ private:
uint getForeColor();
uint getBackColor();
- void addRegistrationOffset(Common::Point &pos);
+ void addRegistrationOffset(Common::Point &pos, bool subtract = false);
};
} // End of namespace Director
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 4667088447..e1653d2041 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1813,9 +1813,21 @@ void LB::b_rollOver(int nargs) {
}
void LB::b_spriteBox(int nargs) {
- g_lingo->printSTUBWithArglist("b_spriteBox", nargs);
+ ARGNUMCHECK(5);
- g_lingo->dropStack(nargs);
+ int b = g_lingo->pop().asInt();
+ int r = g_lingo->pop().asInt();
+ int t = g_lingo->pop().asInt();
+ int l = g_lingo->pop().asInt();
+ int spriteId = g_lingo->pop().asInt();
+ Channel *channel = g_director->getCurrentMovie()->getScore()->getChannelById(spriteId);
+
+ if (!channel)
+ return;
+
+ g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
+ channel->setBbox(l, t, r, b);
+ channel->_dirty = true;
}
void LB::b_unLoad(int nargs) {
@@ -2192,7 +2204,7 @@ void LB::b_window(int nargs) {
for (uint i = 0; i < windowList->size(); i++) {
if ((*windowList)[i].type != OBJECT || (*windowList)[i].u.obj->getObjType() != kWindowObj)
continue;
-
+
Stage *window = static_cast<Stage *>((*windowList)[i].u.obj);
if (window->getName().equalsIgnoreCase(windowName)) {
g_lingo->push(window);
More information about the Scummvm-git-logs
mailing list