Difference between revisions of "SCUMM/V6 opcodes"
(→jumpTrue: added from http://www.scummvm.org/docs/specs/scrp-v6.php) |
(→kill: added from http://www.scummvm.org/docs/specs/scrp-v6.php) |
||
Line 478: | Line 478: | ||
==kill== | ==kill== | ||
'''Encoding''' | |||
''1A'' | |||
'''Stack''' | |||
''( value : -)'' | |||
'''Operation''' | |||
Pops the top value off the stack and discards it. | |||
==land== | ==land== |
Revision as of 13:54, 3 May 2007
SCUMM V6 opcodes
The following conventions are used in the encoding descriptions.
$AB | The constant hexadecimal byte 0xAB. |
value[8] | A constant byte value. |
value[16] | A constant word LE value. |
The following conventions are used in the stack descriptions:
(in1, in2, in3 : out1, out2)
Indicates that the opcode is called with three items on the stack (the most recently pushed being in3) and replaces them with two items on the stack (the most recently pushed being out2).
abs ($C4)
Stack
(in : out)
Operation
out := abs(in)
The absolute value of the top-most item on the stack is calculated. (The absolute value being the value with the sign bit stripped off.)
actorFollowCamera ($79)
actorSet ($9D)
add ($14)
Stack
(in1, in2 : out)
Operation
out := in1 + in2
Performs a division operation on the stack.
animateActor ($82)
arrayOps (This instruction varies considerably according to the form.)
Encoding
load array:
A4 CD arrayp16
define array:
A4 D0 arrayp16 data...
set array:
A4 D4 arrayp16
Stack
...todo...
6.4.7 MM 95 beginOverride
MM 6C breakHere
MM CA breakMaybe
MM 5A byteArrayDec
MM 52 byteArrayInc
byteArrayIndexedRead
Encoding
0A arrayp8
Stack
( indexx , indexy : value )
Operation
value := arrayp [ indexx , indexy ]
Reads the value at offset ( indexx , indexy ) from the array whose resource number is pointed to by arrayp . The array can be a byte or word array; byte values are not sign extended. Note that because arrayp is encoded as a byte, it can only point to a word variable in the range 0000 to 00FF. Use wordArrayIndexedRead for a more general form.
byteArrayIndexedWrite
Encoding
4A arrayp8
Stack ( indexx , indexy , value : -)
Operation arrayp [ indexx , indexy ] := value
Writes value to the array whose resource number is pointed to by arrayp at offset ( indexx , indexy ). The array can be a byte or word array; byte when writing to a byte array, value is truncated. Note that because arrayp is encoded as a byte, it can only point to a word variable in the range 0000 to 00FF. Use wordArrayIndexedWrite for a more general form.
byteArrayRead
Encoding
06 arrayp8
Stack
( index : value )
Operation
value := arrayp [0, index ]
Reads the value at position (0, index ) from the array whose resource number is pointed to by arrayp . The array can be a byte or word array; when writing to an array, byte values are not sign extended. Note that because arrayp is encoded as a byte, it can only point to a word variable in the range 0000 to 00FF. Use wordArrayRead for a more general form.
byteArrayWrite
Encoding
46 arrayp8
Stack
( index value : -)
Operation
arrayp [0, index ] := value
Writes value to the array whose resource number is pointed to by arrayp at offset (0, index ). The array can be a byte or word array; when writing to a byte array, value is truncated. Note that because arrayp is encoded as a byte, it can only point to a word variable in the range 0000 to 00FF. Use wordArrayWrite for a more general form.
MM 56 byteVarDec
MM 4E byteVarInc
MM 9A createBoxMatrix
MM 6B cursorCommand
MM 68 cutScene
delay
Encoding
B0
Stack
( delay : -)
Operation
Prevents the current thread from being rescheduled until delay ticks have passed. Deschedules immediately.
delayLonger
Encoding
B1
Stack
( delay : -)
Operation
Prevents the current thread from being rescheduled until delay× 60 ticks have passed ( delay seconds). Deschedules immediately.
delayVeryLong
Encoding
B2
Stack
( delay : -)
Operation
Prevents the current thread from being rescheduled until delay× 3600 ticks have passed ( delay minutes). Deschedules immediately.
dim
Encoding BC type8 arrayp16
Stack ( max : -)
Operation
Allocates or frees an array.
If type is CC, then the array whose resource number is pointed to by arrayp is freed. Otherwise, a new one-dimensional array with a maximum index of max (i.e., max is one less than the size) is allocated and the resource number written to arrayp .
When allocating an array, if type is C7 then the array will contain words; if it is CB, then it will contain bytes. All other values are undefined. [Currently they all produce a byte array. What are they?]
dim2
Encoding
C0 type8 arrayp16
Stack
( maxx , maxy : -)
Operation
Allocates an array.
A new two-dimensional array is allocated and the resource number is written to arrayp . The new array will have a maximum X index of maxx and a maximum Y index of maxy (i.e., maxy is one less than the size).
When allocating an array, if type is C7 then the array will contain words; if it is CB, then it will contain bytes. All other values are undefined. [Currently they all produce a byte array. What are they?]
MM C5 distObjectObject
MM C6 distObjectPt
MM C7 distPtPt
div
Encoding
17
Stack
( in1 , in2 : out )
Operation
out := in1 / in2
Performs a division operation on the stack. Note the order.
An attempt to divide by zero will cause undefined behaviour, and may cause the interpreter to crash.
MM 83 doSentence
drawBox
Encoding
A6
Stack
( left , top , right , bottom , colour : -)
Operation Draws a solid box on the backbuffer from ( left , top ) to ( right , bottom ) in the colour colour .
dup
Encoding 0C
Stack ( value : value , value )
Operation Duplicates the top-most item on the stack.
MM 67 endCutScene
MM 96 endOverride
eq
Encoding
0E
Stack
( value1 , value2 : bool )
Operation
If value1=value2 , set bool to 1, otherwise set it to 0
Tests the top two values on the stack to see if they are equal.
MM 81 faceActor
MM 92 findInventory
MM A0 findObject
freezeUnfreeze
Encoding
6A
Stack
( bool : -)
Operation
bool=0 :
Thaw all currently frozen threads.
0<bool<$80 :
Freeze all threads that are not marked as unfreezable.
bool³ $80 :
Freeze all threads, even those that are marked as unfreezable.
Freezing is a nestable operation; a thread which is frozen twice must be thawed twice before it becomes runnable again.
ge
Encoding
13
Stack
( value1 value2 : bool)
Operation
If value1³ value2 , set bool to 1, otherwise set it to 0
Compares the top two values on the stack. Note the order.
MM AB getActorAnimCounter1
MM 91 getActorCostume
MM A2 getActorElevation
MM 9F getActorFromXY
MM 8A getActorMoving
MM 8C getActorRoom
MM AA getActorScaleX
MM 90 getActorWalkBox
MM A8 getActorWidth
MM 93 getInventoryCount
MM 8F getObjectDir
MM 8D getObjectX
MM 8E getObjectY
MM 72 getOwner
getRandomNumber
Encoding
87
Stack
( max : result )
Operation A random number in the range 0 to max inclusive is calculated, and the result pushed onto the stack. The result is also written to the RandomNumber word variable (see 6.5).
getRandomNumberRange
Encoding 88
Stack ( min , max , : result )
Operation A random number in the range min to max inclusive is calculated, and the result pushed onto the stack. The result is also written to the RandomNumber word variable (see 6.5).
MM 8B getScriptRunning
MM 6F getState
MM A3 getVerbEntryPoint
MM 94 getVerbFromXY
gt
Encoding
10
Stack
( value1 , value2 : bool )
Operation
If value1 > value2 , set bool to 1, otherwise set it to 0
Compares the top two values on the stack. Note the order.
MM6D ifClassOfls
MM AF isActorInBox
isAnyOf
Encoding
AD
Stack
( arg1 , arg2 , arg3 , ..., argn , n , value : bool )
Operation
If value is any of arg1 .. argn , bool := 1, otherwise bool := 0
Tests to see if value is equal to any of the passed in arguments. If n is less than the number of entries on the stack, undefined behaviour will result.
MM 98 isSoundRunning
MM 73 jump
Encoding
73 offset^16
Stack
(- : -)
Operation
pc := pc + offset
offset is added to the current program counter after the instruction has been decoded.
jumpFalse
Encoding
5D offset^16
Stack
( bool : -)
Operation
if bool = 0, pc := pc + offset
Pops the top value off the stack. If zero, then offset is added to the current program counter after the instruction has been decoded.
jumpTrue
Encoding
5C offset^16
Stack
( bool : -)
Operation
if bool 0, pc := pc + offset
Pops the top value off the stack. If non-zero, then offset is added to the current program counter after the instruction has been decoded.
kill
Encoding
1A
Stack
( value : -)
Operation
Pops the top value off the stack and discards it.
land
le
MM 7B loadRoom
MM 85 loadRoomWithEgo
lor
lt
MM c9 miscOps
mul
neq
MM 78 panCameraTo
pickOneOf
pickOneOfDefault
MM 84 pickupObject
MM B8 printActor
MM B9 printEgo
MM B4 print0
MM B5 print1
MM B6 print2
MM B7 print3
MM A1 psuedoRoom
pushByte
pushByteVar
pushWord
pushWordVar
MM 80 putActorAtObject
MM 7F putActorInRoom
quitPauseRestart
MM 9B resourceRoutines
MM 9C roomOps
MM BF runScriptQuick
MM BE runVerbCodeQuick
MM A5 saveRestoreVerbs
MM 99 setBoxFlags
MM 7A setCameraAt
MM 6E setClass
MM 97 setObjectName
MM 61 setObjectState
MM 62 setObjectXY
MM 71 setOwner
MM 70 setState
MM AC soundKludge
MM 76 startMusic
MM 60 startObject
startScript
MM 5E startScriptEx
MM 74 startSound
MM 69 stopMusic
MM 65 stopObjectCode
MM 66 stopObjectCode
MM 77 stopObjectScript
MM 7C stopScript
MM B3 stopSentence
MM 75 stopSound
sub
MM BA talkActor
MM BB talkEgo
MM 9E verbOps
MM A9 wait
MM 75 walkActorTo
MM 7D walkActorToObj
wordArrayDec
wordArrayInc
wordArrayIndexedRead
wordArrayIndexedWrite
wordArrayRead
wordArrayWrite
wordVarDec
wordVarInc
writeByteVar
writeWordVar
zero
All material © 2000-2002 David Given, unless where stated otherwise.