Difference between revisions of "AGIWiki/new.room.v"

From ScummVM :: Wiki
Jump to navigation Jump to search
(→‎Examples: Fix syntax highlighting)
Line 45: Line 45:
The following code goes to room 25 if [[AGIWiki/Ego|ego]] is touching the left edge of the screen:
The following code goes to room 25 if [[AGIWiki/Ego|ego]] is touching the left edge of the screen:

<syntax type = "C++">
<source lang="cpp">
  #define ego_edge_code v2
  #define ego_edge_code v2
  #define left_edge      4
  #define left_edge      4
Line 54: Line 54:

== Technical Information ==
== Technical Information ==

Revision as of 20:57, 11 May 2016


Control Flow Commands

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


new.room.v(var roomNumber);


The new.room.v 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.


For new.room.v

  • roomNumber: a variable, v0-v255, whose value specifies which room to switch to

Possible errors


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)
    v202 = 25;

Technical Information

Required interpreter version Available in all AGI versions
Bytecode value 19 (0x13 hex)

See also