Room flags

From ZeldaHacking Wiki
Jump to navigation Jump to search

Room flags are a mechanism allowing the game to remember data specific to each room. Each room has one byte worth of room flags, meaning that each room can remember 8 bits of data, or 8 unique boolean values.

Room flags are defined in constants/common/roomFlags.s. There are some standard values, but aside from ROOMFLAG_VISITED and ROOMFLAG_LAYOUTSWAP, room flags can generally be used for any purpose.

In Seasons, room flags are shared between all 4 seasons. In Ages, room flags are shared between corresponding overworld and underwater maps.

Standard values

Field Description
ROOMFLAG_VISITED Set upon visiting the room. Used by the minimap to decide whether to fill in a tile.
ROOMFLAG_ITEM Set upon opening a chest or obtaining a treasure through other means. Remembers whether the item has been collected, and thus whether to mark the chest as opened, or not to spawn the treasure, etc.
ROOMFLAG_LAYOUTSWAP Ages only: Swap the current room's layout with the version on the underwater map. Used for substantial changes to rooms, such as symmetry city.

Scripting

There are a number of scripting opcodes related to the room flags:

  • jumpifroomflagset - Conditional jump depending on if a room flag is set
  • orroomflag - Do a binary OR on the room flags byte (set one or more flags)
  • stopifitemflagset - End the script if a room flag is set
  • stopifroomflag80set - End the script if room flag $80 (ROOMFLAG_80) is set

See include/script_commands.s for details.