Module gba::video::obj

source ·
Expand description

Module for object (OBJ) entry data.

The GBA’s object drawing allows for hardware drawing that is independent of the background layers. Another common term for objects is “sprites”, but within the GBA community they’re called objects, so this crate calls them objects too.

The GBA has 128 object entries within the Object Attribute Memory (OAM) region. The object entries are also interspersed with the memory for the affine entries, so OAM should not be thought of as being an array of just one or the other types of data.

A few of the GBA’s controls will affect all objects at once, particularly the Display Control (which can control if the objects are visible at all), but in general each object can be controlled independently.

Each object entry consists of a number of bit-packed “attributes”. The object’s attributes are stored in three 16-bit fields. The ObjAttr struct has one field for each 16-bit group of attributes: ObjAttr0, ObjAttr1, ObjAttr2.

When you’ve got an object’s data configured how you want, use either the OBJ_ATTR_ALL control (to write all fields at once) or the OBJ_ATTR0, OBJ_ATTR1, and/or OBJ_ATTR2 controls (to write just some of the fields).

Note: When the GBA first boots, the object layer will be off but the object entries in OAM will not be set to prevent individual objects from being displayed. Before enabling the object layer you should generally set the ObjDisplayStyle of all ObjAttr0 fields so that any objects you’re not using don’t appear on the screen. Otherwise, you’ll end up with un-configured objects appearing in the upper left corner of the display.

Structs§

  • Object Attributes.
  • Object Attributes, field 0 of the entry.
  • Object Attributes, field 1 of the entry.
  • Object Attributes, field 2 of the entry.

Enums§