cowlark.com

[Home] [Index] [About] [Mail me]


Contents
1. Introduction
2. CHAR: Character Sets
3. AARY: Arrays and Strings
4. SCRP: Scripts
4.1. V5 opcode list
4.2. V6 opcode list
5. Glossary
6. SLOB files

V6 opcode list

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

6.4.6   arrayOps

[t]1.00 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

6.4.8   MM 6C breakHere

6.4.9   MM CA breakMaybe

6.4.10   MM 5A byteArrayDec

6.4.11   MM 52 byteArrayInc

6.4.12   byteArrayIndexedRead

[t]1.00

Encoding

0A arrayp8

Stack

( indexx , indexy : value )

Operation

value := arrayp [ indexxindexy ]

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.




6.4.13   byteArrayIndexedWrite

[t]1.00

Encoding

4A arrayp8

Stack

( indexx , indexy , value : -)

Operation

arrayp [ indexxindexy ] := 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.




6.4.14   byteArrayRead

[t]1.00

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.




6.4.15   byteArrayWrite

[t]1.00

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.




6.4.16   MM 56 byteVarDec

6.4.17   MM 4E byteVarInc

6.4.18   MM 9A createBoxMatrix

6.4.19   MM 6B cursorCommand

6.4.20   MM 68 cutScene

6.4.21   delay

[t]1.00

Encoding

B0

Stack

( delay : -)

Operation

Prevents the current thread from being rescheduled until delay ticks have passed. Deschedules immediately.




6.4.22   delayLonger

[t]1.00

Encoding

B1

Stack

( delay : -)

Operation

Prevents the current thread from being rescheduled until delay× 60 ticks have passed ( delay seconds). Deschedules immediately.




6.4.23   delayVeryLong

[t]1.00

Encoding

B2

Stack

( delay : -)

Operation

Prevents the current thread from being rescheduled until delay× 3600 ticks have passed ( delay minutes). Deschedules immediately.




6.4.24   dim

[t]1.00

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?]




6.4.25   dim2

[t]1.00

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?]




6.4.26   MM C5 distObjectObject

6.4.27   MM C6 distObjectPt

6.4.28   MM C7 distPtPt

6.4.29   div

[t]1.00

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.




6.4.30   MM 83 doSentence

6.4.31   drawBox

[t]1.00

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 .




6.4.32   dup

[t]1.00

Encoding

0C

Stack

( value  :  valuevalue )

Operation

Duplicates the top-most item on the stack.




6.4.33   MM 67 endCutScene

6.4.34   MM 96 endOverride

6.4.35   eq

[t]1.00

Encoding

0E

Stack

( value1value2  :  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.




6.4.36   MM 81 faceActor

6.4.37   MM 92 findInventory

6.4.38   MM A0 findObject

6.4.39   freezeUnfreeze

[t]1.00

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.




6.4.40   ge

[t]1.00

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.




6.4.41   MM AB getActorAnimCounter1

6.4.42   MM 91 getActorCostume

6.4.43   MM A2 getActorElevation

6.4.44   MM 9F getActorFromXY

6.4.45   MM 8A getActorMoving

6.4.46   MM 8C getActorRoom

6.4.47   MM AA getActorScaleX

6.4.48   MM 90 getActorWalkBox

6.4.49   MM A8 getActorWidth

6.4.50   MM 93 getInventoryCount

6.4.51   MM 8F getObjectDir

6.4.52   MM 8D getObjectX

6.4.53   MM 8E getObjectY

6.4.54   MM 72 getOwner

6.4.55   getRandomNumber

[t]1.00

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).




6.4.56   getRandomNumberRange

[t]1.00

Encoding

88

Stack

( minmax , :  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).




6.4.57   MM 8B getScriptRunning

6.4.58   MM 6F getState

6.4.59   MM A3 getVerbEntryPoint

6.4.60   MM 94 getVerbFromXY

6.4.61   gt

[t]1.00

Encoding

10

Stack

