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

From ScummVM :: Wiki
Jump to navigation Jump to search
m
(→‎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:
 
     new.room.v(v202);
 
     new.room.v(v202);
 
  }
 
  }
</syntax>
+
</source>
  
 
== Technical Information ==
 
== Technical Information ==

Revision as of 20:57, 11 May 2016

AGIWiki


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.

Syntax

new.room.v(var roomNumber);

Remarks

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.

Parameters

For new.room.v

  • roomNumber: a variable, v0-v255, whose value specifies 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)
 {
    v202 = 25;
    new.room.v(v202);
 }

Technical Information

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

See also

Sources