#69348 - gs2phateon - Mon Jan 30, 2006 6:17 am
I'm trying to do this on Mode 0, but I'm have some difficulty. I'm pretty sure I set it up, but the Sprite I'm using isn't turning transparent. If it makes any difference, I'm using two backgrounds. I have already been able to do this on the bitmap modes, so is there anything I have to change when switching over to the tile-based modes?
#69349 - tepples - Mon Jan 30, 2006 6:23 am
It only alpha-blends if the frontmost pixel in the stack is marked as a top layer and the second pixel is marked as a bottom layer. Using the OAM transparency bit already marks the sprite as top, so you'll need to mark both of your bg layers as bottom in BLDCNT.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#69350 - gs2phateon - Mon Jan 30, 2006 6:31 am
Sorry, I'm not really sure how to go about doing that. I'm using backgrounds 1 and 3, would it be possible for you to do a quick example?
#69353 - gs2phateon - Mon Jan 30, 2006 6:45 am
OK, I think I got it, but the blended sprite (green) looks kind of dark against a dark background (blue). This is supposed to happen right?
#69354 - tepples - Mon Jan 30, 2006 6:50 am
gs2phateon wrote: |
Oh, and if this helps, the example I used for mode 3 was
Code: | REG_BLDMOD = (1 << 4) | (1 << 10); |
If doing an example is too hard, could you explain what each part in this line means? |
(1 << 4) means all sprites are "top"; (1 << 10) means BG2 is "bottom". In general, you don't want to make all sprites "top"; instead you want to set the semitransparent bit in an individual OAM structure.
Code: |
/*
* Defines for BLDCNT that may or may not make more sense
* than those in libgba headers
*/
#define BLEND_BG0_TOP (1 << 0)
#define BLEND_BG1_TOP (1 << 1)
#define BLEND_BG2_TOP (1 << 2)
#define BLEND_BG3_TOP (1 << 3)
#define BLEND_BG0_BOTTOM (1 << 8)
#define BLEND_BG1_BOTTOM (1 << 9)
#define BLEND_BG2_BOTTOM (1 << 10)
#define BLEND_BG3_BOTTOM (1 << 11)
#define BLEND_SKY_BOTTOM (1 << 13)
#define BLEND_ALPHA (1 << 6)
// Defines for OAM attribute 0 (Y)
#define OAM_ALPHA (1 << 10)
|
You might have to change the first line of the following to correspond to which bg layers you're actually using:
Code: |
//For use with above defines
REG_BLDMOD = BLEND_ALPHA | BLEND_BG2_BOTTOM | BLEND_BG3_BOTTOM;
OAM[0].attr0 = (/*whatever*/) | OAM_ALPHA;
|
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#69356 - gs2phateon - Mon Jan 30, 2006 6:54 am
Thanks, that helped me a lot. I also have a better idea how to change the bits on other registers.