From 44171b99b6f8aa258cc574bce3ece3dfcc67812b Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Fri, 18 Jun 2004 20:41:59 +0000 Subject: New method of persisting the settings, using a central table. This saves lots of spaghetti code and saves ~6kB in .ajz size. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4772 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 1792 +++++++++++++++++++++++-------------------------------- 1 file changed, 737 insertions(+), 1055 deletions(-) (limited to 'apps/settings.c') diff --git a/apps/settings.c b/apps/settings.c index c9e281dae0..abf152fdf2 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -18,6 +18,7 @@ * ****************************************************************************/ #include +#include #include "config.h" #include "kernel.h" #include "thread.h" @@ -61,6 +62,7 @@ #include "sprintf.h" #include "keyboard.h" #include "version.h" +#include "rtc.h" #ifdef HAVE_MAS3507D void dac_line_in(bool enable); #endif @@ -69,9 +71,10 @@ char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ char rec_base_directory[] = REC_BASE_DIR; -#define CONFIG_BLOCK_VERSION 10 +#define CONFIG_BLOCK_VERSION 11 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 +#define MARKER 0x7FFFFFFF /* FIXME: to be removed with val2phys/phys2val */ #ifdef HAVE_LCD_BITMAP #define MAX_LINES 10 @@ -79,6 +82,28 @@ char rec_base_directory[] = REC_BASE_DIR; #define MAX_LINES 2 #endif +long lasttime = 0; +static unsigned char config_block[CONFIG_BLOCK_SIZE]; + + +/* descriptor for a configuration value */ +/* (watch the struct packing and member sizes to keep this small) */ +struct bit_entry +{ + /* how many bits within the bitfield (1-32), MSB set if value is signed */ + unsigned char bit_size; /* min 6+1 bit */ + /* how many bytes in the global_settings struct (1,2,4) */ + unsigned char byte_size; /* min 2 bits */ + /* store position in global_settings struct */ + short settings_offset; /* min 9 bit, better 10 */ + /* default value */ + int default_val; /* min 15 bit */ + /* variable name in a .cfg file, NULL if not to be saved */ + const char* cfg_name; + /* set of values, or NULL for a numerical value */ + const char* cfg_val; +}; + /******************************************** Config block as saved on the battery-packed RTC user RAM memory block @@ -87,89 +112,296 @@ of 44 bytes, starting at offset 0x14 of the RTC memory space. offset abs 0x00 0x14 "Roc" header signature: 0x52 0x6f 0x63 0x03 0x17 -0x04 0x18 -0x05 0x19 -0x06 0x1a -0x07 0x1b -0x08 0x1c -0x09 0x1d -0x0a 0x1e -0x0b 0x1f -0x0c 0x20 -0x0d 0x21 -0x0e 0x22 -0x0f 0x23 -0x10 0x24 -0x11 0x25 -0x12 0x26 <(short) Resume playlist index, or -1 if no playlist resume> -0x14 0x28 <(short) Resume playlist first index> -0x16 0x2a <(int) Byte offset into resume file> -0x1a 0x2e