aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/dreamweb/dreamweb.cpp19
-rw-r--r--engines/dreamweb/module.mk1
-rw-r--r--engines/dreamweb/mouse.cpp187
-rw-r--r--engines/dreamweb/stubs.cpp142
4 files changed, 188 insertions, 161 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 2e9c7bb2b8..0a35bcdecc 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -422,25 +422,6 @@ void DreamWebEngine::keyPressed(uint16 ascii) {
DreamWeb::g_keyBuffer[in] = ascii;
}
-void DreamWebEngine::mouseCall(uint16 *x, uint16 *y, uint16 *state) {
- processEvents();
- Common::Point pos = _eventMan->getMousePos();
- if (pos.x > 298)
- pos.x = 298;
- if (pos.x < 15)
- pos.x = 15;
- if (pos.y < 15)
- pos.y = 15;
- if (pos.y > 184)
- pos.y = 184;
- *x = pos.x;
- *y = pos.y;
-
- unsigned newState = _eventMan->getButtonState();
- *state = (newState == _oldMouseState? 0 : newState);
- _oldMouseState = newState;
-}
-
void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) {
_system->getPaletteManager()->grabPalette(data, start, count);
while (count--)
diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk
index 6bc4f8728e..3e367c6fdf 100644
--- a/engines/dreamweb/module.mk
+++ b/engines/dreamweb/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
dreamweb.o \
keypad.o \
monitor.o \
+ mouse.o \
newplace.o \
object.o \
pathfind.o \
diff --git a/engines/dreamweb/mouse.cpp b/engines/dreamweb/mouse.cpp
new file mode 100644
index 0000000000..043aaeb2f4
--- /dev/null
+++ b/engines/dreamweb/mouse.cpp
@@ -0,0 +1,187 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/events.h"
+#include "dreamweb/dreamweb.h"
+
+namespace DreamWeb {
+
+void DreamWebEngine::mouseCall(uint16 *x, uint16 *y, uint16 *state) {
+ processEvents();
+ Common::Point pos = _eventMan->getMousePos();
+ if (pos.x > 298)
+ pos.x = 298;
+ if (pos.x < 15)
+ pos.x = 15;
+ if (pos.y < 15)
+ pos.y = 15;
+ if (pos.y > 184)
+ pos.y = 184;
+ *x = pos.x;
+ *y = pos.y;
+
+ unsigned newState = _eventMan->getButtonState();
+ *state = (newState == _oldMouseState? 0 : newState);
+ _oldMouseState = newState;
+}
+
+void DreamWebEngine::readMouse() {
+ _oldButton = _mouseButton;
+ _mouseButton = readMouseState();
+}
+
+uint16 DreamWebEngine::readMouseState() {
+ _oldX = _mouseX;
+ _oldY = _mouseY;
+ uint16 x, y, state;
+ mouseCall(&x, &y, &state);
+ _mouseX = x;
+ _mouseY = y;
+ return state;
+}
+
+void DreamWebEngine::dumpPointer() {
+ dumpBlink();
+ multiDump(_delHereX, _delHereY, _delXS, _delYS);
+ if ((_oldPointerX != _delHereX) || (_oldPointerY != _delHereY))
+ multiDump(_oldPointerX, _oldPointerY, _pointerXS, _pointerYS);
+}
+
+void DreamWebEngine::showPointer() {
+ showBlink();
+ uint16 x = _mouseX;
+ _oldPointerX = _mouseX;
+ uint16 y = _mouseY;
+ _oldPointerY = _mouseY;
+ if (_pickUp == 1) {
+ const GraphicsFile *frames;
+ if (_objectType != kExObjectType)
+ frames = &_freeFrames;
+ else
+ frames = &_exFrames;
+ const Frame *frame = &frames->_frames[(3 * _itemFrame + 1)];
+
+ uint8 width = frame->width;
+ uint8 height = frame->height;
+ if (width < 12)
+ width = 12;
+ if (height < 12)
+ height = 12;
+ _pointerXS = width;
+ _pointerYS = height;
+ uint16 xMin = (x >= width / 2) ? x - width / 2 : 0;
+ uint16 yMin = (y >= height / 2) ? y - height / 2 : 0;
+ _oldPointerX = xMin;
+ _oldPointerY = yMin;
+ multiGet(_pointerBack, xMin, yMin, width, height);
+ showFrame(*frames, x, y, 3 * _itemFrame + 1, 128);
+ showFrame(_icons1, x, y, 3, 128);
+ } else {
+ const Frame *frame = &_icons1._frames[_pointerFrame + 20];
+ uint8 width = frame->width;
+ uint8 height = frame->height;
+ if (width < 12)
+ width = 12;
+ if (height < 12)
+ height = 12;
+ _pointerXS = width;
+ _pointerYS = height;
+ multiGet(_pointerBack, x, y, width, height);
+ showFrame(_icons1, x, y, _pointerFrame + 20, 0);
+ }
+}
+
+void DreamWebEngine::delPointer() {
+ if (_oldPointerX == 0xffff)
+ return;
+ _delHereX = _oldPointerX;
+ _delHereY = _oldPointerY;
+ _delXS = _pointerXS;
+ _delYS = _pointerYS;
+ multiPut(_pointerBack, _delHereX, _delHereY, _pointerXS, _pointerYS);
+}
+
+void DreamWebEngine::animPointer() {
+ if (_pointerMode == 2) {
+ _pointerFrame = 0;
+ if ((_realLocation == 14) && (_commandType == 211))
+ _pointerFrame = 5;
+ return;
+ } else if (_pointerMode == 3) {
+ if (_pointerSpeed != 0) {
+ --_pointerSpeed;
+ } else {
+ _pointerSpeed = 5;
+ ++_pointerCount;
+ if (_pointerCount == 16)
+ _pointerCount = 0;
+ }
+ _pointerFrame = (_pointerCount <= 8) ? 1 : 2;
+ return;
+ }
+ if (_vars._watchingTime != 0) {
+ _pointerFrame = 11;
+ return;
+ }
+ _pointerFrame = 0;
+ if (_inMapArea == 0)
+ return;
+ if (_pointerFirstPath == 0)
+ return;
+ uint8 flag, flagEx;
+ getFlagUnderP(&flag, &flagEx);
+ if (flag < 2)
+ return;
+ if (flag >= 128)
+ return;
+ if (flag & 4) {
+ _pointerFrame = 3;
+ return;
+ }
+ if (flag & 16) {
+ _pointerFrame = 4;
+ return;
+ }
+ if (flag & 2) {
+ _pointerFrame = 5;
+ return;
+ }
+ if (flag & 8) {
+ _pointerFrame = 6;
+ return;
+ }
+ _pointerFrame = 8;
+}
+
+void DreamWebEngine::checkCoords(const RectWithCallback *rectWithCallbacks) {
+ if (_newLocation != 0xff)
+ return;
+ const RectWithCallback *r;
+ for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
+ if (r->contains(_mouseX, _mouseY)) {
+ (this->*(r->_callback))();
+ return;
+ }
+ }
+}
+
+} // End of namespace DreamWeb
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 5a53b82510..750dafe7b4 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -876,22 +876,6 @@ void DreamWebEngine::hangOnCurs(uint16 frameCount) {
}
}
-void DreamWebEngine::readMouse() {
- _oldButton = _mouseButton;
- uint16 state = readMouseState();
- _mouseButton = state;
-}
-
-uint16 DreamWebEngine::readMouseState() {
- _oldX = _mouseX;
- _oldY = _mouseY;
- uint16 x, y, state;
- mouseCall(&x, &y, &state);
- _mouseX = x;
- _mouseY = y;
- return state;
-}
-
void DreamWebEngine::dumpTextLine() {
if (_newTextLine != 1)
return;
@@ -1513,16 +1497,6 @@ void DreamWebEngine::obName(uint8 command, uint8 commandType) {
}
}
-void DreamWebEngine::delPointer() {
- if (_oldPointerX == 0xffff)
- return;
- _delHereX = _oldPointerX;
- _delHereY = _oldPointerY;
- _delXS = _pointerXS;
- _delYS = _pointerYS;
- multiPut(_pointerBack, _delHereX, _delHereY, _pointerXS, _pointerYS);
-}
-
void DreamWebEngine::showBlink() {
if (_manIsOffScreen == 1)
return;
@@ -1554,110 +1528,6 @@ void DreamWebEngine::dumpBlink() {
multiDump(44, 32, 16, 12);
}
-void DreamWebEngine::dumpPointer() {
- dumpBlink();
- multiDump(_delHereX, _delHereY, _delXS, _delYS);
- if ((_oldPointerX != _delHereX) || (_oldPointerY != _delHereY))
- multiDump(_oldPointerX, _oldPointerY, _pointerXS, _pointerYS);
-}
-
-void DreamWebEngine::showPointer() {
- showBlink();
- uint16 x = _mouseX;
- _oldPointerX = _mouseX;
- uint16 y = _mouseY;
- _oldPointerY = _mouseY;
- if (_pickUp == 1) {
- const GraphicsFile *frames;
- if (_objectType != kExObjectType)
- frames = &_freeFrames;
- else
- frames = &_exFrames;
- const Frame *frame = &frames->_frames[(3 * _itemFrame + 1)];
-
- uint8 width = frame->width;
- uint8 height = frame->height;
- if (width < 12)
- width = 12;
- if (height < 12)
- height = 12;
- _pointerXS = width;
- _pointerYS = height;
- uint16 xMin = (x >= width / 2) ? x - width / 2 : 0;
- uint16 yMin = (y >= height / 2) ? y - height / 2 : 0;
- _oldPointerX = xMin;
- _oldPointerY = yMin;
- multiGet(_pointerBack, xMin, yMin, width, height);
- showFrame(*frames, x, y, 3 * _itemFrame + 1, 128);
- showFrame(_icons1, x, y, 3, 128);
- } else {
- const Frame *frame = &_icons1._frames[_pointerFrame + 20];
- uint8 width = frame->width;
- uint8 height = frame->height;
- if (width < 12)
- width = 12;
- if (height < 12)
- height = 12;
- _pointerXS = width;
- _pointerYS = height;
- multiGet(_pointerBack, x, y, width, height);
- showFrame(_icons1, x, y, _pointerFrame + 20, 0);
- }
-}
-
-void DreamWebEngine::animPointer() {
-
- if (_pointerMode == 2) {
- _pointerFrame = 0;
- if ((_realLocation == 14) && (_commandType == 211))
- _pointerFrame = 5;
- return;
- } else if (_pointerMode == 3) {
- if (_pointerSpeed != 0) {
- --_pointerSpeed;
- } else {
- _pointerSpeed = 5;
- ++_pointerCount;
- if (_pointerCount == 16)
- _pointerCount = 0;
- }
- _pointerFrame = (_pointerCount <= 8) ? 1 : 2;
- return;
- }
- if (_vars._watchingTime != 0) {
- _pointerFrame = 11;
- return;
- }
- _pointerFrame = 0;
- if (_inMapArea == 0)
- return;
- if (_pointerFirstPath == 0)
- return;
- uint8 flag, flagEx;
- getFlagUnderP(&flag, &flagEx);
- if (flag < 2)
- return;
- if (flag >= 128)
- return;
- if (flag & 4) {
- _pointerFrame = 3;
- return;
- }
- if (flag & 16) {
- _pointerFrame = 4;
- return;
- }
- if (flag & 2) {
- _pointerFrame = 5;
- return;
- }
- if (flag & 8) {
- _pointerFrame = 6;
- return;
- }
- _pointerFrame = 8;
-}
-
void DreamWebEngine::printMessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered) {
const uint8 *string = (const uint8 *)_commandText.getString(index);
printDirect(string, x, y, maxWidth, centered);
@@ -3183,16 +3053,4 @@ void DreamWebEngine::purgeAnItem() {
}
}
-void DreamWebEngine::checkCoords(const RectWithCallback *rectWithCallbacks) {
- if (_newLocation != 0xff)
- return;
- const RectWithCallback *r;
- for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
- if (r->contains(_mouseX, _mouseY)) {
- (this->*(r->_callback))();
- return;
- }
- }
-}
-
} // End of namespace DreamWeb