( value1value2  :  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.




6.4.62   MM 6D ifClassOfIs

6.4.63   MM AF isActorInBox

6.4.64   isAnyOf

[t]1.00

Encoding

AD

Stack

( arg1arg2arg3 , ...,  argnnvalue  :  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.




6.4.65   MM 98 isSoundRunning

6.4.66   MM 73 jump

[t]1.00

Encoding

73 offset16

Stack

(- : -)

Operation

pc := pc + offset

offset is added to the current program counter after the instruction has been decoded.




6.4.67   jumpFalse

[t]1.00

Encoding

5D offset16

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.




6.4.68   jumpTrue

[t]1.00

Encoding

5C offset16

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.




6.4.69   kill

[t]1.00

Encoding

1A

Stack

( value  : -)

Operation

Pops the top value off the stack and discards it.




6.4.70   land

[t]1.00

Encoding

18

Stack

( in1  in2  :  out)

Operation

out:=in1  &&  in2

Performs a logical and operation on the stack (not a bitwise and). Note the order.

The boolean values are as in C, with 0 for false and non-zero for true.




6.4.71   le

[t]1.00

Encoding

12

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.




6.4.72   MM 7B loadRoom

6.4.73   MM 85 loadRoomWithEgo

6.4.74   lor

[t]1.00

Encoding

19

Stack

( in1  in2  :  out)

Operation

out:=in1  ||  in2

Performs a logical or operation on the stack (not a bitwise or). Note the order.

The boolean values are as in C, with 0 for false and non-zero for true.




6.4.75   lt

[t]1.00

Encoding

11

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.




6.4.76   MM C9 miscOps

6.4.77   mul

[t]1.00

Encoding

16

Stack

( in1  in2  :  out)

Operation

out:=in1× in2

Performs a multiplication operation on the stack. Note the order.




6.4.78   neq

[t]1.00

Encoding

0F

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 not equal.




6.4.79   MM 78 panCameraTo

6.4.80   pickOneOf

[t]1.00

Encoding

CB

Stack

( indexarg0arg1arg2 , ...,  argnn  :  value )

Operation

value := arg[index]

Returns the index th argument on the stack. If n is less than the number of entries on the stack or index is out of range, undefined behaviour will result, usually involving the interpreter shutting down.




6.4.81   pickOneOfDefault

[t]1.00

Encoding

CC

Stack

( indexarg0arg1arg2 , ...,  argnndefault  :  value )

Operation

If index is in the range 0.. n , value  :=  arg[index] ; otherwise value  :=  default .

Returns the index th argument on the stack. If index is out of range, default is returned instead. If n is less than the number of entries on the stack, undefined behaviour will result, usually involving the interpreter shutting down.




6.4.82   MM 84 pickupObject

6.4.83   MM B8 printActor

6.4.84   MM B9 printEgo

6.4.85   MM B4 print0

6.4.86   MM B5 print1

6.4.87   MM B6 print2

6.4.88   MM B7 print3

6.4.89   MM A1 pseudoRoom

6.4.90   pushByte

[t]1.00

Encoding

00 value8

Stack

(- : value )

Operation

Pushes value onto the stack. It is not sign extended.




6.4.91   pushByteVar

[t]1.00

Encoding

02 pointer8

Stack

(- : value )

Operation

Dereferences pointer and pushes the result onto the stack. Note that because pointer is encoded as a byte, it can only point to a word variable in the range 0000-00FF. Use pushWordVar for a more general version of this instruction.




6.4.92   pushWord

[t]1.00

Encoding

01 value16

Stack

(- : value )

Operation

Pushes value onto the stack.




6.4.93   pushWordVar

[t]1.00

Encoding

03 pointer16

Stack

(- : value )

Operation

Dereferences pointer and pushes the result onto the stack.




6.4.94   MM 80 putActorAtObject

6.4.95   MM 7F putActorInRoom

6.4.96   quitPauseRestart

[t]1.00 This instruction varies according to the form.

Encoding

pause:
AE 9E
quit:
AE A0

Stack

(- : -) (both forms)

Operation

Pauses and quits the game. [Details, details!]




6.4.97   MM 9B resourceRoutines

6.4.98   MM 9C roomOps

6.4.99   MM BF runScriptQuick

6.4.100   MM BE runVerbCodeQuick

6.4.101   MM A5 saveRestoreVerbs

6.4.102   MM 99 setBoxFlags

6.4.103   MM 7A setCameraAt

6.4.104   MM 6E setClass

6.4.105   MM 97 setObjectName

6.4.106   MM 61 setObjectState

6.4.107   MM 62 setObjectXY

6.4.108   MM 71 setOwner

6.4.109   MM 70 setState

6.4.110   MM AC soundKludge

6.4.111   MM 76 startMusic

6.4.112   MM 60 startObject

6.4.113   startScript

[t]1.00

Encoding

5F

Stack

( scriptarg0arg1arg2 , ...,  argnn  : -)

Operation

A new thread is started, running the code in the script whose resource number is script . arg0 .. argn form the thread's initial local variables; unspecified variables are not initialised to any specific value.

The new thread starts executing immediately and the current thread is put into the PENDING state until the new thread is descheduled.




6.4.114   MM 5E startScriptEx

6.4.115   MM 74 startSound

6.4.116   MM 69 stopMusic

6.4.117   MM 65 stopObjectCode

6.4.118   MM 66 stopObjectCode

6.4.119   MM 77 stopObjectScript

6.4.120   MM 7C stopScript

6.4.121   MM B3 stopSentence

6.4.122   MM 75 stopSound

6.4.123   sub

[t]1.00

Encoding

15

Stack

( in1  in2out)

Operation

out:=in1-in2

The top two items on the stack are popped off, the first subtracted from the second, and the result pushed back on the stack. Note the order.




6.4.124   MM BA talkActor

6.4.125   MM BB talkEgo

6.4.126   MM 9E verbOps

6.4.127   MM A9 wait

6.4.128   MM 7E walkActorTo

6.4.129   MM 7D walkActorToObj

6.4.130   wordArrayDec

[t]1.00

Encoding

5B arrayp16

Stack

( index  : -)

Operation

arrayp [0,  index ] :=  arrayp [0,  index ] - 1

Increments the value at offset (0,  index ) in the array whose resource number is pointed to by arrayp .




6.4.131   wordArrayInc

[t]1.00

Encoding

53 arrayp16

Stack

( index  : -)

Operation

arrayp [0,  index ] :=  arrayp [0,  index ] + 1

Increments the value at offset (0,  index ) in the array whose resource number is pointed to by arrayp .




6.4.132   wordArrayIndexedRead

[t]1.00

Encoding

0B arrayp16

Stack

( indexx , indexy : value )

Operation

value  :=  arrayp [ indexxindexy ]

Reads the value at offset ( indexxindexy ) 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.




6.4.133   wordArrayIndexedWrite

[t]1.00

Encoding

4B arrayp16

Stack

( indexx , indexy , value : -)

Operation

arrayp [ indexxindexy ] := 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; when writing to a byte array, value is truncated.




6.4.134   wordArrayRead

[t]1.00

Encoding

07 arrayp16

Stack

( index : value )

Operation

value := arrayp [0,  index ]

Reads the value at offset (0,  index ) 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.




6.4.135   wordArrayWrite

[t]1.00

Encoding

47 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.




6.4.136   wordVarDec

[t]1.00

Encoding

57 pointer16

Stack

(- : -)

Operation

* pointer := * pointer - 1

Decrements the variable pointed to by pointer .




6.4.137   wordVarInc

[t]1.00

Encoding

4F pointer16

Stack

(- : -)

Operation

* pointer := * pointer + 1

Increments the variable pointed to by pointer .




6.4.138   writeByteVar

[t]1.00

Encoding

42 pointer8

Stack

( value : -)

Operation

* pointer := value

Writes value to the variable pointed to by pointer . Note that as pointer is encoded as a byte, it can only point to word variables in the range 0x0000 to 0x00FF. For a more general form of this instruction, use writeWordVar.




6.4.139   writeWordVar

[t]1.00

Encoding

43 pointer16

Stack

( value : -)

Operation

* pointer := value

Writes value to the variable pointed to by pointer .




6.4.140   zero

[t]1.00

Encoding

0D

Stack

( value  :  bool )

Operation

If value = 0, set bool to 1, otherwise set it to 0

Tests the value on the stack to see if it compares to zero.

All material © 2000-2002 David Given, unless where stated otherwise.
This page last updated on 2002-09-18 23:05:19.000000000 +0100 scumm/scrp-v6.ns .