aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2009-07-05 19:56:54 +0000
committerSven Hesse2009-07-05 19:56:54 +0000
commitc4dc61edb54c244b4df5c9f1503cb983e2021030 (patch)
treef5be67c59e1f1d3eb6f70fa6e180170f9321dacb /engines
parentaeb020602a6f89a5cbc5af66ded393fe8da61212 (diff)
downloadscummvm-rg350-c4dc61edb54c244b4df5c9f1503cb983e2021030.tar.gz
scummvm-rg350-c4dc61edb54c244b4df5c9f1503cb983e2021030.tar.bz2
scummvm-rg350-c4dc61edb54c244b4df5c9f1503cb983e2021030.zip
Split off Hotspots::evaluateNew()
svn-id: r42145
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/hotspots.cpp407
-rw-r--r--engines/gob/hotspots.h7
2 files changed, 202 insertions, 212 deletions
diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp
index 987b91ca59..eca9a250b4 100644
--- a/engines/gob/hotspots.cpp
+++ b/engines/gob/hotspots.cpp
@@ -924,7 +924,7 @@ uint16 Hotspots::readString(uint16 xPos, uint16 yPos, uint16 width, uint16 heigh
}
uint16 Hotspots::handleInput(int16 time, uint16 maxPos, uint16 &curPos,
- InputDesc *inpDesc, uint16 &id, uint16 &index) {
+ InputDesc *inputs, uint16 &id, uint16 &index) {
uint16 descInd = 0;
uint16 key = 0;
@@ -955,11 +955,11 @@ uint16 Hotspots::handleInput(int16 time, uint16 maxPos, uint16 &curPos,
_vm->_draw->_destSurface = 21;
- _vm->_draw->_backColor = inpDesc[descInd].backColor;
- _vm->_draw->_frontColor = inpDesc[descInd].frontColor;
+ _vm->_draw->_backColor = inputs[descInd].backColor;
+ _vm->_draw->_frontColor = inputs[descInd].frontColor;
_vm->_draw->_textToPrint = tempStr;
_vm->_draw->_transparency = 1;
- _vm->_draw->_fontIndex = inpDesc[descInd].fontIndex;
+ _vm->_draw->_fontIndex = inputs[descInd].fontIndex;
_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10);
@@ -1006,8 +1006,8 @@ uint16 Hotspots::handleInput(int16 time, uint16 maxPos, uint16 &curPos,
key = readString(inputSpot.left, inputSpot.top,
inputSpot.right - inputSpot.left + 1,
inputSpot.bottom - inputSpot.top + 1,
- inpDesc[curPos].backColor, inpDesc[curPos].frontColor,
- GET_VARO_STR(inputSpot.key), inpDesc[curPos].fontIndex,
+ inputs[curPos].backColor, inputs[curPos].frontColor,
+ GET_VARO_STR(inputSpot.key), inputs[curPos].fontIndex,
inputSpot.getType(), time, id, index);
if (_vm->_inter->_terminate)
@@ -1112,250 +1112,237 @@ uint16 Hotspots::handleInput(int16 time, uint16 maxPos, uint16 &curPos,
}
}
-void Hotspots::evaluate() {
- InputDesc descArray[20];
- int16 array[300];
- char *str;
- int16 counter;
- int16 var_24;
- int16 var_26;
- int16 collStackPos;
-
- push(0);
-
- uint16 endIndex = 0;
- while (!_hotspots[endIndex].isEnd())
- endIndex++;
-
- _shouldPush = false;
+void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
+ uint16 &validId, bool &hasInput, uint16 &inputIndex) {
- _vm->_game->_script->skip(1);
+ ids[i] = 0;
- byte count = _vm->_game->_script->readByte();
+ // Type and window
+ byte type = _vm->_game->_script->readByte();
+ byte window = 0;
- _vm->_game->_handleMouse = _vm->_game->_script->peekByte(0);
- int16 duration = _vm->_game->_script->peekByte(1);
- byte stackPos2 = _vm->_game->_script->peekByte(3);
- byte descIndex = _vm->_game->_script->peekByte(4);
- bool needRecalculation = _vm->_game->_script->peekByte(5) != 0;
-
- duration *= 1000;
- if ((stackPos2 != 0) || (descIndex != 0)) {
- duration /= 100;
- if (_vm->_game->_script->peekByte(1) == 100)
- duration = 2;
+ if ((type & 0x40) != 0) {
+ type -= 0x40;
+ window = _vm->_game->_script->readByte();
}
- int16 timeVal = duration;
-
- _vm->_game->_script->skip(6);
-
- WRITE_VAR(16, 0);
-
- byte var_41 = 0;
- int16 var_46 = 0;
-
- uint16 id = 0;
- uint16 validId = 0xFFFF;
- uint16 index = 0;
+ // Coordinates
+ uint16 left, top, width, height, right, bottom;
+ uint32 funcPos = 0;
+ if ((type & 0x80) != 0) {
+ funcPos = _vm->_game->_script->pos();
+ left = _vm->_game->_script->readValExpr();
+ top = _vm->_game->_script->readValExpr();
+ width = _vm->_game->_script->readValExpr();
+ height = _vm->_game->_script->readValExpr();
+ } else {
+ funcPos = 0;
+ left = _vm->_game->_script->readUint16();
+ top = _vm->_game->_script->readUint16();
+ width = _vm->_game->_script->readUint16();
+ height = _vm->_game->_script->readUint16();
+ }
+ type &= 0x7F;
- bool hasInput = false;
- uint16 inputIndex = 0;
+ // Apply global drawing offset
+ if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
+ left += _vm->_draw->_backDeltaX;
+ top += _vm->_draw->_backDeltaY;
+ }
- for (uint16 i = 0; i < count; i++) {
- array[i] = 0;
+ right = left + width - 1;
+ bottom = top + height - 1;
- byte type = _vm->_game->_script->readByte();
- byte window = 0;
+ // Removing 0x4 from the state
+ if ((type == 11) || (type == 12)) {
+ uint8 wantedState = (type == 11) ? 0xE : 0xD;
- if ((type & 0x40) != 0) {
- type -= 0x40;
- window = _vm->_game->_script->readByte();
- }
+ _vm->_game->_script->skip(6);
- uint16 left, top, width, height, right, bottom;
- uint32 funcEnter = 0, funcLeave = 0, funcPos = 0;
- if ((type & 0x80) != 0) {
- funcPos = _vm->_game->_script->pos();
- left = _vm->_game->_script->readValExpr();
- top = _vm->_game->_script->readValExpr();
- width = _vm->_game->_script->readValExpr();
- height = _vm->_game->_script->readValExpr();
- } else {
- funcPos = 0;
- left = _vm->_game->_script->readUint16();
- top = _vm->_game->_script->readUint16();
- width = _vm->_game->_script->readUint16();
- height = _vm->_game->_script->readUint16();
- }
+ for (int j = 0; j < kHotspotCount; j++) {
+ Hotspot &spot = _hotspots[j];
- if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
- left += _vm->_draw->_backDeltaX;
- top += _vm->_draw->_backDeltaY;
+ if (spot.getState() == wantedState) {
+ spot.id &= 0xBFFF;
+ spot.funcEnter = _vm->_game->_script->pos();
+ spot.funcLeave = _vm->_game->_script->pos();
+ }
}
- right = left + width - 1;
- bottom = top + height - 1;
-
- int16 key = 0;
- int16 flags = 0;
- Video::FontDesc *font = 0;
-
- type &= 0x7F;
- switch (type) {
- case kTypeNone:
- _vm->_game->_script->skip(6);
-
- funcEnter = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
+ _vm->_game->_script->skipBlock();
- funcLeave = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
+ return;
+ }
- key = i + 0xA000;
- flags = type + (window << 8);
+ int16 key = 0;
+ int16 flags = 0;
+ Video::FontDesc *font = 0;
+ uint32 funcEnter = 0, funcLeave = 0;
+
+ // Evaluate parameters for the new hotspot
+ switch (type) {
+ case kTypeNone:
+ _vm->_game->_script->skip(6);
+
+ funcEnter = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
+
+ funcLeave = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
+
+ key = i + 0xA000;
+ flags = type + (window << 8);
+ break;
+
+ case kTypeMove:
+ key = _vm->_game->_script->readInt16();
+ ids[i] = _vm->_game->_script->readInt16();
+ flags = _vm->_game->_script->readInt16();
+
+ funcEnter = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
+
+ funcLeave = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
+
+ if (key == 0)
+ key = i + 0xA000;
+
+ flags = type + (window << 8) + (flags << 4);
+ break;
+
+ case kTypeInput1NoLeave:
+ case kTypeInput1Leave:
+ case kTypeInput2NoLeave:
+ case kTypeInput2Leave:
+ case kTypeInput3NoLeave:
+ case kTypeInput3Leave:
+ case kTypeInputFloatNoLeave:
+ case kTypeInputFloatLeave:
+ hasInput = true;
+
+ _vm->_util->clearKeyBuf();
+
+ // Input text parameters
+ key = _vm->_game->_script->readVarIndex();
+ inputs[inputIndex].fontIndex = _vm->_game->_script->readInt16();
+ inputs[inputIndex].backColor = _vm->_game->_script->readByte();
+ inputs[inputIndex].frontColor = _vm->_game->_script->readByte();
+ inputs[inputIndex].str = 0;
+
+ if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) {
+ inputs[inputIndex].str =
+ (const char *) (_vm->_game->_script->getData() + _vm->_game->_script->pos() + 2);
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16() + 2);
+ }
- add(i + 0x8000, left, top, right, bottom,
- flags, key, funcEnter, funcLeave, funcPos);
+ if (left == 0xFFFF) {
+ if ((type & 1) == 0)
+ _vm->_game->_script->skipBlock();
break;
+ }
- case kTypeMove:
- key = _vm->_game->_script->readInt16();
- array[i] = _vm->_game->_script->readInt16();
- flags = _vm->_game->_script->readInt16();
-
- funcEnter = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
+ font = _vm->_draw->_fonts[inputs[inputIndex].fontIndex];
+ if (!font->extraData)
+ right = left + width * font->itemWidth - 1;
+ funcEnter = 0;
+ funcPos = 0;
+ funcLeave = 0;
+ if (!(type & 1)) {
funcLeave = _vm->_game->_script->pos();
_vm->_game->_script->skipBlock();
+ }
- if (key == 0)
- key = i + 0xA000;
- flags = type + (window << 8) + (flags << 4);
-
- add(i + 0x8000, left, top, right, bottom,
- flags, key, funcEnter, funcLeave, funcPos);
- break;
-
- case kTypeInput1NoLeave:
- case kTypeInput1Leave:
- case kTypeInput2NoLeave:
- case kTypeInput2Leave:
- case kTypeInput3NoLeave:
- case kTypeInput3Leave:
- case kTypeInputFloatNoLeave:
- case kTypeInputFloatLeave:
- hasInput = true;
-
- _vm->_util->clearKeyBuf();
-
- key = _vm->_game->_script->readVarIndex();
- descArray[inputIndex].fontIndex = _vm->_game->_script->readInt16();
- descArray[inputIndex].backColor = _vm->_game->_script->readByte();
- descArray[inputIndex].frontColor = _vm->_game->_script->readByte();
- descArray[inputIndex].ptr = 0;
-
- if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) {
- descArray[inputIndex].ptr = _vm->_game->_script->getData() + _vm->_game->_script->pos() + 2;
- _vm->_game->_script->skip(_vm->_game->_script->peekUint16() + 2);
- }
-
- if (left == 0xFFFF) {
- if ((type & 1) == 0)
- _vm->_game->_script->skipBlock();
- break;
- }
+ flags = type;
- font = _vm->_draw->_fonts[descArray[inputIndex].fontIndex];
- if (!font->extraData)
- right = left + width * font->itemWidth - 1;
+ inputIndex++;
+ break;
- funcEnter = 0;
- funcPos = 0;
- funcLeave = 0;
- if (!(type & 1)) {
- funcLeave = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
- }
+ case 20:
+ validId = i;
+ // Fall through to case 2
+ case kTypeClick:
+ key = _vm->_game->_script->readInt16();
+ ids[i] = _vm->_game->_script->readInt16();
+ flags = _vm->_game->_script->readInt16();
- flags = type;
+ funcEnter = 0;
- inputIndex++;
+ funcLeave = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
- add(i + 0x8000, left, top, right, bottom,
- flags, key, funcEnter, funcLeave, funcPos);
+ flags = 2 + (window << 8) + (flags << 4);
+ break;
- break;
+ case 21:
+ key = _vm->_game->_script->readInt16();
+ ids[i] = _vm->_game->_script->readInt16();
+ flags = _vm->_game->_script->readInt16() & 3;
- case 11:
- _vm->_game->_script->skip(6);
+ funcEnter = _vm->_game->_script->pos();
+ _vm->_game->_script->skipBlock();
- for (int j = 0; j < kHotspotCount; j++) {
- Hotspot &spot = _hotspots[j];
+ funcLeave = 0;
- if (spot.getState() == 0xE) {
- spot.id &= 0xBFFF;
- spot.funcEnter = _vm->_game->_script->pos();
- spot.funcLeave = _vm->_game->_script->pos();
- }
- }
+ flags = 2 + (window << 8) + (flags << 4);
+ break;
+ }
- _vm->_game->_script->skipBlock();
- break;
+ add(i + 0x8000, left, top, right, bottom,
+ flags, key, funcEnter, funcLeave, funcPos);
+}
- case 12:
- _vm->_game->_script->skip(6);
+void Hotspots::evaluate() {
+ InputDesc inputs[20];
+ uint16 ids[kHotspotCount];
+ int16 counter;
+ int16 var_24;
+ int16 var_26;
+ int16 collStackPos;
- for (int j = 0; j < kHotspotCount; j++) {
- Hotspot &spot = _hotspots[j];
+ push(0);
- if (spot.getState() == 0xD) {
- spot.id &= 0xBFFF;
- spot.funcEnter = _vm->_game->_script->pos();
- spot.funcLeave = _vm->_game->_script->pos();
- }
- }
+ uint16 endIndex = 0;
+ while (!_hotspots[endIndex].isEnd())
+ endIndex++;
- _vm->_game->_script->skipBlock();
- break;
+ _shouldPush = false;
- case 20:
- validId = i;
- // Fall through to case 2
- case kTypeClick:
- key = _vm->_game->_script->readInt16();
- array[i] = _vm->_game->_script->readInt16();
- flags = _vm->_game->_script->readInt16();
+ _vm->_game->_script->skip(1);
- funcEnter = 0;
+ byte count = _vm->_game->_script->readByte();
- funcLeave = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
+ _vm->_game->_handleMouse = _vm->_game->_script->peekByte(0);
+ int16 duration = _vm->_game->_script->peekByte(1);
+ byte stackPos2 = _vm->_game->_script->peekByte(3);
+ byte descIndex = _vm->_game->_script->peekByte(4);
+ bool needRecalculation = _vm->_game->_script->peekByte(5) != 0;
- flags = 2 + (window << 8) + (flags << 4);
+ duration *= 1000;
+ if ((stackPos2 != 0) || (descIndex != 0)) {
+ duration /= 100;
+ if (_vm->_game->_script->peekByte(1) == 100)
+ duration = 2;
+ }
- add(i + 0x8000, left, top, right, bottom,
- flags, key, funcEnter, funcLeave, funcPos);
- break;
+ int16 timeVal = duration;
- case 21:
- key = _vm->_game->_script->readInt16();
- array[i] = _vm->_game->_script->readInt16();
- flags = _vm->_game->_script->readInt16() & 3;
+ _vm->_game->_script->skip(6);
- funcEnter = _vm->_game->_script->pos();
- _vm->_game->_script->skipBlock();
+ WRITE_VAR(16, 0);
- funcLeave = 0;
+ byte var_41 = 0;
+ int16 var_46 = 0;
- flags = 2 + (window << 8) + (flags << 4);
+ uint16 id = 0;
+ uint16 validId = 0xFFFF;
+ uint16 index = 0;
- add(i + 0x8000, left, top, right, bottom,
- flags, key, funcEnter, funcLeave, funcPos);
- break;
- }
- }
+ bool hasInput = false;
+ uint16 inputIndex = 0;
+ for (uint16 i = 0; i < count; i++)
+ evaluateNew(i, ids, inputs, validId, hasInput, inputIndex);
if (needRecalculation)
recalculate(true);
@@ -1368,7 +1355,7 @@ void Hotspots::evaluate() {
if (hasInput) {
uint16 curEditIndex = 0;
- key = handleInput(duration, inputIndex, curEditIndex, descArray, id, index);
+ key = handleInput(duration, inputIndex, curEditIndex, inputs, id, index);
WRITE_VAR(55, curEditIndex);
if (key == kKeyReturn) {
@@ -1454,7 +1441,7 @@ void Hotspots::evaluate() {
break;
if (Hotspot::getState(id) == 0x8)
- WRITE_VAR(16, array[id & 0xFFF]);
+ WRITE_VAR(16, ids[id & 0xFFF]);
else
WRITE_VAR(16, id & 0xFFF);
@@ -1537,7 +1524,7 @@ void Hotspots::evaluate() {
_vm->_inter->storeMouse();
if (Hotspot::getState(id) == 0x8)
- WRITE_VAR(16, array[id & 0xFFF]);
+ WRITE_VAR(16, ids[id & 0xFFF]);
else
WRITE_VAR(16, id & 0xFFF);
@@ -1581,7 +1568,7 @@ void Hotspots::evaluate() {
}
if ((spot.getType() >= kTypeInput2NoLeave) && (spot.getType() <= kTypeInput3Leave)) {
- str = (char *) descArray[var_24].ptr;
+ const char *str = inputs[var_24].str;
strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
@@ -1605,7 +1592,7 @@ void Hotspots::evaluate() {
WRITE_VAR(17 + var_26, 1);
break;
}
- } while (READ_LE_UINT16(descArray[var_24].ptr - 2) > pos);
+ } while (READ_LE_UINT16(inputs[var_24].str - 2) > pos);
collStackPos++;
} else {
WRITE_VAR(17 + var_26, 2);
@@ -1629,7 +1616,7 @@ void Hotspots::evaluate() {
_vm->_inter->storeMouse();
if (VAR(16) == 0) {
if (Hotspot::getState(id) == 0x8)
- WRITE_VAR(16, array[id & 0xFFF]);
+ WRITE_VAR(16, ids[id & 0xFFF]);
else
WRITE_VAR(16, id & 0xFFF);
}
diff --git a/engines/gob/hotspots.h b/engines/gob/hotspots.h
index e05e37b296..a337620710 100644
--- a/engines/gob/hotspots.h
+++ b/engines/gob/hotspots.h
@@ -133,7 +133,7 @@ private:
uint16 fontIndex;
uint16 backColor;
uint16 frontColor;
- byte *ptr;
+ const char *str;
};
GobEngine *_vm;
@@ -175,7 +175,10 @@ void checkHotspotChanged();
Type type, int16 &duration, uint16 &id, uint16 index);
uint16 handleInput(int16 time, uint16 hotspotIndex, uint16 &curPos,
- InputDesc *inpDesc, uint16 &id, uint16 &index);
+ InputDesc *inputs, uint16 &id, uint16 &index);
+
+ void evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
+ uint16 &validId, bool &hasInput, uint16 &inputIndex);
};
} // End of namespace Gob