aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-05-29 12:55:28 +0000
committerMax Horn2003-05-29 12:55:28 +0000
commit1db0f749ca94598ec9a352a84a2ea0e4a248d375 (patch)
treef419b9a73c1b6368c8dd6cbf3d6af0ca0239a8ae /scumm
parent48ccc623ac2666177f67f03b039633b28ff827c3 (diff)
downloadscummvm-rg350-1db0f749ca94598ec9a352a84a2ea0e4a248d375.tar.gz
scummvm-rg350-1db0f749ca94598ec9a352a84a2ea0e4a248d375.tar.bz2
scummvm-rg350-1db0f749ca94598ec9a352a84a2ea0e4a248d375.zip
moved camera stuff to own file
svn-id: r8099
Diffstat (limited to 'scumm')
-rw-r--r--scumm/camera.cpp373
-rw-r--r--scumm/gfx.cpp371
-rw-r--r--scumm/gfx.h21
-rw-r--r--scumm/intern.h8
-rw-r--r--scumm/module.mk1
-rw-r--r--scumm/scumm.h8
6 files changed, 405 insertions, 377 deletions
diff --git a/scumm/camera.cpp b/scumm/camera.cpp
new file mode 100644
index 0000000000..5e21944ef1
--- /dev/null
+++ b/scumm/camera.cpp
@@ -0,0 +1,373 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2003 The ScummVM project
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "stdafx.h"
+#include "scumm.h"
+#include "intern.h"
+#include "actor.h"
+#include "charset.h"
+
+void Scumm::setCameraAtEx(int at) {
+ if (!(_features & GF_AFTER_V7)) {
+ camera._mode = CM_NORMAL;
+ camera._cur.x = at;
+ setCameraAt(at, 0);
+ camera._movingToActor = false;
+ }
+}
+
+void Scumm::setCameraAt(int pos_x, int pos_y) {
+ if (camera._mode != CM_FOLLOW_ACTOR || abs(pos_x - camera._cur.x) > (_screenWidth / 2)) {
+ camera._cur.x = pos_x;
+ }
+ camera._dest.x = pos_x;
+
+ if (camera._cur.x < VAR(VAR_CAMERA_MIN_X))
+ camera._cur.x = (short) VAR(VAR_CAMERA_MIN_X);
+
+ if (camera._cur.x > VAR(VAR_CAMERA_MAX_X))
+ camera._cur.x = (short) VAR(VAR_CAMERA_MAX_X);
+
+ if (VAR_SCROLL_SCRIPT != 0xFF && VAR(VAR_SCROLL_SCRIPT)) {
+ if (_features & GF_AFTER_V2)
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x / 8;
+ else
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x;
+ runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
+ }
+
+ if (camera._cur.x != camera._last.x && _charset->_hasMask)
+ stopTalk();
+}
+
+void Scumm_v7::setCameraAt(int pos_x, int pos_y) {
+ ScummVM::Point old;
+
+ old = camera._cur;
+
+ camera._cur.x = pos_x;
+ camera._cur.y = pos_y;
+
+ clampCameraPos(&camera._cur);
+
+ camera._dest = camera._cur;
+ VAR(VAR_CAMERA_DEST_X) = camera._dest.x;
+ VAR(VAR_CAMERA_DEST_Y) = camera._dest.y;
+
+ assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
+
+ if ((camera._cur.x != old.x || camera._cur.y != old.y)
+ && VAR(VAR_SCROLL_SCRIPT)) {
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x;
+ VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
+ runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
+ }
+}
+
+void Scumm::setCameraFollows(Actor *a) {
+
+ int t, i;
+
+ camera._mode = CM_FOLLOW_ACTOR;
+ camera._follows = a->number;
+
+ if (!a->isInCurrentRoom()) {
+ startScene(a->getRoom(), 0, 0);
+ camera._mode = CM_FOLLOW_ACTOR;
+ camera._cur.x = a->x;
+ setCameraAt(camera._cur.x, 0);
+ }
+
+ t = (a->x >> 3);
+
+ if (t - _screenStartStrip < camera._leftTrigger || t - _screenStartStrip > camera._rightTrigger)
+ setCameraAt(a->x, 0);
+
+ for (i = 1; i < _numActors; i++) {
+ if (_actors[i].isInCurrentRoom())
+ _actors[i].needRedraw = true;
+ }
+ runHook(0);
+}
+
+void Scumm_v7::setCameraFollows(Actor *a) {
+
+ byte oldfollow = camera._follows;
+ int ax, ay;
+
+ camera._follows = a->number;
+ VAR(VAR_CAMERA_FOLLOWED_ACTOR) = a->number;
+
+ if (!a->isInCurrentRoom()) {
+ startScene(a->getRoom(), 0, 0);
+ }
+
+ ax = abs(a->x - camera._cur.x);
+ ay = abs(a->y - camera._cur.y);
+
+ if (ax > VAR(VAR_CAMERA_THRESHOLD_X) || ay > VAR(VAR_CAMERA_THRESHOLD_Y) || ax > (_screenWidth / 2) || ay > (_screenHeight / 2)) {
+ setCameraAt(a->x, a->y);
+ }
+
+ if (a->number != oldfollow)
+ runHook(0);
+}
+
+
+void Scumm::clampCameraPos(ScummVM::Point *pt) {
+ if (pt->x < VAR(VAR_CAMERA_MIN_X))
+ pt->x = (short) VAR(VAR_CAMERA_MIN_X);
+
+ if (pt->x > VAR(VAR_CAMERA_MAX_X))
+ pt->x = (short) VAR(VAR_CAMERA_MAX_X);
+
+ if (pt->y < VAR(VAR_CAMERA_MIN_Y))
+ pt->y = (short) VAR(VAR_CAMERA_MIN_Y);
+
+ if (pt->y > VAR(VAR_CAMERA_MAX_Y))
+ pt->y = (short) VAR(VAR_CAMERA_MAX_Y);
+}
+
+void Scumm::moveCamera() {
+ if (_features & GF_AFTER_V7) {
+ ScummVM::Point old = camera._cur;
+ Actor *a = NULL;
+
+ if (camera._follows) {
+ a = derefActor(camera._follows, "moveCamera");
+ if (abs(camera._cur.x - a->x) > VAR(VAR_CAMERA_THRESHOLD_X) ||
+ abs(camera._cur.y - a->y) > VAR(VAR_CAMERA_THRESHOLD_Y)) {
+ camera._movingToActor = true;
+ if (VAR(VAR_CAMERA_THRESHOLD_X) == 0)
+ camera._cur.x = a->x;
+ if (VAR(VAR_CAMERA_THRESHOLD_Y) == 0)
+ camera._cur.y = a->y;
+ clampCameraPos(&camera._cur);
+ }
+ } else {
+ camera._movingToActor = false;
+ }
+
+ if (camera._movingToActor) {
+ VAR(VAR_CAMERA_DEST_X) = camera._dest.x = a->x;
+ VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = a->y;
+ }
+
+ assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
+
+ clampCameraPos(&camera._dest);
+
+ if (camera._cur.x < camera._dest.x) {
+ camera._cur.x += (short) VAR(VAR_CAMERA_SPEED_X);
+ if (camera._cur.x > camera._dest.x)
+ camera._cur.x = camera._dest.x;
+ }
+
+ if (camera._cur.x > camera._dest.x) {
+ camera._cur.x -= (short) VAR(VAR_CAMERA_SPEED_X);
+ if (camera._cur.x < camera._dest.x)
+ camera._cur.x = camera._dest.x;
+ }
+
+ if (camera._cur.y < camera._dest.y) {
+ camera._cur.y += (short) VAR(VAR_CAMERA_SPEED_Y);
+ if (camera._cur.y > camera._dest.y)
+ camera._cur.y = camera._dest.y;
+ }
+
+ if (camera._cur.y > camera._dest.y) {
+ camera._cur.y -= (short) VAR(VAR_CAMERA_SPEED_Y);
+ if (camera._cur.y < camera._dest.y)
+ camera._cur.y = camera._dest.y;
+ }
+
+ if (camera._cur.x == camera._dest.x && camera._cur.y == camera._dest.y) {
+
+ camera._movingToActor = false;
+ camera._accel.x = camera._accel.y = 0;
+ VAR(VAR_CAMERA_SPEED_X) = VAR(VAR_CAMERA_SPEED_Y) = 0;
+ } else {
+
+ camera._accel.x += (short) VAR(VAR_CAMERA_ACCEL_X);
+ camera._accel.y += (short) VAR(VAR_CAMERA_ACCEL_Y);
+
+ VAR(VAR_CAMERA_SPEED_X) += camera._accel.x / 100;
+ VAR(VAR_CAMERA_SPEED_Y) += camera._accel.y / 100;
+
+ if (VAR(VAR_CAMERA_SPEED_X) < 8)
+ VAR(VAR_CAMERA_SPEED_X) = 8;
+
+ if (VAR(VAR_CAMERA_SPEED_Y) < 8)
+ VAR(VAR_CAMERA_SPEED_Y) = 8;
+
+ }
+
+ cameraMoved();
+
+ if (camera._cur.x != old.x || camera._cur.y != old.y) {
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x;
+ VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
+
+ if (VAR(VAR_SCROLL_SCRIPT))
+ runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
+ }
+ } else {
+ int pos = camera._cur.x;
+ int actorx, t;
+ Actor *a = NULL;
+
+ camera._cur.x &= 0xFFF8;
+
+ if (camera._cur.x < VAR(VAR_CAMERA_MIN_X)) {
+ if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
+ camera._cur.x = (short) VAR(VAR_CAMERA_MIN_X);
+ else
+ camera._cur.x += 8;
+ cameraMoved();
+ return;
+ }
+
+ if (camera._cur.x > VAR(VAR_CAMERA_MAX_X)) {
+ if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
+ camera._cur.x = (short) VAR(VAR_CAMERA_MAX_X);
+ else
+ camera._cur.x -= 8;
+ cameraMoved();
+ return;
+ }
+
+ if (camera._mode == CM_FOLLOW_ACTOR) {
+ a = derefActor(camera._follows, "moveCamera");
+
+ actorx = a->x;
+ t = (actorx >> 3) - _screenStartStrip;
+
+ if (t < camera._leftTrigger || t > camera._rightTrigger) {
+ if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
+ if (t > 35)
+ camera._dest.x = actorx + 80;
+ if (t < 5)
+ camera._dest.x = actorx - 80;
+ } else
+ camera._movingToActor = true;
+ }
+ }
+
+ if (camera._movingToActor) {
+ a = derefActor(camera._follows, "moveCamera(2)");
+ camera._dest.x = a->x;
+ }
+
+ if (camera._dest.x < VAR(VAR_CAMERA_MIN_X))
+ camera._dest.x = (short) VAR(VAR_CAMERA_MIN_X);
+
+ if (camera._dest.x > VAR(VAR_CAMERA_MAX_X))
+ camera._dest.x = (short) VAR(VAR_CAMERA_MAX_X);
+
+ if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
+ camera._cur.x = camera._dest.x;
+ } else {
+ if (camera._cur.x < camera._dest.x)
+ camera._cur.x += 8;
+ if (camera._cur.x > camera._dest.x)
+ camera._cur.x -= 8;
+ }
+
+ /* a is set a bit above */
+ if (camera._movingToActor && (camera._cur.x >> 3) == (a->x >> 3)) {
+ camera._movingToActor = false;
+ }
+
+ cameraMoved();
+
+ if (VAR_SCROLL_SCRIPT != 0xFF && VAR(VAR_SCROLL_SCRIPT) && pos != camera._cur.x) {
+ if (_features & GF_AFTER_V2)
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x / 8;
+ else
+ VAR(VAR_CAMERA_POS_X) = camera._cur.x;
+ runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
+ }
+ }
+}
+
+void Scumm::cameraMoved() {
+ if (_features & GF_AFTER_V7) {
+ assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
+ } else {
+ if (camera._cur.x < (_screenWidth / 2)) {
+ camera._cur.x = (_screenWidth / 2);
+ } else if (camera._cur.x > _roomWidth - (_screenWidth / 2)) {
+ camera._cur.x = _roomWidth - (_screenWidth / 2);
+ }
+ }
+
+ _screenStartStrip = (camera._cur.x - (_screenWidth / 2)) >> 3;
+ _screenEndStrip = _screenStartStrip + gdi._numStrips - 1;
+
+ _screenTop = camera._cur.y - (_screenHeight / 2);
+ if (_features & GF_AFTER_V7) {
+
+ _screenLeft = camera._cur.x - (_screenWidth / 2);
+ } else {
+
+ _screenLeft = _screenStartStrip << 3;
+ }
+
+#ifdef V7_SMOOTH_SCROLLING_HACK
+ virtscr[0].xstart = _screenLeft;
+#else
+ virtscr[0].xstart = _screenStartStrip << 3;
+#endif
+}
+
+void Scumm::panCameraTo(int x, int y) {
+ camera._dest.x = x;
+ camera._mode = CM_PANNING;
+ camera._movingToActor = false;
+}
+
+void Scumm_v7::panCameraTo(int x, int y) {
+ VAR(VAR_CAMERA_FOLLOWED_ACTOR) = camera._follows = 0;
+ VAR(VAR_CAMERA_DEST_X) = camera._dest.x = x;
+ VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = y;
+}
+
+void Scumm::actorFollowCamera(int act) {
+ if (!(_features & GF_AFTER_V7)) {
+ int old;
+
+ /* mi1 compatibilty */
+ if (act == 0) {
+ camera._mode = CM_NORMAL;
+ camera._follows = 0;
+ camera._movingToActor = false;
+ return;
+ }
+
+ old = camera._follows;
+ setCameraFollows(derefActor(act, "actorFollowCamera"));
+ if (camera._follows != old)
+ runHook(0);
+
+ camera._movingToActor = false;
+ }
+}
+
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 34a0cbf060..5c58206687 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -33,26 +33,6 @@
#endif
-// If you wan to try buggy hacked smooth scrolling support in The Dig, enable
-// the following preprocessor flag by uncommenting it.
-//
-// Note: This is purely experimental, NOT WORKING COMPLETLY and very buggy.
-// Please do not make reports about problems with it - this is only in CVS
-// to get it fixed and so that really interested parties can experiment it.
-// It is NOT FIT FOR GENERAL USAGE! You have been warned.
-//
-// Doing this correctly will be quite some more complicated. Basically, with smooth
-// scrolling, the virtual screen strips don't match the display screen strips.
-// Hence we either have to draw partial strips - but that'd be rather cumbersome.
-// Or the much simple (and IMHO more elegant) solution is to simply use a screen pitch
-// that is 8 pixel wider than the real screen width, and always draw one strip more than
-// needed to the backbuf. This will still require quite some code to be changed but
-// should otherwise be relatively easy to understand, and using VirtScreen::pitch
-// will actually clean up the code.
-//
-// #define V7_SMOOTH_SCROLLING_HACK
-
-
enum {
kScrolltime = 500, // ms scrolling is supposed to take
kPictureDelay = 20
@@ -2005,357 +1985,6 @@ void Gdi::unkDecode11(byte *dst, const byte *src, int height) {
#undef READ_256BIT
#pragma mark -
-#pragma mark --- Camera ---
-#pragma mark -
-
-void Scumm::setCameraAtEx(int at) {
- if (!(_features & GF_AFTER_V7)) {
- camera._mode = CM_NORMAL;
- camera._cur.x = at;
- setCameraAt(at, 0);
- camera._movingToActor = false;
- }
-}
-
-void Scumm::setCameraAt(int pos_x, int pos_y) {
- if (_features & GF_AFTER_V7) {
- ScummVM::Point old;
-
- old = camera._cur;
-
- camera._cur.x = pos_x;
- camera._cur.y = pos_y;
-
- clampCameraPos(&camera._cur);
-
- camera._dest = camera._cur;
- VAR(VAR_CAMERA_DEST_X) = camera._dest.x;
- VAR(VAR_CAMERA_DEST_Y) = camera._dest.y;
-
- assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
-
- if ((camera._cur.x != old.x || camera._cur.y != old.y)
- && VAR(VAR_SCROLL_SCRIPT)) {
- VAR(VAR_CAMERA_POS_X) = camera._cur.x;
- VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
- runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
- }
- } else {
-
- if (camera._mode != CM_FOLLOW_ACTOR || abs(pos_x - camera._cur.x) > (_screenWidth / 2)) {
- camera._cur.x = pos_x;
- }
- camera._dest.x = pos_x;
-
- if (camera._cur.x < VAR(VAR_CAMERA_MIN_X))
- camera._cur.x = (short) VAR(VAR_CAMERA_MIN_X);
-
- if (camera._cur.x > VAR(VAR_CAMERA_MAX_X))
- camera._cur.x = (short) VAR(VAR_CAMERA_MAX_X);
-
- if (VAR_SCROLL_SCRIPT != 0xFF && VAR(VAR_SCROLL_SCRIPT)) {
- if (_features & GF_AFTER_V2)
- VAR(VAR_CAMERA_POS_X) = camera._cur.x / 8;
- else
- VAR(VAR_CAMERA_POS_X) = camera._cur.x;
- runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
- }
-
- if (camera._cur.x != camera._last.x && _charset->_hasMask)
- stopTalk();
- }
-}
-
-void Scumm::setCameraFollows(Actor *a) {
-
- if (_features & GF_AFTER_V7) {
- byte oldfollow = camera._follows;
- int ax, ay;
-
- camera._follows = a->number;
- VAR(VAR_CAMERA_FOLLOWED_ACTOR) = a->number;
-
- if (!a->isInCurrentRoom()) {
- startScene(a->getRoom(), 0, 0);
- }
-
- ax = abs(a->x - camera._cur.x);
- ay = abs(a->y - camera._cur.y);
-
- if (ax > VAR(VAR_CAMERA_THRESHOLD_X) || ay > VAR(VAR_CAMERA_THRESHOLD_Y) || ax > (_screenWidth / 2) || ay > (_screenHeight / 2)) {
- setCameraAt(a->x, a->y);
- }
-
- if (a->number != oldfollow)
- runHook(0);
- } else {
- int t, i;
-
- camera._mode = CM_FOLLOW_ACTOR;
- camera._follows = a->number;
-
- if (!a->isInCurrentRoom()) {
- startScene(a->getRoom(), 0, 0);
- camera._mode = CM_FOLLOW_ACTOR;
- camera._cur.x = a->x;
- setCameraAt(camera._cur.x, 0);
- }
-
- t = (a->x >> 3);
-
- if (t - _screenStartStrip < camera._leftTrigger || t - _screenStartStrip > camera._rightTrigger)
- setCameraAt(a->x, 0);
-
- for (i = 1; i < _numActors; i++) {
- if (_actors[i].isInCurrentRoom())
- _actors[i].needRedraw = true;
- }
- runHook(0);
- }
-}
-
-void Scumm::clampCameraPos(ScummVM::Point *pt) {
- if (pt->x < VAR(VAR_CAMERA_MIN_X))
- pt->x = (short) VAR(VAR_CAMERA_MIN_X);
-
- if (pt->x > VAR(VAR_CAMERA_MAX_X))
- pt->x = (short) VAR(VAR_CAMERA_MAX_X);
-
- if (pt->y < VAR(VAR_CAMERA_MIN_Y))
- pt->y = (short) VAR(VAR_CAMERA_MIN_Y);
-
- if (pt->y > VAR(VAR_CAMERA_MAX_Y))
- pt->y = (short) VAR(VAR_CAMERA_MAX_Y);
-}
-
-void Scumm::moveCamera() {
- if (_features & GF_AFTER_V7) {
- ScummVM::Point old = camera._cur;
- Actor *a = NULL;
-
- if (camera._follows) {
- a = derefActor(camera._follows, "moveCamera");
- if (abs(camera._cur.x - a->x) > VAR(VAR_CAMERA_THRESHOLD_X) ||
- abs(camera._cur.y - a->y) > VAR(VAR_CAMERA_THRESHOLD_Y)) {
- camera._movingToActor = true;
- if (VAR(VAR_CAMERA_THRESHOLD_X) == 0)
- camera._cur.x = a->x;
- if (VAR(VAR_CAMERA_THRESHOLD_Y) == 0)
- camera._cur.y = a->y;
- clampCameraPos(&camera._cur);
- }
- } else {
- camera._movingToActor = false;
- }
-
- if (camera._movingToActor) {
- VAR(VAR_CAMERA_DEST_X) = camera._dest.x = a->x;
- VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = a->y;
- }
-
- assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
-
- clampCameraPos(&camera._dest);
-
- if (camera._cur.x < camera._dest.x) {
- camera._cur.x += (short) VAR(VAR_CAMERA_SPEED_X);
- if (camera._cur.x > camera._dest.x)
- camera._cur.x = camera._dest.x;
- }
-
- if (camera._cur.x > camera._dest.x) {
- camera._cur.x -= (short) VAR(VAR_CAMERA_SPEED_X);
- if (camera._cur.x < camera._dest.x)
- camera._cur.x = camera._dest.x;
- }
-
- if (camera._cur.y < camera._dest.y) {
- camera._cur.y += (short) VAR(VAR_CAMERA_SPEED_Y);
- if (camera._cur.y > camera._dest.y)
- camera._cur.y = camera._dest.y;
- }
-
- if (camera._cur.y > camera._dest.y) {
- camera._cur.y -= (short) VAR(VAR_CAMERA_SPEED_Y);
- if (camera._cur.y < camera._dest.y)
- camera._cur.y = camera._dest.y;
- }
-
- if (camera._cur.x == camera._dest.x && camera._cur.y == camera._dest.y) {
-
- camera._movingToActor = false;
- camera._accel.x = camera._accel.y = 0;
- VAR(VAR_CAMERA_SPEED_X) = VAR(VAR_CAMERA_SPEED_Y) = 0;
- } else {
-
- camera._accel.x += (short) VAR(VAR_CAMERA_ACCEL_X);
- camera._accel.y += (short) VAR(VAR_CAMERA_ACCEL_Y);
-
- VAR(VAR_CAMERA_SPEED_X) += camera._accel.x / 100;
- VAR(VAR_CAMERA_SPEED_Y) += camera._accel.y / 100;
-
- if (VAR(VAR_CAMERA_SPEED_X) < 8)
- VAR(VAR_CAMERA_SPEED_X) = 8;
-
- if (VAR(VAR_CAMERA_SPEED_Y) < 8)
- VAR(VAR_CAMERA_SPEED_Y) = 8;
-
- }
-
- cameraMoved();
-
- if (camera._cur.x != old.x || camera._cur.y != old.y) {
- VAR(VAR_CAMERA_POS_X) = camera._cur.x;
- VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
-
- if (VAR(VAR_SCROLL_SCRIPT))
- runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
- }
- } else {
- int pos = camera._cur.x;
- int actorx, t;
- Actor *a = NULL;
-
- camera._cur.x &= 0xFFF8;
-
- if (camera._cur.x < VAR(VAR_CAMERA_MIN_X)) {
- if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
- camera._cur.x = (short) VAR(VAR_CAMERA_MIN_X);
- else
- camera._cur.x += 8;
- cameraMoved();
- return;
- }
-
- if (camera._cur.x > VAR(VAR_CAMERA_MAX_X)) {
- if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X))
- camera._cur.x = (short) VAR(VAR_CAMERA_MAX_X);
- else
- camera._cur.x -= 8;
- cameraMoved();
- return;
- }
-
- if (camera._mode == CM_FOLLOW_ACTOR) {
- a = derefActor(camera._follows, "moveCamera");
-
- actorx = a->x;
- t = (actorx >> 3) - _screenStartStrip;
-
- if (t < camera._leftTrigger || t > camera._rightTrigger) {
- if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
- if (t > 35)
- camera._dest.x = actorx + 80;
- if (t < 5)
- camera._dest.x = actorx - 80;
- } else
- camera._movingToActor = true;
- }
- }
-
- if (camera._movingToActor) {
- a = derefActor(camera._follows, "moveCamera(2)");
- camera._dest.x = a->x;
- }
-
- if (camera._dest.x < VAR(VAR_CAMERA_MIN_X))
- camera._dest.x = (short) VAR(VAR_CAMERA_MIN_X);
-
- if (camera._dest.x > VAR(VAR_CAMERA_MAX_X))
- camera._dest.x = (short) VAR(VAR_CAMERA_MAX_X);
-
- if (VAR_CAMERA_FAST_X != 0xFF && VAR(VAR_CAMERA_FAST_X)) {
- camera._cur.x = camera._dest.x;
- } else {
- if (camera._cur.x < camera._dest.x)
- camera._cur.x += 8;
- if (camera._cur.x > camera._dest.x)
- camera._cur.x -= 8;
- }
-
- /* a is set a bit above */
- if (camera._movingToActor && (camera._cur.x >> 3) == (a->x >> 3)) {
- camera._movingToActor = false;
- }
-
- cameraMoved();
-
- if (VAR_SCROLL_SCRIPT != 0xFF && VAR(VAR_SCROLL_SCRIPT) && pos != camera._cur.x) {
- if (_features & GF_AFTER_V2)
- VAR(VAR_CAMERA_POS_X) = camera._cur.x / 8;
- else
- VAR(VAR_CAMERA_POS_X) = camera._cur.x;
- runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
- }
- }
-}
-
-void Scumm::cameraMoved() {
- if (_features & GF_AFTER_V7) {
- assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
- } else {
- if (camera._cur.x < (_screenWidth / 2)) {
- camera._cur.x = (_screenWidth / 2);
- } else if (camera._cur.x > _roomWidth - (_screenWidth / 2)) {
- camera._cur.x = _roomWidth - (_screenWidth / 2);
- }
- }
-
- _screenStartStrip = (camera._cur.x - (_screenWidth / 2)) >> 3;
- _screenEndStrip = _screenStartStrip + gdi._numStrips - 1;
-
- _screenTop = camera._cur.y - (_screenHeight / 2);
- if (_features & GF_AFTER_V7) {
-
- _screenLeft = camera._cur.x - (_screenWidth / 2);
- } else {
-
- _screenLeft = _screenStartStrip << 3;
- }
-
-#ifdef V7_SMOOTH_SCROLLING_HACK
- virtscr[0].xstart = _screenLeft;
-#else
- virtscr[0].xstart = _screenStartStrip << 3;
-#endif
-}
-
-void Scumm::panCameraTo(int x, int y) {
- if (_features & GF_AFTER_V7) {
-
- VAR(VAR_CAMERA_FOLLOWED_ACTOR) = camera._follows = 0;
- VAR(VAR_CAMERA_DEST_X) = camera._dest.x = x;
- VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = y;
- } else {
-
- camera._dest.x = x;
- camera._mode = CM_PANNING;
- camera._movingToActor = false;
- }
-}
-
-void Scumm::actorFollowCamera(int act) {
- if (!(_features & GF_AFTER_V7)) {
- int old;
-
- /* mi1 compatibilty */
- if (act == 0) {
- camera._mode = CM_NORMAL;
- camera._follows = 0;
- camera._movingToActor = false;
- return;
- }
-
- old = camera._follows;
- setCameraFollows(derefActor(act, "actorFollowCamera"));
- if (camera._follows != old)
- runHook(0);
-
- camera._movingToActor = false;
- }
-}
-
-#pragma mark -
#pragma mark --- Transition effects ---
#pragma mark -
diff --git a/scumm/gfx.h b/scumm/gfx.h
index 5c49d27e22..0d54389a90 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -170,4 +170,25 @@ public:
};
};
+
+// If you wan to try buggy hacked smooth scrolling support in The Dig, enable
+// the following preprocessor flag by uncommenting it.
+//
+// Note: This is purely experimental, NOT WORKING COMPLETLY and very buggy.
+// Please do not make reports about problems with it - this is only in CVS
+// to get it fixed and so that really interested parties can experiment it.
+// It is NOT FIT FOR GENERAL USAGE! You have been warned.
+//
+// Doing this correctly will be quite some more complicated. Basically, with smooth
+// scrolling, the virtual screen strips don't match the display screen strips.
+// Hence we either have to draw partial strips - but that'd be rather cumbersome.
+// Or the much simple (and IMHO more elegant) solution is to simply use a screen pitch
+// that is 8 pixel wider than the real screen width, and always draw one strip more than
+// needed to the backbuf. This will still require quite some code to be changed but
+// should otherwise be relatively easy to understand, and using VirtScreen::pitch
+// will actually clean up the code.
+//
+// #define V7_SMOOTH_SCROLLING_HACK
+
+
#endif
diff --git a/scumm/intern.h b/scumm/intern.h
index 3db728ebb1..efd16eb17f 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -520,9 +520,13 @@ public:
protected:
virtual void setupScummVars();
+
+ virtual void setCameraAt(int pos_x, int pos_y);
+ virtual void panCameraTo(int x, int y);
+ virtual void setCameraFollows(Actor *a);
};
-class Scumm_v8 : public Scumm_v6 {
+class Scumm_v8 : public Scumm_v7 {
protected:
typedef void (Scumm_v8::*OpcodeProcV8)();
struct OpcodeEntryV8 {
@@ -533,7 +537,7 @@ protected:
const OpcodeEntryV8 *_opcodesV8;
public:
- Scumm_v8(GameDetector *detector, OSystem *syst) : Scumm_v6(detector, syst) {}
+ Scumm_v8(GameDetector *detector, OSystem *syst) : Scumm_v7(detector, syst) {}
protected:
virtual void setupOpcodes();
diff --git a/scumm/module.mk b/scumm/module.mk
index 33e2efb282..eb616d2bd3 100644
--- a/scumm/module.mk
+++ b/scumm/module.mk
@@ -6,6 +6,7 @@ SCUMM_OBJS = \
scumm/base-costume.o \
scumm/boxes.o \
scumm/bundle.o \
+ scumm/camera.o \
scumm/charset.o \
scumm/costume.o \
scumm/debugger.o \
diff --git a/scumm/scumm.h b/scumm/scumm.h
index bfc801a034..2b9f208049 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -736,7 +736,6 @@ protected:
void processActors();
void processUpperActors();
int getActorFromPos(int x, int y);
- void actorFollowCamera(int act);
bool isCostumeInUse(int i);
@@ -820,10 +819,11 @@ protected:
void moveCamera();
void cameraMoved();
void setCameraAtEx(int at);
- void setCameraAt(int pos_x, int pos_y);
- void panCameraTo(int x, int y);
- void setCameraFollows(Actor *a);
+ virtual void setCameraAt(int pos_x, int pos_y);
+ virtual void panCameraTo(int x, int y);
+ virtual void setCameraFollows(Actor *a);
void clampCameraPos(ScummVM::Point *pt);
+ void actorFollowCamera(int act);
const byte *getPalettePtr();
void setupEGAPalette();