aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-30 09:26:14 +0000
committerMartin Kiewitz2009-10-30 09:26:14 +0000
commit6c101f7c1aad4d401e793ada760bba33432773b1 (patch)
tree5884d74b46c94afd19e0ce43b5fb029a15e21b41 /engines/sci
parent87aa24e1740bb9aa957537c5dfe96fa3c0f4fb29 (diff)
downloadscummvm-rg350-6c101f7c1aad4d401e793ada760bba33432773b1.tar.gz
scummvm-rg350-6c101f7c1aad4d401e793ada760bba33432773b1.tar.bz2
scummvm-rg350-6c101f7c1aad4d401e793ada760bba33432773b1.zip
SCI/newgui: Reanimate implemented
svn-id: r45527
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gui/gui.cpp12
-rw-r--r--engines/sci/gui/gui_animate.cpp77
-rw-r--r--engines/sci/gui/gui_animate.h6
-rw-r--r--engines/sci/gui/gui_helpers.h1
-rw-r--r--engines/sci/gui/gui_windowmgr.cpp6
-rw-r--r--engines/sci/gui/gui_windowmgr.h4
6 files changed, 67 insertions, 39 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 3d5a0728ab..b86a1dc065 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -59,7 +59,7 @@ SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette,
_transitions = new SciGuiTransitions(this, _screen, _palette, _s->resMan->isVGA());
_animate = new SciGuiAnimate(_s, _gfx, _screen, _palette);
_text = new SciGuiText(_s->resMan, _gfx, _screen);
- _windowMgr = new SciGuiWindowMgr(_screen, _gfx, _animate, _text);
+ _windowMgr = new SciGuiWindowMgr(this, _screen, _gfx, _text);
_controls = new SciGuiControls(_s->_segMan, _gfx, _text);
// _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
}
@@ -232,7 +232,7 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
_gfx->BitsGetRect(argv[0], &rect);
rect.translate(-_gfx->GetPort()->left, -_gfx->GetPort()->top);
_gfx->BitsRestore(argv[0]);
- _animate->reAnimate(rect);
+ graphRedrawBox(rect);
// finishing loop
argc = 0;
break;
@@ -452,7 +452,15 @@ void SciGui::graphUpdateBox(Common::Rect rect) {
}
void SciGui::graphRedrawBox(Common::Rect rect) {
+ localToGlobal(&rect.left, &rect.top);
+ localToGlobal(&rect.right, &rect.bottom);
+ GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
+ globalToLocal(&rect.left, &rect.top);
+ globalToLocal(&rect.right, &rect.bottom);
+
_animate->reAnimate(rect);
+
+ _gfx->SetPort(oldPort);
}
int16 SciGui::picNotValid(int16 newPicNotValid) {
diff --git a/engines/sci/gui/gui_animate.cpp b/engines/sci/gui/gui_animate.cpp
index ec6e8520c7..a130e44eea 100644
--- a/engines/sci/gui/gui_animate.cpp
+++ b/engines/sci/gui/gui_animate.cpp
@@ -44,11 +44,17 @@ SciGuiAnimate::SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *s
}
SciGuiAnimate::~SciGuiAnimate() {
+ if (_listData)
+ free(_listData);
+ if (_lastCastData)
+ free(_lastCastData);
}
void SciGuiAnimate::init() {
_listData = NULL;
- _listSize = 0;
+ _listCount = 0;
+ _lastCastData = NULL;
+ _lastCastCount = 0;
_ignoreFastCast = false;
// fastCast object is not found in any SCI games prior SCI1
@@ -61,9 +67,7 @@ void SciGuiAnimate::init() {
}
void SciGuiAnimate::disposeLastCast() {
- // FIXME
- //if (!_lastCast->first.isNull())
- //_lastCast->DeleteList();
+ _lastCastCount = 0;
}
bool SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) {
@@ -126,13 +130,20 @@ void SciGuiAnimate::makeSortedList(List *list) {
return;
// Adjust list size, if needed
- if ((_listData == NULL) || (_listSize < listCount)) {
+ if ((_listData == NULL) || (_listCount < listCount)) {
if (_listData)
free(_listData);
_listData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
if (!_listData)
- error("Could not allocate memory for _animateList");
- _listSize = listCount;
+ error("Could not allocate memory for _listData");
+ _listCount = listCount;
+
+ if (_lastCastData)
+ free(_lastCastData);
+ _lastCastData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
+ if (!_lastCastData)
+ error("Could not allocate memory for _lastCastData");
+ _lastCastCount = 0;
}
// Fill the list
@@ -342,11 +353,14 @@ void SciGuiAnimate::drawCels() {
SegManager *segMan = _s->_segMan;
reg_t curObject;
GuiAnimateEntry *listEntry;
+ GuiAnimateEntry *lastCastEntry = _lastCastData;
uint16 signal;
reg_t bitsHandle;
GuiAnimateList::iterator listIterator;
GuiAnimateList::iterator listEnd = _list.end();
+ _lastCastCount = 0;
+
listIterator = _list.begin();
while (listIterator != listEnd) {
listEntry = *listIterator;
@@ -366,17 +380,10 @@ void SciGuiAnimate::drawCels() {
signal &= 0xFFFF ^ kSignalRemoveView;
}
listEntry->signal = signal;
-
-// HEAPHANDLE hNewCast = heapNewPtr(sizeof(sciCast), kDataCast);
-// sciCast *pNewCast = (sciCast *)heap2Ptr(hNewCast);
-// pNewCast->view = view;
-// pNewCast->loop = loop;
-// pNewCast->cel = cel;
-// pNewCast->z = z;
-// pNewCast->pal = pal;
-// pNewCast->hSaved = 0;
-// pNewCast->rect = *rect;
-// _lastCast->AddToEnd(hNewCast);
+
+ // Remember that entry in lastCast
+ memcpy(lastCastEntry, listEntry, sizeof(GuiAnimateEntry));
+ lastCastEntry++; _lastCastCount++;
}
listIterator++;
}
@@ -475,16 +482,30 @@ void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) {
}
void SciGuiAnimate::reAnimate(Common::Rect rect) {
- // TODO: implement ReAnimate
- _gfx->BitsShow(rect);
+ GuiAnimateEntry *lastCastEntry;
+ uint16 lastCastCount;
+
+ if (_lastCastCount > 0) {
+ lastCastEntry = _lastCastData;
+ lastCastCount = _lastCastCount;
+ while (lastCastCount > 0) {
+ lastCastEntry->castHandle = _gfx->BitsSave(lastCastEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+ _gfx->drawCel(lastCastEntry->viewId, lastCastEntry->loopNo, lastCastEntry->celNo, lastCastEntry->celRect, lastCastEntry->priority, lastCastEntry->paletteNo);
+ lastCastEntry++; lastCastCount--;
+ }
+ _gfx->BitsShow(rect);
+ // restoring
+ lastCastCount = _lastCastCount;
+ while (lastCastCount > 0) {
+ lastCastEntry--;
+ _gfx->BitsRestore(lastCastEntry->castHandle);
+ lastCastCount--;
+ }
+ } else {
+ _gfx->BitsShow(rect);
+ }
/*
- _s->_gui->localToGlobal(rect.left, rect.top);
- _s->_gui->localToGlobal(rect.right, rect.bottom);
- GuiPort *oldPort = _gfx->SetPort((GuiPort *)_picWind);
- _s->_gui->globalToLocal(rect.left, rect.top);
- _s->_gui->globalToLocal(rect.right, rect.bottom);
-
if (!_lastCast->isEmpty()) {
HEAPHANDLE hnode = _lastCast->getFirst();
sciCast *pCast;
@@ -504,10 +525,6 @@ void SciGuiAnimate::reAnimate(Common::Rect rect) {
_gfx->BitsShow(pCast->hSaved);
hnode = pCast->node.prev;
}
- } else
- _gfx->BitsShow(rect);
-
- _gfx->SetPort(oldPort);
*/
}
diff --git a/engines/sci/gui/gui_animate.h b/engines/sci/gui/gui_animate.h
index b734d5c50e..f3c19448e0 100644
--- a/engines/sci/gui/gui_animate.h
+++ b/engines/sci/gui/gui_animate.h
@@ -84,10 +84,12 @@ private:
SciGuiScreen *_screen;
SciGuiPalette *_palette;
- uint16 _listSize;
+ uint16 _listCount;
GuiAnimateEntry *_listData;
GuiAnimateList _list;
- //List *_lastCast;
+
+ uint16 _lastCastCount;
+ GuiAnimateEntry *_lastCastData;
bool _ignoreFastCast;
};
diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h
index 191b7039a1..6bc91797b8 100644
--- a/engines/sci/gui/gui_helpers.h
+++ b/engines/sci/gui/gui_helpers.h
@@ -87,6 +87,7 @@ struct GuiAnimateEntry {
uint16 signal;
Common::Rect celRect;
bool showBitsFlag;
+ GuiMemoryHandle castHandle;
};
typedef Common::List<GuiAnimateEntry *> GuiAnimateList;
diff --git a/engines/sci/gui/gui_windowmgr.cpp b/engines/sci/gui/gui_windowmgr.cpp
index de9fe7ac0a..ba0464b57b 100644
--- a/engines/sci/gui/gui_windowmgr.cpp
+++ b/engines/sci/gui/gui_windowmgr.cpp
@@ -44,8 +44,8 @@ enum {
SCI_WINDOWMGR_STYLE_USER = (1 << 7)
};
-SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate, SciGuiText *text)
- : _screen(screen), _gfx(gfx), _animate(animate), _text(text) {
+SciGuiWindowMgr::SciGuiWindowMgr(SciGui *gui, SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiText *text)
+ : _gui(gui), _screen(screen), _gfx(gfx), _text(text) {
}
SciGuiWindowMgr::~SciGuiWindowMgr() {
@@ -257,7 +257,7 @@ void SciGuiWindowMgr::DisposeWindow(GuiWindow *pWnd, int16 arg2) {
if (arg2)
_gfx->BitsShow(pWnd->restoreRect);
else
- _animate->reAnimate(pWnd->restoreRect);
+ _gui->graphRedrawBox(pWnd->restoreRect);
_windowList.remove(pWnd);
_gfx->SetPort(_windowList.back());
_windowsById[pWnd->id] = 0;
diff --git a/engines/sci/gui/gui_windowmgr.h b/engines/sci/gui/gui_windowmgr.h
index e848a68335..01796b078b 100644
--- a/engines/sci/gui/gui_windowmgr.h
+++ b/engines/sci/gui/gui_windowmgr.h
@@ -33,7 +33,7 @@ namespace Sci {
class SciGuiWindowMgr {
public:
- SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate, SciGuiText *text);
+ SciGuiWindowMgr(SciGui *gui, SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiText *text);
~SciGuiWindowMgr();
void init(Common::String gameName);
@@ -54,9 +54,9 @@ public:
private:
typedef Common::List<GuiPort *> PortList;
+ SciGui *_gui;
SciGuiScreen *_screen;
SciGuiGfx *_gfx;
- SciGuiAnimate *_animate;
SciGuiText *_text;
/** The list of open 'windows' (and ports), in visual order. */