Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Question on Config block/user_settings
From: Linus Nielsen Feltzing (linus_at_haxx.se)
Date: 2003-04-25


Björn Stenberg wrote:
> Looks good to me:
>
> Save - The caption boolean is converted to bit 1 of byte 0xAE:
>
> config_block[0xae] = (unsigned char)
> ((global_settings.fade_on_stop & 1) |
> ((global_settings.caption_backlight & 1) << 1));

Here you expect that bit 0 is set.

>
> Load - Bit 1 of byte 0xAE is converted to the caption boolean:
>
> global_settings.caption_backlight = config_block[0xae] & 2;

Here you set bit 1.

This doesn't look good to me. I think you should refrain from preying on
the internal representation of a bool. Do like this instead:

     config_block[0xae] = (unsigned char)
         ((global_settings.fade_on_stop?1:0) |
          (global_settings.caption_backlight?2:0));

Or at least set the bool to true when you load it:

         global_settings.caption_backlight = (config_block[0xae] &
2)?true:false;

/Linus



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa