aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-17 15:29:10 +0000
committerJohannes Schickel2008-04-17 15:29:10 +0000
commit66328be342c3b82b121744e52e6f55583e8309b4 (patch)
tree669ef3a6093f1af6805dd4fa5cc587ccacb41906 /engines/kyra
parent4685cc047d5908c110afb10422ae6f8f463f03fa (diff)
downloadscummvm-rg350-66328be342c3b82b121744e52e6f55583e8309b4.tar.gz
scummvm-rg350-66328be342c3b82b121744e52e6f55583e8309b4.tar.bz2
scummvm-rg350-66328be342c3b82b121744e52e6f55583e8309b4.zip
Added partial implementation of updateMouse cursor.
svn-id: r31537
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/items_v3.cpp39
-rw-r--r--engines/kyra/kyra_v3.cpp121
-rw-r--r--engines/kyra/kyra_v3.h39
-rw-r--r--engines/kyra/scene_v3.cpp13
4 files changed, 192 insertions, 20 deletions
diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp
index 303be84d66..7ec48c647d 100644
--- a/engines/kyra/items_v3.cpp
+++ b/engines/kyra/items_v3.cpp
@@ -51,4 +51,43 @@ int KyraEngine_v3::findFreeItem() {
return -1;
}
+int KyraEngine_v3::checkItemCollision(int x, int y) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::checkItemCollision(%d, %d)", x, y);
+ int itemIndex = -1;
+ int maxItemY = -1;
+
+ for (int i = 0; i < 50; ++i) {
+ if (_itemList[i].id == 0xFFFF || _itemList[i].sceneId != _mainCharacter.sceneId)
+ continue;
+
+ const int x1 = _itemList[i].x - 11;
+ const int x2 = _itemList[i].x + 10;
+
+ if (x < x1 || x > x2)
+ continue;
+
+ const int y1 = _itemList[i].y - _itemBuffer1[_itemList[i].id] - 3;
+ const int y2 = _itemList[i].y + 3;
+
+ if (y < y1 || y > y2)
+ continue;
+
+ if (_itemList[i].y >= maxItemY) {
+ itemIndex = i;
+ maxItemY = _itemList[i].y;
+ }
+ }
+
+ return itemIndex;
+}
+
+void KyraEngine_v3::setItemMouseCursor() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::setItemMouseCursor()");
+ _handItemSet = _itemInHand;
+ if (_itemInHand == -1)
+ _screen->setMouseCursor(0, 0, _gameShapes[0]);
+ else
+ _screen->setMouseCursor(0xC, 0x13, _gameShapes[_itemInHand+248]);
+}
+
} // end of namespace Kyra
diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp
index e956f8cbdd..848f062eab 100644
--- a/engines/kyra/kyra_v3.cpp
+++ b/engines/kyra/kyra_v3.cpp
@@ -916,7 +916,7 @@ void KyraEngine_v3::update() {
musicUpdate(0);
refreshAnimObjectsIfNeed();
musicUpdate(0);
- //XXX
+ updateMouse();
updateSpecialSceneScripts();
updateCommandLine();
//XXX
@@ -925,6 +925,125 @@ void KyraEngine_v3::update() {
_screen->updateScreen();
}
+void KyraEngine_v3::updateMouse() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::updateMouse()");
+ int shape = 0, offsetX = 0, offsetY = 0;
+ Common::Point mouse = getMousePos();
+ bool hasItemCollision = checkItemCollision(mouse.x, mouse.y) != -1;
+
+ if (mouse.y > 187) {
+ bool setItemCursor = false;
+ if (_handItemSet == -6) {
+ if (mouse.x < 311)
+ setItemCursor = true;
+ } else if (_handItemSet == -5) {
+ if (mouse.x < _sceneMinX || mouse.x > _sceneMaxX)
+ setItemCursor = true;
+ } else if (_handItemSet == -4) {
+ if (mouse.x > 8)
+ setItemCursor = true;
+ }
+
+ if (setItemCursor) {
+ setItemMouseCursor();
+ return;
+ }
+ }
+
+ if (_inventoryState) {
+ if (mouse.y >= 144)
+ return;
+ //hideInventory();
+ }
+
+ if (hasItemCollision && _handItemSet < -1 && _itemInHand < 0) {
+ _handItemSet = -1;
+ _itemInHand = -1;
+ _screen->setMouseCursor(0, 0, _gameShapes[0]);
+ }
+
+ int type = 0;
+ if (mouse.y <= 199) {
+ if (mouse.x <= 8) {
+ if (_sceneExit4 != 0xFFFF) {
+ type = -4;
+ shape = 4;
+ offsetX = 0;
+ offsetY = 0;
+ }
+ } else if (mouse.x >= 311) {
+ if (_sceneExit2 != 0xFFFF) {
+ type = -6;
+ shape = 2;
+ offsetX = 13;
+ offsetY = 8;
+ }
+ } else if (mouse.y >= 171) {
+ if (_sceneExit3 != 0xFFFF) {
+ if (mouse.x >= _sceneMinX && mouse.x <= _sceneMaxX) {
+ type = -5;
+ shape = 3;
+ offsetX = 8;
+ offsetY = 13;
+ }
+ }
+ } else if (mouse.y <= 8) {
+ if (_sceneExit1 != 0xFFFF) {
+ type = -7;
+ shape = 1;
+ offsetX = 8;
+ offsetY = 0;
+ }
+ }
+ }
+
+ for (int i = 0; i < _specialExitCount; ++i) {
+ if (checkSpecialSceneExit(i, mouse.x, mouse.y)) {
+ switch (_specialExitTable[20+i]) {
+ case 0:
+ type = -7;
+ shape = 1;
+ offsetX = 8;
+ offsetY = 0;
+ break;
+
+ case 2:
+ type = -6;
+ shape = 2;
+ offsetX = 13;
+ offsetY = 8;
+ break;
+
+ case 4:
+ type = -5;
+ shape = 3;
+ offsetX = 8;
+ offsetY = 13;
+ break;
+
+ case 6:
+ type = -4;
+ shape = 4;
+ offsetX = 0;
+ offsetY = 8;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if (type != 0 && type != _handItemSet && !hasItemCollision) {
+ _handItemSet = type;
+ _screen->setMouseCursor(offsetX, offsetY, _gameShapes[shape]);
+ } else if (type == 0 && _handItemSet != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) {
+ setItemMouseCursor();
+ } else if (mouse.y > 187 && _handItemSet > -4 && type == 0 && !_inventoryState) {
+ //showInventory();
+ }
+}
+
void KyraEngine_v3::delay(uint32 millis, bool doUpdate, bool isMainLoop) {
debugC(9, kDebugLevelMain, "KyraEngine_v3::delay(%d, %d, %d)", millis, doUpdate, isMainLoop);
uint32 endTime = _system->getMillis() + millis;
diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h
index f44529f38d..f5a0f282c0 100644
--- a/engines/kyra/kyra_v3.h
+++ b/engines/kyra/kyra_v3.h
@@ -74,6 +74,7 @@ private:
void handleInput(int x, int y);
void update();
+ void updateMouse();
void delay(uint32 millis, bool update = false, bool isMainLoop = false);
@@ -225,10 +226,28 @@ private:
// items
uint8 *_itemBuffer1;
uint8 *_itemBuffer2;
+ struct Item {
+ uint16 id;
+ uint16 sceneId;
+ int16 x, y;
+ uint16 unk8;
+ };
+
+ Item *_itemList;
+ uint16 _hiddenItems[100];
+
+ void resetItem(int index);
+ void resetItemList();
+
+ int findFreeItem();
void initItems();
+ int checkItemCollision(int x, int y);
+
// -> hand item
+ void setItemMouseCursor();
+
int _itemInHand;
int _handItemSet;
@@ -293,8 +312,10 @@ private:
int _sceneEnterX2, _sceneEnterY2;
int _sceneEnterX3, _sceneEnterY3;
int _sceneEnterX4, _sceneEnterY4;
+
int _specialExitCount;
uint16 _specialExitTable[25];
+ bool checkSpecialSceneExit(int index, int x, int y);
bool _noScriptEnter;
void enterNewScene(uint16 scene, int facing, int unk1, int unk2, int unk3);
@@ -314,7 +335,7 @@ private:
void runSceneScript4(int unk1);
void runSceneScript8();
- int _sceneMinY, _sceneMaxY;
+ int _sceneMinX, _sceneMaxX;
int _maskPageMinY, _maskPageMaxY;
ScriptState _sceneScriptState;
@@ -339,22 +360,6 @@ private:
bool _unkSceneScreenFlag1;
- // items
- struct Item {
- uint16 id;
- uint16 sceneId;
- int16 x, y;
- uint16 unk8;
- };
-
- Item *_itemList;
- uint16 _hiddenItems[100];
-
- void resetItem(int index);
- void resetItemList();
-
- int findFreeItem();
-
// character
struct Character {
uint16 sceneId;
diff --git a/engines/kyra/scene_v3.cpp b/engines/kyra/scene_v3.cpp
index 26999627bb..1b4378fdde 100644
--- a/engines/kyra/scene_v3.cpp
+++ b/engines/kyra/scene_v3.cpp
@@ -429,8 +429,8 @@ void KyraEngine_v3::initSceneScript(int unk1) {
_sceneEnterY3 = 171;
_sceneEnterX4 = 24;
_sceneEnterY4 = 93;
- _sceneMinY = 0;
- _sceneMaxY = 319;
+ _sceneMinX = 0;
+ _sceneMaxX = 319;
_scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData);
strcpy(filename, scene.filename2);
@@ -679,4 +679,13 @@ void KyraEngine_v3::runSceneScript8() {
}
}
+bool KyraEngine_v3::checkSpecialSceneExit(int index, int x, int y) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::checkSpecialSceneExit(%d, %d, %d)", index, x, y);
+ if (_specialExitTable[index] < x && _specialExitTable[5+index] < y &&
+ _specialExitTable[10+index] > x && _specialExitTable[15+index] > y)
+ return true;
+
+ return false;
+}
+
} // end of namespace Kyra