Difference between revisions of "SCUMM/Virtual Machine"

Jump to navigation Jump to search
m
Modify table header colouring
m (fine-tuning)
m (Modify table header colouring)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== The SCUMM virtual machine ==
== The SCUMM virtual machine ==


The SCUMM virtual machine was given a complete rewrite between version 5 and version 6. Both virtual machines are simple byte-code machines with built-in cooperative threading; up to 25 threads can be run simultaneously. Each thread gets 16 words of local storage. Up to 8192 words and 32768 bits of global storage are also available. The word and bit storage areas occupy seperate address spaces. The exception to this rule is Zak256, where both actually use the same memory (possibly this is also true for other older SCUMM versions).  
The SCUMM virtual machine was given a complete rewrite between version 5 and version 6. Both virtual machines are simple byte-code machines with built-in cooperative threading; up to 25 threads can be run simultaneously. Each thread gets 16 words of local storage. Up to 8192 words and 32768 bits of global storage are also available. The word and bit storage areas occupy separate address spaces. The exception to this rule is Zak256, where both actually use the same memory (possibly this is also true for other older SCUMM versions).  


The V5 machine has hard-coded limits on 800 word variables and 2048 bit variables. All operations are done to and from a variable (global or local). The V6 machine can stores the number of variables in the '''MAXS''' resource in the index and uses a 100-word global stack for performing operations.  
The V5 machine has hard-coded limits on 800 word variables and 2048 bit variables. All operations are done to and from a variable (global or local). The V6 machine can stores the number of variables in the '''MAXS''' resource in the index and uses a 100-word global stack for performing operations.  


Additional storage is supplied in Array resources. V5 requires arrays to be declared in the data file; V6 can define new ones on the fly, which means they can be used as a dynamic heap.  
Additional storage is supplied in Array resources. V5 requires arrays to be declared in the data file; V6 can define new ones on the fly, which means they can be used as a dynamic heap.


== Pointers ==
== Pointers ==
Line 14: Line 14:


{| border="1" cellpadding="2" width=25%
{| border="1" cellpadding="2" width=25%
|-
|- style="background:gainsboro"
|15||14||13||12 ... 0
|15||14||13||12 ... 0
|- style="background:silver"
|-  
|0||0||0||address
|0||0||0||address
|-
|-
Line 26: Line 26:


{| border="1" cellpadding="2" width=15%
{| border="1" cellpadding="2" width=15%
|- style="background:gainsboro"
|15||14 ... 0
|-
|-
|15||14 ... 0
|- style="background:silver"
|1||address
|1||address
|-
|-
Line 36: Line 36:


{| border="1" cellpadding="2" width=30%
{| border="1" cellpadding="2" width=30%
|- style="background:gainsboro"
|15||14||13||12 ... 4||3 ... 0
|-
|-
|15||14||13||12 ... 4||3 ... 0
|- style="background:silver"
|0||1||?||0||var no
|0||1||?||0||var no
|-
|-
Line 46: Line 46:


{| border="1" cellpadding="2" width=25%
{| border="1" cellpadding="2" width=25%
|- style="background:gainsboro"
|15||14||13||12 ... 0
|-
|-
|15||14||13||12 ... 0
|- style="background:silver"
|0||0||1||address
|0||0||1||address
|- style="background:silver"
|-
|0||0||I||offset
|0||0||I||offset
|-
|-
Line 66: Line 66:


{| border="1" cellpadding="2" width=100%
{| border="1" cellpadding="2" width=100%
|- style="background:silver"
|- style="background:gainsboro"
|State||Meaning
|State||Meaning
|-
|-
Line 98: Line 98:


{| border="1" cellpadding="2" width=10%
{| border="1" cellpadding="2" width=10%
|- style="background:gainsboro"
|7||6 ... 0
|-
|-
|7||6 0
|- style="background:silver"
|p1||$5A
|p1||$5A
|-
|-
Line 107: Line 107:
If the ''p1'' bit is set, then the parameter is evaluated as a pointer and dereferenced. Otherwise it is treated as a constant. If multiple parameters are present, the bits work down from the MSB to the LSB.  
If the ''p1'' bit is set, then the parameter is evaluated as a pointer and dereferenced. Otherwise it is treated as a constant. If multiple parameters are present, the bits work down from the MSB to the LSB.  


However, many instructions are exceptions to this rule. For example, instructions such as '''actorSet''' that take an auxiliary opcode will put it somewhere in the instruction stream; '''actorSet''' puts it after the first parameter, and then the other parameters vary according to the particular operation. '''jumpRelative''' puts the jump target immediately after the opcode encoded as a constant. Some opcodes (such as '''drawBox''') take too many parameters and have a supplementary opcode byte to contain the extra parameter bits. You have been warned.  
However, many instructions are exceptions to this rule. For example, instructions such as '''actorSet''' that take an auxiliary opcode will put it somewhere in the instruction stream; '''actorSet''' puts it after the first parameter, and then the other parameters vary according to the particular operation. '''jumpRelative''' puts the jump target immediately after the opcode encoded as a constant. Some opcodes (such as '''drawBox''') take too many parameters and have a supplementary opcode byte to contain the extra parameter bits. You have been warned.


== Version 6 instruction encoding ==
== Version 6 instruction encoding ==
125

edits

Navigation menu