Expand description
GBA Memory-mapped IO (MMIO) stuff.
The GBA is controlled via MMIO. An MMIO location is called a “register”, similar to the CPU having registers. The different registers are all globally accessible, so user code must have its own convention for who is supposed to touch what values when.
This crate defines newtypes that describe the data layout of each register,
and if you enable the unsafe_addresses
feature it also defines the
addresses of each register. The type of address used for each register lets
you know about the safety (or not) of accessing a given register. The safety
assessment relies on the code being run only on a GBA, so if you use this
crate on your desktop or something that’s your fault.
This is only “work in progress” status, but please file an issue if things are unclear. While you’re waiting you can also check GBATEK, which is the standard resource for GBA info (and it’s most of where this crate’s docs come from).
§Naming Conventions
By default, the name used for an address is the same as the GBATEK name.
In some cases I’ve combined what GBATEK considers multiple adjacent
registers into a single larger register. For example, WININ
and WINOUT
have been combined to simply be exposed as WIN_CONTROL
. The MMIO is
flexible like this, as long as the alignment of the combined address is
correct for the combined data type it’s all fine. Let me know what you think
(tracker), because we
could make adjustments in this area.
For each setting within a register data newtype there will be three methods per setting contained within the newtype:
- A const “getter” named the same as the setting (eg:
foo
). - A const “with-er” which takes
self
and returns a new value (eg:with_foo
). - A “setter” which takes
&mut self
and updates the value in place (eg:set_foo
). This will hopefully also be const in a future version of Rust.
Structs§
- Alpha
Blend Value - Coefficients for the alpha blending special effect.
- Background
Control Value - Lets you adjust how each background layer is displayed.
- Blend
Control Value - This lets you configure hardware color blending.
- Color
- On the GBA, colors have 5 bits per channel.
- Color
Special Effect - The color special effects available via hardware on the GBA.
- Danger
Write VolAddr - Represents an MMIO address that can be safely read, but writes are dangerous.
- Display
Control Value - Top level control for the LCD display.
- Display
Status Value - Relates to the status of the display.
- High
Active Keys - The GBA’s key data, where a high value in a bit means the key is pressed.
- LowActive
Keys - The GBA’s key data, where a low value in a bit means the key is pressed.
- Mode3
- A ZST for namespacing VideoMode3 stuff into one place.
- Mode4
- A ZST for namespacing VideoMode4 stuff into one place.
- Mode5
- A ZST for namespacing VideoMode4 stuff into one place.
- Mode3
Col - A particular column within the Mode 3 bitmap.
- Mode3
Row - A particular row within the Mode 3 bitmap.
- Mode4
Col - A column within one of the two Mode 4 indexmaps.
- Mode4
Frame - One of the two indexmap frames available in Mode 4.
- Mode4
Row - A row within one of the two Mode 4 indexmaps.
- Mode5
Col - A column of one of the two Mode 5 bitmaps.
- Mode5
Frame - One of the two bitmap frames available in Mode 5.
- Mode5
Row - A row within one of the Mode 5 frames.
- Mosaic
Control Value - Controls the intensity of the “mosaic” special effect.
- PALRAM
- A ZST for namespacing palette ram related functionality.
- Read
Only VolAddr - Represents an MMIO address that can be safely read, but not written.
- Simple
VolAddr - Represents a simple MMIO address that can be safely read or written.
- Video
Mode - The video modes available on the GBA.
- WinHorizontal
- Defines the horizontal bounds of Window 0 and 1.
- WinVertical
- Defines the vertical bounds of Window 0 and 1.
- Window
Control Value - Lets you set what layers appear inside and outside of the window areas.
- Write
Only VolAddr - Represents a simple MMIO address that can be written but not read.
Constants§
- BG0CNT
- “Background 0 Control” (Text mode only).
- BG0OFS
- “Background 0 Offset” (Text mode only).
- BG1CNT
- “Background 1 Control” (Text mode only).
- BG1OFS
- “Background 1 Offset” (Text mode only).
- BG2CNT
- “Background 2 Control” (Text/Affine mode only).
- BG2OFS
- “Background 0 Offset” (Text mode only).
- BG2_
AFFINE_ MATRIX - “Background 2 Affine Parameter Matrix” (Affine/Bitmap mode only).
- BG2_
REF_ POINT - “Background 2 Reference Point” (Affine/Bitmap mode only).
- BG3CNT
- “Background 3 Control” (Text/Affine mode only).
- BG3OFS
- “Background 0 Offset” (Text mode only).
- BG3_
AFFINE_ MATRIX - “Background 3 Affine Parameter Matrix” (Affine mode only).
- BG3_
REF_ POINT - “Background 3 Reference Point” (Affine mode only).
- BLDALPHA
- “Alpha Blend Control”.
- BLDBRIGHT
- “Brightness Blend Control”.
- BLDCNT
- “Blend Control”.
- DISPCNT
- “Display Control”
- DISPSTAT
- “Display Status”
- KEYINPUT
- The register that lets you read the current state of all the keys.
- MOSAIC
- “Mosaic Effect”
- VCOUNT
- “Vertical Counter”
- VRAM
- Base address value of VRAM.
- WIN_
CONTROL - “Window Controls”
- WIN_
HORIZONTAL - “Window Horizontal Edges”
- WIN_
VERTICAL - “Window Vertical Edges”