aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBenjamin Haisch2010-06-18 14:18:44 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:09 +0100
commit2acf1bf6f589f162908b456cb69cb03df6e798e7 (patch)
treeec6c1a91d4e93b93c9df6bca0f7e2125fa4ce6a1 /engines
parent8ea6831825f2d16ca03a8bc5be946465f9bb3fd9 (diff)
downloadscummvm-rg350-2acf1bf6f589f162908b456cb69cb03df6e798e7.tar.gz
scummvm-rg350-2acf1bf6f589f162908b456cb69cb03df6e798e7.tar.bz2
scummvm-rg350-2acf1bf6f589f162908b456cb69cb03df6e798e7.zip
TOLTECS: - Hopefully fixed a bug in findRectAtPoint which causes the game to crash before the first scene
- sfHandleInput
Diffstat (limited to 'engines')
-rw-r--r--engines/toltecs/script.cpp23
-rw-r--r--engines/toltecs/toltecs.cpp12
-rw-r--r--engines/toltecs/toltecs.h4
3 files changed, 30 insertions, 9 deletions
diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp
index 4aaa626dd9..d062f46806 100644
--- a/engines/toltecs/script.cpp
+++ b/engines/toltecs/script.cpp
@@ -920,10 +920,12 @@ void ScriptInterpreter::sfSetGuiHeight() {
void ScriptInterpreter::sfFindMouseInRectIndex1() {
int16 index = -1;
if (_vm->_mouseY < _vm->_cameraHeight) {
- index = _vm->findRectAtPoint(getSlotData(arg16(5)) + arg16(3),
+ int16 slotIndex = arg16(5);
+ index = _vm->findRectAtPoint(getSlotData(slotIndex) + arg16(3),
_vm->_mouseX + _vm->_cameraX,
_vm->_mouseY + _vm->_cameraY,
- arg16(11) + 1, arg16(7));
+ arg16(11) + 1, arg16(7),
+ getSlotData(slotIndex) + _slots[slotIndex].size);
}
localWrite16(arg16(9), index);
}
@@ -932,10 +934,12 @@ void ScriptInterpreter::sfFindMouseInRectIndex2() {
int16 index = -1;
if (_vm->_sceneResIndex != 0) {
if (_vm->_mouseY < _vm->_cameraHeight) {
- index = _vm->findRectAtPoint(getSlotData(arg16(5)) + arg16(3),
+ int16 slotIndex = arg16(5);
+ index = _vm->findRectAtPoint(getSlotData(slotIndex) + arg16(3),
_vm->_mouseX + _vm->_cameraX,
_vm->_mouseY + _vm->_cameraY,
- 0, arg16(7));
+ 0, arg16(7),
+ getSlotData(slotIndex) + _slots[slotIndex].size);
}
}
localWrite16(arg16(9), index);
@@ -1066,7 +1070,14 @@ void ScriptInterpreter::sfClearScreen() {
void ScriptInterpreter::sfHandleInput() {
// TODO: Recheck what this does
int16 varOfs = arg16(3);
- localWrite16(varOfs, 0);
+ int16 keyCode = 0;
+ if (_vm->_rightButtonDown) {
+ keyCode = 1;
+ } else {
+ // TODO: Handle Escape
+ // TODO: Set keyboard scancode
+ }
+ localWrite16(varOfs, keyCode);
}
void ScriptInterpreter::sfRunOptionsScreen() {
@@ -1074,7 +1085,7 @@ void ScriptInterpreter::sfRunOptionsScreen() {
}
/* NOTE: The opcodes sfPrecacheSprites, sfPrecacheSounds1, sfPrecacheSounds2 and
- sfDeletePrecachedFiles were used by the original engine to handle precaching
+ sfDeletePrecachedFiles were used by the original engine to handle precaching
of data so the game doesn't stall while playing (due to the slow speed of
CD-Drives back then). This is not needed in ScummVM since all supported
systems are fast enough to load data in-game. */
diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp
index 2e4d4f6454..62bf250062 100644
--- a/engines/toltecs/toltecs.cpp
+++ b/engines/toltecs/toltecs.cpp
@@ -245,6 +245,7 @@ void ToltecsEngine::updateScreen() {
//printf("_guiHeight = %d\n", _guiHeight); fflush(stdout);
if (_screen->_guiRefresh && _guiHeight > 0 && _cameraHeight > 0) {
+ // Update the GUI when needed and it's visible
_system->copyRectToScreen((const byte *)_screen->_frontScreen + _cameraHeight * 640,
640, 0, _cameraHeight, 640, _guiHeight);
_screen->_guiRefresh = false;
@@ -263,6 +264,9 @@ void ToltecsEngine::updateInput() {
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
+ _keyState = event.kbd;
+
+ //debug("key: flags = %02X; keycode = %d", _keyState.flags, _keyState.keycode);
// FIXME: This is just for debugging
switch (event.kbd.keycode) {
@@ -277,6 +281,9 @@ void ToltecsEngine::updateInput() {
}
break;
+ case Common::EVENT_KEYUP:
+ _keyState.reset();
+ break;
case Common::EVENT_QUIT:
quitGame();
break;
@@ -540,11 +547,12 @@ void ToltecsEngine::walk(byte *walkData) {
}
-int16 ToltecsEngine::findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize) {
+int16 ToltecsEngine::findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize,
+ byte *rectDataEnd) {
rectData += index * itemSize;
- while (1) {
+ while (rectData < rectDataEnd) {
int16 rectY = READ_LE_UINT16(rectData);
if (rectY == -10)
break;
diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h
index 7816b3b2e9..bcd2c3d234 100644
--- a/engines/toltecs/toltecs.h
+++ b/engines/toltecs/toltecs.h
@@ -98,7 +98,8 @@ public:
void walk(byte *walkData);
- int16 findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize);
+ int16 findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize,
+ byte *rectDataEnd);
public:
@@ -130,6 +131,7 @@ public:
int16 _walkSpeedY, _walkSpeedX;
+ Common::KeyState _keyState;
int16 _mouseX, _mouseY;
int16 _mouseCounter;
bool _mouseButtonPressedFlag;