Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#377 closed defect

FOA: Bad colours for light and shadows

Reported by: eriktorbjorn Owned by: fingolfin
Priority: normal Component: Engine: SCUMM
Keywords: Cc:
Game: Indiana Jones 4

Description

This applies to the July 29 CVS snapshot:

In the scene where you dive for Atlantis, the colours for the boat and submarine shadows are incorrect (see attached screen shot). A similar phenomenon also happens when riding the subway car.

In both these cases, unkRoomFunc3() will be called, which currently does nothing. My theory is that it should be setting up the _transEffect[] array. The first two arguments look like they would be min and max colours, while the remaining three arguments could be scale factors for R, G, and B.

I've included a rough patch which produces reasonable results for the diving scene and the first half of the subway car ride. That I'm not submitting it as a batch is because it's pretty broken in some other respects. The colours look strange in the second half of the subway ride, and the light doesn't fade out like I think it should. Also, since the _transEffect[] array isn't saved, restoring a saved game during one of these scenes will cause bad colours as well.

I checked with 0.2.0, and for some reason I don't get the psychedelic colours or recent snapshots. Instead, the submarine shadow is rendered as solid black.

Ticket imported from: #588501. Ticket imported from: bugs/377.

Attachments (9)

transeffect.diff (6.4 KB ) - added by eriktorbjorn 18 years ago.
Experimental patch. Don't apply this to CVS yet.
atlantis.s01 (53.4 KB ) - added by eriktorbjorn 18 years ago.
Saved game right before the diving scene
atlantis.s02 (54.7 KB ) - added by eriktorbjorn 18 years ago.
Saved game right before the subway car ride
snapshot1.png (48.1 KB ) - added by eriktorbjorn 18 years ago.
Screenshot without experimental patch
snapshot2.png (48.1 KB ) - added by eriktorbjorn 18 years ago.
Screenshot with experimental patch
subway7.png (49.9 KB ) - added by eriktorbjorn 18 years ago.
Beginning of subway ride, with DOSEMU
subway8.png (51.1 KB ) - added by eriktorbjorn 18 years ago.
Middle of subway ride, with DOSEMU
subway9.png (20.2 KB ) - added by eriktorbjorn 18 years ago.
End of subway ride, with DOSEMU
unkroomfunc3.diff (1.9 KB ) - added by eriktorbjorn 18 years ago.
Updated (but still not correct) patch

Download all attachments as: .zip

Change History (20)

by eriktorbjorn, 18 years ago

Attachment: transeffect.diff added

Experimental patch. Don't apply this to CVS yet.

by eriktorbjorn, 18 years ago

Attachment: atlantis.s01 added

Saved game right before the diving scene

by eriktorbjorn, 18 years ago

Attachment: atlantis.s02 added

Saved game right before the subway car ride

by eriktorbjorn, 18 years ago

Attachment: snapshot1.png added

Screenshot without experimental patch

by eriktorbjorn, 18 years ago

Attachment: snapshot2.png added

Screenshot with experimental patch

comment:1 by eriktorbjorn, 18 years ago

I meant "submitting as a patch", not as a "batch", of course.

What I forgot to mention is that since I don't see _transEffect[] being initialised anywhere, the results without the patch are probably undefined, i.e. you may not get the same psychedelic colours as I did. I could be wrong about that, though.

comment:2 by fingolfin, 18 years ago

Owner: set to fingolfin

comment:3 by fingolfin, 18 years ago

I poked thru old versions of ScummVM, and in the end found out the truth about _transEffect - it's simply _shadowPalette! Thus, got rid of all references to it, and use _shadow_table in the CostumeRenderer class instead.

Please check if this helps or not. I can't verify myself right now, since I can't load your savegame for some reasons (Error(42:59:0x2FA): No verb block in object 500!). What version of FOA are you using?

by eriktorbjorn, 18 years ago

Attachment: subway7.png added

Beginning of subway ride, with DOSEMU

comment:4 by eriktorbjorn, 18 years ago

I'll try it for real when I get home. In the meantime, assuming your changes have made it into the daily Windows snapshot, then no, it doesn't help. I no longer get psychedelic colours, though. In fact, I don't even see the lights and shadows at all.

Considering that unkRoomFunc3() is still a no-op, this isn't particularly surprising. I would assume that _shadowPalette still has its default mapping, i.e. the identity function.

I've made some more investiation on my end, and it turns out my guess for the first two parameters to unkRoomFunc3() were most likely wrong. At the end of the subway ride, the function is called several times in rapid succession with 160 and 191 as the first two arguments, and as far as I can tell none of the colours in the 160-191 interval are used for drawing the subway headlight. So there has to be some other use for these, but I have no idea what that is. Except that in this case they must be used to further brighten the colours.

(As far as I remember, these arguments are 16, 255 in the diving scene, and 0, 255 at the beginning of the subway scene, and for those cases the output from my experimental patch looks ok.)

I'm attaching some screenshots of the subway ride that I made with DOSEMU. It's the last one that I haven't been able to figure out how to emulate properly.

It's a pity the save games don't work for you. I don't know which versions there are of FOA, but the one I have is an English CD "talkie" version. By the way, the diving scene is in the demo so you should be able to reach that one pretty quickly, even without a saved game.

by eriktorbjorn, 18 years ago

Attachment: subway8.png added

Middle of subway ride, with DOSEMU

by eriktorbjorn, 18 years ago

Attachment: subway9.png added

End of subway ride, with DOSEMU

by eriktorbjorn, 18 years ago

Attachment: unkroomfunc3.diff added

Updated (but still not correct) patch

comment:5 by eriktorbjorn, 18 years ago

I've updated the patch to take the recent changes in account. It still doesn't work correctly, though, but maybe someone can figure out what's wrong?

comment:6 by eriktorbjorn, 18 years ago

This may be significant: I just noticed that all the colours I need to paint the beam of light in the subway9.png screenshot seem to be in the 160-191 range of the palette, i.e. the first two arguments may be describing which part of the palette it's ok to map colours to.

(Actually, the colours aren't exactly the same as in the screenshot, but I'm going to ignore that for the moment. Who knows what DOSEMU does to pick colours anyway?)

I don't yet know how to create that mapping, though. I'll keep looking...

comment:7 by SF/ender, 18 years ago

Fingolfin, do you want to apply the patch as-is? It's better than nothing, even if it still has one remaining issue..

comment:8 by fingolfin, 18 years ago

Status: newclosed

comment:9 by fingolfin, 18 years ago

Done. With additional comments.

comment:10 by SF/jamieson630, 18 years ago

Refer to Patch #608543, just posted. This patch contains a corrected algorithm, along with a description of what had to be changed to make this work.

The key was to use the CLUT palette, NOT the current palette (which is way too dark in some cases). The output from this one matches LEC's except for some very slight and occassional pixel variations. Possibly rounding differences on the computations, but I'm not sure. Nothing that would jump out at a user and shout, "Look, I'm SCREWY!" ;-)

comment:11 by eriktorbjorn, 18 years ago

Cool! I had pretty much given up hope on ever figuring this one out.

Note: See TracTickets for help on using tickets.