RAM
Wikipedia also has an article about RAM. |
RAM (random-access memory) is a class of computer memory.
The RAM, like scratch paper is a database of writable variables in the game that are usually (except for SRAM) not kept when the game is powered off.
Examples of RAM addresses include the current level and species of a wild Pokémon in battle, the player's current coordinates, the current music data and so on.
The location of a RAM address in Game Boy games (like ROM addresses) are represented by two bytes, for example D059 in English Pokémon Red and Blue controls which Pokemon or Trainer will be encountered by the player.
A single RAM address can store up to one byte (8 bits or 256 values) worth of data, but RAM addresses can be combined to store more data.
Writing to the RAM will change this data, and writes to the RAM usually take place during run-time of the game.
Cheating devices, arbitrary code execution and unintended ROM code execution can perform writes to the RAM for an unintended advantage. Arbitrary code execution itself is the execution of RAM as if it was code rather than data.
Game Boy RAM
In a Game Boy game there are various different types of RAM represented by two bytes, including:
- VRAM (8000-9FFF): Used for graphics data. VRAM is not always accessible and can return FFs or the wrong data if read during VRAM inaccessibility.
- SRAM (A000-BFFF): Used for the save data. SRAM is banked and can also be locked until a write to ROM is attempted.
- RAM (C000-CFFF): Used to store various in-game variables, such as the wild Pokémon in battle or a Pokémon's stats. This section of the RAM is unbanked.
- WRAM (D000-DFFF): An extension of RAM, banked. WRAM stands for working RAM.
- Echo RAM (E000-FDFF): Echo RAM is normally not meant to be used, but is a copy of the RAM at C000-DDFF. Modifying the RAM and WRAM will also modify the Echo RAM. Echo RAM is often abused in arbitrary code execution.
- HRAM (FF80-FFFE): Stores hardware related variables. Also known as the zero page.