aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gui
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/gui')
-rw-r--r--engines/sci/gui/gui.cpp8
-rw-r--r--engines/sci/gui/gui.h3
-rw-r--r--engines/sci/gui/gui_gfx.cpp75
-rw-r--r--engines/sci/gui/gui_gfx.h10
-rw-r--r--engines/sci/gui/gui_picture.cpp8
5 files changed, 87 insertions, 17 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index f0cfb2e11d..5ef2cf9575 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -112,6 +112,14 @@ void SciGui::localToGlobal(int16 *x, int16 *y) {
*y = *y + curPort->top;
}
+int16 SciGui::coordinateToPriority(int16 y) {
+ return _gfx->CoordinateToPriority(y);
+}
+
+int16 SciGui::priorityToCoordinate(int16 priority) {
+ return _gfx->PriorityToCoordinate(priority);
+}
+
reg_t SciGui::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
GuiWindow *wnd = NULL;
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index 58a6da8075..caeda61d6c 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -51,6 +51,9 @@ public:
virtual reg_t getPort();
virtual void globalToLocal(int16 *x, int16 *y);
virtual void localToGlobal(int16 *x, int16 *y);
+ virtual int16 coordinateToPriority(int16 y);
+ virtual int16 priorityToCoordinate(int16 priority);
+
virtual reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
virtual void disposeWindow(uint16 windowPtr, int16 arg2);
diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp
index 2891eacf73..1c5874eb3e 100644
--- a/engines/sci/gui/gui_gfx.cpp
+++ b/engines/sci/gui/gui_gfx.cpp
@@ -65,6 +65,15 @@ void SciGuiGfx::init() {
SetFont(0);
_menuPort->rect = Common::Rect(0, 0, _screen->_width, _screen->_height);
_menuRect = Common::Rect(0, 0, _screen->_width, 9);
+
+ // Initialize priority bands
+ if (_s->usesOldGfxFunctions()) {
+ _priorityBandCount = 15;
+ PriorityBandsInit(42, 200);
+ } else {
+ _priorityBandCount = 14;
+ PriorityBandsInit(42, 190);
+ }
}
GuiPort *SciGuiGfx::SetPort(GuiPort *newPort) {
@@ -571,14 +580,14 @@ void SciGuiGfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect,
}
// Update (part of) screen
-void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 flags) {
+void SciGuiGfx::ShowBits(const Common::Rect &r, uint16 screenMask) {
Common::Rect rect(r.left, r.top, r.right, r.bottom);
rect.clip(_curPort->rect);
if (rect.isEmpty()) // nothing to show
return;
OffsetRect(rect);
- assert((flags&0x8000) == 0);
+ assert((screenMask & 0x8000) == 0);
_screen->copyToScreen();
// _system->copyRectToScreen(GetSegment(flags) + _baseTable[rect.top] + rect.left, 320, rect.left, rect.top, rect.width(), rect.height());
// _system->updateScreen();
@@ -1064,6 +1073,50 @@ static inline int sign_extend_byte(int value) {
return value;
}
+void SciGuiGfx::PriorityBandsInit(int16 top, int16 bottom) {
+ double bandSize;
+ int16 y;
+
+ _priorityTop = top;
+ _priorityBottom = bottom;
+ bandSize = (_priorityBottom - _priorityTop) / _priorityBandCount;
+
+ memset(_priorityBands, 0, _priorityTop);
+ for (y = _priorityTop; y < _priorityBottom; y++)
+ _priorityBands[y] = (byte)(1 + (y - _priorityTop) / bandSize);
+}
+
+void SciGuiGfx::PriorityBandsInit(byte *data) {
+ int i = 0, inx;
+ byte priority = 0;
+
+ for (inx = 0; inx < 14; inx++) {
+ priority = *data++;
+ while (i < priority)
+ _priorityBands[i++] = inx;
+ }
+ while (i < 200)
+ _priorityBands[i++] = inx;
+}
+
+byte SciGuiGfx::CoordinateToPriority(int16 y) {
+ if (y < _priorityTop)
+ return _priorityBands[_priorityTop];
+ if (y > _priorityBottom)
+ return _priorityBands[_priorityBottom];
+ return _priorityBands[y];
+}
+
+int16 SciGuiGfx::PriorityToCoordinate(byte priority) {
+ int16 y;
+ if (priority <= _priorityBandCount) {
+ for (y = 0; y <= _priorityBottom; y++)
+ if (_priorityBands[y] == priority)
+ return y;
+ }
+ return _priorityBottom;
+}
+
void SciGuiGfx::AnimateDisposeLastCast() {
// FIXME
//if (!_lastCast->first.isNull())
@@ -1311,7 +1364,7 @@ void SciGuiGfx::AnimateUpdate(List *list) {
// arr1[i] = 1;
if ((signal[listNr] & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
rect = celRect[listNr];
- //rect.top = CLIP<int16>(PriCoord(zs[i]) - 1, rect.top, rect.bottom - 1);
+ rect.top = CLIP<int16>(PriorityToCoordinate(z[listNr]) - 1, rect.top, rect.bottom - 1);
FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
}
}
@@ -1425,7 +1478,7 @@ void SciGuiGfx::AddToPicDrawCels(List *list) {
GuiViewLoopNo loopNo;
GuiViewCelNo celNo;
int16 x, y, z, priority;
- uint16 paletteNo;
+ uint16 paletteNo, signal;
Common::Rect celRect;
while (curNode) {
@@ -1440,22 +1493,22 @@ void SciGuiGfx::AddToPicDrawCels(List *list) {
z = GET_SEL32V(curObject, z);
priority = GET_SEL32V(curObject, priority);
if (priority == -1)
- priority = 0; //CoordPri(y);
+ priority = CoordinateToPriority(y);
paletteNo = GET_SEL32V(curObject, palette);
+ signal = GET_SEL32V(curObject, signal);
// Get the corresponding view
view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
// Create rect according to coordinates and given cel
- view->getCelRect(loopNo, celNo, x, y, z, &celRect);
+ view->getCelRect(loopNo, celNo, x, y, priority, &celRect);
// draw corresponding cel
drawCel(viewId, loopNo, celNo, celRect.left, celRect.top, z, paletteNo);
-// FIXME find out what 17 is and implement this as well
-// if ((obj.getProperty(17) & 0x4000) == 0) {
-// rect.top = CLIP<int16>(PriCoord(prio) - 1, rect.top, rect.bottom - 1);
-// _gfx->RFillRect(rect, 4, 0, 0, 0xF);
-// }
+ if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+ celRect.top = CLIP<int16>(PriorityToCoordinate(priority) - 1, celRect.top, celRect.bottom - 1);
+ FillRect(celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ }
curAddress = curNode->succ;
curNode = _s->_segMan->lookupNode(curAddress);
diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h
index 461a9a895c..4e9f0b2288 100644
--- a/engines/sci/gui/gui_gfx.h
+++ b/engines/sci/gui/gui_gfx.h
@@ -100,6 +100,12 @@ public:
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
int16 onControl(uint16 screenMask, Common::Rect rect);
+
+ void PriorityBandsInit(int16 top, int16 bottom);
+ void PriorityBandsInit(byte *data);
+ byte CoordinateToPriority(int16 y);
+ int16 PriorityToCoordinate(byte priority);
+
void AnimateDisposeLastCast();
void AnimateInvoke(List *list, int argc, reg_t *argv);
void AnimateFill(List *list, byte &oldPicNotValid);
@@ -144,6 +150,10 @@ private:
int _textColorsCount;
uint16 *_textColors;
+ // Priority Bands related variables
+ int16 _priorityTop, _priorityBottom, _priorityBandCount;
+ byte _priorityBands[200];
+
// Animate* related variables
List *_lastCast;
diff --git a/engines/sci/gui/gui_picture.cpp b/engines/sci/gui/gui_picture.cpp
index fbdaea01a6..e43bad575b 100644
--- a/engines/sci/gui/gui_picture.cpp
+++ b/engines/sci/gui/gui_picture.cpp
@@ -483,15 +483,11 @@ void SciGuiPicture::drawVectorData(byte *data, int dataSize) {
curPos += size;
break;
case PIC_OPX_VGA_PRIORITY_TABLE_EQDIST:
- //FIXME
- //g_sci->InitPri(READ_LE_UINT16(ptr), READ_LE_UINT16(ptr + 2));
- debug(5, "DrawPic::InitPri %d %d",
- READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
+ _gfx->PriorityBandsInit(READ_LE_UINT16(data + curPos), READ_LE_UINT16(data + curPos + 2));
curPos += 4;
break;
case PIC_OPX_VGA_PRIORITY_TABLE_EXPLICIT:
- //FIXME
- //g_sci->PriBands(ptr);
+ _gfx->PriorityBandsInit(data + curPos);
curPos += 14;
break;
default: