aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/inter_v2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/inter_v2.cpp')
-rw-r--r--engines/gob/inter_v2.cpp71
1 files changed, 28 insertions, 43 deletions
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 82822330b1..20f812bb88 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -39,6 +39,7 @@
#include "gob/expression.h"
#include "gob/script.h"
#include "gob/resources.h"
+#include "gob/hotspots.h"
#include "gob/goblin.h"
#include "gob/map.h"
#include "gob/mult.h"
@@ -121,8 +122,8 @@ void Inter_v2::setupOpcodesFunc() {
OPCODEFUNC(0x17, o2_animPalInit);
- OPCODEFUNC(0x18, o2_addCollision);
- OPCODEFUNC(0x19, o2_freeCollision);
+ OPCODEFUNC(0x18, o2_addHotspot);
+ OPCODEFUNC(0x19, o2_removeHotspot);
OPCODEFUNC(0x25, o2_goblinFunc);
@@ -1176,67 +1177,51 @@ bool Inter_v2::o2_animPalInit(OpFuncParams &params) {
return false;
}
-bool Inter_v2::o2_addCollision(OpFuncParams &params) {
- int16 id;
- int16 left, top, width, height;
- int16 flags;
- int16 key;
- int16 funcSub;
-
- id = _vm->_game->_script->readValExpr();
- funcSub = _vm->_game->_script->pos();
- left = _vm->_game->_script->readValExpr();
- top = _vm->_game->_script->readValExpr();
- width = _vm->_game->_script->readValExpr();
- height = _vm->_game->_script->readValExpr();
- flags = _vm->_game->_script->readValExpr();
- key = _vm->_game->_script->readInt16();
+bool Inter_v2::o2_addHotspot(OpFuncParams &params) {
+ int16 id = _vm->_game->_script->readValExpr();
+ uint16 funcPos = _vm->_game->_script->pos();
+ int16 left = _vm->_game->_script->readValExpr();
+ int16 top = _vm->_game->_script->readValExpr();
+ uint16 width = _vm->_game->_script->readValExpr();
+ uint16 height = _vm->_game->_script->readValExpr();
+ uint16 flags = _vm->_game->_script->readValExpr();
+ uint16 key = _vm->_game->_script->readInt16();
if (key == 0)
key = ABS(id) + 41960;
- _vm->_draw->adjustCoords(0, &left, &top);
- _vm->_draw->adjustCoords(2, &width, &height);
-
if (left < 0) {
width += left;
- left = 0;
+ left = 0;
}
if (top < 0) {
height += top;
- top = 0;
+ top = 0;
}
int16 index;
if (id < 0)
- index = _vm->_game->addNewCollision(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
- left + width + 3, top + height + 3, flags, key, 0, 0);
+ index = _vm->_game->_hotspots->add(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
+ left + width + 3, top + height + 3, flags, key, 0, 0, funcPos);
else
- index = _vm->_game->addNewCollision(0xE000 + id, left, top,
- left + width - 1, top + height - 1, flags, key, 0, 0);
-
- _vm->_game->_collisionAreas[index].funcSub = funcSub;
+ index = _vm->_game->_hotspots->add(0xE000 + id, left, top,
+ left + width - 1, top + height - 1, flags, key, 0, 0, funcPos);
return false;
}
-bool Inter_v2::o2_freeCollision(OpFuncParams &params) {
- int16 id;
+bool Inter_v2::o2_removeHotspot(OpFuncParams &params) {
+ int16 id = _vm->_game->_script->readValExpr();
+ uint8 stateType1 = Hotspots::kStateFilledDisabled | Hotspots::kStateType1;
+ uint8 stateType2 = Hotspots::kStateFilledDisabled | Hotspots::kStateType2;
- id = _vm->_game->_script->readValExpr();
- if (id == -2) {
- for (int i = 0; i < 150; i++) {
- if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xD000)
- _vm->_game->_collisionAreas[i].left = 0xFFFF;
- }
- } else if (id == -1) {
- for (int i = 0; i < 150; i++) {
- if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xE000)
- _vm->_game->_collisionAreas[i].left = 0xFFFF;
- }
- } else
- _vm->_game->freeCollision(0xE000 + id);
+ if (id == -2)
+ _vm->_game->_hotspots->removeState(stateType1);
+ else if (id == -1)
+ _vm->_game->_hotspots->removeState(stateType2);
+ else
+ _vm->_game->_hotspots->remove((stateType2 << 12) + id);
return false;
}