aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
authorStrangerke2015-12-08 08:42:08 +0100
committerWillem Jan Palenstijn2015-12-23 21:33:55 +0100
commit6b9264d9da41d8be08ea46076026901374d3d106 (patch)
treeb4929b0ceeaeaf6e23ddfe3bd46429f7127d12a6 /engines/lab
parent73eb0d2f284809d6bec2336d0647e9905368c3cd (diff)
downloadscummvm-rg350-6b9264d9da41d8be08ea46076026901374d3d106.tar.gz
scummvm-rg350-6b9264d9da41d8be08ea46076026901374d3d106.tar.bz2
scummvm-rg350-6b9264d9da41d8be08ea46076026901374d3d106.zip
LAB: Refactoring the vgaUnscale code and the way it's used
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/tilepuzzle.cpp54
-rw-r--r--engines/lab/utils.cpp29
-rw-r--r--engines/lab/utils.h3
3 files changed, 38 insertions, 48 deletions
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index cdc6735de3..2739473d47 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -66,17 +66,16 @@ void LabEngine::initTilePuzzle() {
/* Processes mouse clicks and changes the combination. */
/*****************************************************************************/
void LabEngine::mouseTile(Common::Point pos) {
- int x = _utils->vgaUnscaleX(pos.x);
- int y = _utils->vgaUnscaleY(pos.y);
+ Common::Point realPos = _utils->vgaUnscale(pos);
- if ((x < 101) || (y < 26))
+ if ((realPos.x < 101) || (realPos.y < 26))
return;
- x = (x - 101) / 30;
- y = (y - 26) / 25;
+ int tileX = (realPos.x - 101) / 30;
+ int tileY = (realPos.y - 26) / 25;
- if ((x < 4) && (y < 4))
- changeTile(x, y);
+ if ((tileX < 4) && (tileY < 4))
+ changeTile(tileX, tileY);
}
/*****************************************************************************/
@@ -152,29 +151,26 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
/* Processes mouse clicks and changes the combination. */
/*****************************************************************************/
void LabEngine::mouseCombination(Common::Point pos) {
- uint16 number;
-
- int x = _utils->vgaUnscaleX(pos.x);
- int y = _utils->vgaUnscaleY(pos.y);
-
- if ((y >= 63) && (y <= 99)) {
- if ((x >= 44) && (x < 83))
- number = 0;
- else if (x < 127)
- number = 1;
- else if (x < 165)
- number = 2;
- else if (x < 210)
- number = 3;
- else if (x < 245)
- number = 4;
- else if (x < 286)
- number = 5;
- else
- return;
+ Common::Point realPos = _utils->vgaUnscale(pos);
- changeCombination(number);
- }
+ if (!Common::Rect(44, 63, 285, 99).contains(realPos))
+ return;
+
+ uint16 number = 0;
+ if (realPos.x < 83)
+ number = 0;
+ else if (realPos.x < 127)
+ number = 1;
+ else if (realPos.x < 165)
+ number = 2;
+ else if (realPos.x < 210)
+ number = 3;
+ else if (realPos.x < 245)
+ number = 4;
+ else if (realPos.x < 286)
+ number = 5;
+
+ changeCombination(number);
}
/*****************************************************************************/
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 6d4784d0ac..041a970eff 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -59,7 +59,7 @@ uint16 Utils::scaleY(uint16 y) {
}
/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
+/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
/*****************************************************************************/
int16 Utils::vgaScaleX(int16 x) {
if (_vm->_isHiRes)
@@ -69,7 +69,7 @@ int16 Utils::vgaScaleX(int16 x) {
}
/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
+/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
/*****************************************************************************/
int16 Utils::vgaScaleY(int16 y) {
if (_vm->_isHiRes)
@@ -86,23 +86,18 @@ uint16 Utils::svgaCord(uint16 cord) {
}
/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
+/* Converts SVGA coords to VGA if necessary, otherwise returns VGA coords. */
/*****************************************************************************/
-int Utils::vgaUnscaleX(int x) {
- if (_vm->_isHiRes)
- return (x / 2);
- else
- return x;
-}
+Common::Point Utils::vgaUnscale(Common::Point pos) {
+ Common::Point result;
+ if (_vm->_isHiRes) {
+ result.x = pos.x / 2;
+ result.y = (pos.y * 5) / 12;
+ } else {
+ result = pos;
+ }
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
-/*****************************************************************************/
-int Utils::vgaUnscaleY(int y) {
- if (_vm->_isHiRes)
- return ((y * 5) / 12);
- else
- return y;
+ return result;
}
/*****************************************************************************/
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 4fa168dd54..441473672c 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -52,8 +52,7 @@ public:
int16 vgaScaleX(int16 x);
int16 vgaScaleY(int16 y);
uint16 svgaCord(uint16 cord);
- int vgaUnscaleX(int x);
- int vgaUnscaleY(int y);
+ Common::Point vgaUnscale(Common::Point pos);
void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
void runLengthDecode(byte *dest, byte *source);
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);