Search code examples
c++cnintendo-ds

Alpha blending sprites in Nintendo DS Homebrew


I'm trying to alpha blend sprites and backgrounds with devkitPro (including libnds, libarm, etc).

Does anyone know how to do this?


Solution

  • As a generic reference, i once wrote a small blog entry about that issue. Basically, you first have to define which layer is alpha-blended against which other layer(s). Afaik,

    • the source layer(s) must be over destination layer(s) to have some blending displayed. that means the priority of source layers should be numerically lower than the the priority of destination layers.
    • the source layer is what is going to be translucent, the destination(s) is what is going to be seen through (and yes, i find this rather confusing).

    For the sprites, specifically, you then have 3 ways to achieve alpha-blending depending on what you need and what you're "ready to pay" for it:

    • You can make all the sprites have some alpha-blending by turning on BLEND_SRC_SPRITE in REG_BLDCNT[_SUB] ... not that useful.
    • You can selectively turn on blending of some sprites by using ATTR0_TYPE_BLENDED. The blending level will be the same for all sprites (and layers)
    • bitmap-type sprites use direct colors (bypassing the palettes), so the ATTR2_PALETTE() field of GBA sprites is useless and has been recycled into ATTR2_ALPHA.