Starting at (I think) SCI 1.1 Sierra decided to change format of the script 
resource
and split it into 2 parts - script and heap, when only the "heap" part is 
loaded to the
heap of the vm (which is limited to 64kb).

I have made a research of the new format and till now I have found this:

when you load "script" #N you have to load also "heap" #N. Both resources 
have the data
part and then follows a relocation table. The first word in the both 
resources indicate the length
of the data part in bytes (and also the offset to find the relocation 
table). This first word is considered
a part of this "data part".

First we get the length of the data part of the "heap" resource, allocate a 
place in the heap (at address "H1" )and copy the data part of the "heap" 
resource there.

Then we need to relocate both resources (the same alogorithm):

We go to the reloc table, the first word is the number of the entries. Then 
follows entries; each of them is a word
that is an offset to the data part of the resource, on this offset we read 
a word, add H1 (the heap-allocated block) to it
and write it back. This relocates all absolute heap addresses.

The "heap" resource: The next word is a size of the next block - contains a 
number of words that follows. I don't know
what is the meaning of this block yet. The next word should contain the 
magic number 0x1234 - I think this is the 1st object in the resource. (i.e. 
Get Word at offset 2, multiply by 2(number of words), add 4(skip first 2 
words) and on this offset in the "heap" resource should be word containing 
0x1234). The next word after the magic 0x1234 is a number of words in this 
block, i.e. multiply by 2 and add to the previous offset to get the 
position of the next "magic" number 0x1234.

I still need to figure out the rest.

Petr





Reply via email to