AGIWiki/new.room

From ScummVM :: Wiki
< AGIWiki
Revision as of 15:11, 25 October 2018 by Criezy (talk | contribs) (Text replacement - "</source>" to "</syntaxhighlight>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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