gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Fading a bitmap

#43200 - Impatient - Fri May 20, 2005 6:40 am

Say I have a mode 3 or mode 5 bitmap. Those do not have seperate RGB value tables. How do you fade those to and from black? The GBA has a hardware fade register (forgot the name). Can't you just use that register to fade to/from black? Or do you need to in mode 3 and 5 to fade each and every single pixel in a loop masking out the colors?

#43210 - MrD - Fri May 20, 2005 11:16 am

You can use REG_BLDMOD (04000050h) and REG_COLEY (04000054h), sure!

Remember that you need to set it to fade BG2 (also for mode 3,4,5 bitmaps) as an A layer.

Code:
REG_BLDMOD = bit6 | bit7 | bit2;
REG_COLEY = 0;                 // Number from 0-17.
                                // Controls strength of fades =to white and black=.

// bit2 is BG2 as an A layer. bit6 and 7 make it a fade to black using REG_COLEY

u32 frame = 0;

while (frame < 17) {       // Simple fast fade, 16 frames long.
   vsync();
   REG_COLEY = frame;
   frame++;
}

// Screen will be totally black here. Remember to set REG_BLDMOD and REG_COLEY to something innocent when you try to display something else, or you'll just get black!


http://user.chem.tue.nl/jakvijn/tonc/gfx.htm - TONC has ?ber blending advice + register layout.
_________________
Not active on this forum. For Lemmings DS help see its website.

#43416 - Impatient - Mon May 23, 2005 6:26 am

Where does the BLDCNT register fit it? Bits 6 and 7 in this register should control a hardware based fade??

#43421 - MrD - Mon May 23, 2005 10:13 am

http://user.chem.tue.nl/jakvijn/tonc/gfx.htm#blend

I think BLDMOD is the new name for BLDCNT or vice versa... CowBite seems to call it both.

Bits 0,1,2,3,4,5 choose what is the A-layer.
Bits 8,9,a,b,c,d choose what is the B-layer.
and Bits 6 and 7 choose the fade type.

REG_COLEY controls the strength of a "blend A to white/black" fade (16 is fully white/black)

REG_COLEV controls the weights of a standard "blend A with B" blend. Check out the TONC, s'got a good example.
_________________
Not active on this forum. For Lemmings DS help see its website.