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.

Graphics > Adjust contrast in game?

#2349 - remi59 - Sun Feb 02, 2003 9:55 am

Can one adjust the constrast of GBA without modifying the palette in MODE 0? How??

Thanks in advance!

@+
_________________
---@Remi59@---
BOMBERMAN ZERO
Soon in your GBA

#2351 - Lord Graga - Sun Feb 02, 2003 10:28 am

Code:
void DarkenBackgroundPalette(void)
{
   u16 i;
   for(i = 0; i < 256; i++)
      if(BGPaletteMem[i] - 1 >= 0)
         BGPaletteMem[i]--;
}
void LightenBackgroundPalette(void)
{
   u16 i;
   for(i = 0; i < 256; i++)
      if(BGPaletteMem[i] + 1 < 256)
         BGPaletteMem[i]++;
}
void DarkenSpritePalette(void)
{
   u16 i;
   for(i = 0; i < 256; i++)
      if(OBJPaletteMem[i] - 1 >= 0)
         OBJPaletteMem[i]--;
}
void LightenSpritePalette(void)
{
   u16 i;
   for(i = 0; i < 256; i++)
      if(OBJPaletteMem[i] + 1 < 256)
         OBJPaletteMem[i]++;
}

#2357 - Splam - Sun Feb 02, 2003 11:59 am

what on earth is that? Palettes are 16bit values RGB 555 so unfortunatly that code is nonsense ;) and even if it was 8bit for each r,g,b testing for < 256 then if it is adding 1 would allow values of 256 which would = 0 ie wrap.

-edit-
In my shocked state ;) I forgot to tell you how to do it..
Simply use the colour special effects modes. Theres probably something about it in one of the documents around but it simply involves setting a register (BLDCNT) to say which BGs you want to effect and that you're doing a colour darken or brighten effect, then another register (BLDY) holds the amount to effect it by. Used quite a lot for screen fades.

#2372 - darkcloud - Sun Feb 02, 2003 5:20 pm

I think this doc might help:
http://www.gbadev.org/files/mode0_blending.txt
It was in the gbadev doc section. It helped make it easier for me to play around with colour effects.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#3799 - wtuck - Sun Mar 09, 2003 9:57 am

I tried the code in the link.

http://www.gbadev.org/files/mode0_blending.txt

it works great, but...

On one of my layers I would like to have low contrast on it and when my sprit moves over a certian 32x32 tile it would highlight it (higher contrast for only that 32x32 section). I would perfer not to modify my palette since my other layers are using it. Any ideas?

#3802 - tepples - Sun Mar 09, 2003 3:10 pm

wtuck wrote:
On one of my layers I would like to have low contrast on it and when my sprit moves over a certian 32x32 tile it would highlight it (higher contrast for only that 32x32 section). I would perfer not to modify my palette since my other layers are using it. Any ideas?

For a flashlight effect as seen in Zelda III, you could use blending with windows. Or you could use a different 16-color palette for those tiles that are close to the hero (you are using 4-bit tiles, right?).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.