<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://insidethelink.ortiche.net/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://insidethelink.ortiche.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BahamutZERO</id>
		<title>A look inside The Link @ wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://insidethelink.ortiche.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BahamutZERO"/>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Special:Contributions/BahamutZERO"/>
		<updated>2026-04-19T04:33:22Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.15</generator>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2009-05-23T03:05:56Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: fixed a typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! Event name !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse down||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse still down||Mouse button down, sent to last pressed hotspot (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse up||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse enter||Mouse entered the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse within||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse leave||Mouse left the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|6||Load card||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Close card||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Open card||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display update||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
Despite its power, command 1 is used on a few scripts only.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. This command has no effect on the active ambient sound group; the sound is mixed with the ambient sounds.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Refreshes the card, behaving like a &amp;quot;go to &amp;lt;current card&amp;gt;&amp;quot; command. The full handler sequence is executed (see command 2). Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record. A SLST record describes an ambient sound group. The Riven engine can only have one active sound group at any given time (henceforth the &amp;quot;active ambient sound group&amp;quot;). This command sets the active ambient sound group to the specified SLST record. Appropriate fading in and fading out actions are taken based on the SLST record's fade flags. Activating the active ambient sound group has no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_tBMP_resources</id>
		<title>Talk:Riven tBMP resources</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_tBMP_resources"/>
				<updated>2009-02-26T07:38:48Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Aaron, I'm not entirely clear on your recent additions to the tBMP decode algorithms. Are you aware of specific images that exhibit the behaviors you describe to use a test cases, or a decoder implementation which respects those details?&lt;br /&gt;
&lt;br /&gt;
'''[ [[User:TitoDalCanton|TitoDalCanton]] 21:18, 24 February 2009 (CET) ]''' I think I've seen Aaron's effects in some compressed tBMPs. In particular, I recall being surprised by observing duplets repeating themselves, though I don't remember which tBMPs I was inspecting at the time.&lt;br /&gt;
&lt;br /&gt;
'''[ [[User:Aaron|Aaron]] 06:55, 23 February 2009 (CET) ]''' I mean to go back and check specifically for this, but I'm almost completely certain that this is true. Initially, in my algorithm, I used an unsigned integer to represent the number of pixels to look back from where I started, and decremented it each time I copied a pixel. This crippled all my images, and caused weird segfaults when it rolled over after 0. This was fixed when I used a signed integer type (ie let the command copy into newly-written pixels). This is basically an implementation detail, most people would do it a different way where this doesn't matter, or use a signed integer to begin with. [also, I think that pixel-based lookbacks ignore the extra space off the edge, while duplet-based ones do not, but I'm not certain on that. I'll verify that too, but it's too late now.] I didn't realize this was new information, I just thought it was left out.&lt;br /&gt;
&lt;br /&gt;
'''[ [[User:Aaron|Aaron]] 04:21, 24 February 2009 (CET) ]''' OK, I found specific examples. First of all, pixel lookbacks either never happen close enough to new rows to look back into the last row, or they take into account the extra info not in the final image (the bytes per row thing I mentioned in the article), so I'm glad I tried to confirm it before adding it. As for the others, all of these examples are from my original 5-cd riven set, and they're all from b_Data.MHK. tBMPs 99, 101, and 106 (and others) have a higher bytes per row than image width, and only appear correctly when rendered as if they were (bytes per row) wide, then cropped. tBMP 0 (and almost every other compressed image) has many repeat subcommands that ask for more data than there is available at the time. Specifically, byte 165 of the command stream of tBMP 0 is 0xEC followed by 0x08, meaning n = 6 and m = 8, so it needs 12 pixels copied from 8 pixels ago. These images only render correctly when they are allowed to read into themselves. This also happens with repeat command 0xFC. I hope this clarifies things.&lt;br /&gt;
&lt;br /&gt;
'''[ [[User:TitoDalCanton|TitoDalCanton]] 21:18, 24 February 2009 (CET) ]''' I checked my decoder implementation and I can confirm that your interpretation of row bytes is correct. In fact, I decode to a larger buffer (''rowbytes'' pixels wide) and then crop it to ''width'' pixels to get the final image.&lt;br /&gt;
&lt;br /&gt;
'''[ [[bahamutZERO|Jean-Francois Roy]] 23:37, 25 February 2009 (PST) ]''' Thanks everyone for the information. MHKKit also uses a row_bytes * height * bytes_per_pixel for image decoding. If Tito's decoder is &amp;quot;correct&amp;quot;, in that it produces correct images, I'll validate MHKKit against it. Perhaps post RGBA checksums for some of those tBMP resources for other people can unit test their decoders. Tito, is the source to maglev that you sent me a while ago still up to date?&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_tBMP_resources</id>
		<title>Talk:Riven tBMP resources</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_tBMP_resources"/>
				<updated>2009-02-19T19:30:45Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: New page: Aaron, I'm not entirely clear on your recent additions to the tBMP decode algorithms. Are you aware of specific images that exhibit the behaviors you describe to use a test cases, or a dec...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Aaron, I'm not entirely clear on your recent additions to the tBMP decode algorithms. Are you aware of specific images that exhibit the behaviors you describe to use a test cases, or a decoder implementation which respects those details?&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-05-05T18:45:34Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 19: reload card */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! Event name !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse down||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse up||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse within||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse leave||Mouse leaved the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Load card||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Close card||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Open card||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display update||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. This command has no effect on the active ambient sound group; the sound is mixed with the ambient sounds.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable. Based on observations made in Riven X, specifically card jspit 389, the &amp;quot;card load&amp;quot; and &amp;quot;card open&amp;quot; programs should both be re-run by this command. It has not been determined if the &amp;quot;card close&amp;quot; program should be executed as well (e.g. a full card switch sequence).&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record. A SLST record describes an ambient sound group. The Riven engine can only have one active sound group at any given time (henceforth the &amp;quot;active ambient sound group&amp;quot;). This command sets the active ambient sound group to the specified SLST record. Appropriate fading in and fading out actions are taken based on the SLST record's fade flags. Activating the active ambient sound group has no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_SFXE_resources</id>
		<title>Riven SFXE resources</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_SFXE_resources"/>
				<updated>2008-03-27T12:37:10Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* The header */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about Riven resources controlling where to apply the water special effect.&lt;br /&gt;
&lt;br /&gt;
==What is an SFXE resource?==&lt;br /&gt;
SFXE data has to do with the water special effect, which works by taking pixels from the rendered card picture and slightly moving them in periodic motion according to precomputed animation frames. Each frame consists of &amp;quot;displacement commands&amp;quot; that take pixel rows from the original picture and copy them at specified positions over a copy of the same picture. Displacement commands in each frame are arranged in a way that already takes into account periodic motion: the rendering code just loops interpreting frame after frame, blindly copying pixel rows over a copy of the original image.&lt;br /&gt;
&lt;br /&gt;
SFXE data is divided in 4 sections: the header, an unknown and apparently unused section, an offset table and a frame section. The offset table points to frames in the frame section. Everything is in big-endian byte order.&lt;br /&gt;
&lt;br /&gt;
==The header==&lt;br /&gt;
First of all comes a 52-byte header:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|int8_t||magic[2]&lt;br /&gt;
|-&lt;br /&gt;
|uint16_t||frame_count&lt;br /&gt;
|-&lt;br /&gt;
|uint32_t||offset_table_position&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||left, top, right, bottom&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||effect_speed&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||u0&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||alt_top, alt_left, alt_bottom, alt_right&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||u1&lt;br /&gt;
|-&lt;br /&gt;
| uint16_t ||alt_frame_count&lt;br /&gt;
|-&lt;br /&gt;
| uint32_t ||u2&lt;br /&gt;
|-&lt;br /&gt;
| uint32_t ||u3&lt;br /&gt;
|-&lt;br /&gt;
| uint32_t ||u4&lt;br /&gt;
|-&lt;br /&gt;
| uint32_t ||u5&lt;br /&gt;
|-&lt;br /&gt;
| uint32_t ||u6&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*''magic'' is the string &amp;quot;SL&amp;quot;. Maybe it identifies a known format, but I've found no info;&lt;br /&gt;
*''frame_count'' is the number of animation frames;&lt;br /&gt;
*''offset_table_position'' seems always 164. Probably it is the position of the offset table relative to the beginning of the resource, which is exactly 52+112=164. Altering this field makes Riven crash.&lt;br /&gt;
*''left'', ''top'', ''right'', ''bottom'' define the global rectangle of the effect area within the 608x392 game window. Note that ''right'' and ''bottom'' exceed by 1 pixel (that is, fullscreen SFXE resources have right = 608 and bottom = 392, not 607 and 391);&lt;br /&gt;
*''effect_speed'' seems always 15. It controls the speed of the water effect, and seems in units of frames per second;&lt;br /&gt;
*''alt_top'', ''alt_left'', ''alt_bottom'', ''alt_right'' is a copy of the previous rectangle. It seems ignored by the engine, changing it doesn't produce effects;&lt;br /&gt;
*''u1'' seems always 0;&lt;br /&gt;
*''alt_frame_count'' is a copy of frame_count;&lt;br /&gt;
*''u2'', ''u3'', ''u4'', ''u5'' seem always 4, 0, 0x19 and 1 respectively;&lt;br /&gt;
*''u6'' seems always 0 or 0x10000000;&lt;br /&gt;
&lt;br /&gt;
Altering any of the unknown fields ''u0''...''u6'' produces no apparent change at all, nor makes the engine crash. They look really like a waste of space.&lt;br /&gt;
&lt;br /&gt;
==The unknown section==&lt;br /&gt;
This is a 112-byte block of unknown purpose. It seems divided into 8-byte rows, and looks like an encoded mask or a [[Riven tBMP resources|tBMP]] command stream. The values don't change very much between resources and show the same structure. Incredibly enough, altering any of these values doesn't produce observable effects! Well, I've tried only on a few resources, but this behavior is quite disappointing. This data looks like a structure that was discarded in the final version of the engine, but was left in SFXE resources.&lt;br /&gt;
&lt;br /&gt;
==The offset table==&lt;br /&gt;
This is just an array of ''frame_count'' unsigned long offsets, relative to the beginning of the resource. Each offset points to a frame in the frame section.&lt;br /&gt;
&lt;br /&gt;
==The frame section==&lt;br /&gt;
This section contains ''frame_count'' data blocks, each representing an animation frame. Each block is made of a variable number of commands. Each command is an unsigned short opcode optionally followed by arguments. 3 opcodes have been observed:&lt;br /&gt;
*Command 1 has no arguments. It increments ''current_row'' by one pixel; ''current_row'' is a variable that scans the effect area row by row, starting from top. It's used by command 3 to help copying pixel rows. The number of &amp;quot;1&amp;quot; commands inside a frame is equal to the effect area height in pixels, that is, the number of pixel rows affected.&lt;br /&gt;
*Command 3 has 4 unsigned short arguments, ''dst_left src_left src_top row_width''. It defines the displacement: take a row of ''row_width'' pixels from the original picture at (''src_left'',''src_top'') and copy it at (''dst_left,''current_row''). &lt;br /&gt;
*Command 4 is the last command and ends the frame.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_SFXE_resources</id>
		<title>Talk:Riven SFXE resources</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Talk:Riven_SFXE_resources"/>
				<updated>2008-03-24T15:21:05Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: New page: TIto, I wonder if instead of right and bottom, it should be width and height. It seems odd they would have a one-pixel off situation.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;TIto, I wonder if instead of right and bottom, it should be width and height. It seems odd they would have a one-pixel off situation.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:18:34Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 4: play local tWAV resource */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. This command has no effect on the active ambient sound group; the sound is mixed with the ambient sounds.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record. A SLST record describes an ambient sound group. The Riven engine can only have one active sound group at any given time (henceforth the &amp;quot;active ambient sound group&amp;quot;). This command sets the active ambient sound group to the specified SLST record. Appropriate fading in and fading out actions are taken based on the SLST record's fade flags. Activating the active ambient sound group has no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:17:03Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 40: activate SLST record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. Ambient sounds are not touched; the sound is mixed over them.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record. A SLST record describes an ambient sound group. The Riven engine can only have one active sound group at any given time (henceforth the &amp;quot;active ambient sound group&amp;quot;). This command sets the active ambient sound group to the specified SLST record. Appropriate fading in and fading out actions are taken based on the SLST record's fade flags. Activating the active ambient sound group has no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:15:24Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 40: activate SLST record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. Ambient sounds are not touched; the sound is mixed over them.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record. A SLST record describes an ambient sound group. The Riven engine can only have one active sound group at any given time (henceforth the &amp;quot;active ambient sound group&amp;quot;). This command sets the active ambient sound group to the specified SLST record. Appropriate fading in and fading out actions are taken based on the new SLST record's fade flags. Activating the active ambient sound group has no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:12:31Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 3: activate inline SLST record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST record |command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. Ambient sounds are not touched; the sound is mixed over them.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record, so start ambient sounds. This command seems to have effect just once: it won't restart the same sound if it is already playing (even if the SLST tells not to repeat it). Activating another SLST record works always: the current sound is then stopped and replaced with the new one.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:11:45Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 3: play tWAV resource mix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: activate inline SLST record==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an inline [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if [[#Command 40: activate SLST command|command 40]] had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. Ambient sounds are not touched; the sound is mixed over them.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record, so start ambient sounds. This command seems to have effect just once: it won't restart the same sound if it is already playing (even if the SLST tells not to repeat it). Activating another SLST record works always: the current sound is then stopped and replaced with the new one.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts</id>
		<title>Riven scripts</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_scripts"/>
				<updated>2008-02-23T16:10:02Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* Command 3: play tWAV resource mix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Riven}}&lt;br /&gt;
This document talks about the Riven scripting protocol.&lt;br /&gt;
&lt;br /&gt;
==Overview and main data structures==&lt;br /&gt;
The Riven engine is programmed using ''scripts'' attached to objects. The architecture resembles the HyperCard philosophy. A script is subdivided in ''handlers''; each handler is associated to an event which may happen to the script's object and it contains the actions to be executed when that event happens. The actions are described by a list of ''commands''. Cards and hotspots are the only entities with attached scripts.&lt;br /&gt;
&lt;br /&gt;
A script is represented by this data block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||handler_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||handler list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each handler is made of this block:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||event_type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||cmd_count&lt;br /&gt;
|-&lt;br /&gt;
|variable size||command list&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table gives event types identified until now. Types 0 ... 5 are reserved to hotspots, 6 ... 10 are reserved to cards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;Handlers&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! event_type !! What happened&lt;br /&gt;
|-&lt;br /&gt;
|0||Mouse button pressed inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|1||Mouse button pressed inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|2||Mouse button released inside the hotspot rect&lt;br /&gt;
|-&lt;br /&gt;
|3||Mouse moved, pressed or released inside the hotspot rect (never seen in the game)&lt;br /&gt;
|-&lt;br /&gt;
|4||Mouse held inside the hotspot rect (the event is sent repeatedly)&lt;br /&gt;
|-&lt;br /&gt;
|5||Mouse moved inside the hotspot rect (not sure)&lt;br /&gt;
|-&lt;br /&gt;
|6||Card &amp;quot;loaded&amp;quot;. This is the first event sent to a card. Usually cards enable things here. Screen updates are disabled during the execution of this handler, and the display is updated at the end.&lt;br /&gt;
|-&lt;br /&gt;
|7||Leaving card.&lt;br /&gt;
|-&lt;br /&gt;
|9||Card opened. This is sent at the end, when the card has been loaded and the display has been updated. Usually cards start movies and ambient sounds here.&lt;br /&gt;
|-&lt;br /&gt;
|10||Display being updated; for example this event is triggered when the handler for event 6 completes, or by [[#Command 21: enable screen update|command 21]]. The handler is executed before actually updating the display.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In general, each command is an opcode followed by a number of arguments. The same command can be passed a variable number of arguments, though only a few commands actually behave like that. The general structure is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||cmd&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||arg_count&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||args[arg_count]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following subsections explain what has been discovered about each command. Unlisted opcodes have never been observed in Riven.&lt;br /&gt;
==Command 1: draw tBMP resource==&lt;br /&gt;
*'''Argument count:''' 9&lt;br /&gt;
*'''Arguments:''' ''tbmp_id left top right bottom u0 u1 u2 u3''&lt;br /&gt;
&lt;br /&gt;
Draw bitmap from tBMP resource ''tbmp_id'' inside the rectangle described by ''left'', ''top'', ''right'', ''bottom''. If the rectangle dimensions do not match the bitmap size, the bitmap will be attached to the top-left corner and clipped to the rectangle. Other arguments are always zero and seem ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
The command will automatically update the display unless [[#Command 20: disable screen update|command 20]] was used before.&lt;br /&gt;
&lt;br /&gt;
==Command 2: go to card==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''id''&lt;br /&gt;
&lt;br /&gt;
Go to card ''id''. In most cases this command is used in very short hotspot scripts containing just a transition command followed by the &amp;quot;go to card&amp;quot; one. In these cases, the following event chain takes place:&lt;br /&gt;
*the old card receives [[#Handlers|event 7]];&lt;br /&gt;
*the new card receives event 6;&lt;br /&gt;
*the new card receives event 10 (because the display is begin updated);&lt;br /&gt;
*the transition effect is played and the new card image is displayed;&lt;br /&gt;
*the new card receives event 9.&lt;br /&gt;
&lt;br /&gt;
However, it is also used in card event handlers, like 9 or 10. Sometimes it appears multiple times in the same script. The event sequence for these complicated cases is not yet fully understood.&lt;br /&gt;
&lt;br /&gt;
==Command 3: play tWAV resource mix==&lt;br /&gt;
*'''Argument count:''' variable&lt;br /&gt;
*'''Arguments:''' ''N ids[N] fade_flags loop volume u0 u1 volumes[N] balances[N] u2[N]''&lt;br /&gt;
&lt;br /&gt;
This command is basically an in-code [[Riven SLST resources|SLST]] resource record. All referenced sound resources should be looked-up in the current stack's sound archives. The resulting sound group is made current, as if command 40 had been used.&lt;br /&gt;
&lt;br /&gt;
==Command 4: play local tWAV resource==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''id volume u1''&lt;br /&gt;
&lt;br /&gt;
Play tWAV resource ''id'' from the Mohawk archive containing the script. ''volume'' seems always 256, ''u1'' always 0. Ambient sounds are not touched; the sound is mixed over them.&lt;br /&gt;
&lt;br /&gt;
==Command 7: set variable value==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Set variable ''var'' to value ''value''.&lt;br /&gt;
&lt;br /&gt;
==Command 8: conditional branch==&lt;br /&gt;
This doesn't follow the ''command arg_count'' args scheme. It's similar to a C &amp;quot;switch&amp;quot; statement: given a variable, there is a list of possible variable values and a corresponding command list to be executed. The structure of command 8 is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||8&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||2&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||var&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||value_count&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then ''value_count'' blocks follow, each with this structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||value&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||command_count&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;color:#000&amp;quot;|commands to execute if var contains value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If ''value'' is 0xffff, the block is the &amp;quot;default&amp;quot; block exactly like in the C statement. As an example, let's compare the script syntax with a C-like switch statement:&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; valign=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
 0008 0002 beef 3&lt;br /&gt;
   0001 0001&lt;br /&gt;
     a&lt;br /&gt;
   0002 0001&lt;br /&gt;
     b&lt;br /&gt;
   ffff 0002&lt;br /&gt;
     c&lt;br /&gt;
     d&lt;br /&gt;
|&lt;br /&gt;
 switch (variable 0xbeef) {&lt;br /&gt;
   case 1:&lt;br /&gt;
     a;&lt;br /&gt;
     break;&lt;br /&gt;
   case 2:&lt;br /&gt;
     b;&lt;br /&gt;
     break;&lt;br /&gt;
   default:&lt;br /&gt;
     c;&lt;br /&gt;
     d;&lt;br /&gt;
     break;&lt;br /&gt;
 }&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The conditional branch command is used on levers, switches and every place where a variable value makes the difference. It's often used as a simple if-then-else mechanism.&lt;br /&gt;
&lt;br /&gt;
==Command 9: enable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Enable card hotspot with the specified ''hotspot_id''.&lt;br /&gt;
&lt;br /&gt;
==Command 10: disable hotspot==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''hotspot_id''&lt;br /&gt;
&lt;br /&gt;
Disable card hotspot with the specified ''hotspot_id''. A disabled hotspot will not respond to events.&lt;br /&gt;
&lt;br /&gt;
==Command 12==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is 0, 1 or 2. This command is used only a few times, for example near &amp;quot;go to stack&amp;quot; commands like in the &amp;quot;play riven&amp;quot; button. It doesn't seem related to anything special (e.g. movies or sounds). Setting ''u0'' to some other value or replacing the command with others doesn't produce readily observable effects. I suspect it has something to do with variables, but I have yet to realize how to check this.&lt;br /&gt;
==Command 13: set mouse cursor==&lt;br /&gt;
[[Image:Cursors.png|right|frame|Riven cursor icons and their IDs]]&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''cursor''&lt;br /&gt;
&lt;br /&gt;
Set mouse cursor icon to ''cursor'', whose meaning is given on the right.&lt;br /&gt;
&lt;br /&gt;
==Command 14: pause script execution==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ms ''u0''&lt;br /&gt;
&lt;br /&gt;
Pause script execution for ''ms'' milliseconds. ''ms'' is signed and the pause is effective only if ''ms'' &amp;gt; 0. ''u0'' is always 0 and its value seems ignored by the engine.&lt;br /&gt;
&lt;br /&gt;
==Command 17: call external command==&lt;br /&gt;
*'''Argument count:''' variable, at least 2&lt;br /&gt;
*'''Arguments:''' ''cmd count arg1 arg2 ...''&lt;br /&gt;
&lt;br /&gt;
Call an external piece of custom code (&amp;quot;external command&amp;quot;), which is probably hardcoded inside the Riven executable. ''cmd'' tells which external command to call, and ''count'' tells how many arguments to pass to it. Then ''count'' arguments follow. [[Riven NAME resources|NAME]] resource 3 contains the name of each external command: ''cmd'' is the corresponding NAME record index. See the [[Riven external commands|external command list]] for more info on external commands.&lt;br /&gt;
&lt;br /&gt;
==Command 18: transition==&lt;br /&gt;
*'''Argument count:''' 1 or 5&lt;br /&gt;
*'''Arguments:''' ''code [left top right bottom]''&lt;br /&gt;
&lt;br /&gt;
Schedule a transition effect described by ''code'' (see below for what code means). The transition will actually play when a display update occurs, for example with [[#Command 21: enable screen update|command 21]], [[#Command 39: activate PLST record|39]] or after going to another card (it doesn't seem to work for [[#Command 1: draw tBMP resource|command 1]], however). The optional 4 args ''left'', ''top'', ''right'', and ''bottom'' specify a clip rectangle in pixels, but are never really used in the game.&lt;br /&gt;
&lt;br /&gt;
{| border=1 cellpadding=4 cellspacing=0 style=&amp;quot;border:1px #000 solid;border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#CCC&amp;quot;&lt;br /&gt;
! code !! Effect&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|0...15&lt;br /&gt;
|Scroll. Bits 0 and 1 control the direction (0=left, 1=right, 2=top, 3=bottom); bit 2 tells if the new image should move (1) or stay fixed (0); bit 3 tells if the old image should move or stay fixed.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|16||Dissolve.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;font-family:monospace&amp;quot;|17||Seems to behave like 16, rare (t_Data, CARD 155).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that Riven uses only transitions from 12 to 17; other effects were discovered by hacking scripts. Maybe there are more.&lt;br /&gt;
&lt;br /&gt;
==Command 19: reload card==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
It's something like &amp;quot;refresh card&amp;quot;: it acts like a &amp;quot;go to this card&amp;quot; command. Often used to update the card display after an hotspot script has altered a variable.&lt;br /&gt;
&lt;br /&gt;
==Command 20: disable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems to disable the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]]. It doesn't work like a &amp;quot;toggle&amp;quot; command: using it multiple times won't re-enable the automatic update (it is re-enabled by command 21 instead). Its effect persists even after the script ends (extending to any successive script, e.g. hotspot ones) but is reset on card switches. Command 20 often precedes [[#Command 18: transition|command 18]].&lt;br /&gt;
&lt;br /&gt;
==Command 21: enable screen update==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
This seems the opposite of [[#Command 20: disable screen update|command 20]]: it re-enables the automatic display update for commands [[#Command 1: draw tBMP resource|1]] and [[#Command 39: activate PLST record|39]], triggers [[#Handlers|event 10]], updates the display and plays the transition effect if one was scheduled before.&lt;br /&gt;
&lt;br /&gt;
Command 21 shows inconsistent behavior if used alone (sometimes it updates the display, sometimes it doesn't, sometimes it skips the transition, etc.); the correct way of using commands 20 and 21 seems to be the following construct, which is also what is usually found in scripts:&lt;br /&gt;
#disable screen update&lt;br /&gt;
#schedule transition&lt;br /&gt;
#activate [[PLST]] records / draw [[tBMP]] resources&lt;br /&gt;
#enable screen update&lt;br /&gt;
&lt;br /&gt;
This construct will compose a final picture (by overlaying the specified PLST records and tBMP bitmaps, in the same order as they appear in the script) and then play the specified transition effect from the previously displayed picture to the new one. Note that such a complex effect wouldn't be possible without commands 20/21.&lt;br /&gt;
&lt;br /&gt;
==Command 24: increment variable==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''var value''&lt;br /&gt;
&lt;br /&gt;
Add ''value'' to variable ''var''.&lt;br /&gt;
&lt;br /&gt;
==Command 27: go to stack==&lt;br /&gt;
*'''Argument count:''' 3&lt;br /&gt;
*'''Arguments:''' ''stack_name code_hi code_lo''&lt;br /&gt;
&lt;br /&gt;
Go to another stack. The destination stack is specified by ''stack_name''; you get the actual stack name string by looking up record ''stack_name'' in [[Riven NAME resources|NAME]] resource 5. The destination card is specified through ''code_hi'' (higher 16 bytes) and ''code_lo'' (lower 16 bytes) which together form an unsigned long [[Riven RMAP resources|RMAP]] card code.&lt;br /&gt;
&lt;br /&gt;
==Command 28==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. It should have something to do with movies: it comes almost always after [[#Command 32: play foreground movie|command 32]] with the same argument. However, changing code or even removing the command itself seem to have no effect neither on the movie nor on anything else. Maybe it purges the memory used by the movie or something like that.&lt;br /&gt;
&lt;br /&gt;
==Command 29==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown. Seems related to movies since in most cases it comes after [[#Command 32: play foreground movie|command 32]]. Used quite rarely.&lt;br /&gt;
==Command 31==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies, it comes often before [[#Command 33: play background movie|command 33]] with the same argument. Changing code seems to have no effect.&lt;br /&gt;
&lt;br /&gt;
==Command 32: play foreground movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Play a movie listed in the [[Riven MLST resources|MLST]] resource, blocking the script execution until movie ends. code matches the code field of the MLST record that should be played. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead (or nothing will happen at all). If multiple records have that code value, one will be chosen randomly, I guess. Sometimes this command follows [[#Command 33: play background movie|command 33]] with the same parameter: probably it just means &amp;quot;wait until the movie ends&amp;quot; in that case.&lt;br /&gt;
&lt;br /&gt;
==Command 33: play background movie==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''code''&lt;br /&gt;
&lt;br /&gt;
Start a &amp;quot;background&amp;quot; movie from [[Riven MLST resources|MLST]] record with specified code. Script execution will go on (and eventually terminate) while the movie is playing. Often this command follows [[#Command 31|command 31]]. The MLST record must be first enabled with [[#Command 46: activate MLST record|command 46]], otherwise some other random movie will play instead.&lt;br /&gt;
&lt;br /&gt;
==Command 34==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. ''u0'' is always 1.&lt;br /&gt;
&lt;br /&gt;
==Command 36==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 37==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Unknown.&lt;br /&gt;
&lt;br /&gt;
==Command 38==&lt;br /&gt;
*'''Argument count:''' 5&lt;br /&gt;
*'''Arguments:''' ''u1 u2 u3 u4 u5''&lt;br /&gt;
&lt;br /&gt;
Unknown, but should have something to do with movies. ''u1'' seems to refer to a [[Riven MLST resources|MLST]] record code, ''u5'' seems to be a [[Riven SLST resources|SLST]] record index and ''u4'' seems always 40. ''u2'' and ''u3'' seem to form a 32-bit value set to large numbers (4000, 9000...), which I suspect are milliseconds.&lt;br /&gt;
&lt;br /&gt;
This command seems to perform complex actions: if ''u4'' is changed to 0, ''u5'' is interpreted instead as a [[Riven tBMP resources|tBMP]] resource ID and that bitmap is drawn right after the movie.&lt;br /&gt;
&lt;br /&gt;
==Command 39: activate PLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven PLST resources|PLST]] resource, making one of the card bitmaps visible. The actual screen update takes place immediately (with a transition effect, if one was scheduled before) unless [[#Command 20: disable screen update|command 20]] was used before or the command is called from [[#Handlers|handlers 6 or 10]].&lt;br /&gt;
&lt;br /&gt;
==Command 40: activate SLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified [[Riven SLST resources|SLST]] record, so start ambient sounds. This command seems to have effect just once: it won't restart the same sound if it is already playing (even if the SLST tells not to repeat it). Activating another SLST record works always: the current sound is then stopped and replaced with the new one.&lt;br /&gt;
&lt;br /&gt;
==Command 41==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''u0''&lt;br /&gt;
&lt;br /&gt;
Unknown. Should have something to do with movies because it comes often before [[#Command 32: play foreground movie|command 32]] with the same argument. A hypothesis is that it activates a [[Riven MLST resources|MLST]] record like [[#Command 46: activate MLST record|46]], but using its code field rather than the MLST record index.&lt;br /&gt;
==Command 43: activate BLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven BLST resources|BLST]] resource, so enable or disable one of the card hotspots (depending on the record info).&lt;br /&gt;
&lt;br /&gt;
==Command 44: activate FLST record==&lt;br /&gt;
*'''Argument count:''' 1&lt;br /&gt;
*'''Arguments:''' ''record''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven FLST resources|FLST]] resource, so enable a realtime [[Riven SFXE resources|SFXE]] effect.&lt;br /&gt;
&lt;br /&gt;
==Command 45: do zip mode==&lt;br /&gt;
*'''Argument count:''' 0&lt;br /&gt;
&lt;br /&gt;
Find the correct [[Riven ZIPS resources|ZIPS]] record using the hotspot name, get the destination card from the found record and go to that card. Though likely, this behavior has not been confirmed yet.&lt;br /&gt;
&lt;br /&gt;
==Command 46: activate MLST record==&lt;br /&gt;
*'''Argument count:''' 2&lt;br /&gt;
*'''Arguments:''' ''record u0''&lt;br /&gt;
&lt;br /&gt;
Activate the specified record in the [[Riven MLST resources|MLST]] resource. This command won't actually start the movie; it will only &amp;quot;enable&amp;quot; it for later playing. ''u0'' seems 0 or 1 if the movie is to be played once or looped forever, respectively. This is redundant, since the same info can be found in the MLST record; moreover, ''u0'' seems to be ignored by the engine.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Riven_tMOV_resources</id>
		<title>Riven tMOV resources</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Riven_tMOV_resources"/>
				<updated>2008-02-12T14:24:23Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{{Riven}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
tMOV resources are QuickTime movies. For a complete reference of the format, please see http://developer.apple.com/documentation/QuickTime/QTFF/QTFFPreface/chapter_1_section_1.html.&lt;br /&gt;
&lt;br /&gt;
== Codecs ==&lt;br /&gt;
&lt;br /&gt;
All Riven movies use the Cinepak video codec and the Apple IMA 4:1 audio codec.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	<entry>
		<id>http://insidethelink.ortiche.net/wiki/index.php/Mohawk_archive_format</id>
		<title>Mohawk archive format</title>
		<link rel="alternate" type="text/html" href="http://insidethelink.ortiche.net/wiki/index.php/Mohawk_archive_format"/>
				<updated>2008-02-05T15:56:23Z</updated>
		
		<summary type="html">&lt;p&gt;BahamutZERO: /* File table */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==General layout==&lt;br /&gt;
Mohawk archives are organized in chunks, and this is the chunk layout:&lt;br /&gt;
* IFF chunk&lt;br /&gt;
** IFF header&lt;br /&gt;
** RSRC header&lt;br /&gt;
** Resource dir&lt;br /&gt;
*** Type table&lt;br /&gt;
*** Name tables (one for each resource type)&lt;br /&gt;
*** Resource tables (one for each resource type)&lt;br /&gt;
*** Resource name list&lt;br /&gt;
*** File table&lt;br /&gt;
** Actual data (resource contents)&lt;br /&gt;
Note that the chunks may be found in a different order: never trust on them being at fixed locations, and use the offsets to reach them.&lt;br /&gt;
&lt;br /&gt;
Every integer is in big-endian (Motorola) byte order.&lt;br /&gt;
&lt;br /&gt;
==IFF header==&lt;br /&gt;
This is always at the beginning of the file.&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|4 bytes||chunk signature (MHWK), identifies Mohawk archive format&lt;br /&gt;
|-&lt;br /&gt;
|unsigned long||file size in bytes, '''not''' counting this IFF header (that is, file size - 8)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==RSRC header==&lt;br /&gt;
I think this is actually the &amp;quot;Resource Dir header&amp;quot;. Note that the Dir can be anywhere in file, but this header always follows the IFF Header.&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|4 bytes||chunk signature (RSRC)&lt;br /&gt;
|-&lt;br /&gt;
|unsigned long||should be length of RSRC chunk (never bothered to check)&lt;br /&gt;
|-&lt;br /&gt;
|unsigned long||total file size in bytes&lt;br /&gt;
|-&lt;br /&gt;
|unsigned long||absolute offset of the Resource Dir&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||offset in Resource Dir of the File Table&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||File Table size in bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Type table==&lt;br /&gt;
It lists resource types in the Mohawk file. This table is always at the beginning of the Resource Dir.&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||offset in Resource Dir of the Resource Name List (maybe this should go with the RSRC Header)&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||number of resource types in this file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry (one for each type):&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|4 bytes||resource type (tWAV, tBMP, NAME etc.)&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||offset in Resource Dir of the Resource Table for this type&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||offset in Resource Dir of the Name Table for this type&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Name table==&lt;br /&gt;
There is one name table for each resource type. Many types don't have resource names; usually only tBMP, tWAV and tMOV do. Each entry holds the name offset in the name list for a resource.&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||number of name entries (can be zero)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||offset of the name string in Name List&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||resource index (equal to the resource's index in File Table)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resource table==&lt;br /&gt;
Again, there is one resource table for each resource type. The resource table holds crucial information about each resource of this type.&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||number of resources for this type (number of table entries)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned short||resource ID&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||index in file table (starting from 1). Also used to find the matching name table entry&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resource name list==&lt;br /&gt;
This is a simple list of null-terminated strings (C strings), where each string is a resource name. Given a resource, you can get the offset to its name by looking in the name table entry for that resource.&lt;br /&gt;
&lt;br /&gt;
==File table==&lt;br /&gt;
This table holds other important data about each resource, notably the location and size of the resource content within the whole Mohawk file. I wonder why this information couldn't go directly inside the resource table entry.&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned long||number of file table entries&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry:&lt;br /&gt;
{| class=&amp;quot;structure&amp;quot;&lt;br /&gt;
|unsigned long||absolute offset of resource data block&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||resource data size, bits 15-0&lt;br /&gt;
|-&lt;br /&gt;
|byte||resource data size, bits 23-16&lt;br /&gt;
|-&lt;br /&gt;
|byte||resource flags (unknown)&lt;br /&gt;
|-&lt;br /&gt;
|unsigned short||unknown (usually zero in Riven files)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It should be noted that the resource data size information is quite often incorrect (at least in Riven archives). One can compensate for this by computing file lengths using the resource offsets.&lt;/div&gt;</summary>
		<author><name>BahamutZERO</name></author>	</entry>

	</feed>