cowlark.com
|
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.10 MM 5A byteArrayDec
6.4.11 MM 52 byteArrayInc
6.4.12 byteArrayIndexedRead[t]1.00
Encoding0A 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.
6.4.13 byteArrayIndexedWrite[t]1.00
Encoding4A 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.
6.4.14 byteArrayRead[t]1.00
Encoding06 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
Encoding46 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.18 MM 9A createBoxMatrix
6.4.19 MM 6B cursorCommand
6.4.21 delay[t]1.00
EncodingB0
Stack( delay : -)
OperationPrevents the current thread from being rescheduled until delay
ticks have passed. Deschedules immediately.
6.4.22 delayLonger[t]1.00
EncodingB1
Stack( delay : -)
OperationPrevents the current thread from being rescheduled until delay× 60
ticks have passed ( delay seconds). Deschedules immediately.
6.4.23 delayVeryLong[t]1.00
EncodingB2
Stack( delay : -)
OperationPrevents the current thread from being rescheduled until delay× 3600
ticks have passed ( delay minutes). Deschedules immediately.
6.4.24 dim[t]1.00
EncodingBC type8 arrayp16
Stack( max : -)
OperationAllocates 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
EncodingC0 type8 arrayp16
Stack( maxx , maxy : -)
OperationAllocates 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.29 div[t]1.00
Encoding17
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.31 drawBox[t]1.00
EncodingA6
Stack( left , top , right , bottom , colour
: -)
OperationDraws a solid box on the backbuffer from ( left , top )
to ( right , bottom ) in the colour colour .
6.4.32 dup[t]1.00
Encoding0C
Stack( value : value , value )
OperationDuplicates the top-most item on the stack.
6.4.35 eq[t]1.00
Encoding0E
Stack( value1 , value2 : bool )
OperationIf 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.37 MM 92 findInventory
6.4.39 freezeUnfreeze[t]1.00
Encoding6A
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
Encoding13
Stack ( value1 value2 : bool)
OperationIf 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.55 getRandomNumber[t]1.00
Encoding87
Stack( max : result )
OperationA 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
Encoding88
Stack( min , max , : result )
OperationA 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.59 MM A3 getVerbEntryPoint
6.4.60 MM 94 getVerbFromXY
6.4.61 gt[t]1.00
Encoding10
Stack( value1 , value2 : bool )
OperationIf value1 > value2 , set bool to 1, otherwise
set it to 0
Compares the top two values on the stack. Note the order.
6.4.63 MM AF isActorInBox
6.4.64 isAnyOf[t]1.00
EncodingAD
Stack( arg1 , arg2 , arg3 , ..., argn , n , value : bool )
OperationIf 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
Encoding73 offset16
Stack(- : -)
Operationpc := pc + offset
offset is added to the current program counter after the instruction
has been decoded.
6.4.67 jumpFalse[t]1.00
Encoding5D offset16
Stack( bool : -)
Operationif 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
Encoding5C offset16
Stack( bool : -)
Operationif 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
Encoding1A
Stack( value : -)
OperationPops the top value off the stack and discards it.
6.4.70 land[t]1.00
Encoding18
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
Encoding12
Stack ( value1 value2 : bool)
OperationIf value1£ value2 , set bool to 1, otherwise
set it to 0
Compares the top two values on the stack. Note the order.
6.4.73 MM 85 loadRoomWithEgo
6.4.74 lor[t]1.00
Encoding19
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
Encoding11
Stack ( value1 value2 : bool)
OperationIf value1<value2 , set bool to 1, otherwise set
it to 0
Compares the top two values on the stack. Note the order.
6.4.77 mul[t]1.00
Encoding16
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
Encoding0F
Stack( value1 , value2 : bool )
OperationIf 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.80 pickOneOf[t]1.00
EncodingCB
Stack( index , arg0 , arg1 , arg2 , ..., argn , n : 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
EncodingCC
Stack( index , arg0 , arg1 , arg2 , ..., argn , n , default : value )
OperationIf 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.90 pushByte[t]1.00
Encoding00 value8
Stack(- : value )
OperationPushes value onto the stack. It is not sign extended.
6.4.91 pushByteVar[t]1.00
Encoding02 pointer8
Stack(- : value )
OperationDereferences 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
Encoding01 value16
Stack(- : value )
OperationPushes value onto the stack.
6.4.93 pushWordVar[t]1.00
Encoding03 pointer16
Stack(- : value )
OperationDereferences 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)
OperationPauses and quits the game. [Details, details!]
6.4.97 MM 9B resourceRoutines
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.105 MM 97 setObjectName
6.4.106 MM 61 setObjectState
6.4.107 MM 62 setObjectXY
6.4.110 MM AC soundKludge
6.4.112 MM 60 startObject
6.4.113 startScript[t]1.00
Encoding5F
Stack( script , arg0 , arg1 , arg2 , ..., argn , n : -)
OperationA 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.117 MM 65 stopObjectCode
6.4.118 MM 66 stopObjectCode
6.4.119 MM 77 stopObjectScript
6.4.121 MM B3 stopSentence
6.4.123 sub[t]1.00
Encoding15
Stack ( in1 in2: out)
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.128 MM 7E walkActorTo
6.4.129 MM 7D walkActorToObj
6.4.130 wordArrayDec[t]1.00
Encoding5B 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
Encoding53 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
Encoding0B arrayp16
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.
6.4.133 wordArrayIndexedWrite[t]1.00
Encoding4B arrayp16
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; when writing to a byte array,
value is truncated.
6.4.134 wordArrayRead[t]1.00
Encoding07 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
Encoding47 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
Encoding57 pointer16
Stack(- : -)
Operation* pointer := * pointer - 1
Decrements the variable pointed to by pointer .
6.4.137 wordVarInc[t]1.00
Encoding4F pointer16
Stack(- : -)
Operation* pointer := * pointer + 1
Increments the variable pointed to by pointer .
6.4.138 writeByteVar[t]1.00
Encoding42 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
Encoding43 pointer16
Stack( value : -)
Operation* pointer := value
Writes value to the variable pointed to by pointer .
6.4.140 zero[t]1.00
Encoding0D
Stack( value : bool )
OperationIf value = 0, set bool to 1, otherwise set it to
0
Tests the value on the stack to see if it compares to zero.
|