Graphics
VRAM Layouts
Here are some general layouts for the structure of VRAM in various scenarios.
In-game
Bank 0 | |
---|---|
Address range | Graphics |
8000-8fff | Dynamically allocated sprite graphics for npcs, enemies, etc |
9000-91ff | gfx_hud (digits for rupees, hearts, etc) |
9200-93ff(?) | "Tree" graphics for different treetops (can also be used for other things, ie. vasu's sign in seasons). See data/{game}/treeGfxHeaders.s (ages/seasons).
|
9400-97ff | Textbox graphics |
Bank 1 | |
---|---|
Address range | Graphics |
8000-84df | spr_common_sprites |
84e0-851f | Boomerang sprite |
8520-85f0(?) | Weapon sprite (sword, cane, etc) |
8600-86ff | Companion sprites (w1Companion) |
8700-877f(?) | Link sprites |
8780-87ff | Inventory item sprites (items on the HUD) |
8800-97ff | Tileset graphics |
Bank 0 | |
---|---|
Address range | Graphics |
8000-82ff | gfx_inventory_hud_1 |
8300-83ff | gfx_present_past_symbols |
8400-85ff | gfx_quest_items_5 |
8600-867f | gfx_save |
8680-87ff | gfx_map_compass_keys_bookofseals (first quarter not visible) |
8800-89ff | gfx_blank |
8a00-8dff | gfx_rings |
8e00-8fff | gfx_inventory_hud_2 |
9000-97ff | Unused |
Bank 1 | |
---|---|
Address range | Graphics |
8000-81ff | gfx_item_icons_1_spr |
8200-83ff | gfx_item_icons_2 |
8400-85ff | gfx_item_icons_3 |
8600-877f | gfx_essences |
8780-87ff | A and B button item graphics (dynamically changing) |
8800-89ff | gfx_quest_items_1 |
8a00-8bff | gfx_quest_items_2 |
8c00-8dff | gfx_quest_items_3 |
8e00-8fff | gfx_quest_items_4 |
9000-91ff | Unused |
9200-93ff | Text (in the bar at the bottom of the screen) |
9400-97ff | Unused |
Graphics file list
The disassembly has two folders with graphics, the "gfx" folder and the "gfx_compressible" folder. Files in the "gfx_compressible" folder are, of course, compressible, while files in the "gfx" folder are not. Most graphics are compressible, but there are certain cases where it's advantageous to store graphics uncompressed.
There are four types of graphics files:
- gfx_: Graphics data.
- spr_: Graphics data; assumed to be an interleaved sprite, which affects how the PNG is converted to gameboy tiles.
- map_: A tilemap which specifies where to draw which tiles. Usually has a corresponding "flg_".
- flg_: "Flag" or "attribute" data that determines which palettes to use, whether to flip the tile, etc. (These won't be listed since they always correspond to a "map_".)
This is a list of some files in these folders. It isn't complete; it just lists some of the most important graphics, or the ones that aren't self-explanitory.
gfx folder
Filename | Description |
---|---|
gfx_animations_* | These are tiles used for animating the background layer (ie. water, lava, waterfalls). |
spr_dungeon_sprites | Graphics for various objects (minecarts, moving platforms, etc). |
gfx_font | This is the font used in textboxes and whatnot. Unlike most other graphics, it's stored in 1bpp format. The first 14 characters are ignored. |
gfx_font_jp | This file contains mostly kanji, so it's not used much in the english version. It also contains a triangle symbol, though, which is used. 1bpp format. |
gfx_font_tradeitems | These are trade item icons used in textboxes. 2bpp format. |
spr_item_icons_[1,2,3] | These are item icons. They're used in the inventory screen (but the A/B buttons always use sprites; see "spr_item_icons_1_spr" in the "gfx_compressible" folder.) |
gfx_link | Link. |
gfx_past_chest | This file overwrites the chest graphics whenever Link is in the past. This is helpful for indoor areas that use the same tileset in both the past and the present. |
gfx_past_sign | Same idea as gfx_past_chest. |
map_rings | Each 8 bytes of this file defines the tilemap and the attributes needed to display each ring. |
gfx_compressible folder
Filename | Description |
---|---|
gfx_blurb_* | A graphic to show when opening the map in each dungeon. |
spr_common_items | Graphics for the most common item drops (rupees, hearts, fairies, seeds, etc). |
spr_common_sprites | Graphics for many common sprites (explosions, somaria block, etc). Always loaded in address 1:8000 during normal gameplay. |
gfx_dungeon_map_tiles | Graphics for the dungeon map, as well as the cursor (which is also used on the overworld map). |
gfx_hud | Status bar tiles (plus arrow tiles used for textboxes). Usually loaded at 0:9000. |
gfx_inventory_hud | Tiles used in the inventory and the ring list screen. |
spr_item_icons_1_spr | This is analagous to "spr_item_icons_1" in the "gfx" folder, except it's formatted slightly differently to be usable as sprites. Item icons are sprites when on the A or B buttons; otherwise, they're on the background layer.
(gfx_item_icons_2 and 3 don't have sprite versions; apparently, they can be used on both the background and sprite layers already.) |
gfx_map_icons | Icons that appear when you hover over certain areas of the map; and other miscellaneous things (arrows and sparkles for the time portal) |
gfx_map_tiles_common | Tiles used for both the past and present overworld maps. |
gfx_map_tiles_[present,past]_* | Tiles used specifically for the present or past overworld maps. |
map_inventory_[1-3] | Tilemaps for each of the three subscreens of the inventory. |
Object Animations
All of the graphics that can be displayed for an object are handled by animations, even when the "animation" consists of a static image. The animation data is mostly stored in two files: data/<game>/*Animations.s
and data/<game>/*OamData.s
, where the * can be replaced with interaction
, enemy
, or specialObject
. For special objects, like Link, there is an additional third file called data/<game>/specialObjectAnimationPointers.s
. These files exist in both games.
Animations.s
Contents
The bulk of this file is made up of pointer tables.
The first is the Object Animation Table, which maps each object to a list of animations based on that object's ID (interaction ID, enemy ID, or specialObject ID). The second is the Object OAM Table, which maps each object to a list of OAM Blocks. It's also indexed by the object's ID.
Next come the Animation Lists, which are pointed to by the Object Animation Table. These lists point to the actual animation data, which is made up of one or more states. Each state has the following format:
Animation Data Format | |
---|---|
Byte | Description |
0 | State Length, presumably in frames |
1 | OAM List Offset, an offset into the object's OAM List (described below) |
2 | Unknown, possibly used by code to trigger events? |
Each animation state represents a specific OAM setup for the object to be rendered with.
For example, the basic NPC idle animation of the sprite moving back and forth, as seen in the GIF on the right, is made up of two states: one that sets up OAM to render the sprite as it appears in the sprite-sheet, and one that sets up OAM to render the sprite flipped horizontally.
The last bits of data in *Animations.s
are the OAM Lists. These are pointers to the OAM Tiles located in the *OamData.s
files.
OamData.s
Contents
*OamData.s
contains the OAM tile data used by the animations to set up OAM to render the object. Each label represents an OAM Block, and each OAM Block is made up of zero or more OAM Tiles.
Each OAM Block is composed of a single byte that dictates how many OAM Tiles there are, followed by the Tiles themselves. They have the following format:
OAM Tile Format | |
---|---|
Byte | Description |
0 | Y Position of the tile |
1 | X Position of the tile |
2 | Sprite Tile Number (In 8x16 mode, the lower bit of the tile number is ignored. IE: the upper 8x8 tile is "NN AND FEh", and the lower 8x8 tile is "NN OR 01h".) |
3 | A bitfield, enumerated below |
Byte 3 Bitfield | |
---|---|
Bit | Description |
0-2 | GBC Palette Number (palettes 0-7) |
3 | Tile VRAM-Bank (should probably be 0 for most things) |
4 | GB Palette Number (palettes 0-1, probably unused in GBC?) |
5 | X Flip (0=Normal, 1=Horizontally mirrored) |
6 | Y Flip (0=Normal, 1=Vertically mirrored) |
7 | OBJ-to-BG Priority (0=OBJ Above BG, 1=OBJ Behind BG color 1-3); Used for both BG and Window. BG color 0 is always behind OBJ |