I've been trying to use the GBA hardware's special effects to adjust the
brightness of selected sprites.
I've got a demo that works exactly as I'd hoped on VisualBoy Advance v1.5.1
(in that only the selected sprites have their brightness changed) but on the
real hardware all the sprites brightnesses change. It does different things
again on BoycottAdvance v0.2.8. I've put up the binary demonstrating this
online at:
http://www.davidsharp.com/brighttest.zip
The relevant samples of source code are below, I've stripped out large parts
of it to get down to the bare bones. Can anyone tell me if what I'm trying
to do is possible and if so where I'm going wrong?
I'm quite prepared to believe I'm doing something silly which is normally
not sensible and that's why the emulators don't handle it correctly.
// enable display
REG_BG1CNT = 0x4084;
REG_BG1HOFS = 0;
REG_BG1VOFS = 0;
SetMode(SCREENMODE1 | BG1ENABLE | OBJENABLE | OBJMAP1D );
// load tiled background and set up sprites on display as shown in PERN
tutorial, set sprites up as follows
// sprites[spriteNumber].attribute0 = COLOR_256 | y | SQUARE;
// sprites[spriteNumber].attribute1 = SIZE_16 | x;
// sprites[spriteNumber].attribute2 = charNumber;
// copy all sprite data to OAM
// select targets of colour FX
REG_BLDMOD = 0x1090; // bit 4 - use OBJ as 1st target, bit 7 - change
brightness, set bit 12 to say that OBJ is second target too (has no obvious
effect)
// set all the sprites in the top row to be the ones fading
int sprCount;
for(sprCount = OAM_LETTERS; sprCount < firstSpriteOfInstructions;
sprCount++)
{
sprites[sprCount].attribute0 &= ~(0xC00); // clear OBJ mode flag to
ensure Normal OBJ mode
sprites[sprCount].attribute0 |= 1 << 10; // set to semi-transparent mode
}
// set the bottom words to be the ones stuck not fading
for(sprCount = firstSpriteOfInstructions; sprCount < spriteNum; sprCount++)
{
sprites[sprCount].attribute0 &= ~(0xC00); // clear OBJ mode flag to
ensure Normal OBJ mode
}
copyAllOAM();
// set brightness to approx halfway between normal and white
REG_COLEY = 8;
Cheers
Dave