Difference between revisions of "AGIWiki/new.room"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
Tags: Mobile edit Mobile web edit
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
Line 53: Line 53:
 
     new.room(25);
 
     new.room(25);
 
  }
 
  }
</source>
+
</syntaxhighlight>
  
 
The next example accomplishes the same task with <code>new.room.v</code><nowiki>: </nowiki>
 
The next example accomplishes the same task with <code>new.room.v</code><nowiki>: </nowiki>
Line 66: Line 66:
 
     new.room.v(v202);
 
     new.room.v(v202);
 
  }
 
  }
</source>
+
</syntaxhighlight>
  
 
== Technical Information ==
 
== Technical Information ==

Latest revision as of 15:11, 25 October 2018

AGIWiki


Control Flow Commands

The new.room command changes the current room number to a new room and forces an update. There is an indirect version of this command called new.room.v.

Syntax

new.room(byt roomNumber);

Remarks

The new.room command causes the interpreter to halt execution of the current script. The resources on the memory heap are dumped (with the exception of logic 0). The following things happen automatically when this command is issued:

  • If a sound is playing, it is stopped.
  • The keyboard buffer and controller state are cleared.
  • The script table is cleared.
  • All objects are unanimated.
  • All resources except logic 0 are discarded (removed from memory).
  • The player.control command is executed.
  • The unblock command is executed.
  • The horizon is set to 36.
  • v1 (previous room number) is set to the value of v0 (room number)
  • v0 (room number) is assigned roomNumber
  • v16 (ego view number) is set to the view number assigned to ego.
  • v8 (free memory pages) is set to 10.
  • The logic for the new room is loaded (logic roomNumber).
  • If ego was touching an edge of the screen, it is placed on the opposite side (i.e. if ego touched right edge, it is moved to left edge).
  • v2 (ego_edge_code) is set to zero.
  • Status line is redrawn.
  • Flag 5 (new room flag) is set (the flag is reset after the first cycle in the new room).
  • Execution jumps to the start of logic 0.

Parameters

For new.room

  • roomNumber: a number, 0-255, specifying which room to switch to

Possible errors

Examples

The following code goes to room 25 if ego is touching the left edge of the screen:

 #define ego_edge_code v2
 #define left_edge      4

 if (ego_edge_code == left_edge)
 {
     new.room(25);
 }

The next example accomplishes the same task with new.room.v:

 #define ego_edge_code v2
 #define left_edge      4

 if (ego_edge_code == left_edge)
 {
    v202 = 25;
    new.room.v(v202);
 }

Technical Information

Required interpreter version Available in all AGI versions
Bytecode value 18 (0x12 hex)

See also

Sources