gmarty / scumm-nes

An app to explore and modify the game Maniac Mansion on NES 🎮.
https://gmarty.github.io/scumm-nes/
Other
3 stars 5 forks source link

Apply attribute table values on state change #5

Closed gzip closed 3 months ago

gzip commented 4 months ago

Check the garage door objects in room 16 to close the garage door and the attribute table is not updated correctly. Same issue with the shower curtain in room 24, the sarcophagus in room 25, and the refrigerator in room 7, maybe others.

The attribute data is not straightforward to deal with If I recall correctly.

gmarty commented 4 months ago

Yes, that's one of the things that needs implementing. What's missing is the data is not yet parsed. I had a quick look at SCUMMVM and I think the code to port is here: https://github.com/scummvm/scummvm/blob/master/engines/scumm/gfx.cpp#L3104-L3134

Yes, the encoding used here doesn't look familiar to me.

The mask object override will need to be ported as well.

gmarty commented 3 months ago

The object attribute change was implemented in c026038. The rooms you mention look great now!

gzip commented 3 months ago

Whoa, that's a lot if bitwise operations! Any idea what it's doing or is it just a direct port? Would you be able to document the format now or implement that data from scratch for new objects?

gmarty commented 3 months ago

Unfortunately I can't 🙈 I just ported the code from C directly. I'll have to look into though if I am to write a serialiser for objects. The complexity lays in working with bitwise operators, but at least we know the input and the output. With some test driven development it should be doable to write the inverse function.

gzip commented 3 months ago

It looks overly complex so that's understandable. I just wonder what the purpose of all the complexity is. It might have to do with applying partial attribute updates since a single value covers so much area. Consider two objects with state changes that affect the same attribute value. But does such a case exist in MM?

In the longer term we could consider changing the format if that serves the tool better, but maybe all that complexity is necessary. Anyway, great job on the fix!