[Scummvm-devel] Skim, V6 and arrays

Max Horn max at quendi.de
Sat Apr 24 06:11:02 CEST 2004


Am 21.04.2004 um 11:58 schrieb David Given:

> On Wednesday 21 April 2004 08:29, M. Uli Kusterer wrote:
> [...]
>>   I've been reading the Scumm docs on the Skim page. Now, there are a
>> few more questions that aren't answered there, and since you guys now
>> the engine inside out, I thought you might be able to give me a quick
>> answer without any of us having to dig through tons of source code.
>
> Remember that the stuff on the Skim page is incomplete, unfinished, 
> and likely
> extremely inaccurate!
>
>>   When an array is loaded/created using opcodes like dim or dim2, this
>> is like malloc()-ing an array in C, right? You get a new pointer to
>> that array, and you're responsible for getting rid of it, right?
>
> Is this V5 or V6?
>
> V5 supports 32 arrays; when you initialise the array, you tell it 
> which one
> you want.
>
> V6 arrays are much more like how you describe; dim and dim2 create a 
> new array
> and return you the handle of it. I believe you can also predefine 
> arrays in
> the AARY chunk. But my recollection of this is very hazy; I'd suggest 
> you
> look at the source code.

There is no such thing as a "handle" which is returned; rather, the 
bytecode can "dim" (=create) a new array with a given size; this array 
is then reference to via an array number (which is passed to "dim" by 
the bytecode). In particular, it's up the script to make sure it uses 
an array id which is not already in use; any existing array with that 
ID will be deleted.

The AARY blocks contain a list of predefined arrays. The only 
difference is that those arrays are automatically created, with the 
specified type/size; the scripts don't have to "manually" create them.

>>   And local variables can only contain integers, right?
>
> 16 words, yes.

Where a word is 32bit in SCUMM V8, and 16bit for the other versions.


>>   So, how does ScummVM handle strings? Do I create an array and stuff
>> my characters in the bytes there?
>
> Unsure.
>

These are essentially the same as the arrays. Which are internally 
realized as resources of type rtString. See also 
ScummEngine_v5::o5_stringOps() and ScummEngine_v6::o6_arrayOps()



Bye,

Max





More information about the Scummvm-devel mailing list