[−][src]Module gba_addresses::vram
Video RAM (VRAM
).
The exact usage of this memory depends on your video mode:
- Mode 0: Layers 0, 1, 2 and 3 are text mode.
- Mode 1: Layers 0 and 1 are textual, layer 2 is affine.
- Mode 2: Layers 2 and 3 are affine.
- Mode 3: Layer 2 is a 240x160 direct color bitmap.
- Mode 4: Layer 2 is two 240x160 indexed color bitmaps.
- Mode 5: Layer 2 is two 160x128 direct color bitmaps.
A tile is always 8x8, but tiles can be either 4bpp and 8bpp.
Many things related to VRAM
work in "Charblocks":
- A charblock is 16kb.
- In terms of charblocks,
VRAM
has 4 blocks for background tiles and 2 blocks for object tiles. - In video modes 0, 1, and 2 both tile data and screenblocks occupy the first 4 charblocks.
- In video mode 3, 4, and 5, the bitmap data occupies all background charblocks and also the first object charblock, so only the final charblock is available for object tile data.
A "Screenblock" gives the layout of how tiles should be arranged.
- A screenblock index always is in terms of 2kb, so indexes are always in
the range
0..32
. Note that the actual size of a full screenblock isn't necessarily 2kb. - Screenblocks and tile image data both have to share space in VRAM.
- Text Mode:
- 2 bytes per screen entry, 32x32 entries per screenblock (2kb).
- A layer can be 1, 2, or 4 screenblocks:
- 32x32: one screenblock (square)
- 64x32: one screenblock, and the next screenblock on the right (horizontal).
- 32x64: one screenblock, and the next screenblock beneath (vertical).
- 64c64: the base screenblock, then down, then right, then down right (large square).
- Affine Mode:
- 1 byte per entry, entry count per screenblock depends on the background size: 16x16 (256b), 32x32 (1kb), 64x64 (4kb), or 128x128 (16kb).
- Each layer is a one screenblock.
You cannot validly write a single byte to VRAM
. If you do so, the
8-bits are written to both the upper and lower 8-bits of the given 16-bit
segment of memory. This can cause a problem when working with the video mode
4 bitmap, or with the video mode 1 or 2 affine screenblocks. To modify a
single byte correctly you must read at least 16-bits, mask in the new 8-bit
value, and then write back the larger value.
- Size: 96kb
- Wait states: 0
- Bus Size: 16-bit
- Read/Write: 16/32
Structs
CharblockAddress | This is just a |
Constants
AFFINE_SCREENBLOCK_ENTRY_SIZE | The size of an affine mode screen entry. |
AFFINE_SIZE0_SCREENBLOCK_ENTRY_COUNT | The number of entries in a size 0 affine screenblock. |
AFFINE_SIZE0_SCREENBLOCK_SIZE | The size of a size 0 affine screenblock. |
AFFINE_SIZE1_SCREENBLOCK_ENTRY_COUNT | The number of entries in a size 1 affine screenblock. |
AFFINE_SIZE1_SCREENBLOCK_SIZE | The size of a size 1 affine screenblock. |
AFFINE_SIZE2_SCREENBLOCK_ENTRY_COUNT | The number of entries in a size 2 affine screenblock. |
AFFINE_SIZE2_SCREENBLOCK_SIZE | The size of a size 2 affine screenblock. |
AFFINE_SIZE3_SCREENBLOCK_ENTRY_COUNT | The number of entries in a size 3 affine screenblock. |
AFFINE_SIZE3_SCREENBLOCK_SIZE | The size of a size 3 affine screenblock. |
CHARBLOCK_4BPP_COUNT | The number of 4bpp tiles in a Charblock. |
CHARBLOCK_8BPP_COUNT | The number of 8bpp tiles in a Charblock. |
CHARBLOCK_BG_BASE_ADDR | The base address of the background charblocks. |
CHARBLOCK_BG_COUNT | There are 4 background charblocks. |
CHARBLOCK_OBJ_BASE_ADDR | The base address of the object charblocks. |
CHARBLOCK_OBJ_COUNT | There are 2 object charblocks. |
CHARBLOCK_OBJ_TILE_COUNT | The number of object tile indexes available. |
CHARBLOCK_SIZE | The size of a single Charblock. |
TEXT_SCREENBLOCK_ENTRY_COUNT | The number of entries in a text screenblock. |
TEXT_SCREENBLOCK_ENTRY_SIZE | The size of a text mode screen entry. |
TEXT_SCREENBLOCK_SIZE | The size of a text mode screenblock. |
TILE_4BPP_SIZE | The size of a 4bpp tile. |
TILE_8BPP_SIZE | The size of an 8bpp tile. |
VRAM_BASE_ADDR | The base address for |
VRAM_FRAME0_BASE_ADDR | Base address of the bitmap frame 0 (video modes 3, 4, and 5). |
VRAM_MODE4_FRAME1_BASE_ADDR | Base address of the bitmap frame 1 (video modes 4 or 5). |
Functions
index_bg_charblock | Index to a given background charblock address. |
index_obj_tile | Index to a given object tile. |
index_screenblock | Index to the start of a particular screenblock. |