Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCUMM: Fix the stairs in room 32 for the earliest Loom EGA releases #4258

Merged

Conversation

dwatteau
Copy link
Contributor

@dwatteau dwatteau commented Sep 6, 2022

This was found by @einstein95 on Discord while comparing the scripts of the 1.0/1.1/1.2 EGA releases of Loom.

scummvm-loom-ega-fr-00000

In the earliest 16-color releases of Loom (English only, it seems), Bobbin will walk through the stairs (literally) if you exit one of the rooms in the dragon's cave by using the staircase on the right, after entering the room with the stairs in the middle of the ground. The 16-color 1.2 releases (and probably all later versions) fixed this, but it seems that the original 16-color English release is always 1.0/1.1 and so it always has this bug.

(EDIT: this problem also happens with the original DOS interpreter, if using a 1.0/1.1 version.)

Explanations

It appears that the staircase is drawn with two objects, no. 540 and 541. Their states should change in some conditions (I can't say why it has to do that, though).

The 1.2 DOS/EGA French release appears to have fixed is this way:

LFv3_0032/ROv3/OCv3_0537:
=========================

@@ -5,6 +5,7 @@ Events:
 (30) setBoxFlags(0,0);
 (30) setBoxFlags(1,0);
 (30) setBoxFlags(2,0);
+(07) setState(541,0);
 (05) drawObject(540,255,255);
 (5D) setClass(1,[0,146]);
 (1E) walkActorTo(1,430,80);

LFv3_0032/SCv3_0079:
====================

@@ -13,6 +13,7 @@
 (30) setBoxFlags(2,0);
 (0A) startScript(18,[2]);
 (80) breakHere();
+(07) setState(541,0);
 (05) drawObject(540,255,255);
 (2D) putActorInRoom(1,32);
 (01) putActor(1,480,80);
@@ -27,6 +28,7 @@
 (30) setBoxFlags(2,128);
 (5D) setClass(1,[0]);
 (01) putActor(1,442,72);
+(07) setState(540,0);
 (05) drawObject(541,255,255);
 (80) breakHere();
 (C0) endCutscene();

The entry script for that room also has some differences, but it looks like descumm has trouble properly decoding it. Fortunately, the excellent NUTCracker now has support for decoding v3 scripts, too.

So here's the difference for the entry script of room 32, with windex syntax:

@@ -116,9 +119,11 @@ room room_32 {
        set-box 1 to 128
        set-box 2 to 128
        if !(V.112 is 30) jump not_v112
+       state-of 541 is 0
        draw-object 540 at 255,255
        jump done
not_v112:
+       state-of 540 is 0
        draw-object 541 at 255,255
done:
        load-costume 98
@@ -128,6 +133,13 @@ done:
        put-actor 2 in-room 32
        put-actor 2 at 53,30
        do-animation 2 7
+       break-here
+       break-here
+       complex-temp = actor-x 1
+       if !(complex-temp <= 380) jump nope
+       state-of 540 is 0
+       draw-object 541 at 255,255
+nope:
        end-object
}

This one is looking at Bobbin's coordinates on the screen, 380 looking close to the base of the staircase…

I couldn't find a nice, simple way of replicating all these changes (especially the entry script ones) but it looks like I've found a smaller workaround which has the same effect. I'm not really sure of what I'm doing here, but it's a very simple room and I can't find any issue with this workaround. Tests welcome, though!

How to test

  1. Start any 16-color release of Loom (Macintosh, Amiga and Atari tests welcome! especially the Macintosh one, since it's quite different!)
  2. In the ScummVM debugger, run room 32. Exit the room with the stairs in the ground, and then walk back to room 32 (otherwise you won't see the bug).
  3. Walk to the top of the staircase on the right. In the 1.0/1.1 releases (type Ctrl-V in-game), Bobbin will glitch through the stairs in this case, unless you use this enhancement. In the 1.2 release, the bug should already be fixed, but this workaround shouldn't cause any regression either.
  4. Also try walking the other stairs, walking to the left of the room… there should be no regression.

Tested with the DOS/EGA English release (had the bug), and the DOS/EGA French release (didn't have the bug).

@athrxx
Copy link
Member

athrxx commented Sep 6, 2022

Is it a bug that also happens with the original interpreter (otherwise we'd rather fix it on the lower level)?

@einstein95
Copy link
Contributor

einstein95 commented Sep 6, 2022

@athrxx After checking in both 1.0 and 1.1 using dosbox (enabling debug mode using schwanensee+F7, Shift+G, "room 32 xpos 60"), the bug doesn't appear there

@athrxx
Copy link
Member

athrxx commented Sep 6, 2022

Weird. There must have been some reason to fix the scripts, though.

@einstein95
Copy link
Contributor

einstein95 commented Sep 7, 2022

@athrxx So, I was incorrect. I was able to replicate the bug with the original interpreter. This is because of how the bug is activated.

  • If you enter in via debug room code, the bug isn't present.
  • If you enter in via the door on the rightmost side, the bug isn't present.
  • If you enter in via the stairs in the middle of the right-hand side of the room, the bug is present.

@eriktorbjorn
Copy link
Member

eriktorbjorn commented Sep 7, 2022

Seems to work fine with my Macintosh version. I don't think it shows any version information on Ctrl+V, but in a Mac emulator it claims to be "Release Version 1.2 25-JAN-91". I hope I didn't mess up by making a savegame in the room (before exiting through the stairs in the floor) and tested from that.

Before:

loom-before

After:

loom-after

@athrxx
Copy link
Member

athrxx commented Sep 7, 2022

Since this has now been confirmed to be an original issue that workaround seems to be the right approach.

@dwatteau
Copy link
Contributor Author

dwatteau commented Sep 7, 2022

Yes sorry, when I submit new workarounds I usually check that the issue also happens with the original interpreters, but I sometimes forget to mention it!

You also need to exit this room and come back from the stairs in the middle of the ground to see the issue; I'll edit my description above to make it clearer.

Thanks for the tests!

The earliest 16-color releases of Loom have a bug when Bobbin exits
room 32 (in the dragon's cave) with the staircase on the right: he will
walk *through* them instead of just walking *on* them, if he entered the
room via the other stairs in the ground.

This has been fixed in some 1.2 and later releases, but the original
16-color English releases appear to always have this bug (even with the
original interpreters).  The 1.2 release fixed this with more changes
(incl. checking Bobbin's coordinates), but this smaller fix appears to
be enough.

With some help from eientei on Discord, who also found that the
scripts were different in this room between the EGA releases.
@dwatteau dwatteau force-pushed the fix/scumm-loom-older-ega-stairs-bug-room-32 branch from 52e23ed to 05a98c3 Compare Sep 7, 2022
@bluegr
Copy link
Member

bluegr commented Sep 11, 2022

Very nice work and thorough explanation, thanks! Merging

@bluegr bluegr merged commit b4caf16 into scummvm:master Sep 11, 2022
8 checks passed
@dwatteau dwatteau deleted the fix/scumm-loom-older-ega-stairs-bug-room-32 branch Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants