Monkey Island 2 SCUMM opcodes ============================= Variable range [0-0x31F] variables are wordsize. Local variable range [0-0x10] Local variables are wordsize. Bit variable range [0-0xFF] NOTE: Bit variables are wordsize and only take values 0 or 1! Varbits ======= Variables now take control bits (known as varbits) in their highbyte. The meanings of the varbits are as follows: Hex Binary Decimal Function 80 10000000 128 Var is a Bit variable. 40 01000000 64 Var is a Local variable. 20 00100000 32 Var is relative and takes another parameter as a pointer. NOTE: if bit 5 in the parameter is set aswell then the parameter denotes a Var(parameter) Examples -------- 1A aa bb cc dd MOV Var(bbaa)=ddcc 1A aa 2b cc dd ee ff MOV Var(baa+ddcc),ffee 1A aa 2b cc 2d ee ff MOV Var(baa+Var(dcc)),ffee 1A aa 4b cc dd MOV Localvar(baa),ddcc 1A aa 8b cc dd MOV Bitvar(baa),ddcc 9A aa 2b cc 2d ee 2f gg hh MOV Var(baa+Var(dcc)),Var(fee+Var(hhgg)) 9A aa 2b cc dd ee 4f MOV Var(baa+ddcc),Localvar(fee) ----------------------------------------------------------------------- pickUp (object nr, room nr) * =========================== Removes the object from the designated room and adds it to the inventory. If the room nr is zero, the object is taken from the current room. 25 pickUp (word(a), byte(b)) 65 pickUp (word(a), var(b)) A5 pickUp (var(a), byte(b)) E5 pickUp (var(a), var(b)) ----------------------------------------------------------------------- stopScript * ========== Stops the current script. 00 stopScript A0 stopScript ----------------------------------------------------------------------- print * ===== Print a scumm-string to screen. The string contains all kinds of control codes that haven't been looked into. Probably has to do with x,y-pos, color etc etc A scumm-string allways ends with 0xff. 14 byte(a) string 94 var(a) string ----------------------------------------------------------------------- cursor * ====== Cursor commands. 2C 01 cursor.On 2C 02 cursor.Off 2C 05 cursor.Inc (cursor is incremented???) 2C 06 cursor.Dec (cursor is decremented???) ----------------------------------------------------------------------- getActorCostume(var number, actor number) * ========================================= Gets the costume nr of the given actor and stores it in a var. 71 getActorCostume (var(a), byte(b)) F1 getActorCostume (var(a), var(b)) ----------------------------------------------------------------------- chainScript(script number) * ========================== Stops the active script, loads the given script and starts executing that one. 42 chainScript (byte(a)) C2 chainScript (var(a)) ----------------------------------------------------------------------- getActorLocation(var number, actor number) * ========================================== Gets the room number of the specified actor is in and stores it in the specified variable. 03 getActorLocation (var(a), byte(b)) 83 getActorLocation (var(a), var(b)) ----------------------------------------------------------------------- walkActorTo(actor number, x-pos, y-pos) * ======================================= Lets the actor walk towards x-pos, y-pos. 1E walkActorTo (byte(a), word(b), word(c)) 3E walkActorTo (byte(a), word(b), var(c)) 5E walkActorTo (byte(a), var(b), word(c)) 7E walkActorTo (byte(a), var(b), var(c)) 9E walkActorTo (var(a), word(b), word(c)) BE walkActorTo (var(a), word(b), var(c)) DE walkActorTo (var(a), var(b), word(c)) FE walkActorTo (var(a), var(b), var(c)) ----------------------------------------------------------------------- putActor (actor number, x-pos, y-pos) * ===================================== Positions the actor at x-pos, y-pos in the actor's current room location. 01 putActor(byte(a), word(b), word(c)) 21 putActor(byte(a), word(b), var(c)) 41 putActor(byte(a), var(b), word(c)) 61 putActor(byte(a), var(b), var(c)) 81 putActor(var(a), word(b), word(c)) A1 putActor(var(a), word(b), var(c)) C1 putActor(var(a), var(b), word(c)) E1 putActor(var(a), var(b), var(c)) ----------------------------------------------------------------------- isGreaterEqual a,b * ================== Var(a)>=b? if a>=b execute the next instruction, else branch to current offset+c. 04 isGreaterEqual (var(a), word(b)), word(c) 84 isGreaterEqual (var(a), var(b)), word(c) ----------------------------------------------------------------------- isNotEqual a,b * ============== Var(a)<>b? if a<>b execute the next instruction, else branch to current offset+c. 08 isNotEqual (var(a), word(b)), word(c) 88 isNotEqual (var(a), var(b)), word(c) ----------------------------------------------------------------------- getObjectState a,b * ================== The state of object(b) is stored in var(a). 0F getObjectState (var(a), word(b)) 8F getObjectState (var(a), var(b)) ----------------------------------------------------------------------- getObjectOwner a,b * ================== The owner of object(b) is stored in var(a). 10 getObjectOwner (var(a), word(b)) 90 getObjectOwner (var(a), var(b)) ----------------------------------------------------------------------- and a,b * ======= var(a)=var(a) and b 17 and (var(a), word(b)) 97 and (var(a), var(b)) ----------------------------------------------------------------------- jumpRelative a * ============== Jump a bytes forward (or backward). Counted from the offset of the next instruction. 18 jumpRelative a ----------------------------------------------------------------------- move a,b * ======== Stores the value of b in var(a). 1A move (var(a), word(b)) 9A move (var(a), var(b)) ----------------------------------------------------------------------- multiply a,b * ============ Multiplies var(a) with b. 1B multiply (var(a), word(b)) 9B multiply (var(a), var(b)) ----------------------------------------------------------------------- equalZero a * =========== If var(a)==0 execute the next instruction, else branch to current offset+b. 28 equalZero (var(a)),word(b) ----------------------------------------------------------------------- lessOrEqual a,b * =============== if var(a)=b execute next instruction, else branch to current offset+c. 78 isGreater (var(a), word(b)) F8 isGreater (var(a), var(b)) ----------------------------------------------------------------------- notEqualZero a * ============== If var(a)<>0 execute next instruction, else branch to current offset+b. A8 notEqualZero (var(a)), word(b) ----------------------------------------------------------------------- decrement a * =========== Var(a) is decremented by 1. C6 decrement (var(a)) ----------------------------------------------------------------------- Internals: ds:2492 script structures (total size=360 bytes, structure size=18 bytes) 20 scripts running concurrently 2492 word scriptOfs 2494 word scriptSeg 2496 word 2498 word 249A word scriptNumber (0:no script else number of global script) 249C byte scriptStatus (0:stopped 1 2:running 249D byte 249E byte 249F byte 24A0 byte 24A1 byte 24A2 byte activeCutScene (0:no cutscene ds:261C (total size ?, structure size=30 bytes) ds:4ADA object table (total size, struc size 2 bytes) bit 87654321 |||||--> object owner (actornr) |--> object state ds:4D1E cutscene structures (total size 20 bytes= 4D1E word 4D20 word ds:4D3A object structure (total size 256 bytes= ds:4E2A (total size 5 bytes= ds:6C6C inventorylist (size 160 bytes, 80 items) 6C6C word objectNr (0:position empty) ds:71E0 scumm variables (total size 1602 bytes, 801 items) Scumm Var Nr Function ------------------------- 10 contains current drive number 37 Text speed 39 Debug mode 44 x-position of cursor 45 y-position of cursor 49 current video mode 51 contains disk medium (0:floppy 1:fixed disk) 57 contains last pressed keyboard char 67 mouse present (0:no 1:yes) 68 machine speed 69 video speed