Alpha blending sprites at Nintendo DS Homebrew

I am trying to use alpha-blend sprites and backgrounds with devkitPro (including libnds, libarm, etc.).

Does anyone know how to do this?

+7
c ++ c nintendo-ds
source share
3 answers

As a generic link, I once wrote a short blog post about this issue. Basically, you first need to determine which layer is the alpha mixture against which the other layers are located. AFAIK,

  • The source layer (s) must be on top of the target layer (s) in order to display any blending. this means that the priority of the source layers must be numerically lower than the priority of the target layers.
  • the source layer is what will be translucent, the destination (s) is what will be visible (and yes, I find it rather confusing).

In sprites, in particular , you have 3 ways to achieve alpha blending, depending on what you need and what you are “willing to pay” for it:

  • You can make all sprites alpha blend by including BLEND_SRC_SPRITE in REG_BLDCNT[_SUB] ... not so useful.
  • You can selectively enable blending of some sprites with ATTR0_TYPE_BLENDED . The blending level will be the same for all sprites (and layers).
  • In raster types, sprites use direct colors (bypassing the palettes), so the ATTR2_PALETTE() field of the GBA descriptors is useless and redesigned into ATTR2_ALPHA .
+4
source share

Sprites on DS can be offset by alpha using the mix control registers . TONC provides the necessary information to get the mix working on the main screen because the register locations are the same. Alpha blending on a sub-screen uses the same process with different registers with an offset of 1000 hours.

The registers you will 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 secondary screen.

Also remember that you need to change the graphical mode of the sprite to enable blending for the sprite.

+4
source share

It was a long time since I did any GBA programming, but as I recall, DS supports most (if not all) of the files supported by GBA. This link contains a section on how to perform alpha blending for GBA (section 13.2). I don’t know if there is any DS-specific way to do this, but this should work for you.

+1
source share

All Articles