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



Rockbox mail archive

Subject: Re: Question on Config block/user_settings

Re: Question on Config block/user_settings

From: Linus Nielsen Feltzing <linus_at_haxx.se>
Date: Fri, 25 Apr 2003 11:02:35 +0200

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
Received on 2003-04-25

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy