aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/hotspots.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/hotspots.cpp')
-rw-r--r--engines/gob/hotspots.cpp82
1 files changed, 39 insertions, 43 deletions
diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp
index 1edb7fc0cb..dad141a254 100644
--- a/engines/gob/hotspots.cpp
+++ b/engines/gob/hotspots.cpp
@@ -431,9 +431,10 @@ void Hotspots::pop() {
// Find the end of the filled hotspot space
int i;
Hotspot *destPtr = _hotspots;
- for (i = 0; i < kHotspotCount; i++, destPtr++)
+ for (i = 0; i < kHotspotCount; i++, destPtr++) {
if (destPtr->isEnd())
break;
+ }
if (((uint32) (kHotspotCount - i)) < backup.size)
error("Hotspots::pop(): Not enough free space in the current Hotspot "
@@ -525,12 +526,12 @@ void Hotspots::leave(uint16 index) {
int16 Hotspots::curWindow(int16 &dx, int16 &dy) const {
if ((_vm->_draw->_renderFlags & 0x80)==0)
return(0);
- for (int i = 0; i < 10; i++)
- if (_vm->_draw->_fascinWin[i].id != -1)
+ for (int i = 0; i < 10; i++) {
+ if (_vm->_draw->_fascinWin[i].id != -1) {
if (_vm->_global->_inter_mouseX >= _vm->_draw->_fascinWin[i].left &&
_vm->_global->_inter_mouseX < _vm->_draw->_fascinWin[i].left + _vm->_draw->_fascinWin[i].width &&
_vm->_global->_inter_mouseY >= _vm->_draw->_fascinWin[i].top &&
- _vm->_global->_inter_mouseY < _vm->_draw->_fascinWin[i].top + _vm->_draw->_fascinWin[i].height)
+ _vm->_global->_inter_mouseY < _vm->_draw->_fascinWin[i].top + _vm->_draw->_fascinWin[i].height) {
if (_vm->_draw->_fascinWin[i].id == _vm->_draw->_winCount-1) {
dx = _vm->_draw->_fascinWin[i].left;
dy = _vm->_draw->_fascinWin[i].top;
@@ -546,6 +547,9 @@ int16 Hotspots::curWindow(int16 &dx, int16 &dy) const {
return(6);
return(-i);
}
+ }
+ }
+ }
return(0);
}
@@ -555,10 +559,7 @@ uint16 Hotspots::checkMouse(Type type, uint16 &id, uint16 &index) const {
int16 dx = 0;
int16 dy = 0;
- int16 winId = -1;
-
- if (_vm->getGameType() == kGameTypeFascination)
- winId = _vm->_draw->isOverWin(dx, dy);
+ int16 winId = _vm->_draw->getWinFromCoord(dx, dy);
if (winId < 0) {
winId = 0;
@@ -753,11 +754,8 @@ uint16 Hotspots::check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index
if (_vm->_game->_mouseButtons != kMouseButtonsNone) {
// Mouse button pressed
- int i;
- if (_vm->getGameType() == kGameTypeFascination)
- i = _vm->_draw->handleCurWin();
- else
- i = 0;
+ int i = _vm->_draw->handleCurWin();
+
if (!i) {
_vm->_draw->animateCursor(2);
if (delay > 0) {
@@ -778,9 +776,11 @@ uint16 Hotspots::check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index
((delay <= 0) || (_vm->_game->_mouseButtons == kMouseButtonsNone)))
_vm->_draw->blitCursor();
+
+ if ((key != _currentKey) && (_vm->getGameType() != kGameTypeFascination))
// If the hotspot changed, leave the old one
- if (key != _currentKey)
- leave(_currentIndex);
+ // Code not present in Fascination executables
+ leave(_currentIndex);
_currentKey = 0;
break;
@@ -800,11 +800,9 @@ uint16 Hotspots::check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index
enter(_currentIndex);
} else {
WRITE_VAR(16, (int32)i);
- if (id)
- id = 0;
- if (index)
- index = 0;
- return(0);
+ id = 0;
+ index = 0;
+ return 0;
}
} else
// No mouse button pressed, check whether the position changed at least
@@ -1232,28 +1230,28 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
height = _vm->_game->_script->readUint16();
}
if (_vm->_draw->_renderFlags & 64) {
- warning("_renderFlags check added for Fascination");
_vm->_draw->_invalidatedTops[0] = 0;
_vm->_draw->_invalidatedLefts[0] = 0;
_vm->_draw->_invalidatedRights[0] = 319;
_vm->_draw->_invalidatedBottoms[0] = 199;
_vm->_draw->_invalidatedCount = 1;
if (windowNum == 0) {
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0);
- } else
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left + width - 1, top, left + width - 1, top + height - 1, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left, top + height - 1, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left + width - 1, top, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top + height - 1, left + width - 1, top + height - 1, 0);
+ } else {
if ((_vm->_draw->_fascinWin[windowNum].id != -1) && (_vm->_draw->_fascinWin[windowNum].id == _vm->_draw->_winCount - 1)) {
left += _vm->_draw->_fascinWin[windowNum].left;
top += _vm->_draw->_fascinWin[windowNum].top;
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0);
- _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left + width - 1, top, left + width - 1, top + height - 1, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left, top + height - 1, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left + width - 1, top, 0);
+ _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top + height - 1, left + width - 1, top + height - 1, 0);
left -= _vm->_draw->_fascinWin[windowNum].left;
top -= _vm->_draw->_fascinWin[windowNum].top;
}
+ }
}
type &= 0x7F;
@@ -1297,7 +1295,7 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
uint32 funcEnter = 0, funcLeave = 0;
if ((windowNum != 0) && (type != 0) && (type != 2))
- warning("evaluateNew - type %d, win %d\n",type, windowNum);
+ warning("evaluateNew - type %d, win %d",type, windowNum);
// Evaluate parameters for the new hotspot
switch (type) {
@@ -1393,9 +1391,9 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
ids[i] = _vm->_game->_script->readInt16();
flags = _vm->_game->_script->readInt16();
- if (flags > 3)
- warning("evaluateNew: Warning, use of type 2 or 20. flags = %d, should be %d\n", flags, flags&3);
-
+ if (flags > 3)
+ warning("evaluateNew: Warning, use of type 2 or 20. flags = %d, should be %d", flags, flags&3);
+
funcEnter = 0;
funcLeave = _vm->_game->_script->pos();
@@ -1424,7 +1422,7 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
}
bool Hotspots::evaluateFind(uint16 key, int16 timeVal, const uint16 *ids,
- uint16 leaveWindowIndex, uint16 hotspotIndex1, uint16 hotspotIndex2,
+ uint16 leaveWindowIndex, uint16 hotspotIndex1, uint16 hotspotIndex2,
uint16 endIndex, int16 &duration, uint16 &id, uint16 &index, bool &finished) {
bool fascinCheck = false;
@@ -1518,7 +1516,7 @@ void Hotspots::evaluate() {
int16 duration = _vm->_game->_script->peekByte(1);
byte leaveWindowIndex = 0;
- if ( _vm->getGameType() == kGameTypeFascination )
+ if (_vm->getGameType() == kGameTypeFascination)
leaveWindowIndex = _vm->_game->_script->peekByte(2);
byte hotspotIndex1 = _vm->_game->_script->peekByte(3);
@@ -1644,7 +1642,7 @@ int16 Hotspots::findCursor(uint16 x, uint16 y) const {
int16 deltax = 0;
int16 deltay = 0;
- if ( _vm->getGameType() == kGameTypeFascination )
+ if (_vm->getGameType() == kGameTypeFascination)
cursor = curWindow(deltax, deltay);
if (cursor == 0) {
@@ -1678,7 +1676,7 @@ int16 Hotspots::findCursor(uint16 x, uint16 y) const {
cursor = 0;
for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
const Hotspot &spot = _hotspots[i];
- // this check is /really/ Fascination specific.
+ // this check is /really/ Fascination specific.
// It's illogical, so if it's to be reused in Adi games... Be careful!
if ((spot.flags & 0xFF00) == curType)
if (spot.isIn(x - deltax, y - deltay)) {
@@ -1722,9 +1720,9 @@ void Hotspots::oPlaytoons_F_1B() {
// var_4 += unk_var;
for (int i = 0; i < kHotspotCount; i++) {
- if (_hotspots[i].isEnd()) {
+ if (_hotspots[i].isEnd())
return;
- }
+
if ((_hotspots[i].id == 0xD000 + shortId) || (_hotspots[i].id == 0xB000 + shortId) ||
(_hotspots[i].id == 0x4000 + shortId)) {
longId = _hotspots[i].id;
@@ -1745,7 +1743,6 @@ void Hotspots::oPlaytoons_F_1B() {
right -= 2;
bottom -= 2;
}
-// oPlaytoons_sub_F_1B(0x8000 + var2, left, top, right, bottom, _vm->_game->_script->getResultStr(), var3, var4, shortId);
_vm->_draw->oPlaytoons_sub_F_1B(0x8000+ var2, left, top, right, bottom, _vm->_game->_script->getResultStr(), fontIndex, var4, shortId);
return;
}
@@ -2053,7 +2050,6 @@ void Hotspots::matchInputStrings(const InputDesc *inputs) const {
cleanFloatString(spot);
if ((spot.getType() >= kTypeInput2NoLeave) && (spot.getType() <= kTypeInput3Leave)) {
-
// Look if we find a match between the wanted and the typed string
checkStringMatch(spot, inputs[inputIndex], inputPos);
strInputCount++;
@@ -2110,7 +2106,7 @@ void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16
_vm->_draw->_spriteBottom = height;
_vm->_draw->_backColor = color;
- _vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
+ _vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10);
}
void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {