SCUMM: v7-8: Fix FT camera bug and properly fix #1195 and #1579

There was a nasty bug in the fuel tower room, when the cops arrive at the
tower and the player regains control, in which the camera would be brought up
and then down again.

While I was there, since this is the same domain, I rechecked the v7-8 camera
code from the disasm, made some corrections, and properly fixed #1195 and
#1579. Another workaround bites the dust :)
This commit is contained in:
AndywinXp 2023-01-08 17:42:50 +01:00
parent a79e451fee
commit 61fa4b6253
4 changed files with 17 additions and 16 deletions

View File

@ -169,6 +169,7 @@ void ScummEngine::moveCamera() {
void ScummEngine::cameraMoved() {
int screenLeft;
if (_game.version >= 7) {
clampCameraPos(&camera._cur);
assert(camera._cur.x >= (_screenWidth / 2) && camera._cur.y >= (_screenHeight / 2));
} else {
if (camera._cur.x < (_screenWidth / 2)) {
@ -222,23 +223,15 @@ void ScummEngine_v7::setCameraAt(int pos_x, int 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) {
if (VAR(VAR_SCROLL_SCRIPT)) {
if (VAR(VAR_SCROLL_SCRIPT) && _game.version != 8) {
VAR(VAR_CAMERA_POS_X) = camera._cur.x;
VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0);
}
// Even though cameraMoved() is called automatically, we may
// need to know at once that the camera has moved, or text may
// be printed at the wrong coordinates. See bugs #1195 and
// #1579
cameraMoved();
}
}
@ -248,7 +241,6 @@ void ScummEngine_v7::setCameraFollows(Actor *a, bool setCamera) {
int ax, ay;
camera._follows = a->_number;
VAR(VAR_CAMERA_FOLLOWED_ACTOR) = a->_number;
if (!a->isInCurrentRoom()) {
startScene(a->getRoom(), 0, 0);
@ -345,9 +337,19 @@ void ScummEngine_v7::moveCamera() {
cameraMoved();
if (camera._cur.x != old.x || camera._cur.y != old.y) {
if (_game.id != GID_FT) {
VAR(VAR_CAMERA_POS_X) = camera._cur.x;
VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
VAR(VAR_CAMERA_DEST_X) = camera._dest.x;
VAR(VAR_CAMERA_DEST_Y) = camera._dest.y;
VAR(VAR_CAMERA_FOLLOWED_ACTOR) = camera._follows;
}
if (camera._cur.x != old.x || camera._cur.y != old.y) {
if (_game.id == GID_FT) {
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);
@ -355,7 +357,7 @@ void ScummEngine_v7::moveCamera() {
}
void ScummEngine_v7::panCameraTo(int x, int y) {
VAR(VAR_CAMERA_FOLLOWED_ACTOR) = camera._follows = 0;
camera._follows = 0;
VAR(VAR_CAMERA_DEST_X) = camera._dest.x = x;
VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = y;
}

View File

@ -1063,7 +1063,6 @@ void ScummEngine_v6::o6_setCameraAt() {
int x, y;
camera._follows = 0;
VAR(VAR_CAMERA_FOLLOWED_ACTOR) = 0;
y = pop();
x = pop();

View File

@ -2623,7 +2623,7 @@ void ScummEngine_v90he::scummLoop(int delta) {
#endif
void ScummEngine::scummLoop_updateScummVars() {
if (_game.version >= 7) {
if (_game.version == 7) {
VAR(VAR_CAMERA_POS_X) = camera._cur.x;
VAR(VAR_CAMERA_POS_Y) = camera._cur.y;
} else if (_game.platform == Common::kPlatformNES) {

View File

@ -634,11 +634,11 @@ void ScummEngine_v7::CHARSET_1() {
StringTab saveStr = _string[0];
if (a && _string[0].overhead) {
int s;
_string[0].xpos = a->getPos().x - _virtscr[kMainVirtScreen].xstart;
_string[0].xpos = a->getPos().x + (_screenWidth / 2) - camera._cur.x;
s = a->_scalex * a->_talkPosX / 255;
_string[0].xpos += (a->_talkPosX - s) / 2 + s;
_string[0].ypos = a->getPos().y - a->getElevation() - _screenTop;
_string[0].ypos = a->getPos().y - a->getElevation() + (_screenHeight / 2) - camera._cur.y;
s = a->_scaley * a->_talkPosY / 255;
_string[0].ypos += (a->_talkPosY - s) / 2 + s;