Open main menu

SCUMM/V5 opcodes

< SCUMM
Revision as of 18:48, 28 October 2006 by Clone2727 (talk | contribs) (initial V5 opcodes page from website)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SCUMM V5 opcodes

The following conventions are used in the encoding descriptions.

opcode The instruction's opcode, with the appropriate bits set according to the parameters.
result A result pointer. (A standard word pointer, always a LE word.)
value[8] An 8-bit constant (a byte).
value[16] A 16-bit constant (a word LE).
value[p8] An 8-bit parameter. This may be encoded as a word LE if it's a pointer, or a byte if it's a constant.
value[p16] A 16-bit parameter. This is always encoded as a word LE.
value[v16] A variable number of word LE parameters. These are encoded as a sequence of aux[8] param[p16]; param; aux contains the parameter bit to describe param. A byte of $FF terminates the sequence.
value[o] The offset word for parameter value. This is only encoded if needed, but always at the position indicated. If not specified, the offset word occurs immediately after the parameter.
(term) An optional term.


$52

actorFollowCamera

$15

actorFromPos

$13

actorSet

$5D

actorSetClass

$5A

add

Encoding

opcode result value[p16]

Operation

result := result + value

The variable pointed to by result is read, value is added to it, and the result written back.

$17

and

one parameter, uses result

Encoding

opcode result value[p16]

Operation

result := result and value

The variable pointed to by result is read, logically ANDed with value, and the result written back.

$11

animateActor

$27

arrayOp

parameters depend on auxilary opcode

Encoding

opcode $01 array[p8] opcode $02 dest[p8] src[p8] opcode $03 array[p8] index[p8] data[p8] opcode $04 result array[p8] index[p8] opcode $05 array[p8] size[p8]

Operation

Miscellaneous actions on Arrays (referred to by resource number).

Opcode Meaning Description
$01 load array Ensures that the Array is loaded into memory. [I don't know what this does.]
$02 copy array Creates a duplicate of src at resource number dest. The old Array at dest is lost.
$03 write entry Writes the byte data at offset index of Array array. Out of bounds accesses cause undefined behaviour.
$04 read entry Sets result to the byte of data at offset index of Array array. Out of bounds accesses cause undefined behaviour.
$05 create entry Allocates or frees an Array. The Array array is initialised to size size; if size is zero, the Array is freed.

$80

breakHere

no parameters

Encoding

opcode

Operation

Deschedules the currently running thread. Execution continues at the next instruction when the thread's next timeslot comes around.

$42

chainScript

one parameter plus varargs

Encoding

opcode script[p8] args[v16]...

Operation

Replaces the currently running script with another one. The current script is terminated immediately and the new script, resource number script, is executed in the same thread. The new script has its local variables initialised to the list args. Uninitialised variables have undefined values.

$2C

cursorCommand

$40

cutScene

$6B

debug

one parameter, no result

Encoding

opcode param[p16]

Operation

Passes the parameter to the interpreter's debugger. What this does is entirely platform-specific (and may do nothing).

$C6

decrement

no parameters, uses result

Encoding

opcode result

Operation

result := result - 1

Reads the variable pointed to by result, decrements it, and writes it back.

$2E

delay

one constant parameter

Encoding

opcode param[24]

Operation

Suspends the current thread for the appropriate number of 1/60ths of a second. Yes, that really is a 24-bit LE constant.

$2E

delayVariable

one constant parameter

Encoding

opcode pointer[16]

Operation

pointer is dereferenced and the current thread suspended for that number of 1/60ths of a second. Note that pointer is an inline constant, not a parameter.

$5B

divide

one parameter, uses result

Encoding

opcode result value[p16]

Operation

result := result / value

The variable pointed to by result is read, divided by value, and the result written back. If value is zero, the result is undefined (and the interpeter may halt with an error).

$19

doSentence

$3F

drawBox

two parameters, does not use result, supplementary opcode byte with three more subsequent parameters

Encoding

opcode left[p16] top[p16] auxopcode[8] right[p16] bottom[p16] colour[p8]

Operation

Draws a solid box on the backbuffer from (left, top)-(right, bottom) in the colour colour.

The only part of auxopcode that is relevant are the parameter bits. The rest of the opcode is ignored.

$05

drawObject

$67

dummy

$C0

endCutScene

$28

equalZero

$AC

expression

$09

faceActor

$3D

findInventory

$35

findObject

$60

freezeScripts

$71

getActorCostume

$06

getActorElevation

$63

getActorFacing

$56

getActorMoving

$03

getActorRoom

$3B

getActorScale

$7B

getActorWalkBox

$6C

getActorWidth

$43

getActorX

$23

getActorY

$22

getAnimCounter

$66

getClosestObjActor

$34

getDist

$31

getInventoryCount

$10

getObjectOwner

$0F

getObjectState

$16

getRandomNumber

$68

getScriptRunning

$0B

getVerbEntryPoint

$1D

ifClassOfIs

$46

increment

no parameters, uses result

Encoding

opcode result

Operation

result := result + 1

Reads the variable pointed to by result, increments it, and writes it back.

$1F

isActorInBox

$48

isEqual

$78

isGreater

$04

isGreaterEqual

$44

isLess

$08

isNotEqual

$7C

isSoundRunning

$18

jumpRelative

non-standard encoding

Encoding

opcode target[16]

Operation

PC := PC + target

The inline constant target is read as a signed word and added to the program counter after the instruction has been read. Therefore, if target is zero, the instruction will do nothing; if target is -3, an infinite loop will result.

$38

lessOrEqual

$70

lights

$72

loadRoom

$24

loadRoomWithEgo

$30

matrixOp

$1A

move

$1B

multiply

$A8

notEqualZero

$57

or

one parameter, uses result

Encoding

opcode result value[p16]

Operation

result := result and value

The variable pointed to by result is read, logically ORed with value, and the result written back.

$58

overRide

$12

panCameraTo

$25

pickupObject

$14

print

$D8

printEgo

$CC

pseudoRoom

$01

putActor

$0E

putActorAtObject

$2D

putActorInRoom

$98

quitPauseRestart

$0C

resourceRoutines

$33

roomOp

$AB

saveRestoreVerbs

$32

setCameraAt

$54

setObjectName

$29

setOwnerOf

$07

setState

$26

setVarRange

$4C

soundKludge

$01

startMusic

$37

startObject

$0A

startScript

one parameter plus varargs, extra encoding in opcode

Encoding

opcode script[p8] args[v16]...

Operation

Spawns a new thread running the code in script script. The new script has its local variables initialised to the list args. Uninitialised variables have undefined values.

The opcode carries extra information:

7 6 5 4 0
P1 Q F $0A

$1C

startSound

$20

stopMusic

$00

stopObjectCode

$6E

stopObjectScript

$62

stopScript

$3C

stopSound

$3A

subtract

$11

animateActor

$AE

wait

$1E

walkActorTo

$0D

walkActorToActor

$36

walkActorToObject


All material © 2000-2002 David Given, unless where stated otherwise.