Studying sword1 engine

Ask for help with ScummVM problems

Moderator: ScummVM Team

Post Reply
timetravel0
Posts: 2
Joined: Sat Sep 16, 2023 1:20 pm

Studying sword1 engine

Post by timetravel0 »

I'm interested in understanding the logics behind Virtual Engine so i started analyzing sword1 engine.
I managed to create a python procedure able to parse swordref.rif and extracting the correspondent resources from any *.clu file.

The point is that now i want to parse properly each file extracted; At the moment i identified three different types of file:
- ChrTxt --> dialogues
- Sprite --> most likely images
- RIFF --> audio files

Starting from ChrTxt, i understood there's an header (20 bytes) composed by:

Code: Select all

        'Type'
        'Version'
        'Compressed Length'
        'Compression'
        'Decompressed Length'
Point is after those 20 bytes, there's still a variable portion of bytes (dependant from the overall dimension of the ChrTxt file) that i do not understand how to parse.
Did someone already went through this?

Similarly for the "Sprite" i did not understand how to parse each file and recreate the image.
Tried to analyze the sword1 engine but it's difficult without documentation.

Any help would be really appreciated.
Thanks in advance to the whole community
AndywinXp
ScummVM Developer
Posts: 29
Joined: Sun Jul 29, 2012 8:15 pm

Re: Studying sword1 engine

Post by AndywinXp »

No way! I was just doing exactly that too yesterday, what are the chances of that? :lol:

Here's my script:
https://gist.github.com/AndywinXp/7e42a ... feeee090b8

Right now I'm only parsing Sprite resources (the ones with compression type NONE). To test it you can open the SWORDRES.RIF file with the application, then open the "general" cluster, go to group 5, find the resource with size 768 and click it, and then go to anything else in that group to visualize fonts and graphics from the main menu. I am also parsing ChrTxt resources (printing them not on the GUI but on the terminal).

Currently I'm not supporting resource extraction but that's on my list, if I ever get around to finish this thing, because right now it's just about the worst hacky piece of code I have ever written.

Now, as for the ChrTxt format, my best guess is:
- The header you mentioned
- Number of items (uint32)
- Exactly the above number of offsets
- The various text files
timetravel0
Posts: 2
Joined: Sat Sep 16, 2023 1:20 pm

Re: Studying sword1 engine

Post by timetravel0 »

Ciao Andy, interesting.
Here's what i am working on:
https://gist.github.com/timetravel0/9cf ... 1d415f03ae

- read.py splits clu(s) in different chunks
- read_obj.py permits to read the content of different types (ChrTxt only at the moment!)

End goal would be extracting logics/scripts as well to understand more in deep Virtual Theatre.
Step by step :)
Post Reply