aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kernel32.cpp26
-rw-r--r--engines/sci/engine/vm.h2
-rw-r--r--engines/sci/gui/gui.cpp87
-rw-r--r--engines/sci/gui/gui.h5
4 files changed, 78 insertions, 42 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp
index 753fd6f133..c7dc629d8f 100644
--- a/engines/sci/engine/kernel32.cpp
+++ b/engines/sci/engine/kernel32.cpp
@@ -698,35 +698,25 @@ reg_t kDeleteScreenItem(EngineState *s, int argc, reg_t *argv) {
}
reg_t kAddPlane(EngineState *s, int argc, reg_t *argv) {
- reg_t picObj = argv[0];
-
- // TODO
+ reg_t planeObj = argv[0];
- // The picture selector usually doesn't hold the actual picture at this point. It's filled in
- // when kUpdatePlane is called
-
- warning("kAddPlane object %04x:%04x", PRINT_REG(picObj));
+ s->_gui->addPlane(planeObj);
+ warning("kAddPlane object %04x:%04x", PRINT_REG(planeObj));
return NULL_REG;
}
reg_t kDeletePlane(EngineState *s, int argc, reg_t *argv) {
- reg_t picObj = argv[0];
+ reg_t planeObj = argv[0];
- // TODO
-
- warning("kDeletePlane object %04x:%04x", PRINT_REG(picObj));
+ s->_gui->deletePlane(planeObj);
+ warning("kDeletePlane object %04x:%04x", PRINT_REG(planeObj));
return NULL_REG;
}
reg_t kUpdatePlane(EngineState *s, int argc, reg_t *argv) {
- reg_t picObj = argv[0];
- int16 picNum = GET_SEL32V(s->_segMan, picObj, picture);
-
- if (picNum > -1) {
- s->_gui->drawPicture(picNum, 100, false, false, false, 0);
- s->_gui->animateShowPic();
- }
+ reg_t planeObj = argv[0];
+ s->_gui->updatePlane(planeObj);
return s->r_acc;
}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index be53d6a94a..abc1af119a 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -199,6 +199,8 @@ struct SelectorCache {
#ifdef ENABLE_SCI32
Selector data; // Used by Array()
Selector picture; // Used to hold the picture ID for SCI32 pictures
+
+ Selector plane;
#endif
};
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 93a40bb378..a9aecc32a8 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -67,6 +67,7 @@ SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette,
// _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
_screenItemCount = 0;
+ _planeCount = 0;
}
SciGui::SciGui() {
@@ -854,33 +855,71 @@ void SciGui::deleteScreenItem(reg_t object) {
}
}
-void SciGui::frameOut() {
- for (int itemNr = 0; itemNr < _screenItemCount; itemNr++) {
- reg_t viewObj = _screenItems[itemNr];
- uint16 viewId = GET_SEL32V(_s->_segMan, viewObj, view);
- uint16 loopNo = GET_SEL32V(_s->_segMan, viewObj, loop);
- uint16 celNo = GET_SEL32V(_s->_segMan, viewObj, cel);
- uint16 leftPos = GET_SEL32V(_s->_segMan, viewObj, x);
- uint16 topPos = GET_SEL32V(_s->_segMan, viewObj, y);
- int16 priority = GET_SEL32V(_s->_segMan, viewObj, priority);
- //int16 control = 0;
-
- // Theoretically, leftPos and topPos should be sane
- // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that
- // the hack underneath does not try and draw cels outside the screen coordinates
- if (leftPos >= getScreenWidth()) {
- warning("kAddScreenItem: invalid left position (%d), resetting to 0", leftPos);
- leftPos = 0;
- }
+void SciGui::addPlane(reg_t object) {
+ _planes.push_back(object);
+ _planeCount++;
+}
+
+void SciGui::updatePlane(reg_t object) {
+ int16 picNum = GET_SEL32V(_s->_segMan, object, picture);
+ if (picNum > -1) {
+ drawPicture(picNum, 100, false, false, false, 0);
+ animateShowPic();
+ }
+}
- if (topPos >= getScreenHeight()) {
- warning("kAddScreenItem: invalid top position (%d), resetting to 0", topPos);
- topPos = 0;
+void SciGui::deletePlane(reg_t object) {
+ for (int planeNr = 0; planeNr < _planeCount; planeNr++) {
+ if (_planes[planeNr] == object) {
+ _planes.remove_at(planeNr);
+ _planeCount--;
+ return;
}
+ }
+}
- // HACK: just draw the view on screen
- if (viewId != 0xffff)
- drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0);
+void SciGui::frameOut() {
+ for (int planeNr = 0; planeNr < _planeCount; planeNr++) {
+ reg_t planeObj = _planes[planeNr];
+ int16 priority = GET_SEL32V(_s->_segMan, planeObj, priority);
+
+ if (priority == -1)
+ continue;
+
+ for (int itemNr = 0; itemNr < _screenItemCount; itemNr++) {
+ reg_t viewObj = _screenItems[itemNr];
+ reg_t planeOfItem = GET_SEL32(_s->_segMan, viewObj, plane);
+ if (planeOfItem == _planes[planeNr]) {
+ uint16 viewId = GET_SEL32V(_s->_segMan, viewObj, view);
+ uint16 loopNo = GET_SEL32V(_s->_segMan, viewObj, loop);
+ uint16 celNo = GET_SEL32V(_s->_segMan, viewObj, cel);
+ uint16 leftPos = GET_SEL32V(_s->_segMan, viewObj, x);
+ uint16 topPos = GET_SEL32V(_s->_segMan, viewObj, y);
+ int16 priority = GET_SEL32V(_s->_segMan, viewObj, priority);
+ int16 signal = GET_SEL32V(_s->_segMan, viewObj, signal);
+ int16 plane = GET_SEL32V(_s->_segMan, viewObj, plane);
+
+ warning("viewId %d plane %X", viewId, plane);
+ //int16 control = 0;
+
+ // Theoretically, leftPos and topPos should be sane
+ // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that
+ // the hack underneath does not try and draw cels outside the screen coordinates
+ if (leftPos >= getScreenWidth()) {
+ warning("kAddScreenItem: invalid left position (%d), resetting to 0", leftPos);
+ leftPos = 0;
+ }
+
+ if (topPos >= getScreenHeight()) {
+ warning("kAddScreenItem: invalid top position (%d), resetting to 0", topPos);
+ topPos = 0;
+ }
+
+ // HACK: just draw the view on screen
+ if (viewId != 0xffff)
+ drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0);
+ }
+ }
}
}
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index a81e61d7e9..07e8f6df4f 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -156,6 +156,9 @@ public:
// SCI32
virtual void addScreenItem(reg_t object);
virtual void deleteScreenItem(reg_t object);
+ virtual void addPlane(reg_t object);
+ virtual void updatePlane(reg_t object);
+ virtual void deletePlane(reg_t object);
virtual void frameOut();
virtual bool debugUndither(bool flag);
@@ -188,6 +191,8 @@ private:
Common::Array<reg_t> _screenItems;
int _screenItemCount;
+ Common::Array<reg_t> _planes;
+ int _planeCount;
};
} // End of namespace Sci