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

Does anyone know how to do this?


It's been a long time since I've done any GBA programming, but as I recall, the DS supports most (if not all) of the stuff that GBA supports. This link has a section on how to do alpha blending for GBA (section 13.2). I don't know if there's a DS-specific way of doing it, but this should work for you.

Daniel F. Hanson
Too GBA specific
+3  A: 

Sprites on the DS can be alpha blended using the blend control registers. TONC gives the necessary information for getting blending working on the main screen because the register locations are the same. Alpha blending on the subscreen uses the same process with different registers at a 1000h offset.

The registers you'll be looking at are REG_BLDMOD, REG_COLV, and REG_COLY for the main screen and REG_BLDMOD_SUB, REG_COLV_SUB, and REG_COLY_SUB for the sub screen.

Also remember that you'll have to change the sprite's graphic mode to enable blending per sprite.

Cristián Romo
+3  A: 

As a generic reference, i once wrotea 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).