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.

DS development > Master brightness not working with 3D? [Solved]

#144895 - Noda - Fri Nov 09, 2007 12:02 am

hmm I don't get why it's not working well, as according to Gbatek it should work...

here is my code to change master brightness:
Code:
// adjust screens brightness
void setBrightness(s8 bright) {

    // mode: fade to black/white
    u16 mode = 1 << 14;

   if (bright < 0) {
      mode = 2 << 14;
      bright = -bright;
   }

   if (bright > 31)
        bright = 31;

    // adjust main screen brightness
   *(volatile u16 *)(BRIGHTNESS) = bright + mode;

    // adjust sub screen brightness
    *(volatile u16 *)(SUB_BRIGHTNESS) = bright + mode;
}


I use 3D on both screen using the REG_CAPTURE method.

using setBrightness(-31) for example has absolutely no effect, whereas the screen should have become black.. :(

Any idea?


Last edited by Noda on Fri Nov 09, 2007 2:11 am; edited 1 time in total

#144898 - Cydrak - Fri Nov 09, 2007 12:35 am

If you're just using libnds, BRIGHTNESS isn't a pointer or some expression, it's already #defined to act like a variable.

Unless you redefined it, looks like you might be casting the actual brightness as a pointer...

#144906 - Noda - Fri Nov 09, 2007 2:11 am

Scored. Thank you for your help, it's working now (I've just ported this function from an old game of mine, juste renamed the register value without checking for the cast) ;)