fadein/fadeout in paletted screenmode

Post Reply
jotd
Posts: 32
Joined: Sun Dec 13, 2009 9:43 pm
Location: France
Contact:

fadein/fadeout in paletted screenmode

Post by jotd » Wed Dec 30, 2009 11:03 pm

Hi,

I'm using SDL to perform fadein/fadeout on my game.

On the PC in 24 bit mode I use alpha channel to perform this, but on the DS I have opened a 8 bit screen to save memory and CPU (maybe I'm misled because 16 bit depth would be better but I have tried this first and it was rather slow).

So my fadein/fadeout works on a PC with 8-bit screen because in this case I'm using palette manipulation (through SDL_SetPalette with hardware palette flag set). So it's OK SDL-wise. I have checked and the hardware palette flag is set for the screen.

The problem is that it's not working on a real DS. I don't see the transitions... The funniest thing is it works on IdeaS (a DS emulator): I see the fadein effect!! It does not work on No$GBA.

So is there some register to poke into to commit the changes? SDL for NDS has a lot of limitations & bugs, so I'm sure that this is not fully supported. I'm willing to fix this.

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: fadein/fadeout in paletted screenmode

Post by Discostew » Thu Dec 31, 2009 1:42 am

Not sure if you'd want to do this, but you can change the master brightness of your display output (not the actual display).
It doesn't give as smooth a transition because it is only 5-bits, but if you aren't doing really slow transitions, it may be adequate.

http://nocash.emubase.de/gbatek.htm#dsvideo

Code: Select all

400006Ch - NDS9 - MASTER_BRIGHT - 16bit - Master Brightness Up/Down

  0-4   Factor used for 6bit R,G,B Intensities (0-16, values >16 same as 16)
          Brightness up:   New = Old + (63-Old) * Factor/16
          Brightness down: New = Old - Old      * Factor/16
  5-13  Not used
  14-15 Mode (0=Disable, 1=Up, 2=Down, 3=Reserved)
That is just for the main display, but you can also change the sub display as well. (Both registers are defined already in the nds headers)

#define REG_MASTER_BRIGHT (*(vu16*)0x0400006C)
#define REG_MASTER_BRIGHT_SUB (*(vu16*)0x0400106C)

If you don't care about dealing with registers directly, there is a function in libnds that will handle everything for you.

Code: Select all

/** \brief
	\param screen 1 = main screen, 2 = subscreen, 3 = both
	\param level -16 = black, 0 = full brightness, 16 = white

*/
void setBrightness(int screen, int level);

jotd
Posts: 32
Joined: Sun Dec 13, 2009 9:43 pm
Location: France
Contact:

Re: fadein/fadeout in paletted screenmode

Post by jotd » Thu Dec 31, 2009 9:10 am

5 bits!!! That's more than enough. I have an Amiga so I know how to stay humble when it come to color.

I'll try this, looks very interesting for what I want to do. Thanks

EDIT: works fine and is very simple !!!! I hate this generic SDL shit when it comes to the DS: you have 2 registers to poke into, and they make you create a zillion structures to call a zillion stubbed code ... that does not work :)

thanks a lot!

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests