[Scummvm-git-logs] scummvm master -> 01b2e97c6ee708bd3995ca0424894a557c09b005
npjg
nathanael.gentrydb8 at gmail.com
Tue Jun 16 12:48:31 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3b795ae07a GRAPHICS: MACGUI: Enable macDrawPixel to invert pixels
01b2e97c6e GRAPHICS: MACGUI: Draw zoomBox with pixel inversion
Commit: 3b795ae07aeb764e98a3d453faa8ff0ba12b8415
https://github.com/scummvm/scummvm/commit/3b795ae07aeb764e98a3d453faa8ff0ba12b8415
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-16T08:48:21-04:00
Commit Message:
GRAPHICS: MACGUI: Enable macDrawPixel to invert pixels
Changed paths:
graphics/macgui/macwindowmanager.cpp
graphics/macgui/macwindowmanager.h
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 99f4da10e7..f829854830 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -346,7 +346,7 @@ void macDrawPixel(int x, int y, int color, void *data) {
*((byte *)p->surface->getBasePtr(xu, yu)) =
(pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ?
- color : p->bgColor;
+ color : (p->invert ? abs(255 - *((byte *)p->surface->getBasePtr(xu, yu))) : p->bgColor);
if (p->mask)
*((byte *)p->mask->getBasePtr(xu, yu)) = 0xff;
@@ -364,7 +364,7 @@ void macDrawPixel(int x, int y, int color, void *data) {
uint yu = (uint)y;
*((byte *)p->surface->getBasePtr(xu, yu)) =
(pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ?
- color : p->bgColor;
+ color : (p->invert ? abs(255 - *((byte *)p->surface->getBasePtr(xu, yu))) : p->bgColor);
if (p->mask)
*((byte *)p->mask->getBasePtr(xu, yu)) = 0xff;
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index afbccda925..d1c5936eba 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -96,9 +96,10 @@ struct MacPlotData {
int fillOriginY;
int thickness;
uint bgColor;
+ bool invert;
- MacPlotData(Graphics::ManagedSurface *s, Graphics::ManagedSurface *m, MacPatterns *p, uint f, int fx, int fy, int t, uint bg) :
- surface(s), mask(m), patterns(p), fillType(f), fillOriginX(fx), fillOriginY(fy), thickness(t), bgColor(bg) {
+ MacPlotData(Graphics::ManagedSurface *s, Graphics::ManagedSurface *m, MacPatterns *p, uint f, int fx, int fy, int t, uint bg, bool inv = false) :
+ surface(s), mask(m), patterns(p), fillType(f), fillOriginX(fx), fillOriginY(fy), thickness(t), bgColor(bg), invert(inv) {
}
};
Commit: 01b2e97c6ee708bd3995ca0424894a557c09b005
https://github.com/scummvm/scummvm/commit/01b2e97c6ee708bd3995ca0424894a557c09b005
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-16T08:48:21-04:00
Commit Message:
GRAPHICS: MACGUI: Draw zoomBox with pixel inversion
The Director engine, which relies upon zoomBox, is also updated.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/score.cpp
engines/director/score.h
graphics/macgui/macwindowmanager.cpp
graphics/macgui/macwindowmanager.h
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index eeb265c534..9ade91d604 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1840,21 +1840,26 @@ void LB::b_zoomBox(int nargs) {
if ((uint)curFrame + 1 < score->_frames.size())
endRect = &score->_frames[curFrame + 1]->_sprites[endSprite]->_currentBbox;
}
+ if (!endRect) {
+ if ((uint)curFrame - 1 > 0)
+ endRect = &score->_frames[curFrame - 1]->_sprites[endSprite]->_currentBbox;
+ }
if (!endRect) {
warning("b_zoomBox: unknown end sprite #%d", endSprite);
return;
}
- ZoomBox *box = new ZoomBox;
+ Graphics::ZoomBox *box = new Graphics::ZoomBox;
box->start = *startRect;
box->end = *endRect;
+ // box->last = Common::Rect(0, 0);
box->delay = delayTicks;
box->step = 0;
box->startTime = g_system->getMillis();
box->nextTime = g_system->getMillis() + 1000 * box->step / 60;
- score->addZoomBox(box);
+ g_director->_wm->addZoomBox(box);
}
void LB::b_updateStage(int nargs) {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 3562f1b529..ec7e1f356b 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -363,7 +363,7 @@ void Score::startLoop() {
void Score::update() {
if (g_system->getMillis() < _nextFrameTime && !debugChannelSet(-1, kDebugFast)) {
- renderZoomBox(true);
+ _vm->_wm->renderZoomBox(true);
if (!_vm->_newMovieStarted)
_vm->_wm->draw();
@@ -512,7 +512,7 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
renderSprite(i);
if (!updateStageOnly) {
- renderZoomBox();
+ _vm->_wm->renderZoomBox();
_vm->_wm->draw();
@@ -525,8 +525,6 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
playSoundChannel(frameId);
}
- if (_vm->getCurrentScore()->haveZoomBox())
- _backSurface->copyFrom(*_surface);
}
g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height());
@@ -686,6 +684,24 @@ void Score::renderShape(uint16 spriteId) {
inkBasedBlit(&maskSurface, tmpSurface, ink, shapeRect, spriteId);
}
+Cast *Score::getCastMember(int castId) {
+ Cast *result = nullptr;
+
+ if (_loadedCast->contains(castId)) {
+ result = _loadedCast->getVal(castId);
+ }
+ return result;
+}
+
+const Stxt *Score::getStxt(int castId) {
+ const Stxt *result = nullptr;
+
+ if (_loadedStxts->contains(castId)) {
+ result = _loadedStxts->getVal(castId);
+ }
+ return result;
+}
+
uint16 Score::getSpriteIDFromPos(Common::Point pos) {
for (int i = _sprites.size() - 1; i >= 0; i--)
if (_sprites[i]->_currentBbox.contains(pos))
@@ -702,7 +718,10 @@ bool Score::checkSpriteIntersection(uint16 spriteId, Common::Point pos) {
}
Common::Rect *Score::getSpriteRect(uint16 spriteId) {
- return &_sprites[spriteId]->_currentBbox;
+ if (!_sprites[spriteId]->_currentBbox.isEmpty())
+ return &_sprites[spriteId]->_currentBbox;
+
+ return nullptr;
}
Sprite *Score::getSpriteById(uint16 id) {
@@ -727,81 +746,4 @@ void Score::playSoundChannel(uint16 frameId) {
sound->playCastMember(frame->_sound2, 2, false);
}
-void Score::addZoomBox(ZoomBox *box) {
- _zoomBoxes.push_back(box);
-}
-
-void Score::renderZoomBox(bool redraw) {
- if (!_zoomBoxes.size())
- return;
-
- ZoomBox *box = _zoomBoxes.front();
- uint32 t = g_system->getMillis();
-
- if (box->nextTime > t)
- return;
-
- if (redraw) {
- _surface->copyFrom(*_backSurface);
- }
-
- const int numSteps = 14;
- // We have 15 steps in total, and we have flying rectange
- // from switching 3/4 frames
-
- int start, end;
- // Determine, how many rectangles and what are their numbers
- if (box->step < 5) {
- start = 1;
- end = box->step;
- } else {
- start = box->step - 4;
- end = MIN(start + 3 - box->step % 2, 8);
- }
-
- Graphics::MacPlotData pd(_surface, nullptr, &_vm->_wm->getPatterns(), Graphics::kPatternCheckers, 0, 0, 1, 0);
-
- for (int i = start; i <= end; i++) {
- Common::Rect r(box->start.left + (box->end.left - box->start.left) * i / 8,
- box->start.top + (box->end.top - box->start.top) * i / 8,
- box->start.right + (box->end.right - box->start.right) * i / 8,
- box->start.bottom + (box->end.bottom - box->start.bottom) * i / 8);
-
- Graphics::drawLine(r.left, r.top, r.right, r.top, 0xffff, Graphics::macDrawPixel, &pd);
- Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
- Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
- Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
- }
-
- box->step++;
-
- if (box->step >= numSteps) {
- _zoomBoxes.remove_at(0);
- }
-
- box->nextTime = box->startTime + 1000 * box->step * box->delay / 60;
-
- if (redraw) {
- g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height()); // zoomBox
- }
-}
-
-Cast *Score::getCastMember(int castId) {
- Cast *result = nullptr;
-
- if (_loadedCast->contains(castId)) {
- result = _loadedCast->getVal(castId);
- }
- return result;
-}
-
-const Stxt *Score::getStxt(int castId) {
- const Stxt *result = nullptr;
-
- if (_loadedStxts->contains(castId)) {
- result = _loadedStxts->getVal(castId);
- }
- return result;
-}
-
} // End of namespace Director
diff --git a/engines/director/score.h b/engines/director/score.h
index f4a2480e99..1b50b19ac0 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -24,11 +24,13 @@
#define DIRECTOR_SCORE_H
#include "common/hash-str.h"
+#include "graphics/macgui/macwindowmanager.h"
namespace Graphics {
class ManagedSurface;
class Font;
class MacWindow;
+ class ZoomBox;
}
namespace Common {
@@ -53,16 +55,6 @@ class ScriptCast;
class ShapeCast;
class TextCast;
-struct ZoomBox {
- Common::Rect start;
- Common::Rect end;
- int delay;
- int step;
- uint32 startTime;
- uint32 nextTime;
-};
-
-
struct TransParams {
TransitionType type;
uint duration;
@@ -136,10 +128,6 @@ public:
bool checkSpriteIntersection(uint16 spriteId, Common::Point pos);
Common::Rect *getSpriteRect(uint16 spriteId);
- void addZoomBox(ZoomBox *box);
- void renderZoomBox(bool redraw = false);
- bool haveZoomBox() { return !_zoomBoxes.empty(); }
-
Cast *getCastMember(int castId);
const Stxt *getStxt(int castId);
void renderFrame(uint16 frameId, bool forceUpdate = false, bool updateStageOnly = false);
@@ -243,8 +231,6 @@ private:
int _lingoArchive;
DirectorSound *_soundManager;
DirectorEngine *_vm;
-
- Common::Array<ZoomBox *> _zoomBoxes;
};
} // End of namespace Director
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index f829854830..872233c0e1 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -544,6 +544,75 @@ void MacWindowManager::removeFromWindowList(BaseMacWindow *target) {
}
}
+
+void MacWindowManager::addZoomBox(ZoomBox *box) {
+ _zoomBoxes.push_back(box);
+}
+
+void MacWindowManager::renderZoomBox(bool redraw) {
+ if (!_zoomBoxes.size())
+ return;
+
+ ZoomBox *box = _zoomBoxes.front();
+ uint32 t = g_system->getMillis();
+
+ MacPlotData pd(_screen, nullptr, &getPatterns(), Graphics::kPatternCheckers, 0, 0, 1, 0, true);
+
+ // Undraw the previous boxes
+ if (box->last.size() != 0) {
+ for (uint i = 0; i < box->last.size(); i++) {
+ Common::Rect r = box->last.remove_at(i);
+ zoomBoxInner(r, pd);
+ }
+ }
+
+ if (box->nextTime > t)
+ return;
+
+ const int numSteps = 14;
+ // We have 15 steps in total, and we have flying rectange
+ // from switching 3/4 frames
+
+ int start, end;
+ // Determine, how many rectangles and what are their numbers
+ if (box->step <= 5) {
+ start = 1;
+ end = box->step - 1;
+ } else {
+ start = box->step - 4;
+ end = MIN(start + 3 - box->step % 2, 7);
+ }
+
+ for (int i = start; i <= end; i++) {
+ Common::Rect r(box->start.left + (box->end.left - box->start.left) * i / 8,
+ box->start.top + (box->end.top - box->start.top) * i / 8,
+ box->start.right + (box->end.right - box->start.right) * i / 8,
+ box->start.bottom + (box->end.bottom - box->start.bottom) * i / 8);
+
+ zoomBoxInner(r, pd);
+ box->last.push_back(r);
+ }
+
+ box->step++;
+ box->nextTime = box->startTime + 1000 * box->step * box->delay / 60;
+
+ if (redraw) {
+ g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->getBounds().width(), _screen->getBounds().height()); // zoomBox
+ }
+
+ if (box->step >= numSteps) {
+ delete _zoomBoxes[0];
+ _zoomBoxes.remove_at(0);
+ }
+}
+
+void MacWindowManager::zoomBoxInner(Common::Rect &r, Graphics::MacPlotData &pd) {
+ Graphics::drawLine(r.left, r.top, r.right, r.top, 0xff, Graphics::macDrawPixel, &pd);
+ Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
+ Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
+ Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
+}
+
/////////////////
// Cursor stuff
/////////////////
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index d1c5936eba..c52bfc6d6a 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -103,6 +103,16 @@ struct MacPlotData {
}
};
+struct ZoomBox {
+ Common::Rect start;
+ Common::Rect end;
+ Common::Array<Common::Rect> last;
+ int delay;
+ int step;
+ uint32 startTime;
+ uint32 nextTime;
+};
+
void macDrawPixel(int x, int y, int color, void *data);
void macInvertPixel(int x, int y, int color, void *data);
@@ -251,6 +261,9 @@ public:
void passPalette(const byte *palette, uint size);
uint findBestColor(byte cr, byte cg, byte cb);
+ void renderZoomBox(bool redraw = false);
+ void addZoomBox(ZoomBox *box);
+
public:
MacFontManager *_fontMan;
uint32 _mode;
@@ -273,6 +286,9 @@ private:
void removeFromStack(BaseMacWindow *target);
void removeFromWindowList(BaseMacWindow *target);
+ void zoomBoxInner(Common::Rect &r, Graphics::MacPlotData &pd);
+ bool haveZoomBox() { return !_zoomBoxes.empty(); }
+
public:
ManagedSurface *_screen;
ManagedSurface *_screenCopy;
@@ -305,6 +321,8 @@ private:
MacWidget *_activeWidget;
PauseToken _screenCopyPauseToken;
+
+ Common::Array<ZoomBox *> _zoomBoxes;
};
} // End of namespace Graphics
More information about the Scummvm-git-logs
mailing list